diff --git a/git/.gitconfig b/git/.gitconfig index fb93374..ad7965b 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -40,6 +40,7 @@ bn = branch --no-merged pl = pull pt = push origin --tags + ph = push origin HEAD merge2 = !sh -c '_CURRENT_BRANCH=$(git symbolic-ref --short HEAD) && git checkout $1 && git merge $_CURRENT_BRANCH && git checkout $_CURRENT_BRANCH' - bg = "!f() { git branch | grep $1; }; f" delbr = "!f(){ git branch -D $(git branch | grep \"\b$1\"); };f" diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 23ec90d..ac0d857 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -13,6 +13,7 @@ "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform.nvim": { "branch": "master", "commit": "192a6d2ddace343f1840a8f72efe2315bd392243" }, "dashboard-nvim": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" }, "flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, diff --git a/nvim/lua/plugins/diffview.lua b/nvim/lua/plugins/diffview.lua new file mode 100644 index 0000000..e4a3402 --- /dev/null +++ b/nvim/lua/plugins/diffview.lua @@ -0,0 +1,3 @@ +return { + "sindrets/diffview.nvim", +} diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua index f8fb6a9..614d56a 100644 --- a/nvim/lua/plugins/gitsigns.lua +++ b/nvim/lua/plugins/gitsigns.lua @@ -4,25 +4,30 @@ return { opts = { signs = { -- TODO add hl to colorscheme - add = {hl = 'GitSignsAdd' , text = '▎', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, - change = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - delete = {hl = 'GitSignsDelete', text = '契', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - topdelete = {hl = 'GitSignsDelete', text = '契', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - changedelete = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - }, - numhl = false, - linehl = false, - watch_gitdir = { - interval = 1000 - }, - sign_priority = 6, - update_debounce = 200, - status_formatter = nil, -- Use default + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { + hl = "GitSignsChange", + text = "▎", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + }, + numhl = false, + linehl = false, + watch_gitdir = { + interval = 1000, + }, + sign_priority = 6, + update_debounce = 200, + status_formatter = nil, -- Use default on_attach = function(buffer) local gs = package.loaded.gitsigns - + local function map(mode, l, r, desc) - vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) + vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) end -- stylua: ignore start @@ -38,7 +43,8 @@ return { map("n", "ghd", gs.diffthis, "Diff This") map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") - end, - } - } -} \ No newline at end of file + end, + }, + }, +} + diff --git a/nvim/lua/plugins/mason.lua b/nvim/lua/plugins/mason.lua index 3bf3d96..d7353d1 100644 --- a/nvim/lua/plugins/mason.lua +++ b/nvim/lua/plugins/mason.lua @@ -6,12 +6,14 @@ return { "stylua", "selene", "luacheck", - "shellcheck", + "bashls", "shfmt", - "tailwindcss-language-server", - "typescript-language-server", - "css-lsp", + "tailwindcss", + "tsserver", + "pylyzer", + "cssls", }) end, }, -} \ No newline at end of file +} + diff --git a/nvim/lua/plugins/nvim-tree.lua b/nvim/lua/plugins/nvim-tree.lua index 0a1d3e1..0dc518f 100644 --- a/nvim/lua/plugins/nvim-tree.lua +++ b/nvim/lua/plugins/nvim-tree.lua @@ -1,38 +1,38 @@ local function my_on_attach(bufnr) - local api = require "nvim-tree.api" + local api = require("nvim-tree.api") - local function opts(desc) - return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } - end - - -- default mappings - api.config.mappings.default_on_attach(bufnr) - - -- custom mappings - vim.keymap.set('n', '', api.tree.change_root_to_parent, opts('Up')) - vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help')) - vim.keymap.set('n', 'l', api.node.open.edit, opts('Edit')) - vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Parent Close')) - vim.keymap.set('n', 's', api.node.open.horizontal, opts('Horizontal Split')) - vim.keymap.set('n', 'v', api.node.open.vertical, opts('Vertical Split')) + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- default mappings + api.config.mappings.default_on_attach(bufnr) + + -- custom mappings + vim.keymap.set("n", "", api.tree.change_root_to_parent, opts("Up")) + vim.keymap.set("n", "?", api.tree.toggle_help, opts("Help")) + vim.keymap.set("n", "l", api.node.open.edit, opts("Edit")) + vim.keymap.set("n", "h", api.node.navigate.parent_close, opts("Parent Close")) + vim.keymap.set("n", "s", api.node.open.horizontal, opts("Horizontal Split")) + vim.keymap.set("n", "v", api.node.open.vertical, opts("Vertical Split")) + vim.keymap.set("n", "", api.tree.reload, opts("Reload")) end vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent markers when folders are open -vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes. +vim.g.nvim_tree_auto_ignore_ft = "startify" --empty by default, don't auto open tree on specific filetypes. vim.g.nvim_tree_icons = { - default = '', - symlink = '', - git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""}, - folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""} + default = "", + symlink = "", + git = { unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = "" }, + folder = { default = "", open = "", empty = "", empty_open = "", symlink = "" }, } - return { { - 'nvim-tree/nvim-tree.lua', + "nvim-tree/nvim-tree.lua", dependencies = { - 'nvim-tree/nvim-web-devicons', -- optional + "nvim-tree/nvim-web-devicons", -- optional }, opts = { on_attach = my_on_attach, @@ -41,7 +41,7 @@ return { --auto_close = false, filters = { dotfiles = false, - custom = {} + custom = {}, }, git = { enable = true, @@ -50,14 +50,15 @@ return { }, update_focused_file = { -- enables the feature - enable = true, + enable = true, -- update the root directory of the tree to the one of the folder containing the file if the file is not under the current root directory -- only relevant when `update_focused_file.enable` is true - update_cwd = false, + update_cwd = false, -- list of buffer names / filetypes that will not update the cwd if the file isn't found under the current root directory -- only relevant when `update_focused_file.update_cwd` is true and `update_focused_file.enable` is true - ignore_list = {} + ignore_list = {}, }, }, }, -} \ No newline at end of file +} + diff --git a/script/tmux-init.sh b/script/tmux-init.sh new file mode 100755 index 0000000..616601b --- /dev/null +++ b/script/tmux-init.sh @@ -0,0 +1,20 @@ +#/bin/bash + +echo 'Init tmux config' +src=$HOME/.tmux.conf +if [ -e $src ]; then + mv $src $src.bak +fi +ln -s $HOME/.dotfile/tmux/.tmux.conf $src + + +echo 'Install tpm' +if [ ! -e ~/.tmux/plugins/tpm ]; then + git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm +fi + +echo 'Install tmux plugin by tpm' +$HOME/.tmux/plugins/tpm/bin/install_plugins + +echo 'Reload tmux' +tmux source ~/.tmux.conf \ No newline at end of file diff --git a/.tmux.conf b/tmux/.tmux.conf similarity index 75% rename from .tmux.conf rename to tmux/.tmux.conf index fb37b47..6f0bfb0 100644 --- a/.tmux.conf +++ b/tmux/.tmux.conf @@ -20,8 +20,8 @@ set-option -g mouse on # 绑定hjkl键为面板切换的上下左右键 bind k select-pane -U # 绑定k为↑ bind j select-pane -D # 绑定j为↓ -bind h select-pane -L # 绑定h为← -bind l select-pane -R # 绑定l为→ +#bind h select-pane -L # 绑定h为← +#bind l select-pane -R # 绑定l为→ # 绑定Ctrl+hjkl键为面板上下左右调整边缘的快捷指令 bind -r K resizep -U 10 # 绑定Ctrl+k为往↑调整面板边缘10个单元格 @@ -29,11 +29,13 @@ bind -r J resizep -D 10 # 绑定Ctrl+j为往↓调整面板边缘10个单元格 bind -r H resizep -L 10 # 绑定Ctrl+h为往←调整面板边缘10个单元格 bind -r L resizep -R 10 # 绑定Ctrl+l为往→调整面板边缘10个单元格 +bind -r j select-pane -t .+1 \; resize-pane -Z # prefix + j to switch pane in current window + # 设置tmux的延迟,文档说当有干扰的时候可以设置这个参数,比如影响vim编辑的时候 set -s escape-time 1 # 返回上一个窗口 -bind g last-window +bind L switch-client -l # 设置窗口名为当前目录名 set-option -g status-interval 10 @@ -44,5 +46,11 @@ set-option -g set-titles on #set-option -g set-titles-string "#{session_name} - #{host}" set-option -g set-titles-string "#{session_name}" -# tmux resurrect -run-shell ~/.tmux/plugins/tmux-resurrect/resurrect.tmux +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'junegunn/fzf' +set -g @plugin 'tmux-plugins/tmux-fzf' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.tmux/plugins/tpm/tpm'