diff --git a/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim index 5dd11c12..eb60ce77 100644 --- a/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim +++ b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim @@ -29,6 +29,6 @@ call ale#linter#Define('clojure', { \ 'name': 'clj-kondo', \ 'output_stream': 'stdout', \ 'executable': 'clj-kondo', -\ 'command': 'clj-kondo --lint %t', +\ 'command': 'clj-kondo --cache --lint %t', \ 'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim index 3c6854fa..66c075be 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim @@ -174,6 +174,7 @@ endfunction call ale#linter#Define('kotlin', { \ 'name': 'kotlinc', \ 'executable': 'kotlinc', +\ 'output_stream': 'stderr', \ 'command': function('ale_linters#kotlin#kotlinc#RunWithImportPaths'), \ 'callback': 'ale_linters#kotlin#kotlinc#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/scala/metals.vim b/sources_non_forked/ale/ale_linters/scala/metals.vim index f78c7119..da9e855d 100644 --- a/sources_non_forked/ale/ale_linters/scala/metals.vim +++ b/sources_non_forked/ale/ale_linters/scala/metals.vim @@ -32,6 +32,8 @@ function! ale_linters#scala#metals#GetProjectRoot(buffer) abort \) endif endfor + + return '' endfunction function! ale_linters#scala#metals#GetCommand(buffer) abort diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim b/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim new file mode 100644 index 00000000..e2408c15 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim @@ -0,0 +1,25 @@ +" Author: OJFord +" Description: terraform-lsp integration for ALE (cf. https://github.com/juliosueiras/terraform-lsp) + +call ale#Set('terraform_langserver_executable', 'terraform-lsp') +call ale#Set('terraform_langserver_options', '') + +function! ale_linters#terraform#terraform_lsp#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'terraform_langserver_options')) +endfunction + +function! ale_linters#terraform#terraform_lsp#GetProjectRoot(buffer) abort + let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform') + + return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'terraform_lsp', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'terraform_langserver_executable')}, +\ 'command': function('ale_linters#terraform#terraform_lsp#GetCommand'), +\ 'project_root': function('ale_linters#terraform#terraform_lsp#GetProjectRoot'), +\ 'language': 'terraform', +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/verilator.vim b/sources_non_forked/ale/ale_linters/verilog/verilator.vim index 64bb6e41..029dd4c9 100644 --- a/sources_non_forked/ale/ale_linters/verilog/verilator.vim +++ b/sources_non_forked/ale/ale_linters/verilog/verilator.vim @@ -28,21 +28,30 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort " %Warning-UNDRIVEN: test.v:3: Signal is not driven: clk " %Warning-UNUSED: test.v:4: Signal is not used: dout " %Warning-BLKSEQ: test.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=). - let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\d\+\): \(.\+\)$' + " Since version 4.032 (04/2020) verilator linter messages also contain the column number, + " and look like: + " %Error: /tmp/test.sv:3:1: syntax error, unexpected endmodule, expecting ';' + " + " to stay compatible with old versions of the tool, the column number is + " optional in the researched pattern + let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:line = l:match[3] + 0 - let l:type = l:match[1] is# 'Error' ? 'E' : 'W' - let l:text = l:match[4] + let l:item = { + \ 'lnum': str2nr(l:match[3]), + \ 'text': l:match[5], + \ 'type': l:match[1] is# 'Error' ? 'E' : 'W', + \} + + if !empty(l:match[4]) + let l:item.col = str2nr(l:match[4]) + endif + let l:file = l:match[2] if l:file =~# '_verilator_linted.v' - call add(l:output, { - \ 'lnum': l:line, - \ 'text': l:text, - \ 'type': l:type, - \}) + call add(l:output, l:item) endif endfor diff --git a/sources_non_forked/ale/ale_linters/vim/vimls.vim b/sources_non_forked/ale/ale_linters/vim/vimls.vim new file mode 100644 index 00000000..26014d66 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vim/vimls.vim @@ -0,0 +1,61 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Vim Language Server integration for ALE + +call ale#Set('vim_vimls_executable', 'vim-language-server') +call ale#Set('vim_vimls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('vim_vimls_config', {}) + +function! ale_linters#vim#vimls#GetProjectRoot(buffer) abort + let l:trigger_file_candidates = [ + \ '.vimrc', + \ 'init.vim', + \] + + for l:candidate in l:trigger_file_candidates + let l:trigger_file = fnamemodify(bufname(a:buffer), ':t') + + if l:trigger_file is# l:candidate + return fnamemodify( + \ bufname(a:buffer), + \ ':h', + \) + endif + endfor + + let l:trigger_dir_candidates = [ + \ 'autoload', + \ 'plugin', + \ '.git', + \] + + let l:path_upwards = ale#path#Upwards(fnamemodify(bufname(a:buffer), ':p:h')) + + for l:path in l:path_upwards + for l:candidate in l:trigger_dir_candidates + let l:trigger_dir = ale#path#Simplify( + \ l:path . '/' . l:candidate, + \) + + if isdirectory(l:trigger_dir) + return fnamemodify( + \ l:trigger_dir, + \ ':p:h:h', + \) + endif + endfor + endfor + + return '' +endfunction + +call ale#linter#Define('vim', { +\ 'name': 'vimls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')}, +\ 'executable': {b -> ale#node#FindExecutable(b, 'vim_vimls', [ +\ 'node_modules/.bin/vim-language-server', +\ ])}, +\ 'command': '%e --stdio', +\ 'language': 'vim', +\ 'project_root': function('ale_linters#vim#vimls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/autoload/ale.vim b/sources_non_forked/ale/autoload/ale.vim index ee1a0d54..01e17b15 100644 --- a/sources_non_forked/ale/autoload/ale.vim +++ b/sources_non_forked/ale/autoload/ale.vim @@ -258,9 +258,9 @@ function! ale#GetLocItemMessage(item, format_string) abort " Replace special markers with certain information. " \=l:variable is used to avoid escaping issues. + let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g') let l:msg = substitute(l:msg, '\V%severity%', '\=l:severity', 'g') let l:msg = substitute(l:msg, '\V%linter%', '\=l:linter_name', 'g') - let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g') " Replace %s with the text. let l:msg = substitute(l:msg, '\V%s', '\=a:item.text', 'g') diff --git a/sources_non_forked/ale/autoload/ale/ant.vim b/sources_non_forked/ale/autoload/ale/ant.vim index 689b444b..7d02484e 100644 --- a/sources_non_forked/ale/autoload/ale/ant.vim +++ b/sources_non_forked/ale/autoload/ale/ant.vim @@ -1,4 +1,4 @@ -" Author: Andrew Lee . +" Author: Andrew Lee . " Inspired by ale/gradle.vim by Michael Pardo " Description: Functions for working with Ant projects. diff --git a/sources_non_forked/ale/autoload/ale/code_action.vim b/sources_non_forked/ale/autoload/ale/code_action.vim index 0af1bb70..60c3bbef 100644 --- a/sources_non_forked/ale/autoload/ale/code_action.vim +++ b/sources_non_forked/ale/autoload/ale/code_action.vim @@ -1,7 +1,7 @@ " Author: Jerko Steiner " Description: Code action support for LSP / tsserver -function! ale#code_action#HandleCodeAction(code_action) abort +function! ale#code_action#HandleCodeAction(code_action, should_save) abort let l:current_buffer = bufnr('') let l:changes = a:code_action.changes @@ -17,11 +17,14 @@ function! ale#code_action#HandleCodeAction(code_action) abort for l:file_code_edit in l:changes call ale#code_action#ApplyChanges( - \ l:file_code_edit.fileName, l:file_code_edit.textChanges) + \ l:file_code_edit.fileName, + \ l:file_code_edit.textChanges, + \ a:should_save, + \ ) endfor endfunction -function! ale#code_action#ApplyChanges(filename, changes) abort +function! ale#code_action#ApplyChanges(filename, changes, should_save) abort let l:current_buffer = bufnr('') " The buffer is used to determine the fileformat, if available. let l:buffer = bufnr(a:filename) @@ -106,10 +109,17 @@ function! ale#code_action#ApplyChanges(filename, changes) abort call remove(l:lines, -1) endif - call ale#util#Writefile(l:buffer, l:lines, a:filename) + if a:should_save + call ale#util#Writefile(l:buffer, l:lines, a:filename) + else + call ale#util#SetBufferContents(l:buffer, l:lines) + endif if l:is_current_buffer - call ale#util#Execute(':e!') + if a:should_save + call ale#util#Execute(':e!') + endif + call setpos('.', [0, l:pos[0], l:pos[1], 0]) endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index 80684a30..2b5756e4 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -823,7 +823,7 @@ function! ale#completion#HandleUserData(completed_item) abort endif for l:code_action in get(l:user_data, 'codeActions', []) - call ale#code_action#HandleCodeAction(l:code_action) + call ale#code_action#HandleCodeAction(l:code_action, v:false) endfor endfunction diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 3915cac1..ffcd9d10 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -5,6 +5,7 @@ let s:go_to_definition_map = {} " Enable automatic updates of the tagstack let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1) +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') " Used to get the definition map in tests. function! ale#definition#GetMap() abort @@ -134,6 +135,10 @@ function! s:GoToLSPDefinition(linter, options, capability) abort endfunction function! ale#definition#GoTo(options) abort + if !get(g:, 'ale_ignore_2_7_warnings') && has_key(a:options, 'deprecated_command') + execute 'echom '':' . a:options.deprecated_command . ' is deprecated. Use `let g:ale_ignore_2_7_warnings = 1` to disable this message.''' + endif + for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) call s:GoToLSPDefinition(l:linter, a:options, 'definition') @@ -142,6 +147,10 @@ function! ale#definition#GoTo(options) abort endfunction function! ale#definition#GoToType(options) abort + if !get(g:, 'ale_ignore_2_7_warnings') && has_key(a:options, 'deprecated_command') + execute 'echom '':' . a:options.deprecated_command . ' is deprecated. Use `let g:ale_ignore_2_7_warnings = 1` to disable this message.''' + endif + for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) " TODO: handle typeDefinition for tsserver if supported by the @@ -154,3 +163,33 @@ function! ale#definition#GoToType(options) abort endif endfor endfunction + +function! ale#definition#GoToCommandHandler(command, ...) abort + let l:options = {} + + if len(a:000) > 0 + for l:option in a:000 + if l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' + endif + endfor + endif + + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + + if a:command is# 'type' + call ale#definition#GoToType(l:options) + else + call ale#definition#GoTo(l:options) + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim index dad9e2bc..69817b36 100644 --- a/sources_non_forked/ale/autoload/ale/fix.vim +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -4,40 +4,15 @@ call ale#Set('fix_on_save_ignore', {}) " Vim doesn't let you modify hidden buffers. function! ale#fix#ApplyQueuedFixes(buffer) abort let l:data = get(g:ale_fix_buffer_data, a:buffer, {'done': 0}) - let l:has_bufline_api = exists('*deletebufline') && exists('*setbufline') - if !l:data.done || (!l:has_bufline_api && a:buffer isnot bufnr('')) + if !l:data.done || (!ale#util#HasBuflineApi() && a:buffer isnot bufnr('')) return endif call remove(g:ale_fix_buffer_data, a:buffer) if l:data.changes_made - " If the file is in DOS mode, we have to remove carriage returns from - " the ends of lines before calling setline(), or we will see them - " twice. - let l:new_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' - \ ? map(copy(l:data.output), 'substitute(v:val, ''\r\+$'', '''', '''')') - \ : l:data.output - let l:first_line_to_remove = len(l:new_lines) + 1 - - " Use a Vim API for setting lines in other buffers, if available. - if l:has_bufline_api - call setbufline(a:buffer, 1, l:new_lines) - call deletebufline(a:buffer, l:first_line_to_remove, '$') - " Fall back on setting lines the old way, for the current buffer. - else - let l:old_line_length = len(l:data.lines_before) - - if l:old_line_length >= l:first_line_to_remove - let l:save = winsaveview() - silent execute - \ l:first_line_to_remove . ',' . l:old_line_length . 'd_' - call winrestview(l:save) - endif - - call setline(1, l:new_lines) - endif + let l:new_lines = ale#util#SetBufferContents(a:buffer, l:data.output) if l:data.should_save if a:buffer is bufnr('') diff --git a/sources_non_forked/ale/autoload/ale/highlight.vim b/sources_non_forked/ale/autoload/ale/highlight.vim index 82ad57e0..473ad354 100644 --- a/sources_non_forked/ale/autoload/ale/highlight.vim +++ b/sources_non_forked/ale/autoload/ale/highlight.vim @@ -210,6 +210,12 @@ function! ale#highlight#SetHighlights(buffer, loclist) abort " Set the list in the buffer variable. call setbufvar(str2nr(a:buffer), 'ale_highlight_items', l:new_list) + let l:exclude_list = ale#Var(a:buffer, 'exclude_highlights') + + if !empty(l:exclude_list) + call filter(l:new_list, 'empty(ale#util#GetMatches(v:val.text, l:exclude_list))') + endif + " Update highlights for the current buffer, which may or may not " be the buffer we just set highlights for. call ale#highlight#UpdateHighlights() diff --git a/sources_non_forked/ale/autoload/ale/organize_imports.vim b/sources_non_forked/ale/autoload/ale/organize_imports.vim index bc9b829e..e89c832c 100644 --- a/sources_non_forked/ale/autoload/ale/organize_imports.vim +++ b/sources_non_forked/ale/autoload/ale/organize_imports.vim @@ -15,7 +15,7 @@ function! ale#organize_imports#HandleTSServerResponse(conn_id, response) abort call ale#code_action#HandleCodeAction({ \ 'description': 'Organize Imports', \ 'changes': l:file_code_edits, - \}) + \}, v:false) endfunction function! s:OnReady(linter, lsp_details) abort diff --git a/sources_non_forked/ale/autoload/ale/preview.vim b/sources_non_forked/ale/autoload/ale/preview.vim index 6d58aca9..7902ec63 100644 --- a/sources_non_forked/ale/autoload/ale/preview.vim +++ b/sources_non_forked/ale/autoload/ale/preview.vim @@ -1,6 +1,14 @@ " Author: w0rp " Description: Preview windows for showing whatever information in. +if !has_key(s:, 'last_selection_list') + let s:last_selection_list = [] +endif + +if !has_key(s:, 'last_selection_open_in') + let s:last_selection_open_in = 'current-buffer' +endif + " Open a preview window and show some lines in it. " A second argument can be passed as a Dictionary with options. They are... " @@ -67,9 +75,24 @@ function! ale#preview#ShowSelection(item_list, ...) abort call ale#preview#Show(l:lines, {'filetype': 'ale-preview-selection'}) let b:ale_preview_item_list = a:item_list + let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer') + + " Remove the last preview + let s:last_selection_list = b:ale_preview_item_list + let s:last_selection_open_in = b:ale_preview_item_open_in endfunction -function! s:Open(open_in_tab) abort +function! ale#preview#RepeatSelection() abort + if empty(s:last_selection_list) + return + endif + + call ale#preview#ShowSelection(s:last_selection_list, { + \ 'open_in': s:last_selection_open_in, + \}) +endfunction + +function! s:Open(open_in) abort let l:item_list = get(b:, 'ale_preview_item_list', []) let l:item = get(l:item_list, getpos('.')[1] - 1, {}) @@ -77,22 +100,20 @@ function! s:Open(open_in_tab) abort return endif - if !a:open_in_tab - :q! - endif + :q! call ale#util#Open( \ l:item.filename, \ l:item.line, \ l:item.column, - \ {'open_in_tab': a:open_in_tab}, + \ {'open_in': a:open_in}, \) endfunction -function! ale#preview#OpenSelectionInBuffer() abort - call s:Open(0) +function! ale#preview#OpenSelection() abort + call s:Open(b:ale_preview_item_open_in) endfunction function! ale#preview#OpenSelectionInTab() abort - call s:Open(1) + call s:Open('tab') endfunction diff --git a/sources_non_forked/ale/autoload/ale/references.vim b/sources_non_forked/ale/autoload/ale/references.vim index b9725e1e..38ff0d3d 100644 --- a/sources_non_forked/ale/autoload/ale/references.vim +++ b/sources_non_forked/ale/autoload/ale/references.vim @@ -1,3 +1,5 @@ +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') + let s:references_map = {} " Used to get the references map in tests. @@ -99,7 +101,8 @@ function! s:OnReady(line, column, options, linter, lsp_details) abort let l:request_id = ale#lsp#Send(l:id, l:message) let s:references_map[l:request_id] = { - \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0 + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0, + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), \} endfunction @@ -110,10 +113,24 @@ function! ale#references#Find(...) abort for l:option in a:000 if l:option is? '-relative' let l:options.use_relative_paths = 1 + elseif l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' endif endfor endif + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + let l:buffer = bufnr('') let [l:line, l:column] = getpos('.')[1:2] let l:column = min([l:column, len(getline(l:line))]) diff --git a/sources_non_forked/ale/autoload/ale/rename.vim b/sources_non_forked/ale/autoload/ale/rename.vim index 02b7b579..fbd6c2ad 100644 --- a/sources_non_forked/ale/autoload/ale/rename.vim +++ b/sources_non_forked/ale/autoload/ale/rename.vim @@ -80,7 +80,7 @@ function! ale#rename#HandleTSServerResponse(conn_id, response) abort call ale#code_action#HandleCodeAction({ \ 'description': 'rename', \ 'changes': l:changes, - \}) + \}, v:true) endfunction function! ale#rename#HandleLSPResponse(conn_id, response) abort @@ -134,7 +134,7 @@ function! ale#rename#HandleLSPResponse(conn_id, response) abort call ale#code_action#HandleCodeAction({ \ 'description': 'rename', \ 'changes': l:changes, - \}) + \}, v:true) endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim index db0e1ab6..8109c60e 100644 --- a/sources_non_forked/ale/autoload/ale/sign.vim +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -23,7 +23,7 @@ let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0) -let s:supports_sign_groups = has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) +let s:supports_sign_groups = has('nvim-0.4.2') || has('patch-8.1.614') if !hlexists('ALEErrorSign') highlight link ALEErrorSign error diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index 99cd856a..ee62af28 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -91,17 +91,17 @@ endfunction " options['open_in'] can be: " current-buffer (default) " tab -" vertical-split -" horizontal-split +" split +" vsplit function! ale#util#Open(filename, line, column, options) abort let l:open_in = get(a:options, 'open_in', 'current-buffer') let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename) if l:open_in is# 'tab' call ale#util#Execute('tabedit ' . l:args_to_open) - elseif l:open_in is# 'horizontal-split' + elseif l:open_in is# 'split' call ale#util#Execute('split ' . l:args_to_open) - elseif l:open_in is# 'vertical-split' + elseif l:open_in is# 'vsplit' call ale#util#Execute('vsplit ' . l:args_to_open) elseif bufnr(a:filename) isnot bufnr('') " Open another file only if we need to. @@ -336,15 +336,11 @@ function! ale#util#GetMatches(lines, patterns) abort endfunction function! s:LoadArgCount(function) abort - let l:Function = a:function - - redir => l:output - silent! function Function - redir END - - if !exists('l:output') + try + let l:output = execute('function a:function') + catch /E123/ return 0 - endif + endtry let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2] let l:arg_list = filter(split(l:match, ', '), 'v:val isnot# ''...''') @@ -480,3 +476,44 @@ endfunction function! ale#util#Input(message, value) abort return input(a:message, a:value) endfunction + +function! ale#util#HasBuflineApi() abort + return exists('*deletebufline') && exists('*setbufline') +endfunction + +" Sets buffer contents to lines +function! ale#util#SetBufferContents(buffer, lines) abort + let l:has_bufline_api = ale#util#HasBuflineApi() + + if !l:has_bufline_api && a:buffer isnot bufnr('') + return + endif + + " If the file is in DOS mode, we have to remove carriage returns from + " the ends of lines before calling setline(), or we will see them + " twice. + let l:new_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' + \ ? map(copy(a:lines), 'substitute(v:val, ''\r\+$'', '''', '''')') + \ : a:lines + let l:first_line_to_remove = len(l:new_lines) + 1 + + " Use a Vim API for setting lines in other buffers, if available. + if l:has_bufline_api + call setbufline(a:buffer, 1, l:new_lines) + call deletebufline(a:buffer, l:first_line_to_remove, '$') + " Fall back on setting lines the old way, for the current buffer. + else + let l:old_line_length = line('$') + + if l:old_line_length >= l:first_line_to_remove + let l:save = winsaveview() + silent execute + \ l:first_line_to_remove . ',' . l:old_line_length . 'd_' + call winrestview(l:save) + endif + + call setline(1, l:new_lines) + endif + + return l:new_lines +endfunction diff --git a/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt b/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt index 29dabab7..636985fb 100644 --- a/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt +++ b/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt @@ -485,6 +485,7 @@ Notes: * `vcom` * `xvhdl` * Vim + * `vimls` * `vint` * Vim help^ * `alex`!! diff --git a/sources_non_forked/ale/doc/ale-terraform.txt b/sources_non_forked/ale/doc/ale-terraform.txt index 387fd732..f62db190 100644 --- a/sources_non_forked/ale/doc/ale-terraform.txt +++ b/sources_non_forked/ale/doc/ale-terraform.txt @@ -32,6 +32,25 @@ g:ale_terraform_terraform_executable *g:ale_terraform_terraform_executable* This variable can be changed to use a different executable for terraform. +=============================================================================== +terraform-lsp *ale-terraform-terraform-lsp* + +g:ale_terraform_langserver_executable *g:ale_terraform_langserver_executable* + *b:ale_terraform_langserver_executable* + Type: |String| + Default: `'terraform-lsp'` + + This variable can be changed to use a different executable for terraform-lsp. + + +g:ale_terraform_langserver_options *g:ale_terraform_langserver_options* + *b:ale_terraform_langserver_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to terraform-lsp. + + =============================================================================== tflint *ale-terraform-tflint* diff --git a/sources_non_forked/ale/doc/ale-vim.txt b/sources_non_forked/ale/doc/ale-vim.txt index 772bad23..f85b43eb 100644 --- a/sources_non_forked/ale/doc/ale-vim.txt +++ b/sources_non_forked/ale/doc/ale-vim.txt @@ -2,6 +2,61 @@ ALE Vim Integration *ale-vim-options* +=============================================================================== +vimls *ale-vim-vimls* + + The `vim-language-server` is the engine that powers VimL editor support + using the Language Server Protocol. See the installation instructions: + https://github.com/iamcco/vim-language-server#install + +g:ale_vim_vimls_executable *g:ale_vim_vimls_executable* + *b:ale_vim_vimls_executable* + Type: |String| + Default: `'vim-language-server'` + + This option can be set to change the executable path for vimls. + + +g:ale_vim_vimls_config *g:ale_vim_vimls_config* + *b:ale_vim_vimls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. For example: > + { + \ 'vim': { + \ 'iskeyword': '@,48-57,_,192-255,-#', + \ 'vimruntime': '', + \ 'runtimepath': '', + \ 'diagnostic': { + \ 'enable': v:true + \ }, + \ 'indexes': { + \ 'runtimepath': v:true, + \ 'gap': 100, + \ 'count': 3, + \ 'projectRootPatterns' : ['.git', 'autoload', 'plugin'] + \ }, + \ 'suggest': { + \ 'fromVimruntime': v:true, + \ 'fromRuntimepath': v:false + \ }, + \ } + \} +< + Consult the vim-language-server documentation for more information about + settings. + + +g:ale_vim_vimls_use_global *g:ale_vim_vimls_use_global* + *b:ale_vim_vimls_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vint *ale-vim-vint* diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index eafbc119..16b204a4 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -478,12 +478,9 @@ would like to use. An example here shows the available options for symbols > ALE supports jumping to the files and locations where symbols are defined through any enabled LSP linters. The locations ALE will jump to depend on the -information returned by LSP servers. The following commands are supported: - -|ALEGoToDefinition| - Open the definition of the symbol under the cursor. -|ALEGoToDefinitionInTab| - The same, but for opening the file in a new tab. -|ALEGoToDefinitionInSplit| - The same, but in a new split. -|ALEGoToDefinitionInVSplit| - The same, but in a new vertical split. +information returned by LSP servers. The |ALEGoToDefinition| command will jump +to the definition of symbols under the cursor. See the documentation for the +command for configuring how the location will be displayed. ALE will update Vim's |tagstack| automatically unless |g:ale_update_tagstack| is set to `0`. @@ -493,15 +490,10 @@ set to `0`. ALE supports jumping to the files and locations where symbols' types are defined through any enabled LSP linters. The locations ALE will jump to depend -on the information returned by LSP servers. The following commands are -supported: - -|ALEGoToTypeDefinition| - Open the definition of the symbol's type under - the cursor. -|ALEGoToTypeDefinitionInTab| - The same, but for opening the file in a new tab. -|ALEGoToTypeDefinitionInSplit| - The same, but in a new split. -|ALEGoToTypeDefinitionInVSplit| - The same, but in a new vertical split. - +on the information returned by LSP servers. The |ALEGoToTypeDefinition| +command will jump to the definition of symbols under the cursor. See the +documentation for the command for configuring how the location will be +displayed. ------------------------------------------------------------------------------- 5.4 Find References *ale-find-references* @@ -666,7 +658,7 @@ g:ale_completion_delay *g:ale_completion_delay* g:ale_completion_enabled *g:ale_completion_enabled* -b:ale_completion_enabled *b:ale_completion_enabled* + *b:ale_completion_enabled* Type: |Number| Default: `0` @@ -793,6 +785,16 @@ g:ale_cursor_detail *g:ale_cursor_detail* loaded for messages to be displayed. See |ale-lint-settings-on-startup|. +g:ale_default_navigation *g:ale_default_navigation* + *b:ale_default_navigation* + + Type: |String| + Default: `'buffer'` + + The default method for navigating away from the current buffer to another + buffer, such as for |ALEFindReferences:|, or |ALEGoToDefinition|. + + g:ale_disable_lsp *g:ale_disable_lsp* *b:ale_disable_lsp* @@ -845,7 +847,7 @@ g:ale_echo_msg_error_str *g:ale_echo_msg_error_str* g:ale_echo_msg_format *g:ale_echo_msg_format* -b:ale_echo_msg_format *b:ale_echo_msg_format* + *b:ale_echo_msg_format* Type: |String| Default: `'%code: %%s'` @@ -923,6 +925,21 @@ g:ale_enabled *g:ale_enabled* See |g:ale_pattern_options| for more information on that option. +g:ale_exclude_highlights *g:ale_exclude_highlights* + *b:ale_exclude_highlights* + + Type: |List| + Default: `[]` + + A list of regular expressions for matching against highlight messages to + remove. For example: > + + " Do not highlight messages matching strings like these. + let b:ale_exclude_highlights = ['line too long', 'foo.*bar'] +< + See also: |g:ale_set_highlights| + + g:ale_fixers *g:ale_fixers* *b:ale_fixers* @@ -946,7 +963,7 @@ g:ale_fixers *g:ale_fixers* < g:ale_fix_on_save *g:ale_fix_on_save* -b:ale_fix_on_save *b:ale_fix_on_save* + *b:ale_fix_on_save* Type: |Number| Default: `0` @@ -968,7 +985,7 @@ b:ale_fix_on_save *b:ale_fix_on_save* g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore* -b:ale_fix_on_save_ignore *b:ale_fix_on_save_ignore* + *b:ale_fix_on_save_ignore* Type: |Dictionary| or |List| Default: `{}` @@ -1344,7 +1361,7 @@ g:ale_list_vertical *g:ale_list_vertical* g:ale_loclist_msg_format *g:ale_loclist_msg_format* -b:ale_loclist_msg_format *b:ale_loclist_msg_format* + *b:ale_loclist_msg_format* Type: |String| Default: `g:ale_echo_msg_format` @@ -1396,7 +1413,7 @@ g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* g:ale_lsp_root *g:ale_lsp_root* -b:ale_lsp_root *b:ale_lsp_root* + *b:ale_lsp_root* Type: |Dictionary| or |String| Default: {} @@ -1609,6 +1626,8 @@ g:ale_set_highlights *g:ale_set_highlights* match highlights, whereas the line highlights when signs are enabled will run to the edge of the screen. + Highlights can be excluded with the |g:ale_exclude_highlights| option. + g:ale_set_loclist *g:ale_set_loclist* @@ -1875,7 +1894,8 @@ g:ale_virtualtext_cursor *g:ale_virtualtext_cursor* g:ale_virtualtext_delay *g:ale_virtualtext_delay* -b:ale_virtualtext_delay *b:ale_virtualtext_delay* + *b:ale_virtualtext_delay* + Type: |Number| Default: `10` @@ -1894,7 +1914,7 @@ g:ale_virtualtext_prefix *g:ale_virtualtext_prefix* Prefix to be used with |g:ale_virtualtext_cursor|. g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names* -b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* + *b:ale_virtualenv_dir_names* Type: |List| Default: `['.env', '.venv', 'env', 've-py3', 've', 'virtualenv', 'venv']` @@ -1908,7 +1928,7 @@ b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* g:ale_warn_about_trailing_blank_lines *g:ale_warn_about_trailing_blank_lines* -b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines* + *b:ale_warn_about_trailing_blank_lines* Type: |Number| Default: `1` @@ -1920,7 +1940,7 @@ b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines* g:ale_warn_about_trailing_whitespace *g:ale_warn_about_trailing_whitespace* -b:ale_warn_about_trailing_whitespace *b:ale_warn_about_trailing_whitespace* + *b:ale_warn_about_trailing_whitespace* Type: |Number| Default: `1` @@ -2603,6 +2623,7 @@ documented in additional help files. terraform...............................|ale-terraform-options| terraform-fmt-fixer...................|ale-terraform-fmt-fixer| terraform.............................|ale-terraform-terraform| + terraform-lsp.........................|ale-terraform-terraform-lsp| tflint................................|ale-terraform-tflint| tex.....................................|ale-tex-options| chktex................................|ale-tex-chktex| @@ -2634,6 +2655,7 @@ documented in additional help files. vcom..................................|ale-vhdl-vcom| xvhdl.................................|ale-vhdl-xvhdl| vim.....................................|ale-vim-options| + vimls.................................|ale-vim-vimls| vint..................................|ale-vim-vint| vim help................................|ale-vim-help-options| write-good............................|ale-vim-help-write-good| @@ -2687,11 +2709,23 @@ ALEFindReferences *ALEFindReferences* Enter key (``) can be used to jump to a referencing location, or the `t` key can be used to jump to the location in a new tab. + The locations opened in different ways using the following variations. + + `:ALEFindReferences -tab` - Open the location in a new tab. + `:ALEFindReferences -split` - Open the location in a horizontal split. + `:ALEFindReferences -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + The selection can be opened again with the |ALERepeatSelection| command. + You can jump back to the position you were at before going to a reference of something with jump motions like CTRL-O. See |jump-motions|. A plug mapping `(ale_find_references)` is defined for this command. + ALEFix *ALEFix* Fix problems with the current buffer. See |ale-fix| for more information. @@ -2706,42 +2740,31 @@ ALEFixSuggest *ALEFixSuggest* See |ale-fix| for more information. -ALEGoToDefinition *ALEGoToDefinition* +ALEGoToDefinition `` *ALEGoToDefinition* Jump to the definition of a symbol under the cursor using the enabled LSP linters for the buffer. ALE will jump to a definition if an LSP server provides a location to jump to. Otherwise, ALE will do nothing. + The locations opened in different ways using the following variations. + + `:ALEGoToDefinition -tab` - Open the location in a new tab. + `:ALEGoToDefinition -split` - Open the location in a horizontal split. + `:ALEGoToDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + You can jump back to the position you were at before going to the definition of something with jump motions like CTRL-O. See |jump-motions|. + You should consider using the 'hidden' option in combination with this + command. Otherwise, Vim will refuse to leave the buffer you're jumping from + unless you have saved your edits. + A plug mapping `(ale_go_to_definition)` is defined for this command. -ALEGoToDefinitionInTab *ALEGoToDefinitionInTab* - - The same as |ALEGoToDefinition|, but opens results in a new tab. - - A plug mapping `(ale_go_to_definition_in_tab)` is defined for this - command. - - -ALEGoToDefinitionInSplit *ALEGoToDefinitionInSplit* - - The same as |ALEGoToDefinition|, but opens results in a new split. - - A plug mapping `(ale_go_to_definition_in_split)` is defined for this - command. - - -ALEGoToDefinitionInVSplit *ALEGoToDefinitionInVSplit* - - The same as |ALEGoToDefinition|, but opens results in a new vertical split. - - A plug mapping `(ale_go_to_definition_in_vsplit)` is defined for this - command. - - ALEGoToTypeDefinition *ALEGoToTypeDefinition* This works similar to |ALEGoToDefinition| but instead jumps to the @@ -2749,6 +2772,15 @@ ALEGoToTypeDefinition *ALEGoToTypeDefinition* definition if an LSP server provides a location to jump to. Otherwise, ALE will do nothing. + The locations opened in different ways using the following variations. + + `:ALEGoToTypeDefinition -tab` - Open the location in a new tab. + `:ALEGoToTypeDefinition -split` - Open the location in a horizontal split. + `:ALEGoToTypeDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + You can jump back to the position you were at before going to the definition of something with jump motions like CTRL-O. See |jump-motions|. @@ -2756,31 +2788,6 @@ ALEGoToTypeDefinition *ALEGoToTypeDefinition* command. -ALEGoToTypeDefinitionInTab *ALEGoToTypeDefinitionInTab* - - The same as |ALEGoToTypeDefinition|, but opens results in a new tab. - - A plug mapping `(ale_go_to_type_definition_in_tab)` is defined for - this command. - - -ALEGoToTypeDefinitionInSplit *ALEGoToTypeDefinitionInSplit* - - The same as |ALEGoToTypeDefinition|, but opens results in a new split. - - A plug mapping `(ale_go_to_type_definition_in_split)` is defined for - this command. - - -ALEGoToTypeDefinitionInVSplit *ALEGoToTypeDefinitionInVSplit* - - The same as |ALEGoToTypeDefinition|, but opens results in a new vertical - split. - - A plug mapping `(ale_go_to_type_definition_in_vsplit)` is defined for - this command. - - ALEHover *ALEHover* Print brief information about the symbol under the cursor, taken from any @@ -2806,6 +2813,11 @@ ALERename *ALERename* The user will be prompted for a new name. +ALERepeatSelection *ALERepeatSelection* + + Repeat the last selection displayed in the preview window. + + ALESymbolSearch `` *ALESymbolSearch* Search for symbols in the workspace, taken from any available LSP linters. @@ -3114,7 +3126,6 @@ ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()* 'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))} < - The following `options` can be provided. `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for diff --git a/sources_non_forked/ale/ftplugin/ale-preview-selection.vim b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim index d77b4f98..7ec84068 100644 --- a/sources_non_forked/ale/ftplugin/ale-preview-selection.vim +++ b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim @@ -12,5 +12,5 @@ noremap A noremap o noremap O " Keybinds for opening selection items. -noremap :call ale#preview#OpenSelectionInBuffer() +noremap :call ale#preview#OpenSelection() noremap t :call ale#preview#OpenSelectionInTab() diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 8fea3bb4..e1ddf7b7 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -109,6 +109,9 @@ let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs')) " This flag can be set to 0 to disable setting error highlights. let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax')) +" This List can be configured to exclude particular highlights. +let g:ale_exclude_highlights = get(g:, 'ale_exclude_highlights', []) + " This flag can be set to 0 to disable echoing when the cursor moves. let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1) @@ -199,16 +202,23 @@ command! -bar -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEF command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype) " Go to definition for tsserver and LSP -command! -bar ALEGoToDefinition :call ale#definition#GoTo({}) -command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab'}) -command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'horizontal-split'}) -command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vertical-split'}) +command! -bar -nargs=* ALEGoToDefinition :call ale#definition#GoToCommandHandler('', ) + +" Deprecated commands we have to keep for now. +command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab', 'deprecated_command': 'ALEGoToDefinitionInTab'}) +command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'split', 'deprecated_command': 'ALEGoToDefinitionInSplit'}) +command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vsplit', 'deprecated_command': 'ALEGoToDefinitionInVSplit'}) " Go to type definition for tsserver and LSP -command! -bar ALEGoToTypeDefinition :call ale#definition#GoToType({}) -command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab'}) -command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'horizontal-split'}) -command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vertical-split'}) +command! -bar -nargs=* ALEGoToTypeDefinition :call ale#definition#GoToCommandHandler('type', ) + +" Deprecated commands we have to keep for now. +command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab', 'deprecated_command': 'ALEGoToTypeDefinitionInTab'}) +command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'split', 'deprecated_command': 'ALEGoToTypeDefinitionInSplit'}) +command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vsplit', 'deprecated_command': 'ALEGoToTypeDefinitionInVSplit'}) + +" Repeat a previous selection in the preview window +command! -bar ALERepeatSelection :call ale#preview#RepeatSelection() " Find references for tsserver and LSP command! -bar -nargs=* ALEFindReferences :call ale#references#Find() @@ -257,18 +267,21 @@ nnoremap (ale_lint) :ALELint nnoremap (ale_detail) :ALEDetail nnoremap (ale_fix) :ALEFix nnoremap (ale_go_to_definition) :ALEGoToDefinition -nnoremap (ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab -nnoremap (ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit -nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit nnoremap (ale_go_to_type_definition) :ALEGoToTypeDefinition -nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab -nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit -nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit nnoremap (ale_find_references) :ALEFindReferences nnoremap (ale_hover) :ALEHover nnoremap (ale_documentation) :ALEDocumentation inoremap (ale_complete) :ALEComplete nnoremap (ale_rename) :ALERename +nnoremap (ale_repeat_selection) :ALERepeatSelection + +" Deprecated mappings +nnoremap (ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab +nnoremap (ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit +nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit +nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab +nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit +nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit " Set up autocmd groups now. call ale#events#Init() diff --git a/sources_non_forked/ale/supported-tools.md b/sources_non_forked/ale/supported-tools.md index 0abc6b75..d5c0c9d4 100644 --- a/sources_non_forked/ale/supported-tools.md +++ b/sources_non_forked/ale/supported-tools.md @@ -494,6 +494,7 @@ formatting. * [vcom](https://www.mentor.com/products/fv/questa/) * [xvhdl](https://www.xilinx.com/products/design-tools/vivado.html) * Vim + * [vimls](https://github.com/iamcco/vim-language-server) * [vint](https://github.com/Kuniwak/vint) * Vim help * [alex](https://github.com/wooorm/alex) :warning: :floppy_disk: diff --git a/sources_non_forked/bufexplorer/README.md b/sources_non_forked/bufexplorer/README.md index 5ee9346e..2987bdd9 100644 --- a/sources_non_forked/bufexplorer/README.md +++ b/sources_non_forked/bufexplorer/README.md @@ -5,10 +5,14 @@ BufExplorer Plugin for Vim With bufexplorer, you can quickly and easily switch between buffers by using the one of the default public interfaces: - '\be' (normal open) or - '\bt' (toggle open / close) or - '\bs' (force horizontal split open) or - '\bv' (force vertical split open) +`\be` normal open + +`\bt` toggle open / close + +`\bs` force horizontal split open + +`\bv` force vertical split open + Once the bufexplorer window is open you can use the normal movement keys (hjkl) to move around and then use or to select the buffer you would like to open. If you would like to have the selected buffer opened in a new tab, simply press either or 't'. Please note that when opening a buffer in a tab, that if the buffer is already in another tab, bufexplorer can switch to that tab automatically for you if you would like. More about that in the supplied VIM help. diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt index 424dd36d..56e3e5d8 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt @@ -1107,13 +1107,13 @@ c) End the string with a colon ':' followed by a Vim command to execute that See also: Vim's |++opt| and |+cmd|. -d) Submit two dots '..' to go upward the directory tree by 1 level. To go up +d) Input two dots '..' and then hit the key to go upward the directory tree by 1 level. To go up multiple levels, use one extra dot for each extra level: > Raw input Interpreted as - .. ../ - ... ../../ - .... ../../../ + .. ../ + ... ../../ + .... ../../../ < Note: if the parent directories are large and uncached, this can be slow. diff --git a/sources_non_forked/gruvbox/README.md b/sources_non_forked/gruvbox/README.md index 4269786c..cd07e486 100644 --- a/sources_non_forked/gruvbox/README.md +++ b/sources_non_forked/gruvbox/README.md @@ -13,7 +13,7 @@ Attention 1. [Read this first](https://github.com/morhetz/gruvbox/wiki/Terminal-specific) 2. Typeface from gallery is [Fantasque Sans Mono](https://github.com/belluzj/fantasque-sans) -3. Typeface from screenshots below is [Fira Mono](http://www.carrois.com/fira-4-1/) +3. Typeface from screenshots below is [Fira Mono](https://mozilla.github.io/Fira/) Screenshots ----------- diff --git a/sources_non_forked/gruvbox/colors/gruvbox.vim b/sources_non_forked/gruvbox/colors/gruvbox.vim index a0c2c0ba..66246fba 100644 --- a/sources_non_forked/gruvbox/colors/gruvbox.vim +++ b/sources_non_forked/gruvbox/colors/gruvbox.vim @@ -454,6 +454,7 @@ call s:HL('GruvboxYellowSign', s:yellow, s:sign_column, s:invert_signs) call s:HL('GruvboxBlueSign', s:blue, s:sign_column, s:invert_signs) call s:HL('GruvboxPurpleSign', s:purple, s:sign_column, s:invert_signs) call s:HL('GruvboxAquaSign', s:aqua, s:sign_column, s:invert_signs) +call s:HL('GruvboxOrangeSign', s:orange, s:sign_column, s:invert_signs) " }}} @@ -888,6 +889,30 @@ hi! link NERDTreeToggleOff GruvboxRed call s:HL('multiple_cursors_cursor', s:none, s:none, s:inverse) call s:HL('multiple_cursors_visual', s:none, s:bg2) +" }}} +" coc.nvim: {{{ + +hi! link CocErrorSign GruvboxRedSign +hi! link CocWarningSign GruvboxOrangeSign +hi! link CocInfoSign GruvboxYellowSign +hi! link CocHintSign GruvboxBlueSign +hi! link CocErrorFloat GruvboxRed +hi! link CocWarningFloat GruvboxOrange +hi! link CocInfoFloat GruvboxYellow +hi! link CocHintFloat GruvboxBlue +hi! link CocDiagnosticsError GruvboxRed +hi! link CocDiagnosticsWarning GruvboxOrange +hi! link CocDiagnosticsInfo GruvboxYellow +hi! link CocDiagnosticsHint GruvboxBlue + +hi! link CocSelectedText GruvboxRed +hi! link CocCodeLens GruvboxGray + +call s:HL('CocErrorHighlight', s:none, s:none, s:undercurl, s:red) +call s:HL('CocWarningHighlight', s:none, s:none, s:undercurl, s:orange) +call s:HL('CocInfoHighlight', s:none, s:none, s:undercurl, s:yellow) +call s:HL('CocHintHighlight', s:none, s:none, s:undercurl, s:blue) + " }}} " Filetype specific ----------------------------------------------------------- diff --git a/sources_non_forked/lightline.vim/.github/workflows/ci.yaml b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml new file mode 100644 index 00000000..0a3e5685 --- /dev/null +++ b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml @@ -0,0 +1,33 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + vim: + - v8.2.0000 + - v8.1.0000 + - v8.0.0000 + - v7.4 + - v7.3 + steps: + - name: Checkout code + uses: actions/checkout@master + - name: Checkout vim-themis + uses: actions/checkout@master + with: + repository: thinca/vim-themis + path: vim-themis + - name: Setup Vim + uses: rhysd/action-setup-vim@v1 + id: vim + with: + version: ${{ matrix.vim }} + - name: Test + env: + THEMIS_VIM: ${{ steps.vim.outputs.executable }} + run: ./vim-themis/bin/themis --reporter spec diff --git a/sources_non_forked/lightline.vim/.travis.yml b/sources_non_forked/lightline.vim/.travis.yml deleted file mode 100644 index e7e41c51..00000000 --- a/sources_non_forked/lightline.vim/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: generic - -install: - - git clone --depth=1 https://github.com/thinca/vim-themis /tmp/themis - - (if ! test -d $HOME/vim-$VIM_VERSION/bin; then - git clone https://github.com/vim/vim $HOME/vim && - cd $HOME/vim && - git checkout v$VIM_VERSION && - ./configure --prefix=$HOME/vim-$VIM_VERSION && - make && - make install; - fi) - -cache: - directories: - - $HOME/vim-$VIM_VERSION - -env: - - VIM_VERSION=8.2.0000 - - VIM_VERSION=8.1.0000 - - VIM_VERSION=8.0.0000 - - VIM_VERSION=7.4 - - VIM_VERSION=7.3 - -script: - - export PATH=$HOME/vim-$VIM_VERSION/bin:$PATH - - vim --version - - /tmp/themis/bin/themis --reporter spec diff --git a/sources_non_forked/lightline.vim/autoload/lightline.vim b/sources_non_forked/lightline.vim/autoload/lightline.vim index 07800f42..0e5d401a 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline.vim " Author: itchyny " License: MIT License -" Last Change: 2020/01/27 19:41:58. +" Last Change: 2020/03/16 19:10:15. " ============================================================================= let s:save_cpo = &cpo @@ -24,16 +24,9 @@ function! lightline#update() abort let s = winnr('$') == 1 && w > 0 ? [lightline#statusline(0)] : [lightline#statusline(0), lightline#statusline(1)] for n in range(1, winnr('$')) call setwinvar(n, '&statusline', s[n!=w]) - call setwinvar(n, 'lightline', n!=w) endfor endfunction -function! lightline#update_once() abort - if !exists('w:lightline') || w:lightline - call lightline#update() - endif -endfunction - function! lightline#update_disable() abort if !s:lightline.enable.statusline return @@ -46,14 +39,13 @@ function! lightline#enable() abort call lightline#update() augroup lightline autocmd! - autocmd WinEnter,BufEnter,SessionLoadPost * call lightline#update() + autocmd WinEnter,BufEnter,BufDelete,SessionLoadPost,FileChangedShellPost * call lightline#update() if !has('patch-8.1.1715') autocmd FileType qf call lightline#update() endif autocmd SessionLoadPost * call lightline#highlight() autocmd ColorScheme * if !has('vim_starting') || expand('') !=# 'macvim' \ | call lightline#update() | call lightline#highlight() | endif - autocmd CursorMoved,BufUnload * call lightline#update_once() augroup END augroup lightline-disable autocmd! @@ -224,7 +216,7 @@ endfunction let s:mode = '' function! lightline#link(...) abort let mode = get(s:lightline._mode_, a:0 ? a:1 : mode(), 'normal') - if s:mode == mode + if s:mode ==# mode return '' endif let s:mode = mode diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim new file mode 100644 index 00000000..9505c01d --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim @@ -0,0 +1,39 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/ayu_light.vim +" Author: christalib +" License: MIT License +" Last Change: 2020/02/15 18:45:57. +" ============================================================================= +let s:base0 = [ '#5C6773', 244 ] +let s:base1 = [ '#5C6773', 247 ] +let s:base2 = [ '#828C99', 248 ] +let s:base3 = [ '#5C6773', 252 ] +let s:base00 = [ '#FFFFFF', 242 ] +let s:base01 = [ '#FFFFFF', 240 ] +let s:base02 = [ '#FAFAFA', 238 ] +let s:base023 = [ '#FAFAFA', 236 ] +let s:base03 = [ '#E6B673', 235 ] +let s:yellow = [ '#E6B673', 180 ] +let s:orange = [ '#FF7733', 173 ] +let s:red = [ '#f07178', 203 ] +let s:magenta = [ '#A37ACC', 216 ] +let s:blue = [ '#59c2ff', 117 ] +let s:cyan = s:blue +let s:green = [ '#86B300', 119 ] +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base1, s:base01 ], [ s:base3, s:base01 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.inactive.right = [ [ s:base1, s:base01 ], [ s:base2, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base02, s:base03 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] +let g:lightline#colorscheme#ayu_light#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim index 0a7da609..7471a6b5 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/deus.vim " Author: nikersify " License: MIT License -" Last Change: 2018/01/24 13:26:00 +" Last Change: 2020/02/15 20:56:45. " ============================================================================= let s:term_red = 204 @@ -20,7 +20,6 @@ let s:p.normal.left = [ [ '#292c33', '#98c379', s:term_black, s:term_green, 'bol let s:p.normal.right = [ [ '#292c33', '#98c379', s:term_black, s:term_green ], [ '#abb2bf', '#3e4452', s:term_white, s:term_grey ], [ '#98c379', '#292c33', s:term_green, s:term_black ] ] let s:p.inactive.right = [ [ '#292c33', '#61afef', s:term_black, s:term_blue], [ '#abb2bf', '#3e4452', s:term_white, s:term_grey ] ] let s:p.inactive.left = s:p.inactive.right[1:] -" her let s:p.insert.left = [ [ '#292c33', '#61afef', s:term_black, s:term_blue, 'bold' ], [ '#61afef', '#292c33', s:term_blue, s:term_black ] ] let s:p.insert.right = [ [ '#292c33', '#61afef', s:term_black, s:term_blue ], [ '#ABB2BF', '#3E4452', s:term_white, s:term_grey ], [ '#61afef', '#292c33', s:term_blue, s:term_black ] ] let s:p.replace.left = [ [ '#292c33', '#e06c75', s:term_black, s:term_red, 'bold' ], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim index 9d066a1b..c17cafbc 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim @@ -2,9 +2,9 @@ " Filename: autoload/lightline/colorscheme/molokai.vim " Author: challsted " License: MIT License -" Last Change: 2016/11/17 00:27:58. +" Last Change: 2020/02/15 20:57:45. " ============================================================================= -" + let s:black = [ '#232526', 233 ] let s:gray = [ '#808080', 244 ] let s:white = [ '#f8f8f2', 234 ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim index d6ee9c6b..53788311 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/solarized.vim " Author: itchyny " License: MIT License -" Last Change: 2017/11/25 11:13:46. +" Last Change: 2020/04/06 19:22:53. " ============================================================================= let s:cuicolors = { @@ -73,7 +73,7 @@ let s:p.inactive.middle = [ [ s:base01, s:base02 ] ] let s:p.tabline.left = [ [ s:base03, s:base00 ] ] let s:p.tabline.tabsel = [ [ s:base03, s:base1 ] ] let s:p.tabline.middle = [ [ s:base0, s:base02 ] ] -let s:p.tabline.right = copy(s:p.normal.right) +let s:p.tabline.right = copy(s:p.tabline.left) let s:p.normal.error = [ [ s:base03, s:red ] ] let s:p.normal.warning = [ [ s:base03, s:yellow ] ] diff --git a/sources_non_forked/lightline.vim/colorscheme.md b/sources_non_forked/lightline.vim/colorscheme.md index 5b944ab6..14fa1787 100644 --- a/sources_non_forked/lightline.vim/colorscheme.md +++ b/sources_non_forked/lightline.vim/colorscheme.md @@ -48,6 +48,10 @@ ![lightline.vim - ayu mirage](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_mirage.png) +### ayu_light + +![lightline.vim - ayu light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_light.png) + ### darcula ![lightline.vim - darcula](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/darcula.png) diff --git a/sources_non_forked/lightline.vim/doc/lightline.txt b/sources_non_forked/lightline.vim/doc/lightline.txt index c94b63d0..10ab0987 100644 --- a/sources_non_forked/lightline.vim/doc/lightline.txt +++ b/sources_non_forked/lightline.vim/doc/lightline.txt @@ -4,7 +4,7 @@ Version: 0.1 Author: itchyny (https://github.com/itchyny) License: MIT License Repository: https://github.com/itchyny/lightline.vim -Last Change: 2020/01/28 18:40:21. +Last Change: 2020/02/15 18:44:06. CONTENTS *lightline-contents* @@ -231,7 +231,7 @@ OPTIONS *lightline-option* Tomorrow, Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Bright, Tomorrow_Night_Eighties, PaperColor, landscape, one, materia, material, OldHope, nord, deus, - srcery_drk, ayu_mirage and 16color are available. + srcery_drk, ayu_mirage, ayu_light and 16color are available. The default value is: > let g:lightline.colorscheme = 'default' diff --git a/sources_non_forked/lightline.vim/plugin/lightline.vim b/sources_non_forked/lightline.vim/plugin/lightline.vim index d08517d7..a11d6622 100644 --- a/sources_non_forked/lightline.vim/plugin/lightline.vim +++ b/sources_non_forked/lightline.vim/plugin/lightline.vim @@ -2,7 +2,7 @@ " Filename: plugin/lightline.vim " Author: itchyny " License: MIT License -" Last Change: 2019/07/30 12:00:00. +" Last Change: 2020/03/16 19:08:41. " ============================================================================= if exists('g:loaded_lightline') || v:version < 700 @@ -15,14 +15,13 @@ set cpo&vim augroup lightline autocmd! - autocmd WinEnter,BufEnter,SessionLoadPost * call lightline#update() + autocmd WinEnter,BufEnter,BufDelete,SessionLoadPost,FileChangedShellPost * call lightline#update() if !has('patch-8.1.1715') autocmd FileType qf call lightline#update() endif autocmd SessionLoadPost * call lightline#highlight() autocmd ColorScheme * if !has('vim_starting') || expand('') !=# 'macvim' \ | call lightline#update() | call lightline#highlight() | endif - autocmd CursorMoved,BufUnload * call lightline#update_once() augroup END " This quickfix option was introduced at Vim 85850f3a5ef9, which is the commit diff --git a/sources_non_forked/nerdtree/CHANGELOG.md b/sources_non_forked/nerdtree/CHANGELOG.md index e163c6c9..d0de2be7 100644 --- a/sources_non_forked/nerdtree/CHANGELOG.md +++ b/sources_non_forked/nerdtree/CHANGELOG.md @@ -1,12 +1,21 @@ # NERDTree Change Log - - +#### 6.7 +- **.7**: Put '%' argument in bufname() for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) +- **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103) +- **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] ` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) +- **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) +- **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098) +- **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) +- **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094) +- **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090) +#### 6.6 +- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087) +- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) #### 6.5 - **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083) #### 6.4 diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown index e7632420..09173a65 100644 --- a/sources_non_forked/nerdtree/README.markdown +++ b/sources_non_forked/nerdtree/README.markdown @@ -59,6 +59,13 @@ Plug 'preservim/nerdtree' call plug#end() ``` +#### [dein.vim](https://github.com/Shougo/dein.vim) +```vim +call dein#begin() +call dein#add('preservim/nerdtree') +call dein#end() +``` + #### [apt-vim](https://github.com/egalpin/apt-vim) ```bash apt-vim install -y https://github.com/preservim/nerdtree.git @@ -143,3 +150,8 @@ Use these variables in your vimrc. Note that below are default arrow symbols let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' ``` +You can remove the arrows altogether by setting these variables to empty strings, as shown below. This will remove not only the arrows, but a single space following them, shifting the whole tree two character positions to the left. +```vim +let g:NERDTreeDirArrowExpandable = '' +let g:NERDTreeDirArrowCollapsible = '' +``` diff --git a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim index 57af126b..aef1b046 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim @@ -284,6 +284,7 @@ endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 function! s:findAndRevealPath(pathStr) abort let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') + let l:revealOpts = {} if empty(l:pathStr) call nerdtree#echoWarning('no file for the current buffer') @@ -292,6 +293,7 @@ function! s:findAndRevealPath(pathStr) abort if !filereadable(l:pathStr) let l:pathStr = fnamemodify(l:pathStr, ':h') + let l:revealOpts['open'] = 1 endif try @@ -327,7 +329,7 @@ function! s:findAndRevealPath(pathStr) abort call b:NERDTree.ui.setShowHidden(1) endif - let l:node = b:NERDTree.root.reveal(l:pathObj) + let l:node = b:NERDTree.root.reveal(l:pathObj, l:revealOpts) call b:NERDTree.render() call l:node.putCursorHere(1, 0) endfunction diff --git a/sources_non_forked/nerdtree/doc/NERDTree.txt b/sources_non_forked/nerdtree/doc/NERDTree.txt index e2dd56a3..47d65ccc 100644 --- a/sources_non_forked/nerdtree/doc/NERDTree.txt +++ b/sources_non_forked/nerdtree/doc/NERDTree.txt @@ -1223,13 +1223,19 @@ Values: Any single character. Defaults: Windows: ~ and + Others: ▾ and ▸ These characters indicate whether a directory is collapsible or expandable. - -They can be set to "\u00a0" to hide the arrows, but if you do this you may -need to change the node delimiter. See |NERDTreeNodeDelimiter|. You cannot use -the same character for both the arrows and the delimiter. Example: > +Example: > let NERDTreeDirArrowExpandable=">" let NERDTreeDirArrowCollapsible="v" < +They can be set to "\u00a0" to replace the arrows with a non-breaking space. +If you do this you may need to change the node delimiter. See +|NERDTreeNodeDelimiter|. You cannot use the same character for both the arrows +and the delimiter. + +Alternatively, they can be set to '' (an empty string). This removes the +arrows and the single space that follows them, shifting the entire tree two +character positions to the left. + ------------------------------------------------------------------------------ *NERDTreeNodeDelimiter* Values: Any single character. diff --git a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim index e2b3fa0a..abaa8dbe 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim @@ -366,7 +366,7 @@ function! s:Creator.toggleTabTree(dir) if g:NERDTree.ExistsForTab() if !g:NERDTree.IsOpen() call self._createTreeWin() - if !empty(a:dir) + if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str() call self.createTabTree(a:dir) elseif !&hidden call b:NERDTree.render() diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim index d8dba34e..0d9f9ba8 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -195,7 +195,7 @@ function! s:Opener._newVSplit() endif call nerdtree#exec('wincmd p', 1) - call nerdtree#exec('vnew', 1) + call nerdtree#exec('vsplit', 1) let l:currentWindowNumber = winnr() diff --git a/sources_non_forked/nerdtree/lib/nerdtree/path.vim b/sources_non_forked/nerdtree/lib/nerdtree/path.vim index 6a23c7ba..2ac8c71c 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/path.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -199,7 +199,7 @@ function! s:Path.copy(dest) let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd) endif - let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars()) + let cmd = cmd_prefix . ' ' . shellescape(self.str()) . ' ' . shellescape(a:dest) let success = system(cmd) if v:shell_error !=# 0 throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'" @@ -295,7 +295,10 @@ endfunction " FUNCTION: Path.edit() {{{1 function! s:Path.edit() - exec 'edit ' . self.str({'format': 'Edit'}) + let l:bufname = self.str({'format': 'Edit'}) + if bufname('%') !=# l:bufname + exec 'edit ' . l:bufname + endif endfunction " FUNCTION: Path.extractDriveLetter(fullpath) {{{1 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim index 1502ea73..88ac319f 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim @@ -104,16 +104,11 @@ function! s:TreeDirNode.displayString() endfor " Select the appropriate open/closed status indicator symbol. - if l:cascade[-1].isOpen - let l:symbol = g:NERDTreeDirArrowCollapsible - else - let l:symbol = g:NERDTreeDirArrowExpandable - endif - + let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable ) + let l:symbol .= (g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') let l:flags = l:cascade[-1].path.flagSet.renderToString() - let l:result = l:symbol . ' ' . l:flags . l:label - return l:result + return l:symbol . l:flags . l:label endfunction " FUNCTION: TreeDirNode.findNode(path) {{{1 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim index 34074a25..957b98ac 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim @@ -321,13 +321,9 @@ function! s:TreeFileNode._renderToString(depth, drawText) if a:drawText ==# 1 let treeParts = repeat(' ', a:depth - 1) - - if !self.path.isDirectory - let treeParts = treeParts . ' ' - endif + let treeParts .= (self.path.isDirectory || g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') let line = treeParts . self.displayString() - let output = output . line . "\n" endif diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim index fc9db71e..9ffadf6e 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -284,7 +284,11 @@ endfunction function! s:UI._indentLevelFor(line) " Replace multi-character DirArrows with a single space so the " indentation calculation doesn't get messed up. - let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + if g:NERDTreeDirArrowExpandable ==# '' + let l:line = ' '.a:line + else + let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + endif let leadChars = match(l:line, '\M\[^ ]') return leadChars / s:UI.IndentWid() endfunction diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim index 281116fd..9750976f 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -209,7 +209,8 @@ function! NERDTreeMoveNode() try if curNode.path.isDirectory - let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"') + let l:curPath = escape(curNode.path.str(),'\') . (nerdtree#runningWindows()?'\\':'/') . '.*' + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# "'.escape(l:curPath,'\').'"') else let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') endif @@ -387,44 +388,67 @@ endfunction " FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeRevealInFinder() {{{1 function! NERDTreeRevealInFinder() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("open -R '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('open -R ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeExecuteFile() {{{1 function! NERDTreeExecuteFile() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("open '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('open ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeRevealFileLinux() {{{1 function! NERDTreeRevealFileLinux() - let treenode = g:NERDTreeFileNode.GetSelected() - let parentnode = treenode.parent - if parentnode !=# {} - call system("xdg-open '" . parentnode.path.str() . "' &") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + " Handle the edge case of "/", which has no parent. + if l:node.path.str() ==# '/' + call system('xdg-open /') + return + endif + + if empty(l:node.parent) + return + endif + + call system('xdg-open ' . shellescape(l:node.parent.path.str())) endfunction " FUNCTION: NERDTreeExecuteFileLinux() {{{1 function! NERDTreeExecuteFileLinux() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("xdg-open '" . treenode.path.str() . "' &") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('xdg-open ' . shellescape(l:node.path.str())) endfunction " vim: set sw=4 sts=4 et fdm=marker: - diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim b/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim index 36d5427e..d20e35e5 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim @@ -34,7 +34,7 @@ endfunction function! s:FindParentVCSRoot(path) let l:path = a:path while !empty(l:path) && - \ l:path._str() !~# '^\(\a:\\\|\/\)$' && + \ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' && \ !isdirectory(l:path._str() . '/.git') && \ !isdirectory(l:path._str() . '/.svn') && \ !isdirectory(l:path._str() . '/.hg') && @@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path) \ !isdirectory(l:path._str() . '/_darcs') let l:path = l:path.getParent() endwhile - return (empty(l:path) || l:path._str() =~# '^\(\a:\\\|\/\)$') ? a:path : l:path + return (empty(l:path) || l:path._str() =~# '^\(\a:[\\\/]\|\/\)$') ? a:path : l:path endfunction diff --git a/sources_non_forked/nerdtree/syntax/nerdtree.vim b/sources_non_forked/nerdtree/syntax/nerdtree.vim index 0df9d12e..df0c8046 100644 --- a/sources_non_forked/nerdtree/syntax/nerdtree.vim +++ b/sources_non_forked/nerdtree/syntax/nerdtree.vim @@ -19,24 +19,7 @@ syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir -"highlighing for directory nodes and file nodes -syn match NERDTreeDirSlash #/# containedin=NERDTreeDir - -exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' -exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' - -let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') -exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' -syn match NERDTreeExecFile '^ .*\*\($\| \)' contains=NERDTreeRO,NERDTreeBookmark -exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' - -"highlighting for readonly files -exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' - -syn match NERDTreeFlags #^ *\zs\[[^\]]*\]# containedin=NERDTreeFile,NERDTreeExecFile -syn match NERDTreeFlags #\[[^\]]*\]# containedin=NERDTreeDir - -"highlighing to conceal the delimiter around the file/dir name +"highlighting to conceal the delimiter around the file/dir name if has('conceal') exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' setlocal conceallevel=3 concealcursor=nvic @@ -45,6 +28,27 @@ else hi! link NERDTreeNodeDelimiters Ignore endif +"highlighing for directory nodes and file nodes +syn match NERDTreeDirSlash #/# containedin=NERDTreeDir + +if g:NERDTreeDirArrowExpandable !=# '' + exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') + exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' + exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark' + exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' +else + exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#' + exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark' + exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' +endif + +"highlighting for readonly files +exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' + +exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeDir' + syn match NERDTreeCWD #^[(MatchitNormalForward)') ==# '' + keepjumps normal! % + else + " Prefer matchit.vim official plugin to native % since the plugin + " provides better behavior than original % (#391) + " To load the plugin, run: + " :packadd matchit + execute 'keepjumps' 'normal' "\(MatchitNormalForward)" + endif if line('.') < cursor_line return '' endif @@ -541,21 +549,20 @@ function! rust#Test(mods, winsize, all, options) abort let saved = getpos('.') try let func_name = s:SearchTestFunctionNameUnderCursor() - if func_name ==# '' - echohl ErrorMsg - echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' - echohl None - return - endif - if a:options ==# '' - execute cmd . 'cargo test --manifest-path' manifest func_name - else - execute cmd . 'cargo test --manifest-path' manifest func_name a:options - endif - return finally call setpos('.', saved) endtry + if func_name ==# '' + echohl ErrorMsg + echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' + echohl None + return + endif + if a:options ==# '' + execute cmd . 'cargo test --manifest-path' manifest func_name + else + execute cmd . 'cargo test --manifest-path' manifest func_name a:options + endif endfunction " }}}1 diff --git a/sources_non_forked/rust.vim/compiler/rustc.vim b/sources_non_forked/rust.vim/compiler/rustc.vim index c8e77005..9b70732a 100644 --- a/sources_non_forked/rust.vim/compiler/rustc.vim +++ b/sources_non_forked/rust.vim/compiler/rustc.vim @@ -24,7 +24,7 @@ else if has('patch-7.4.191') CompilerSet makeprg=rustc\ \%:S else - CompilerSet makeprg=rustc\ \% + CompilerSet makeprg=rustc\ \"%\" endif endif diff --git a/sources_non_forked/rust.vim/doc/rust.txt b/sources_non_forked/rust.vim/doc/rust.txt index c3efb461..9d5eb8cc 100644 --- a/sources_non_forked/rust.vim/doc/rust.txt +++ b/sources_non_forked/rust.vim/doc/rust.txt @@ -125,7 +125,7 @@ g:rustfmt_autosave~ < There is also a buffer-local b:rustfmt_autosave that can be set for the same purpose, and can override the global setting. - + *g:rustfmt_autosave_if_config_present* g:rustfmt_autosave_if_config_present~ Set this option to 1 to have *b:rustfmt_autosave* be set automatically @@ -187,6 +187,16 @@ g:cargo_makeprg_params~ let g:cargo_makeprg_params = 'build' < + *g:cargo_shell_command_runner* +g:cargo_shell_command_runner~ + Set this option to change how to run shell commands for cargo commands + |:Cargo|, |:Cbuild|, |:Crun|, ... + By default, |:terminal| is used to run shell command in terminal window + asynchronously. But if you prefer |:!| for running the commands, it can + be specified: > + let g:cargo_shell_command_runner = '!' +< + Integration with Syntastic *rust-syntastic* -------------------------- diff --git a/sources_non_forked/rust.vim/ftplugin/rust.vim b/sources_non_forked/rust.vim/ftplugin/rust.vim index ac1b438a..ce48116e 100644 --- a/sources_non_forked/rust.vim/ftplugin/rust.vim +++ b/sources_non_forked/rust.vim/ftplugin/rust.vim @@ -121,7 +121,7 @@ command! -nargs=* -buffer RustEmitAsm call rust#Emit("asm", ) command! -range=% RustPlay :call rust#Play(, , , ) " See |:RustFmt| for docs -command! -buffer RustFmt call rustfmt#Format() +command! -bar -buffer RustFmt call rustfmt#Format() " See |:RustFmtRange| for docs command! -range -buffer RustFmtRange call rustfmt#FormatRange(, ) diff --git a/sources_non_forked/rust.vim/triagebot.toml b/sources_non_forked/rust.vim/triagebot.toml new file mode 100644 index 00000000..fa0824ac --- /dev/null +++ b/sources_non_forked/rust.vim/triagebot.toml @@ -0,0 +1 @@ +[assign] diff --git a/sources_non_forked/typescript-vim/indent/typescript.vim b/sources_non_forked/typescript-vim/indent/typescript.vim index 81373985..3ee9aa01 100644 --- a/sources_non_forked/typescript-vim/indent/typescript.vim +++ b/sources_non_forked/typescript-vim/indent/typescript.vim @@ -169,7 +169,7 @@ endfunction function s:PrevCodeLine(lnum) let l:n = prevnonblank(a:lnum) while l:n - if getline(l:n) =~ '^\s*\/[/*]' + if getline(l:n) =~ '^\s*\/[/*]' if (stridx(getline(l:n),'`') > 0 || getline(l:n-1)[-1:] == '\') && \ s:syn_at(l:n,1) =~? s:syng_str return l:n @@ -293,8 +293,9 @@ function GetTypescriptIndent() let l:line = '' endif - " the containing paren, bracket, or curly. Many hacks for performance - let idx = index([']',')','}'],l:line[0]) + " the containing paren, bracket, curly, or closing '>'. + " Many hacks for performance + let idx = index([']',')','}','>'],l:line[0]) if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum && \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum)) call call('cursor',b:js_cache[1:]) diff --git a/sources_non_forked/typescript-vim/syntax/typescript.vim b/sources_non_forked/typescript-vim/syntax/typescript.vim index 705016d1..8c6ecf22 100644 --- a/sources_non_forked/typescript-vim/syntax/typescript.vim +++ b/sources_non_forked/typescript-vim/syntax/typescript.vim @@ -223,10 +223,11 @@ syn region foldBraces start=/{/ skip=/\(\/\/.*\)\|\(\/.*\/\)/ end=/}/ transparen " }}} " Define the default highlighting. -" For version 5.7 and earlier: only when not done already +" For version 5.7 and earlier: only when not done already by this script " For version 5.8 and later: only when an item doesn't have highlighting yet +" For version 8.1.1486 and later: only when not done already by this script (need to override vim's new typescript support) if version >= 508 || !exists("did_typescript_syn_inits") - if version < 508 + if version < 508 || has('patch-8.1.1486') let did_typescript_syn_inits = 1 command -nargs=+ HiLink hi link else diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim index 6fd3f044..e93820c2 100644 --- a/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim +++ b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim @@ -2,7 +2,8 @@ " TODO refactor: create glob function " noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"\\.git\\\\.hg\\node_modules\\\\.pyc" ) " noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"default" ) -function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern) +function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern, ...) + let opts = a:0 > 0 ? a:1 : {} if a:exclude_pattern == "default" let exclude_pattern = '\.git\|\.hg\|node_modules\|\.pyc' else @@ -16,7 +17,7 @@ function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern) let exclude = exclude_pattern == '' ? '' : ' | grep -v -e '.shellescape(exclude_pattern) - let cmd = 'find | grep -e '.shellescape(g).exclude + let cmd = get(opts, 'cmd_find', 'find'). ' . | grep -e '.shellescape(g).exclude let files = split(system(cmd),"\n") " for nom in a:excludes " call filter(files,nom) diff --git a/sources_non_forked/vim-flake8/README.mdown b/sources_non_forked/vim-flake8/README.mdown index 5d4e00c8..338e4450 100644 --- a/sources_non_forked/vim-flake8/README.mdown +++ b/sources_non_forked/vim-flake8/README.mdown @@ -104,6 +104,12 @@ To customize the colors used for markers, define the highlight groups, `Flake8_E highlight link Flake8_Naming WarningMsg highlight link Flake8_PyFlake WarningMsg +To show the error message of the current line in the ruler, call `flake8#ShowError()`: + + " add binding to call the function + nnoremap :call flake8#Flake8ShowError() + + Tips ---- A tip might be to run the Flake8 check every time you write a Python file, to diff --git a/sources_non_forked/vim-flake8/autoload/flake8.vim b/sources_non_forked/vim-flake8/autoload/flake8.vim index cf592cf7..180bcadb 100644 --- a/sources_non_forked/vim-flake8/autoload/flake8.vim +++ b/sources_non_forked/vim-flake8/autoload/flake8.vim @@ -20,6 +20,10 @@ function! flake8#Flake8UnplaceMarkers() call s:Warnings() endfunction +function! flake8#Flake8ShowError() + call s:ShowErrorMessage() +endfunction + "" }}} "" ** internal ** {{{ @@ -101,6 +105,7 @@ function! s:Setup() " {{{ let s:markerdata['F'].marker = s:flake8_pyflake_marker let s:markerdata['C'].marker = s:flake8_complexity_marker let s:markerdata['N'].marker = s:flake8_naming_marker + endfunction " }}} "" do flake8 @@ -154,11 +159,20 @@ function! s:Flake8() " {{{ let &shellpipe=l:old_shellpipe let &t_ti=l:old_t_ti let &t_te=l:old_t_te + " store mapping of line number to error string " process results + let s:resultDict = {} + let l:results=getqflist() let l:has_results=results != [] if l:has_results + " save line number of each error message + for result in l:results + let linenum = result.lnum + let s:resultDict[linenum] = result.text + endfor + " markers if !s:flake8_show_in_gutter == 0 || !s:flake8_show_in_file == 0 call s:PlaceMarkers(l:results) @@ -184,8 +198,9 @@ function! s:Flake8() " {{{ endif endfunction " }}} -"" markers + +"" markers function! s:PlaceMarkers(results) " {{{ " in gutter? if !s:flake8_show_in_gutter == 0 @@ -253,6 +268,29 @@ function! s:UnplaceMarkers() " {{{ endfor endfunction " }}} +function! s:ShowErrorMessage() " {{{ + let l:cursorPos = getpos(".") + if !exists('s:resultDict') + return + endif + + " if there is a message on the current line, + " then echo it + if has_key(s:resultDict, l:cursorPos[1]) + let l:errorText = get(s:resultDict, l:cursorPos[1]) + echo strpart(l:errorText, 0, &columns-1) + let b:showing_message = 1 + endif + + " if a message is already being shown, + " then clear it + if !b:showing_message == 0 + echo + let b:showing_message = 0 + endif + +endfunction " }}} + "" }}} let &cpo = s:save_cpo diff --git a/sources_non_forked/vim-fugitive/autoload/fugitive.vim b/sources_non_forked/vim-fugitive/autoload/fugitive.vim index 2823ec13..78a572c4 100644 --- a/sources_non_forked/vim-fugitive/autoload/fugitive.vim +++ b/sources_non_forked/vim-fugitive/autoload/fugitive.vim @@ -45,13 +45,23 @@ 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_/:.-]\+$' + elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' return a:arg elseif s:winshell() - return '"'.s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"').'"' + return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' else return shellescape(a:arg) endif @@ -107,8 +117,13 @@ function! s:Resolve(path) abort 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 exists('+fileignorecase') && &fileignorecase + if s:FileIgnoreCase(0) let path = FugitiveVimPath(tolower(a:path)) else let path = FugitiveVimPath(a:path) @@ -116,19 +131,6 @@ function! s:cpath(path, ...) abort return a:0 ? path ==# s:cpath(a:1) : path endfunction -function! s:Cd(...) abort - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd' - if !a:0 - return cd - endif - let cwd = getcwd() - if s:cpath(cwd, a:1) - return '' - endif - exe cd s:fnameescape(a:1) - return cd . ' ' . s:fnameescape(cwd) -endfunction - let s:executables = {} function! s:executable(binary) abort @@ -193,94 +195,20 @@ function! s:Map(mode, lhs, rhs, ...) abort endfor endfunction -" Section: Quickfix - -function! s:QuickfixGet(nr, ...) abort - if a:nr < 0 - return call('getqflist', a:000) - else - return call('getloclist', [a:nr] + a:000) - endif -endfunction - -function! s:QuickfixSet(nr, ...) abort - if a:nr < 0 - return call('setqflist', a:000) - else - return call('setloclist', [a:nr] + a:000) - endif -endfunction - -function! s:QuickfixCreate(nr, opts) abort - if has('patch-7.4.2200') - call s:QuickfixSet(a:nr, [], ' ', a:opts) - else - call s:QuickfixSet(a:nr, [], ' ') - endif -endfunction - -function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort - let opts = {'title': a:title, 'context': {'items': []}} - call s:QuickfixCreate(a:nr, opts) - let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event - silent exe s:DoAutocmd('QuickFixCmdPre ' . event) - let winnr = winnr() - exe a:nr < 0 ? 'copen' : 'lopen' - if winnr != winnr() - wincmd p - endif - - let buffer = [] - let lines = split(s:SystemError(s:shellesc(a:cmd))[0], "\n") - for line in lines - call extend(buffer, call(a:callback, a:000 + [line])) - if len(buffer) >= 20 - let contexts = map(copy(buffer), 'get(v:val, "context", {})') - lockvar contexts - call extend(opts.context.items, contexts) - unlet contexts - call s:QuickfixSet(a:nr, remove(buffer, 0, -1), 'a') - redraw - endif - endfor - call extend(buffer, call(a:callback, a:000 + [0])) - call extend(opts.context.items, map(copy(buffer), 'get(v:val, "context", {})')) - lockvar opts.context.items - call s:QuickfixSet(a:nr, buffer, 'a') - - silent exe s:DoAutocmd('QuickFixCmdPost ' . event) - if a:first && len(s:QuickfixGet(a:nr)) - call s:BlurStatus() - return a:nr < 0 ? 'cfirst' : 'lfirst' - else - return 'exe' - endif -endfunction - -let s:common_efm = '' - \ . '%+Egit:%.%#,' - \ . '%+Eusage:%.%#,' - \ . '%+Eerror:%.%#,' - \ . '%+Efatal:%.%#,' - \ . '%-G%.%#%\e[K%.%#,' - \ . '%-G%.%#%\r%.%\+' - -function! fugitive#Cwindow() abort - if &buftype == 'quickfix' - cwindow - else - botright cwindow - if &buftype == 'quickfix' - wincmd p - endif - endif -endfunction - " Section: Git function! s:UserCommandList(...) abort let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+') - let dir = a:0 ? s:Dir(a:1) : '' + let flags = [] + if a:0 && type(a:1) == type({}) + let git = copy(get(a:1, 'git', git)) + let flags = get(a:1, 'flags', flags) + let dir = a:1.dir + elseif a:0 + let dir = a:1 + else + let dir = '' + endif if len(dir) let tree = s:Tree(dir) if empty(tree) @@ -293,7 +221,7 @@ function! s:UserCommandList(...) abort endif endif endif - return git + return git + flags endfunction function! s:UserCommand(...) abort @@ -409,9 +337,9 @@ function! fugitive#PrepareDirEnvArgv(...) abort let i = 0 while i < len(cmd) if cmd[i] =~# '^$\|[\/.]' && cmd[i] !~# '^-' - let dir = remove(cmd, 0) + let dir = remove(cmd, i) elseif cmd[i] =~# '^--git-dir=' - let dir = remove(cmd, 0)[10:-1] + let dir = remove(cmd, i)[10:-1] elseif type(cmd[i]) ==# type(0) let dir = s:Dir(remove(cmd, i)) elseif cmd[i] ==# '-c' && len(cmd) > i + 1 @@ -460,6 +388,25 @@ function! s:BuildEnvPrefix(env) abort endif endfunction +function! s:JobOpts(cmd, env) abort + if empty(a:env) + return [a:cmd, {}] + elseif has('patch-8.2.0239') || has('patch-8.1.0902') && !has('nvim') && (!has('win32') || empty(filter(keys(a:env), 'exists("$" . v:val)'))) + return [a:cmd, {'env': a:env}] + endif + let envlist = map(items(a:env), 'join(v:val, "=")') + if !has('win32') + return [['env'] + envlist + a:cmd, {}] + else + let pre = join(map(envlist, '"set " . substitute(v:val, "[&|<>^]", "^^^&", "g") . "& "'), '') + if len(a:cmd) == 3 && a:cmd[0] ==# 'cmd.exe' && a:cmd[1] ==# '/c' + return [a:cmd[0:1] + [pre . a:cmd[2]], {}] + else + return [['cmd.exe', '/c', pre . s:WinShellEsc(a:cmd)], {}] + endif + endif +endfunction + function! s:BuildShell(dir, env, args) abort let cmd = copy(a:args) let tree = s:Tree(a:dir) @@ -534,9 +481,13 @@ function! s:TreeChomp(...) abort endfunction function! s:EchoExec(...) abort - echo call('s:ChompError', a:000)[0] - call fugitive#ReloadStatus(-1, 1) - return 'checktime' + if s:RunJobs() + return 'Git ' . s:fnameescape(a:000) + else + echo call('s:ChompError', a:000)[0] + call fugitive#ReloadStatus(-1, 1) + return 'checktime' + endif endfunction let s:head_cache = {} @@ -614,7 +565,11 @@ function! fugitive#Config(...) abort if !has_key(dict, key) let dict[key] = [] endif - call add(dict[key], strpart(line, len(key) + 1)) + if len(key) ==# len(line) + call add(dict[key], 1) + else + call add(dict[key], strpart(line, len(key) + 1)) + endif endfor let s:config[dir] = [s:ConfigTimestamps(dir, dict), dict] lockvar! dict @@ -643,6 +598,89 @@ function! fugitive#RemoteUrl(...) abort return s:ChompDefault('', [dir, 'remote', 'get-url', remote, '--']) endfunction +" Section: Quickfix + +function! s:QuickfixGet(nr, ...) abort + if a:nr < 0 + return call('getqflist', a:000) + else + return call('getloclist', [a:nr] + a:000) + endif +endfunction + +function! s:QuickfixSet(nr, ...) abort + if a:nr < 0 + return call('setqflist', a:000) + else + return call('setloclist', [a:nr] + a:000) + endif +endfunction + +function! s:QuickfixCreate(nr, opts) abort + if has('patch-7.4.2200') + call s:QuickfixSet(a:nr, [], ' ', a:opts) + else + call s:QuickfixSet(a:nr, [], ' ') + endif +endfunction + +function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort + let opts = {'title': a:title, 'context': {'items': []}} + call s:QuickfixCreate(a:nr, opts) + let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event + silent exe s:DoAutocmd('QuickFixCmdPre ' . event) + let winnr = winnr() + exe a:nr < 0 ? 'copen' : 'lopen' + if winnr != winnr() + wincmd p + endif + + let buffer = [] + let lines = split(s:SystemError(s:shellesc(a:cmd))[0], "\n") + for line in lines + call extend(buffer, call(a:callback, a:000 + [line])) + if len(buffer) >= 20 + let contexts = map(copy(buffer), 'get(v:val, "context", {})') + lockvar contexts + call extend(opts.context.items, contexts) + unlet contexts + call s:QuickfixSet(a:nr, remove(buffer, 0, -1), 'a') + redraw + endif + endfor + call extend(buffer, call(a:callback, a:000 + [0])) + call extend(opts.context.items, map(copy(buffer), 'get(v:val, "context", {})')) + lockvar opts.context.items + call s:QuickfixSet(a:nr, buffer, 'a') + + silent exe s:DoAutocmd('QuickFixCmdPost ' . event) + if a:first && len(s:QuickfixGet(a:nr)) + call s:BlurStatus() + return a:nr < 0 ? 'cfirst' : 'lfirst' + else + return 'exe' + endif +endfunction + +let s:common_efm = '' + \ . '%+Egit:%.%#,' + \ . '%+Eusage:%.%#,' + \ . '%+Eerror:%.%#,' + \ . '%+Efatal:%.%#,' + \ . '%-G%.%#%\e[K%.%#,' + \ . '%-G%.%#%\r%.%\+' + +function! fugitive#Cwindow() abort + if &buftype == 'quickfix' + cwindow + else + botright cwindow + if &buftype == 'quickfix' + wincmd p + endif + endif +endfunction + " Section: Repository Object function! s:add_methods(namespace, method_names) abort @@ -708,23 +746,16 @@ function! s:repo_prepare(...) dict abort endfunction function! s:repo_git_command(...) dict abort - let git = s:UserCommand() . ' --git-dir='.s:shellesc(self.git_dir) + let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir) return git.join(map(copy(a:000),'" ".s:shellesc(v:val)'),'') endfunction function! s:repo_git_chomp(...) dict abort - let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir) - let output = git . join(map(copy(a:000),'" ".s:shellesc(v:val)'),'') - return s:sub(system(output), '\n$', '') + return s:sub(system(FugitivePrepare(a:000, self.git_dir)), '\n$', '') endfunction function! s:repo_git_chomp_in_tree(...) dict abort - let cdback = s:Cd(self.tree()) - try - return call(self.git_chomp, a:000, self) - finally - execute cdback - endtry + return call(self.git_chomp, a:000, self) endfunction function! s:repo_rev_parse(rev) dict abort @@ -1285,6 +1316,12 @@ function! fugitive#getfperm(url) abort return perm ==# '---------' ? '' : perm endfunction +function s:UpdateIndex(dir, info) abort + let info = join(a:info[0:-2]) . "\t" . a:info[-1] . "\n" + let [error, exec_error] = s:SystemError([a:dir, 'update-index', '--index-info'], info) + return !exec_error ? '' : len(error) ? error : 'fugitive: unknown update-index error' +endfunction + function! fugitive#setfperm(url, perm) abort let [dir, commit, file] = s:DirCommitFile(a:url) let entry = s:PathInfo(a:url) @@ -1293,9 +1330,8 @@ function! fugitive#setfperm(url, perm) abort \ substitute(perm, 'x', '-', 'g') !=# substitute(a:perm, 'x', '-', 'g') return -2 endif - let exec_error = s:SystemError([dir, 'update-index', '--index-info'], - \ (a:perm =~# 'x' ? '000755 ' : '000644 ') . entry[3] . ' ' . commit . "\t" . file[1:-1])[1] - return exec_error ? -1 : 0 + let error = s:UpdateIndex(dir, [a:perm =~# 'x' ? '000755' : '000644', entry[3], commit, file[1:-1]]) + return len(error) ? -1 : 0 endfunction function! s:TempCmd(out, cmd) abort @@ -1365,9 +1401,8 @@ function! fugitive#writefile(lines, url, ...) abort let [hash, exec_error] = s:ChompError([dir, 'hash-object', '-w', temp]) let mode = len(entry[1]) ? entry[1] : '100644' if !exec_error && hash =~# '^\x\{40,\}$' - let exec_error = s:SystemError([dir, 'update-index', '--index-info'], - \ mode . ' ' . hash . ' ' . commit . "\t" . file[1:-1])[1] - if !exec_error + let error = s:UpdateIndex(dir, [mode, hash, commit, file[1:-1]]) + if empty(error) return 0 endif endif @@ -1420,9 +1455,8 @@ function! fugitive#delete(url, ...) abort if entry[2] !=# 'blob' return -1 endif - let exec_error = s:SystemError([dir, 'update-index', '--index-info'], - \ '000000 0000000000000000000000000000000000000000 ' . commit . "\t" . file[1:-1])[1] - return exec_error ? -1 : 0 + let error = s:UpdateIndex(dir, ['000000', '0000000000000000000000000000000000000000', commit, file[1:-1]]) + return len(error) ? -1 : 0 endfunction " Section: Buffer Object @@ -1451,7 +1485,8 @@ function! s:FilterEscape(items, ...) abort let items = copy(a:items) call map(items, 's:fnameescape(v:val)') if a:0 && type(a:1) == type('') - call filter(items, 'strpart(v:val, 0, strlen(a:1)) ==# a:1') + let cmp = s:FileIgnoreCase(1) ? '==?' : '==#' + call filter(items, 'strpart(v:val, 0, strlen(a:1)) ' . cmp . ' a:1') endif return items endfunction @@ -1470,10 +1505,21 @@ function! s:GlobComplete(lead, pattern) abort endfunction function! fugitive#CompletePath(base, ...) abort - let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir() - let tree = s:Tree(dir) . '/' - let strip = '^\%(:/:\=\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)' - let base = substitute(a:base, strip, '', '') + let dir = a:0 == 1 ? a:1 : a:0 >= 3 ? a:3 : s:Dir() + let stripped = matchstr(a:base, '^\%(:/:\=\|:(top)\|:(top,literal)\|:(literal,top)\)') + let base = strpart(a:base, len(stripped)) + if len(stripped) || a:0 < 4 + let root = s:Tree(dir) + else + let root = a:4 + endif + if root !=# '/' && len(root) + let root .= '/' + endif + if empty(stripped) + let stripped = matchstr(a:base, '^\%(:(literal)\|:\)') + let base = strpart(a:base, len(stripped)) + endif if base =~# '^\.git/' let pattern = s:gsub(base[5:-1], '/', '*&').'*' let matches = s:GlobComplete(dir . '/', pattern) @@ -1485,14 +1531,14 @@ function! fugitive#CompletePath(base, ...) abort call map(matches, "'.git/' . v:val") elseif base =~# '^\~/' let matches = map(s:GlobComplete(expand('~/'), base[2:-1] . '*'), '"~/" . v:val') - elseif a:base =~# '^/\|^\a\+:\|^\.\.\=/\|^:(literal)' + elseif a:base =~# '^/\|^\a\+:\|^\.\.\=/' let matches = s:GlobComplete('', base . '*') - elseif len(tree) > 1 - let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*') + elseif len(root) + let matches = s:GlobComplete(root, s:gsub(base, '/', '*&').'*') else let matches = [] endif - call map(matches, 's:fnameescape(s:Slash(matchstr(a:base, strip) . v:val))') + call map(matches, 's:fnameescape(s:Slash(stripped . v:val))') return matches endfunction @@ -1501,18 +1547,21 @@ function! fugitive#PathComplete(...) abort endfunction function! s:CompleteHeads(dir) abort + if empty(a:dir) + return [] + endif let dir = fugitive#Find('.git/', a:dir) return sort(filter(['HEAD', 'FETCH_HEAD', 'ORIG_HEAD'] + s:merge_heads, 'filereadable(dir . v:val)')) + - \ sort(s:LinesError('rev-parse', '--symbolic', '--branches', '--tags', '--remotes')[0]) + \ sort(s:LinesError([a:dir, 'rev-parse', '--symbolic', '--branches', '--tags', '--remotes'])[0]) endfunction function! fugitive#CompleteObject(base, ...) abort - let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir() + let dir = a:0 == 1 ? a:1 : a:0 >= 3 ? a:3 : s:Dir() + let tree = s:Tree(dir) let cwd = getcwd() - let tree = s:Tree(dir) . '/' let subdir = '' - if len(tree) > 1 && s:cpath(tree, cwd[0 : len(tree) - 1]) - let subdir = strpart(cwd, len(tree)) . '/' + if len(tree) && s:cpath(tree . '/', cwd[0 : len(tree)]) + let subdir = strpart(cwd, len(tree) + 1) . '/' endif if a:base =~# '^\.\=/\|^:(' || a:base !~# ':' @@ -1528,9 +1577,7 @@ function! fugitive#CompleteObject(base, ...) abort endif let results += s:FilterEscape(heads, a:base) endif - if !empty(tree) - let results += a:0 == 1 ? fugitive#CompletePath(a:base, dir) : fugitive#CompletePath(a:base) - endif + let results += a:0 == 1 || a:0 >= 3 ? fugitive#CompletePath(a:base, 0, '', dir, a:0 >= 4 ? a:4 : tree) : fugitive#CompletePath(a:base) return results elseif a:base =~# '^:' @@ -1545,8 +1592,8 @@ function! fugitive#CompleteObject(base, ...) abort endif else - let tree = matchstr(a:base, '.*[:/]') - let entries = s:LinesError(['ls-tree', substitute(tree, ':\zs\./', '\=subdir', '')], dir)[0] + let parent = matchstr(a:base, '.*[:/]') + let entries = s:LinesError(['ls-tree', substitute(parent, ':\zs\./', '\=subdir', '')], dir)[0] call map(entries,'s:sub(v:val,"^04.*\\zs$","/")') call map(entries,'tree.s:sub(v:val,".*\t","")') @@ -1563,24 +1610,25 @@ function! s:CompleteSub(subcommand, A, L, P, ...) abort elseif !a:0 return fugitive#CompleteObject(a:A, s:Dir()) elseif type(a:1) == type(function('tr')) - return call(a:1, [a:A, a:L, a:P]) + return call(a:1, [a:A, a:L, a:P] + (a:0 > 1 ? a:2 : [])) else return s:FilterEscape(a:1, a:A) endif endfunction function! s:CompleteRevision(A, L, P, ...) abort - return s:FilterEscape(s:CompleteHeads(s:Dir()), a:A) + return s:FilterEscape(s:CompleteHeads(a:0 ? a:1 : s:Dir()), a:A) endfunction -function! s:CompleteRemote(A, L, P) abort +function! s:CompleteRemote(A, L, P, ...) abort + let dir = a:0 ? a:1 : s:Dir() let remote = matchstr(a:L, '\u\w*[! ] *\zs\S\+\ze ') if !empty(remote) - let matches = s:LinesError('ls-remote', remote)[0] + let matches = s:LinesError([dir, 'ls-remote', remote])[0] call filter(matches, 'v:val =~# "\t" && v:val !~# "{"') call map(matches, 's:sub(v:val, "^.*\t%(refs/%(heads/|tags/)=)=", "")') else - let matches = s:LinesError('remote')[0] + let matches = s:LinesError([dir, 'remote'])[0] endif return s:FilterEscape(matches, a:A) endfunction @@ -1594,7 +1642,13 @@ function! s:ReplaceCmd(cmd) abort call s:throw((len(err) ? err : filereadable(temp) ? join(readfile(temp), ' ') : 'unknown error running ' . a:cmd)) endif silent exe 'lockmarks keepalt 0read ++edit' s:fnameescape(temp) - silent keepjumps $delete _ + if &foldenable && foldlevel('$') > 0 + set nofoldenable + silent keepjumps $delete _ + set foldenable + else + silent keepjumps $delete _ + endif call delete(temp) if s:cpath(fnamemodify(bufname('$'), ':p'), temp) silent! execute bufnr('$') . 'bwipeout' @@ -1680,6 +1734,10 @@ function! fugitive#BufReadStatus() abort let cmd += ['-c', 'GIT_INDEX_FILE=' . amatch] endif + if fugitive#GitVersion(2, 15) + call add(cmd, '--no-optional-locks') + endif + let b:fugitive_files = {'Staged': {}, 'Unstaged': {}} let [staged, unstaged, untracked] = [[], [], []] let props = {} @@ -1906,7 +1964,7 @@ function! fugitive#BufReadStatus() abort if &bufhidden ==# '' setlocal bufhidden=delete endif - let b:dispatch = ':Gfetch --all' + let b:dispatch = ':Git fetch --all' call fugitive#MapJumps() call s:Map('n', '-', ":execute Do('Toggle',0)", '') call s:Map('x', '-', ":execute Do('Toggle',1)", '') @@ -1921,7 +1979,7 @@ function! fugitive#BufReadStatus() abort call s:MapMotion('gp', "exe StageJump(v:count, 'Unpushed')") call s:MapMotion('gP', "exe StageJump(v:count, 'Unpulled')") call s:MapMotion('gr', "exe StageJump(v:count, 'Rebasing')") - call s:Map('n', 'C', ":Gcommit:echohl WarningMsgecho ':Gstatus C is deprecated in favor of cc'echohl NONE", '') + call s:Map('n', 'C', ":echoerr ':Gstatus C has been removed in favor of cc'", '') call s:Map('n', 'a', ":execute Do('Toggle',0)", '') call s:Map('n', 'i', ":execute NextExpandedHunk(v:count1)", '') call s:Map('n', "=", ":execute StageInline('toggle',line('.'),v:count)", '') @@ -2008,9 +2066,8 @@ function! fugitive#FileWriteCmd(...) abort if empty(old_mode) let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644' endif - let info = old_mode.' '.sha1.' '.commit."\t".file[1:-1] - let [error, exec_error] = s:SystemError([dir, 'update-index', '--index-info'], info . "\n") - if !exec_error + let error = s:UpdateIndex(dir, [old_mode, sha1, commit, file[1:-1]]) + if empty(error) setlocal nomodified if exists('#' . autype . 'WritePost') execute s:DoAutocmd(autype . 'WritePost ' . s:fnameescape(amatch)) @@ -2179,7 +2236,7 @@ function! s:TempReadPre(file) abort if has_key(s:temp_files, s:cpath(a:file)) let dict = s:temp_files[s:cpath(a:file)] setlocal nomodeline - setlocal bufhidden=delete nobuflisted + setlocal bufhidden=delete setlocal buftype=nowrite setlocal nomodifiable if len(dict.dir) @@ -2192,6 +2249,7 @@ endfunction function! s:TempReadPost(file) abort if has_key(s:temp_files, s:cpath(a:file)) let dict = s:temp_files[s:cpath(a:file)] + setlocal nobuflisted if has_key(dict, 'filetype') && dict.filetype !=# &l:filetype let &l:filetype = dict.filetype endif @@ -2260,13 +2318,24 @@ function! s:RunWait(state, job) abort if !exists('*jobwait') sleep 1m endif - let peek = getchar(1) - if peek != 0 && !(has('win32') && peek == 128) - let c = getchar() - let c = type(c) == type(0) ? nr2char(c) : c - call s:RunSend(a:job, c) - if !a:state.pty - echon c + if !get(a:state, 'closed') + let peek = getchar(1) + if peek != 0 && !(has('win32') && peek == 128) + let c = getchar() + let c = type(c) == type(0) ? nr2char(c) : c + if c ==# "\" + let a:state.closed = 1 + if type(a:job) ==# type(0) + call chanclose(a:job, 'stdin') + else + call ch_close_in(a:job) + endif + else + call s:RunSend(a:job, c) + if !a:state.pty + echon c + endif + endif endif endif endwhile @@ -2304,15 +2373,15 @@ endif function! fugitive#Resume() abort while len(s:resume_queue) let [state, job] = remove(s:resume_queue, 0) + if filereadable(state.temp . '.edit') + call delete(state.temp . '.edit') + endif call s:RunWait(state, job) endwhile endfunction function! s:RunBufDelete(bufnr) abort if has_key(s:edit_jobs, a:bufnr) | - if filereadable(s:edit_jobs[a:bufnr][0].temp . '.edit') - call delete(s:edit_jobs[a:bufnr][0].temp . '.edit') - endif call add(s:resume_queue, remove(s:edit_jobs, a:bufnr)) call feedkeys(":redraw!|call fugitive#Resume()|silent checktime\r", 'n') endif @@ -2323,10 +2392,44 @@ augroup fugitive_job autocmd BufDelete * call s:RunBufDelete(expand('')) autocmd VimLeave * \ for s:jobbuf in keys(s:edit_jobs) | - \ call writefile([], remove(s:edit_jobs, s:jobbuf)[0].temp . '.exit') | + \ call writefile([], s:edit_jobs[s:jobbuf][0].temp . '.exit') | + \ redraw! | + \ call call('s:RunWait', remove(s:edit_jobs, s:jobbuf)) | \ endfor augroup END +function! fugitive#PagerFor(argv, ...) abort + let args = a:argv + if empty(args) + return 0 + elseif (args[0] ==# 'help' || get(args, 1, '') ==# '--help') && !s:HasOpt(args, '--web') + return 1 + endif + if args[0] ==# 'config' && (s:HasOpt(args, '-e', '--edit') || + \ !s:HasOpt(args, '--list', '--get-all', '--get-regexp', '--get-urlmatch')) || + \ args[0] =~# '^\%(tag\|branch\)$' && ( + \ s:HasOpt(args, '--edit-description', '--unset-upstream', '-m', '-M', '--move', '-c', '-C', '--copy', '-d', '-D', '--delete') || + \ len(filter(args[1:-1], 'v:val =~# "^[^-]\\|^--set-upstream-to="')) && + \ !s:HasOpt(args, '--contains', '--no-contains', '--merged', '--no-merged', '--points-at')) + return 0 + endif + let config = a:0 ? a:1 : fugitive#Config() + let value = get(FugitiveConfigGetAll('pager.' . args[0], config), 0, -1) + if value =~# '^\%(true\|yes\|on\|1\)$' + return 1 + elseif value =~# '^\%(false\|no|off\|0\|\)$' + return 0 + elseif type(value) == type('') + return value + elseif args[0] =~# 'diff\%(tool\)\@!\|log\|^show$\|^config$\|^branch$\|^tag$' || + \ (args[0] ==# 'stash' && get(args, 1, '') ==# 'show') || + \ (args[0] ==# 'am' && s:HasOpt(args, '--show-current-patch')) + return 1 + else + return 0 + endif +endfunction + let s:disable_colors = [] for s:colortype in ['advice', 'branch', 'diff', 'grep', 'interactive', 'pager', 'push', 'remote', 'showBranch', 'status', 'transport', 'ui'] call extend(s:disable_colors, ['-c', 'color.' . s:colortype . '=false']) @@ -2334,53 +2437,106 @@ endfor unlet s:colortype function! fugitive#Command(line1, line2, range, bang, mods, arg) abort let dir = s:Dir() + let config = copy(fugitive#Config(dir)) let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir)) - if empty(args) + let flags = [] + let pager = -1 + while len(args) + if args[0] ==# '-c' && len(args) > 1 + call extend(flags, remove(args, 0, 1)) + elseif args[0] =~# '^-p$\|^--paginate$' + let pager = 1 + call remove(args, 0) + elseif args[0] =~# '^-P$\|^--no-pager$' + let pager = 0 + call remove(args, 0) + elseif args[0] =~# '^--\%([[:lower:]-]\+-pathspecs\|no-optional-locks\)$' + call add(flags, remove(args, 0)) + elseif args[0] =~# '^-C$\|^--\%(exec-path=\|git-dir=\|work-tree=\|bare$\)' + return 'echoerr ' . string('fugitive: ' . args[0] . ' is not supported') + else + break + endif + endwhile + if pager is# 0 + call add(flags, '--no-pager') + endif + if empty(args) && pager is# -1 let cmd = s:StatusCommand(a:line1, a:line2, a:range, a:line2, a:bang, a:mods, '', '', []) return (empty(cmd) ? 'exe' : cmd) . after endif - let alias = get(s:Aliases(dir), args[0], '!') - if get(args, 1, '') !=# '--help' && alias !~# '^!\|[\"'']' && !filereadable(s:ExecPath() . '/git-' . args[0]) + let alias = fugitive#Config('alias.' . get(args, 0, ''), config) + if get(args, 1, '') !=# '--help' && alias !~# '^$\|^!\|[\"'']' && !filereadable(s:ExecPath() . '/git-' . args[0]) \ && !(has('win32') && filereadable(s:ExecPath() . '/git-' . args[0] . '.exe')) call remove(args, 0) call extend(args, split(alias, '\s\+'), 'keep') endif - let name = substitute(args[0], '\%(^\|-\)\(\l\)', '\u\1', 'g') - if exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' + let name = substitute(get(args, 0, ''), '\%(^\|-\)\(\l\)', '\u\1', 'g') + let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+') + let options = {'git': git, 'dir': dir, 'flags': flags} + if pager is# -1 && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' try - exe s:DirCheck(dir) - let opts = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, args[1:-1]) - if type(opts) == type('') - return 'exe ' . string(opts) . after + let overrides = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, extend({'command': args[0], 'args': args[1:-1]}, options)) + if type(overrides) == type('') + return 'exe ' . string(overrides) . after endif + let args = [get(overrides, 'command', args[0])] + get(overrides, 'insert_args', []) + args[1:-1] catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry else - let opts = {} + let overrides = {} endif - let args = get(opts, 'args', args) - if a:bang || args[0] =~# '^-p$\|^--paginate$\|diff\%(tool\)\@!\|log\|^show$' || - \ (args[0] ==# 'stash' && get(args, 1, '') ==# 'show') || - \ (args[0] ==# 'help' || get(args, 1, '') ==# '--help') && !s:HasOpt(args, '--web') - if args[0] =~# '^-p$\|^--paginate$' - call remove(args, 0) + let env = get(overrides, 'env', {}) + let i = 0 + while i < len(flags) - 1 + if flags[i] ==# '-c' + let i += 1 + let config_name = tolower(matchstr(flags[i], '^[^=]\+')) + if has_key(s:prepare_env, config_name) && flags[i] =~# '=.' + let env[s:prepare_env[config_name]] = matchstr(flags[i], '=\zs.*') + endif + if flags[i] =~# '=' + let config[config_name] = [matchstr(flags[i], '=\zs.*')] + else + let config[config_name] = [1] + endif + endif + let i += 1 + endwhile + let editcmd = a:line2 ? 'split' : 'edit' + if pager is# 1 + if a:bang && a:line2 >= 0 + let editcmd = 'read' + elseif a:bang + let editcmd = 'pedit' + endif + elseif pager is# -1 + let pager = fugitive#PagerFor(args, config) + if a:bang && pager isnot# 1 + return 'echoerr ' . string('fugitive: :Git! for temp buffer output has been replaced by :Git --paginate') + endif + endif + if pager is# 1 + if editcmd ==# 'read' + return s:ReadExec(a:line1, a:line2, a:range, a:mods, env, args, options) . after + else + return s:OpenExec(editcmd, a:mods, env, args, options) . after endif - return s:OpenExec((a:line2 > 0 ? a:line2 : '') . (a:line2 ? 'split' : 'edit'), a:mods, args, dir) . after endif if s:HasOpt(args, ['add', 'checkout', 'commit', 'stage', 'stash', 'reset'], '-p', '--patch') || - \ s:HasOpt(args, ['add', 'clean', 'stage'], '-i', '--interactive') + \ s:HasOpt(args, ['add', 'clean', 'stage'], '-i', '--interactive') || + \ type(pager) == type('') let mods = substitute(s:Mods(a:mods), '\', '-tab', 'g') let assign = len(dir) ? '|let b:git_dir = ' . string(dir) : '' if has('nvim') if &autowrite || &autowriteall | silent! wall | endif - return mods . (a:line2 ? 'split' : 'edit') . ' term://' . s:fnameescape(s:UserCommand(dir, args)) . assign . '|startinsert' . after + return mods . (a:line2 ? 'split' : 'edit') . ' term://' . s:fnameescape(s:UserCommand(options, args)) . assign . '|startinsert' . after elseif has('terminal') if &autowrite || &autowriteall | silent! wall | endif - return 'exe ' . string(mods . 'terminal ' . (a:line2 ? '' : '++curwin ') . join(map(s:UserCommandList(dir) + args, 's:fnameescape(v:val)'))) . assign . after + return 'exe ' . string(mods . 'terminal ' . (a:line2 ? '' : '++curwin ') . join(map(s:UserCommandList(options) + args, 's:fnameescape(v:val)'))) . assign . after endif endif - let env = get(opts, 'env', {}) if s:RunJobs() let state = {'dir': dir, 'mods': s:Mods(a:mods), 'temp': tempname(), 'log': []} let state.pty = get(g:, 'fugitive_pty', has('unix') && (has('patch-8.0.0744') || has('nvim'))) @@ -2401,57 +2557,39 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort \ 'GIT_MERGE_AUTOEDIT': '1', \ 'GIT_PAGER': 'cat', \ 'PAGER': 'cat'}, 'keep') - let args = ['-c', 'advice.waitingForEditor=false'] + s:disable_colors + args - let argv = s:UserCommandList(dir) + args - if !has('patch-8.0.0902') || has('nvim') - let envlist = map(items(env), 'join(v:val, "=")') - if s:executable('env') - let argv = ['env'] + envlist + argv - elseif has('win32') - let argv = ['cmd.exe', '/c', - \ join(map(envlist, { _, v -> 'set ' . substitute(v, '[&|<>^]', '^^^&', 'g') }) + - \ [s:shellesc(argv)], '& ')] - else - return 'echoerr ' . string('fugitive: "env" command missing') - endif - let env = {} - endif + let args = s:disable_colors + flags + ['-c', 'advice.waitingForEditor=false'] + args + let argv = s:UserCommandList({'git': git, 'dir': dir}) + args + let [argv, jobopts] = s:JobOpts(argv, env) let state.cmd = argv let g:_fugitive_last_job = state if &autowrite || &autowriteall | silent! wall | endif if exists('*job_start') - let jobopts = { + call extend(jobopts, { \ 'mode': 'raw', \ 'callback': function('s:RunReceive', [state]), - \ } + \ }) if state.pty let jobopts.pty = 1 endif - if len(env) - let jobopts.env = env - endif let job = job_start(argv, jobopts) else - let job = jobstart(argv, { + let job = jobstart(argv, extend(jobopts, { \ 'pty': state.pty, - \ 'env': env, \ 'TERM': 'dumb', \ 'on_stdout': function('s:RunReceive', [state]), \ 'on_stderr': function('s:RunReceive', [state]), - \ }) + \ })) endif let state.job = job call s:RunWait(state, job) return 'silent checktime' . after + elseif has('win32') + return 'echoerr ' . string('fugitive: Vim 8 with job support required to use :Git on Windows') + elseif has('gui_running') + return 'echoerr ' . string('fugitive: Vim 8 with job support required to use :Git in GVim') else - if has('gui_running') && !has('win32') - call insert(args, '--no-pager') - endif - if has('nvim') - let env.GIT_TERMINAL_PROMPT = '0' - endif let pre = s:BuildEnvPrefix(env) - return 'exe ' . string('noautocmd !' . escape(pre . s:UserCommand(dir, args), '!#%')) . + return 'exe ' . string('noautocmd !' . escape(pre . s:UserCommand(options, args), '!#%')) . \ '|call fugitive#ReloadStatus(' . string(dir) . ', 1)' . \ after endif @@ -2483,21 +2621,31 @@ function! s:Aliases(dir) abort endfunction function! fugitive#Complete(lead, ...) abort - let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir() + let dir = a:0 == 1 ? a:1 : a:0 >= 3 ? a:3 : s:Dir() + let root = a:0 >= 4 ? a:4 : s:Tree(s:Dir()) let pre = a:0 > 1 ? strpart(a:1, 0, a:2) : '' let subcmd = matchstr(pre, '\u\w*[! ] *\zs[[:alnum:]-]\+\ze ') if empty(subcmd) let results = sort(s:Subcommands() + keys(s:Aliases(dir))) + elseif a:0 ==# 2 && subcmd =~# '^\%(commit\|revert\|push\|fetch\|pull\|merge\|rebase\)$' + let cmdline = substitute(a:1, '\u\w*\([! ] *\)' . subcmd, 'G' . subcmd, '') + let caps_subcmd = substitute(subcmd, '\%(^\|-\)\l', '\u&', 'g') + return fugitive#{caps_subcmd}Complete(a:lead, cmdline, a:2 + len(cmdline) - len(a:1), dir, root) elseif pre =~# ' -- ' - return fugitive#CompletePath(a:lead, dir) + return fugitive#CompletePath(a:lead, a:1, a:2, dir, root) elseif a:lead =~# '^-' let results = split(s:ChompDefault('', dir, subcmd, '--git-completion-helper'), ' ') else - return fugitive#CompleteObject(a:lead, dir) + return fugitive#CompleteObject(a:lead, a:1, a:2, dir, root) endif return filter(results, 'strpart(v:val, 0, strlen(a:lead)) ==# a:lead') endfunction +function! fugitive#CompleteForWorkingDir(A, L, P, ...) abort + let path = a:0 ? a:1 : getcwd() + return fugitive#Complete(a:A, a:L, a:P, FugitiveExtractGitDir(path), path) +endfunction + " Section: :Gcd, :Glcd function! fugitive#CdComplete(A, L, P) abort @@ -2542,7 +2690,7 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args elseif a:bang return mods . 'pedit' . arg . '|wincmd P' else - return mods . (a:count > 0 ? a:count : '') . 'split' . arg + return mods . 'keepalt split' . arg endif catch /^fugitive:/ return 'echoerr ' . string(v:exception) @@ -3232,6 +3380,8 @@ function! s:StageInline(mode, ...) abort endif let start = index let mode = 'head' + elseif mode ==# 'head' && line =~# '^diff ' + let start = index elseif mode ==# 'head' && substitute(line, "\t$", '', '') ==# '--- ' . info.relative[-1] let mode = 'await' elseif mode ==# 'head' && substitute(line, "\t$", '', '') ==# '+++ ' . info.relative[0] @@ -3267,16 +3417,16 @@ function! s:StageDiff(diff) abort let prefix = info.offset > 0 ? '+' . info.offset : '' if info.sub =~# '^S' if info.section ==# 'Staged' - return 'Git! diff --no-ext-diff --submodule=log --cached -- ' . info.paths[0] + return 'Git --paginate diff --no-ext-diff --submodule=log --cached -- ' . info.paths[0] elseif info.sub =~# '^SC' - return 'Git! diff --no-ext-diff --submodule=log -- ' . info.paths[0] + return 'Git --paginate diff --no-ext-diff --submodule=log -- ' . info.paths[0] else - return 'Git! diff --no-ext-diff --submodule=diff -- ' . info.paths[0] + return 'Git --paginate diff --no-ext-diff --submodule=diff -- ' . info.paths[0] endif elseif empty(info.paths) && info.section ==# 'Staged' - return 'Git! diff --no-ext-diff --cached' + return 'Git --paginate diff --no-ext-diff --cached' elseif empty(info.paths) - return 'Git! diff --no-ext-diff' + return 'Git --paginate diff --no-ext-diff' elseif len(info.paths) > 1 execute 'Gedit' . prefix s:fnameescape(':0:' . info.paths[0]) return a:diff . '! HEAD:'.s:fnameescape(info.paths[1]) @@ -3299,12 +3449,12 @@ function! s:StageDiffEdit() abort let info = s:StageInfo(line('.')) let arg = (empty(info.paths) ? s:Tree() : info.paths[0]) if info.section ==# 'Staged' - return 'Git! diff --no-ext-diff --cached '.s:fnameescape(arg) + return 'Git --paginate diff --no-ext-diff --cached '.s:fnameescape(arg) elseif info.status ==# '?' call s:TreeChomp('add', '--intent-to-add', '--', arg) return s:ReloadStatus() else - return 'Git! diff --no-ext-diff '.s:fnameescape(arg) + return 'Git --paginate diff --no-ext-diff '.s:fnameescape(arg) endif endfunction @@ -3448,6 +3598,19 @@ function! s:DoToggleHeadHeader(value) abort call search('\C^index$', 'wc') endfunction +function! s:DoStagePushHeader(value) abort + let remote = matchstr(a:value, '\zs[^/]\+\ze/') + if empty(remote) + let remote = '.' + endif + let branch = matchstr(a:value, '\%([^/]\+/\)\=\zs\S\+') + call feedkeys(':Git push ' . remote . ' ' . branch) +endfunction + +function! s:DoTogglePushHeader(value) abort + return s:DoStagePushHeader(a:value) +endfunction + function! s:DoStageUnpushedHeading(heading) abort let remote = matchstr(a:heading, 'to \zs[^/]\+\ze/') if empty(remote) @@ -3491,7 +3654,7 @@ function! s:DoToggleUnpulled(record) abort endfunction function! s:DoUnstageUnpushed(record) abort - call feedkeys(':Git rebase --autosquash ' . a:record.commit . '^') + call feedkeys(':Git -c sequence.editor=true rebase --interactive --autosquash ' . a:record.commit . '^') endfunction function! s:DoToggleStagedHeading(...) abort @@ -3606,10 +3769,10 @@ function! s:StagePatch(lnum1,lnum2) abort return s:ReloadStatus() endfunction -" Section: :Gcommit, :Grevert +" Section: :Git commit, :Git revert -function! s:CommitInteractive(line1, line2, range, bang, mods, args, patch) abort - let status = s:StatusCommand(a:line1, a:line2, a:range, a:line2, a:bang, a:mods, '', '', []) +function! s:CommitInteractive(line1, line2, range, bang, mods, options, patch) abort + let status = s:StatusCommand(a:line1, a:line2, a:range, a:line2, a:bang, a:mods, '', '', [], a:options.dir) let status = len(status) ? status . '|' : '' if a:patch return status . 'if search("^Unstaged")|exe "normal >"|exe "+"|endif' @@ -3618,8 +3781,8 @@ function! s:CommitInteractive(line1, line2, range, bang, mods, args, patch) abor endif endfunction -function! s:CommitSubcommand(line1, line2, range, bang, mods, args) abort - let argv = copy(a:args) +function! s:CommitSubcommand(line1, line2, range, bang, mods, options) abort + let argv = copy(a:options.args) let i = 0 while get(argv, i, '--') !=# '--' if argv[i] =~# '^-[apzsneiovq].' @@ -3630,21 +3793,22 @@ function! s:CommitSubcommand(line1, line2, range, bang, mods, args) abort endif endwhile if s:HasOpt(argv, '-i', '--interactive') - return s:CommitInteractive(a:line1, a:line2, a:range, a:bang, a:mods, argv, 0) + return s:CommitInteractive(a:line1, a:line2, a:range, a:bang, a:mods, a:options, 0) elseif s:HasOpt(argv, '-p', '--patch') - return s:CommitInteractive(a:line1, a:line2, a:range, a:bang, a:mods, argv, 1) + return s:CommitInteractive(a:line1, a:line2, a:range, a:bang, a:mods, a:options, 1) else return {} endif endfunction -function! s:RevertSubcommand(line1, line2, range, bang, mods, args) abort - return {'args': ['revert', '--edit'] + a:args} +function! s:RevertSubcommand(line1, line2, range, bang, mods, options) abort + return {'insert_args': ['--edit']} endfunction -function! fugitive#CommitComplete(A, L, P) abort +function! fugitive#CommitComplete(A, L, P, ...) abort + let dir = a:0 ? a:1 : s:Dir() if a:A =~# '^--fixup=\|^--squash=' - let commits = s:LinesError(['log', '--pretty=format:%s', '@{upstream}..'])[0] + let commits = s:LinesError([dir, 'log', '--pretty=format:%s', '@{upstream}..'])[0] let pre = matchstr(a:A, '^--\w*=''\=') . ':/^' if pre =~# "'" call map(commits, 'pre . string(tr(v:val, "|\"^$*[]", "......."))[1:-1]') @@ -3654,43 +3818,44 @@ function! fugitive#CommitComplete(A, L, P) abort return s:FilterEscape(map(commits, 'pre . tr(v:val, "\\ !^$*?[]()''\"`&;<>|#", "....................")'), a:A) endif else - return s:CompleteSub('commit', a:A, a:L, a:P, function('fugitive#CompletePath')) + return s:CompleteSub('commit', a:A, a:L, a:P, function('fugitive#CompletePath'), a:000) endif return [] endfunction -function! fugitive#RevertComplete(A, L, P) abort - return s:CompleteSub('revert', a:A, a:L, a:P, function('s:CompleteRevision')) +function! fugitive#RevertComplete(A, L, P, ...) abort + return s:CompleteSub('revert', a:A, a:L, a:P, function('s:CompleteRevision'), a:000) endfunction -" Section: :Gmerge, :Grebase, :Gpull +" Section: :Git merge, :Git rebase, :Git pull -function! fugitive#MergeComplete(A, L, P) abort - return s:CompleteSub('merge', a:A, a:L, a:P, function('s:CompleteRevision')) +function! fugitive#MergeComplete(A, L, P, ...) abort + return s:CompleteSub('merge', a:A, a:L, a:P, function('s:CompleteRevision'), a:000) endfunction -function! fugitive#RebaseComplete(A, L, P) abort - return s:CompleteSub('rebase', a:A, a:L, a:P, function('s:CompleteRevision')) +function! fugitive#RebaseComplete(A, L, P, ...) abort + return s:CompleteSub('rebase', a:A, a:L, a:P, function('s:CompleteRevision'), a:000) endfunction -function! fugitive#PullComplete(A, L, P) abort - return s:CompleteSub('pull', a:A, a:L, a:P, function('s:CompleteRemote')) +function! fugitive#PullComplete(A, L, P, ...) abort + return s:CompleteSub('pull', a:A, a:L, a:P, function('s:CompleteRemote'), a:000) endfunction -function! s:MergeSubcommand(line1, line2, range, bang, mods, args) abort - let dir = s:Dir() - if empty(a:args) && ( +function! s:MergeSubcommand(line1, line2, range, bang, mods, options) abort + let dir = a:options.dir + if empty(a:options.args) && ( \ filereadable(fugitive#Find('.git/MERGE_MSG', dir)) || \ isdirectory(fugitive#Find('.git/rebase-apply', dir)) || \ !empty(s:TreeChomp(dir, 'diff-files', '--diff-filter=U'))) - return 'echohl WarningMsg|echo ":Git merge for loading conflicts is deprecated in favor of :Git mergetool"|echohl NONE|silent Git' . (a:bang ? '!' : '') . ' mergetool' + return 'echohl WarningMsg|echo ":Git merge for loading conflicts is deprecated in favor of :Git mergetool"|echohl NONE|silent Git' . (a:bang ? '!' : '') . s:fnameescape(a:options.flags + ['mergetool']) endif return {} endfunction -function! s:RebaseSubcommand(line1, line2, range, bang, mods, args) abort - if s:HasOpt(a:args, '--autosquash') && !s:HasOpt(a:args, '-i', '--interactive') - return {'env': {'GIT_SEQUENCE_EDITOR': 'true'}, 'args': ['rebase', '--interactive'] + a:args} +function! s:RebaseSubcommand(line1, line2, range, bang, mods, options) abort + let args = a:options.args + if s:HasOpt(args, '--autosquash') && !s:HasOpt(args, '-i', '--interactive') + return {'env': {'GIT_SEQUENCE_EDITOR': 'true'}, 'insert_args': ['--interactive']} endif return {} endfunction @@ -3778,7 +3943,7 @@ function! s:ToolParse(state, line) abort return [] endfunction -function! s:ToolStream(dir, line1, line2, range, bang, mods, args, state, title) abort +function! s:ToolStream(line1, line2, range, bang, mods, options, args, state) abort let i = 0 let argv = copy(a:args) let prompt = 1 @@ -3812,9 +3977,14 @@ function! s:ToolStream(dir, line1, line2, range, bang, mods, args, state, title) let a:state.mode = 'init' let a:state.from = '' let a:state.to = '' - let exec = s:UserCommandList(a:dir) + ['--no-pager', '-c', 'diff.context=0', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv + let exec = s:UserCommandList({'git': a:options.git, 'dir': a:options.dir}) + if fugitive#GitVersion(1, 9) || (!s:HasOpt(argv, '--name-status') && !prompt) + let exec += ['-c', 'diff.context=0'] + endif + let exec += a:options.flags + ['--no-pager', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv if prompt - return s:QuickfixStream(a:line2, 'difftool', a:title, exec, !a:bang, s:function('s:ToolParse'), a:state) + let title = ':Git ' . s:fnameescape(a:options.flags + [a:options.command] + a:options.args) + return s:QuickfixStream(a:line2, 'difftool', title, exec, !a:bang, s:function('s:ToolParse'), a:state) else let filename = '' let cmd = [] @@ -3835,23 +4005,23 @@ function! s:ToolStream(dir, line1, line2, range, bang, mods, args, state, title) endif endfunction -function! s:MergetoolSubcommand(line1, line2, range, bang, mods, args) abort - let dir = s:Dir() +function! s:MergetoolSubcommand(line1, line2, range, bang, mods, options) abort + let dir = a:options.dir + exe s:DirCheck(dir) let i = 0 - let argv = copy(a:args) let prompt = 1 - let title = ':Git mergetool' . (len(a:args) ? ' ' . s:fnameescape(a:args) : '') let cmd = ['diff', '--diff-filter=U'] let state = {'name_only': 0} let state.diff = [{'prefix': ':2:', 'module': ':2:'}, {'prefix': ':3:', 'module': ':3:'}, {'prefix': ':(top)'}] call map(state.diff, 'extend(v:val, {"filename": fugitive#Find(v:val.prefix, dir)})') - return s:ToolStream(dir, a:line1, a:line2, a:range, a:bang, a:mods, ['--diff-filter=U'] + a:args, state, title) + return s:ToolStream(a:line1, a:line2, a:range, a:bang, a:mods, a:options, ['--diff-filter=U'] + a:options.args, state) endfunction -function! s:DifftoolSubcommand(line1, line2, range, bang, mods, args) abort - let dir = s:Dir() +function! s:DifftoolSubcommand(line1, line2, range, bang, mods, options) abort + let dir = a:options.dir + exe s:DirCheck(dir) let i = 0 - let argv = copy(a:args) + let argv = copy(a:options.args) let commits = [] let cached = 0 let reverse = 1 @@ -3904,7 +4074,6 @@ function! s:DifftoolSubcommand(line1, line2, range, bang, mods, args) abort endif let i += 1 endwhile - let title = ':Git difftool' . (len(a:args) ? ' ' . s:fnameescape(a:args) : '') if len(merge_base_against) call add(commits, merge_base_against) endif @@ -3929,7 +4098,7 @@ function! s:DifftoolSubcommand(line1, line2, range, bang, mods, args) abort endif call map(commits, 'extend(v:val, {"filename": fugitive#Find(v:val.prefix, dir)})') let state.diff = commits - return s:ToolStream(dir, a:line1, a:line2, a:range, a:bang, a:mods, argv, state, title) + return s:ToolStream(a:line1, a:line2, a:range, a:bang, a:mods, a:options, argv, state) endfunction " Section: :Ggrep, :Glog @@ -3977,16 +4146,16 @@ function! s:GrepParseLine(prefix, name_only, dir, line) abort return entry endfunction -function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort - let dir = s:Dir() +function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort + let dir = a:options.dir exe s:DirCheck(dir) let listnr = a:line1 == 0 ? a:line1 : a:line2 let cmd = ['--no-pager', 'grep', '-n', '--no-color', '--full-name'] - if fugitive#GitVersion(2, 19) - call add(cmd, '--column') - endif let tree = s:Tree(dir) - let args = a:args + let args = a:options.args + if get(args, 0, '') =~# '^-O\|--open-files-in-pager$' + let args = args[1:-1] + endif let name_only = s:HasOpt(args, '-l', '--files-with-matches', '--name-only', '-L', '--files-without-match') let title = [listnr < 0 ? ':Ggrep' : ':Glgrep'] + args if listnr > 0 @@ -4002,7 +4171,7 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort let prefix = FugitiveVimPath(s:HasOpt(args, '--cached') || empty(tree) ? \ 'fugitive://' . dir . '//0/' : \ s:cpath(getcwd(), tree) ? '' : tree . '/') - exe '!' . escape(s:UserCommand(dir, cmd + args), '%#!') + exe '!' . escape(s:UserCommand(a:options, cmd + args), '%#!') \ printf(&shellpipe . (&shellpipe =~# '%s' ? '' : ' %s'), s:shellesc(tempfile)) let list = map(readfile(tempfile), 's:GrepParseLine(prefix, name_only, dir, v:val)') call s:QuickfixSet(listnr, list, 'a') @@ -4017,11 +4186,16 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort endif endfunction +function! fugitive#GrepCommand(line1, line2, range, bang, mods, arg) abort + return fugitive#Command(a:line1, a:line2, a:range, a:bang, a:mods, + \ "grep -O " . (fugitive#GitVersion(2, 19) ? "--column " : "") . a:arg) +endfunction + let s:log_diff_context = '{"filename": fugitive#Find(v:val . from, a:dir), "lnum": get(offsets, v:key), "module": strpart(v:val, 0, len(a:state.base_module)) . from}' function! s:LogFlushQueue(state, dir) abort let queue = remove(a:state, 'queue') - if a:state.child_found && get(a:state, 'ignore_summary') + if a:state.child_found && get(a:state, 'ignore_commit') call remove(queue, 0) elseif len(queue) && len(a:state.target) && len(get(a:state, 'parents', [])) let from = substitute(a:state.target, '^/', ':', '') @@ -4158,11 +4332,13 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort let state.ignore_summary = 1 endif endif + let state.ignore_commit = 1 elseif a:count > 0 if !s:HasOpt(args, '--merges', '--no-merges') call insert(extra_args, '--no-merges') endif call add(args, '-L' . a:line1 . ',' . a:count . ':' . path[1:-1]) + let state.ignore_commit = 1 endif if len(path) && empty(filter(copy(args), 'v:val =~# "^[^-]"')) let owner = s:Owner(@%, dir) @@ -4189,7 +4365,7 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort \ args + extra_args + paths + extra_paths) let state.target = path let title = titlepre . (listnr < 0 ? 'Gclog ' : 'Gllog ') . s:fnameescape(args + paths) - if empty(paths + extra_paths) && empty(a:type) && len(s:Relative('/')) + if empty(paths + extra_paths) && empty(a:type) && a:count < 0 && len(s:Relative('/')) let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after endif return s:QuickfixStream(listnr, 'log', title, s:UserCommandList(dir) + cmd, !a:bang, s:function('s:LogParse'), state, dir) . after @@ -4304,12 +4480,12 @@ function! s:BlurStatus() abort endif endfunction -function! s:OpenExec(cmd, mods, args, ...) abort - let dir = a:0 ? s:Dir(a:1) : s:Dir() +function! s:OpenExec(cmd, mods, env, args, ...) abort + let options = a:0 ? a:1 : {'dir': s:Dir()} let temp = tempname() let columns = get(g:, 'fugitive_columns', 80) - let env = s:BuildEnvPrefix({'COLUMNS': columns}) - silent! execute '!' . escape(env . s:UserCommand(dir, ['--no-pager'] + a:args), '!#%') . + let env = s:BuildEnvPrefix(extend({'COLUMNS': columns}, a:env)) + silent! execute '!' . escape(env . s:UserCommand(options, ['--no-pager'] + a:args), '!#%') . \ (&shell =~# 'csh' ? ' >& ' . temp : ' > ' . temp . ' 2>&1') redraw! let temp = s:Resolve(temp) @@ -4319,18 +4495,18 @@ function! s:OpenExec(cmd, mods, args, ...) abort else let filetype = 'git' endif - let s:temp_files[s:cpath(temp)] = { 'dir': dir, 'filetype': filetype } + let s:temp_files[s:cpath(temp)] = { 'dir': options.dir, 'filetype': filetype } if a:cmd ==# 'edit' call s:BlurStatus() endif silent execute s:Mods(a:mods) . a:cmd temp - call fugitive#ReloadStatus(dir, 1) - return 'echo ' . string(':!' . s:UserCommand(dir, a:args)) + call fugitive#ReloadStatus(options.dir, 1) + return 'echo ' . string(':!' . s:UserCommand(options, a:args)) endfunction function! fugitive#Open(cmd, bang, mods, arg, args) abort if a:bang - return s:OpenExec(a:cmd, a:mods, s:SplitExpand(a:arg, s:Tree())) + return s:OpenExec(a:cmd, a:mods, {}, s:SplitExpand(a:arg, s:Tree())) endif let mods = s:Mods(a:mods) @@ -4348,7 +4524,7 @@ function! fugitive#Open(cmd, bang, mods, arg, args) abort return mods . a:cmd . pre . ' ' . s:fnameescape(file) endfunction -function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort +function! s:ReadPrepare(line1, count, range, mods) abort let mods = s:Mods(a:mods) let after = a:count if a:count < 0 @@ -4359,26 +4535,39 @@ function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort else let delete = '' endif + if foldlevel(after) + let pre = after . 'foldopen!|' + else + let pre = '' + endif + return [pre . mods . after . 'read', delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '')] +endfunction + +function! s:ReadExec(line1, count, range, mods, env, args, options) abort + let [read, post] = s:ReadPrepare(a:line1, a:count, a:range, a:mods) + let env = s:BuildEnvPrefix(extend({'COLUMNS': &tw ? &tw : 80}, a:env)) + silent execute read . '!' escape(env . s:UserCommand(a:options, ['--no-pager'] + a:args), '!#%') + execute post + call fugitive#ReloadStatus(a:options.dir, 1) + return 'redraw|echo '.string(':!'.s:UserCommand(a:options, a:args)) +endfunction + +function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort if a:bang let dir = s:Dir() let args = s:SplitExpand(a:arg, s:Tree(dir)) - silent execute mods . after . 'read!' escape(s:UserCommand(dir, ['--no-pager'] + args), '!#%') - execute delete . 'diffupdate' - call fugitive#ReloadStatus(dir, 1) - return 'redraw|echo '.string(':!'.s:UserCommand(dir, args)) + return s:ReadExec(a:line1, a:count, a:range, a:mods, {}, args, {'dir': dir}) endif + let [read, post] = s:ReadPrepare(a:line1, a:count, a:range, a:mods) try let [file, pre] = s:OpenParse(a:args, 0) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry - if file =~# '^fugitive:' && after is# 0 - return 'exe ' .string(mods . fugitive#FileReadCmd(file, 0, pre)) . '|diffupdate' + if file =~# '^fugitive:' && a:count is# 0 + return 'exe ' .string(s:Mods(a:mods) . fugitive#FileReadCmd(file, 0, pre)) . '|diffupdate' endif - if foldlevel(after) - exe after . 'foldopen!' - endif - return mods . after . 'read' . pre . ' ' . s:fnameescape(file) . '|' . delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '') + return read . ' ' . pre . ' ' . s:fnameescape(file) . '|' . post endfunction function! fugitive#EditComplete(A, L, P) abort @@ -4405,7 +4594,7 @@ function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abor elseif expand('%:t') == 'COMMIT_EDITMSG' && $GIT_INDEX_FILE != '' return 'wq' elseif get(b:, 'fugitive_type', '') ==# 'index' - return 'Gcommit' + return 'Git commit' elseif &buftype ==# 'nowrite' && getline(4) =~# '^[+-]\{3\} ' return 'echoerr ' . string('fugitive: :Gwrite from :Git diff has been removed in favor of :Git add --edit') endif @@ -4543,19 +4732,19 @@ function! fugitive#WqCommand(...) abort endif endfunction -" Section: :Gpush, :Gfetch +" Section: :Git push, :Git fetch -function! fugitive#PushComplete(A, L, P) abort - return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompleteRemote')) +function! fugitive#PushComplete(A, L, P, ...) abort + return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompleteRemote'), a:000) endfunction -function! fugitive#FetchComplete(A, L, P) abort - return s:CompleteSub('fetch', a:A, a:L, a:P, function('s:CompleteRemote')) +function! fugitive#FetchComplete(A, L, P, ...) abort + return s:CompleteSub('fetch', a:A, a:L, a:P, function('s:CompleteRemote'), a:000) endfunction function! s:AskPassArgs(dir) abort if (len($DISPLAY) || len($TERM_PROGRAM) || has('gui_running')) && fugitive#GitVersion(1, 8) && - \ empty($GIT_ASKPASS) && empty($SSH_ASKPASS) && empty(get(fugitive#Config(a:dir), 'core.askpass', [])) + \ empty($GIT_ASKPASS) && empty($SSH_ASKPASS) && empty(FugitiveConfigGetAll('core.askpass', a:dir)) if s:executable(s:ExecPath() . '/git-gui--askpass') return ['-c', 'core.askPass=' . s:ExecPath() . '/git-gui--askpass'] elseif s:executable('ssh-askpass') @@ -4565,14 +4754,15 @@ function! s:AskPassArgs(dir) abort return [] endfunction -function! s:Dispatch(bang, cmd, args) abort - let dir = s:Dir() +function! s:Dispatch(bang, options) abort + let dir = a:options.dir + exe s:DirCheck(dir) let [mp, efm, cc] = [&l:mp, &l:efm, get(b:, 'current_compiler', '')] try let b:current_compiler = 'git' let &l:errorformat = s:common_efm . \ ',%\&git_dir=' . escape(substitute(dir, '%', '%%', 'g'), '\,') - let &l:makeprg = s:UserCommand(dir, s:AskPassArgs(dir) + [a:cmd] + a:args) + let &l:makeprg = s:UserCommand({'git': a:options.git, 'dir': dir}, s:AskPassArgs(dir) + a:options.flags + [a:options.command] + a:options.args) if exists(':Make') == 2 Make return '' @@ -4595,12 +4785,12 @@ function! s:Dispatch(bang, cmd, args) abort endtry endfunction -function! s:PushSubcommand(line1, line2, range, bang, mods, args) abort - return s:Dispatch(a:bang ? '!' : '', 'push', a:args) +function! s:PushSubcommand(line1, line2, range, bang, mods, options) abort + return s:Dispatch(a:bang ? '!' : '', a:options) endfunction -function! s:FetchSubcommand(line1, line2, range, bang, mods, args) abort - return s:Dispatch(a:bang ? '!' : '', 'fetch', a:args) +function! s:FetchSubcommand(line1, line2, range, bang, mods, options) abort + return s:Dispatch(a:bang ? '!' : '', a:options) endfunction " Section: :Gdiff @@ -4851,9 +5041,7 @@ function! s:Move(force, rename, destination) abort if s:DirCommitFile(@%)[1] !~# '^0\=$' || empty(@%) return 'echoerr ' . string('fugitive: mv not supported for this buffer') endif - if a:destination =~# '^\.\.\=\%(/\|$\)' - let destination = simplify(getcwd() . '/' . a:destination) - elseif a:destination =~# '^\a\+:\|^/' + if a:destination =~# '^\a\+:\|^/' let destination = a:destination elseif a:destination =~# '^:/:\=' let destination = s:Tree(dir) . substitute(a:destination, '^:/:\=', '', '') @@ -4862,7 +5050,9 @@ function! s:Move(force, rename, destination) abort elseif a:destination =~# '^:(literal)' let destination = simplify(getcwd() . '/' . matchstr(a:destination, ')\zs.*')) elseif a:rename - let destination = expand('%:p:s?[\/]$??:h') . '/' . a:destination + let destination = simplify(expand('%:p:s?[\/]$??:h') . '/' . a:destination) + elseif a:destination =~# '^\.\.\=\%(/\|$\)' + let destination = simplify(getcwd() . '/' . a:destination) else let destination = s:Tree(dir) . '/' . a:destination endif @@ -4937,14 +5127,14 @@ function! fugitive#DeleteCommand(line1, line2, range, bang, mods, arg, args) abo return s:Remove('bdelete', a:bang) endfunction -" Section: :Gblame +" Section: :Git blame function! s:Keywordprg() abort let args = ' --git-dir='.escape(s:Dir(),"\\\"' ") if has('gui_running') && !has('win32') - return s:UserCommand() . ' --no-pager' . args . ' log -1' + return g:fugitive_git_executable . ' --no-pager' . args . ' log -1' else - return s:UserCommand() . args . ' show' + return g:fugitive_git_executable . args . ' show' endif endfunction @@ -4974,7 +5164,7 @@ function! s:BlameCommitFileLnum(...) abort if commit =~# '^0\+$' let commit = '' elseif has_key(state, 'blame_reverse_end') - let commit = get(s:LinesError('rev-list', '--ancestry-path', '--reverse', commit . '..' . state.blame_reverse_end)[0], 0, '') + let commit = get(s:LinesError(state.dir, 'rev-list', '--ancestry-path', '--reverse', commit . '..' . state.blame_reverse_end)[0], 0, '') endif let lnum = +matchstr(line, ' \zs\d\+\ze \%((\| *\d\+)\)') let path = matchstr(line, '^\^\=[?*]*\x* \+\%(\d\+ \+\d\+ \+\)\=\zs.\{-\}\ze\s*\d\+ \%((\| *\d\+)\)') @@ -5009,9 +5199,10 @@ function! fugitive#BlameComplete(A, L, P) abort return s:CompleteSub('blame', a:A, a:L, a:P) endfunction -function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort - exe s:DirCheck() - let flags = copy(a:args) +function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort + let dir = s:Dir() + exe s:DirCheck(dir) + let flags = copy(a:options.args) let i = 0 let raw = 0 let commits = [] @@ -5066,7 +5257,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort continue endif try - let dcf = s:DirCommitFile(fugitive#Find(arg)) + let dcf = s:DirCommitFile(fugitive#Find(arg, dir)) if len(dcf[1]) && empty(dcf[2]) call add(commits, remove(flags, i)) continue @@ -5078,13 +5269,13 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort endif let i += 1 endwhile - let file = substitute(get(files, 0, get(s:TempState(), 'blame_file', s:Relative('./'))), '^\.\%(/\|$\)', '', '') + let file = substitute(get(files, 0, get(s:TempState(), 'blame_file', s:Relative('./', dir))), '^\.\%(/\|$\)', '', '') if empty(commits) && len(files) > 1 call add(commits, remove(files, 1)) endif exe s:BlameLeave() try - let cmd = ['--no-pager', '-c', 'blame.coloring=none', '-c', 'blame.blankBoundary=false', 'blame', '--show-number'] + let cmd = a:options.flags + ['--no-pager', '-c', 'blame.coloring=none', '-c', 'blame.blankBoundary=false', a:options.command, '--show-number'] call extend(cmd, filter(copy(flags), 'v:val !~# "\\v^%(-b|--%(no-)=color-.*|--progress)$"')) if a:count > 0 && empty(ranges) let cmd += ['-L', (a:line1 ? a:line1 : line('.')) . ',' . (a:line1 ? a:line1 : line('.'))] @@ -5097,7 +5288,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort elseif empty(files) && !s:HasOpt(flags, '--reverse') let cmd += ['--contents', '-'] endif - let basecmd = escape(fugitive#Prepare(cmd) . ' -- ' . s:shellesc(len(files) ? files : file), '!#%') + let basecmd = escape(s:UserCommand({'git': a:options.git, 'dir': dir}, cmd + ['--'] + (len(files) ? files : [file])), '!#%') let tempname = tempname() let error = tempname . '.err' let temp = tempname . (raw ? '' : '.fugitiveblame') @@ -5129,7 +5320,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort endfor return '' endif - let temp_state = {'dir': s:Dir(), 'filetype': (raw ? '' : 'fugitiveblame'), 'blame_flags': flags, 'blame_file': file} + let temp_state = {'dir': dir, 'filetype': (raw ? '' : 'fugitiveblame'), 'options': a:options, 'blame_flags': flags, 'blame_file': file} if s:HasOpt(flags, '--reverse') let temp_state.blame_reverse_end = matchstr(get(commits, 0, ''), '\.\.\zs.*') endif @@ -5153,29 +5344,38 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort if a:mods =~# '\' silent tabedit % endif + let bufnr = bufnr('') + let temp_state.bufnr = bufnr + let restore = [] let mods = substitute(a:mods, '\', '', 'g') for winnr in range(winnr('$'),1,-1) if getwinvar(winnr, '&scrollbind') - call setwinvar(winnr, '&scrollbind', 0) + if !&l:scrollbind + call setwinvar(winnr, '&scrollbind', 0) + elseif winnr != winnr() && getwinvar(winnr, '&foldenable') + call setwinvar(winnr, '&foldenable', 0) + call add(restore, 'call setwinvar(bufwinnr('.winbufnr(winnr).'),"&foldenable",1)') + endif endif - if exists('+cursorbind') && getwinvar(winnr, '&cursorbind') + if exists('+cursorbind') && !&l:cursorbind && getwinvar(winnr, '&cursorbind') call setwinvar(winnr, '&cursorbind', 0) endif if s:BlameBufnr(winbufnr(winnr)) > 0 execute winbufnr(winnr).'bdelete' endif endfor - let bufnr = bufnr('') - let temp_state.bufnr = bufnr - let restore = 'call setwinvar(bufwinnr('.bufnr.'),"&scrollbind",0)' - if exists('+cursorbind') - let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&cursorbind",0)' + let restore_winnr = 'bufwinnr(' . bufnr . ')' + if !&l:scrollbind + call add(restore, 'call setwinvar(' . restore_winnr . ',"&scrollbind",0)') + endif + if exists('+cursorbind') && !&l:cursorbind + call add(restore, 'call setwinvar(' . restore_winnr . ',"&cursorbind",0)') endif if &l:wrap - let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&wrap",1)' + call add(restore, 'call setwinvar(' . restore_winnr . ',"&wrap",1)') endif if &l:foldenable - let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&foldenable",1)' + call add(restore, 'call setwinvar(' . restore_winnr . ',"&foldenable",1)') endif setlocal scrollbind nowrap nofoldenable if exists('+cursorbind') @@ -5184,7 +5384,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort let top = line('w0') + &scrolloff let current = line('.') exe 'silent keepalt' (a:bang ? s:Mods(mods) . 'split' : s:Mods(mods, 'leftabove') . 'vsplit') s:fnameescape(temp) - let w:fugitive_leave = restore + let w:fugitive_leave = join(restore, '|') execute top normal! zt execute current @@ -5278,7 +5478,8 @@ function! s:BlameJump(suffix, ...) abort let suffix = '' endif let offset = line('.') - line('w0') - let flags = get(s:TempState(), 'blame_flags', []) + let state = s:TempState() + let flags = get(state, 'blame_flags', []) if a:0 && a:1 if s:HasOpt(flags, '--reverse') call remove(flags, '--reverse') @@ -5297,30 +5498,28 @@ function! s:BlameJump(suffix, ...) abort execute 'Gedit' s:fnameescape(commit . suffix . ':' . path) execute lnum endif - if exists(':Gblame') - let my_bufnr = bufnr('') - if blame_bufnr < 0 - let blame_args = flags + [commit . suffix, '--', path] - let result = s:BlameSubcommand(0, 0, 0, 0, '', blame_args) - else - let blame_args = flags - let result = s:BlameSubcommand(-1, -1, 0, 0, '', blame_args) - endif - if bufnr('') == my_bufnr - return result - endif - execute result - execute lnum - let delta = line('.') - line('w0') - offset - if delta > 0 - execute 'normal! '.delta."\" - elseif delta < 0 - execute 'normal! '.(-delta)."\" - endif - keepjumps syncbind - redraw - echo ':Gblame' s:fnameescape(blame_args) + let my_bufnr = bufnr('') + if blame_bufnr < 0 + let blame_args = flags + [commit . suffix, '--', path] + let result = s:BlameSubcommand(0, 0, 0, 0, '', extend({'args': blame_args}, state.options, 'keep')) + else + let blame_args = flags + let result = s:BlameSubcommand(-1, -1, 0, 0, '', extend({'args': blame_args}, state.options, 'keep')) endif + if bufnr('') == my_bufnr + return result + endif + execute result + execute lnum + let delta = line('.') - line('w0') - offset + if delta > 0 + execute 'normal! '.delta."\" + elseif delta < 0 + execute 'normal! '.(-delta)."\" + endif + keepjumps syncbind + redraw + echo ':Git blame' s:fnameescape(blame_args) return '' endfunction @@ -5328,12 +5527,11 @@ let s:hash_colors = {} function! fugitive#BlameSyntax() abort let conceal = has('conceal') ? ' conceal' : '' - let config = fugitive#Config() let flags = get(s:TempState(), 'blame_flags', []) syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite syn match FugitiveblameHash "\%(^\^\=[?*]*\)\@<=\<\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite syn match FugitiveblameUncommitted "\%(^\^\=\)\@<=\<0\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite - if get(get(config, 'blame.blankboundary', ['x']), 0, 'x') =~# '^$\|^true$' || s:HasOpt(flags, '-b') + if s:HasOpt(flags, '-b') || FugitiveConfigGet('blame.blankBoundary') =~# '^1$\|^true$' syn match FugitiveblameBoundaryIgnore "^\^[*?]*\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite else syn match FugitiveblameBoundary "^\^" @@ -5409,10 +5607,10 @@ function! s:BlameFileType() abort if &modifiable return '' endif - call s:Map('n', '', ':help :Gblame', '') - call s:Map('n', 'g?', ':help :Gblame', '') + call s:Map('n', '', ':help :Git_blame', '') + call s:Map('n', 'g?', ':help :Git_blame', '') if mapcheck('q', 'n') =~# '^$\|bdelete' - call s:Map('n', 'q', ':exe BlameQuit()echohl WarningMsgecho ":Gblame q is deprecated in favor of gq"echohl NONE', '') + call s:Map('n', 'q', ':exe BlameQuit()echohl WarningMsgecho ":Git blame q is deprecated in favor of gq"echohl NONE', '') endif call s:Map('n', 'gq', ':exe BlameQuit()', '') call s:Map('n', '<2-LeftMouse>', ':exe BlameCommit("exe BlameLeave()edit")', '') @@ -5483,6 +5681,9 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo let type = 'blob' endif let path = path[1:-1] + elseif full =~? '^\a\a\+:[\/][\/]' + let path = s:Slash(full) + let type = 'url' elseif empty(s:Tree(dir)) let path = '.git/' . full[strlen(dir)+1:-1] let type = '' @@ -5621,13 +5822,17 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo \ 'line1': line1, \ 'line2': line2} - let url = '' - for Handler in get(g:, 'fugitive_browse_handlers', []) - let url = call(Handler, [copy(opts)]) - if !empty(url) - break - endif - endfor + if type ==# 'url' + let url = path + else + let url = '' + for Handler in get(g:, 'fugitive_browse_handlers', []) + let url = call(Handler, [copy(opts)]) + if !empty(url) + break + endif + endfor + endif if empty(url) call s:throw("No Gbrowse handler installed for '".raw."'") @@ -5658,6 +5863,8 @@ endfunction " Section: Go to file +let s:ref_header = '\%(Merge\|Rebase\|Upstream\|Pull\|Push\)' + nnoremap : :=v:count ? v:count : '' function! fugitive#MapCfile(...) abort exe 'cnoremap ' (a:0 ? a:1 : 'fugitive#Cfile()') @@ -5678,7 +5885,7 @@ endfunction function! s:SquashArgument(...) abort if &filetype == 'fugitive' - let commit = matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze ') + let commit = matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze \|^' . s:ref_header . ': \zs\S\+') elseif has_key(s:temp_files, s:cpath(expand('%:p'))) let commit = matchstr(getline('.'), '\<\x\{4,\}\>') else @@ -5720,7 +5927,7 @@ endfunction function! fugitive#MapJumps(...) abort if !&modifiable if get(b:, 'fugitive_type', '') ==# 'blob' - let blame_map = 'Gblame=v:count ? " --reverse" : ""' + let blame_map = 'Git blame=v:count ? " --reverse" : ""' call s:Map('n', '<2-LeftMouse>', ':0,1' . blame_map, '') call s:Map('n', '', ':0,1' . blame_map, '') call s:Map('n', 'o', ':0,2' . blame_map, '') @@ -5780,73 +5987,73 @@ function! fugitive#MapJumps(...) abort call s:Map('n', 'gi', ":exe 'Gsplit' (v:count ? '.gitignore' : '.git/info/exclude')", '') call s:Map('x', 'gi', ":exe 'Gsplit' (v:count ? '.gitignore' : '.git/info/exclude')", '') - nnoremap c :Git commit - nnoremap c :Git commit - nnoremap cv :tab Git commit -v - nnoremap cv :tab Git commit -v - nnoremap ca :Gcommit --amend - nnoremap cc :Gcommit - nnoremap ce :Gcommit --amend --no-edit - nnoremap cw :Gcommit --amend --only - nnoremap cva :tab Gcommit -v --amend - nnoremap cvc :tab Gcommit -v - nnoremap cRa :Gcommit --reset-author --amend - nnoremap cRe :Gcommit --reset-author --amend --no-edit - nnoremap cRw :Gcommit --reset-author --amend --only - nnoremap cf :Gcommit --fixup==SquashArgument() - nnoremap cF :Grebase --autosquash=RebaseArgument()Gcommit --fixup==SquashArgument() - nnoremap cs :Gcommit --no-edit --squash==SquashArgument() - nnoremap cS :Grebase --autosquash=RebaseArgument()Gcommit --no-edit --squash==SquashArgument() - nnoremap cA :Gcommit --edit --squash==SquashArgument() - nnoremap c? :help fugitive_c + call s:Map('n', 'c', ':Git commit') + call s:Map('n', 'c', ':Git commit') + call s:Map('n', 'cv', ':tab Git commit -v') + call s:Map('n', 'cv', ':tab Git commit -v') + call s:Map('n', 'ca', ':Git commit --amend', '') + call s:Map('n', 'cc', ':Git commit', '') + call s:Map('n', 'ce', ':Git commit --amend --no-edit', '') + call s:Map('n', 'cw', ':Git commit --amend --only', '') + call s:Map('n', 'cva', ':tab Git commit -v --amend', '') + call s:Map('n', 'cvc', ':tab Git commit -v', '') + call s:Map('n', 'cRa', ':Git commit --reset-author --amend', '') + call s:Map('n', 'cRe', ':Git commit --reset-author --amend --no-edit', '') + call s:Map('n', 'cRw', ':Git commit --reset-author --amend --only', '') + call s:Map('n', 'cf', ':Git commit --fixup==SquashArgument()') + call s:Map('n', 'cF', ':Git -c sequence.editor=true rebase --interactive --autosquash=RebaseArgument()Git commit --fixup==SquashArgument()') + call s:Map('n', 'cs', ':Git commit --no-edit --squash==SquashArgument()') + call s:Map('n', 'cS', ':Git -c sequence.editor=true rebase --interactive --autosquash=RebaseArgument()Git commit --no-edit --squash==SquashArgument()') + call s:Map('n', 'cA', ':Git commit --edit --squash==SquashArgument()') + call s:Map('n', 'c?', ':help fugitive_c', '') - nnoremap cr :Git revert - nnoremap cr :Git revert - nnoremap crc :Grevert =SquashArgument() - nnoremap crn :Grevert --no-commit =SquashArgument() - nnoremap cr? :help fugitive_cr + call s:Map('n', 'cr', ':Git revert') + call s:Map('n', 'cr', ':Git revert') + call s:Map('n', 'crc', ':Git revert =SquashArgument()', '') + call s:Map('n', 'crn', ':Git revert --no-commit =SquashArgument()', '') + call s:Map('n', 'cr?', ':help fugitive_cr', '') - nnoremap cm :Git merge - nnoremap cm :Git merge - nnoremap cmt :Git mergetool - nnoremap cm? :help fugitive_cm + call s:Map('n', 'cm', ':Git merge') + call s:Map('n', 'cm', ':Git merge') + call s:Map('n', 'cmt', ':Git mergetool') + call s:Map('n', 'cm?', ':help fugitive_cm', '') - nnoremap cz :Git stash - nnoremap cz :Git stash - nnoremap cza :exe EchoExec(['stash', 'apply', '--quiet', '--index', 'stash@{' . v:count . '}']) - nnoremap czA :exe EchoExec(['stash', 'apply', '--quiet', 'stash@{' . v:count . '}']) - nnoremap czp :exe EchoExec(['stash', 'pop', '--quiet', '--index', 'stash@{' . v:count . '}']) - nnoremap czP :exe EchoExec(['stash', 'pop', '--quiet', 'stash@{' . v:count . '}']) - nnoremap czv :exe 'Gedit' fugitive#RevParse('stash@{' . v:count . '}') - nnoremap czw :exe EchoExec(['stash', '--keep-index'] + (v:count > 1 ? ['--all'] : v:count ? ['--include-untracked'] : [])) - nnoremap czz :exe EchoExec(['stash'] + (v:count > 1 ? ['--all'] : v:count ? ['--include-untracked'] : [])) - nnoremap cz? :help fugitive_cz + call s:Map('n', 'cz', ':Git stash') + call s:Map('n', 'cz', ':Git stash') + call s:Map('n', 'cza', ':Git stash apply --quiet --index stash@{=v:count}') + call s:Map('n', 'czA', ':Git stash apply --quiet stash@{=v:count}') + call s:Map('n', 'czp', ':Git stash pop --quiet --index stash@{=v:count}') + call s:Map('n', 'czP', ':Git stash pop --quiet stash@{=v:count}') + call s:Map('n', 'czv', ':exe "Gedit" fugitive#RevParse("stash@{" . v:count . "}")', '') + call s:Map('n', 'czw', ':Git stash --keep-index=v:count > 1 ? " --all" : v:count ? " --include-untracked" : ""') + call s:Map('n', 'czz', ':Git stash =v:count > 1 ? " --all" : v:count ? " --include-untracked" : ""') + call s:Map('n', 'cz?', ':help fugitive_cz', '') - nnoremap co :Git checkout - nnoremap co :Git checkout - nnoremap coo :exe EchoExec(['checkout'] + split(SquashArgument()) + ['--']) - nnoremap co? :help fugitive_co + call s:Map('n', 'co', ':Git checkout') + call s:Map('n', 'co', ':Git checkout') + call s:Map('n', 'coo', ':Git checkout =SquashArgument() --') + call s:Map('n', 'co?', ':help fugitive_co', '') - nnoremap cb :Git branch - nnoremap cb :Git branch - nnoremap cb? :help fugitive_cb + call s:Map('n', 'cb', ':Git branch') + call s:Map('n', 'cb', ':Git branch') + call s:Map('n', 'cb?', ':help fugitive_cb', '') - nnoremap r :Git rebase - nnoremap r :Git rebase - nnoremap ri :Grebase --interactive=RebaseArgument() - nnoremap rf :Grebase --autosquash=RebaseArgument() - nnoremap ru :Grebase --interactive @{upstream} - nnoremap rp :Grebase --interactive @{push} - nnoremap rw :Grebase --interactive=RebaseArgument()s/^pick/reword/e - nnoremap rm :Grebase --interactive=RebaseArgument()s/^pick/edit/e - nnoremap rd :Grebase --interactive=RebaseArgument()s/^pick/drop/e - nnoremap rk :Grebase --interactive=RebaseArgument()s/^pick/drop/e - nnoremap rx :Grebase --interactive=RebaseArgument()s/^pick/drop/e - nnoremap rr :Grebase --continue - nnoremap rs :Grebase --skip - nnoremap re :Grebase --edit-todo - nnoremap ra :Grebase --abort - nnoremap r? :help fugitive_r + call s:Map('n', 'r', ':Git rebase') + call s:Map('n', 'r', ':Git rebase') + call s:Map('n', 'ri', ':Git rebase --interactive=RebaseArgument()', '') + call s:Map('n', 'rf', ':Git -c sequence.editor=true rebase --interactive --autosquash=RebaseArgument()', '') + call s:Map('n', 'ru', ':Git rebase --interactive @{upstream}', '') + call s:Map('n', 'rp', ':Git rebase --interactive @{push}', '') + call s:Map('n', 'rw', ':Git rebase --interactive=RebaseArgument()s/^pick/reword/e', '') + call s:Map('n', 'rm', ':Git rebase --interactive=RebaseArgument()s/^pick/edit/e', '') + call s:Map('n', 'rd', ':Git rebase --interactive=RebaseArgument()s/^pick/drop/e', '') + call s:Map('n', 'rk', ':Git rebase --interactive=RebaseArgument()s/^pick/drop/e', '') + call s:Map('n', 'rx', ':Git rebase --interactive=RebaseArgument()s/^pick/drop/e', '') + call s:Map('n', 'rr', ':Git rebase --continue', '') + call s:Map('n', 'rs', ':Git rebase --skip', '') + call s:Map('n', 're', ':Git rebase --edit-todo', '') + call s:Map('n', 'ra', ':Git rebase --abort', '') + call s:Map('n', 'r?', ':help fugitive_r', '') call s:Map('n', '.', ": =fnameescape(fugitive#Real(@%))") call s:Map('x', '.', ": =fnameescape(fugitive#Real(@%))") @@ -5872,7 +6079,7 @@ function! s:StatusCfile(...) abort return [lead . info.relative[0]] elseif len(info.commit) return [info.commit] - elseif line =~# '^\%(Head\|Merge\|Rebase\|Upstream\|Pull\|Push\): ' + elseif line =~# '^' . s:ref_header . ': \|^Head: ' return [matchstr(line, ' \zs.*')] else return [''] diff --git a/sources_non_forked/vim-fugitive/doc/fugitive.txt b/sources_non_forked/vim-fugitive/doc/fugitive.txt index efb4425a..e950a310 100644 --- a/sources_non_forked/vim-fugitive/doc/fugitive.txt +++ b/sources_non_forked/vim-fugitive/doc/fugitive.txt @@ -25,19 +25,22 @@ that are part of Git repositories). resume running the command. A few Git subcommands have different behavior; these are documented below. -:Git! {args} Run an arbitrary git command, capture output to a temp -:Git --paginate {args} file, and |:split| that temp file. Use :0Git to -:Git -p {args} |:edit| the temp file instead. A temp file is always - used for diff and log commands. + *:Git_--paginate* *:Git_-p* +:Git --paginate {args} Run an arbitrary git command, capture output to a temp +:Git -p {args} file, and |:split| that temp file. Use :0Git to +:G --paginate {args} |:edit| the temp file instead. A temp file is always +:G -p {args} used for commands like diff and log that typically + user a pager, and for any command that has the + pager. Git configuration option set. - *:Gstatus* -:Git Bring up a summary window vaguely akin to git-status. -:G Press g? or see |fugitive-maps| for usage. -:Gstatus + *fugitive-summary* +:Git With no arguments, bring up a summary window vaguely +:G akin to git-status. Press g? or see |fugitive-maps| + for usage. - *:Git-blame* *:Gblame* + *:Git_blame* :Git blame [flags] Run git-blame [flags] on the current file and open the -:Gblame [flags] results in a scroll-bound vertical split. The + results in a scroll-bound vertical split. The following maps, which work on the cursor line commit where sensible, are provided: @@ -56,20 +59,12 @@ that are part of Git repositories). ~ reblame at [count]th first grandparent P reblame at [count]th parent (like HEAD^[count]) -:[range]Gblame [flags] If a range is given, just that part of the file will -:Gblame [flags] {file} be blamed, and a horizontal split without -:Git blame ... scrollbinding is used. You can also give an arbitrary +:[range]Git blame [...] If a range is given, just that part of the file will +:Git blame [...] {file} be blamed, and a horizontal split without + scrollbinding is used. You can also give an arbitrary filename. - *:Ggrep* *:Gcgrep* *:Git-grep* -:Ggrep[!] [args] |:grep|[!] with git-grep as 'grepprg'. -:Git[!] grep [args] - - *:Glgrep* -:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'. -:0Git[!] grep [args] - - *:Git-difftool* + *:Git_difftool* :Git[!] difftool [args] Invoke `git diff [args]` and load the changes into the quickfix list. Each changed hunk gets a separate quickfix entry unless you pass an option like @@ -77,42 +72,32 @@ that are part of Git repositories). change unless [!] is given. :Git difftool -y [args] Invoke `git diff [args]`, open each changed file in a - new tab, and invoke `:Gdiffsplit!` against the + new tab, and invoke |:Gdiffsplit!| against the appropriate commit. - *:Git-mergetool* -:Git mergetool [args] Like |:Git-difftool|, but target merge conflicts. + *:Git_mergetool* +:Git mergetool [args] Like |:Git_difftool|, but target merge conflicts. - *:Git-push* *:Gpush* + *:Git_push* :Git push [args] Invoke git-push, load the results into the |quickfix| -:Gpush [args] list, and invoke |:cwindow| to reveal any errors. + list, and invoke |:cwindow| to reveal any errors. |:Dispatch| is used if available for asynchronous invocation. - *:Git-fetch* *:Gfetch* -:Git fetch [args] Like |:Gpush|, but for git-fetch. -:Gfetch [args] + *:Git_fetch* +:Git fetch [args] Like |:Git_push|, but for git-fetch. - *:Git-merge* *:Gmerge* -:Gmerge [args] Deprecated alias for |:Git| merge. Use |:Git-mergetool| - to get the old behavior of loading merge conflicts - into the quickfix list. + *:Ggrep* *:Gcgrep* *:Git_grep* +:Ggrep[!] [args] |:grep|[!] with git-grep as 'grepprg'. +:Git[!] grep [args] - *:Git-pull* *:Gpull* -:Gpull [args] Deprecated alias for |:Git| pull. + *:Glgrep* +:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'. +:0Git[!] grep [args] - *:Git-rebase* *:Grebase* -:Grebase [args] Deprecated alias for |:Git| rebase. - - *:Git-commit* *:Gcommit* -:Gcommit [args] Deprecated alias for |:Git| commit. - - *:Git-revert* *:Grevert* -:Grevert [args] Deprecated alias for |:Git| revert. - - *:Gclog* *:Glog* + *:Gclog* :Gclog[!] [args] Use git-log [args] to load the commit history into the -:Glog[!] [args] |quickfix| list. Jumps to the first commit unless [!] + |quickfix| list. Jumps to the first commit unless [!] is given. :{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given @@ -146,13 +131,6 @@ that are part of Git repositories). *:Gpedit* :Gpedit [object] |:pedit| a |fugitive-object|. -:Gsplit! [args] *:Gsplit!* *:Gvsplit!* -:Gvsplit! [args] *:Gtabedit!* *:Gpedit!* -:Gtabedit! [args] Capture the output of `git [args]` to a temp file and -:Gpedit! [args] open it in a split, tab, or preview window. Use - :0Gsplit! to suppress the split and open it in the - current window. - *:Gread* *fugitive-:Gr* :Gread [object] Empty the buffer and |:read| a |fugitive-object|. When the argument is omitted, this is similar to @@ -210,28 +188,28 @@ that are part of Git repositories). *:Gvdiffsplit* :Gvdiffsplit [object] Like |:Gdiffsplit|, but always split vertically. - *:Ghdiffsplit* *:Gsdiff* + *:Ghdiffsplit* :Ghdiffsplit [object] Like |:Gdiffsplit|, but always split horizontally. - *:Gmove* -:Gmove {destination} Wrapper around git-mv that renames the buffer + *:GMove* +:GMove {destination} Wrapper around git-mv that renames the buffer afterward. Add a ! to pass -f. - *:Grename* -:Grename {destination} Like |:Gmove| but operates relative to the parent + *:GRename* +:GRename {destination} Like |:GMove| but operates relative to the parent directory of the current file. - *:Gdelete* -:Gdelete Wrapper around git-rm that deletes the buffer + *:GDelete* +:GDelete Wrapper around git-rm that deletes the buffer afterward. When invoked in an index file, --cached is passed. Add a ! to pass -f and forcefully discard the buffer. - *:Gremove* -:Gremove Like :Gdelete, but keep the (now empty) buffer around. + *:GRemove* +:GRemove Like |:GDelete|, but keep the (now empty) buffer around. - *:Gbrowse* -:Gbrowse Open the current file, blob, tree, commit, or tag + *:GBrowse* +:GBrowse Open the current file, blob, tree, commit, or tag in your browser at the upstream hosting provider. If a range is given, it is appropriately appended to the URL as an anchor. @@ -241,27 +219,27 @@ that are part of Git repositories). supported by installing rhubarb.vim, available at . -:Gbrowse {object} Like :Gbrowse, but for a given |fugitive-object|. +:GBrowse {object} Like :GBrowse, but for a given |fugitive-object|. -:Gbrowse [...]@{remote} Force using the given remote rather than the remote +:GBrowse [...]@{remote} Force using the given remote rather than the remote for the current branch. The remote is used to determine which upstream repository to link to. -:{range}Gbrowse [args] Appends an anchor to the URL that emphasizes the +:{range}GBrowse [args] Appends an anchor to the URL that emphasizes the selected lines. This also forces the URL to include a commit rather than a branch name so it remains valid if the file changes. You can give a range of "0" to force this behavior without including an anchor. -:[range]Gbrowse! [args] Like :Gbrowse, but put the URL on the clipboard rather +:[range]GBrowse! [args] Like :GBrowse, but put the URL on the clipboard rather than opening it. MAPS *fugitive-maps* -These maps are available in both the |:Gstatus| buffer and Fugitive object -buffers, although not all maps make sense in all buffers. Mappings that -operate on the file or hunk under the cursor are generally available in visual -mode to operate on multiple files or partial hunks. +These maps are available in both the |fugitive-summary| buffer and Fugitive +object buffers, although not all maps make sense in all buffers. Mappings +that operate on the file or hunk under the cursor are generally available in +visual mode to operate on multiple files or partial hunks. *fugitive-staging-maps* Staging/unstaging maps ~ @@ -407,7 +385,7 @@ i Jump to the next file or hunk, expanding inline diffs ][ Jump [count] section ends forward. *fugitive_star* -* One the first column of a + or - diff line, search for +* On the first column of a + or - diff line, search for the corresponding - or + line. Otherwise, defer to built-in |star|. @@ -502,7 +480,7 @@ czz Push stash. Pass a [count] of 1 to add `--include-untracked` or 2 to add `--all`. czw Push stash of worktree. Like `czz` with - `--include-index`. + `--keep-index`. czA Apply topmost stash, or stash@{count}. @@ -611,7 +589,7 @@ Makefile The file named Makefile in the work tree !:Makefile The file named Makefile in the commit owning the current file !3^2 The second parent of the commit owning buffer #3 .git/config The repo config file -: Same as |:Gstatus| +: The |fugitive-summary| buffer. STATUSLINE *fugitive-statusline* @@ -628,6 +606,39 @@ HEAD is detached, FugitiveHead() will return the empty string, unless the optional argument is given, in which case the hash of the current commit will be truncated to the given number of characters. +DEPRECATIONS *fugitive-deprecated* + +The following commands are softly deprecated in favor of replacements that +adhere to a new naming scheme. They will eventually be removed, but probably +not in the near future. + +Remember that |:Git| can be shortened to |:G|, so replacements using it are +just one space character longer than the legacy version. + +*:Gremove* Superseded by |:GRemove|. +*:Gdelete* Superseded by |:GDelete|. +*:Gmove* Superseded by |:GMove|. +*:Grename* Superseded by |:GRename|. +*:Gbrowse* Superseded by |:GBrowse|. +*:Gdiff* Superseded by |:Gdiffsplit| +*:Gsdiff* Superseded by |:Ghdiffsplit| +*:Gvdiff* Superseded by |:Gvdiffsplit| or |:vert| |:Gdiffsplit|. +*:Gblame* Superseded by |:Git_blame|. +*:Gcommit* Superseded by |:Git| commit. +*:Gmerge* Superseded by |:Git| merge and |:Git_mergetool|. +*:Gpull* Superseded by |:Git| pull. +*:Grebase* Superseded by |:Git| rebase. +*:Grevert* Superseded by |:Git| revert. +*:Gpush* Superseded by |:Git_push|. +*:Gfetch* Superseded by |:Git_fetch|. +*:Glog* Superseded by |:Gclog|. +*:Gstatus* Superseded by |:Git| (with no arguments). +*:Git!* Superseded by |:Git_--paginate|. +*:Gsplit!* Superseded by |:Git_--paginate|. +*:Gvsplit!* Superseded by :vert Git --paginate. +*:Gtabsplit!* Superseded by :tab Git --paginate. +*:Gpedit!* Superseded by :Git! --paginate. + ABOUT *fugitive-about* Grab the latest version or report a bug on GitHub: diff --git a/sources_non_forked/vim-fugitive/plugin/fugitive.vim b/sources_non_forked/vim-fugitive/plugin/fugitive.vim index a1e66fb6..2b9e4d90 100644 --- a/sources_non_forked/vim-fugitive/plugin/fugitive.vim +++ b/sources_non_forked/vim-fugitive/plugin/fugitive.vim @@ -420,30 +420,32 @@ let s:addr_other = has('patch-8.1.560') ? '-addr=other' : '' let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : '' let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : '' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete G exe fugitive#Command(, , +"", 0, "", )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete Git exe fugitive#Command(, , +"", 0, "", )' +command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete G exe fugitive#Command(, , +"", 0, "", ) +command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete Git exe fugitive#Command(, , +"", 0, "", ) -exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(, , +"", 0, "", )' +if exists(':Gstatus') !=# 2 + exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(, , +"", 0, "", )' +endif -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#CommitComplete Gcommit exe fugitive#Command(, , +"", 0, "", "commit " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#RevertComplete Grevert exe fugitive#Command(, , +"", 0, "", "revert " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#MergeComplete Gmerge exe fugitive#Command(, , +"", 0, "", "merge " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#RebaseComplete Grebase exe fugitive#Command(, , +"", 0, "", "rebase " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#PullComplete Gpull exe fugitive#Command(, , +"", 0, "", "pull " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#PushComplete Gpush exe fugitive#Command(, , +"", 0, "", "push " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#FetchComplete Gfetch exe fugitive#Command(, , +"", 0, "", "fetch " . )' -exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#BlameComplete Gblame exe fugitive#Command(, , +"", 0, "", "blame " . )' +for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'Blame'] + if exists(':G' . tolower(s:cmd)) != 2 + exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd) 'exe fugitive#Command(, , +"", 0, "", "' . tolower(s:cmd) . ' " . )' + endif +endfor +unlet s:cmd exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(, 0)" exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(, 1)" -exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#Command(, , +"", 0, "", "grep " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#Command(, , +"", 0, "", "grep " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#Command(0, > 0 ? : 0, +"", 0, "", "grep " . )' +exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#GrepCommand(, , +"", 0, "", )' +exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#GrepCommand(, , +"", 0, "", )' +exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#GrepCommand(0, > 0 ? : 0, +"", 0, "", )' exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(,,+"",0,"",, "")' exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(,,+"",0,"",, "c")' +exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GcLog :exe fugitive#LogCommand(,,+"",0,"",, "c")' exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gllog :exe fugitive#LogCommand(,,+"",0,"",, "l")' +exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GlLog :exe fugitive#LogCommand(,,+"",0,"",, "l")' exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ge exe fugitive#Open("edit", 0, "", , [])' exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gedit exe fugitive#Open("edit", 0, "", , [])' @@ -465,12 +467,27 @@ exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwrite exe fugitive#WriteCommand(, , +"", 0, "", , [])' exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwq exe fugitive#WqCommand( , , +"", 0, "", , [])' -exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gremove exe fugitive#RemoveCommand(, , +"", 0, "", , [])' -exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gdelete exe fugitive#DeleteCommand(, , +"", 0, "", , [])' -exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( , , +"", 0, "", , [])' -exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject GRemove exe fugitive#RemoveCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject GDelete exe fugitive#DeleteCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject GMove exe fugitive#MoveCommand( , , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete GRename exe fugitive#RenameCommand(, , +"", 0, "", , [])' +if exists(':Gremove') != 2 + exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gremove exe fugitive#RemoveCommand(, , +"", 0, "", , [])' +endif +if exists(':Gdelete') != 2 + exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gdelete exe fugitive#DeleteCommand(, , +"", 0, "", , [])' +endif +if exists(':Gmove') != 2 + exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( , , +"", 0, "", , [])' +endif +if exists(':Grename') != 2 + exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(, , +"", 0, "", , [])' +endif -exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject GBrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' +if exists(':Gbrowse') != 2 + exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' +endif if get(g:, 'fugitive_no_maps') finish diff --git a/sources_non_forked/vim-gist/.github/FUNDING.yml b/sources_non_forked/vim-gist/.github/FUNDING.yml new file mode 100644 index 00000000..351ae11a --- /dev/null +++ b/sources_non_forked/vim-gist/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: mattn # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/sources_non_forked/vim-gist/README.md b/sources_non_forked/vim-gist/README.md new file mode 100644 index 00000000..f2df1bb7 --- /dev/null +++ b/sources_non_forked/vim-gist/README.md @@ -0,0 +1,281 @@ +# Gist.vim + +This is a vimscript for creating gists (http://gist.github.com). + +For the latest version please see https://github.com/mattn/vim-gist. + +## Usage: + +- Post current buffer to gist, using default privacy option. + + :Gist + +- Post selected text to gist, using default privacy option. + This applies to all permutations listed below (except multi). + + :'<,'>Gist + +- Create a private gist. + + :Gist -p + +- Create a public gist. + (Only relevant if you've set gists to be private by default.) + + :Gist -P + +> This is only relevant if you've set gists to be private by default; +> if you get an empty gist list, try ":Gist --abandon". + +- Create a gist anonymously. + + :Gist -a + +- Create a gist with all open buffers. + + :Gist -m + +- Edit the gist (you need to have opened the gist buffer first). + You can update the gist with the ":w" command within the gist buffer. + + :Gist -e + +- Edit the gist with name 'foo.js' (you need to have opened the gist buffer + first). + + :Gist -e foo.js + +- Post/Edit with the description " (you need to have opened the gist buffer + first). > + + :Gist -s something + :Gist -e -s something + +- Delete the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -d + +- Fork the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -f + +- Star the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist +1 + +- Unstar the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -1 + +- Get gist XXXXX. + + :Gist XXXXX + +- Get gist XXXXX and add to clipboard. + + :Gist -c XXXXX + +- List your public gists. + + :Gist -l + +- List gists from user "mattn". + + :Gist -l mattn + +- List everyone's gists. + + :Gist -la + +- List gists from your starred gists. + + :Gist -ls + +- Open the gist on browser after you post or update it. + + :Gist -b + +## List Feature + +- Useful mappings on the gist-listing buffer: + - Both `o` or `Enter` open the gist file in a new buffer, and close the + vim-gist listing one. + - `b` opens the gist file in a browser; this is necessary because + `Shift-Enter` (as was originally) only works for GUI vim. + - `y` copies the contents of the selected gist to the clipboard, and + closes the vim-gist buffer. + - `p` pastes the contents of the selected gist to the buffer from where + vim-gist was called, and closes the vim-gist buffer. + - Hitting `Escape` or `Tab` at the vim-gist buffer closes it. + +- Gist listing has fixed-length columns now, more amenable to eye inspection. + Every line on the gist-listing buffer contains the gist id, name and + description, in that order. Columns are now padded and truncated to offer a + faster browsing, in the following way: + - The gist id string is fixed at 32 characters. + - The length (in characters) of the name of the gist is fixed and + can be set by the user using, for example: + + `let g:gistvim_namelength = 20` + + The default value for `gistvim_namelength` is 30. If the gist (file)name + exceeds that length, it is truncated to the specified length. + - Finally, the gist description is truncated in length to fit the remaining + of the line, avoiding wrapped lines that mess up the table layout. + - Note that the gist listing buffer now does not show the field 'code' + (not sure what that did in the first place). + +## Tips: + +If you set g:gist_clip_command, gist.vim will copy the gist code with option +'-c'. + +- Mac: + + let g:gist_clip_command = 'pbcopy' + +- Linux: + + let g:gist_clip_command = 'xclip -selection clipboard' + +- Others (cygwin?): + + let g:gist_clip_command = 'putclip' + +If you want to detect filetype from the filename: + + let g:gist_detect_filetype = 1 + +If you want to open browser after the post: + + let g:gist_open_browser_after_post = 1 + +If you want to change the browser: + + let g:gist_browser_command = 'w3m %URL%' + +or: + + let g:gist_browser_command = 'opera %URL% &' + +On windows, this should work with your user settings. + +If you want to show your private gists with ":Gist -l": + + let g:gist_show_privates = 1 + +If you want your gist to be private by default: + + let g:gist_post_private = 1 + +If you want your gist to be anonymous by default: + + let g:gist_post_anonymous = 1 + +If you want to manipulate multiple files in a gist: + + let g:gist_get_multiplefile = 1 + +If you want to use on GitHub Enterprise: + + let g:gist_api_url = 'http://your-github-enterprise-domain/api/v3' + +You need to either set global git config: + + $ git config --global github.user Username + +## License: + + Copyright 2010 by Yasuhiro Matsumoto + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + +## Install: + +Copy it to your plugin directory. +gist.vim will create a curl cookie-jar file in your runtimepath. + +- rtp: + - autoload/gist.vim + - plugin/gist.vim + +If you want to uninstall gist.vim, remember to also remove `~/.gist-vim`. + +You need to install webapi-vim also: + + http://www.vim.org/scripts/script.php?script_id=4019 + +If you want to use latest one: + + https://github.com/mattn/webapi-vim + +### Install with [Vundle](https://github.com/gmarik/vundle) + +Add the following lines to your `.vimrc`. + + Bundle 'mattn/webapi-vim' + Bundle 'mattn/vim-gist' + +Now restart Vim and run `:BundleInstall`. + +### Install with [NeoBundle](https://github.com/Shougo/neobundle.vim) + +Add the following line to your `.vimrc`. + + NeoBundle 'mattn/vim-gist', {'depends': 'mattn/webapi-vim'} + +## Requirements: + +- curl command (http://curl.haxx.se/) +- webapi-vim (https://github.com/mattn/webapi-vim) +- and if you want to use your git profile, the git command-line client. + +## Setup: + +This plugin supports both basic and two-factor authentication using GitHub +API v3. The plugin stores its credentials in `~/.gist-vim`. + +First, you need to set your GitHub username in git's global configuration: + + $ git config --global github.user + +Then vim-gist will ask for your password in order to create an access +token. If you have two-factor authentication enabled, vim-gist will also +prompt you to enter the two-factor key you receive. + +NOTE: +If you want you can set it directly to `g:github_user` and `g:gist_token`. + +Whichever type of authentication you use, your GitHub password will not be +stored, only a OAuth access token produced specifically for vim-gist. The +token is stored in `~/.gist-vim`. If you stop using the plugin, you can +easily remove this file. To revoke the associated GitHub token, go to the +list of ["Authorized applications" on GitHub's "Account Settings" +page][uas]. + +[uas]: https://github.com/settings/applications + +**Note:** the username is optional if you only send anonymous gists. diff --git a/sources_non_forked/vim-gist/autoload/gist.vim b/sources_non_forked/vim-gist/autoload/gist.vim new file mode 100644 index 00000000..7f803c6c --- /dev/null +++ b/sources_non_forked/vim-gist/autoload/gist.vim @@ -0,0 +1,1165 @@ +"============================================================================= +" File: gist.vim +" Author: Yasuhiro Matsumoto +" Last Change: 10-Oct-2016. +" Version: 7.3 +" WebPage: http://github.com/mattn/vim-gist +" License: BSD + +let s:save_cpo = &cpoptions +set cpoptions&vim + +if exists('g:gist_disabled') && g:gist_disabled == 1 + function! gist#Gist(...) abort + endfunction + finish +endif + +if !exists('g:github_user') && !executable('git') + echohl ErrorMsg | echomsg 'Gist: require ''git'' command' | echohl None + finish +endif + +if !executable('curl') + echohl ErrorMsg | echomsg 'Gist: require ''curl'' command' | echohl None + finish +endif + +if globpath(&rtp, 'autoload/webapi/http.vim') ==# '' + echohl ErrorMsg | echomsg 'Gist: require ''webapi'', install https://github.com/mattn/webapi-vim' | echohl None + finish +else + call webapi#json#true() +endif + +let s:gist_token_file = expand(get(g:, 'gist_token_file', '~/.gist-vim')) +let s:system = function(get(g:, 'webapi#system_function', 'system')) + +if !exists('g:github_user') + let g:github_user = substitute(s:system('git config --get github.user'), "\n", '', '') + if strlen(g:github_user) == 0 + let g:github_user = $GITHUB_USER + end +endif + +if !exists('g:gist_api_url') + let g:gist_api_url = substitute(s:system('git config --get github.apiurl'), "\n", '', '') + if strlen(g:gist_api_url) == 0 + let g:gist_api_url = 'https://api.github.com/' + end + if exists('g:github_api_url') && !exists('g:gist_shutup_issue154') + if matchstr(g:gist_api_url, 'https\?://\zs[^/]\+\ze') != matchstr(g:github_api_url, 'https\?://\zs[^/]\+\ze') + echohl WarningMsg + echo '--- Warning ---' + echo 'It seems that you set different URIs for github_api_url/gist_api_url.' + echo 'If you want to remove this message: let g:gist_shutup_issue154 = 1' + echohl None + if confirm('Continue?', '&Yes\n&No') != 1 + let g:gist_disabled = 1 + finish + endif + redraw! + endif + endif +endif +if g:gist_api_url !~# '/$' + let g:gist_api_url .= '/' +endif + +if !exists('g:gist_update_on_write') + let g:gist_update_on_write = 1 +endif + +function! s:get_browser_command() abort + let gist_browser_command = get(g:, 'gist_browser_command', '') + if gist_browser_command ==# '' + if has('win32') || has('win64') + let gist_browser_command = '!start rundll32 url.dll,FileProtocolHandler %URL%' + elseif has('mac') || has('macunix') || has('gui_macvim') || system('uname') =~? '^darwin' + let gist_browser_command = 'open %URL%' + elseif executable('xdg-open') + let gist_browser_command = 'xdg-open %URL%' + elseif executable('firefox') + let gist_browser_command = 'firefox %URL% &' + else + let gist_browser_command = '' + endif + endif + return gist_browser_command +endfunction + +function! s:open_browser(url) abort + let cmd = s:get_browser_command() + if len(cmd) == 0 + redraw + echohl WarningMsg + echo 'It seems that you don''t have general web browser. Open URL below.' + echohl None + echo a:url + return + endif + let quote = &shellxquote == '"' ? "'" : '"' + if cmd =~# '^!' + let cmd = substitute(cmd, '%URL%', '\=quote.a:url.quote', 'g') + silent! exec cmd + elseif cmd =~# '^:[A-Z]' + let cmd = substitute(cmd, '%URL%', '\=a:url', 'g') + exec cmd + else + let cmd = substitute(cmd, '%URL%', '\=quote.a:url.quote', 'g') + call system(cmd) + endif +endfunction + +function! s:shellwords(str) abort + let words = split(a:str, '\%(\([^ \t\''"]\+\)\|''\([^\'']*\)''\|"\(\%([^\"\\]\|\\.\)*\)"\)\zs\s*\ze') + let words = map(words, 'substitute(v:val, ''\\\([\\ ]\)'', ''\1'', "g")') + let words = map(words, 'matchstr(v:val, ''^\%\("\zs\(.*\)\ze"\|''''\zs\(.*\)\ze''''\|.*\)$'')') + return words +endfunction + +function! s:truncate(str, num) + let mx_first = '^\(.\)\(.*\)$' + let str = a:str + let ret = '' + let width = 0 + while 1 + let char = substitute(str, mx_first, '\1', '') + let cells = strdisplaywidth(char) + if cells == 0 || width + cells > a:num + break + endif + let width = width + cells + let ret .= char + let str = substitute(str, mx_first, '\2', '') + endwhile + while width + 1 <= a:num + let ret .= " " + let width = width + 1 + endwhile + return ret +endfunction + +function! s:format_gist(gist) abort + let files = sort(keys(a:gist.files)) + if empty(files) + return '' + endif + let file = a:gist.files[files[0]] + let name = file.filename + if has_key(file, 'content') + let code = file.content + let code = "\n".join(map(split(code, "\n"), '" ".v:val'), "\n") + else + let code = '' + endif + let desc = type(a:gist.description)==0 || a:gist.description ==# '' ? '' : a:gist.description + let name = substitute(name, '[\r\n\t]', ' ', 'g') + let name = substitute(name, ' ', ' ', 'g') + let desc = substitute(desc, '[\r\n\t]', ' ', 'g') + let desc = substitute(desc, ' ', ' ', 'g') + " Display a nice formatted (and truncated if needed) table of gists on screen + " Calculate field lengths for gist-listing formatting on screen + redir =>a |exe "sil sign place buffer=".bufnr('')|redir end + let signlist = split(a, '\n') + let width = winwidth(0) - ((&number||&relativenumber) ? &numberwidth : 0) - &foldcolumn - (len(signlist) > 2 ? 2 : 0) + let idlen = 33 + let namelen = get(g:, 'gist_namelength', 30) + let desclen = width - (idlen + namelen + 10) + return printf('gist: %s %s %s', s:truncate(a:gist.id, idlen), s:truncate(name, namelen), s:truncate(desc, desclen)) +endfunction + +" Note: A colon in the file name has side effects on Windows due to NTFS Alternate Data Streams; avoid it. +let s:bufprefix = 'gist' . (has('unix') ? ':' : '_') +function! s:GistList(gistls, page) abort + if a:gistls ==# '-all' + let url = g:gist_api_url.'gists/public' + elseif get(g:, 'gist_show_privates', 0) && a:gistls ==# 'starred' + let url = g:gist_api_url.'gists/starred' + elseif get(g:, 'gist_show_privates') && a:gistls ==# 'mine' + let url = g:gist_api_url.'gists' + else + let url = g:gist_api_url.'users/'.a:gistls.'/gists' + endif + let winnum = bufwinnr(bufnr(s:bufprefix.a:gistls)) + if winnum != -1 + if winnum != bufwinnr('%') + exe winnum 'wincmd w' + endif + setlocal modifiable + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd vsplit +set\ winfixwidth ' s:bufprefix.a:gistls + elseif get(g:, 'gist_list_rightbelow', 0) + exec 'silent noautocmd rightbelow 5 split +set\ winfixheight ' s:bufprefix.a:gistls + else + exec 'silent noautocmd split' s:bufprefix.a:gistls + endif + endif + if a:page > 1 + let oldlines = getline(0, line('$')) + let url = url . '?page=' . a:page + endif + + setlocal modifiable + let old_undolevels = &undolevels + let oldlines = [] + silent %d _ + + redraw | echon 'Listing gists... ' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + bw! + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let res = webapi#http#get(url, '', { "Authorization": auth }) + if v:shell_error != 0 + bw! + redraw + echohl ErrorMsg | echomsg 'Gists not found' | echohl None + return + endif + let content = webapi#json#decode(res.content) + if type(content) == 4 && has_key(content, 'message') && len(content.message) + bw! + redraw + echohl ErrorMsg | echomsg content.message | echohl None + if content.message ==# 'Bad credentials' + call delete(s:gist_token_file) + endif + return + endif + + let lines = map(filter(content, '!empty(v:val.files)'), 's:format_gist(v:val)') + call setline(1, split(join(lines, "\n"), "\n")) + + $put='more...' + + let b:gistls = a:gistls + let b:page = a:page + setlocal buftype=nofile bufhidden=hide noswapfile + setlocal cursorline + setlocal nomodified + setlocal nomodifiable + syntax match SpecialKey /^gist:/he=e-1 + syntax match Title /^gist: \S\+/hs=s+5 contains=ALL + nnoremap :call GistListAction(0) + nnoremap o :call GistListAction(0) + nnoremap b :call GistListAction(1) + nnoremap y :call GistListAction(2) + nnoremap p :call GistListAction(3) + nnoremap :bw + nnoremap :call GistListAction(1) + + cal cursor(1+len(oldlines),1) + nohlsearch + redraw | echo '' +endfunction + +function! gist#list_recursively(user, ...) abort + let use_cache = get(a:000, 0, 1) + let limit = get(a:000, 1, -1) + let verbose = get(a:000, 2, 1) + if a:user ==# 'mine' + let url = g:gist_api_url . 'gists' + elseif a:user ==# 'starred' + let url = g:gist_api_url . 'gists/starred' + else + let url = g:gist_api_url.'users/'.a:user.'/gists' + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + " anonymous user cannot get gists to prevent infinite recursive loading + return [] + endif + + if use_cache && exists('g:gist_list_recursively_cache') + if has_key(g:gist_list_recursively_cache, a:user) + return webapi#json#decode(g:gist_list_recursively_cache[a:user]) + endif + endif + + let page = 1 + let gists = [] + let lastpage = -1 + + function! s:get_lastpage(res) abort + let links = split(a:res.header[match(a:res.header, 'Link')], ',') + let link = links[match(links, 'rel=[''"]last[''"]')] + let page = str2nr(matchlist(link, '\%(page=\)\(\d\+\)')[1]) + return page + endfunction + + if verbose > 0 + redraw | echon 'Loading gists...' + endif + + while limit == -1 || page <= limit + let res = webapi#http#get(url.'?page='.page, '', {'Authorization': auth}) + if limit == -1 + " update limit to the last page + let limit = s:get_lastpage(res) + endif + if verbose > 0 + redraw | echon 'Loading gists... ' . page . '/' . limit . ' pages has loaded.' + endif + let gists = gists + webapi#json#decode(res.content) + let page = page + 1 + endwhile + let g:gist_list_recursively_cache = get(g:, 'gist_list_recursively_cache', {}) + let g:gist_list_recursively_cache[a:user] = webapi#json#encode(gists) + return gists +endfunction + +function! gist#list(user, ...) abort + let page = get(a:000, 0, 0) + if a:user ==# '-all' + let url = g:gist_api_url.'gists/public' + elseif get(g:, 'gist_show_privates', 0) && a:user ==# 'starred' + let url = g:gist_api_url.'gists/starred' + elseif get(g:, 'gist_show_privates') && a:user ==# 'mine' + let url = g:gist_api_url.'gists' + else + let url = g:gist_api_url.'users/'.a:user.'/gists' + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return [] + endif + let res = webapi#http#get(url, '', { "Authorization": auth }) + return webapi#json#decode(res.content) +endfunction + +function! s:GistGetFileName(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return '' + endif + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth }) + let gist = webapi#json#decode(res.content) + if has_key(gist, 'files') + return sort(keys(gist.files))[0] + endif + return '' +endfunction + +function! s:GistDetectFiletype(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return '' + endif + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth }) + let gist = webapi#json#decode(res.content) + let filename = sort(keys(gist.files))[0] + let ext = fnamemodify(filename, ':e') + if has_key(s:extmap, ext) + let type = s:extmap[ext] + else + let type = get(gist.files[filename], 'type', 'text') + endif + silent! exec 'setlocal ft='.tolower(type) +endfunction + +function! s:GistWrite(fname) abort + if substitute(a:fname, '\\', '/', 'g') == expand("%:p:gs@\\@/@") + if g:gist_update_on_write != 2 || v:cmdbang + Gist -e + else + echohl ErrorMsg | echomsg 'Please type ":w!" to update a gist.' | echohl None + endif + else + exe 'w'.(v:cmdbang ? '!' : '') fnameescape(v:cmdarg) fnameescape(a:fname) + silent! exe 'file' fnameescape(a:fname) + silent! au! BufWriteCmd + endif +endfunction + +function! s:GistGet(gistid, clipboard) abort + redraw | echon 'Getting gist... ' + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": s:GistGetAuthHeader() }) + if res.status =~# '^2' + try + let gist = webapi#json#decode(res.content) + catch + redraw + echohl ErrorMsg | echomsg 'Gist seems to be broken' | echohl None + return + endtry + if get(g:, 'gist_get_multiplefile', 0) != 0 + let num_file = len(keys(gist.files)) + else + let num_file = 1 + endif + redraw + if num_file > len(keys(gist.files)) + echohl ErrorMsg | echomsg 'Gist not found' | echohl None + return + endif + augroup GistWrite + au! + augroup END + for n in range(num_file) + try + let old_undolevels = &undolevels + let filename = sort(keys(gist.files))[n] + + let winnum = bufwinnr(bufnr(s:bufprefix.a:gistid.'/'.filename)) + if winnum != -1 + if winnum != bufwinnr('%') + exe winnum 'wincmd w' + endif + setlocal modifiable + else + if num_file == 1 + if get(g:, 'gist_edit_with_buffers', 0) + let found = -1 + for wnr in range(1, winnr('$')) + let bnr = winbufnr(wnr) + if bnr != -1 && !empty(getbufvar(bnr, 'gist')) + let found = wnr + break + endif + endfor + if found != -1 + exe found 'wincmd w' + setlocal modifiable + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + else + silent only! + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + setlocal noswapfile + silent exec 'noautocmd file' s:bufprefix.a:gistid.'/'.fnameescape(filename) + endif + set undolevels=-1 + filetype detect + silent %d _ + + let content = gist.files[filename].content + call setline(1, split(content, "\n")) + let b:gist = { + \ "filename": filename, + \ "id": gist.id, + \ "description": gist.description, + \ "private": gist.public =~ 'true', + \} + catch + let &undolevels = old_undolevels + bw! + redraw + echohl ErrorMsg | echomsg 'Gist contains binary' | echohl None + return + endtry + let &undolevels = old_undolevels + setlocal buftype=acwrite bufhidden=hide noswapfile + setlocal nomodified + doau StdinReadPost,BufRead,BufReadPost + let gist_detect_filetype = get(g:, 'gist_detect_filetype', 0) + if (&ft ==# '' && gist_detect_filetype == 1) || gist_detect_filetype == 2 + call s:GistDetectFiletype(a:gistid) + endif + if a:clipboard + if exists('g:gist_clip_command') + exec 'silent w !'.g:gist_clip_command + elseif has('clipboard') + silent! %yank + + else + %yank + endif + endif + 1 + augroup GistWrite + au! BufWriteCmd call s:GistWrite(expand("")) + augroup END + endfor + else + bw! + redraw + echohl ErrorMsg | echomsg 'Gist not found' | echohl None + return + endif +endfunction + +function! s:GistListAction(mode) abort + let line = getline('.') + let mx = '^gist:\s*\zs\(\w\+\)\ze.*' + if line =~# mx + let gistid = matchstr(line, mx) + if a:mode == 1 + call s:open_browser('https://gist.github.com/' . gistid) + elseif a:mode == 0 + call s:GistGet(gistid, 0) + wincmd w + bw + elseif a:mode == 2 + call s:GistGet(gistid, 1) + " TODO close with buffe rname + bdelete + bdelete + elseif a:mode == 3 + call s:GistGet(gistid, 1) + " TODO close with buffe rname + bdelete + bdelete + normal! "+p + endif + return + endif + if line =~# '^more\.\.\.$' + call s:GistList(b:gistls, b:page+1) + return + endif +endfunction + +function! s:GistUpdate(content, gistid, gistnm, desc) abort + let gist = { "id": a:gistid, "files" : {}, "description": "","public": function('webapi#json#true') } + if exists('b:gist') + if has_key(b:gist, 'filename') && len(a:gistnm) > 0 + let gist.files[b:gist.filename] = { "content": '', "filename": b:gist.filename } + let b:gist.filename = a:gistnm + endif + if has_key(b:gist, 'private') && b:gist.private | let gist['public'] = function('webapi#json#false') | endif + if has_key(b:gist, 'description') | let gist['description'] = b:gist.description | endif + if has_key(b:gist, 'filename') | let filename = b:gist.filename | endif + else + let filename = a:gistnm + if len(filename) == 0 | let filename = s:GistGetFileName(a:gistid) | endif + if len(filename) == 0 | let filename = s:get_current_filename(1) | endif + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + + " Update description + " If no new description specified, keep the old description + if a:desc !=# ' ' + let gist['description'] = a:desc + else + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth }) + if res.status =~# '^2' + let old_gist = webapi#json#decode(res.content) + let gist['description'] = old_gist.description + endif + endif + + let gist.files[filename] = { "content": a:content, "filename": filename } + + redraw | echon 'Updating gist... ' + let res = webapi#http#post(g:gist_api_url.'gists/' . a:gistid, + \ webapi#json#encode(gist), { + \ "Authorization": auth, + \ "Content-Type": "application/json", + \}) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = {"id": a:gistid, "filename": filename} + setlocal nomodified + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: ' . res.message | echohl None + endif + return loc +endfunction + +function! s:GistDelete(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + + redraw | echon 'Deleting gist... ' + let res = webapi#http#post(g:gist_api_url.'gists/'.a:gistid, '', { + \ "Authorization": auth, + \ "Content-Type": "application/json", + \}, 'DELETE') + if res.status =~# '^2' + if exists('b:gist') + unlet b:gist + endif + redraw | echomsg 'Done: ' + else + echohl ErrorMsg | echomsg 'Delete failed: ' . res.message | echohl None + endif +endfunction + +function! s:get_current_filename(no) abort + let filename = expand('%:t') + if len(filename) == 0 && &ft !=# '' + let pair = filter(items(s:extmap), 'v:val[1] == &ft') + if len(pair) > 0 + let filename = printf('gistfile%d%s', a:no, pair[0][0]) + endif + endif + if filename ==# '' + let filename = printf('gistfile%d.txt', a:no) + endif + return filename +endfunction + +function! s:update_GistID(id) abort + let view = winsaveview() + normal! gg + let ret = 0 + if search('\:\s*$') + let line = getline('.') + let line = substitute(line, '\s\+$', '', 'g') + call setline('.', line . ' ' . a:id) + let ret = 1 + endif + call winrestview(view) + return ret +endfunction + +" GistPost function: +" Post new gist to github +" +" if there is an embedded gist url or gist id in your file, +" it will just update it. +" -- by c9s +" +" embedded gist id format: +" +" GistID: 123123 +" +function! s:GistPost(content, private, desc, anonymous) abort + let gist = { "files" : {}, "description": "","public": function('webapi#json#true') } + if a:desc !=# ' ' | let gist['description'] = a:desc | endif + if a:private | let gist['public'] = function('webapi#json#false') | endif + let filename = s:get_current_filename(1) + let gist.files[filename] = { "content": a:content, "filename": filename } + + let header = {"Content-Type": "application/json"} + if !a:anonymous + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let header['Authorization'] = auth + endif + + redraw | echon 'Posting it to gist... ' + let res = webapi#http#post(g:gist_api_url.'gists', webapi#json#encode(gist), header) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = { + \ "filename": filename, + \ "id": matchstr(loc, '[^/]\+$'), + \ "description": gist['description'], + \ "private": a:private, + \} + if s:update_GistID(b:gist['id']) + Gist -e + endif + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: '. res.message | echohl None + endif + return loc +endfunction + +function! s:GistPostBuffers(private, desc, anonymous) abort + let bufnrs = range(1, bufnr('$')) + let bn = bufnr('%') + let query = [] + + let gist = { "files" : {}, "description": "","public": function('webapi#json#true') } + if a:desc !=# ' ' | let gist['description'] = a:desc | endif + if a:private | let gist['public'] = function('webapi#json#false') | endif + + let index = 1 + for bufnr in bufnrs + if !bufexists(bufnr) || buflisted(bufnr) == 0 + continue + endif + echo 'Creating gist content'.index.'... ' + silent! exec 'buffer!' bufnr + let content = join(getline(1, line('$')), "\n") + let filename = s:get_current_filename(index) + let gist.files[filename] = { "content": content, "filename": filename } + let index = index + 1 + endfor + silent! exec 'buffer!' bn + + let header = {"Content-Type": "application/json"} + if !a:anonymous + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let header['Authorization'] = auth + endif + + redraw | echon 'Posting it to gist... ' + let res = webapi#http#post(g:gist_api_url.'gists', webapi#json#encode(gist), header) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = { + \ "filename": filename, + \ "id": matchstr(loc, '[^/]\+$'), + \ "description": gist['description'], + \ "private": a:private, + \} + if s:update_GistID(b:gist['id']) + Gist -e + endif + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: ' . res.message | echohl None + endif + return loc +endfunction + +function! gist#Gist(count, bang, line1, line2, ...) abort + redraw + let bufname = bufname('%') + " find GistID: in content , then we should just update + let gistid = '' + let gistls = '' + let gistnm = '' + let gistdesc = ' ' + let private = get(g:, 'gist_post_private', 0) + let multibuffer = 0 + let clipboard = 0 + let deletepost = 0 + let editpost = 0 + let anonymous = get(g:, 'gist_post_anonymous', 0) + let openbrowser = 0 + let listmx = '^\%(-l\|--list\)\s*\([^\s]\+\)\?$' + let bufnamemx = '^' . s:bufprefix .'\(\zs[0-9a-f]\+\ze\|\zs[0-9a-f]\+\ze[/\\].*\)$' + if strlen(g:github_user) == 0 && anonymous == 0 + echohl ErrorMsg | echomsg 'You have not configured a Github account. Read '':help gist-setup''.' | echohl None + return + endif + if a:bang == '!' + let gistidbuf = '' + elseif bufname =~# bufnamemx + let gistidbuf = matchstr(bufname, bufnamemx) + elseif exists('b:gist') && has_key(b:gist, 'id') + let gistidbuf = b:gist['id'] + else + let gistidbuf = matchstr(join(getline(a:line1, a:line2), "\n"), 'GistID:\s*\zs\w\+') + endif + + let args = (a:0 > 0) ? s:shellwords(a:1) : [] + for arg in args + if arg =~# '^\(-h\|--help\)$\C' + help :Gist + return + elseif arg =~# '^\(-g\|--git\)$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' && has_key(b:, 'gist') && has_key(b:gist, 'id') + echo printf('git clone git@github.com:%s', b:gist['id']) + return + elseif arg =~# '^\(-G\|--gitclone\)$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' && has_key(b:, 'gist') && has_key(b:gist, 'id') + exe '!' printf('git clone git@github.com:%s', b:gist['id']) + return + elseif arg =~# '^\(-la\|--listall\)$\C' + let gistls = '-all' + elseif arg =~# '^\(-ls\|--liststar\)$\C' + let gistls = 'starred' + elseif arg =~# '^\(-l\|--list\)$\C' + if get(g:, 'gist_show_privates') + let gistls = 'mine' + else + let gistls = g:github_user + endif + elseif arg =~# '^\(-m\|--multibuffer\)$\C' + let multibuffer = 1 + elseif arg =~# '^\(-p\|--private\)$\C' + let private = 1 + elseif arg =~# '^\(-P\|--public\)$\C' + let private = 0 + elseif arg =~# '^\(-a\|--anonymous\)$\C' + let anonymous = 1 + elseif arg =~# '^\(-s\|--description\)$\C' + let gistdesc = '' + elseif arg =~# '^\(-c\|--clipboard\)$\C' + let clipboard = 1 + elseif arg =~# '^--rawurl$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' + let gistid = gistidbuf + echo 'https://gist.github.com/raw/'.gistid + return + elseif arg =~# '^\(-d\|--delete\)$\C' && gistidbuf !=# '' + let gistid = gistidbuf + let deletepost = 1 + elseif arg =~# '^\(-e\|--edit\)$\C' + if gistidbuf !=# '' + let gistid = gistidbuf + endif + let editpost = 1 + elseif arg =~# '^\(+1\|--star\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { "Authorization": auth }, 'PUT') + if res.status =~# '^2' + echomsg 'Starred' gistid + else + echohl ErrorMsg | echomsg 'Star failed' | echohl None + endif + endif + return + elseif arg =~# '^\(-1\|--unstar\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { "Authorization": auth }, 'DELETE') + if res.status =~# '^2' + echomsg 'Unstarred' gistid + else + echohl ErrorMsg | echomsg 'Unstar failed' | echohl None + endif + endif + return + elseif arg =~# '^\(-f\|--fork\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/fork', '', { "Authorization": auth }) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let gistid = obj['id'] + else + echohl ErrorMsg | echomsg 'Fork failed' | echohl None + return + endif + endif + elseif arg =~# '^\(-b\|--browser\)$\C' + let openbrowser = 1 + elseif arg !~# '^-' && len(gistnm) == 0 + if gistdesc !=# ' ' + let gistdesc = matchstr(arg, '^\s*\zs.*\ze\s*$') + elseif editpost == 1 || deletepost == 1 + let gistnm = arg + elseif len(gistls) > 0 && arg !=# '^\w\+$\C' + let gistls = arg + elseif arg =~# '^[0-9a-z]\+$\C' + let gistid = arg + else + echohl ErrorMsg | echomsg 'Invalid arguments: '.arg | echohl None + unlet args + return 0 + endif + elseif len(arg) > 0 + echohl ErrorMsg | echomsg 'Invalid arguments: '.arg | echohl None + unlet args + return 0 + endif + endfor + unlet args + "echom "gistid=".gistid + "echom "gistls=".gistls + "echom "gistnm=".gistnm + "echom "gistdesc=".gistdesc + "echom "private=".private + "echom "clipboard=".clipboard + "echom "editpost=".editpost + "echom "deletepost=".deletepost + + if gistidbuf !=# '' && gistid ==# '' && editpost == 0 && deletepost == 0 && anonymous == 0 + let editpost = 1 + let gistid = gistidbuf + endif + + if len(gistls) > 0 + call s:GistList(gistls, 1) + elseif len(gistid) > 0 && editpost == 0 && deletepost == 0 + call s:GistGet(gistid, clipboard) + else + let url = '' + if multibuffer == 1 + let url = s:GistPostBuffers(private, gistdesc, anonymous) + else + if a:count < 1 + let content = join(getline(a:line1, a:line2), "\n") + else + let save_regcont = @" + let save_regtype = getregtype('"') + silent! normal! gvy + let content = @" + call setreg('"', save_regcont, save_regtype) + endif + if editpost == 1 + let url = s:GistUpdate(content, gistid, gistnm, gistdesc) + elseif deletepost == 1 + call s:GistDelete(gistid) + else + let url = s:GistPost(content, private, gistdesc, anonymous) + endif + if a:count >= 1 && get(g:, 'gist_keep_selection', 0) == 1 + silent! normal! gv + endif + endif + if type(url) == 1 && len(url) > 0 + if get(g:, 'gist_open_browser_after_post', 0) == 1 || openbrowser + call s:open_browser(url) + endif + let gist_put_url_to_clipboard_after_post = get(g:, 'gist_put_url_to_clipboard_after_post', 1) + if gist_put_url_to_clipboard_after_post > 0 || clipboard + if gist_put_url_to_clipboard_after_post == 2 + let url = url . "\n" + endif + if exists('g:gist_clip_command') + call system(g:gist_clip_command, url) + elseif has('clipboard') + let @+ = url + else + let @" = url + endif + endif + endif + endif + return 1 +endfunction + +function! s:GistGetAuthHeader() abort + if get(g:, 'gist_use_password_in_gitconfig', 0) != 0 + let password = substitute(system('git config --get github.password'), "\n", '', '') + if password =~# '^!' | let password = system(password[1:]) | endif + return printf('basic %s', webapi#base64#b64encode(g:github_user.':'.password)) + endif + let auth = '' + if !empty(get(g:, 'gist_token', $GITHUB_TOKEN)) + let auth = 'token ' . get(g:, 'gist_token', $GITHUB_TOKEN) + elseif filereadable(s:gist_token_file) + let str = join(readfile(s:gist_token_file), '') + if type(str) == 1 + let auth = str + endif + endif + if len(auth) > 0 + return auth + endif + + redraw + echohl WarningMsg + echo 'Gist.vim requires authorization to use the GitHub API. These settings are stored in "~/.gist-vim". If you want to revoke, do "rm ~/.gist-vim".' + echohl None + let password = inputsecret('GitHub Password for '.g:github_user.':') + if len(password) == 0 + let v:errmsg = 'Canceled' + return '' + endif + let note = 'Gist.vim on '.hostname().' '.strftime('%Y/%m/%d-%H:%M:%S') + let note_url = 'http://www.vim.org/scripts/script.php?script_id=2423' + let insecureSecret = printf('basic %s', webapi#base64#b64encode(g:github_user.':'.password)) + let res = webapi#http#post(g:gist_api_url.'authorizations', webapi#json#encode({ + \ "scopes" : ["gist"], + \ "note" : note, + \ "note_url" : note_url, + \}), { + \ "Content-Type" : "application/json", + \ "Authorization" : insecureSecret, + \}) + let h = filter(res.header, 'stridx(v:val, "X-GitHub-OTP:") == 0') + if len(h) + let otp = inputsecret('OTP:') + if len(otp) == 0 + let v:errmsg = 'Canceled' + return '' + endif + let res = webapi#http#post(g:gist_api_url.'authorizations', webapi#json#encode({ + \ "scopes" : ["gist"], + \ "note" : note, + \ "note_url" : note_url, + \}), { + \ "Content-Type" : "application/json", + \ "Authorization" : insecureSecret, + \ "X-GitHub-OTP" : otp, + \}) + endif + let authorization = webapi#json#decode(res.content) + if has_key(authorization, 'token') + let secret = printf('token %s', authorization.token) + call writefile([secret], s:gist_token_file) + if !(has('win32') || has('win64')) + call system('chmod go= '.s:gist_token_file) + endif + elseif has_key(authorization, 'message') + let secret = '' + let v:errmsg = authorization.message + endif + return secret +endfunction + +let s:extmap = extend({ +\".adb": "ada", +\".ahk": "ahk", +\".arc": "arc", +\".as": "actionscript", +\".asm": "asm", +\".asp": "asp", +\".aw": "php", +\".b": "b", +\".bat": "bat", +\".befunge": "befunge", +\".bmx": "bmx", +\".boo": "boo", +\".c-objdump": "c-objdump", +\".c": "c", +\".cfg": "cfg", +\".cfm": "cfm", +\".ck": "ck", +\".cl": "cl", +\".clj": "clj", +\".cmake": "cmake", +\".coffee": "coffee", +\".cpp": "cpp", +\".cppobjdump": "cppobjdump", +\".cs": "csharp", +\".css": "css", +\".cw": "cw", +\".d-objdump": "d-objdump", +\".d": "d", +\".darcspatch": "darcspatch", +\".diff": "diff", +\".duby": "duby", +\".dylan": "dylan", +\".e": "e", +\".ebuild": "ebuild", +\".eclass": "eclass", +\".el": "lisp", +\".erb": "erb", +\".erl": "erlang", +\".f90": "f90", +\".factor": "factor", +\".feature": "feature", +\".fs": "fs", +\".fy": "fy", +\".go": "go", +\".groovy": "groovy", +\".gs": "gs", +\".gsp": "gsp", +\".haml": "haml", +\".hs": "haskell", +\".html": "html", +\".hx": "hx", +\".ik": "ik", +\".ino": "ino", +\".io": "io", +\".j": "j", +\".java": "java", +\".js": "javascript", +\".json": "json", +\".jsp": "jsp", +\".kid": "kid", +\".lhs": "lhs", +\".lisp": "lisp", +\".ll": "ll", +\".lua": "lua", +\".ly": "ly", +\".m": "objc", +\".mak": "mak", +\".man": "man", +\".mao": "mao", +\".matlab": "matlab", +\".md": "markdown", +\".minid": "minid", +\".ml": "ml", +\".moo": "moo", +\".mu": "mu", +\".mustache": "mustache", +\".mxt": "mxt", +\".myt": "myt", +\".n": "n", +\".nim": "nim", +\".nu": "nu", +\".numpy": "numpy", +\".objdump": "objdump", +\".ooc": "ooc", +\".parrot": "parrot", +\".pas": "pas", +\".pasm": "pasm", +\".pd": "pd", +\".phtml": "phtml", +\".pir": "pir", +\".pl": "perl", +\".po": "po", +\".py": "python", +\".pytb": "pytb", +\".pyx": "pyx", +\".r": "r", +\".raw": "raw", +\".rb": "ruby", +\".rhtml": "rhtml", +\".rkt": "rkt", +\".rs": "rs", +\".rst": "rst", +\".s": "s", +\".sass": "sass", +\".sc": "sc", +\".scala": "scala", +\".scm": "scheme", +\".scpt": "scpt", +\".scss": "scss", +\".self": "self", +\".sh": "sh", +\".sml": "sml", +\".sql": "sql", +\".st": "smalltalk", +\".swift": "swift", +\".tcl": "tcl", +\".tcsh": "tcsh", +\".tex": "tex", +\".textile": "textile", +\".tpl": "smarty", +\".twig": "twig", +\".txt" : "text", +\".v": "verilog", +\".vala": "vala", +\".vb": "vbnet", +\".vhd": "vhdl", +\".vim": "vim", +\".weechatlog": "weechatlog", +\".xml": "xml", +\".xq": "xquery", +\".xs": "xs", +\".yml": "yaml", +\}, get(g:, 'gist_extmap', {})) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et: diff --git a/sources_non_forked/vim-gist/doc/gist-vim.txt b/sources_non_forked/vim-gist/doc/gist-vim.txt new file mode 100644 index 00000000..88c46d10 --- /dev/null +++ b/sources_non_forked/vim-gist/doc/gist-vim.txt @@ -0,0 +1,358 @@ +*Gist.vim* Vimscript for creating gists (http://gist.github.com) + +Usage |vim-gist-usage| +Tips |vim-gist-tips| +License |vim-gist-license| +Install |vim-gist-install| +Requirements |vim-gist-requirements| +Setup |vim-gist-setup| +FAQ |vim-gist-faq| + +This is a vimscript for creating gists (http://gist.github.com) + +For the latest version please see https://github.com/mattn/vim-gist. + +============================================================================== +USAGE *:Gist* *vim-gist-usage* + +- Post current buffer to gist, using default privacy option. > + + :Gist +< +- Post selected text to gist, using default privacy option. + This applies to all permutations listed below (except multi). > + + :'<,'>Gist +< +- Create a private gist. > + + :Gist -p + :Gist --private +< +- Create a public gist. + (Only relevant if you've set gists to be private by default.) > + + :Gist -P + :Gist --public +< +- Post whole text to gist as public. + This is only relevant if you've set gists to be private by default. +> + :Gist -P +< +- Create a gist anonymously. > + + :Gist -a + :Gist --anonymous +< +- Create a gist with all open buffers. > + + :Gist -m + :Gist --multibuffer +< +- Edit the gist (you need to have opened the gist buffer first). + You can update the gist with the {:w} command within the gist buffer. > + + :Gist -e + :Gist --edit +< +- Edit the gist with name "foo.js" (you need to have opened the gist buffer + first). > + + :Gist -e foo.js +< +- Post/Edit with the description " (you need to have opened the gist buffer + first). > + + :Gist -s something + :Gist --description something + :Gist -e -s something +< +- Delete the gist (you need to have opened the gist buffer first). + Password authentication is needed. > + + :Gist -d + :Gist --delete +< +- Fork the gist (you need to have opened the gist buffer first). + Password authentication is needed. > + + :Gist -f + :Gist --fork +< +- Star the gist (you need to have opened the gist buffer first). + Password authentication is needed. +> + :Gist +1 +< +- Unstar the gist (you need to have opened the gist buffer first). + Password authentication is needed. +> + :Gist -1 +< +- Get gist XXXXX. > + + :Gist XXXXX +< +- Get gist XXXXX and add to clipboard. > + + :Gist -c XXXXX +< +- List your public gists. > + + :Gist -l + :Gist --list +< +- List gists from user "mattn". > + + :Gist -l mattn +< +- List everyone's gists. > + + :Gist -la + :Gist --listall +< +- List gists from your starred gists. +> + :Gist -ls + :Gist --liststar + +- While the gist list is visible, the following mappings apply: + + - 'o' or 'Enter' will open the selected gist file in a new buffer + and close the vim-gist listing split. + - 'b' will open the selected gist file in a browser. If you are in + GUI vim you can also achieve this by pressing 'Shift-Enter'. + - 'y' will copy the contents of the selected gist to the clipboard, + and close the vim-gist listing split. + - 'p' will (copy and) paste the contents of the selected gist to the + buffer from which vim-gist was called, and close the vim-gist + listing split. + - 'Esc' will close the vim-gist listing split without performing any + further action. + +- Open the gist on browser after you post or update it. +> + :Gist -b + :Gist --browser +< +- Post as new gist after editing on the buffer. +> + :Gist! +< +============================================================================== +TIPS *vim-gist-tips* + +If you set "g:gist_clip_command", gist.vim will copy the gist code with option +"-c". + + - Mac: > + let g:gist_clip_command = 'pbcopy' +< + - Linux: > + let g:gist_clip_command = 'xclip -selection clipboard' +< + - Others (cygwin?): > + let g:gist_clip_command = 'putclip' +< +If you want to detect filetype from the filename: > + + let g:gist_detect_filetype = 1 +< +If you want to open the browser after the post: > + + let g:gist_open_browser_after_post = 1 +< +If you want to change the browser: > + + let g:gist_browser_command = 'w3m %URL%' +< +or: > + + let g:gist_browser_command = 'opera %URL% &' +< +On windows, this should work with your user settings. + +If you want to show your private gists with ":Gist -l": > + + let g:gist_show_privates = 1 +< +If you want your gist to be private by default: > + + let g:gist_post_private = 1 +< +If you want your gist to be anonymous by default: > + + let g:gist_post_anonymous = 1 +< +If you want to edit all files for gists containing more than one: > + + let g:gist_get_multiplefile = 1 +< +If you want to use on GitHub Enterprise: > + + let g:gist_api_url = 'http://your-github-enterprise-domain/api/v3' +< +If you want to open gist with current editing buffers: > + + let g:gist_edit_with_buffers = 1 + +If you want to open gist list/buffer as vertical split: > + + let g:gist_list_vsplit = 1 + +If you want to modify filetype for the file on github, or add mapping of +filetype/file-extension: > + + let g:gist_extmap = { ".swift": "swift" } +< + key is file-extension, value is filetype. + +If you want to update a gist, embed > + + GistID: xxxxx +> +in your local file, then call > + + :Gist + +The vim-gist listing split lists gists ids, names (filenames) as well as +their description. This is done following a table layout, with fixed space +for each column. For offering quick browsing, vim-gist will truncate all +output exceeding the available horizontal space, assuring that every gist +listed only takes one line on the table. Although the gist id field width is +fixed internally, the user can define the length of the (file)name field on +the vim-gist listing. This can be done by the following declaration: + + let g:gist_namelength = 20 + +Note that the default value for gist_namelength is 30. Again, if the gist +(file)name exceeds the specified number of characters, it will be truncated. + +If you want to update a gist when only |:w!|: > + + " :w and :w! update a gist. + let g:gist_update_on_write = 1 + + " Only :w! updates a gist. + let g:gist_update_on_write = 2 +> +All other values are treated as 1. +This variable's value is 1 by default. + +============================================================================== +LICENSE *vim-gist-license* + + + Copyright 2010 by Yasuhiro Matsumoto + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + +============================================================================== +INSTALL *vim-gist-install* + +Copy following files into your plugin directory. + +rtp: + - autoload/gist.vim + - plugin/gist.vim + +If you want to uninstall gist.vim, remember to also remove `~/.vim-gist`. + +You need to install webapi-vim also: + + http://www.vim.org/scripts/script.php?script_id=4019 + +If you want to use latest one: + + https://github.com/mattn/webapi-vim + +============================================================================== +REQUIREMENTS *vim-gist-requirements* + + - curl command (http://curl.haxx.se/) + - webapi-vim (https://github.com/mattn/webapi-vim) + - and, if you want to use your git profile, the git command-line client. + +============================================================================== +SETUP *vim-gist-setup* + +This plugin uses GitHub API v3. The authentication value is stored in `~/.vim-gist`. +vim-gist provides two ways to authenticate against the GitHub APIs. + +First, you need to set your GitHub username in global git config: +> + $ git config --global github.user Username +< +Then, gist.vim will ask for your password to create an authorization when you +first use it. The password is not stored and only the OAuth access token will +be kept for later use. You can revoke the token at any time from the list of +"Authorized applications" on GitHub's "Account Settings" page. +(https://github.com/settings/applications) + +If you have two-factor authentication enabled on GitHub, you'll see the message +"Must specify two-factor authentication OTP code." In this case, you need to +create a "Personal Access Token" on GitHub's "Account Settings" page +(https://github.com/settings/applications) and place it in a file +named ~/.vim-gist like this: +> + token xxxxx +< +If you happen to have your password already written in ~/.gitconfig like +below: +> + [github] + password = xxxxx +< +Then, add following into your ~/.vimrc +> + let g:gist_use_password_in_gitconfig = 1 +< +This is not secure at all, so strongly discouraged. + +NOTE: the username is optional if you only send anonymous gists. + +============================================================================== +FAQ *vim-gist-faq* + +Q. :Gist returns a Forbidden error +A. Try deleting ~/.vim-gist and authenticating again. + +============================================================================== +THANKS *vim-gist-thanks* + + AD7six + Bruno Bigras + c9s + Daniel Bretoi + Jeremy Michael Cantrell + Kien N + kongo2002 + MATSUU Takuto + Matthew Weier O'Phinney + ornicar + Roland Schilter + steve + tyru + Will Gray + netj + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-gist/plugin/gist.vim b/sources_non_forked/vim-gist/plugin/gist.vim new file mode 100644 index 00000000..4d4efe67 --- /dev/null +++ b/sources_non_forked/vim-gist/plugin/gist.vim @@ -0,0 +1,23 @@ +"============================================================================= +" File: gist.vim +" Author: Yasuhiro Matsumoto +" WebPage: http://github.com/mattn/vim-gist +" License: BSD +" GetLatestVimScripts: 2423 1 :AutoInstall: gist.vim +" script type: plugin + +if &compatible || (exists('g:loaded_gist_vim') && g:loaded_gist_vim) + finish +endif +let g:loaded_gist_vim = 1 + +function! s:CompleteArgs(arg_lead,cmdline,cursor_pos) + return filter(copy(["-p", "-P", "-a", "-m", "-e", "-s", "-d", "+1", "-1", "-f", "-c", "-l", "-la", "-ls", "-b", + \ "--listall", "--liststar", "--list", "--multibuffer", "--private", "--public", "--anonymous", "--description", "--clipboard", + \ "--rawurl", "--delete", "--edit", "--star", "--unstar", "--fork", "--browser" + \ ]), 'stridx(v:val, a:arg_lead)==0') +endfunction + +command! -nargs=? -range=% -bang -complete=customlist,s:CompleteArgs Gist :call gist#Gist(, "", , , ) + +" vim:set et: diff --git a/sources_non_forked/vim-gitgutter/README.mkd b/sources_non_forked/vim-gitgutter/README.mkd index 0c21f3c1..9c5e48c2 100644 --- a/sources_non_forked/vim-gitgutter/README.mkd +++ b/sources_non_forked/vim-gitgutter/README.mkd @@ -1,9 +1,11 @@ ## vim-gitgutter -A Vim plugin which shows a git diff in the 'gutter' (sign column). It shows which lines have been added, modified, or removed. You can also preview, stage, and undo individual hunks; and stage partial hunks. The plugin also provides a hunk text object. +A Vim plugin which shows a git diff in the sign column. It shows which lines have been added, modified, or removed. You can also preview, stage, and undo individual hunks; and stage partial hunks. The plugin also provides a hunk text object. The signs are always up to date and the plugin never saves your buffer. +The name "gitgutter" comes from the Sublime Text 3 plugin which inspired this in 2013. + Features: * Shows signs for added, modified, and removed lines. @@ -33,6 +35,10 @@ Constraints: * Supports git only. If you work with other version control systems, I recommend [vim-signify](https://github.com/mhinz/vim-signify). * Relies on the `FocusGained` event. If your terminal doesn't report focus events, either use something like [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`. For tmux, `set -g focus-events on` in your tmux.conf. +Compatibility: + +Compatible back to Vim 7.4, and probably 7.3. + ### Screenshot @@ -88,6 +94,10 @@ You can jump between hunks with `[c` and `]c`. You can preview, stage, and undo You cannot unstage a staged hunk. +After updating the signs, the plugin fires the `GitGutter` User autocommand. + +After staging a hunk or part of a hunk, the plugin fires the `GitGutterStage` User autocommand. + #### Activation @@ -308,31 +318,20 @@ let g:gitgutter_sign_allow_clobber = 1 #### Signs' colours and symbols -By default vim-gitgutter uses your colourscheme's `Diff*` highlight groups' foreground colours for the signs' foreground colours. For example, your `DiffAdd` foreground colour will be used for the `+` sign's foreground colour. +If you or your colourscheme has defined `GitGutter*` highlight groups, the plugin will use those for the signs' colours. -The signs' background colours will all be set to the sign column's background colour. +Otherwise it will use your colourscheme's `Diff*` highlight groups. -If you don't like the default colours, you can either fix your colourscheme's `Diff*` highlights or configure your own `GitGutter*` highlight groups. These groups are: +Either way the signs' background colours will be set to the sign column's background colour. + +If you don't like the colours, specify the ones you want in your vimrc (see `:help highlight-guifg` and `:help highlight-ctermfg`). For example, to get vim-gitgutter's original colours (based on git-diff's colours in my terminal): ```viml -GitGutterAdd " an added line (default: links to DiffAdd) -GitGutterChange " a changed line (default: links to DiffChange) -GitGutterDelete " at least one removed line (default: links to DiffDelete) -GitGutterChangeDelete " a changed line followed by at least one removed line (default: links to GitGutterChange) +highlight GitGutterAdd guifg=#009900 ctermfg=2 +highlight GitGutterChange guifg=#bbbb00 ctermfg=3 +highlight GitGutterDelete guifg=#ff2222 ctermfg=1 ``` -You can either set these with `highlight GitGutterAdd {key}={arg}...` or link them to existing highlight groups with, say, `highlight link GitGutterAdd MyDiffAdd`. - -To get vim-gitgutter's original colours (based on git-diff's colours in my terminal): - -```viml -highlight GitGutterAdd guifg=#009900 guibg= ctermfg=2 ctermbg= -highlight GitGutterChange guifg=#bbbb00 guibg= ctermfg=3 ctermbg= -highlight GitGutterDelete guifg=#ff2222 guibg= ctermfg=1 ctermbg= -``` - -– where you would replace `` and `` with the background colour of your `SignColumn` in the gui and the terminal respectively. For example, with the solarized colorscheme and a dark background, `guibg=#073642` and `ctermbg=0`. - To customise the symbols, add the following to your `~/.vimrc`: ```viml @@ -399,6 +398,8 @@ By default buffers are diffed against the index. However you can diff against a let g:gitgutter_diff_base = '' ``` +If you are looking at a previous version of a file with Fugitive (e.g. via `:0Gclog`), gitgutter sets the diff base to the parent of the current revision. + This setting is ignored when the diffs are relative to the working tree. @@ -632,16 +633,6 @@ This plugin is for showing changes between the buffer and the index (and staging Your colorscheme is configuring the `SignColumn` highlight group weirdly. Please see the section above on customising the sign column. -> Why are the colours in the preview window weird? - -Probably because your colourscheme doesn't configure the `diff{Added,Changed,Removed}` highlight groups. Try this in `after/syntax/diff.vim`: - -```viml -highlight link diffAdded DiffAdd -highlight link diffChanged DiffChange -highlight link diffRemoved DiffDelete -``` - > What happens if I also use another plugin which uses signs (e.g. Syntastic)? You can configure whether GitGutter preserves or clobbers other signs using `g:gitgutter_sign_allow_clobber`. Set to `1` to clobber other signs (default on Vim >= 8.1.0614 and NeoVim >= 0.4.0) or `0` to preserve them. diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim index 582ea4b0..d56a8d9b 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim @@ -1,5 +1,3 @@ -let s:t_string = type('') - " Primary functions {{{ function! gitgutter#all(force) abort @@ -37,7 +35,7 @@ function! gitgutter#process_buffer(bufnr, force) abort if a:force || s:has_fresh_changes(a:bufnr) - let diff = '' + let diff = 'NOT SET' try let diff = gitgutter#diff#run_diff(a:bufnr, g:gitgutter_diff_relative_to, 0) catch /gitgutter not tracked/ @@ -47,7 +45,7 @@ function! gitgutter#process_buffer(bufnr, force) abort call gitgutter#hunk#reset(a:bufnr) endtry - if diff != 'async' + if diff != 'async' && diff != 'NOT SET' call gitgutter#diff#handler(a:bufnr, diff) endif @@ -156,11 +154,7 @@ function! gitgutter#setup_maps() endfunction function! s:setup_path(bufnr, continuation) - let p = gitgutter#utility#repo_path(a:bufnr, 0) - - if type(p) == s:t_string && !empty(p) " if path is known - return - endif + if gitgutter#utility#has_repo_path(a:bufnr) | return | endif return gitgutter#utility#set_repo_path(a:bufnr, a:continuation) endfunction @@ -188,7 +182,7 @@ endfunction function! gitgutter#quickfix() let locations = [] let cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager '.g:gitgutter_git_args. - \ ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args + \ ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args. ' '. g:gitgutter_diff_base let diff = systemlist(cmd) let lnum = 0 for line in diff diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim index be8a685f..04a0de97 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim @@ -1,3 +1,5 @@ +scriptencoding utf8 + let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '' : '' let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@' @@ -10,9 +12,6 @@ endfunction let s:c_flag = s:git_supports_command_line_config_override() - -let s:temp_from = tempname() -let s:temp_buffer = tempname() let s:counter = 0 " Returns a diff of the buffer against the index or the working tree. @@ -76,6 +75,9 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort throw 'gitgutter not tracked' endif + let temp_from = tempname() + let temp_buffer = tempname() + " Wrap compound commands in parentheses to make Windows happy. " bash doesn't mind the parentheses. let cmd = '(' @@ -88,7 +90,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort " second gitgutter#process_buffer() writing the file (synchronously, below) " and the first gitgutter#process_buffer()'s async job reading it (with " git-diff). - let buff_file = s:temp_buffer.'.'.a:bufnr + let buff_file = temp_buffer.'.'.a:bufnr " Add a counter to avoid a similar race with two quick writes of the same buffer. " Use a modulus greater than a maximum reasonable number of visible buffers. @@ -108,7 +110,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort " Without the buffer number, from_file would have a race in the shell " between the second process writing it (with git-show) and the first " reading it (with git-diff). - let from_file = s:temp_from.'.'.a:bufnr + let from_file = temp_from.'.'.a:bufnr " Add a counter to avoid a similar race with two quick writes of the same buffer. let from_file .= '.'.s:counter @@ -118,7 +120,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort endif " Write file from index to temporary file. - let index_name = g:gitgutter_diff_base.':'.gitgutter#utility#repo_path(a:bufnr, 1) + let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#repo_path(a:bufnr, 1) let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager show '.index_name.' > '.from_file.' && ' elseif a:from ==# 'working_tree' @@ -405,5 +407,3 @@ endfunction function! s:save_last_seen_change(bufnr) abort call gitgutter#utility#setbufvar(a:bufnr, 'tick', getbufvar(a:bufnr, 'changedtick')) endfunction - - diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/highlight.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/highlight.vim index e8ac1a25..da8ecbd0 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/highlight.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/highlight.vim @@ -84,6 +84,20 @@ function! gitgutter#highlight#define_highlights() abort highlight default link GitGutterChangeDeleteInvisible GitGutterChangeInvisible " When they are visible. + + " If GitGutter* highlights are already defined, either by the user or the colourscheme, + " set their backgrounds to the sign column's. + for type in ["Add", "Change", "Delete"] + if hlexists("GitGutter".type) + " Were the highlight self-contained we could just declare the + " background attributes and they would be merged. But it might be a + " link, in which case it would be overwritten. So re-declare it in its + " entirety. + let [guifg, ctermfg] = s:get_foreground_colors('GitGutter'.type) + execute "highlight GitGutter".type." guifg=".guifg." guibg=".guibg." ctermfg=".ctermfg." ctermbg=".ctermbg + endif + endfor + " By default use Diff* foreground colors with SignColumn's background. for type in ['Add', 'Change', 'Delete'] let [guifg, ctermfg] = s:get_foreground_colors('Diff'.type) @@ -107,6 +121,14 @@ function! gitgutter#highlight#define_highlights() abort " Highlights used intra line. highlight GitGutterAddIntraLine gui=reverse cterm=reverse highlight GitGutterDeleteIntraLine gui=reverse cterm=reverse + " Set diff syntax colours (used in the preview window) - diffAdded,diffChanged,diffRemoved - + " to match the signs, if not set aleady. + for [dtype,type] in [['Added','Add'], ['Changed','Change'], ['Removed','Delete']] + if !hlexists('diff'.dtype) + let [guifg, ctermfg] = s:get_foreground_colors('GitGutter'.type) + execute "highlight diff".dtype." guifg=".guifg." ctermfg=".ctermfg." guibg=NONE ctermbg=NONE" + endif + endfor endfunction function! gitgutter#highlight#define_signs() abort diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim index c51dd7a5..2404f087 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim @@ -1,4 +1,6 @@ let s:winid = 0 +let s:preview_bufnr = 0 +let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '' : '' function! gitgutter#hunk#set_hunks(bufnr, hunks) abort call gitgutter#utility#setbufvar(a:bufnr, 'hunks', a:hunks) @@ -172,6 +174,8 @@ endfunction function! gitgutter#hunk#stage(...) abort + if !s:in_hunk_preview_window() && !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + if a:0 && (a:1 != 1 || a:2 != line('$')) call s:hunk_op(function('s:stage'), a:1, a:2) else @@ -181,11 +185,15 @@ function! gitgutter#hunk#stage(...) abort endfunction function! gitgutter#hunk#undo() abort + if !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + call s:hunk_op(function('s:undo')) silent! call repeat#set("\(GitGutterUndoHunk)", -1) endfunction function! gitgutter#hunk#preview() abort + if !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + call s:hunk_op(function('s:preview')) silent! call repeat#set("\(GitGutterPreviewHunk)", -1) endfunction @@ -268,6 +276,10 @@ function! s:stage(hunk_diff) \ diff) if v:shell_error call gitgutter#utility#warn('patch does not apply') + else + if exists('#User#GitGutterStage') + execute 'doautocmd' s:nomodeline 'User GitGutterStage' + endif endif " Refresh gitgutter's view of buffer. @@ -430,7 +442,12 @@ function! s:open_hunk_preview_window() silent! wincmd P if !&previewwindow noautocmd execute g:gitgutter_preview_win_location &previewheight 'new gitgutter://hunk-preview' - let s:winid = win_getid() + doautocmd WinEnter + if exists('*win_getid') + let s:winid = win_getid() + else + let s:preview_bufnr = bufnr('') + endif set previewwindow setlocal filetype=diff buftype=acwrite bufhidden=delete " Reset some defaults in case someone else has changed them. @@ -499,18 +516,21 @@ endfunction function! s:enable_staging_from_hunk_preview_window() augroup gitgutter_hunk_preview autocmd! - execute 'autocmd BufWriteCmd GitGutterStageHunk' + let bufnr = s:winid != 0 ? winbufnr(s:winid) : s:preview_bufnr + execute 'autocmd BufWriteCmd GitGutterStageHunk' augroup END endfunction function! s:goto_original_window() noautocmd wincmd p + doautocmd WinEnter endfunction function! s:close_hunk_preview_window() - call setbufvar(winbufnr(s:winid), '&modified', 0) + let bufnr = s:winid != 0 ? winbufnr(s:winid) : s:preview_bufnr + call setbufvar(bufnr, '&modified', 0) if g:gitgutter_preview_win_floating if win_id2win(s:winid) > 0 @@ -521,4 +541,5 @@ function! s:close_hunk_preview_window() endif let s:winid = 0 + let s:preview_bufnr = 0 endfunction diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim index 3f533ba4..4151aea2 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim @@ -9,25 +9,19 @@ endfunction function! gitgutter#utility#setbufvar(buffer, varname, val) let buffer = +a:buffer " Default value for getbufvar() was introduced in Vim 7.3.831. - let bvars = getbufvar(buffer, '') - if empty(bvars) - let bvars = {} - endif - let dict = get(bvars, 'gitgutter', {}) - let needs_setting = empty(dict) - let dict[a:varname] = a:val - if needs_setting - call setbufvar(buffer, 'gitgutter', dict) + let ggvars = getbufvar(buffer, 'gitgutter') + if type(ggvars) == type('') + unlet ggvars + let ggvars = {} + call setbufvar(buffer, 'gitgutter', ggvars) endif + let ggvars[a:varname] = a:val endfunction function! gitgutter#utility#getbufvar(buffer, varname, ...) - let bvars = getbufvar(a:buffer, '') - if !empty(bvars) - let dict = get(bvars, 'gitgutter', {}) - if has_key(dict, a:varname) - return dict[a:varname] - endif + let ggvars = getbufvar(a:buffer, 'gitgutter') + if type(ggvars) == type({}) && has_key(ggvars, a:varname) + return ggvars[a:varname] endif if a:0 return a:1 @@ -105,6 +99,10 @@ function! gitgutter#utility#system(cmd, ...) abort return output endfunction +function! gitgutter#utility#has_repo_path(bufnr) + return index(['', -1, -2], gitgutter#utility#repo_path(a:bufnr, 0)) == -1 +endfunction + " Path of file relative to repo root. " " * empty string - not set @@ -112,7 +110,7 @@ endfunction " * -1 - pending " * -2 - not tracked by git function! gitgutter#utility#repo_path(bufnr, shellesc) abort - let p = gitgutter#utility#getbufvar(a:bufnr, 'path') + let p = gitgutter#utility#getbufvar(a:bufnr, 'path', '') return a:shellesc ? gitgutter#utility#shellescape(p) : p endfunction @@ -186,8 +184,21 @@ function! s:restore_shell() abort endif endfunction +function! gitgutter#utility#get_diff_base(bufnr) + let p = resolve(expand('#'.a:bufnr.':p')) + let ml = matchlist(p, '\v^fugitive:/.*/(\x{40,})/') + if !empty(ml) && !empty(ml[1]) + return ml[1].'^' + endif + return g:gitgutter_diff_base +endfunction + function! s:abs_path(bufnr, shellesc) let p = resolve(expand('#'.a:bufnr.':p')) + + " Remove extra parts from fugitive's filepaths + let p = substitute(substitute(p, '^fugitive:', '', ''), '\v\.git/\x{40,}/', '', '') + return a:shellesc ? gitgutter#utility#shellescape(p) : p endfunction diff --git a/sources_non_forked/vim-gitgutter/doc/gitgutter.txt b/sources_non_forked/vim-gitgutter/doc/gitgutter.txt index 1f52989f..e8f81789 100644 --- a/sources_non_forked/vim-gitgutter/doc/gitgutter.txt +++ b/sources_non_forked/vim-gitgutter/doc/gitgutter.txt @@ -1,7 +1,7 @@ *gitgutter.txt* A Vim plugin which shows a git diff in the gutter. - Vim Git Gutter + Vim GitGutter Author: Andy Stewart @@ -27,13 +27,16 @@ CONTENTS *gitgutter* =============================================================================== INTRODUCTION *gitgutter-introduction* -GitGutter is a Vim plugin which shows a git diff in the 'gutter' (sign column). +GitGutter is a Vim plugin which shows a git diff in the sign column. It shows which lines have been added, modified, or removed. You can also preview, stage, and undo individual hunks. The plugin also provides a hunk text object. The signs are always up to date and the plugin never saves your buffer. +The name "gitgutter" comes from the Sublime Text 3 plugin which inspired this +one in 2013. + =============================================================================== INSTALLATION *gitgutter-installation* @@ -177,7 +180,7 @@ Commands for folds:~ =============================================================================== -AUTOCOMMAND *gitgutter-autocommand* +AUTOCOMMANDS *gitgutter-autocommands* User GitGutter~ @@ -189,6 +192,10 @@ event GitGutter. You can listen for this event, for example: A dictionary `g:gitgutter_hook_context` is made available during its execution, which contains an entry `bufnr` that contains the buffer number being updated. +User GitGutterStage~ + +After staging a hunk or part of a hunk vim-gitgutter fires a |User| |autocmd| +with the event GitGutterStage. Staging always happens in the current buffer. =============================================================================== MAPPINGS *gitgutter-mappings* @@ -366,6 +373,9 @@ a revision instead. For example: let g:gitgutter_diff_base = '' < +If you are looking at a previous version of a file with Fugitive (e.g. +via :0Gclog), gitgutter sets the diff base to the parent of the current revision. + This setting is ignore when the diff is relative to the working tree (|g:gitgutter_diff_relative_to|). @@ -519,20 +529,14 @@ of the current window instead of the global quickfix list. =============================================================================== HIGHLIGHTS *gitgutter-highlights* -To change the signs' colours, set up the following highlight groups in your -colorscheme or |vimrc|: +To change the signs' colours, specify these highlight groups in your |vimrc|: > - GitGutterAdd " an added line - GitGutterChange " a changed line - GitGutterDelete " at least one removed line - GitGutterChangeDelete " a changed line followed by at least one removed line + highlight GitGutterAdd guifg=#009900 ctermfg=2 + highlight GitGutterChange guifg=#bbbb00 ctermfg=3 + highlight GitGutterDelete guifg=#ff2222 ctermfg=1 < -You can either set these with `highlight GitGutterAdd {key}={arg}...` or link -them to existing highlight groups with, say: -> - highlight link GitGutterAdd MyDiffAdd -< +See |highlight-guifg| and |highlight-ctermfg| for the values you can use. To change the line highlights, set up the following highlight groups in your colorscheme or |vimrc|: diff --git a/sources_non_forked/vim-javascript/syntax/javascript.vim b/sources_non_forked/vim-javascript/syntax/javascript.vim index 4d1a7e50..3b3689b2 100644 --- a/sources_non_forked/vim-javascript/syntax/javascript.vim +++ b/sources_non_forked/vim-javascript/syntax/javascript.vim @@ -184,7 +184,7 @@ syntax match jsClassNoise contained /\./ syntax match jsClassFuncName contained /\<\K\k*\ze\s*[(<]/ skipwhite skipempty nextgroup=jsFuncArgs,jsFlowClassFunctionGroup syntax match jsClassMethodType contained /\<\%([gs]et\|static\)\ze\s\+\K\k*/ skipwhite skipempty nextgroup=jsAsyncKeyword,jsClassFuncName,jsClassProperty syntax region jsClassDefinition start=/\/ end=/\(\\s\+\)\@ 3.4.0) rspec-expectations (~> 3.4.0) diff --git a/sources_non_forked/vim-multiple-cursors/README.md b/sources_non_forked/vim-multiple-cursors/README.md index 7a6eb479..43dcfee8 100644 --- a/sources_non_forked/vim-multiple-cursors/README.md +++ b/sources_non_forked/vim-multiple-cursors/README.md @@ -103,6 +103,9 @@ let g:multi_cursor_quit_key = '' ## Settings Currently there are four additional global settings one can tweak: +### ```g:multi_cursor_support_imap``` (Default: 1) +If set to 0, insert mappings won't be supported in _Insert_ mode anymore. + ### ```g:multi_cursor_exit_from_visual_mode``` (Default: 0) If set to 1, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will quit and delete all existing cursors, just skipping normal mode with multiple cursors. diff --git a/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim b/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim index c2739755..cdc8d978 100644 --- a/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim +++ b/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim @@ -1234,7 +1234,7 @@ function! s:wait_for_user_input(mode) " imap jj JJ " imap jjj JJJ " will always trigger the 'jj' mapping - if s:from_mode ==# 'i' && mapcheck(s:char, "i") != "" + if s:from_mode ==# 'i' && mapcheck(s:char, "i") != "" && g:multi_cursor_support_imap let map_dict = {} let s_time = s:get_time_in_ms() while 1 diff --git a/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt b/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt index a01b4ed0..ab86815b 100644 --- a/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt +++ b/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt @@ -94,6 +94,10 @@ otherwise you'll have a tough time quitting from multicursor mode. Currently there are four additional global settings one can tweak: +*g:multi_cursor_support_imap* (Default: 1) + +If set to 0, insert mappings won't be supported in |insert-mode| anymore. + *g:multi_cursor_exit_from_visual_mode* (Default: 0) If set to 0, then pressing |g:multi_cursor_quit_key| in |visual-mode| will quit diff --git a/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim b/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim index 0f6e41f4..e7f975a1 100644 --- a/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim +++ b/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim @@ -31,6 +31,7 @@ let s:settings = { \ 'exit_from_insert_mode': 0, \ 'use_default_mapping': 1, \ 'debug_latency': 0, + \ 'support_imap': 1, \ } let s:settings_if_default = { diff --git a/sources_non_forked/vim-python-pep8-indent/indent/python.vim b/sources_non_forked/vim-python-pep8-indent/indent/python.vim index aca216e7..047ae3d7 100644 --- a/sources_non_forked/vim-python-pep8-indent/indent/python.vim +++ b/sources_non_forked/vim-python-pep8-indent/indent/python.vim @@ -158,8 +158,8 @@ function! s:find_start_of_block(lnum, types, skip, multiple) abort else let re_skip = '' endif - let lnum = a:lnum - let last_indent = indent(lnum) + 1 + let last_indent = indent(a:lnum) + 1 + let lnum = a:lnum - 1 while lnum > 0 && last_indent > 0 let indent = indent(lnum) if indent < last_indent @@ -260,7 +260,7 @@ function! s:indent_like_block(lnum) endif let [blocks, skip] = blocks_ignore - let indents = s:find_start_of_block(a:lnum - 1, blocks, skip, multiple) + let indents = s:find_start_of_block(a:lnum, blocks, skip, multiple) if empty(indents) return -1 endif diff --git a/sources_non_forked/vim-python-pep8-indent/spec/indent/indent_spec.rb b/sources_non_forked/vim-python-pep8-indent/spec/indent/indent_spec.rb index 55e2fba4..745e939d 100644 --- a/sources_non_forked/vim-python-pep8-indent/spec/indent/indent_spec.rb +++ b/sources_non_forked/vim-python-pep8-indent/spec/indent/indent_spec.rb @@ -774,3 +774,23 @@ describe "elif after else" do indent.should == 4 end end + +describe "elif after two ifs" do + before { + vim.feedkeys '\ggdG' + } + + it "keeps its indent to the outer if" do + vim.feedkeys 'iif 1:\if 2:\pass\elif 3:\pass\' + indent.should == 4 + vim.feedkeys '\' + indent.should == 0 + proposed_indent.should == shiftwidth + vim.feedkeys 'ielif 4:' + indent.should == 0 + proposed_indent.should == 0 + vim.feedkeys '\' + indent.should == 4 + proposed_indent.should == 4 + end +end diff --git a/sources_non_forked/vim-ruby/autoload/rubycomplete.vim b/sources_non_forked/vim-ruby/autoload/rubycomplete.vim index c77884ad..8eff8003 100644 --- a/sources_non_forked/vim-ruby/autoload/rubycomplete.vim +++ b/sources_non_forked/vim-ruby/autoload/rubycomplete.vim @@ -500,13 +500,8 @@ class VimRubyCompletion return if rails_base == nil $:.push rails_base unless $:.index( rails_base ) - rails_config = rails_base + "config/" - rails_lib = rails_base + "lib/" - $:.push rails_config unless $:.index( rails_config ) - $:.push rails_lib unless $:.index( rails_lib ) - - bootfile = rails_config + "boot.rb" - envfile = rails_config + "environment.rb" + bootfile = rails_base + "config/boot.rb" + envfile = rails_base + "config/environment.rb" if File.exists?( bootfile ) && File.exists?( envfile ) begin require bootfile diff --git a/sources_non_forked/vim-ruby/ftplugin/ruby.vim b/sources_non_forked/vim-ruby/ftplugin/ruby.vim index 90a9bda8..81457288 100644 --- a/sources_non_forked/vim-ruby/ftplugin/ruby.vim +++ b/sources_non_forked/vim-ruby/ftplugin/ruby.vim @@ -111,7 +111,7 @@ else if !exists('g:ruby_default_path') if has("ruby") && has("win32") ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) ) - elseif executable('ruby') + elseif executable('ruby') && !empty($HOME) let g:ruby_default_path = s:query_path($HOME) else let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val') diff --git a/sources_non_forked/vim-ruby/spec/syntax/maxmempattern_limit_spec.rb b/sources_non_forked/vim-ruby/spec/syntax/maxmempattern_limit_spec.rb new file mode 100644 index 00000000..365ed63f --- /dev/null +++ b/sources_non_forked/vim-ruby/spec/syntax/maxmempattern_limit_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "Maxmempattern limit" do + specify "maxmempattern=1000 is enough even for long strings" do + str = <<~'EOF' + hash = { + "A-NOT-Managed-Strings" => "ABCDEfghe910dmckamks019292djdjOOOjjjd/cr3wdCA+1n/xHfHMgG+cC0EoUNngcBjgWvBMEF1CurBwTtDswJjQYa5wYRAQEBAQECCwGwAQEvI50CnwMNAwRrAQYBr9PPAoK7sQMBAQMCBAkICAQIAwEBAwYBAQQFFQEBAhQDAwMDCwEBAQUBAQHGAQEWBAEBDecBfS8CHQEKkAEMMxcMCQoUDwYHIjd3DQ4MFk0JWGYALSKLAQOLAYEBFBAjCBGDAQICAgMANjsZAg9fCxkCgLZKAwSEAQIBiwEZGAsrBCgFMmUEJShyFSfRBQEOSQY62AG0AVlCrQ", + } + EOF + assert_correct_highlighting str, %w[ABCDE], 'rubyString' + end +end diff --git a/sources_non_forked/vim-ruby/syntax/ruby.vim b/sources_non_forked/vim-ruby/syntax/ruby.vim index 563885ed..8f7a51c2 100644 --- a/sources_non_forked/vim-ruby/syntax/ruby.vim +++ b/sources_non_forked/vim-ruby/syntax/ruby.vim @@ -461,7 +461,7 @@ endif syn match rubyDefinedOperator "\%#=1\= 0 diff --git a/sources_non_forked/vim-snippets/UltiSnips/cs.snippets b/sources_non_forked/vim-snippets/UltiSnips/cs.snippets index 303fd209..4c58bcbe 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/cs.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/cs.snippets @@ -308,16 +308,29 @@ endsnippet # methods # ############# -snippet equals "Equals method" b -public override bool Equals(object obj) +snippet equals "Equality for a type" b +public override bool Equals(object obj) => Equals(obj as ${1:TYPE}); + +public bool Equals($1 other) // IEquatable<$1> { - if (obj == null || GetType() != obj.GetType()) - { + if (object.ReferenceEquals(other, null)) + return false; + if (object.ReferenceEquals(this, other)) + return true; + if (this.GetType() != other.GetType()) return false; - } $0 - return base.Equals(obj); + return base.Equals(other); } + +public override int GetHashCode() => base.GetHashCode(); + +public static bool operator ==($1 x, $1 y) => + (object.ReferenceEquals(x, null) && object.ReferenceEquals(y, null)) + || (!object.ReferenceEquals(x, null) && x.Equals(y)); + +public static bool operator !=($1 x, $1 y) => !(x == y); + endsnippet snippet mth "Method" b diff --git a/sources_non_forked/vim-snippets/UltiSnips/ejs.snippets b/sources_non_forked/vim-snippets/UltiSnips/ejs.snippets new file mode 100644 index 00000000..1e3c0044 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/ejs.snippets @@ -0,0 +1,10 @@ +snippet for "ejs for loop" b +<% for (let ${1:i = 0}; ${2:i + ${0:body} +<% } %> +endsnippet +snippet forE "ejs for Each loop" b +<% ${1:array}.forEach((${2:single var}) => { %> + ${0:body} +<% }) %> +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_react.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript_react.snippets new file mode 100644 index 00000000..d529c54c --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript_react.snippets @@ -0,0 +1,42 @@ +# Functional components +snippet rfc "react functional component" b +import React, {useState} from "react" + +function ${1:`!p snip.rv = snip.basename`}(${2}){ + return( +
+ ${3:

Body

} +
+ ) +} + +export default $4`!p snip.rv = snip.basename` +endsnippet +# React Hooks +snippet useS "useState Hook" b +const [${1}, set$1`!p snip.rv=t[1].title()`] = useState(${3:"${4}"}) +endsnippet +snippet useE "useEffect Hook" b +useEffect(() => { + ${1:${0}} + }${2}) +endsnippet +snippet useC "useContext Hook" b +const ${1:context} = useContext(${2}) +endsnippet +snippet useRe "useReducer Hook" b +const [${3:state}, ${4:dispatch}] = useReducer(${5:reducer}, ${2:initial_value}) +endsnippet +snippet useCB "useCallback(fn, inputs)" b +const ${1:callback} = useCallback((${2})) => ${3:{ + ${4} +}}, [${5}] +endsnippet +snippet useM "useMemo(fn, inputs)" b +const ${1:memorized} = useMemo(() => ${2:{ + ${3} +}}, [${4}]) +endsnippet +snippet useR "useRef(defaultValue)" b +const ${1:ref} = useRef(${2:null}) +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets b/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets index bc8664bb..b9962a10 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets @@ -96,6 +96,9 @@ snippet *** "bold italics" ***${1:${VISUAL}}***$0 endsnippet +snippet /* "Comment" +$0 +endsnippet ################ # Common stuff # @@ -131,6 +134,12 @@ snippet fnt "Footnote" [^$1]:${2:Text} endsnippet +snippet detail "Disclosure" + + ${1:summary>${2}}$0 + +endsnippet + post_jump "create_table(snip)" snippet "tb([1-9][1-9])" "Fancy table" br `!p snip.rv = match.group(1)` diff --git a/sources_non_forked/vim-snippets/UltiSnips/rust.snippets b/sources_non_forked/vim-snippets/UltiSnips/rust.snippets index fbf459d1..39dff8f0 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/rust.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/rust.snippets @@ -4,7 +4,7 @@ priority -50 -snippet fn "pub fn name(?) -> ? {}" +snippet fn "fn name(?) -> ? {}" fn ${1:function_name}($2)${3/..*/ -> /}$3 { ${VISUAL}$0 } diff --git a/sources_non_forked/vim-snippets/UltiSnips/svelte.snippets b/sources_non_forked/vim-snippets/UltiSnips/svelte.snippets new file mode 100644 index 00000000..4e09d0cc --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/svelte.snippets @@ -0,0 +1 @@ +extends html, javascript, css diff --git a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets index b5be4b74..0243b468 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets @@ -44,7 +44,7 @@ def add_row(snip): endglobal -snippet "b(egin)?" "begin{} / end{}" br +snippet "\\?b(egin)?" "begin{} / end{}" br \begin{${1:something}} ${0:${VISUAL}} \end{$1} diff --git a/sources_non_forked/vim-snippets/snippets/awk.snippets b/sources_non_forked/vim-snippets/snippets/awk.snippets index 5c94734a..64f61c0c 100644 --- a/sources_non_forked/vim-snippets/snippets/awk.snippets +++ b/sources_non_forked/vim-snippets/snippets/awk.snippets @@ -1,88 +1,70 @@ # cannot use /usr/bin/env because it does not support parameters (as -f) snippet #! #!/usr/bin/awk -f #!/usr/bin/awk -f - # @include is a gawk extension snippet inc @include @include "${1}"${0} - # @load is a gawk extension snippet loa @load @load "${1}"${0} - snippet beg BEGIN { ... } BEGIN { ${0} } - # BEGINFILE is a gawk extension snippet begf BEGINFILE { ... } BEGINFILE { ${0} } - snippet end END { ... } END { ${0} } - # ENDFILE is a gawk extension snippet endf ENDFILE { ... } ENDFILE { ${0} } - snippet pri print print ${1:"${2}"}${0} - snippet printf printf printf("${1:%s}\n", ${2})${0} - snippet ign IGNORECASE IGNORECASE = ${1:1} - snippet if if {...} if (${1}) { ${0:${VISUAL}} } - snippet ife if ... else ... if (${1}) { ${2:${VISUAL}} } else { ${0} } - snippet eif else if ... else if (${1}) { ${0} } - snippet el else {...} else { ${0} } - snippet wh while while (${1}) { ${2} } - snippet do do ... while do { ${0} } while (${1}) - snippet for for for (${2:i} = 0; i < ${1:n}; ${3:++i}) { ${0} } - snippet fore for each for (${1:i} in ${2:array}) { ${0} } - # the switch is a gawk extension snippet sw switch switch (${1}) { @@ -93,10 +75,8 @@ snippet sw switch ${0} break } - # the switch is a gawk extension snippet case case case ${1}: ${0} break - diff --git a/sources_non_forked/vim-snippets/snippets/c.snippets b/sources_non_forked/vim-snippets/snippets/c.snippets index 614a4882..5c084154 100644 --- a/sources_non_forked/vim-snippets/snippets/c.snippets +++ b/sources_non_forked/vim-snippets/snippets/c.snippets @@ -1,7 +1,7 @@ ## Main # main snippet main - int main(int argc, const char *argv[]) + int main(int argc, char *argv[]) { ${0} return 0; diff --git a/sources_non_forked/vim-snippets/snippets/dart-flutter.snippets b/sources_non_forked/vim-snippets/snippets/dart-flutter.snippets new file mode 100644 index 00000000..f3ded26a --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/dart-flutter.snippets @@ -0,0 +1,59 @@ +# Snippets for dart in flutter project, to use add the following to your .vimrc +# `autocmd BufRead,BufNewFile,BufEnter *.dart UltiSnipsAddFiletypes dart-flutter` +# Flutter stateless widget +snippet stless + class $1 extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } + +# Flutter stateful widget +snippet stful + class $1 extends StatefulWidget { + @override + _$1State createState() => _$1State(); + } + + class _$1State extends State<$1> { + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } + +# Flutter widget with AnimationController +snippet stanim + class $1 extends StatefulWidget { + @override + _$1State createState() => _$1State(); + } + + class _$1State extends State<$1> + with SingleTickerProviderStateMixin { + AnimationController _controller; + + @override + void initState() { + super.initState(); + _controller = AnimationController(vsync: this); + } + + @override + void dispose() { + super.dispose(); + _controller.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } diff --git a/sources_non_forked/vim-snippets/snippets/haskell.snippets b/sources_non_forked/vim-snippets/snippets/haskell.snippets index 3965f1da..585d3522 100644 --- a/sources_non_forked/vim-snippets/snippets/haskell.snippets +++ b/sources_non_forked/vim-snippets/snippets/haskell.snippets @@ -21,9 +21,9 @@ snippet info snippet imp import ${0:Data.Text} snippet import - import ${0:Data.Text} + import ${0:Data.Text} snippet import2 - import ${1:Data.Text} (${0:head}) + import ${1:Data.Text} (${0:head}) snippet impq import qualified ${1:Data.Text} as ${0:T} snippet importq diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets index 147e897f..c3d5a8b8 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets @@ -327,7 +327,9 @@ snippet => (${1}) => { ${0:${VISUAL}} } -snippet af +snippet af "() =>" + (${1}) => ${0:${VISUAL}} +snippet afb "() => {}" (${1}) => { ${0:${VISUAL}} } diff --git a/sources_non_forked/vim-snippets/snippets/julia.snippets b/sources_non_forked/vim-snippets/snippets/julia.snippets index 490d050d..1e0d3f2f 100644 --- a/sources_non_forked/vim-snippets/snippets/julia.snippets +++ b/sources_non_forked/vim-snippets/snippets/julia.snippets @@ -89,14 +89,26 @@ snippet thr throw ${0} # Messages -snippet in - info("${1}") - ${0} +snippet @i + @info "${1}" ${0} -snippet wa - warn("${1}") - ${0} +snippet @w + @warn "${1}" ${0} -snippet err - error("${1}") - ${0} +snippet @e + @error "${1}" ${0} + +snippet @d + @debug "${1}" ${0} + +snippet @t @testset with @test + @testset "${1}" begin + ${2} + @test ${0} + end + +snippet @tt @testset with @test_throws + @testset "${1}" begin + ${2} + @test_throws ${0} + end diff --git a/sources_non_forked/vim-snippets/snippets/liquid.snippets b/sources_non_forked/vim-snippets/snippets/liquid.snippets index 4f11f086..a39a0876 100644 --- a/sources_non_forked/vim-snippets/snippets/liquid.snippets +++ b/sources_non_forked/vim-snippets/snippets/liquid.snippets @@ -63,6 +63,10 @@ snippet include {% include '${0:snippet}' %} snippet includewith {% include '${1:snippet}', ${2:variable}: ${0:value} %} +snippet render + {% render '${0:snippet}' %} +snippet renderwith + {% render '${1:snippet}', ${2:variable}: ${0:value} %} snippet section {% section '${1:snippet}' %} snippet raw diff --git a/sources_non_forked/vim-snippets/snippets/markdown.snippets b/sources_non_forked/vim-snippets/snippets/markdown.snippets index 303271ed..b1aa3e14 100644 --- a/sources_non_forked/vim-snippets/snippets/markdown.snippets +++ b/sources_non_forked/vim-snippets/snippets/markdown.snippets @@ -129,6 +129,12 @@ snippet img snippet youtube {% youtube ${0:video_id} %} +snippet tb + | ${0:factors} | ${1:a} | ${2:b} | + | ------------- |------------- | ------- | + | ${3:f1} | Y | N | + | ${4:f2} | Y | N | + # The quote should appear only once in the text. It is inherently part of it. # See http://octopress.org/docs/plugins/pullquote/ for more info. diff --git a/sources_non_forked/vim-snippets/snippets/perl.snippets b/sources_non_forked/vim-snippets/snippets/perl.snippets index 2ed2932a..b318d18c 100644 --- a/sources_non_forked/vim-snippets/snippets/perl.snippets +++ b/sources_non_forked/vim-snippets/snippets/perl.snippets @@ -357,6 +357,10 @@ snippet dump use Data::Dump qw(dump); warn dump ${1:variable} +snippet ddp + use DDP; + p ${1:variable} + snippet subtest subtest '${1: test_name}' => sub { ${2} diff --git a/sources_non_forked/vim-snippets/snippets/python.snippets b/sources_non_forked/vim-snippets/snippets/python.snippets index 42832815..cd1224df 100644 --- a/sources_non_forked/vim-snippets/snippets/python.snippets +++ b/sources_non_forked/vim-snippets/snippets/python.snippets @@ -123,6 +123,8 @@ snippet ret return ${0} snippet . self. +snippet sa self.attribute = attribute + self.${1:attribute} = $1 snippet try Try/Except try: ${1:${VISUAL}} @@ -182,6 +184,10 @@ snippet ptpython # python console debugger (pudb) snippet pudb __import__('pudb').set_trace() +# python console debugger remote (pudb) +snippet pudbr + from pudb.remote import set_trace + set_trace() # pdb in nosetests snippet nosetrace __import__('nose').tools.set_trace() diff --git a/sources_non_forked/vim-snippets/snippets/r.snippets b/sources_non_forked/vim-snippets/snippets/r.snippets index 7bdeeec0..9dbe0f39 100644 --- a/sources_non_forked/vim-snippets/snippets/r.snippets +++ b/sources_non_forked/vim-snippets/snippets/r.snippets @@ -32,6 +32,10 @@ snippet for for (${1:item} in ${2:list}) { ${3} } +snippet foreach + foreach (${1:item} = ${2:list}) { + ${3} + } # functions snippet fun diff --git a/sources_non_forked/vim-snippets/snippets/rmd.snippets b/sources_non_forked/vim-snippets/snippets/rmd.snippets new file mode 100644 index 00000000..96b0ea0e --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/rmd.snippets @@ -0,0 +1,205 @@ +# +# Snipmate Snippets for Pandoc Markdown +# +# Many snippets have starred versions, i.e., versions +# that end with an asterisk (`*`). These snippets use +# vim's `"*` register---i.e., the contents of the +# system clipboard---to insert text. + +# Insert Title Block +snippet %% + % ${1:`Filename('', 'title')`} + % ${2:`g:snips_author`} + % ${3:`strftime("%d %B %Y")`} + + ${4} +snippet %%* + % ${1:`Filename('', @*)`} + % ${2:`g:snips_author`} + % ${3:`strftime("%d %b %Y")`} + + ${4} + +# Insert Definition List +snippet :: + ${1:term} + ~ ${2:definition} + +# Underline with `=`s or `-`s +snippet === + `repeat('=', strlen(getline(line(".") - 1)))` + + ${1} +snippet --- + `repeat('-', strlen(getline(line(".") - 1)))` + + ${1} + +# Links and their kin +# ------------------- +# +# (These don't play very well with delimitMate) +# + +snippet [ + [${1:link}](http://${2:url} "${3:title}")${4} +snippet [* + [${1:link}](${2:`@*`} "${3:title}")${4} + +snippet [: + [${1:id}]: http://${2:url} "${3:title}" +snippet [:* + [${1:id}]: ${2:`@*`} "${3:title}" + +snippet [@ + [${1:link}](mailto:${2:email})${3} +snippet [@* + [${1:link}](mailto:${2:`@*`})${3} + +snippet [:@ + [${1:id}]: mailto:${2:email} "${3:title}" +snippet [:@* + [${1:id}]: mailto:${2:`@*`} "${3:title}" + +snippet ![ + ![${1:alt}](${2:url} "${3:title}")${4} +snippet ![* + ![${1:alt}](${2:`@*`} "${3:title}")${4} + +snippet ![: + ![${1:id}]: ${2:url} "${3:title}" +snippet ![:* + ![${1:id}]: ${2:`@*`} "${3:title}" + +snippet [^: + [^${1:id}]: ${2:note} +snippet [^:* + [^${1:id}]: ${2:`@*`} + +# + +# library() +snippet req + require(${1:}, quietly = TRUE) +# If Condition +snippet if + if ( ${1:condition} ) + { + ${2:} + } +snippet el + else + { + ${1:} + } + +# Function +snippet fun + ${1:funname} <- # ${2:} + function + ( + ${3:} + ) + { + ${4:} + } +# repeat +snippet re + repeat{ + ${2:} + if(${1:condition}) break + } + +# matrix +snippet ma + matrix(NA, nrow = ${1:}, ncol = ${2:}) + +# data frame +snippet df + data.frame(${1:}, header = TRUE) + +snippet cmdarg + args <- commandArgs(TRUE) + if (length(args) == 0) + stop("Please give ${1:}!") + if (!all(file.exists(args))) + stop("Couln't find input files!") + +snippet getopt + require('getopt', quietly = TRUE) + opt_spec <- matrix(c( + 'help', 'h', 0, "logical", "Getting help", + 'file', 'f', 1, "character","File to process" + ), ncol = 5, byrow = TRUE) + opt <- getopt(spec = opt_spec) + if ( !is.null(opt$help) || is.null(commandArgs()) ) { + cat(getopt(spec = opt_spec, usage = TRUE, command = "yourCmd")) + q(status=0) + } + # some inital value + if ( is.null(opt$???) ) { opt$??? <- ??? } + +snippet optparse + require("optparse", quietly = TRUE) + option_list <- + list(make_option(c("-n", "--add_numbers"), action="store_true", default=FALSE, + help="Print line number at the beginning of each line [default]") + ) + parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) + arguments <- parse_args(parser, positional_arguments = TRUE) + opt <- arguments$options + + if(length(arguments$args) != 1) { + cat("Incorrect number of required positional arguments\n\n") + print_help(parser) + stop() + } else { + file <- arguments$args + } + + if( file.access(file) == -1) { + stop(sprintf("Specified file ( %s ) does not exist", file)) + } else { + file_text <- readLines(file) + } + +snippet #! + #!/usr/bin/env Rscript + +snippet debug + # Development & Debugging, don't forget to uncomment afterwards! + #-------------------------------------------------------------------------------- + #setwd("~/Projekte/${1:}") + #opt <- list(${2:} + # ) + #-------------------------------------------------------------------------------- + + +# Took from pandoc-plugin <<<< +# Underline with `=`s or `-`s +snippet #=== + #`repeat('=', strlen(getline(line(".") - 1)))` + ${1} +snippet #--- + #`repeat('-', strlen(getline(line(".") - 1)))` + ${1} + +# >>>> + +snippet r + \`\`\`{r ${1:chung_tag}, echo = FALSE ${2:options}} + ${3:} + \`\`\` +snippet ri + \`{r ${1:}}\` + +snippet copt + \`\`\` {r setup, echo = FALSE} + opts_chunk$set(fig.path='../figures/${1:}', cache.path='../cache/-' + , fig.align='center', fig.show='hold', par=TRUE) + #opts_knit$set(upload.fun = imgur_upload) # upload images + \`\`\` + + +# End of File =================================================================== +# vim: set noexpandtab: diff --git a/sources_non_forked/vim-snippets/snippets/svelte.snippets b/sources_non_forked/vim-snippets/snippets/svelte.snippets new file mode 100644 index 00000000..4e09d0cc --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/svelte.snippets @@ -0,0 +1 @@ +extends html, javascript, css diff --git a/sources_non_forked/vim-snippets/snippets/tex.snippets b/sources_non_forked/vim-snippets/snippets/tex.snippets index 0f8f9c03..c02d3401 100644 --- a/sources_non_forked/vim-snippets/snippets/tex.snippets +++ b/sources_non_forked/vim-snippets/snippets/tex.snippets @@ -289,7 +289,9 @@ snippet sum \sum^{}_{} snippet lim \lim_{} \\lim_{${1:n \\to \\infty}} ${0} snippet frame frame environment - \\begin{frame}[${1:t}]{${2:title}} + \\begin{frame}[${1:t}] + \frametitle{${2:title}} + \framesubtitle{${3:subtitle}} ${0:${VISUAL}} \\end{frame} snippet block block environment diff --git a/sources_non_forked/vim-snippets/snippets/vhdl.snippets b/sources_non_forked/vim-snippets/snippets/vhdl.snippets index f13f5bf9..7a991344 100644 --- a/sources_non_forked/vim-snippets/snippets/vhdl.snippets +++ b/sources_non_forked/vim-snippets/snippets/vhdl.snippets @@ -75,6 +75,16 @@ snippet prc ${2} end if; end process; +# process with clock and reset +snippet prcr + process (${1:clk}, ${2:nrst}) + begin + if ($2 = '${3:0}') then + ${4} + elsif rising_edge($1) then + ${5} + end if; + end process; # process all snippet pra process (${1:all})