From a3629d57245bbef426eed53188d779c69c17771a Mon Sep 17 00:00:00 2001 From: Philippe Serhal Date: Fri, 28 Apr 2023 10:26:08 -0400 Subject: [PATCH] chore: misc. 2022 vim updates --- .gitignore | 1 + vim/bundle/vim-fugitive/.gitattributes | 2 + vim/bundle/vim-fugitive/.github/FUNDING.yml | 2 + vim/bundle/vim-fugitive/CONTRIBUTING.markdown | 10 +- vim/bundle/vim-fugitive/README.markdown | 172 +- vim/bundle/vim-fugitive/autoload/fugitive.vim | 6517 +++++++++++++++++ vim/bundle/vim-fugitive/doc/fugitive.txt | 771 +- vim/bundle/vim-fugitive/ftdetect/fugitive.vim | 1 + vim/bundle/vim-fugitive/plugin/fugitive.vim | 3414 +-------- vim/bundle/vim-fugitive/syntax/fugitive.vim | 57 + .../vim-fugitive/syntax/fugitiveblame.vim | 7 + vimrc | 19 +- 12 files changed, 7631 insertions(+), 3342 deletions(-) create mode 100644 vim/bundle/vim-fugitive/.gitattributes create mode 100644 vim/bundle/vim-fugitive/.github/FUNDING.yml create mode 100644 vim/bundle/vim-fugitive/autoload/fugitive.vim create mode 100644 vim/bundle/vim-fugitive/ftdetect/fugitive.vim create mode 100644 vim/bundle/vim-fugitive/syntax/fugitive.vim create mode 100644 vim/bundle/vim-fugitive/syntax/fugitiveblame.vim diff --git a/.gitignore b/.gitignore index 225c528..de1f652 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ ssh/known_hosts ssh/id_rsa +vim/runtime/undo diff --git a/vim/bundle/vim-fugitive/.gitattributes b/vim/bundle/vim-fugitive/.gitattributes new file mode 100644 index 0000000..50afa41 --- /dev/null +++ b/vim/bundle/vim-fugitive/.gitattributes @@ -0,0 +1,2 @@ +.git* export-ignore +*.markdown export-ignore diff --git a/vim/bundle/vim-fugitive/.github/FUNDING.yml b/vim/bundle/vim-fugitive/.github/FUNDING.yml new file mode 100644 index 0000000..e2a49d1 --- /dev/null +++ b/vim/bundle/vim-fugitive/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: tpope +custom: ["https://www.paypal.me/vimpope"] diff --git a/vim/bundle/vim-fugitive/CONTRIBUTING.markdown b/vim/bundle/vim-fugitive/CONTRIBUTING.markdown index e651dca..843bbe6 100644 --- a/vim/bundle/vim-fugitive/CONTRIBUTING.markdown +++ b/vim/bundle/vim-fugitive/CONTRIBUTING.markdown @@ -8,8 +8,14 @@ platform issues, and interactions with other plugins. I end up bisecting a lot more than other projects, and thus I'm especially meticulous here about maintaining a clean, readable, history. Squash and force push any requested changes to a pull request. And if your [commit message -sucks](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), -I'm not going to accept it. Period. +sucks](https://commit.style), I'm not going to accept it. Period. + +If your contribution involves adding a configuration option, you are going to +need a very compelling justification for it. Options add a maintenance +burden, support burden, and documentation bloat, and oftentimes can be +achieved much more simply with a custom map or autocommand. If your option +controls an underlying Git command, ask yourself why Git itself does not offer +such configuration. Beyond that, don't be shy about asking before patching. What takes you hours might take me minutes simply because I have both domain knowledge and a diff --git a/vim/bundle/vim-fugitive/README.markdown b/vim/bundle/vim-fugitive/README.markdown index fd15cc9..198490a 100644 --- a/vim/bundle/vim-fugitive/README.markdown +++ b/vim/bundle/vim-fugitive/README.markdown @@ -1,55 +1,80 @@ # fugitive.vim -I'm not going to lie to you; fugitive.vim may very well be the best -Git wrapper of all time. Check out these features: - -View any blob, tree, commit, or tag in the repository with `:Gedit` (and -`:Gsplit`, `:Gvsplit`, `:Gtabedit`, ...). Edit a file in the index and -write to it to stage the changes. Use `:Gdiff` to bring up the staged -version of the file side by side with the working tree version and use -Vim's diff handling capabilities to stage a subset of the file's -changes. - -Bring up the output of `git status` with `:Gstatus`. Press `-` to -`add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch`. And guess -what `:Gcommit` does! - -`:Gblame` brings up an interactive vertical split with `git blame` -output. Press enter on a line to edit the commit where the line -changed, or `o` to open it in a split. When you're done, use `:Gedit` -in the historic buffer to go back to the work tree version. - -`:Gmove` does a `git mv` on a file and simultaneously renames the -buffer. `:Gdelete` does a `git rm` on a file and simultaneously deletes -the buffer. - -Use `:Ggrep` to search the work tree (or any arbitrary commit) with -`git grep`, skipping over that which is not tracked in the repository. -`:Glog` loads all previous revisions of a file into the quickfix list so -you can iterate over them and watch the file evolve! - -`:Gread` is a variant of `git checkout -- filename` that operates on the -buffer rather than the filename. This means you can use `u` to undo it -and you never get any warnings about the file changing outside Vim. -`:Gwrite` writes to both the work tree and index versions of a file, -making it like `git add` when called from a work tree file and like -`git checkout` when called from the index or a blob in history. - -Use `:Gbrowse` to open the current file on the web front-end of your favorite -hosting provider, with optional line range (try it in visual mode!). Built-in -support is provided for `git instaweb`, and plugins are available for popular -providers such as [GitHub][rhubarb.vim], [GitLab][fugitive-gitlab.vim], and -[Bitbucket][fubitive.vim]. +Fugitive is the premier Vim plugin for Git. Or maybe it's the premier Git +plugin for Vim? Either way, it's "so awesome, it should be illegal". That's +why it's called Fugitive. + +The crown jewel of Fugitive is `:Git` (or just `:G`), which calls any +arbitrary Git command. If you know how to use Git at the command line, you +know how to use `:Git`. It's vaguely akin to `:!git` but with numerous +improvements: + +* The default behavior is to directly echo the command's output. Quiet + commands like `:Git add` avoid the dreaded "Press ENTER or type command to + continue" prompt. +* `:Git commit`, `:Git rebase -i`, and other commands that invoke an editor do + their editing in the current Vim instance. +* `:Git diff`, `:Git log`, and other verbose, paginated commands have their + output loaded into a temporary buffer. Force this behavior for any command + with `:Git --paginate` or `:Git -p`. +* `:Git blame` uses a temporary buffer with maps for additional triage. Press + enter on a line to view the commit where the line changed, or `g?` to see + other available maps. Omit the filename argument and the currently edited + file will be blamed in a vertical, scroll-bound split. +* `:Git mergetool` and `:Git difftool` load their changesets into the quickfix + list. +* Called with no arguments, `:Git` opens a summary window with dirty files and + unpushed and unpulled commits. Press `g?` to bring up a list of maps for + numerous operations including diffing, staging, committing, rebasing, and + stashing. (This is the successor to the old `:Gstatus`.) +* This command (along with all other commands) always uses the current + buffer's repository, so you don't need to worry about the current working + directory. + +Additional commands are provided for higher level operations: + +* View any blob, tree, commit, or tag in the repository with `:Gedit` (and + `:Gsplit`, etc.). For example, `:Gedit HEAD~3:%` loads the current file as + it existed 3 commits ago. +* `:Gdiffsplit` brings up the staged version of the file side by side with the + working tree version. Use Vim's diff handling capabilities to apply changes + to the staged version, and write that buffer to stage the changes. You can + also give an arbitrary `:Gedit` argument to diff against older versions of + the file. +* `:Gread` is a variant of `git checkout -- filename` that operates on the + buffer rather than the file itself. This means you can use `u` to undo it + and you never get any warnings about the file changing outside Vim. +* `:Gwrite` writes to both the work tree and index versions of a file, making + it like `git add` when called from a work tree file and like `git checkout` + when called from the index or a blob in history. +* `:Ggrep` is `:grep` for `git grep`. `:Glgrep` is `:lgrep` for the same. +* `:GMove` does a `git mv` on the current file and changes the buffer name to + match. `:GRename` does the same with a destination filename relative to the + current file's directory. +* `:GDelete` does a `git rm` on the current file and simultaneously deletes + the buffer. `:GRemove` does the same but leaves the (now empty) buffer + open. +* `:GBrowse` to open the current file on the web front-end of your favorite + hosting provider, with optional line range (try it in visual mode). Plugins + are available for popular providers such as [GitHub][rhubarb.vim], + [GitLab][fugitive-gitlab.vim], [Bitbucket][fubitive.vim], + [Gitee][fugitive-gitee.vim], [Pagure][pagure], + [Phabricator][vim-phabricator], [Azure DevOps][fugitive-azure-devops.vim], + and [sourcehut][srht.vim]. [rhubarb.vim]: https://github.com/tpope/vim-rhubarb [fugitive-gitlab.vim]: https://github.com/shumphrey/fugitive-gitlab.vim [fubitive.vim]: https://github.com/tommcdo/vim-fubitive +[fugitive-gitee.vim]: https://github.com/linuxsuren/fugitive-gitee.vim +[pagure]: https://github.com/FrostyX/vim-fugitive-pagure +[vim-phabricator]: https://github.com/jparise/vim-phabricator +[fugitive-azure-devops.vim]: https://github.com/cedarbaum/fugitive-azure-devops.vim +[srht.vim]: https://git.sr.ht/~willdurand/srht.vim -Add `%{fugitive#statusline()}` to `'statusline'` to get an indicator -with the current branch in (surprise!) your statusline. +Add `%{FugitiveStatusline()}` to `'statusline'` to get an indicator +with the current branch in your statusline. -Last but not least, there's `:Git` for running any arbitrary command, -and `Git!` to open the output of a command in a temp file. +For more information, see `:help fugitive`. ## Screencasts @@ -61,53 +86,34 @@ and `Git!` to open the output of a command in a temp file. ## Installation -If you don't have a preferred installation method, one option is to install -[pathogen.vim](https://github.com/tpope/vim-pathogen), and then copy -and paste: +Install using your favorite package manager, or use Vim's built-in package support: - cd ~/.vim/bundle - git clone https://github.com/tpope/vim-fugitive.git - vim -u NONE -c "helptags vim-fugitive/doc" -c q - -If your Vim version is below 7.2, I recommend also installing -[vim-git](https://github.com/tpope/vim-git) for syntax highlighting and -other Git niceties. + mkdir -p ~/.vim/pack/tpope/start + cd ~/.vim/pack/tpope/start + git clone https://tpope.io/vim/fugitive.git + vim -u NONE -c "helptags fugitive/doc" -c q ## FAQ -> I installed the plugin and started Vim. Why don't any of the commands -> exist? - -Fugitive cares about the current file, not the current working -directory. Edit a file from the repository. - -> I opened a new tab. Why don't any of the commands exist? - -Fugitive cares about the current file, not the current working -directory. Edit a file from the repository. - -> Why is `:Gbrowse` not using the right browser? - -`:Gbrowse` delegates to `git web--browse`, which is less than perfect -when it comes to finding the right browser. You can tell it the correct -browser to use with `git config --global web.browser ...`. On macOS, for -example, you might want to set this to `open`. See `git web--browse --help` -for details. +> What happened to the dispatch.vim backed asynchronous `:Gpush` and +> `:Gfetch`? -> Here's a patch that automatically opens the quickfix window after -> `:Ggrep`. +This behavior was divisive, confusing, and complicated inputting passwords, so +it was removed. Use `:Dispatch git push` for effectively the same behavior, +or provide your own asynchronous `:Gpush` and `:Gfetch` by adding the +following to your vimrc: -This is a great example of why I recommend asking before patching. -There are valid arguments to be made both for and against automatically -opening the quickfix window. Whenever I have to make an arbitrary -decision like this, I ask what Vim would do. And Vim does not open a -quickfix window after `:grep`. + command! -bang -bar -nargs=* Gpush execute 'Dispatch -dir=' . + \ fnameescape(FugitiveGitDir()) 'git push' + command! -bang -bar -nargs=* Gfetch execute 'Dispatch -dir=' . + \ fnameescape(FugitiveGitDir()) 'git fetch' -Luckily, it's easy to implement the desired behavior without changing -fugitive.vim. The following autocommand will cause the quickfix window -to open after any grep invocation: +> So I have a symlink and... - autocmd QuickFixCmdPost *grep* cwindow +Stop. Just stop. If Git won't deal with your symlink, then Fugitive won't +either. Consider using a [plugin that resolves +symlinks](https://github.com/aymericbeaumet/symlink.vim), or even better, +using fewer symlinks. ## Self-Promotion diff --git a/vim/bundle/vim-fugitive/autoload/fugitive.vim b/vim/bundle/vim-fugitive/autoload/fugitive.vim new file mode 100644 index 0000000..6e48d9d --- /dev/null +++ b/vim/bundle/vim-fugitive/autoload/fugitive.vim @@ -0,0 +1,6517 @@ +" Location: autoload/fugitive.vim +" Maintainer: Tim Pope + +if exists('g:autoloaded_fugitive') + finish +endif +let g:autoloaded_fugitive = 1 + +if !exists('g:fugitive_git_executable') + let g:fugitive_git_executable = 'git' +elseif g:fugitive_git_executable =~# '^\w\+=' + let g:fugitive_git_executable = 'env ' . g:fugitive_git_executable +endif + +" Section: Utility + +function! s:function(name) abort + return function(substitute(a:name,'^s:',matchstr(expand(''), '.*\zs\d\+_'),'')) +endfunction + +function! s:sub(str,pat,rep) abort + return substitute(a:str,'\v\C'.a:pat,a:rep,'') +endfunction + +function! s:gsub(str,pat,rep) abort + return substitute(a:str,'\v\C'.a:pat,a:rep,'g') +endfunction + +function! s:Uniq(list) abort + let i = 0 + let seen = {} + while i < len(a:list) + let str = string(a:list[i]) + if has_key(seen, str) + call remove(a:list, i) + else + let seen[str] = 1 + let i += 1 + endif + endwhile + return a:list +endfunction + +function! s:winshell() abort + return has('win32') && &shellcmdflag !~# '^-' +endfunction + +function! s:WinShellEsc(arg) abort + if type(a:arg) == type([]) + return join(map(copy(a:arg), 's:shellesc(v:val)')) + elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' + return a:arg + else + return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' + endif +endfunction + +function! s:shellesc(arg) abort + if type(a:arg) == type([]) + return join(map(copy(a:arg), 's:shellesc(v:val)')) + elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' + return a:arg + elseif s:winshell() + return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' + else + return shellescape(a:arg) + endif +endfunction + +let s:fnameescape = " \t\n*?[{`$\\%#'\"|!<" +function! s:fnameescape(file) abort + if type(a:file) == type([]) + return join(map(copy(a:file), 's:fnameescape(v:val)')) + elseif exists('*fnameescape') + return fnameescape(a:file) + else + return escape(a:file, s:fnameescape) + endif +endfunction + +function! s:throw(string) abort + throw 'fugitive: '.a:string +endfunction + +function! s:DirCheck(...) abort + if !empty(a:0 ? s:Dir(a:1) : s:Dir()) + return '' + elseif empty(bufname('')) + return 'return ' . string('echoerr "fugitive: working directory does not belong to a Git repository"') + else + return 'return ' . string('echoerr "fugitive: file does not belong to a Git repository"') + endif +endfunction + +function! s:Mods(mods, ...) abort + let mods = substitute(a:mods, '\C', '', '') + let mods = mods =~# '\S$' ? mods . ' ' : mods + if a:0 && mods !~# '\<\%(aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright\|tab\)\>' + let mods = a:1 . ' ' . mods + endif + return substitute(mods, '\s\+', ' ', 'g') +endfunction + +if exists('+shellslash') + function! s:Slash(path) abort + return tr(a:path, '\', '/') + endfunction +else + function! s:Slash(path) abort + return a:path + endfunction +endif + +function! s:Resolve(path) abort + let path = resolve(a:path) + if has('win32') + let path = FugitiveVimPath(fnamemodify(fnamemodify(path, ':h'), ':p') . fnamemodify(path, ':t')) + endif + return path +endfunction + +function! s:FileIgnoreCase(for_completion) abort + return (exists('+fileignorecase') && &fileignorecase) + \ || (a:for_completion && exists('+wildignorecase') && &wildignorecase) +endfunction + +function! s:cpath(path, ...) abort + if s:FileIgnoreCase(0) + let path = FugitiveVimPath(tolower(a:path)) + else + let path = FugitiveVimPath(a:path) + endif + return a:0 ? path ==# s:cpath(a:1) : path +endfunction + +let s:executables = {} + +function! s:executable(binary) abort + if !has_key(s:executables, a:binary) + let s:executables[a:binary] = executable(a:binary) + endif + return s:executables[a:binary] +endfunction + +if !exists('s:temp_scripts') + let s:temp_scripts = {} +endif +function! s:TempScript(...) abort + let body = join(a:000, "\n") + if !has_key(s:temp_scripts, body) + let s:temp_scripts[body] = tempname() . '.sh' + endif + let temp = s:temp_scripts[body] + if !filereadable(temp) + call writefile(['#!/bin/sh'] + a:000, temp) + endif + return FugitiveGitPath(temp) +endfunction + +function! s:DoAutocmd(cmd) abort + if v:version >= 704 || (v:version == 703 && has('patch442')) + return 'doautocmd ' . a:cmd + elseif &modelines > 0 + return 'try|set modelines=0|doautocmd ' . a:cmd . '|finally|set modelines=' . &modelines . '|endtry' + else + return 'doautocmd ' . a:cmd + endif +endfunction + +let s:nowait = v:version >= 704 ? '' : '' + +function! s:Map(mode, lhs, rhs, ...) abort + for mode in split(a:mode, '\zs') + let flags = (a:0 ? a:1 : '') . (a:rhs =~# '' ? '' : '