From d90e912e46b4a294576dd2187a560e22cbdb306a Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 23 Jul 2019 20:42:34 -0400 Subject: [PATCH] Provide ignoring maps Closes https://github.com/tpope/vim-fugitive/issues/235 --- autoload/fugitive.vim | 20 ++++++++++++++++++++ doc/fugitive.txt | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index bd8e966..bfbc981 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1821,6 +1821,8 @@ function! fugitive#BufReadStatus() abort xnoremap g :echoerr 'Changed to X' nnoremap X :execute StageDelete(line('.'), 0, v:count) xnoremap X :execute StageDelete(line("'<"), line("'>"), v:count) + nnoremap gI :execute StageIgnore(line('.'), line('.'), v:count) + xnoremap gI :execute StageIgnore(line("'<"), line("'>"), v:count) nnoremap . : =StageArgs(0) xnoremap . : =StageArgs(1) nnoremap :help fugitive-mappings @@ -2854,6 +2856,23 @@ function! s:StageDelete(lnum1, lnum2, count) abort \ string('To restore, :Gedit ' . info.relative[0] . '|Gread ' . hash[0:6]) endfunction +function! s:StageIgnore(lnum1, lnum2, count) abort + let paths = [] + for info in s:Selection(a:lnum1, a:lnum2) + call extend(paths, info.relative) + endfor + call map(paths, '"/" . v:val') + exe 'Gsplit' (a:count ? '.gitignore' : '.git/info/exclude') + let last = line('$') + if last == 1 && empty(getline(1)) + call setline(last, paths) + else + call append(last, paths) + exe last + 1 + endif + return '' +endfunction + function! s:DoToggleHeadHeader(value) abort exe 'edit' s:fnameescape(s:Dir()) call search('\C^index$', 'wc') @@ -4881,6 +4900,7 @@ function! fugitive#MapJumps(...) abort nnoremap cp :echoerr 'Use gC' nnoremap gC :exe 'Gpedit ' . fnameescape(ContainingCommit()) nnoremap gc :exe 'Gpedit ' . fnameescape(ContainingCommit()) + nnoremap gi :exe 'Gsplit' (v:count ? '.gitignore' : '.git/info/exclude') nnoremap c- :Gcommit - nnoremap c :Gcommit diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 079dbc1..8ac2219 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -270,6 +270,10 @@ X Discard the change under the cursor. This uses *fugitive_<* < Remove the inline diff of the file under the cursor. + *fugitive_gI* +gI Open .git/info/exclude in a split and add the file + under the cursor. Use a count to open .gitignore. + P Invoke |:Git| add --patch or reset --patch on the file under the cursor. On untracked files, this instead calls |:Git| add --intent-to-add. @@ -352,6 +356,10 @@ gP Jump to "Unpulled" section. *fugitive_gr* gr Jump to "Rebasing" section. + *fugitive_gi* +gi Open .git/info/exclude in a split. Use a count to + open .gitignore. + *fugitive_c* Commit mappings ~