nvim: plugins: Drop fugitive
With our switch to jujutsu, all of this is of no use any more.
This commit is contained in:
parent
0c275b10d0
commit
946b0504da
4 changed files with 0 additions and 371 deletions
|
@ -1,21 +0,0 @@
|
|||
nnoremap <buffer> <silent>q :bwipeout!<CR>
|
||||
|
||||
nnoremap <buffer> <Leader>gb :call git#git_branch_checkout()<CR>
|
||||
nnoremap <buffer> <Leader>gB :call git#git_branch_delete()<CR>
|
||||
nnoremap <buffer> <Leader>gc :call git#git_cherry_pick()<CR>
|
||||
xnoremap <buffer> <Leader>gC :<C-U>call git#git_cherry_pick_range()<CR>
|
||||
nnoremap <buffer> <Leader>gd :call git#git_diff_commit()<CR>
|
||||
nnoremap <buffer> <Leader>gD :call git#git_difftool_commit()<CR>
|
||||
nnoremap <buffer> <Leader>gf :call git#git_format_patch()<CR>
|
||||
xnoremap <buffer> <Leader>gf :call git#git_format_patch_range()<CR>
|
||||
nnoremap <buffer> <Leader>gl :call git#git_branch_log()<CR>
|
||||
nnoremap <buffer> <Leader>gL :call git#git_branch_log_pretty()<CR>
|
||||
nnoremap <buffer> <Leader>gR :call git#git_reflog_restore()<CR>
|
||||
|
||||
nnoremap <buffer> <expr> <Leader>gn git#git_branch_rename()
|
||||
nnoremap <buffer> <expr> <Leader>gp git#git_push_commit()
|
||||
nnoremap <buffer> <expr> <Leader>gr git#git_rebase_branch()
|
||||
|
||||
" Jump to sections of diff
|
||||
nnoremap <buffer> [c ?^@@<CR>
|
||||
nnoremap <buffer> ]c /^@@<CR>
|
|
@ -1,46 +0,0 @@
|
|||
nnoremap <Leader>ga :Git add %<CR>
|
||||
nnoremap <Leader>gA :Git reset HEAD %<CR>
|
||||
xnoremap <Leader>gb :Git blame -w -C -C -C -M<CR>
|
||||
nnoremap <Leader>gb :keepalt Git branch -a<CR>
|
||||
nnoremap <Leader>gB :keepalt Git branch<SPACE>
|
||||
nnoremap <Leader>gc :Git checkout -b<SPACE>
|
||||
nnoremap <Leader>gC :Git checkout<SPACE>
|
||||
nnoremap <Leader>gd :Git difftool<CR>
|
||||
nnoremap <Leader>gD :Git difftool -y<CR>
|
||||
nnoremap <Leader>ge :sp<CR>:Gedit HEAD~:%<Left><Left>
|
||||
nnoremap <Leader>gE :sp<CR>:Gedit :%:p<Left><Left><Left><Left>
|
||||
nnoremap <Leader>gf :Git fetch --all --tags -f<CR>
|
||||
nnoremap <Leader>gF :call git#git_fetch_origin_merge()<CR>
|
||||
nnoremap <Leader>gg :Git<CR>
|
||||
nnoremap <Leader>gh :keepalt Git log --grep=
|
||||
nnoremap <Leader>gH :<C-U>keepalt Git log -G<C-r><C-w>
|
||||
nnoremap <Leader>gk :call git#git_review()<CR>
|
||||
nnoremap <Leader>gK :call git#git_review_fileview()<CR>
|
||||
nnoremap <Leader>gl :keepalt Git log --stat %<CR>
|
||||
nnoremap <Leader>gL :keepalt Git log --stat -n 100<CR>
|
||||
xnoremap <Leader>gl :<C-U>call git#git_log_range()<CR>
|
||||
xnoremap <Leader>gL :call git#git_log_named_block()<CR>
|
||||
nnoremap <Leader>gm :0,3Git blame -w -C -C -C -M<CR><C-w>j<CR>
|
||||
nnoremap <Leader>gM :call git#git_merge_origin()<CR>
|
||||
nnoremap <Leader>gn :Git branch -m<SPACE>
|
||||
nnoremap <Leader>go :call git#git_log_compare()<CR>
|
||||
nnoremap <Leader>gr :keepalt Ggrep! -q<SPACE>
|
||||
nnoremap <Leader>gR :call git#git_rebase_origin()<CR>
|
||||
nnoremap <Leader>g- :call git#git_stash()<CR>:e<CR>
|
||||
nnoremap <Leader>g+ :Git stash pop stash@
|
||||
nnoremap <Leader>gs :Git stash list<CR>
|
||||
nnoremap <Leader>gS :Git stash -- %<CR>
|
||||
nnoremap <Leader>gt :keepalt Git reflog<CR>
|
||||
nnoremap <Leader>gw :Gwrite<CR>
|
||||
nnoremap <Leader>G :keepalt Git<SPACE>
|
||||
|
||||
nnoremap <Leader>gp :call git#git_push_to_upstream()<CR>
|
||||
nnoremap <expr> <Leader>gP git#git_push()
|
||||
nnoremap <expr> <Leader>gO git#git_show_file_on_branch()
|
||||
|
||||
augroup custom_fugitive
|
||||
autocmd!
|
||||
autocmd BufReadPost fugitive://* setlocal bufhidden=wipe
|
||||
autocmd User FugitiveObject,FugitiveIndex nnoremap <buffer><silent> q :bwipeout!<CR>
|
||||
autocmd User FugitiveIndex nmap <buffer> dt :Gtabedit <Plug><cfile><Bar>Gdiffsplit!<Bar>only<CR>
|
||||
augroup END
|
|
@ -1,303 +0,0 @@
|
|||
" The purpose of creating this autoload is with functions like git_branch_log
|
||||
" which opens another 'git' filetype buffer defining such a function in
|
||||
" after/ftplugin/ft.vim results in a complain about duplicated function since
|
||||
" anything defined there will be loaded again. See :help autoload.
|
||||
|
||||
" Delete the branch on the current line in the output of Git branch -a.
|
||||
function! git#git_branch_delete() abort
|
||||
let line = trim(getline('.'))
|
||||
let branch = split(line, "/")
|
||||
if len(branch) == 1
|
||||
" Handles the case for local branch
|
||||
execute "keepalt Git branch -D " . branch[0]
|
||||
else
|
||||
" Handles the case for remote remotes/remote_name/branch_name
|
||||
let remote = branch[1]
|
||||
let branch = branch[2]
|
||||
execute "keepalt Git push -d " . remote . " " . branch
|
||||
execute "keepalt Git branch -D " . branch
|
||||
endif
|
||||
silent execute "keepalt bw"
|
||||
endfunction
|
||||
|
||||
" Checkout the branch on the current line in the output of Git branch -a.
|
||||
function! git#git_branch_checkout() abort
|
||||
let line = trim(getline('.'))
|
||||
let branch = split(line, "/")
|
||||
if len(branch) == 1
|
||||
" Handles the case for local branch
|
||||
silent execute "keepalt Git checkout " . branch[0]
|
||||
else
|
||||
" Handles the case for remote remotes/remote_name/branch_name
|
||||
let remote = join(branch[1:2], "/")
|
||||
silent execute "keepalt Git checkout " . remote
|
||||
silent execute "keepalt Git checkout -b " . branch[2]
|
||||
silent execute "keepalt Git branch --set-upstream-to=" . remote . " " . branch[2]
|
||||
endif
|
||||
silent execute "keepalt bw"
|
||||
endfunction
|
||||
|
||||
" Populate the command line with git command to rename branch on current line.
|
||||
" Run Git branch -a first. Not for renaming current branch.
|
||||
function! git#git_branch_rename() abort
|
||||
let branch_to_rename = trim(getline('.'))
|
||||
return ":Git branch -m " . branch_to_rename . " "
|
||||
endfunction
|
||||
|
||||
" Get the log of the branch on current line in the output of Git branch -a.
|
||||
function! git#git_branch_log() abort
|
||||
let line = trim(getline('.'))
|
||||
let branch = split(line, "/")
|
||||
" Close the buffer opened by Git branch -a
|
||||
silent execute "bw"
|
||||
if len(branch) == 1
|
||||
" Handles the case for local branch
|
||||
execute "keepalt Git log " . branch[0]
|
||||
else
|
||||
" Handles the case for remote remotes/remote_name/branch_name
|
||||
let remote = join(branch[1:2], "/")
|
||||
execute "keepalt Git log " . remote
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Get the log of the branch on current line in the output of Git branch -a.
|
||||
" This one returns a log where a line has the form <SHA> <commit-msg>. This
|
||||
" acts as a precursor to what we run cherry-pick on.
|
||||
function! git#git_branch_log_pretty() abort
|
||||
let line = trim(getline('.'))
|
||||
let branch = split(line, "/")
|
||||
" Close the buffer opened by Git branch -a
|
||||
silent execute "bw"
|
||||
if len(branch) == 1
|
||||
" Handles the case for local branch
|
||||
execute "keepalt Git log --pretty=oneline --no-merges " . branch[0]
|
||||
else
|
||||
" Handles the case for remote remotes/remote_name/branch_name
|
||||
let remote = join(branch[1:2], "/")
|
||||
execute "keepalt Git log --pretty=oneline --no-merges " . remote
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Run Git cherry-pick on the commit in the line which we are at. To be used
|
||||
" after running some variation of Git log.
|
||||
function! git#git_cherry_pick() abort
|
||||
" A line in Git log is of the form commit <SHA>
|
||||
let line = trim(getline('.'))
|
||||
let commit = split(line, " ")
|
||||
silent execute "keepalt Git cherry-pick " . commit[1]
|
||||
endfunction
|
||||
|
||||
" Git cherry-pick a range of commits. To be run on output of Git log
|
||||
" --pretty=oneline. See git_branch_log_pretty.
|
||||
function! git#git_cherry_pick_range() abort
|
||||
let [lnum1, col1] = getpos("'<")[1:2]
|
||||
let [lnum2, col2] = getpos("'>")[1:2]
|
||||
let lines = reverse(getline(lnum1, lnum2))
|
||||
if len(lines) == 0
|
||||
return ''
|
||||
endif
|
||||
let oldCommit = split(lines[0], " ")[:0][0]
|
||||
let newCommit = split(lines[-1], " ")[:0][0]
|
||||
execute "keepalt Git cherry-pick " . oldCommit . "^.." . newCommit
|
||||
silent execute "keepalt bw"
|
||||
endfunction
|
||||
|
||||
" Run Git diff on the commit in the line which we are at. To be used after
|
||||
" running some variation of Git log.
|
||||
function! git#git_diff_commit() abort
|
||||
" A line in Git log is of the form commit <SHA>
|
||||
let line = trim(getline('.'))
|
||||
let commit = split(line, " ")
|
||||
execute "Gtabedit | Git diff " . commit[1] . "^ " . commit[1] . "| only"
|
||||
endfunction
|
||||
|
||||
" Run Git difftool on the commit in the line which we are at. To be used after
|
||||
" running some variation of Git log.
|
||||
function! git#git_difftool_commit() abort
|
||||
" A line in Git log is of the form commit <SHA>
|
||||
let line = trim(getline('.'))
|
||||
let commit = split(line, " ")
|
||||
execute "Gtabedit | Git difftool " . commit[1] . "^ " . commit[1]
|
||||
endfunction
|
||||
|
||||
" To be used after running some variation of Git log.
|
||||
function! git#git_format_patch() abort
|
||||
" A line in Git log is of the form commit <SHA>
|
||||
let line = trim(getline('.'))
|
||||
let commit = split(line, " ")
|
||||
execute "keepalt Git format-patch " . commit[1] . "~1"
|
||||
endfunction
|
||||
|
||||
" Git format-patch a range of commits. To be run on output of Git log
|
||||
" --pretty=oneline. See git_branch_log_pretty.
|
||||
function! git#git_format_patch_range() abort
|
||||
let [lnum1, col1] = getpos("'<")[1:2]
|
||||
let [lnum2, col2] = getpos("'>")[1:2]
|
||||
let lines = reverse(getline(lnum1, lnum2))
|
||||
if len(lines) == 0
|
||||
return ''
|
||||
endif
|
||||
let oldCommit = split(lines[0], " ")[:0][0]
|
||||
let newCommit = split(lines[-1], " ")[:0][0]
|
||||
execute "keepalt Git format-patch " . oldCommit . "~1.." . newCommit
|
||||
silent execute "keepalt bw"
|
||||
endfunction
|
||||
|
||||
" The next two functions allow scoping diffs by line range of a file and named
|
||||
" block in a file. Inspired by reading the following article.
|
||||
" https://susanpotter.net/software/tracking-diffs-by-scoping-to-file-range-function-method-or-class-changes-in-git/
|
||||
|
||||
" Use these two links as reference to come up with this function
|
||||
" https://vi.stackexchange.com/questions/17606/vmap-and-visual-block-how-do-i-write-a-function-to-operate-once-for-the-entire
|
||||
" https://stackoverflow.com/questions/41238238/how-to-map-vim-visual-mode-to-replace-my-selected-text-parts
|
||||
function! git#git_log_range() abort
|
||||
let [lnum1, col1] = getpos("'<")[1:2]
|
||||
let [lnum2, col2] = getpos("'>")[1:2]
|
||||
silent execute "keepalt Git log --no-patch -L " . lnum1 . "," . lnum2 . ":%"
|
||||
endfunction
|
||||
|
||||
" Taken from https://learnvimscriptthehardway.stevelosh.com/chapters/33.html.
|
||||
" Modified and stripped to do what I needed.
|
||||
function! git#git_log_named_block() abort
|
||||
normal! `<v`>y
|
||||
silent execute "keepalt Git log --no-patch -L :" . trim(shellescape(@@)) . ":%"
|
||||
endfunction
|
||||
|
||||
" Compares current branch against master. For eg. git log master..current.
|
||||
" This combined with Git diff are helpful for MR reviews.
|
||||
function! git#git_log_compare() abort
|
||||
let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/')
|
||||
let current = trim(system('git branch --show-current'))
|
||||
let are_we_on_default = match(default[3], current)
|
||||
if (are_we_on_default == 0)
|
||||
echom "We are already on default branch. Nothing to compare."
|
||||
else
|
||||
silent execute "keepalt Git log " . default[3] . ".." . current
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Merge remote origin:master/main into local:master/main
|
||||
function! git#git_fetch_origin_merge() abort
|
||||
let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/')
|
||||
execute "Git fetch origin " . default[3] . ":" . default[3]
|
||||
endfunction
|
||||
|
||||
" Figures out whether default branch is main or master and runs git merge.
|
||||
function! git#git_merge_origin() abort
|
||||
let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/')
|
||||
let current = trim(system("git branch --show-current"))
|
||||
let are_we_on_default = match(default[3], current)
|
||||
if (are_we_on_default == 0)
|
||||
echom "Merging origin/" . default[3]
|
||||
execute "Git merge origin/" . default[3]
|
||||
else
|
||||
echom "Not on " . default[3]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! git#git_push_to_upstream() abort
|
||||
let current = trim(system("git branch --show-current"))
|
||||
let upstream = split(trim(system('git rev-parse --abbrev-ref ' . current . '@{upstream}')), '/')
|
||||
if len(upstream) != 2
|
||||
echom "Upstream not set for branch " . current
|
||||
else
|
||||
execute "Git push -u " . upstream[0] . " " . upstream[1]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! git#git_push() abort
|
||||
let current = trim(system("git branch --show-current"))
|
||||
let upstream = split(trim(system('git rev-parse --abbrev-ref ' . current . '@{upstream}')), '/')
|
||||
if len(upstream) != 2
|
||||
echom "Upstream not set for branch " . current
|
||||
return ":Git push -u " . " " . current
|
||||
else
|
||||
return ":Git push --force-with-lease -u " . upstream[0] . " " . upstream[1]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" To be used after calling Git log and cursor on the commit line.
|
||||
function! git#git_push_commit() abort
|
||||
let line = trim(getline('.'))
|
||||
let commit = split(line, " ")[1]
|
||||
let current = trim(system("git branch --show-current"))
|
||||
let upstream = split(trim(system('git rev-parse --abbrev-ref ' . current . '@{upstream}')), '/')
|
||||
if len(upstream) != 2
|
||||
echom "Upstream not set for branch " . current
|
||||
return ":Git push -u " . " " . current
|
||||
else
|
||||
return ":Git push -u " . upstream[0] . " " . commit . ":" . upstream[1]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Rebase the current checked out branch to the branch on the current line.
|
||||
" Git branch -a should be run before this.
|
||||
function! git#git_rebase_branch() abort
|
||||
let line = trim(getline('.'))
|
||||
let branch = split(line, "/")
|
||||
if len(branch) == 1
|
||||
" Handles the case for local branch
|
||||
return ":Git rebase HEAD~" . " --onto " . branch[0]
|
||||
else
|
||||
" Handles the case for remote remotes/remote_name/branch_name
|
||||
let remote = branch[1]
|
||||
let branch = branch[2]
|
||||
return ":Git rebase HEAD~" . " --onto " . remote . "/" . branch
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Git reflog should be run first before invoking this
|
||||
function! git#git_reflog_restore() abort
|
||||
let line = trim(getline('.'))
|
||||
" A line in git reflog is of the form below
|
||||
" f6a8c7ed4 HEAD@{73}: rebase (pick): gst-rtmp: Add mux queues to stats gathering
|
||||
let sl1 = split(line, ":")
|
||||
" sl1[0] will give f6a8c7ed4 HEAD@{73} for above example
|
||||
let sl2 = split(sl1[0], " ")
|
||||
" sl2[0] will have f6a8c7ed4 and sl2[1] will have HEAD@{73}
|
||||
echom "Command executed will be: Git reset --hard " . sl2[1]
|
||||
call inputsave()
|
||||
let restore = input('Restore to: ' . line . '. Enter y to proceed: ')
|
||||
call inputrestore()
|
||||
let to_restore = match(restore, 'y')
|
||||
if (to_restore == 0)
|
||||
execute "keepalt Git reset --hard " . sl2[1]
|
||||
else
|
||||
echom "Not restoring to " . line
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Figures out whether default branch is main or master and runs git rebase.
|
||||
function! git#git_rebase_origin() abort
|
||||
let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/')
|
||||
echom "Rebasing current branch on origin/" . default[3]
|
||||
execute "Git rebase origin/" . default[3]
|
||||
endfunction
|
||||
|
||||
" Opens the output of Git difftool main...<current_branch> for review
|
||||
function! git#git_review() abort
|
||||
let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/')
|
||||
let current = trim(system("git branch --show-current"))
|
||||
execute "Gtabedit | Git difftool " . default[3] . "..." . current
|
||||
endfunction
|
||||
|
||||
" Opens the output of Git difftool main...<current_branch> for review. Each
|
||||
" file is opened in a tab.
|
||||
function! git#git_review_fileview() abort
|
||||
let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/')
|
||||
let current = trim(system("git branch --show-current"))
|
||||
execute "Git difftool -y " . default[3] . "..." . current
|
||||
endfunction
|
||||
|
||||
" Show file on another branch without changing current branch
|
||||
function! git#git_show_file_on_branch() abort
|
||||
return ":Git show :" . expand("%")
|
||||
endfunction
|
||||
|
||||
" Generate a helpful name when using Git stash
|
||||
function! git#git_stash() abort
|
||||
let current = trim(system("git branch --show-current"))
|
||||
let current_time = strftime("%Y-%b-%d_%H-%M")
|
||||
let stash_name = current . "-" . current_time
|
||||
execute "Git stash push -m " . stash_name
|
||||
endfunction
|
|
@ -10,7 +10,6 @@ require "paq" {
|
|||
'dcampos/nvim-snippy' ,
|
||||
'honza/vim-snippets' ,
|
||||
-- Git
|
||||
'tpope/vim-fugitive' ,
|
||||
'SanchayanMaity/gitlinker.nvim' ,
|
||||
-- Quickfix
|
||||
'yorickpeterse/nvim-pqf' ,
|
||||
|
|
Loading…
Reference in a new issue