diff --git a/.zshrc b/.zshrc index 65dec73..1c51daa 100644 --- a/.zshrc +++ b/.zshrc @@ -110,12 +110,16 @@ export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebr export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" export HOMEBREW_NO_AUTO_UPDATE=true # 禁止 brew 每次安装软件都 upate +# git +export REVIEW_BASE="master" + # go export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin export GOPROXY=goproxy.cn export GOSUMDB="sum.golang.google.cn" + [ -f ~/.zprofile ] && source ~/.zprofile [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh diff --git a/git/.gitconfig b/git/.gitconfig index 7d1e6f0..7772065 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -6,6 +6,14 @@ quotepath = false editor = /usr/local/bin/nvim excludesfile = ~/.dotfile/git/.gitignore +[push] + default = current +[merge] + tool = vimdiff +[include] + path = ~/.subgitconfig +[branch] + autoSetupMerge = always [alias] au = add -u co = checkout @@ -20,11 +28,20 @@ delbr = "!f(){ git branch -D $(git branch | grep \"\b$1\"); };f" can = commit --amend --no-edit cleanbr = "!git branch --merged master | grep -v '\\*\\|master\\|main' | xargs -n 1 git branch -d" -[push] - default = current -[merge] - tool = vimdiff -[include] - path = ~/.subgitconfig -[branch] - autoSetupMerge = always + # list files which have changed since REVIEW_BASE + # (REVIEW_BASE defaults to 'master' in my zshrc) + files = !git diff --name-only $(git merge-base HEAD \"$REVIEW_BASE\") + + # Same as above, but with a diff stat instead of just names + # (better for interactive use) + stat = !git diff --stat $(git merge-base HEAD \"$REVIEW_BASE\") + # Open all files changed since REVIEW_BASE in Vim tabs + # Then, run fugitive's :Gdiff in each tab, and finally + # tell vim-gitgutter to show +/- for changes since REVIEW_BASE + review = !vim -p $(git files) +\"tabdo Gdiffsplit $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\" + + # Same as the above, except specify names of files as arguments, + # instead of opening all files: + # git reviewone foo.js bar.js + reviewone = !vim -p +\"tabdo Gdiff $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\" + diff --git a/nvim/ftplugin/typescript.lua b/nvim/ftplugin/typescript.lua new file mode 100644 index 0000000..2634b42 --- /dev/null +++ b/nvim/ftplugin/typescript.lua @@ -0,0 +1,2 @@ +vim.cmd('set ts=2') -- Insert 2 spaces for a tab +vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation diff --git a/nvim/lua/pluginconfig/which-key.lua b/nvim/lua/pluginconfig/which-key.lua index 2ec6993..8f561e8 100644 --- a/nvim/lua/pluginconfig/which-key.lua +++ b/nvim/lua/pluginconfig/which-key.lua @@ -136,11 +136,13 @@ local mappings = { t = { "NvimTreeToggle", "toggle nvim tree" }, r = { "RnvimrToggle", "toggle rnvimr" }, y = { "lua require'utils'.yank_filepath()", "copy the file path" }, + d = { "lua require'utils'.yank_file_dir()", "copy the file path" }, l = { "NvimTreeFindFile", "find file" }, -- T = {"let @+ = 'go test -v -run='+expand('')", "get current word in go test"}, }, g = { name = "+Git", + m = {"Gvdiff master:%", "Diff with master"}, j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, l = { "lua require 'gitsigns'.blame_line()", "Blame" }, diff --git a/nvim/lua/utils/init.lua b/nvim/lua/utils/init.lua index 77e8211..b1d4790 100644 --- a/nvim/lua/utils/init.lua +++ b/nvim/lua/utils/init.lua @@ -4,10 +4,19 @@ local lv_utils = {} -- copy current filepath to clipboard function lv_utils.yank_filepath() local p = vim.fn.expand('%:p') + local line = vim.fn.line(".") + p = p..":"..line print(p) vim.fn.setreg('+',p) end +function lv_utils.yank_file_dir() + local p = vim.fn.expand('%:p:h') + print(p) + vim.fn.setreg('+',p) +end + + function lv_utils.open_md() local p = vim.fn.expand('%:p') vim.fn.system("open -a typora "..p)