From a9f48d2d5976d76a112809882f93549409f6906c Mon Sep 17 00:00:00 2001 From: Laily Date: Tue, 11 Jun 2024 17:53:43 +0800 Subject: [PATCH 1/4] fix: add git alias --- git/.gitconfig | 1 + nvim/lua/plugins/gitsigns.lua | 46 ++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 20 deletions(-) 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/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, + }, + }, +} + From d97fb14d1fadb3cf9a05963071b71c937ffa87af Mon Sep 17 00:00:00 2001 From: Laily Date: Wed, 12 Jun 2024 17:49:36 +0800 Subject: [PATCH 2/4] fix: modify mason server --- nvim/lua/plugins/mason.lua | 12 ++++--- nvim/lua/plugins/nvim-tree.lua | 57 +++++++++++++++++----------------- 2 files changed, 36 insertions(+), 33 deletions(-) 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 +} + From 785d8bde8c51b2021c3198b910e609ae2c3bb062 Mon Sep 17 00:00:00 2001 From: Laily Date: Wed, 19 Jun 2024 12:22:18 +0800 Subject: [PATCH 3/4] feat: add tpm for tmux --- nvim/lazy-lock.json | 1 + nvim/lua/plugins/diffview.lua | 3 +++ script/tmux-init.sh | 20 ++++++++++++++++++++ .tmux.conf => tmux/.tmux.conf | 10 ++++++++-- 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 nvim/lua/plugins/diffview.lua create mode 100755 script/tmux-init.sh rename .tmux.conf => tmux/.tmux.conf (84%) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index d47e1b8..bd744c5 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": "6dc1603ea408f476a57937bbeaf7f86520a21a98" }, "dashboard-nvim": { "branch": "master", "commit": "a0a78099658c7d4be3714f657b18ca8285d5d106" }, + "diffview.nvim": { "branch": "main", "commit": "3afa6a053f680e9f1329c4a151db988a482306cd" }, "dressing.nvim": { "branch": "master", "commit": "5162edb1442a729a885c45455a07e9a89058be2f" }, "flash.nvim": { "branch": "main", "commit": "7bb4a9c75d1e20cd24185afedeaa11681829ba23" }, "friendly-snippets": { "branch": "main", "commit": "3e9a3f5a0cfcef1741e352c37bda4e82e5eb846a" }, 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/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 84% rename from .tmux.conf rename to tmux/.tmux.conf index fb37b47..33ccc7a 100644 --- a/.tmux.conf +++ b/tmux/.tmux.conf @@ -44,5 +44,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' \ No newline at end of file From a64b47a65f185cc33b441adafc6cd77370602245 Mon Sep 17 00:00:00 2001 From: Laily Date: Thu, 20 Jun 2024 15:33:12 +0800 Subject: [PATCH 4/4] feat: add shortcut of swith pane --- tmux/.tmux.conf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index 33ccc7a..6f0bfb0 100644 --- a/tmux/.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 @@ -51,4 +53,4 @@ 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' \ No newline at end of file +run '~/.tmux/plugins/tpm/tpm'