From 72bdaba47e1cba1744bd5314cf5995cb22d0a0be Mon Sep 17 00:00:00 2001 From: Amir Salihefendic Date: Sat, 16 Nov 2019 16:28:42 +0100 Subject: [PATCH] Updated plugins --- .../ale/ale_linters/c/clangd.vim | 7 +- .../ale/ale_linters/c/clangtidy.vim | 13 +- .../ale/ale_linters/cpp/clangcheck.vim | 2 +- .../ale/ale_linters/cpp/clangd.vim | 7 +- .../ale/ale_linters/cpp/clangtidy.vim | 13 +- .../ale/ale_linters/crystal/crystal.vim | 4 + .../ale/ale_linters/elm/elm_ls.vim | 11 +- .../ale/ale_linters/erlang/dialyzer.vim | 4 +- .../ale/ale_linters/eruby/ruumba.vim | 2 +- sources_non_forked/ale/ale_linters/ink/ls.vim | 35 + .../ale/ale_linters/javascript/standard.vim | 2 + .../ale/ale_linters/markdown/mdl.vim | 11 +- .../ale/ale_linters/nim/nimcheck.vim | 14 + .../ale/ale_linters/nim/nimlsp.vim | 33 + .../ale/ale_linters/php/psalm.vim | 11 +- .../ale/ale_linters/powershell/powershell.vim | 1 + .../ale/ale_linters/ruby/brakeman.vim | 2 +- .../ale/ale_linters/ruby/debride.vim | 42 + .../ale_linters/ruby/rails_best_practices.vim | 2 +- .../ale/ale_linters/ruby/reek.vim | 2 +- .../ale/ale_linters/ruby/rubocop.vim | 2 +- .../ale/ale_linters/ruby/sorbet.vim | 2 +- .../ale/ale_linters/ruby/standardrb.vim | 2 +- .../ale/ale_linters/scala/metals.vim | 48 + .../ale/ale_linters/sh/shell.vim | 4 +- .../ale/ale_linters/solidity/solc.vim | 35 + .../ale/ale_linters/terraform/tflint.vim | 76 +- .../ale/ale_linters/typescript/standard.vim | 31 + .../ale/ale_linters/verilog/vlog.vim | 14 + sources_non_forked/ale/autoload/ale.vim | 9 +- .../ale/autoload/ale/assert.vim | 14 +- sources_non_forked/ale/autoload/ale/c.vim | 18 +- .../ale/autoload/ale/code_action.vim | 163 ++++ .../ale/autoload/ale/completion.vim | 238 +++-- .../ale/autoload/ale/debugging.vim | 1 + sources_non_forked/ale/autoload/ale/fix.vim | 4 +- .../ale/autoload/ale/fix/registry.vim | 32 +- .../ale/autoload/ale/fixers/dfmt.vim | 18 + .../ale/autoload/ale/fixers/html_beautify.vim | 21 + .../ale/autoload/ale/fixers/nimpretty.vim | 15 + .../ale/autoload/ale/fixers/nixpkgsfmt.vim | 12 + .../ale/autoload/ale/fixers/purty.vim | 22 + .../ale/autoload/ale/fixers/rubocop.vim | 2 +- .../ale/autoload/ale/fixers/sorbet.vim | 2 +- .../ale/autoload/ale/fixers/sqlformat.vim | 16 + .../ale/autoload/ale/fixers/standard.vim | 10 +- .../ale/autoload/ale/fixers/standardrb.vim | 2 +- .../ale/autoload/ale/fixers/stylelint.vim | 9 +- .../ale/autoload/ale/fixers/styler.vim | 4 +- .../autoload/ale/handlers/languagetool.vim | 5 +- .../ale/autoload/ale/handlers/ruby.vim | 8 - .../ale/autoload/ale/highlight.vim | 71 +- .../ale/autoload/ale/linter.vim | 3 + sources_non_forked/ale/autoload/ale/lsp.vim | 6 + .../ale/autoload/ale/lsp/message.vim | 10 + .../ale/autoload/ale/lsp/tsserver_message.vim | 28 +- .../ale/autoload/ale/lsp_linter.vim | 6 + .../ale/autoload/ale/lsp_window.vim | 58 ++ .../ale/autoload/ale/organize_imports.vim | 59 ++ sources_non_forked/ale/autoload/ale/path.vim | 4 +- .../ale/autoload/ale/rename.vim | 225 +++++ sources_non_forked/ale/autoload/ale/ruby.vim | 7 + sources_non_forked/ale/autoload/ale/sign.vim | 76 +- sources_non_forked/ale/autoload/ale/util.vim | 3 + sources_non_forked/ale/doc/ale-cs.txt | 23 +- sources_non_forked/ale/doc/ale-d.txt | 9 + .../ale/doc/ale-development.txt | 11 +- sources_non_forked/ale/doc/ale-elm.txt | 14 +- sources_non_forked/ale/doc/ale-html.txt | 10 + sources_non_forked/ale/doc/ale-ink.txt | 40 + sources_non_forked/ale/doc/ale-nim.txt | 45 + sources_non_forked/ale/doc/ale-nix.txt | 24 + sources_non_forked/ale/doc/ale-php.txt | 11 +- sources_non_forked/ale/doc/ale-purescript.txt | 9 + sources_non_forked/ale/doc/ale-ruby.txt | 26 +- sources_non_forked/ale/doc/ale-scala.txt | 26 + sources_non_forked/ale/doc/ale-solidity.txt | 12 + sources_non_forked/ale/doc/ale-sql.txt | 18 + .../doc/ale-supported-languages-and-tools.txt | 15 +- sources_non_forked/ale/doc/ale-typescript.txt | 27 + sources_non_forked/ale/doc/ale.txt | 275 +++++- sources_non_forked/ale/plugin/ale.vim | 7 + sources_non_forked/ale/supported-tools.md | 23 +- .../ctrlp.vim/autoload/ctrlp.vim | 92 +- sources_non_forked/ctrlp.vim/doc/ctrlp.cnx | 2 +- sources_non_forked/ctrlp.vim/doc/ctrlp.txt | 2 +- sources_non_forked/lightline.vim/README.md | 11 +- .../autoload/lightline/colorscheme.vim | 4 +- .../autoload/lightline/colorscheme/one.vim | 40 +- .../lightline/colorscheme/simpleblack.vim | 43 + .../lightline.vim/colorscheme.md | 113 +++ .../nerdtree/.github/PULL_REQUEST_TEMPLATE.md | 13 +- sources_non_forked/nerdtree/CHANGELOG.md | 39 +- sources_non_forked/nerdtree/README.markdown | 101 ++- .../nerdtree/autoload/nerdtree.vim | 30 +- .../nerdtree/autoload/nerdtree/ui_glue.vim | 4 + sources_non_forked/nerdtree/doc/NERDTree.txt | 16 +- .../nerdtree/lib/nerdtree/menu_controller.vim | 3 +- .../nerdtree/lib/nerdtree/nerdtree.vim | 13 +- .../nerdtree/lib/nerdtree/opener.vim | 54 +- .../nerdtree/lib/nerdtree/path.vim | 9 +- .../nerdtree/lib/nerdtree/tree_dir_node.vim | 3 +- .../nerdtree/lib/nerdtree/tree_file_node.vim | 6 + .../nerdtree/lib/nerdtree/ui.vim | 13 +- .../nerdtree/nerdtree_plugin/fs_menu.vim | 6 +- .../nerdtree/plugin/NERD_tree.vim | 11 +- .../vim-abolish/.github/FUNDING.yml | 2 + .../vim-abolish/plugin/abolish.vim | 5 +- .../vim-bundle-mako/ftplugin/mako.vim | 12 +- .../vim-commentary/.github/FUNDING.yml | 2 + .../vim-commentary/doc/commentary.txt | 3 + .../vim-commentary/plugin/commentary.vim | 8 +- .../vim-fugitive/autoload/fugitive.vim | 846 ++++++++++-------- .../vim-fugitive/doc/fugitive.txt | 370 ++++---- .../vim-fugitive/plugin/fugitive.vim | 153 +++- sources_non_forked/vim-gitgutter/README.mkd | 147 +-- .../vim-gitgutter/autoload/gitgutter.vim | 72 +- .../vim-gitgutter/autoload/gitgutter/diff.vim | 8 +- .../autoload/gitgutter/diff_highlight.vim | 225 +++++ .../vim-gitgutter/autoload/gitgutter/fold.vim | 31 + .../autoload/gitgutter/highlight.vim | 21 +- .../vim-gitgutter/autoload/gitgutter/hunk.vim | 194 +++- .../vim-gitgutter/autoload/gitgutter/sign.vim | 4 +- .../vim-gitgutter/doc/gitgutter.txt | 96 +- .../vim-gitgutter/plugin/gitgutter.vim | 40 +- .../vim-gitgutter/screenshot.png | Bin 16191 -> 601382 bytes .../vim-gitgutter/test/fixture_dos.txt | 11 + .../vim-gitgutter/test/test_gitgutter.vim | 250 +++++- sources_non_forked/vim-go/.travis.yml | 7 +- sources_non_forked/vim-go/CHANGELOG.md | 106 ++- sources_non_forked/vim-go/Dockerfile | 3 +- sources_non_forked/vim-go/Makefile | 2 +- sources_non_forked/vim-go/README.md | 3 +- .../vim-go/autoload/fzf/decls.vim | 8 +- .../vim-go/autoload/go/auto.vim | 64 +- sources_non_forked/vim-go/autoload/go/cmd.vim | 73 +- .../vim-go/autoload/go/complete.vim | 11 +- .../vim-go/autoload/go/complete_test.vim | 13 +- .../vim-go/autoload/go/config.vim | 47 +- .../vim-go/autoload/go/config_test.vim | 86 ++ .../vim-go/autoload/go/coverage.vim | 6 +- .../vim-go/autoload/go/debug.vim | 201 ++++- .../vim-go/autoload/go/debug_test.vim | 5 +- sources_non_forked/vim-go/autoload/go/def.vim | 14 +- sources_non_forked/vim-go/autoload/go/doc.vim | 50 +- .../vim-go/autoload/go/fillstruct_test.vim | 2 +- sources_non_forked/vim-go/autoload/go/fmt.vim | 16 +- .../vim-go/autoload/go/guru.vim | 86 +- .../vim-go/autoload/go/highlight_test.vim | 40 + sources_non_forked/vim-go/autoload/go/job.vim | 13 +- .../vim-go/autoload/go/job_test.vim | 53 ++ .../vim-go/autoload/go/lint.vim | 65 +- .../vim-go/autoload/go/lint_test.vim | 39 +- .../vim-go/autoload/go/list.vim | 11 +- sources_non_forked/vim-go/autoload/go/lsp.vim | 239 ++++- .../vim-go/autoload/go/lsp/message.vim | 20 + .../vim-go/autoload/go/lsp_test.vim | 2 +- sources_non_forked/vim-go/autoload/go/mod.vim | 15 +- .../vim-go/autoload/go/package.vim | 2 +- .../vim-go/autoload/go/path.vim | 4 +- .../vim-go/autoload/go/play.vim | 7 +- .../vim-go/autoload/go/rename.vim | 17 +- .../vim-go/autoload/go/term.vim | 8 +- .../config/buildtags/buildtags.go | 5 + .../config/buildtags/constrainedfoo.go | 8 + .../go/test-fixtures/config/buildtags/foo.go | 7 + .../go/test-fixtures/config/buildtags/go.mod | 3 + .../test-fixtures/job/dir has spaces/main.go | 6 + .../src/vet/compilererror/compilererror.go | 7 + .../vim-go/autoload/go/util.vim | 53 +- sources_non_forked/vim-go/compiler/go.vim | 15 +- sources_non_forked/vim-go/doc/vim-go.txt | 166 +++- sources_non_forked/vim-go/ftplugin/go.vim | 9 +- sources_non_forked/vim-go/plugin/go.vim | 89 +- .../vim-go/scripts/bench-syntax | 2 +- sources_non_forked/vim-go/scripts/install-vim | 11 +- sources_non_forked/vim-go/scripts/lint | 2 +- sources_non_forked/vim-go/scripts/run-vim | 2 +- sources_non_forked/vim-go/scripts/runtest.vim | 6 +- sources_non_forked/vim-go/scripts/test | 2 +- sources_non_forked/vim-go/syntax/go.vim | 19 +- sources_non_forked/vim-go/syntax/gomod.vim | 9 +- .../vim-multiple-cursors/README.md | 4 + .../doc/multiple_cursors.txt | 4 + sources_non_forked/vim-pug/syntax/pug.vim | 3 +- .../vim-repeat/.github/FUNDING.yml | 2 + .../vim-snippets/UltiSnips/all.snippets | 15 +- .../vim-snippets/UltiSnips/markdown.snippets | 65 +- .../vim-snippets/UltiSnips/python.snippets | 4 +- .../vim-snippets/UltiSnips/rst.snippets | 109 +-- .../vim-snippets/pythonx/vimsnippets.py | 52 +- .../vim-snippets/snippets/css.snippets | 2 +- .../vim-snippets/snippets/freemarker.snippets | 77 +- .../vim-snippets/snippets/go.snippets | 17 + .../snippets/javascript/javascript.snippets | 5 +- .../vim-snippets/snippets/puppet.snippets | 8 +- .../vim-snippets/snippets/rst.snippets | 43 +- .../vim-snippets/snippets/rust.snippets | 4 + .../vim-snippets/snippets/sass.snippets | 2 +- .../vim-snippets/snippets/tex.snippets | 4 + .../vim-snippets/snippets/typescript.snippets | 42 + .../vim-snippets/snippets/vim.snippets | 2 + .../vim-snippets/snippets/vue.snippets | 11 + .../vim-surround/.github/FUNDING.yml | 2 + 204 files changed, 5936 insertions(+), 1666 deletions(-) create mode 100644 sources_non_forked/ale/ale_linters/ink/ls.vim create mode 100644 sources_non_forked/ale/ale_linters/nim/nimlsp.vim create mode 100644 sources_non_forked/ale/ale_linters/ruby/debride.vim create mode 100644 sources_non_forked/ale/ale_linters/scala/metals.vim create mode 100644 sources_non_forked/ale/ale_linters/solidity/solc.vim create mode 100644 sources_non_forked/ale/ale_linters/typescript/standard.vim create mode 100644 sources_non_forked/ale/autoload/ale/code_action.vim create mode 100644 sources_non_forked/ale/autoload/ale/fixers/dfmt.vim create mode 100644 sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim create mode 100644 sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim create mode 100644 sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim create mode 100644 sources_non_forked/ale/autoload/ale/fixers/purty.vim create mode 100644 sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim create mode 100644 sources_non_forked/ale/autoload/ale/lsp_window.vim create mode 100644 sources_non_forked/ale/autoload/ale/organize_imports.vim create mode 100644 sources_non_forked/ale/autoload/ale/rename.vim create mode 100644 sources_non_forked/ale/doc/ale-ink.txt create mode 100644 sources_non_forked/ale/doc/ale-nim.txt create mode 100644 sources_non_forked/ale/doc/ale-nix.txt create mode 100644 sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim create mode 100644 sources_non_forked/lightline.vim/colorscheme.md create mode 100644 sources_non_forked/vim-abolish/.github/FUNDING.yml create mode 100644 sources_non_forked/vim-commentary/.github/FUNDING.yml create mode 100644 sources_non_forked/vim-gitgutter/autoload/gitgutter/diff_highlight.vim create mode 100644 sources_non_forked/vim-gitgutter/test/fixture_dos.txt create mode 100644 sources_non_forked/vim-go/autoload/go/config_test.vim create mode 100644 sources_non_forked/vim-go/autoload/go/job_test.vim create mode 100644 sources_non_forked/vim-go/autoload/go/test-fixtures/config/buildtags/buildtags.go create mode 100644 sources_non_forked/vim-go/autoload/go/test-fixtures/config/buildtags/constrainedfoo.go create mode 100644 sources_non_forked/vim-go/autoload/go/test-fixtures/config/buildtags/foo.go create mode 100644 sources_non_forked/vim-go/autoload/go/test-fixtures/config/buildtags/go.mod create mode 100644 sources_non_forked/vim-go/autoload/go/test-fixtures/job/dir has spaces/main.go create mode 100644 sources_non_forked/vim-go/autoload/go/test-fixtures/lint/src/vet/compilererror/compilererror.go create mode 100644 sources_non_forked/vim-repeat/.github/FUNDING.yml create mode 100644 sources_non_forked/vim-surround/.github/FUNDING.yml diff --git a/sources_non_forked/ale/ale_linters/c/clangd.vim b/sources_non_forked/ale/ale_linters/c/clangd.vim index 79b600fa..c42d4497 100644 --- a/sources_non_forked/ale/ale_linters/c/clangd.vim +++ b/sources_non_forked/ale/ale_linters/c/clangd.vim @@ -3,9 +3,14 @@ call ale#Set('c_clangd_executable', 'clangd') call ale#Set('c_clangd_options', '') +call ale#Set('c_build_dir', '') function! ale_linters#c#clangd#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') endfunction call ale#linter#Define('c', { diff --git a/sources_non_forked/ale/ale_linters/c/clangtidy.vim b/sources_non_forked/ale/ale_linters/c/clangtidy.vim index f998866a..553cc23b 100644 --- a/sources_non_forked/ale/ale_linters/c/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/c/clangtidy.vim @@ -19,14 +19,17 @@ call ale#Set('c_clangtidy_options', '') call ale#Set('c_clangtidy_extra_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#c#clangtidy#GetCommand(buffer) abort +function! ale_linters#c#clangtidy#GetCommand(buffer, output) abort let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',') let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = '' " Get the extra options if we couldn't find a build directory. - let l:options = empty(l:build_dir) - \ ? ale#Var(a:buffer, 'c_clangtidy_options') - \ : '' + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'c_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + endif " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options') @@ -43,7 +46,7 @@ call ale#linter#Define('c', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')}, -\ 'command': function('ale_linters#c#clangtidy#GetCommand'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clangtidy#GetCommand'))}, \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim index 7d32a57c..4cb04864 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim @@ -20,7 +20,7 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort " being generated. These are only added if no build directory can be " detected. return '%e -analyze %s' - \ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '') + \ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '') \ . ale#Pad(l:user_options) \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') endfunction diff --git a/sources_non_forked/ale/ale_linters/cpp/clangd.vim b/sources_non_forked/ale/ale_linters/cpp/clangd.vim index fab605f4..14f3fe55 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangd.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangd.vim @@ -3,9 +3,14 @@ call ale#Set('cpp_clangd_executable', 'clangd') call ale#Set('cpp_clangd_options', '') +call ale#Set('c_build_dir', '') function! ale_linters#cpp#clangd#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options')) + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') endfunction call ale#linter#Define('cpp', { diff --git a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim index 085bc332..191b7b07 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim @@ -13,14 +13,17 @@ call ale#Set('cpp_clangtidy_options', '') call ale#Set('cpp_clangtidy_extra_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort +function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',') let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = '' " Get the extra options if we couldn't find a build directory. - let l:options = empty(l:build_dir) - \ ? ale#Var(a:buffer, 'cpp_clangtidy_options') - \ : '' + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + endif " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options') @@ -37,7 +40,7 @@ call ale#linter#Define('cpp', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'cpp_clangtidy_executable')}, -\ 'command': function('ale_linters#cpp#clangtidy#GetCommand'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clangtidy#GetCommand'))}, \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/crystal/crystal.vim b/sources_non_forked/ale/ale_linters/crystal/crystal.vim index 3c2fefb7..8a905b12 100644 --- a/sources_non_forked/ale/ale_linters/crystal/crystal.vim +++ b/sources_non_forked/ale/ale_linters/crystal/crystal.vim @@ -5,6 +5,10 @@ function! ale_linters#crystal#crystal#Handle(buffer, lines) abort let l:output = [] for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + if !has_key(l:error, 'file') + continue + endif + call add(l:output, { \ 'lnum': l:error.line + 0, \ 'col': l:error.column + 0, diff --git a/sources_non_forked/ale/ale_linters/elm/elm_ls.vim b/sources_non_forked/ale/ale_linters/elm/elm_ls.vim index 374ef8de..2fa71adb 100644 --- a/sources_non_forked/ale/ale_linters/elm/elm_ls.vim +++ b/sources_non_forked/ale/ale_linters/elm/elm_ls.vim @@ -3,9 +3,12 @@ call ale#Set('elm_ls_executable', 'elm-language-server') call ale#Set('elm_ls_use_global', get(g:, 'ale_use_global_executables', 1)) -call ale#Set('elm_ls_elm_path', 'elm') -call ale#Set('elm_ls_elm_format_path', 'elm-format') -call ale#Set('elm_ls_elm_test_path', 'elm-test') + +" elm-language-server will search for local and global binaries, if empty +call ale#Set('elm_ls_elm_path', '') +call ale#Set('elm_ls_elm_format_path', '') +call ale#Set('elm_ls_elm_test_path', '') +call ale#Set('elm_ls_elm_analyse_trigger', 'change') function! elm_ls#GetRootDir(buffer) abort let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') @@ -15,10 +18,10 @@ endfunction function! elm_ls#GetOptions(buffer) abort return { - \ 'runtime': 'node', \ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'), \ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'), \ 'elmTestPath': ale#Var(a:buffer, 'elm_ls_elm_test_path'), + \ 'elmAnalyseTrigger': ale#Var(a:buffer, 'elm_ls_elm_analyse_trigger'), \} endfunction diff --git a/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim b/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim index 7af64c4f..395647a0 100644 --- a/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim +++ b/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim @@ -15,10 +15,10 @@ endfunction function! ale_linters#erlang#dialyzer#FindPlt(buffer) abort let l:plt_file = '' let l:rebar3_profile = ale_linters#erlang#dialyzer#GetRebar3Profile(a:buffer) - let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build' . l:rebar3_profile) + let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build/' . l:rebar3_profile) if !empty(l:plt_file_directory) - let l:plt_file = split(globpath(l:plt_file_directory, '/*_plt'), '\n') + let l:plt_file = globpath(l:plt_file_directory, '*_plt', 0, 1) endif if !empty(l:plt_file) diff --git a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim index e68bb51d..2e84acf7 100644 --- a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim +++ b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim @@ -8,7 +8,7 @@ call ale#Set('eruby_ruumba_options', '') function! ale_linters#eruby#ruumba#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'eruby_ruumba_executable') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'ruumba') + return ale#ruby#EscapeExecutable(l:executable, 'ruumba') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'eruby_ruumba_options') \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) diff --git a/sources_non_forked/ale/ale_linters/ink/ls.vim b/sources_non_forked/ale/ale_linters/ink/ls.vim new file mode 100644 index 00000000..1cc93583 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ink/ls.vim @@ -0,0 +1,35 @@ +" Author: Andreww Hayworth +" Description: Integrate ALE with ink-language-server + +call ale#Set('ink_ls_executable', 'ink-language-server') +call ale#Set('ink_ls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('ink_ls_initialization_options', {}) + +function! ale_linters#ink#ls#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'ink_ls', [ + \ 'ink-language-server', + \ 'node_modules/.bin/ink-language-server', + \]) +endfunction + +function! ale_linters#ink#ls#GetCommand(buffer) abort + let l:executable = ale_linters#ink#ls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +function! ale_linters#ink#ls#FindProjectRoot(buffer) abort + let l:main_file = get(ale#Var(a:buffer, 'ink_ls_initialization_options'), 'mainStoryPath', 'main.ink') + let l:config = ale#path#ResolveLocalPath(a:buffer, l:main_file, expand('#' . a:buffer . ':p')) + + return ale#path#Dirname(l:config) +endfunction + +call ale#linter#Define('ink', { +\ 'name': 'ink-language-server', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#ink#ls#GetExecutable'), +\ 'command': function('ale_linters#ink#ls#GetCommand'), +\ 'project_root': function('ale_linters#ink#ls#FindProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'ink_ls_initialization_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/standard.vim b/sources_non_forked/ale/ale_linters/javascript/standard.vim index 4cd2c303..1990adce 100644 --- a/sources_non_forked/ale/ale_linters/javascript/standard.vim +++ b/sources_non_forked/ale/ale_linters/javascript/standard.vim @@ -7,7 +7,9 @@ call ale#Set('javascript_standard_options', '') function! ale_linters#javascript#standard#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/semistandard/bin/cmd.js', \ 'node_modules/.bin/standard', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/markdown/mdl.vim b/sources_non_forked/ale/ale_linters/markdown/mdl.vim index 305f5359..fd44de6e 100644 --- a/sources_non_forked/ale/ale_linters/markdown/mdl.vim +++ b/sources_non_forked/ale/ale_linters/markdown/mdl.vim @@ -17,18 +17,17 @@ function! ale_linters#markdown#mdl#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'markdown_mdl_options') return ale#Escape(l:executable) . l:exec_args - \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -j' . (!empty(l:options) ? ' ' . l:options : '') endfunction function! ale_linters#markdown#mdl#Handle(buffer, lines) abort - " matches: '(stdin):173: MD004 Unordered list style' - let l:pattern = ':\(\d*\): \(.*\)$' let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'text': l:match[2], + \ 'lnum': l:error['line'], + \ 'code': l:error['rule'] . '/' . join(l:error['aliases'], '/'), + \ 'text': l:error['description'], \ 'type': 'W', \}) endfor diff --git a/sources_non_forked/ale/ale_linters/nim/nimcheck.vim b/sources_non_forked/ale/ale_linters/nim/nimcheck.vim index b5796dcd..b739ca04 100644 --- a/sources_non_forked/ale/ale_linters/nim/nimcheck.vim +++ b/sources_non_forked/ale/ale_linters/nim/nimcheck.vim @@ -1,6 +1,15 @@ " Author: Baabelfish " Description: Typechecking for nim files +let s:end_col_patterns = [ +\ '\v''([^'']+)'' is declared but not used.*', +\ '\videntifier expected, but found ''([^'']+)''', +\ '\vimported and not used: ''([^'']+)''.*', +\ '\vundeclared identifier: ''([^'']+)''', +\ '\v''([^'']+)'' cannot be assigned to', +\ '\vredefinition of ''([^'']+)'';', +\] + function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p:t') let l:pattern = '^\(.\+\.nim\)(\(\d\+\), \(\d\+\)) \(.\+\)' @@ -43,6 +52,11 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort let l:item.code = l:code_match[2] endif + " Find position end_col. + for l:col_match in ale#util#GetMatches(l:item.text, s:end_col_patterns) + let l:item.end_col = l:item.col + len(l:col_match[1]) - 1 + endfor + call add(l:output, l:item) endfor diff --git a/sources_non_forked/ale/ale_linters/nim/nimlsp.vim b/sources_non_forked/ale/ale_linters/nim/nimlsp.vim new file mode 100644 index 00000000..5d041043 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nim/nimlsp.vim @@ -0,0 +1,33 @@ +" Author: jeremija +" Description: Support for nimlsp (language server for nim) + +call ale#Set('nim_nimlsp_nim_sources', '') + +function! ale_linters#nim#nimlsp#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + + if !empty(l:project_root) + return fnamemodify(l:project_root, ':h:h') + endif + + return '' +endfunction + +function! ale_linters#nim#nimlsp#GetCommand(buffer) abort + let l:nim_sources = ale#Var(a:buffer, 'nim_nimlsp_nim_sources') + + if !empty(l:nim_sources) + let l:nim_sources = ale#Escape(l:nim_sources) + endif + + return '%e' . ale#Pad(l:nim_sources) +endfunction + +call ale#linter#Define('nim', { +\ 'name': 'nimlsp', +\ 'lsp': 'stdio', +\ 'executable': 'nimlsp', +\ 'command': function('ale_linters#nim#nimlsp#GetCommand'), +\ 'language': 'nim', +\ 'project_root': function('ale_linters#nim#nimlsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/psalm.vim b/sources_non_forked/ale/ale_linters/php/psalm.vim index 3cdb026a..ab4dbbc9 100644 --- a/sources_non_forked/ale/ale_linters/php/psalm.vim +++ b/sources_non_forked/ale/ale_linters/php/psalm.vim @@ -1,7 +1,8 @@ " Author: Matt Brown " Description: plugin for Psalm, static analyzer for PHP -call ale#Set('psalm_langserver_executable', 'psalm-language-server') +call ale#Set('psalm_langserver_executable', 'psalm') +call ale#Set('psalm_langserver_options', '') call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#psalm#GetProjectRoot(buffer) abort @@ -10,12 +11,16 @@ function! ale_linters#php#psalm#GetProjectRoot(buffer) abort return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' endfunction +function! ale_linters#php#psalm#GetCommand(buffer) abort + return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'psalm_langserver_options')) +endfunction + call ale#linter#Define('php', { \ 'name': 'psalm', \ 'lsp': 'stdio', \ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [ -\ 'vendor/bin/psalm-language-server', +\ 'vendor/bin/psalm', \ ])}, -\ 'command': '%e', +\ 'command': function('ale_linters#php#psalm#GetCommand'), \ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/powershell/powershell.vim b/sources_non_forked/ale/ale_linters/powershell/powershell.vim index a63191fd..5f49f72c 100644 --- a/sources_non_forked/ale/ale_linters/powershell/powershell.vim +++ b/sources_non_forked/ale/ale_linters/powershell/powershell.vim @@ -12,6 +12,7 @@ endfunction " https://rkeithhill.wordpress.com/2007/10/30/powershell-quicktip-preparsing-scripts-to-check-for-syntax-errors/ function! ale_linters#powershell#powershell#GetCommand(buffer) abort let l:script = ['Param($Script); + \ $ErrorView = "Normal"; \ trap {$_;continue} & { \ $Contents = Get-Content -Path $Script; \ $Contents = [string]::Join([Environment]::NewLine, $Contents); diff --git a/sources_non_forked/ale/ale_linters/ruby/brakeman.vim b/sources_non_forked/ale/ale_linters/ruby/brakeman.vim index a8088080..2dc48740 100644 --- a/sources_non_forked/ale/ale_linters/ruby/brakeman.vim +++ b/sources_non_forked/ale/ale_linters/ruby/brakeman.vim @@ -36,7 +36,7 @@ function! ale_linters#ruby#brakeman#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_brakeman_executable') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'brakeman') + return ale#ruby#EscapeExecutable(l:executable, 'brakeman') \ . ' -f json -q ' \ . ale#Var(a:buffer, 'ruby_brakeman_options') \ . ' -p ' . ale#Escape(l:rails_root) diff --git a/sources_non_forked/ale/ale_linters/ruby/debride.vim b/sources_non_forked/ale/ale_linters/ruby/debride.vim new file mode 100644 index 00000000..3b2cc443 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/debride.vim @@ -0,0 +1,42 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: debride, a dead method detector for Ruby files + +call ale#Set('ruby_debride_executable', 'debride') +call ale#Set('ruby_debride_options', '') + +function! ale_linters#ruby#debride#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_debride_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'debride') + \ . ale#Var(a:buffer, 'ruby_debride_options') + \ . ' %s' +endfunction + +function! ale_linters#ruby#debride#HandleOutput(buffer, lines) abort + let l:output = [] + + for l:line in a:lines + if l:line !~# '^ ' + continue + endif + + let l:elements = split(l:line) + let l:method_name = l:elements[0] + let l:lnum = split(l:elements[1], ':')[1] + + call add(l:output, { + \ 'lnum': 0 + l:lnum, + \ 'text': 'Possible unused method: ' . l:method_name, + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'debride', +\ 'executable': {b -> ale#Var(b, 'ruby_debride_executable')}, +\ 'command': function('ale_linters#ruby#debride#GetCommand'), +\ 'callback': 'ale_linters#ruby#debride#HandleOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim b/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim index a94fb671..36646647 100644 --- a/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim +++ b/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim @@ -33,7 +33,7 @@ function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort let l:output_file = has('win32') ? '%t ' : '/dev/stdout ' let l:cat_file = has('win32') ? '; type %t' : '' - return ale#handlers#ruby#EscapeExecutable(l:executable, 'rails_best_practices') + return ale#ruby#EscapeExecutable(l:executable, 'rails_best_practices') \ . ' --silent -f json --output-file ' . l:output_file \ . ale#Var(a:buffer, 'ruby_rails_best_practices_options') \ . ale#Escape(l:rails_root) diff --git a/sources_non_forked/ale/ale_linters/ruby/reek.vim b/sources_non_forked/ale/ale_linters/ruby/reek.vim index e39e366f..226b452e 100644 --- a/sources_non_forked/ale/ale_linters/ruby/reek.vim +++ b/sources_non_forked/ale/ale_linters/ruby/reek.vim @@ -14,7 +14,7 @@ function! ale_linters#ruby#reek#GetCommand(buffer, version) abort \ ? ' --stdin-filename %s' \ : '' - return ale#handlers#ruby#EscapeExecutable(l:executable, 'reek') + return ale#ruby#EscapeExecutable(l:executable, 'reek') \ . ' -f json --no-progress --no-color --force-exclusion' \ . l:display_name_args endfunction diff --git a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim index 8b9e9c84..410ed0ea 100644 --- a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim +++ b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim @@ -7,7 +7,7 @@ call ale#Set('ruby_rubocop_options', '') function! ale_linters#ruby#rubocop#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop') + return ale#ruby#EscapeExecutable(l:executable, 'rubocop') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'ruby_rubocop_options') \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) diff --git a/sources_non_forked/ale/ale_linters/ruby/sorbet.vim b/sources_non_forked/ale/ale_linters/ruby/sorbet.vim index ee765a6e..cae0683c 100644 --- a/sources_non_forked/ale/ale_linters/ruby/sorbet.vim +++ b/sources_non_forked/ale/ale_linters/ruby/sorbet.vim @@ -5,7 +5,7 @@ function! ale_linters#ruby#sorbet#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable') let l:options = ale#Var(a:buffer, 'ruby_sorbet_options') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'srb') + return ale#ruby#EscapeExecutable(l:executable, 'srb') \ . ' tc' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --lsp --disable-watchman' diff --git a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim index f075a7d5..f751e803 100644 --- a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim +++ b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim @@ -8,7 +8,7 @@ call ale#Set('ruby_standardrb_options', '') function! ale_linters#ruby#standardrb#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_standardrb_executable') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'standardrb') + return ale#ruby#EscapeExecutable(l:executable, 'standardrb') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'ruby_standardrb_options') \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) diff --git a/sources_non_forked/ale/ale_linters/scala/metals.vim b/sources_non_forked/ale/ale_linters/scala/metals.vim new file mode 100644 index 00000000..f78c7119 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/metals.vim @@ -0,0 +1,48 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Metals Language Server for Scala https://scalameta.org/metals/ + +call ale#Set('scala_metals_executable', 'metals-vim') +call ale#Set('scala_metals_project_root', '') + +function! ale_linters#scala#metals#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'scala_metals_project_root') + + if !empty(l:project_root) + return l:project_root + endif + + let l:potential_roots = [ + \ 'build.sc', + \ 'build.sbt', + \ '.bloop', + \ '.metals', + \] + + for l:root in l:potential_roots + let l:project_root = ale#path#ResolveLocalPath( + \ a:buffer, + \ l:root, + \ '' + \) + + if !empty(l:project_root) + return fnamemodify( + \ l:project_root, + \ ':h', + \) + endif + endfor +endfunction + +function! ale_linters#scala#metals#GetCommand(buffer) abort + return '%e' . ale#Pad('stdio') +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'metals', +\ 'lsp': 'stdio', +\ 'language': 'scala', +\ 'executable': {b -> ale#Var(b, 'scala_metals_executable')}, +\ 'command': function('ale_linters#scala#metals#GetCommand'), +\ 'project_root': function('ale_linters#scala#metals#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/sh/shell.vim b/sources_non_forked/ale/ale_linters/sh/shell.vim index 189dc21d..171fe64e 100644 --- a/sources_non_forked/ale/ale_linters/sh/shell.vim +++ b/sources_non_forked/ale/ale_linters/sh/shell.vim @@ -34,8 +34,10 @@ function! ale_linters#sh#shell#Handle(buffer, lines) abort " Matches patterns line the following: " " bash: line 13: syntax error near unexpected token `d' + " bash:行0: 未预期的符号“done”附近有语法错误 + " bash: 列 90: 尋找匹配的「"」時遇到了未預期的檔案結束符 " sh: 11: Syntax error: "(" unexpected - let l:pattern = '\v(line |: ?)(\d+): (.+)$' + let l:pattern = '\v([^:]+:\D*)(\d+): (.+)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) diff --git a/sources_non_forked/ale/ale_linters/solidity/solc.vim b/sources_non_forked/ale/ale_linters/solidity/solc.vim new file mode 100644 index 00000000..e4f220ac --- /dev/null +++ b/sources_non_forked/ale/ale_linters/solidity/solc.vim @@ -0,0 +1,35 @@ +" Author: Karl Bartel - http://karl.berlin/ +" Description: Report solc compiler errors in Solidity code + +call ale#Set('solidity_solc_options', '') + +function! ale_linters#solidity#solc#Handle(buffer, lines) abort + " Matches patterns like the following: + " /path/to/file/file.sol:1:10: Error: Identifier not found or not unique. + let l:pattern = '\v^[^:]+:(\d+):(\d+): (Error|Warning): (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:isError = l:match[3] is? 'error' + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': l:isError ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +function! ale_linters#solidity#solc#GetCommand(buffer) abort + return 'solc' . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s' +endfunction + +call ale#linter#Define('solidity', { +\ 'name': 'solc', +\ 'executable': 'solc', +\ 'command': function('ale_linters#solidity#solc#GetCommand'), +\ 'callback': 'ale_linters#solidity#solc#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/tflint.vim b/sources_non_forked/ale/ale_linters/terraform/tflint.vim index 6d54a8b1..f57ee6b6 100644 --- a/sources_non_forked/ale/ale_linters/terraform/tflint.vim +++ b/sources_non_forked/ale/ale_linters/terraform/tflint.vim @@ -9,23 +9,69 @@ call ale#Set('terraform_tflint_executable', 'tflint') function! ale_linters#terraform#tflint#Handle(buffer, lines) abort let l:output = [] + let l:pattern = '\v^(.*):(\d+),(\d+)-(\d+)?,?(\d+): (.{-1,}); (.+)$' + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) - for l:error in ale#util#FuzzyJSONDecode(a:lines, []) - if l:error.type is# 'ERROR' - let l:type = 'E' - elseif l:error.type is# 'NOTICE' - let l:type = 'I' - else - let l:type = 'W' - endif + " This is a rough test for tflint's output format + " On versions prior to 0.11 it outputs all errors as a single level list + if type(l:json) is v:t_list + for l:error in l:json + if l:error.type is# 'ERROR' + let l:type = 'E' + elseif l:error.type is# 'NOTICE' + let l:type = 'I' + else + let l:type = 'W' + endif - call add(l:output, { - \ 'lnum': l:error.line, - \ 'text': l:error.message, - \ 'type': l:type, - \ 'code': l:error.detector, - \}) - endfor + call add(l:output, { + \ 'lnum': l:error.line, + \ 'text': l:error.message, + \ 'type': l:type, + \ 'code': l:error.detector, + \}) + endfor + else + for l:error in get(l:json, 'errors', []) + for l:match in ale#util#GetMatches(l:error.message, [l:pattern]) + if l:match[4] is# '' + let l:match[4] = l:match[2] + endif + + call add(l:output, { + \ 'filename': l:match[1], + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'end_lnum': str2nr(l:match[4]), + \ 'end_col': str2nr(l:match[5]), + \ 'text': l:match[7], + \ 'code': l:match[6], + \ 'type': 'E', + \}) + endfor + endfor + + for l:error in get(l:json, 'issues', []) + if l:error.rule.severity is# 'ERROR' + let l:type = 'E' + elseif l:error.rule.severity is# 'NOTICE' + let l:type = 'I' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'filename': l:error.range.filename, + \ 'lnum': l:error.range.start.line, + \ 'col': l:error.range.start.column, + \ 'end_lnum': l:error.range.end.line, + \ 'end_col': l:error.range.end.column, + \ 'text': l:error.message, + \ 'code': l:error.rule.name, + \ 'type': l:type, + \}) + endfor + endif return l:output endfunction diff --git a/sources_non_forked/ale/ale_linters/typescript/standard.vim b/sources_non_forked/ale/ale_linters/typescript/standard.vim new file mode 100644 index 00000000..da8f14eb --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/standard.vim @@ -0,0 +1,31 @@ +" Author: Ahmed El Gabri <@ahmedelgabri> +" Description: standardjs for typescript files + +call ale#Set('typescript_standard_executable', 'standard') +call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typescript_standard_options', '') + +function! ale_linters#typescript#standard#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'typescript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', + \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/.bin/standard', + \]) +endfunction + +function! ale_linters#typescript#standard#GetCommand(buffer) abort + let l:executable = ale_linters#typescript#standard#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'typescript_standard_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin %s' +endfunction + +" standard uses eslint and the output format is the same +call ale#linter#Define('typescript', { +\ 'name': 'standard', +\ 'executable': function('ale_linters#typescript#standard#GetExecutable'), +\ 'command': function('ale_linters#typescript#standard#GetCommand'), +\ 'callback': 'ale#handlers#eslint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/vlog.vim b/sources_non_forked/ale/ale_linters/verilog/vlog.vim index 37d21c4c..951e2037 100644 --- a/sources_non_forked/ale/ale_linters/verilog/vlog.vim +++ b/sources_non_forked/ale/ale_linters/verilog/vlog.vim @@ -24,6 +24,20 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort \}) endfor + "Matches patterns like the following: + "** Warning: (vlog-2623) add.v(7): Undefined variable: C. + "** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C. + " let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:pattern = '^**\s\(\w*\):\s\([^)]*)\)[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[3] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[2] . ' ' . l:match[4], + \}) + endfor + return l:output endfunction diff --git a/sources_non_forked/ale/autoload/ale.vim b/sources_non_forked/ale/autoload/ale.vim index 3a4e79c8..ee1a0d54 100644 --- a/sources_non_forked/ale/autoload/ale.vim +++ b/sources_non_forked/ale/autoload/ale.vim @@ -5,11 +5,18 @@ " Strings used for severity in the echoed message let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error') let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info') +let g:ale_echo_msg_log_str = get(g:, 'ale_echo_msg_log_str', 'Log') let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning') " Ignoring linters, for disabling some, or ignoring LSP diagnostics. let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {}) let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 0) +" LSP window/showMessage format +let g:ale_lsp_show_message_format = get(g:, 'ale_lsp_show_message_format', '%severity%:%linter%: %s') +" Valid values mimic LSP definitions (error, warning and information; log is +" never shown) +let g:ale_lsp_show_message_severity = get(g:, 'ale_lsp_show_message_severity', 'error') + let s:lint_timer = -1 let s:getcmdwintype_exists = exists('*getcmdwintype') @@ -156,7 +163,7 @@ function! ale#Queue(delay, ...) abort endif endfunction -let s:current_ale_version = [2, 5, 0] +let s:current_ale_version = [2, 6, 0] " A function used to check for ALE features in files outside of the project. function! ale#Has(feature) abort diff --git a/sources_non_forked/ale/autoload/ale/assert.vim b/sources_non_forked/ale/autoload/ale/assert.vim index dac5efb7..291edcee 100644 --- a/sources_non_forked/ale/autoload/ale/assert.vim +++ b/sources_non_forked/ale/autoload/ale/assert.vim @@ -267,14 +267,22 @@ function! ale#assert#TearDownLinterTest() abort endif endfunction -function! ale#assert#SetUpFixerTest(filetype, name) abort +function! ale#assert#SetUpFixerTest(filetype, name, ...) abort + " If the suffix of the option names format is different, an additional + " argument can be used for that instead. + if a:0 > 1 + throw 'Too many arguments' + endif + " Set up a marker so ALE doesn't create real random temporary filenames. let g:ale_create_dummy_temporary_file = 1 let l:function_name = ale#fix#registry#GetFunc(a:name) let s:FixerFunction = function(l:function_name) - let l:prefix = 'ale_' . a:filetype . '_' . a:name + let l:option_suffix = get(a:000, 0, a:name) + let l:prefix = 'ale_' . a:filetype . '_' + \ . substitute(l:option_suffix, '-', '_', 'g') let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' for l:key in filter(keys(g:), b:filter_expr) @@ -286,7 +294,7 @@ function! ale#assert#SetUpFixerTest(filetype, name) abort unlet b:[l:key] endfor - execute 'runtime autoload/ale/fixers/' . a:name . '.vim' + execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim' if !exists('g:dir') call ale#test#SetDirectory('/testplugin/test/fixers') diff --git a/sources_non_forked/ale/autoload/ale/c.vim b/sources_non_forked/ale/autoload/ale/c.vim index 5540ec14..9b428700 100644 --- a/sources_non_forked/ale/autoload/ale/c.vim +++ b/sources_non_forked/ale/autoload/ale/c.vim @@ -265,6 +265,16 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort return l:empty endfunction +function! ale#c#GetCompileCommand(json_item) abort + if has_key(a:json_item, 'command') + return a:json_item.command + elseif has_key(a:json_item, 'arguments') + return join(a:json_item.arguments, ' ') + endif + + return '' +endfunction + function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort " Search for an exact file match first. let l:basename = tolower(expand('#' . a:buffer . ':t')) @@ -287,15 +297,14 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort for l:item in l:file_list " Load the flags for this file, or for a source file matching the " header file. - if has_key(l:item, 'command') - \&& ( + if ( \ bufnr(l:item.file) is a:buffer \ || ( \ !empty(l:source_file) \ && l:item.file[-len(l:source_file):] is? l:source_file \ ) \) - return ale#c#ParseCFlags(l:item.directory, l:item.command) + return ale#c#ParseCFlags(l:item.directory, ale#c#GetCompileCommand(l:item)) endif endfor @@ -307,8 +316,7 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort for l:item in l:dir_list if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir - \&& has_key(l:item, 'command') - return ale#c#ParseCFlags(l:item.directory, l:item.command) + return ale#c#ParseCFlags(l:item.directory, ale#c#GetCompileCommand(l:item)) endif endfor diff --git a/sources_non_forked/ale/autoload/ale/code_action.vim b/sources_non_forked/ale/autoload/ale/code_action.vim new file mode 100644 index 00000000..0af1bb70 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/code_action.vim @@ -0,0 +1,163 @@ +" Author: Jerko Steiner +" Description: Code action support for LSP / tsserver + +function! ale#code_action#HandleCodeAction(code_action) abort + let l:current_buffer = bufnr('') + let l:changes = a:code_action.changes + + for l:file_code_edit in l:changes + let l:buf = bufnr(l:file_code_edit.fileName) + + if l:buf != -1 && l:buf != l:current_buffer && getbufvar(l:buf, '&mod') + call ale#util#Execute('echom ''Aborting action, file is unsaved''') + + return + endif + endfor + + for l:file_code_edit in l:changes + call ale#code_action#ApplyChanges( + \ l:file_code_edit.fileName, l:file_code_edit.textChanges) + endfor +endfunction + +function! ale#code_action#ApplyChanges(filename, changes) abort + let l:current_buffer = bufnr('') + " The buffer is used to determine the fileformat, if available. + let l:buffer = bufnr(a:filename) + let l:is_current_buffer = l:buffer > 0 && l:buffer == l:current_buffer + + if l:buffer > 0 + let l:lines = getbufline(l:buffer, 1, '$') + else + let l:lines = readfile(a:filename, 'b') + endif + + if l:is_current_buffer + let l:pos = getpos('.')[1:2] + else + let l:pos = [1, 1] + endif + + " We have to keep track of how many lines we have added, and offset + " changes accordingly. + let l:line_offset = 0 + let l:column_offset = 0 + let l:last_end_line = 0 + + for l:code_edit in a:changes + if l:code_edit.start.line isnot l:last_end_line + let l:column_offset = 0 + endif + + let l:line = l:code_edit.start.line + l:line_offset + let l:column = l:code_edit.start.offset + l:column_offset + let l:end_line = l:code_edit.end.line + l:line_offset + let l:end_column = l:code_edit.end.offset + l:column_offset + let l:text = l:code_edit.newText + + let l:cur_line = l:pos[0] + let l:cur_column = l:pos[1] + + let l:last_end_line = l:end_line + + " Adjust the ends according to previous edits. + if l:end_line > len(l:lines) + let l:end_line_len = 0 + else + let l:end_line_len = len(l:lines[l:end_line - 1]) + endif + + let l:insertions = split(l:text, '\n', 1) + + if l:line is 1 + " Same logic as for column below. Vimscript's slice [:-1] will not + " be an empty list. + let l:start = [] + else + let l:start = l:lines[: l:line - 2] + endif + + if l:column is 1 + " We need to handle column 1 specially, because we can't slice an + " empty string ending on index 0. + let l:middle = [l:insertions[0]] + else + let l:middle = [l:lines[l:line - 1][: l:column - 2] . l:insertions[0]] + endif + + call extend(l:middle, l:insertions[1:]) + let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :] + + let l:lines_before_change = len(l:lines) + let l:lines = l:start + l:middle + l:lines[l:end_line :] + + let l:current_line_offset = len(l:lines) - l:lines_before_change + let l:line_offset += l:current_line_offset + let l:column_offset = len(l:middle[-1]) - l:end_line_len + + let l:pos = s:UpdateCursor(l:pos, + \ [l:line, l:column], + \ [l:end_line, l:end_column], + \ [l:current_line_offset, l:column_offset]) + endfor + + if l:lines[-1] is# '' + call remove(l:lines, -1) + endif + + call ale#util#Writefile(l:buffer, l:lines, a:filename) + + if l:is_current_buffer + call ale#util#Execute(':e!') + call setpos('.', [0, l:pos[0], l:pos[1], 0]) + endif +endfunction + +function! s:UpdateCursor(cursor, start, end, offset) abort + let l:cur_line = a:cursor[0] + let l:cur_column = a:cursor[1] + let l:line = a:start[0] + let l:column = a:start[1] + let l:end_line = a:end[0] + let l:end_column = a:end[1] + let l:line_offset = a:offset[0] + let l:column_offset = a:offset[1] + + if l:end_line < l:cur_line + " both start and end lines are before the cursor. only line offset + " needs to be updated + let l:cur_line += l:line_offset + elseif l:end_line == l:cur_line + " end line is at the same location as cursor, which means + " l:line <= l:cur_line + if l:line < l:cur_line || l:column <= l:cur_column + " updates are happening either before or around the cursor + if l:end_column < l:cur_column + " updates are happening before the cursor, update the + " column offset for cursor + let l:cur_line += l:line_offset + let l:cur_column += l:column_offset + else + " updates are happening around the cursor, move the cursor + " to the end of the changes + let l:cur_line += l:line_offset + let l:cur_column = l:end_column + l:column_offset + endif + " else is not necessary, it means modifications are happening + " after the cursor so no cursor updates need to be done + endif + else + " end line is after the cursor + if l:line < l:cur_line || l:line == l:cur_line && l:column <= l:cur_column + " changes are happening around the cursor, move the cursor + " to the end of the changes + let l:cur_line = l:end_line + l:line_offset + let l:cur_column = l:end_column + l:column_offset + " else is not necesary, it means modifications are happening + " after the cursor so no cursor updates need to be done + endif + endif + + return [l:cur_line, l:cur_column] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index ebf32909..da24e839 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -1,5 +1,6 @@ " Author: w0rp " Description: Completion support for LSP linters +scriptencoding utf-8 " The omnicompletion menu is shown through a special Plug mapping which is " only valid in Insert mode. This way, feedkeys() won't send these keys if you @@ -15,29 +16,107 @@ onoremap (ale_show_completion_menu) let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100) let g:ale_completion_excluded_words = get(g:, 'ale_completion_excluded_words', []) let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50) +let g:ale_completion_tsserver_autoimport = get(g:, 'ale_completion_tsserver_autoimport', 0) let s:timer_id = -1 let s:last_done_pos = [] " CompletionItemKind values from the LSP protocol. -let s:LSP_COMPLETION_TEXT_KIND = 1 -let s:LSP_COMPLETION_METHOD_KIND = 2 -let s:LSP_COMPLETION_FUNCTION_KIND = 3 -let s:LSP_COMPLETION_CONSTRUCTOR_KIND = 4 -let s:LSP_COMPLETION_FIELD_KIND = 5 -let s:LSP_COMPLETION_VARIABLE_KIND = 6 -let s:LSP_COMPLETION_CLASS_KIND = 7 -let s:LSP_COMPLETION_INTERFACE_KIND = 8 -let s:LSP_COMPLETION_MODULE_KIND = 9 -let s:LSP_COMPLETION_PROPERTY_KIND = 10 -let s:LSP_COMPLETION_UNIT_KIND = 11 -let s:LSP_COMPLETION_VALUE_KIND = 12 -let s:LSP_COMPLETION_ENUM_KIND = 13 -let s:LSP_COMPLETION_KEYWORD_KIND = 14 -let s:LSP_COMPLETION_SNIPPET_KIND = 15 -let s:LSP_COMPLETION_COLOR_KIND = 16 -let s:LSP_COMPLETION_FILE_KIND = 17 -let s:LSP_COMPLETION_REFERENCE_KIND = 18 +let g:ale_lsp_types = { +\ 1: 'text', +\ 2: 'method', +\ 3: 'function', +\ 4: 'constructor', +\ 5: 'field', +\ 6: 'variable', +\ 7: 'class', +\ 8: 'interface', +\ 9: 'module', +\ 10: 'property', +\ 11: 'unit', +\ 12: 'value', +\ 13: 'enum', +\ 14: 'keyword', +\ 15: 'snippet', +\ 16: 'color', +\ 17: 'file', +\ 18: 'reference', +\ 19: 'folder', +\ 20: 'enum_member', +\ 21: 'constant', +\ 22: 'struct', +\ 23: 'event', +\ 24: 'operator', +\ 25: 'type_parameter', +\ } + +" from https://github.com/microsoft/TypeScript/blob/29becf05012bfa7ba20d50b0d16813971e46b8a6/lib/protocol.d.ts#L2472 +let g:ale_tsserver_types = { +\ 'warning': 'text', +\ 'keyword': 'keyword', +\ 'script': 'file', +\ 'module': 'module', +\ 'class': 'class', +\ 'local class': 'class', +\ 'interface': 'interface', +\ 'type': 'class', +\ 'enum': 'enum', +\ 'enum member': 'enum_member', +\ 'var': 'variable', +\ 'local var': 'variable', +\ 'function': 'function', +\ 'local function': 'function', +\ 'method': 'method', +\ 'getter': 'property', +\ 'setter': 'method', +\ 'property': 'property', +\ 'constructor': 'constructor', +\ 'call': 'method', +\ 'index': 'index', +\ 'construct': 'constructor', +\ 'parameter': 'parameter', +\ 'type parameter': 'type_parameter', +\ 'primitive type': 'unit', +\ 'label': 'text', +\ 'alias': 'class', +\ 'const': 'constant', +\ 'let': 'variable', +\ 'directory': 'folder', +\ 'external module name': 'text', +\ 'JSX attribute': 'parameter', +\ 'string': 'text' +\ } + +" For compatibility reasons, we only use built in VIM completion kinds +" See :help complete-items for Vim completion kinds +let g:ale_completion_symbols = get(g:, 'ale_completion_symbols', { +\ 'text': 'v', +\ 'method': 'f', +\ 'function': 'f', +\ 'constructor': 'f', +\ 'field': 'm', +\ 'variable': 'v', +\ 'class': 't', +\ 'interface': 't', +\ 'module': 'd', +\ 'property': 'm', +\ 'unit': 'v', +\ 'value': 'v', +\ 'enum': 't', +\ 'keyword': 'v', +\ 'snippet': 'v', +\ 'color': 'v', +\ 'file': 'v', +\ 'reference': 'v', +\ 'folder': 'v', +\ 'enum_member': 'm', +\ 'constant': 'm', +\ 'struct': 't', +\ 'event': 'v', +\ 'operator': 'f', +\ 'type_parameter': 'p', +\ '': 'v' +\ }) let s:LSP_INSERT_TEXT_FORMAT_PLAIN = 1 let s:LSP_INSERT_TEXT_FORMAT_SNIPPET = 2 @@ -277,6 +356,27 @@ function! ale#completion#GetAllTriggers() abort return deepcopy(s:trigger_character_map) endfunction +function! ale#completion#GetCompletionKind(kind) abort + let l:lsp_symbol = get(g:ale_lsp_types, a:kind, '') + + if !empty(l:lsp_symbol) + return l:lsp_symbol + endif + + return get(g:ale_tsserver_types, a:kind, '') +endfunction + +function! ale#completion#GetCompletionSymbols(kind) abort + let l:kind = ale#completion#GetCompletionKind(a:kind) + let l:symbol = get(g:ale_completion_symbols, l:kind, '') + + if !empty(l:symbol) + return l:symbol + endif + + return get(g:ale_completion_symbols, '', 'v') +endfunction + function! s:CompletionStillValid(request_id) abort let [l:line, l:column] = getpos('.')[1:2] @@ -296,7 +396,10 @@ function! ale#completion#ParseTSServerCompletions(response) abort let l:names = [] for l:suggestion in a:response.body - call add(l:names, l:suggestion.name) + call add(l:names, { + \ 'word': l:suggestion.name, + \ 'source': get(l:suggestion, 'source', ''), + \}) endfor return l:names @@ -310,6 +413,10 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort for l:suggestion in a:response.body let l:displayParts = [] + for l:action in get(l:suggestion, 'codeActions', []) + call add(l:displayParts, l:action.description . ' ') + endfor + for l:part in l:suggestion.displayParts call add(l:displayParts, l:part.text) endfor @@ -321,22 +428,23 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort call add(l:documentationParts, l:part.text) endfor - if l:suggestion.kind is# 'className' - let l:kind = 'f' - elseif l:suggestion.kind is# 'parameterName' - let l:kind = 'f' - else - let l:kind = 'v' - endif - " See :help complete-items - call add(l:results, { + let l:result = { \ 'word': l:suggestion.name, - \ 'kind': l:kind, + \ 'kind': ale#completion#GetCompletionSymbols(l:suggestion.kind), \ 'icase': 1, \ 'menu': join(l:displayParts, ''), + \ 'dup': g:ale_completion_tsserver_autoimport, \ 'info': join(l:documentationParts, ''), - \}) + \} + + if has_key(l:suggestion, 'codeActions') + let l:result.user_data = json_encode({ + \ 'codeActions': l:suggestion.codeActions, + \ }) + endif + + call add(l:results, l:result) endfor let l:names = getbufvar(l:buffer, 'ale_tsserver_completion_names', []) @@ -345,12 +453,12 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort let l:names_with_details = map(copy(l:results), 'v:val.word') let l:missing_names = filter( \ copy(l:names), - \ 'index(l:names_with_details, v:val) < 0', + \ 'index(l:names_with_details, v:val.word) < 0', \) for l:name in l:missing_names call add(l:results, { - \ 'word': l:name, + \ 'word': l:name.word, \ 'kind': 'v', \ 'icase': 1, \ 'menu': '', @@ -408,23 +516,6 @@ function! ale#completion#ParseLSPCompletions(response) abort continue endif - " See :help complete-items for Vim completion kinds - if !has_key(l:item, 'kind') - let l:kind = 'v' - elseif l:item.kind is s:LSP_COMPLETION_METHOD_KIND - let l:kind = 'm' - elseif l:item.kind is s:LSP_COMPLETION_CONSTRUCTOR_KIND - let l:kind = 'm' - elseif l:item.kind is s:LSP_COMPLETION_FUNCTION_KIND - let l:kind = 'f' - elseif l:item.kind is s:LSP_COMPLETION_CLASS_KIND - let l:kind = 'f' - elseif l:item.kind is s:LSP_COMPLETION_INTERFACE_KIND - let l:kind = 'f' - else - let l:kind = 'v' - endif - let l:doc = get(l:item, 'documentation', '') if type(l:doc) is v:t_dict && has_key(l:doc, 'value') @@ -433,7 +524,7 @@ function! ale#completion#ParseLSPCompletions(response) abort call add(l:results, { \ 'word': l:word, - \ 'kind': l:kind, + \ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')), \ 'icase': 1, \ 'menu': get(l:item, 'detail', ''), \ 'info': (type(l:doc) is v:t_string ? l:doc : ''), @@ -472,13 +563,29 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort call setbufvar(l:buffer, 'ale_tsserver_completion_names', l:names) if !empty(l:names) + let l:identifiers = [] + + for l:name in l:names + let l:identifier = { + \ 'name': l:name.word, + \} + let l:source = get(l:name, 'source', '') + + " Empty source results in no details for the completed item + if !empty(l:source) + call extend(l:identifier, { 'source': l:source }) + endif + + call add(l:identifiers, l:identifier) + endfor + let b:ale_completion_info.request_id = ale#lsp#Send( \ b:ale_completion_info.conn_id, \ ale#lsp#tsserver_message#CompletionEntryDetails( \ l:buffer, \ b:ale_completion_info.line, \ b:ale_completion_info.column, - \ l:names, + \ l:identifiers, \ ), \) endif @@ -525,6 +632,7 @@ function! s:OnReady(linter, lsp_details) abort \ b:ale_completion_info.line, \ b:ale_completion_info.column, \ b:ale_completion_info.prefix, + \ g:ale_completion_tsserver_autoimport, \) else " Send a message saying the buffer has changed first, otherwise @@ -692,6 +800,30 @@ function! ale#completion#Queue() abort let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler')) endfunction +function! ale#completion#HandleUserData(completed_item) abort + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if l:source isnot# 'ale-automatic' && l:source isnot# 'ale-manual' && l:source isnot# 'ale-callback' + return + endif + + let l:user_data_json = get(a:completed_item, 'user_data', '') + + if empty(l:user_data_json) + return + endif + + let l:user_data = json_decode(l:user_data_json) + + if type(l:user_data) isnot v:t_dict + return + endif + + for l:code_action in get(l:user_data, 'codeActions', []) + call ale#code_action#HandleCodeAction(l:code_action) + endfor +endfunction + function! ale#completion#Done() abort silent! pclose @@ -700,6 +832,10 @@ function! ale#completion#Done() abort let s:last_done_pos = getpos('.')[1:2] endfunction +augroup ALECompletionActions + autocmd CompleteDone * call ale#completion#HandleUserData(v:completed_item) +augroup END + function! s:Setup(enabled) abort augroup ALECompletionGroup autocmd! diff --git a/sources_non_forked/ale/autoload/ale/debugging.vim b/sources_non_forked/ale/autoload/ale/debugging.vim index 379c0d73..4e134f8c 100644 --- a/sources_non_forked/ale/autoload/ale/debugging.vim +++ b/sources_non_forked/ale/autoload/ale/debugging.vim @@ -50,6 +50,7 @@ let s:global_variable_list = [ \ 'ale_sign_style_error', \ 'ale_sign_style_warning', \ 'ale_sign_warning', +\ 'ale_sign_highlight_linenrs', \ 'ale_statusline_format', \ 'ale_type_map', \ 'ale_use_global_executables', diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim index 9987fbdd..dad9e2bc 100644 --- a/sources_non_forked/ale/autoload/ale/fix.vim +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -47,7 +47,7 @@ function! ale#fix#ApplyQueuedFixes(buffer) abort set nomodified endif else - call writefile(l:new_lines, expand(a:buffer . ':p')) " no-custom-checks + call writefile(l:new_lines, expand('#' . a:buffer . ':p')) " no-custom-checks call setbufvar(a:buffer, '&modified', 0) endif endif @@ -74,7 +74,7 @@ endfunction function! ale#fix#ApplyFixes(buffer, output) abort let l:data = g:ale_fix_buffer_data[a:buffer] let l:data.output = a:output - let l:data.changes_made = l:data.lines_before != l:data.output + let l:data.changes_made = l:data.lines_before !=# l:data.output " no-custom-checks let l:data.done = 1 call ale#command#RemoveManagedFiles(a:buffer) diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index 7a553ccc..1b3ca1a8 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -27,6 +27,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Fix PEP8 issues with black.', \ }, +\ 'dfmt': { +\ 'function': 'ale#fixers#dfmt#Fix', +\ 'suggested_filetypes': ['d'], +\ 'description': 'Fix D files with dfmt.', +\ }, \ 'fecs': { \ 'function': 'ale#fixers#fecs#Fix', \ 'suggested_filetypes': ['javascript', 'css', 'html'], @@ -49,6 +54,11 @@ let s:default_registry = { \ 'description': 'Apply elm-format to a file.', \ 'aliases': ['format'], \ }, +\ 'nimpretty': { +\ 'function': 'ale#fixers#nimpretty#Fix', +\ 'suggested_filetypes': ['nim'], +\ 'description': 'Apply nimpretty to a file.', +\ }, \ 'eslint': { \ 'function': 'ale#fixers#eslint#Fix', \ 'suggested_filetypes': ['javascript', 'typescript'], @@ -230,6 +240,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['haskell'], \ 'description': 'Refactor Haskell files with stylish-haskell.', \ }, +\ 'purty': { +\ 'function': 'ale#fixers#purty#Fix', +\ 'suggested_filetypes': ['purescript'], +\ 'description': 'Format PureScript files with purty.', +\ }, \ 'ocamlformat': { \ 'function': 'ale#fixers#ocamlformat#Fix', \ 'suggested_filetypes': ['ocaml'], @@ -255,6 +270,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['sql'], \ 'description': 'Fix SQL files with sqlfmt.', \ }, +\ 'sqlformat': { +\ 'function': 'ale#fixers#sqlformat#Fix', +\ 'suggested_filetypes': ['sql'], +\ 'description': 'Fix SQL files with sqlformat.', +\ }, \ 'google_java_format': { \ 'function': 'ale#fixers#google_java_format#Fix', \ 'suggested_filetypes': ['java'], @@ -312,7 +332,7 @@ let s:default_registry = { \ }, \ 'styler': { \ 'function': 'ale#fixers#styler#Fix', -\ 'suggested_filetypes': ['r', 'rmarkdown'], +\ 'suggested_filetypes': ['r', 'rmarkdown', 'rmd'], \ 'description': 'Fix R files with styler.', \ }, \ 'latexindent': { @@ -335,6 +355,16 @@ let s:default_registry = { \ 'suggested_filetypes': ['ada'], \ 'description': 'Format Ada files with gnatpp.', \ }, +\ 'nixpkgs-fmt': { +\ 'function': 'ale#fixers#nixpkgsfmt#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'A formatter for Nix code', +\ }, +\ 'html-beautify': { +\ 'function': 'ale#fixers#html_beautify#Fix', +\ 'suggested_filetypes': ['html', 'htmldjango'], +\ 'description': 'Fix HTML files with html-beautify.', +\ }, \} " Reset the function registry to the default entries. diff --git a/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim new file mode 100644 index 00000000..0072e045 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim @@ -0,0 +1,18 @@ +" Author: theoldmoon0602 +" Description: Integration of dfmt with ALE. + +call ale#Set('d_dfmt_executable', 'dfmt') +call ale#Set('d_dfmt_options', '') + +function! ale#fixers#dfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'd_dfmt_executable') + let l:options = ale#Var(a:buffer, 'd_dfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -i' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim b/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim new file mode 100644 index 00000000..236cb6ec --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim @@ -0,0 +1,21 @@ +" Author: WhyNotHugo +" Description: Lint HTML files with html-beautify. +" +call ale#Set('html_beautify_executable', 'html-beautify') +call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('html_beautify_options', '') +call ale#Set('html_beautify_change_directory', 1) + +function! ale#fixers#html_beautify#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'html_beautify', + \ ['html-beautify'] + \) + + let l:options = ale#Var(a:buffer, 'html_beautify_options') + + return { + \ 'command': ale#Escape(l:executable). ' ' . l:options . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim b/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim new file mode 100644 index 00000000..fe2e7136 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim @@ -0,0 +1,15 @@ +" Author: Nhan +" Description: Integration of nimpretty with ALE. + +call ale#Set('nim_nimpretty_executable', 'nimpretty') +call ale#Set('nim_nimpretty_options', '--maxLineLen:80') + +function! ale#fixers#nimpretty#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nim_nimpretty_executable') + let l:options = ale#Var(a:buffer, 'nim_nimpretty_options') + + return { + \ 'command': ale#Escape(l:executable) . ' %t' . ale#Pad(l:options), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim new file mode 100644 index 00000000..403ce798 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim @@ -0,0 +1,12 @@ +call ale#Set('nix_nixpkgsfmt_executable', 'nixpkgs-fmt') +call ale#Set('nix_nixpkgsfmt_options', '') + +function! ale#fixers#nixpkgsfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_nixpkgsfmt_executable') + let l:options = ale#Var(a:buffer, 'nix_nixpkgsfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/purty.vim b/sources_non_forked/ale/autoload/ale/fixers/purty.vim new file mode 100644 index 00000000..46d2cacd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/purty.vim @@ -0,0 +1,22 @@ +" Author: iclanzan +" Description: Integration of purty with ALE. + +call ale#Set('purescript_purty_executable', 'purty') + +function! ale#fixers#purty#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'purescript_purty_executable') + + return ale#Escape(l:executable) +endfunction + +function! ale#fixers#purty#Fix(buffer) abort + let l:executable = ale#fixers#purty#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' --write' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim b/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim index 33ba6887..0c7441e4 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim @@ -6,7 +6,7 @@ function! ale#fixers#rubocop#GetCommand(buffer) abort let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml') let l:options = ale#Var(a:buffer, 'ruby_rubocop_options') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop') + return ale#ruby#EscapeExecutable(l:executable, 'rubocop') \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --auto-correct --force-exclusion %t' diff --git a/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim b/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim index 182f7300..7c12fa1e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim @@ -5,7 +5,7 @@ function! ale#fixers#sorbet#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable') let l:options = ale#Var(a:buffer, 'ruby_sorbet_options') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'srb') + return ale#ruby#EscapeExecutable(l:executable, 'srb') \ . ' tc' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --autocorrect --file %t' diff --git a/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim b/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim new file mode 100644 index 00000000..6319c1ac --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim @@ -0,0 +1,16 @@ +" Author: Cluas +" Description: Fixing files with sqlformat. + +call ale#Set('sql_sqlformat_executable', 'sqlformat') +call ale#Set('sql_sqlformat_options', '') + +function! ale#fixers#sqlformat#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'sql_sqlformat_executable') + let l:options = ale#Var(a:buffer, 'sql_sqlformat_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/standard.vim b/sources_non_forked/ale/autoload/ale/fixers/standard.vim index 77712d40..cffa9f9d 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standard.vim @@ -7,6 +7,7 @@ call ale#Set('javascript_standard_options', '') function! ale#fixers#standard#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/.bin/standard', \]) @@ -14,7 +15,14 @@ endfunction function! ale#fixers#standard#Fix(buffer) abort let l:executable = ale#fixers#standard#GetExecutable(a:buffer) - let l:options = ale#Var(a:buffer, 'javascript_standard_options') + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:options_type = 'javascript_standard_options' + + if l:filetype =~# 'typescript' + let l:options_type = 'typescript_standard_options' + endif + + let l:options = ale#Var(a:buffer, l:options_type) return { \ 'command': ale#node#Executable(a:buffer, l:executable) diff --git a/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim b/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim index fab1e2bc..54330a37 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim @@ -9,7 +9,7 @@ function! ale#fixers#standardrb#GetCommand(buffer) abort let l:config = ale#path#FindNearestFile(a:buffer, '.standard.yml') let l:options = ale#Var(a:buffer, 'ruby_standardrb_options') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'standardrb') + return ale#ruby#EscapeExecutable(l:executable, 'standardrb') \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --fix --force-exclusion %t' diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim index 6bfb2fde..6f4cf177 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim @@ -3,6 +3,7 @@ call ale#Set('stylelint_executable', 'stylelint') call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('stylelint_options', '') function! ale#fixers#stylelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'stylelint', [ @@ -13,10 +14,14 @@ endfunction function! ale#fixers#stylelint#Fix(buffer) abort let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'stylelint_options') return { - \ 'command': ale#node#Executable(a:buffer, l:executable) - \ . ' --fix %t', + \ 'command': ale#path#BufferCdString(a:buffer) + \ . ale#node#Executable(a:buffer, l:executable) + \ . ' %t' + \ . ale#Pad(l:options) + \ . ' --fix', \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/styler.vim b/sources_non_forked/ale/autoload/ale/fixers/styler.vim index 7ff3275c..1c7607bd 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/styler.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/styler.vim @@ -2,13 +2,13 @@ " Description: Fixing R files with styler. call ale#Set('r_styler_executable', 'Rscript') -call ale#Set('r_styler_options', 'tidyverse_style') +call ale#Set('r_styler_options', 'tidyverse_style()') function! ale#fixers#styler#Fix(buffer) abort return { \ 'command': 'Rscript --vanilla -e ' \ . '"suppressPackageStartupMessages(library(styler));' - \ . 'style_file(commandArgs(TRUE), style = ' + \ . 'style_file(commandArgs(TRUE), transformers = ' \ . ale#Var(a:buffer, 'r_styler_options') . ')"' \ . ' %t', \ 'read_temporary_file': 1, diff --git a/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim b/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim index 10e049df..73974ceb 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim @@ -2,6 +2,7 @@ " Description: languagetool for markdown files " call ale#Set('languagetool_executable', 'languagetool') +call ale#Set('languagetool_options', '--autoDetect') function! ale#handlers#languagetool#GetExecutable(buffer) abort return ale#Var(a:buffer, 'languagetool_executable') @@ -9,8 +10,10 @@ endfunction function! ale#handlers#languagetool#GetCommand(buffer) abort let l:executable = ale#handlers#languagetool#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'languagetool_options') - return ale#Escape(l:executable) . ' --autoDetect %s' + return ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) . ' %s' endfunction function! ale#handlers#languagetool#HandleOutput(buffer, lines) abort diff --git a/sources_non_forked/ale/autoload/ale/handlers/ruby.vim b/sources_non_forked/ale/autoload/ale/handlers/ruby.vim index c28b8b75..7a1c5765 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/ruby.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/ruby.vim @@ -36,11 +36,3 @@ endfunction function! ale#handlers#ruby#HandleSyntaxErrors(buffer, lines) abort return s:HandleSyntaxError(a:buffer, a:lines) endfunction - -function! ale#handlers#ruby#EscapeExecutable(executable, bundle_exec) abort - let l:exec_args = a:executable =~? 'bundle' - \ ? ' exec ' . a:bundle_exec - \ : '' - - return ale#Escape(a:executable) . l:exec_args -endfunction diff --git a/sources_non_forked/ale/autoload/ale/highlight.vim b/sources_non_forked/ale/autoload/ale/highlight.vim index cb7911e1..82ad57e0 100644 --- a/sources_non_forked/ale/autoload/ale/highlight.vim +++ b/sources_non_forked/ale/autoload/ale/highlight.vim @@ -26,6 +26,25 @@ endif let s:MAX_POS_VALUES = 8 let s:MAX_COL_SIZE = 1073741824 " pow(2, 30) +let s:has_nvim_highlight = exists('*nvim_buf_add_highlight') && exists('*nvim_buf_clear_namespace') + +if s:has_nvim_highlight + let s:ns_id = nvim_create_namespace('ale_highlight') +endif + +" Wrappers are necessary to test this functionality by faking the calls in tests. +function! ale#highlight#nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) abort + " Ignore all errors for adding highlights. + try + call nvim_buf_add_highlight(a:buffer, a:ns_id, a:hl_group, a:line, a:col_start, a:col_end) + catch + endtry +endfunction + +function! ale#highlight#nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) abort + call nvim_buf_clear_namespace(a:buffer, a:ns_id, a:line_start, a:line_end) +endfunction + function! ale#highlight#CreatePositions(line, col, end_line, end_col) abort if a:line >= a:end_line " For single lines, just return the one position. @@ -51,15 +70,53 @@ endfunction " except these which have matching loclist item entries. function! ale#highlight#RemoveHighlights() abort - for l:match in getmatches() - if l:match.group =~? '\v^ALE(Style)?(Error|Warning|Info)(Line)?$' - call matchdelete(l:match.id) - endif - endfor + if s:has_nvim_highlight + call ale#highlight#nvim_buf_clear_namespace(bufnr(''), s:ns_id, 0, -1) + else + for l:match in getmatches() + if l:match.group =~? '\v^ALE(Style)?(Error|Warning|Info)(Line)?$' + call matchdelete(l:match.id) + endif + endfor + endif +endfunction + +" Same semantics of matchaddpos but will use nvim_buf_add_highlight if +" available. This involves iterating over the position list, switching from +" 1-based indexing to 0-based indexing, and translating the multiple ways +" that position can be specified for matchaddpos into line + col_start + +" col_end. +function! s:matchaddpos(group, pos_list) abort + if s:has_nvim_highlight + for l:pos in a:pos_list + let l:line = type(l:pos) == v:t_number + \ ? l:pos - 1 + \ : l:pos[0] - 1 + + if type(l:pos) == v:t_number || len(l:pos) == 1 + let l:col_start = 0 + let l:col_end = s:MAX_COL_SIZE + else + let l:col_start = l:pos[1] - 1 + let l:col_end = l:col_start + get(l:pos, 2, 1) + endif + + call ale#highlight#nvim_buf_add_highlight( + \ bufnr(''), + \ s:ns_id, + \ a:group, + \ l:line, + \ l:col_start, + \ l:col_end, + \) + endfor + else + call matchaddpos(a:group, a:pos_list) + endif endfunction function! s:highlight_line(bufnr, lnum, group) abort - call matchaddpos(a:group, [a:lnum]) + call s:matchaddpos(a:group, [a:lnum]) endfunction function! s:highlight_range(bufnr, range, group) abort @@ -72,7 +129,7 @@ function! s:highlight_range(bufnr, range, group) abort \ a:range.end_lnum, \ a:range.end_col \ ), - \ 'matchaddpos(a:group, v:val)' + \ 's:matchaddpos(a:group, v:val)' \) endfunction diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim index 78dcd3a2..a85f06e2 100644 --- a/sources_non_forked/ale/autoload/ale/linter.vim +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -12,9 +12,12 @@ let s:linters = {} let s:default_ale_linter_aliases = { \ 'Dockerfile': 'dockerfile', \ 'csh': 'sh', +\ 'javascriptreact': ['javascript', 'jsx'], \ 'plaintex': 'tex', \ 'rmarkdown': 'r', +\ 'rmd': 'r', \ 'systemverilog': 'verilog', +\ 'typescriptreact': ['typescript', 'tsx'], \ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'], \ 'vimwiki': 'markdown', \ 'vue': ['vue', 'javascript'], diff --git a/sources_non_forked/ale/autoload/ale/lsp.vim b/sources_non_forked/ale/autoload/ale/lsp.vim index 017096cd..2509174e 100644 --- a/sources_non_forked/ale/autoload/ale/lsp.vim +++ b/sources_non_forked/ale/autoload/ale/lsp.vim @@ -37,6 +37,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort \ 'init_queue': [], \ 'capabilities': { \ 'hover': 0, + \ 'rename': 0, \ 'references': 0, \ 'completion': 0, \ 'completion_trigger_characters': [], @@ -199,6 +200,10 @@ function! s:UpdateCapabilities(conn, capabilities) abort let a:conn.capabilities.references = 1 endif + if get(a:capabilities, 'renameProvider') is v:true + let a:conn.capabilities.rename = 1 + endif + if !empty(get(a:capabilities, 'completionProvider')) let a:conn.capabilities.completion = 1 endif @@ -317,6 +322,7 @@ function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort let l:conn.capabilities.completion_trigger_characters = ['.'] let l:conn.capabilities.definition = 1 let l:conn.capabilities.symbol_search = 1 + let l:conn.capabilities.rename = 1 endfunction function! s:SendInitMessage(conn) abort diff --git a/sources_non_forked/ale/autoload/ale/lsp/message.vim b/sources_non_forked/ale/autoload/ale/lsp/message.vim index b6b14a22..5b0cb8b7 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/message.vim @@ -162,3 +162,13 @@ function! ale#lsp#message#DidChangeConfiguration(buffer, config) abort \ 'settings': a:config, \}] endfunction + +function! ale#lsp#message#Rename(buffer, line, column, new_name) abort + return [0, 'textDocument/rename', { + \ 'textDocument': { + \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \ 'newName': a:new_name, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim index d6919516..b9fafaa0 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim @@ -36,12 +36,14 @@ function! ale#lsp#tsserver_message#Geterr(buffer) abort return [1, 'ts@geterr', {'files': [expand('#' . a:buffer . ':p')]}] endfunction -function! ale#lsp#tsserver_message#Completions(buffer, line, column, prefix) abort +function! ale#lsp#tsserver_message#Completions( +\ buffer, line, column, prefix, include_external) abort return [0, 'ts@completions', { \ 'line': a:line, \ 'offset': a:column, \ 'file': expand('#' . a:buffer . ':p'), \ 'prefix': a:prefix, + \ 'includeExternalModuleExports': a:include_external, \}] endfunction @@ -77,3 +79,27 @@ function! ale#lsp#tsserver_message#Quickinfo(buffer, line, column) abort \ 'file': expand('#' . a:buffer . ':p'), \}] endfunction + +function! ale#lsp#tsserver_message#Rename( +\ buffer, line, column, find_in_comments, find_in_strings) abort + return [0, 'ts@rename', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'arguments': { + \ 'findInComments': a:find_in_comments, + \ 'findInStrings': a:find_in_strings, + \ } + \}] +endfunction + +function! ale#lsp#tsserver_message#OrganizeImports(buffer) abort + return [0, 'ts@organizeImports', { + \ 'scope': { + \ 'type': 'file', + \ 'args': { + \ 'file': expand('#' . a:buffer . ':p'), + \ }, + \ }, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp_linter.vim b/sources_non_forked/ale/autoload/ale/lsp_linter.vim index 190a16b4..e4148ceb 100644 --- a/sources_non_forked/ale/autoload/ale/lsp_linter.vim +++ b/sources_non_forked/ale/autoload/ale/lsp_linter.vim @@ -130,6 +130,12 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort call s:HandleLSPErrorMessage(l:linter_name, a:response) elseif l:method is# 'textDocument/publishDiagnostics' call s:HandleLSPDiagnostics(a:conn_id, a:response) + elseif l:method is# 'window/showMessage' + call ale#lsp_window#HandleShowMessage( + \ s:lsp_linter_map[a:conn_id], + \ g:ale_lsp_show_message_format, + \ a:response.params + \) elseif get(a:response, 'type', '') is# 'event' \&& get(a:response, 'event', '') is# 'semanticDiag' call s:HandleTSServerDiagnostics(a:response, 'semantic') diff --git a/sources_non_forked/ale/autoload/ale/lsp_window.vim b/sources_non_forked/ale/autoload/ale/lsp_window.vim new file mode 100644 index 00000000..9a27f2f1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp_window.vim @@ -0,0 +1,58 @@ +" Author: suoto +" Description: Handling of window/* LSP methods, although right now only +" handles window/showMessage + +" Constants for message type codes +let s:LSP_MESSAGE_TYPE_DISABLED = 0 +let s:LSP_MESSAGE_TYPE_ERROR = 1 +let s:LSP_MESSAGE_TYPE_WARNING = 2 +let s:LSP_MESSAGE_TYPE_INFORMATION = 3 +let s:LSP_MESSAGE_TYPE_LOG = 4 + +" Translate strings from the user config to a number so we can check +" severities +let s:CFG_TO_LSP_SEVERITY = { +\ 'disabled': s:LSP_MESSAGE_TYPE_DISABLED, +\ 'error': s:LSP_MESSAGE_TYPE_ERROR, +\ 'warning': s:LSP_MESSAGE_TYPE_WARNING, +\ 'information': s:LSP_MESSAGE_TYPE_INFORMATION, +\ 'info': s:LSP_MESSAGE_TYPE_INFORMATION, +\ 'log': s:LSP_MESSAGE_TYPE_LOG +\} + +" Handle window/showMessage response. +" - details: dict containing linter name and format (g:ale_lsp_show_message_format) +" - params: dict with the params for the call in the form of {type: number, message: string} +function! ale#lsp_window#HandleShowMessage(linter_name, format, params) abort + let l:message = a:params.message + let l:type = a:params.type + + " Get the configured severity level threshold and check if the message + " should be displayed or not + let l:configured_severity = tolower(get(g:, 'ale_lsp_show_message_severity', 'error')) + " If the user has configured with a value we can't find on the conversion + " dict, fall back to warning + let l:cfg_severity_threshold = get(s:CFG_TO_LSP_SEVERITY, l:configured_severity, s:LSP_MESSAGE_TYPE_WARNING) + + if l:type > l:cfg_severity_threshold + return + endif + + " Severity will depend on the message type + if l:type is# s:LSP_MESSAGE_TYPE_ERROR + let l:severity = g:ale_echo_msg_error_str + elseif l:type is# s:LSP_MESSAGE_TYPE_INFORMATION + let l:severity = g:ale_echo_msg_info_str + elseif l:type is# s:LSP_MESSAGE_TYPE_LOG + let l:severity = g:ale_echo_msg_log_str + else + " Default to warning just in case + let l:severity = g:ale_echo_msg_warning_str + endif + + let l:string = substitute(a:format, '\V%severity%', l:severity, 'g') + let l:string = substitute(l:string, '\V%linter%', a:linter_name, 'g') + let l:string = substitute(l:string, '\V%s\>', l:message, 'g') + + call ale#util#ShowMessage(l:string) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/organize_imports.vim b/sources_non_forked/ale/autoload/ale/organize_imports.vim new file mode 100644 index 00000000..bc9b829e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/organize_imports.vim @@ -0,0 +1,59 @@ +" Author: Jerko Steiner +" Description: Organize imports support for tsserver +" +function! ale#organize_imports#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') isnot# 'organizeImports' + return + endif + + if get(a:response, 'success', v:false) isnot v:true + return + endif + + let l:file_code_edits = a:response.body + + call ale#code_action#HandleCodeAction({ + \ 'description': 'Organize Imports', + \ 'changes': l:file_code_edits, + \}) +endfunction + +function! s:OnReady(linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if a:linter.lsp isnot# 'tsserver' + call ale#util#Execute('echom ''OrganizeImports currently only works with tsserver''') + + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = function('ale#organize_imports#HandleTSServerResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:message = ale#lsp#tsserver_message#OrganizeImports(l:buffer) + + let l:request_id = ale#lsp#Send(l:id, l:message) +endfunction + +function! s:OrganizeImports(linter) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + + if a:linter.lsp isnot# 'tsserver' + let l:column = min([l:column, len(getline(l:line))]) + endif + + let l:Callback = function('s:OnReady') + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#organize_imports#Execute() abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call s:OrganizeImports(l:linter) + endif + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/path.vim b/sources_non_forked/ale/autoload/ale/path.vim index 84c26d0a..30550503 100644 --- a/sources_non_forked/ale/autoload/ale/path.vim +++ b/sources_non_forked/ale/autoload/ale/path.vim @@ -54,14 +54,14 @@ function! ale#path#FindNearestDirectory(buffer, directory_name) abort return '' endfunction -" Given a buffer, a string to search for, an a global fallback for when +" Given a buffer, a string to search for, and a global fallback for when " the search fails, look for a file in parent paths, and if that fails, " use the global fallback path instead. function! ale#path#ResolveLocalPath(buffer, search_string, global_fallback) abort " Search for a locally installed file first. let l:path = ale#path#FindNearestFile(a:buffer, a:search_string) - " If the serach fails, try the global executable instead. + " If the search fails, try the global executable instead. if empty(l:path) let l:path = a:global_fallback endif diff --git a/sources_non_forked/ale/autoload/ale/rename.vim b/sources_non_forked/ale/autoload/ale/rename.vim new file mode 100644 index 00000000..02b7b579 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/rename.vim @@ -0,0 +1,225 @@ +" Author: Jerko Steiner +" Description: Rename symbol support for LSP / tsserver + +let s:rename_map = {} + +" Used to get the rename map in tests. +function! ale#rename#GetMap() abort + return deepcopy(s:rename_map) +endfunction + +" Used to set the rename map in tests. +function! ale#rename#SetMap(map) abort + let s:rename_map = a:map +endfunction + +function! ale#rename#ClearLSPData() abort + let s:rename_map = {} +endfunction + +let g:ale_rename_tsserver_find_in_comments = get(g:, 'ale_rename_tsserver_find_in_comments') +let g:ale_rename_tsserver_find_in_strings = get(g:, 'ale_rename_tsserver_find_in_strings') + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +function! ale#rename#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') isnot# 'rename' + return + endif + + if !has_key(s:rename_map, a:response.request_seq) + return + endif + + let l:old_name = s:rename_map[a:response.request_seq].old_name + let l:new_name = s:rename_map[a:response.request_seq].new_name + call remove(s:rename_map, a:response.request_seq) + + if get(a:response, 'success', v:false) is v:false + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error renaming "' . l:old_name . '" to: "' . l:new_name + \ . '". Reason: ' . l:message) + + return + endif + + let l:changes = [] + + for l:response_item in a:response.body.locs + let l:filename = l:response_item.file + let l:text_changes = [] + + for l:loc in l:response_item.locs + call add(l:text_changes, { + \ 'start': { + \ 'line': l:loc.start.line, + \ 'offset': l:loc.start.offset, + \ }, + \ 'end': { + \ 'line': l:loc.end.line, + \ 'offset': l:loc.end.offset, + \ }, + \ 'newText': l:new_name, + \}) + endfor + + call add(l:changes, { + \ 'fileName': l:filename, + \ 'textChanges': l:text_changes, + \}) + endfor + + if empty(l:changes) + call s:message('Error renaming "' . l:old_name . '" to: "' . l:new_name . '"') + + return + endif + + call ale#code_action#HandleCodeAction({ + \ 'description': 'rename', + \ 'changes': l:changes, + \}) +endfunction + +function! ale#rename#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:rename_map, a:response.id) + call remove(s:rename_map, a:response.id) + + if !has_key(a:response, 'result') + call s:message('No rename result received from server') + + return + endif + + let l:workspace_edit = a:response.result + + if !has_key(l:workspace_edit, 'changes') || empty(l:workspace_edit.changes) + call s:message('No changes received from server') + + return + endif + + let l:changes = [] + + for l:file_name in keys(l:workspace_edit.changes) + let l:text_edits = l:workspace_edit.changes[l:file_name] + let l:text_changes = [] + + for l:edit in l:text_edits + let l:range = l:edit.range + let l:new_text = l:edit.newText + + call add(l:text_changes, { + \ 'start': { + \ 'line': l:range.start.line + 1, + \ 'offset': l:range.start.character + 1, + \ }, + \ 'end': { + \ 'line': l:range.end.line + 1, + \ 'offset': l:range.end.character + 1, + \ }, + \ 'newText': l:new_text, + \}) + endfor + + call add(l:changes, { + \ 'fileName': ale#path#FromURI(l:file_name), + \ 'textChanges': l:text_changes, + \}) + endfor + + call ale#code_action#HandleCodeAction({ + \ 'description': 'rename', + \ 'changes': l:changes, + \}) + endif +endfunction + +function! s:OnReady(line, column, old_name, new_name, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'rename') + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#rename#HandleTSServerResponse') + \ : function('ale#rename#HandleLSPResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#Rename( + \ l:buffer, + \ a:line, + \ a:column, + \ g:ale_rename_tsserver_find_in_comments, + \ g:ale_rename_tsserver_find_in_strings, + \) + else + " Send a message saying the buffer has changed first, or the + " rename position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:message = ale#lsp#message#Rename( + \ l:buffer, + \ a:line, + \ a:column, + \ a:new_name + \) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:rename_map[l:request_id] = { + \ 'new_name': a:new_name, + \ 'old_name': a:old_name, + \} +endfunction + +function! s:ExecuteRename(linter, old_name, new_name) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + + if a:linter.lsp isnot# 'tsserver' + let l:column = min([l:column, len(getline(l:line))]) + endif + + let l:Callback = function( + \ 's:OnReady', [l:line, l:column, a:old_name, a:new_name]) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#rename#Execute() abort + let l:lsp_linters = [] + + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call add(l:lsp_linters, l:linter) + endif + endfor + + if empty(l:lsp_linters) + call s:message('No active LSPs') + + return + endif + + let l:old_name = expand('') + let l:new_name = ale#util#Input('New name: ', l:old_name) + + if empty(l:new_name) + call s:message('New name cannot be empty!') + + return + endif + + for l:lsp_linter in l:lsp_linters + call s:ExecuteRename(l:lsp_linter, l:old_name, l:new_name) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/ruby.vim b/sources_non_forked/ale/autoload/ale/ruby.vim index 15e835c9..d941bb2c 100644 --- a/sources_non_forked/ale/autoload/ale/ruby.vim +++ b/sources_non_forked/ale/autoload/ale/ruby.vim @@ -74,3 +74,10 @@ function! ale#ruby#HandleRubocopOutput(buffer, lines) abort return l:output endfunction +function! ale#ruby#EscapeExecutable(executable, bundle_exec) abort + let l:exec_args = a:executable =~? 'bundle' + \ ? ' exec ' . a:bundle_exec + \ : '' + + return ale#Escape(a:executable) . l:exec_args +endfunction diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim index eb0dd1cd..db0e1ab6 100644 --- a/sources_non_forked/ale/autoload/ale/sign.vim +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -14,12 +14,16 @@ let g:ale_sign_style_error = get(g:, 'ale_sign_style_error', g:ale_sign_error) let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--') let g:ale_sign_style_warning = get(g:, 'ale_sign_style_warning', g:ale_sign_warning) let g:ale_sign_info = get(g:, 'ale_sign_info', g:ale_sign_warning) +let g:ale_sign_priority = get(g:, 'ale_sign_priority', 30) " This variable sets an offset which can be set for sign IDs. " This ID can be changed depending on what IDs are set for other plugins. " The dummy sign will use the ID exactly equal to the offset. let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) " This flag can be set to 1 to keep sign gutter always open 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')) if !hlexists('ALEErrorSign') highlight link ALEErrorSign error @@ -82,7 +86,7 @@ execute 'sign define ALEInfoSign text=' . s:EscapeSignText(g:ale_sign_info) \ . ' texthl=ALEInfoSign linehl=ALEInfoLine' sign define ALEDummySign -if has('nvim-0.3.2') +if g:ale_sign_highlight_linenrs && has('nvim-0.3.2') if !hlexists('ALEErrorSignLineNr') highlight link ALEErrorSignLineNr CursorLineNr endif @@ -146,24 +150,59 @@ function! ale#sign#GetSignName(sublist) abort return 'ALEErrorSign' endfunction +function! s:PriorityCmd() abort + if s:supports_sign_groups + return ' priority=' . g:ale_sign_priority . ' ' + else + return '' + endif +endfunction + +function! s:GroupCmd() abort + if s:supports_sign_groups + return ' group=ale ' + else + return ' ' + endif +endfunction + " Read sign data for a buffer to a list of lines. function! ale#sign#ReadSigns(buffer) abort redir => l:output - silent execute 'sign place buffer=' . a:buffer + silent execute 'sign place ' . s:GroupCmd() . s:PriorityCmd() + \ . ' buffer=' . a:buffer redir end return split(l:output, "\n") endfunction +function! ale#sign#ParsePattern() abort + if s:supports_sign_groups + " Matches output like : + " line=4 id=1 group=ale name=ALEErrorSign + " строка=1 id=1000001 группа=ale имя=ALEErrorSign + " 行=1 識別子=1000001 グループ=ale 名前=ALEWarningSign + " línea=12 id=1000001 grupo=ale nombre=ALEWarningSign + " riga=1 id=1000001 gruppo=ale nome=ALEWarningSign + " Zeile=235 id=1000001 Gruppe=ale Name=ALEErrorSign + let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=ale>.*\=(ALE[a-zA-Z]+Sign)' + else + " Matches output like : + " line=4 id=1 name=ALEErrorSign + " строка=1 id=1000001 имя=ALEErrorSign + " 行=1 識別子=1000001 名前=ALEWarningSign + " línea=12 id=1000001 nombre=ALEWarningSign + " riga=1 id=1000001 nome=ALEWarningSign + " Zeile=235 id=1000001 Name=ALEErrorSign + let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=(ALE[a-zA-Z]+Sign)' + endif + + return l:pattern +endfunction + " Given a list of lines for sign output, return a List of [line, id, group] function! ale#sign#ParseSigns(line_list) abort - " Matches output like : - " line=4 id=1 name=ALEErrorSign - " строка=1 id=1000001 имя=ALEErrorSign - " 行=1 識別子=1000001 名前=ALEWarningSign - " línea=12 id=1000001 nombre=ALEWarningSign - " riga=1 id=1000001, nome=ALEWarningSign - let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=(ALE[a-zA-Z]+Sign)' + let l:pattern =ale#sign#ParsePattern() let l:result = [] let l:is_dummy_sign_set = 0 @@ -318,8 +357,10 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort if !l:is_dummy_sign_set && (!empty(a:sign_map) || g:ale_sign_column_always) call add(l:command_list, 'sign place ' \ . g:ale_sign_offset - \ . ' line=1 name=ALEDummySign buffer=' - \ . a:buffer + \ . s:GroupCmd() + \ . s:PriorityCmd() + \ . ' line=1 name=ALEDummySign ' + \ . ' buffer=' . a:buffer \) let l:is_dummy_sign_set = 1 endif @@ -336,6 +377,8 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort if index(l:info.current_id_list, l:info.new_id) < 0 call add(l:command_list, 'sign place ' \ . (l:info.new_id) + \ . s:GroupCmd() + \ . s:PriorityCmd() \ . ' line=' . l:line_str \ . ' name=' . (l:info.new_name) \ . ' buffer=' . a:buffer @@ -350,6 +393,7 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort if l:current_id isnot l:info.new_id call add(l:command_list, 'sign unplace ' \ . l:current_id + \ . s:GroupCmd() \ . ' buffer=' . a:buffer \) endif @@ -360,6 +404,7 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort if l:is_dummy_sign_set && !g:ale_sign_column_always call add(l:command_list, 'sign unplace ' \ . g:ale_sign_offset + \ . s:GroupCmd() \ . ' buffer=' . a:buffer \) endif @@ -414,3 +459,12 @@ function! ale#sign#SetSigns(buffer, loclist) abort highlight link SignColumn ALESignColumnWithoutErrors endif endfunction + +" Remove all signs. +function! ale#sign#Clear() abort + if s:supports_sign_groups + sign unplace group=ale * + else + sign unplace * + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index e7563608..99cd856a 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -477,3 +477,6 @@ function! ale#util#FindItemAtCursor(buffer) abort return [l:info, l:loc] endfunction +function! ale#util#Input(message, value) abort + return input(a:message, a:value) +endfunction diff --git a/sources_non_forked/ale/doc/ale-cs.txt b/sources_non_forked/ale/doc/ale-cs.txt index abcc43eb..bb13863f 100644 --- a/sources_non_forked/ale/doc/ale-cs.txt +++ b/sources_non_forked/ale/doc/ale-cs.txt @@ -11,22 +11,21 @@ csc *ale-cs-csc* The |ale-cs-csc| linter checks for semantic errors when files are opened or saved. - + See |ale-lint-file-linters| for more information on linters which do not check for problems while you type. - The csc linter uses the mono csc compiler providing full c# 7 and newer - support to generate a temporary module target file (/t:module). The module - includes including all '*.cs' files contained in the directory tree rooted - at the path defined by the |g:ale_cs_csc_source| or |b:ale_cs_csc_source| - variabl and all sub directories. - + The csc linter uses the mono csc compiler, providing full C# 7 and newer + support, to generate a temporary module target file (/t:module). The module + includes all '*.cs' files contained in the directory tree rooted at the path + defined by the |g:ale_cs_csc_source| or |b:ale_cs_csc_source| variable and + all sub directories. + It will in future replace the |ale-cs-mcs| and |ale-cs-mcsc| linters as both - utilizer the mcsc compiler which according to mono porject ist further - developed and as of writint these lines only receives maintenance updates. - The down is that the csc compiler does not support the -sytax option any more - and therefore |ale-cs-csc| linter doese not offer any as you type syntax - checking like the |ale-cs-mcsc| linter doesn't. + utilize the mcsc compiler which, according to the mono project, is no longer + actively developed, and only receives maintenance updates. However, because + the csc compiler does not support the -syntax option, this linter does not + offer any as-you-type syntax checking, similar to the |ale-cs-mcsc| linter. The paths to search for additional assembly files can be specified using the |g:ale_cs_csc_assembly_path| or |b:ale_cs_csc_assembly_path| variables. diff --git a/sources_non_forked/ale/doc/ale-d.txt b/sources_non_forked/ale/doc/ale-d.txt index 55596062..72349a20 100644 --- a/sources_non_forked/ale/doc/ale-d.txt +++ b/sources_non_forked/ale/doc/ale-d.txt @@ -1,6 +1,15 @@ =============================================================================== ALE D Integration *ale-d-options* +=============================================================================== +dfmt *ale-d-dfmt* + +g:ale_d_dfmt_options *g:ale_d_dfmt_options* + *b:ale_d_dfmt_options* + Type: |String| + Default: `''` + +This variable can be set to pass additional options to the dfmt fixer. =============================================================================== dls *ale-d-dls* diff --git a/sources_non_forked/ale/doc/ale-development.txt b/sources_non_forked/ale/doc/ale-development.txt index 16b16483..faa570c1 100644 --- a/sources_non_forked/ale/doc/ale-development.txt +++ b/sources_non_forked/ale/doc/ale-development.txt @@ -184,13 +184,12 @@ tests: https://github.com/junegunn/vader.vim See |ale-development-linter-tests| for more information on how to write linter tests. -When you add new linters or fixers, make sure to add them into the table in -the README, and also into the |ale-support| list in the main help file. If you -forget to keep them both in sync, you should see an error like the following -in Travis CI. > - +When you add new linters or fixers, make sure to add them into the tables in +supported-tools.md and |ale-supported-languages-and-tools.txt|. If you forget to +keep them both in sync, you should see an error like the following in Travis CI. +> ======================================== - diff README.md and doc/ale.txt tables + diff supported-tools.md and doc/ale-supported-languages-and-tools.txt tables ======================================== Differences follow: diff --git a/sources_non_forked/ale/doc/ale-elm.txt b/sources_non_forked/ale/doc/ale-elm.txt index 823b53e1..b1510241 100644 --- a/sources_non_forked/ale/doc/ale-elm.txt +++ b/sources_non_forked/ale/doc/ale-elm.txt @@ -50,7 +50,7 @@ g:ale_elm_ls_use_global *g:ale_elm_ls_use_global* g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path* *b:ale_elm_ls_elm_path* Type: |String| - Default: `'elm'` + Default: `''` See |ale-integrations-local-executables| @@ -58,7 +58,7 @@ g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path* g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path* *b:ale_elm_ls_elm_format_path* Type: |String| - Default: `'elm-format'` + Default: `''` See |ale-integrations-local-executables| @@ -66,10 +66,18 @@ g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path* g:ale_elm_ls_elm_test_path *g:ale_elm_ls_elm_test_path* *b:ale_elm_ls_elm_test_path* Type: |String| - Default: `'elm-test'` + Default: `''` See |ale-integrations-local-executables| + +g:ale_elm_ls_elm_analyse_trigger *g:ale_elm_ls_elm_analyse_trigger* + *b:ale_elm_ls_elm_analyse_trigger* + Type: |String| + Default: `'change'` + + One of 'change', 'save' or 'never' + =============================================================================== elm-make *ale-elm-elm-make* diff --git a/sources_non_forked/ale/doc/ale-html.txt b/sources_non_forked/ale/doc/ale-html.txt index 5d6b20e2..c78dc4cd 100644 --- a/sources_non_forked/ale/doc/ale-html.txt +++ b/sources_non_forked/ale/doc/ale-html.txt @@ -9,6 +9,16 @@ fecs *ale-html-fecs* and both of them reads `./.fecsrc` as the default configuration file. See: |ale-javascript-fecs|. +=============================================================================== +html-beautify *ale-html-beautify* + +g:ale_html_beautify_options *g:ale_html_beautify_options* + *b:ale_html_beautify_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to html-beautify. + =============================================================================== htmlhint *ale-html-htmlhint* diff --git a/sources_non_forked/ale/doc/ale-ink.txt b/sources_non_forked/ale/doc/ale-ink.txt new file mode 100644 index 00000000..9412a09f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-ink.txt @@ -0,0 +1,40 @@ +=============================================================================== +ALE Ink Integration *ale-ink-options* + + +=============================================================================== +ink-language-server *ale-ink-language-server* + +Ink Language Server + (https://github.com/ephraim/ink-language-server) + +g:ale_ink_ls_executable g:ale_ink_ls_executable + b:ale_ink_ls_executable + Type: |String| + Default: `'ink-language-server'` + + Ink language server executable. + +g:ale_ink_ls_initialization_options + g:ale_ink_ls_initialization_options + b:ale_ink_ls_initialization_options + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server at startup. For certain platforms and certain story + structures, the defaults will suffice. However, many projects will need to + change these settings - see the ink-language-server website for more + information. + + An example of setting non-default options: + { + \ 'ink': { + \ 'mainStoryPath': 'init.ink', + \ 'inklecateExecutablePath': '/usr/local/bin/inklecate', + \ 'runThroughMono': v:false + \ } + \} + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nim.txt b/sources_non_forked/ale/doc/ale-nim.txt new file mode 100644 index 00000000..8985aeb8 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nim.txt @@ -0,0 +1,45 @@ +=============================================================================== +ALE Nim Integration *ale-nim-options* + + +=============================================================================== +nimcheck *ale-nim-nimcheck* + + ALE does not provide additional configuration options for `nimcheck` at this + point. + + +=============================================================================== +nimlsp *ale-nim-nimlsp* + +g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources* + + Type: |String| + Default: `''` + + Sets the path to Nim source repository as the first argument to `nimlsp` + command. + + +=============================================================================== +nimpretty *ale-nim-nimpretty* + + +g:ale_nim_nimpretty_executable *g:ale_nim_nimpretty_executable* + *b:ale_nim_nimpretty_executable* + Type: |String| + Default: `'nimpretty'` + + This variable can be changed to use a different executable for nimpretty. + + +g:ale_nim_nimpretty_options *g:ale_nim_nimpretty_options* + *b:ale_nim_nimpretty_options* + Type: |String| + Default: `'--maxLineLen:80'` + + This variable can be changed to modify flags given to nimpretty. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nix.txt b/sources_non_forked/ale/doc/ale-nix.txt new file mode 100644 index 00000000..5b2bd6cb --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nix.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Nix Integration *ale-nix-options* + + +=============================================================================== +nixpkgs-fmt *ale-nix-nixpkgs-fmt* + +g:ale_nix_nixpkgsfmt_executable *g:ale_nix_nixpkgsfmt_executable* + *b:ale_nix_nixpkgsfmt_executable* + Type: |String| + Default: `'nixpkgs-fmt'` + + This variable sets executable used for nixpkgs-fmt. + +g:ale_nix_nixpkgsfmt_options *g:ale_nix_nixpkgsfmt_options* + *b:ale_nix_nixpkgsfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the nixpkgs-fmt fixer. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-php.txt b/sources_non_forked/ale/doc/ale-php.txt index d41fb50d..645decd7 100644 --- a/sources_non_forked/ale/doc/ale-php.txt +++ b/sources_non_forked/ale/doc/ale-php.txt @@ -157,9 +157,9 @@ g:ale_php_phpstan_level *g:ale_php_phpstan_level* Type: |String| Default: `''` - This variable controls the rule levels. 0 is the loosest and 4 is the + This variable controls the rule levels. 0 is the loosest and 7 is the strictest. If this option isn't set, the rule level will be controlled by - the configuration file. If no configuration file can be detected, `'4'` will + the configuration file. If no configuration file can be detected, `'7'` will be used instead. @@ -189,6 +189,13 @@ g:ale_php_psalm_executable *g:ale_php_psalm_executable* This variable sets the executable used for psalm. +g:ale_psalm_langserver_options *g:ale_psalm_langserver_options* + *b:ale_psalm_langserver_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to psalm. + =============================================================================== php-cs-fixer *ale-php-php-cs-fixer* diff --git a/sources_non_forked/ale/doc/ale-purescript.txt b/sources_non_forked/ale/doc/ale-purescript.txt index 33fd2429..e809f2c9 100644 --- a/sources_non_forked/ale/doc/ale-purescript.txt +++ b/sources_non_forked/ale/doc/ale-purescript.txt @@ -29,5 +29,14 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config \ 'buildCommand': 'spago build -- --json-errors' \ } \} +=============================================================================== +purty *ale-purescript-purty* + +g:ale_purescript_purty_executable *g:ale_purescript_purty_executable* + *b:ale_purescript_purty_executable* + Type: |String| + Default: `'purty'` + + This variable can be changed to use a different executable for purty. =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-ruby.txt b/sources_non_forked/ale/doc/ale-ruby.txt index e373ab8e..a27a20b2 100644 --- a/sources_non_forked/ale/doc/ale-ruby.txt +++ b/sources_non_forked/ale/doc/ale-ruby.txt @@ -21,6 +21,26 @@ g:ale_ruby_brakeman_options *g:ale_ruby_brakeman_options* The contents of this variable will be passed through to brakeman. +=============================================================================== +debride *ale-ruby-debride* + +g:ale_ruby_debride_executable *g:ale_ruby_debride_executable* + *b:ale_ruby_debride_executable* + Type: String + Default: `'debride'` + + Override the invoked debride binary. Set this to `'bundle'` to invoke + `'bundle` `exec` debride'. + + +g:ale_ruby_debride_options *g:ale_ruby_debride_options* + *b:ale_ruby_debride_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to debride. + + =============================================================================== rails_best_practices *ale-ruby-rails_best_practices* @@ -91,7 +111,7 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options* Type: |String| Default: `''` - This variable can be change to modify flags given to rubocop. + This variable can be changed to modify flags given to rubocop. =============================================================================== @@ -146,7 +166,7 @@ g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options* Type: |String| Default: `''` - This variable can be change to modify flags given to sorbet. + This variable can be changed to modify flags given to sorbet. =============================================================================== @@ -166,7 +186,7 @@ g:ale_ruby_standardrb_options *g:ale_ruby_standardrb_options* Type: |String| Default: `''` - This variable can be change to modify flags given to standardrb. + This variable can be changed to modify flags given to standardrb. =============================================================================== diff --git a/sources_non_forked/ale/doc/ale-scala.txt b/sources_non_forked/ale/doc/ale-scala.txt index ff43cd6c..c9638baf 100644 --- a/sources_non_forked/ale/doc/ale-scala.txt +++ b/sources_non_forked/ale/doc/ale-scala.txt @@ -2,6 +2,32 @@ ALE Scala Integration *ale-scala-options* +=============================================================================== +metals *ale-scala-metals* + +`metals` requires either an SBT project, a Mill project, or a running Bloop +server. + + +g:ale_scala_metals_executable *g:ale_scala_metals_executable* + *b:ale_scala_metals_executable* + Type: |String| + Default: `'metals-vim'` + + Override the invoked `metals` binary. + + +g:ale_scala_metals_project_root *g:ale_scala_metals_project_root* + *b:ale_scala_metals_project_root* + Type: |String| + Default: `''` + + By default the project root is found by searching upwards for `build.sbt`, + `build.sc`, `.bloop` or `.metals`. + If the project root is elsewhere, you can override the project root + directory. + + =============================================================================== sbtserver *ale-scala-sbtserver* diff --git a/sources_non_forked/ale/doc/ale-solidity.txt b/sources_non_forked/ale/doc/ale-solidity.txt index 4b74a27a..b6e48675 100644 --- a/sources_non_forked/ale/doc/ale-solidity.txt +++ b/sources_non_forked/ale/doc/ale-solidity.txt @@ -2,6 +2,18 @@ ALE Solidity Integration *ale-solidity-options* +=============================================================================== +solc *ale-solidity-solc* + + +g:ale_solidity_solc_options *g:ale_solidity_solc_options* + *b:ale_solidity_solc_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to solc. + + =============================================================================== solhint *ale-solidity-solhint* diff --git a/sources_non_forked/ale/doc/ale-sql.txt b/sources_non_forked/ale/doc/ale-sql.txt index f9bc6ac2..2807271b 100644 --- a/sources_non_forked/ale/doc/ale-sql.txt +++ b/sources_non_forked/ale/doc/ale-sql.txt @@ -39,5 +39,23 @@ g:ale_sql_sqlfmt_options *g:ale_sql_sqlfmt_options* At this time only the -u flag is available to format with upper-case. +=============================================================================== +sqlformat *ale-sql-sqlformat* + +g:ale_sql_sqlformat_executable *g:ale_sql_sqlformat_executable* + *b:ale_sql_sqlformat_executable* + Type: |String| + Default: `'sqlformat'` + + This variable sets executable used for sqlformat. + +g:ale_sql_sqlformat_options *g:ale_sql_sqlformat_options* + *b:ale_sql_sqlformat_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the sqlformat fixer. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: 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 37345f7b..29dabab7 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 @@ -103,6 +103,7 @@ Notes: * Cython (pyrex filetype) * `cython` * D + * `dfmt` * `dls` * `dmd` * `uncrustify` @@ -123,7 +124,7 @@ Notes: * `mix`!! * Elm * `elm-format` - * `elm-lsp` + * `elm-ls` * `elm-make` * Erb * `erb` @@ -193,6 +194,7 @@ Notes: * HTML * `alex`!! * `fecs` + * `html-beautify` * `HTMLHint` * `prettier` * `proselint` @@ -200,6 +202,8 @@ Notes: * `write-good` * Idris * `idris` +* Ink + * `ink-language-server` * ISPC * `ispc`!! * Java @@ -279,8 +283,11 @@ Notes: * `nasm`!! * Nim * `nim check`!! + * `nimlsp` + * `nimpretty` * nix * `nix-instantiate` + * `nixpkgs-fmt` * nroff * `alex`!! * `proselint` @@ -343,6 +350,7 @@ Notes: * `puppet-lint` * PureScript * `purescript-language-server` + * `purty` * Python * `autopep8` * `bandit` @@ -388,6 +396,7 @@ Notes: * `rpmlint` * Ruby * `brakeman` + * `debride` * `rails_best_practices`!! * `reek` * `rubocop` @@ -406,6 +415,7 @@ Notes: * `stylelint` * Scala * `fsc` + * `metals` * `sbtserver` * `scalac` * `scalafmt` @@ -420,11 +430,13 @@ Notes: * SML * `smlnj` * Solidity + * `solc` * `solhint` * `solium` * SQL * `pgformatter` * `sqlfmt` + * `sqlformat` * `sqlint` * Stylus * `stylelint` @@ -457,6 +469,7 @@ Notes: * `eslint` * `fecs` * `prettier` + * `standard` * `tslint` * `tsserver` * `typecheck` diff --git a/sources_non_forked/ale/doc/ale-typescript.txt b/sources_non_forked/ale/doc/ale-typescript.txt index 7dc59820..2c50d119 100644 --- a/sources_non_forked/ale/doc/ale-typescript.txt +++ b/sources_non_forked/ale/doc/ale-typescript.txt @@ -16,6 +16,33 @@ prettier *ale-typescript-prettier* See |ale-javascript-prettier| for information about the available options. +=============================================================================== +standard *ale-typescript-standard* + +g:ale_typescript_standard_executable *g:ale_typescript_standard_executable* + *b:ale_typescript_standard_executable* + Type: |String| + Default: `'standard'` + + See |ale-integrations-local-executables| + + +g:ale_typescript_standard_options *g:ale_typescript_standard_options* + *b:ale_typescript_standard_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to standard. + + +g:ale_typescript_standard_use_global *g:ale_typescript_standard_use_global* + *b:ale_typescript_standard_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== tslint *ale-typescript-tslint* diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index beca8546..847a9777 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -9,7 +9,8 @@ CONTENTS *ale-contents* 1. Introduction.........................|ale-introduction| 2. Supported Languages & Tools..........|ale-support| 3. Linting..............................|ale-lint| - 3.1 Other Sources.....................|ale-lint-other-sources| + 3.1 Adding Language Servers...........|ale-lint-language-servers| + 3.2 Other Sources.....................|ale-lint-other-sources| 4. Fixing Problems......................|ale-fix| 5. Language Server Protocol Support.....|ale-lsp| 5.1 Completion........................|ale-completion| @@ -147,7 +148,48 @@ ALE offers several options for controlling which linters are run. ------------------------------------------------------------------------------- -3.1 Other Sources *ale-lint-other-sources* +3.1 Adding Language Servers *ale-lint-language-servers* + +ALE comes with many default configurations for language servers, so they can +be detected and run automatically. ALE can connect to other language servers +by defining a new linter for a filetype. New linters can be defined in |vimrc|, +in plugin files, or `ale_linters` directories in |runtimepath|. + +See |ale-linter-loading-behavior| for more information on loading linters. + +A minimal configuration for a language server linter might look so. > + + call ale#linter#Define('filetype_here', { + \ 'name': 'any_name_you_want', + \ 'lsp': 'stdio', + \ 'executable': '/path/to/executable', + \ 'command': '%e run', + \ 'project_root': '/path/to/root_of_project', + \}) +< +For language servers that use a TCP socket connection, you should define the +address to connect to instead. > + + call ale#linter#Define('filetype_here', { + \ 'name': 'any_name_you_want', + \ 'lsp': 'socket', + \ 'address': 'servername:1234', + \ 'project_root': '/path/to/root_of_project', + \}) +< + Most of the options for a language server can be replaced with a |Funcref| + for a function accepting a buffer number for dynamically computing values + such as the executable path, the project path, the server address, etc, + most of which can also be determined based on executing some other + asynchronous task. See |ale#command#Run()| for computing linter options + based on asynchronous results. + + See |ale#linter#Define()| for a detailed explanation of all of the options + for configuring linters. + + +------------------------------------------------------------------------------- +3.2 Other Sources *ale-lint-other-sources* Problems for a buffer can be taken from other sources and rendered by ALE. This allows ALE to be used in combination with other plugins which also want @@ -376,6 +418,10 @@ The |ALEComplete| command can be used to show completion suggestions manually, even when |g:ale_completion_enabled| is set to `0`. For manually requesting completion information with Deoplete, consult Deoplete's documentation. +When working with TypeScript files, ALE by can support automatic imports +from external modules. This behavior can be enabled by setting the +|g:ale_completion_tsserver_autoimport| variable to `1`. + *ale-completion-completeopt-bug* ALE Automatic completion implementation replaces |completeopt| before opening @@ -386,7 +432,42 @@ vimrc, and your issues should go away. > set completeopt=menu,menuone,preview,noselect,noinsert < + *ale-symbols* +ALE provides a set of basic completion symbols. If you want to replace those +symbols with others, you can set the variable |g:ale_completion_symbols| with +a mapping of the type of completion to the symbol or other string that you +would like to use. An example here shows the available options for symbols > + + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'unit', + \ 'value': 'val', + \ 'enum': '', + \ 'keyword': 'keyword', + \ 'snippet': '', + \ 'color': 'color', + \ 'file': '', + \ 'reference': 'ref', + \ 'folder': '', + \ 'enum member': '', + \ 'constant': '', + \ 'struct': '', + \ 'event': 'event', + \ 'operator': '', + \ 'type_parameter': 'type param', + \ '': 'v' + \ } +< ------------------------------------------------------------------------------- 5.2 Go To Definition *ale-go-to-definition* @@ -597,6 +678,16 @@ b:ale_completion_enabled *b:ale_completion_enabled* See |ale-completion| +g:ale_completion_tsserver_autoimport *g:ale_completion_tsserver_autoimport* + + Type: Number + Default: `0` + + When this option is set to `0`, ALE will not try to automatically import + completion results from external modules. It can be enabled by setting it + to `1`. + + g:ale_completion_excluded_words *g:ale_completion_excluded_words* *b:ale_completion_excluded_words* Type: |List| @@ -615,6 +706,47 @@ g:ale_completion_excluded_words *g:ale_completion_excluded_words* let b:ale_completion_excluded_words = ['it', 'describe'] < +g:ale_completion_symbols *g:ale_completion_symbols* + + Type: |Dictionary| + + + A mapping from completion types to symbols for completions. See + |ale-symbols| for more information. + + By default, this mapping only uses built in Vim completion kinds, but it can + be updated to use any unicode character for the completion kind. For + example: > + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'v', + \ 'value': 'v', + \ 'enum': 't', + \ 'keyword': 'v', + \ 'snippet': 'v', + \ 'color': 'v', + \ 'file': 'v', + \ 'reference': 'v', + \ 'folder': 'v', + \ 'enum_member': 'm', + \ 'constant': 'm', + \ 'struct': 't', + \ 'event': 'v', + \ 'operator': 'f', + \ 'type_parameter': 'p', + \ '': 'v' + \ }) +< + g:ale_completion_max_suggestions *g:ale_completion_max_suggestions* Type: |Number| @@ -745,6 +877,15 @@ g:ale_echo_msg_info_str *g:ale_echo_msg_info_str* The string used for `%severity%` for info. See |g:ale_echo_msg_format| +g:ale_echo_msg_log_str *g:ale_echo_msg_log_str* + + Type: |String| + Default: `'Log'` + + The string used for `%severity%` for log, used only for handling LSP show + message requests. See |g:ale_lsp_show_message_format| + + g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str* Type: |String| @@ -1027,9 +1168,12 @@ g:ale_linter_aliases *g:ale_linter_aliases* { \ 'Dockerfile': 'dockerfile', \ 'csh': 'sh', + \ 'javascriptreact': ['javascript', 'jsx'], \ 'plaintex': 'tex', \ 'rmarkdown': 'r', + \ 'rmd': 'r', \ 'systemverilog': 'verilog', + \ 'typescriptreact': ['typescript', 'tsx'], \ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'], \ 'vimwiki': 'markdown', \ 'vue': ['vue', 'javascript'], @@ -1192,6 +1336,47 @@ b:ale_loclist_msg_format *b:ale_loclist_msg_format* The strings for configuring `%severity%` are also used for this option. + +g:ale_lsp_show_message_format *g:ale_lsp_show_message_format* + + Type: |String| + Default: `'%severity%:%linter%: %s'` + + This variable defines the format that messages received from an LSP will + have when echoed. The following sequences of characters will be replaced. + + `%s` - replaced with the message text + `%linter%` - replaced with the name of the linter + `%severity%` - replaced with the severity of the message + + The strings for `%severity%` levels "error", "info" and "warning" are shared + with |g:ale_echo_msg_format|. Severity "log" is unique to + |g:ale_lsp_show_message_format| and it can be configured via + + |g:ale_echo_msg_log_str| - Defaults to `'Log'` + + Please note that |g:ale_lsp_show_message_format| *can not* be configured + separately for each buffer like |g:ale_echo_msg_format| can. + + +g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* + + Type: |String| + Default: `'error'` + + This variable defines the minimum severity level an LSP message needs to be + displayed. Messages below this level are discarded; please note that + messages with `Log` severity level are always discarded. + + Possible values follow the LSP spec `MessageType` definition: + + `'error'` - Displays only errors. + `'warning'` - Displays errors and warnings. + `'information'` - Displays errors, warnings and infos + `'log'` - Same as `'information'` + `'disabled'` - Doesn't display any information at all. + + g:ale_lsp_root *g:ale_lsp_root* b:ale_lsp_root *b:ale_lsp_root* @@ -1317,6 +1502,27 @@ g:ale_pattern_options_enabled *g:ale_pattern_options_enabled* will not set buffer variables per |g:ale_pattern_options|. +g:ale_rename_tsserver_find_in_comments *g:ale_rename_tsserver_find_in_comments* + + Type: |Number| + Default: `0` + + If enabled, this option will tell tsserver to find and replace text in + comments when calling |ALERename|. It can be enabled by settings the value + to `1`. + + +g:ale_rename_tsserver_find_in_strings *g:ale_rename_tsserver_find_in_strings* + + + Type: |Number| + Default: `0` + + If enabled, this option will tell tsserver to find and replace text in + strings when calling |ALERename|. It can be enabled by settings the value to + `1`. + + g:ale_set_balloons *g:ale_set_balloons* *b:ale_set_balloons* @@ -1437,8 +1643,8 @@ g:ale_set_signs *g:ale_set_signs* |ALEWarningLine| - All items with `'type': 'W'` |ALEInfoLine| - All items with `'type': 'I'` - With Neovim 0.3.2 or higher, ALE uses `numhl` option to highlight 'number' - column. It uses the following highlight groups. + With Neovim 0.3.2 or higher, ALE can use the `numhl` option to highlight the + 'number' column. It uses the following highlight groups. |ALEErrorSignLineNr| - Items with `'type': 'E'` |ALEWarningSignLineNr| - Items with `'type': 'W'` @@ -1446,6 +1652,9 @@ g:ale_set_signs *g:ale_set_signs* |ALEStyleErrorSignLineNr| - Items with `'type': 'E'` and `'sub_type': 'style'` |ALEStyleWarningSignLineNr| - Items with `'type': 'W'` and `'sub_type': 'style'` + To enable line number highlighting |g:ale_sign_highlight_linenrs| must be + set to `1` before ALE is loaded. + The markers for the highlights can be customized with the following options: |g:ale_sign_error| @@ -1460,6 +1669,16 @@ g:ale_set_signs *g:ale_set_signs* To limit the number of signs ALE will set, see |g:ale_max_signs|. +g:ale_sign_priority *g:ale_sign_priority* + + Type: |Number| + Default: `30` + + From Neovim 0.4.0 and Vim 8.1, ALE can set sign priority to all signs. The + larger this value is, the higher priority ALE signs have over other plugin + signs. See |sign-priority| for further details on how priority works. + + g:ale_shell *g:ale_shell* Type: |String| @@ -1552,6 +1771,16 @@ g:ale_sign_warning *g:ale_sign_warning* The sign for warnings in the sign gutter. +g:ale_sign_highlight_linenrs *g:ale_sign_highlight_linenrs* + + Type: |Number| + Default: `0` + + When set to `1`, this option enables highlighting problems on the 'number' + column in Vim versions that support `numhl` highlights. This option must be + configured before ALE is loaded. + + g:ale_update_tagstack *g:ale_update_tagstack* *b:ale_update_tagstack* Type: |Number| @@ -1606,6 +1835,8 @@ g:ale_virtualtext_cursor *g:ale_virtualtext_cursor* Type: |Number| Default: `0` + This option only has any effect in NeoVim. + When this option is set to `1`, a message will be shown when a cursor is near a warning or error. ALE will attempt to find the warning or error at a column nearest to the cursor when the cursor is resting on a line which @@ -1954,6 +2185,14 @@ g:ale_languagetool_executable *g:ale_languagetool_executable* The executable to run for languagetool. +g:ale_languagetool_options *g:ale_languagetool_options* + *b:ale_languagetool_options* + Type: |String| + Default: `'--autoDetect'` + + This variable can be set to pass additional options to languagetool. + + ------------------------------------------------------------------------------- 7.3. Options for write-good *ale-write-good-options* @@ -2053,6 +2292,7 @@ documented in additional help files. nvcc..................................|ale-cuda-nvcc| clang-format..........................|ale-cuda-clangformat| d.......................................|ale-d-options| + dfmt..................................|ale-d-dfmt| dls...................................|ale-d-dls| uncrustify............................|ale-d-uncrustify| dart....................................|ale-dart-options| @@ -2129,6 +2369,7 @@ documented in additional help files. terraform-fmt.........................|ale-hcl-terraform-fmt| html....................................|ale-html-options| fecs..................................|ale-html-fecs| + html-beautify.........................|ale-html-beautify| htmlhint..............................|ale-html-htmlhint| tidy..................................|ale-html-tidy| prettier..............................|ale-html-prettier| @@ -2136,6 +2377,8 @@ documented in additional help files. write-good............................|ale-html-write-good| idris...................................|ale-idris-options| idris.................................|ale-idris-idris| + ink.....................................|ale-ink-options| + ink-language-server...................|ale-ink-language-server| ispc....................................|ale-ispc-options| ispc..................................|ale-ispc-ispc| java....................................|ale-java-options| @@ -2191,6 +2434,12 @@ documented in additional help files. mmc...................................|ale-mercury-mmc| nasm....................................|ale-nasm-options| nasm..................................|ale-nasm-nasm| + nim.....................................|ale-nim-options| + nimcheck..............................|ale-nim-nimcheck| + nimlsp................................|ale-nim-nimlsp| + nimpretty.............................|ale-nim-nimpretty| + nix.....................................|ale-nix-options| + nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt| nroff...................................|ale-nroff-options| write-good............................|ale-nroff-write-good| objc....................................|ale-objc-options| @@ -2246,6 +2495,7 @@ documented in additional help files. puppet-languageserver.................|ale-puppet-languageserver| purescript..............................|ale-purescript-options| purescript-language-server............|ale-purescript-language-server| + purty.................................|ale-purescript-purty| pyrex (cython)..........................|ale-pyrex-options| cython................................|ale-pyrex-cython| python..................................|ale-python-options| @@ -2281,6 +2531,7 @@ documented in additional help files. write-good............................|ale-restructuredtext-write-good| ruby....................................|ale-ruby-options| brakeman..............................|ale-ruby-brakeman| + debride...............................|ale-ruby-debride| rails_best_practices..................|ale-ruby-rails_best_practices| reek..................................|ale-ruby-reek| rubocop...............................|ale-ruby-rubocop| @@ -2298,6 +2549,7 @@ documented in additional help files. sasslint..............................|ale-sass-sasslint| stylelint.............................|ale-sass-stylelint| scala...................................|ale-scala-options| + metals................................|ale-scala-metals| sbtserver.............................|ale-scala-sbtserver| scalafmt..............................|ale-scala-scalafmt| scalastyle............................|ale-scala-scalastyle| @@ -2313,6 +2565,7 @@ documented in additional help files. sml.....................................|ale-sml-options| smlnj.................................|ale-sml-smlnj| solidity................................|ale-solidity-options| + solc..................................|ale-solidity-solc| solhint...............................|ale-solidity-solhint| solium................................|ale-solidity-solium| spec....................................|ale-spec-options| @@ -2320,6 +2573,7 @@ documented in additional help files. sql.....................................|ale-sql-options| pgformatter...........................|ale-sql-pgformatter| sqlfmt................................|ale-sql-sqlfmt| + sqlformat.............................|ale-sql-sqlformat| stylus..................................|ale-stylus-options| stylelint.............................|ale-stylus-stylelint| sugarss.................................|ale-sugarss-options| @@ -2347,6 +2601,7 @@ documented in additional help files. typescript..............................|ale-typescript-options| eslint................................|ale-typescript-eslint| prettier..............................|ale-typescript-prettier| + standard..............................|ale-typescript-standard| tslint................................|ale-typescript-tslint| tsserver..............................|ale-typescript-tsserver| vala....................................|ale-vala-options| @@ -2521,6 +2776,18 @@ ALEHover *ALEHover* A plug mapping `(ale_hover)` is defined for this command. +ALEOrganizeImports *ALEOrganizeImports* + + Organize imports using tsserver. Currently not implemented for LSPs. + + +ALERename *ALERename* + + Rename a symbol using TypeScript server or Language Server. + + The user will be prompted for a new name. + + ALESymbolSearch `` *ALESymbolSearch* Search for symbols in the workspace, taken from any available LSP linters. diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 6262a7c4..1912a9c0 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -221,6 +221,12 @@ command! -nargs=1 ALESymbolSearch :call ale#symbol#Search() command! -bar ALEComplete :call ale#completion#GetCompletions('ale-manual') +" Rename symbols using tsserver and LSP +command! -bar ALERename :call ale#rename#Execute() + +" Organize import statements using tsserver +command! -bar ALEOrganizeImports :call ale#organize_imports#Execute() + " mappings for commands nnoremap (ale_previous) :ALEPrevious nnoremap (ale_previous_wrap) :ALEPreviousWrap @@ -259,6 +265,7 @@ nnoremap (ale_find_references) :ALEFindReferences nnoremap (ale_hover) :ALEHover nnoremap (ale_documentation) :ALEDocumentation inoremap (ale_complete) :ALEComplete +nnoremap (ale_rename) :ALERename " 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 c933f510..0abc6b75 100644 --- a/sources_non_forked/ale/supported-tools.md +++ b/sources_non_forked/ale/supported-tools.md @@ -112,6 +112,7 @@ formatting. * Cython (pyrex filetype) * [cython](http://cython.org/) * D + * [dfmt](https://github.com/dlang-community/dfmt) * [dls](https://github.com/d-language-server/dls) * [dmd](https://dlang.org/dmd-linux.html) * [uncrustify](https://github.com/uncrustify/uncrustify) @@ -132,7 +133,7 @@ formatting. * [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk: * Elm * [elm-format](https://github.com/avh4/elm-format) - * [elm-lsp](https://github.com/antew/elm-lsp) + * [elm-ls](https://github.com/elm-tooling/elm-language-server) * [elm-make](https://github.com/elm/compiler) * Erb * [erb](https://apidock.com/ruby/ERB) @@ -202,6 +203,7 @@ formatting. * HTML * [alex](https://github.com/wooorm/alex) :floppy_disk: * [fecs](http://fecs.baidu.com/) + * [html-beautify](https://beautifier.io/) * [HTMLHint](http://htmlhint.com/) * [prettier](https://github.com/prettier/prettier) * [proselint](http://proselint.com/) @@ -209,6 +211,8 @@ formatting. * [write-good](https://github.com/btford/write-good) * Idris * [idris](http://www.idris-lang.org/) +* Ink + * [ink-language-server](https://github.com/ephread/ink-language-server) * ISPC * [ispc](https://ispc.github.io/) :floppy_disk: * Java @@ -223,7 +227,7 @@ formatting. * [eslint](http://eslint.org/) * [fecs](http://fecs.baidu.com/) * [flow](https://flowtype.org/) - * [jscs](http://jscs.info/) + * [jscs](https://jscs-dev.github.io/) * [jshint](http://jshint.com/) * [prettier](https://github.com/prettier/prettier) * [prettier-eslint](https://github.com/prettier/prettier-eslint-cli) @@ -248,7 +252,7 @@ formatting. * [lacheck](https://www.ctan.org/pkg/lacheck) * [proselint](http://proselint.com/) * [redpen](http://redpen.cc/) - * [texlab](https://texlab.netlify.com) ([Rust rewrite](https://github.com/latex-lsp/texlab/tree/rust)) + * [texlab](https://texlab.netlify.com) * [textlint](https://textlint.github.io/) * [vale](https://github.com/ValeLint/vale) * [write-good](https://github.com/btford/write-good) @@ -288,8 +292,11 @@ formatting. * [nasm](https://www.nasm.us/) :floppy_disk: * Nim * [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk: + * [nimlsp](https://github.com/PMunch/nimlsp) + * nimpretty * nix * [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) + * [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) * nroff * [alex](https://github.com/wooorm/alex) :floppy_disk: * [proselint](http://proselint.com/) @@ -338,8 +345,8 @@ formatting. * Pony * [ponyc](https://github.com/ponylang/ponyc) * PowerShell - * [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk - * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk + * [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk: + * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk: * Prolog * [swipl](https://github.com/SWI-Prolog/swipl-devel) * proto @@ -352,6 +359,7 @@ formatting. * [puppet-lint](https://puppet-lint.com) * PureScript * [purescript-language-server](https://github.com/nwolverson/purescript-language-server) + * [purty](https://gitlab.com/joneshf/purty) * Python * [autopep8](https://github.com/hhatto/autopep8) * [bandit](https://github.com/PyCQA/bandit) :warning: @@ -397,6 +405,7 @@ formatting. * [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`) * Ruby * [brakeman](http://brakemanscanner.org/) :floppy_disk: + * [debride](https://github.com/seattlerb/debride) :floppy_disk: * [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) :floppy_disk: * [reek](https://github.com/troessner/reek) * [rubocop](https://github.com/bbatsov/rubocop) @@ -415,6 +424,7 @@ formatting. * [stylelint](https://github.com/stylelint/stylelint) * Scala * [fsc](https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html) + * [metals](https://scalameta.org/metals/) * [sbtserver](https://www.scala-sbt.org/1.x/docs/sbt-server.html) * [scalac](http://scala-lang.org) * [scalafmt](https://scalameta.org/scalafmt/) @@ -429,11 +439,13 @@ formatting. * SML * [smlnj](http://www.smlnj.org/) * Solidity + * [solc](https://solidity.readthedocs.io/) * [solhint](https://github.com/protofire/solhint) * [solium](https://github.com/duaraghav8/Solium) * SQL * [pgformatter](https://github.com/darold/pgFormatter) * [sqlfmt](https://github.com/jackc/sqlfmt) + * [sqlformat](https://github.com/andialbrecht/sqlparse) * [sqlint](https://github.com/purcell/sqlint) * Stylus * [stylelint](https://github.com/stylelint/stylelint) @@ -466,6 +478,7 @@ formatting. * [eslint](http://eslint.org/) * [fecs](http://fecs.baidu.com/) * [prettier](https://github.com/prettier/prettier) + * [standard](http://standardjs.com/) * [tslint](https://github.com/palantir/tslint) * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) * typecheck diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim index 9d92cf1a..d1e23696 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim @@ -330,6 +330,7 @@ fu! s:Open() endf fu! s:Close() + cal s:async_glob_abort() cal s:buffunc(0) if winnr('$') == 1 bw! @@ -434,9 +435,62 @@ fu! s:GlobPath(dirs, depth) en endf -fu! ctrlp#addfile(ch, file) - call add(g:ctrlp_allfiles, a:file) - cal s:BuildPrompt(1) +fu! s:async_glob_update_progress(timer) + let s:must_wait = 0 + if exists('s:focus') && get(s:, 'setlines_post_ended', 0) + cal s:ForceUpdate() + en + if exists('s:timer') + sil! cal ctrlp#statusline() + endif + + if !exists('s:job') + call s:stop_timer_if_exists() + endif +endf + +fu! s:async_glob_on_stdout(job, data, ...) + if type(a:data) ==# type([]) + call extend(g:ctrlp_allfiles, filter(a:data, 'v:val !=# ""')) + else + call add(g:ctrlp_allfiles, a:data) + endif +endf + +fu! s:async_glob_on_exit(...) + let s:must_wait = 0 + if exists('s:job') + unlet s:job + endif + cal s:stop_timer_if_exists() + if exists('s:focus') && get(s:, 'setlines_post_ended', 0) + sil! cal ctrlp#statusline() + cal s:ForceUpdate() + en +endf + +fu! s:async_glob_abort() + cal s:stop_job_if_exists() + cal s:stop_timer_if_exists() + cal s:ForceUpdate() +endf + +fu! s:stop_timer_if_exists() + if exists('s:timer') + call timer_stop(s:timer) + unlet s:timer + en +endf + +fu! s:stop_job_if_exists() + if exists('s:job') + if !has('nvim') + cal job_stop(s:job) + else + cal jobstop(s:job) + endif + unlet s:job + en endf fu! s:safe_printf(format, ...) @@ -462,12 +516,26 @@ fu! s:UserCmd(lscmd) if (has('win32') || has('win64')) && match(&shell, 'sh') != -1 let path = tr(path, '\', '/') en - if s:usrcmdasync && v:version >= 800 && exists('*job_start') - if exists('s:job') - call job_stop(s:job) - en + if s:usrcmdasync && (v:version >= 800 || has('nvim')) && (exists('*job_start') || exists('*jobstart')) + cal s:stop_job_if_exists() let g:ctrlp_allfiles = [] - let s:job = job_start([&shell, &shellcmdflag, printf(lscmd, path)], {'callback': 'ctrlp#addfile'}) + let s:must_wait = 1 + let argv = [&shell, &shellcmdflag, printf(lscmd, path)] + if !has('nvim') + let s:job = job_start(argv, { + \ 'out_cb': function('s:async_glob_on_stdout'), + \ 'exit_cb': function('s:async_glob_on_exit') + \ }) + else + let s:job = jobstart(argv, { + \ 'on_stdout': function('s:async_glob_on_stdout'), + \ 'on_exit': function('s:async_glob_on_exit') + \ }) + endif + let s:timer = timer_start(250, function('s:async_glob_update_progress'), {'repeat': -1}) + while s:must_wait + sleep 50m + endwhile elsei has('patch-7.4-597') && !(has('win32') || has('win64')) let g:ctrlp_allfiles = systemlist(s:safe_printf(lscmd, path)) el @@ -997,7 +1065,7 @@ fu! s:MapSpecs() if !( exists('s:smapped') && s:smapped == s:bufnr ) " Correct arrow keys in terminal if ( has('termresponse') && v:termresponse =~ "\" ) - \ || &term =~? '\vxterm|','\B ','\C ','\D '] exe s:lcmap.' ['.each endfo @@ -1054,6 +1122,7 @@ fu! s:ToggleByFname() endf fu! s:ToggleType(dir) + cal s:async_glob_abort() let max = len(g:ctrlp_ext_vars) + len(s:coretypes) - 1 let next = s:walker(max, s:itemtype, a:dir) cal ctrlp#setlines(next) @@ -1563,6 +1632,9 @@ fu! ctrlp#statusline() let slider = ' <'.prv.'>={'.item.'}=<'.nxt.'>' let dir = ' %=%<%#CtrlPMode2# %{getcwd()} %*' let &l:stl = focus.byfname.regex.slider.marked.dir + if exists('s:timer') + let &l:stl = '%#CtrlPStats# '.len(g:ctrlp_allfiles).' '.&l:stl + en en endf @@ -2571,6 +2643,7 @@ endf fu! s:setlines_pre(...) if a:0 | let s:itemtype = a:1 | en cal s:modevar() + let s:setlines_post_ended = 0 let g:ctrlp_lines = [] endf @@ -2581,6 +2654,7 @@ fu! s:setlines_post() cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])') en let g:ctrlp_lines = eval(types[s:itemtype]) + let s:setlines_post_ended = 1 endf fu! ctrlp#setlines(...) diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx index d99c4c6c..32da378f 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx @@ -1439,7 +1439,7 @@ Before 2016/11/28~ + 新命令: |YankLine()| 来复制整个文件。 + 新选项: |g:ctrlp_types| 来选择內建类型。 + 新特性: 异步在新线程中调用 |g:ctrlp_user_command| 。 设置 - |g:user_command_async| 为1来启用。 + |g:ctrlp_user_command_async| 为1来启用。 + 为 delphi, rust 和 golang提供buffertag支持。 + 新选项: |g:ctrlp_brief_prompt|, |g:match_current_file|, diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt index 6c1335f2..424dd36d 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt @@ -1505,7 +1505,7 @@ Before 2016/11/28~ + New command: |YankLine()| to yank current line. + New option: |g:ctrlp_types| to select builtin modes. + New feature: asynchronized spawn of |g:ctrlp_user_command|. This enable - with set |g:user_command_async| to 1. + with set |g:ctrlp_user_command_async| to 1. + Support buffertag for delphi, rust and golang. + New option: |g:ctrlp_brief_prompt|, |g:match_current_file|, diff --git a/sources_non_forked/lightline.vim/README.md b/sources_non_forked/lightline.vim/README.md index 656fe90c..d47c02eb 100644 --- a/sources_non_forked/lightline.vim/README.md +++ b/sources_non_forked/lightline.vim/README.md @@ -41,10 +41,13 @@ https://github.com/itchyny/lightline.vim landscape is my colorscheme, which is a high-contrast cterm-supported colorscheme, available at https://github.com/itchyny/landscape.vim + +For screenshots of all available colorshemes, see [this file](colorscheme.md). + ## Why yet another clone of powerline? + [vim-powerline](https://github.com/Lokaltog/vim-powerline) is a nice plugin, but deprecated. + [powerline](https://github.com/powerline/powerline) is a nice plugin, but difficult to configure. -+ [vim-airline](https://github.com/vim-airline/vim-airline) is a nice plugin, but it uses too much functions of other plugins, which should be done by users in `.vimrc`. ++ [vim-airline](https://github.com/vim-airline/vim-airline) is a nice plugin, but it uses too many functions of other plugins, which should be done by users in `.vimrc`. ## Spirit of this plugin + Minimalism. The core script is very small to achieve enough functions as a statusline plugin. @@ -105,7 +108,7 @@ then modify `TERM` in your shell configuration (`.zshrc` for example) ```sh export TERM=xterm-256color ``` -and then add the following configure to your `.vimrc`. +and then add the following configuration to your `.vimrc`. ```vim if !has('gui_running') set t_Co=256 @@ -154,7 +157,7 @@ Instead, lightline.vim provides a simple API that user can easily integrate with Once you understand how to configure and how it will be displayed in the statusline, you can also tell how to integrate with your favorite plugins. Let's start to configure the appearance. -The statusline is composed by multiple components. +The statusline is composed of multiple components. It shows the current mode, filename, modified status on the left, and file format, encoding, filetype and cursor positions on the right. So in order to add something in the statusline, you firstly create a new component and specify the place. @@ -225,7 +228,7 @@ Now let's add some integrations with other plugin. The name of the git branch is important these days. But lightline.vim does not provide this information by default because it is also one of plugin crossing configurations, and not all people want the integration. -In order to show the branch name in the statusline, install some plugins which provides the branch information. +In order to show the branch name in the statusline, install some plugins which provide the branch information. The [vim-fugitive](https://github.com/tpope/vim-fugitive) plugin is a famous plugin so let's integrate lightline.vim with it. If you don't like to install full git integration but just want to display the branch name in the statusline, you can use the [vim-gitbranch](https://github.com/itchyny/vim-gitbranch) plugin which provides `gitbranch#name` function. ```vim diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim index 79013ff2..9cd7fa4d 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme.vim " Author: itchyny " License: MIT License -" Last Change: 2018/09/01 22:48:24. +" Last Change: 2019/09/07 11:20:37. " ============================================================================= let s:save_cpo = &cpo @@ -243,7 +243,7 @@ else endif let fg_color = synIDattr(synIDtrans(hlID('Normal')), 'fg', 'cterm') if fg_color !=# '' - if fg_color < 8 || 232 <= fg_color && fg_color < 244 + if fg_color < 7 || 232 <= fg_color && fg_color < 244 return 'light' elseif 8 <= fg_color && fg_color < 16 || 244 <= fg_color return 'dark' diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim index 9d0fba69..b986acf6 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim @@ -2,11 +2,10 @@ " Filename: autoload/lightline/colorscheme/one.vim " Author: Zoltan Dalmadi " License: MIT License -" Last Change: 2019/05/12 20:30:51. +" Last Change: 2019/09/09 22:42:48. " ============================================================================= " Common colors -let s:fg = [ '#abb2bf', 145 ] let s:blue = [ '#61afef', 75 ] let s:green = [ '#98c379', 76 ] let s:purple = [ '#c678dd', 176 ] @@ -18,44 +17,41 @@ let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': if lightline#colorscheme#background() ==# 'light' " Light variant - let s:bg = [ '#fafafa', 255 ] - let s:gray1 = [ '#494b53', 238 ] - let s:gray2 = [ '#f0f0f0', 255 ] - let s:gray3 = [ '#d0d0d0', 250 ] - let s:green = [ '#98c379', 35 ] + let s:fg = [ '#494b53', 238 ] + let s:bg = [ '#fafafa', 255 ] + let s:gray1 = [ '#494b53', 238 ] + let s:gray2 = [ '#f0f0f0', 255 ] + let s:gray3 = [ '#d0d0d0', 250 ] + let s:green = [ '#98c379', 35 ] - let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:gray1, s:gray3 ] ] - let s:p.normal.middle = [ [ s:gray1, s:gray2 ] ] let s:p.inactive.left = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ] let s:p.inactive.middle = [ [ s:gray3, s:gray2 ] ] let s:p.inactive.right = [ [ s:bg, s:gray3 ] ] - let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:gray1, s:gray3 ] ] - let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:gray1, s:gray3 ] ] - let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:gray1, s:gray3 ] ] else " Dark variant - let s:bg = [ '#282c34', 235 ] - let s:gray1 = [ '#5c6370', 241 ] - let s:gray2 = [ '#2c323d', 235 ] - let s:gray3 = [ '#3e4452', 240 ] + let s:fg = [ '#abb2bf', 145 ] + let s:bg = [ '#282c34', 235 ] + let s:gray1 = [ '#5c6370', 241 ] + let s:gray2 = [ '#2c323d', 235 ] + let s:gray3 = [ '#3e4452', 240 ] - let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] - let s:p.normal.middle = [ [ s:fg, s:gray2 ] ] let s:p.inactive.left = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ] let s:p.inactive.middle = [ [ s:gray1, s:gray2 ] ] let s:p.inactive.right = [ [ s:gray1, s:bg ] ] - let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] - let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] - let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] endif " Common +let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.normal.middle = [ [ s:fg, s:gray2 ] ] let s:p.normal.right = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] -let s:p.normal.error = [ [ s:red2, s:bg ] ] +let s:p.normal.error = [ [ s:red2, s:bg ] ] let s:p.normal.warning = [ [ s:yellow, s:bg ] ] let s:p.insert.right = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] let s:p.replace.right = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] let s:p.visual.right = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] let s:p.tabline.left = [ [ s:fg, s:gray3 ] ] let s:p.tabline.tabsel = [ [ s:bg, s:purple, 'bold' ] ] let s:p.tabline.middle = [ [ s:gray3, s:gray2 ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim new file mode 100644 index 00000000..d92610d3 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim @@ -0,0 +1,43 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/simpleblack.vim +" Author: lucasprag +" License: MIT License +" Last Change: 2019/10/28 22:54:01. +" ============================================================================= +let s:black = [ '#000000', '0' ] +let s:black2 = [ '#121212', '233' ] + +let s:gray = [ '#262626', '235' ] +let s:gray2 = [ '#3a3a3a', '237' ] +let s:gray3 = [ '#4e4e4e', '239' ] +let s:gray4 = [ '#626262', '241' ] + +let s:violet = [ '#cf73e6', '170' ] + +let s:blue = [ '#5f87af', '67' ] +let s:blue2 = [ '#91aadf', '110' ] + +let s:green = [ '#57ba37', '71' ] +let s:gold = [ '#f0d50c', '220' ] +let s:red = [ '#d70000', '160' ] +let s:none = [ 'NONE', 'NONE' ] + + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:black, s:blue ], [ s:gray4, s:black2 ] ] +let s:p.normal.right = [ [ s:gray, s:gray4 ], [ s:gray3, s:gray ], [ s:gray2, s:black2 ] ] +let s:p.inactive.right = [ [ s:black, s:black2 ], [ s:gray, s:black ] ] +let s:p.inactive.left = [ [ s:gray, s:black ], [ s:black2, s:black ] ] +let s:p.insert.left = [ [ s:black, s:green ], [ s:gray4, s:black2 ] ] +let s:p.replace.left = [ [ s:black, s:red ], [ s:gray4, s:black2 ] ] +let s:p.visual.left = [ [ s:black, s:violet ], [ s:gray4, s:black2 ] ] +let s:p.normal.middle = [ [ s:gray, s:black ] ] +let s:p.inactive.middle = [ [ s:black2, s:black ] ] +let s:p.tabline.left = [ [ s:gray4, s:black ] ] +let s:p.tabline.tabsel = [ [ s:blue, s:black ] ] +let s:p.tabline.middle = [ [ s:black2, s:black ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:red, s:black ] ] +let s:p.normal.warning = [ [ s:gold, s:black2 ] ] + +let g:lightline#colorscheme#simpleblack#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/colorscheme.md b/sources_non_forked/lightline.vim/colorscheme.md new file mode 100644 index 00000000..5b944ab6 --- /dev/null +++ b/sources_non_forked/lightline.vim/colorscheme.md @@ -0,0 +1,113 @@ +# Available Colorschemes + +### powerline (default) + +![lightline.vim - powerline](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/powerline.png) + +### powerlineish + +![lightline.vim - powerlineish](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/powerlineish.png) + +### wombat + +![lightline.vim - wombat](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/wombat.png) + +### OldHope + +![lightline.vim - OldHope](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/OldHope.png) + +### PaperColor dark + +![lightline.vim - PaperColor dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) + +### PaperColor light + +![lightline.vim - PaperColor light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor.png) + +### Tomorrow + +![lightline.vim - Tomorrow](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow.png) + +### Tomorrow Night + +![lightline.vim - Tomorrow Night](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night.png) + +### Tomorrow Night Blue + +![lightline.vim - Tomorrow Night Blue](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Blue.png) + +### Tomorrow Night Bright + +![lightline.vim - Tomorrow Night Bright](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Bright.png) + +### Tomorrow Night Eighties + +![lightline.vim - Tomorrow Night Eighties](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Eighties.png) + +### ayu_mirage + +![lightline.vim - ayu mirage](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_mirage.png) + +### darcula + +![lightline.vim - darcula](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/darcula.png) + +### deus + +![lightline.vim - deus](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/deus.png) + +### jellybeans + +![lightline.vim - jellybeans](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/jellybeans.png) + +### selenized dark + +![lightline.vim - selenized dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_dark.png) + +### solarized dark + +![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) + +### solarized light + +![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) + +### materia + +![lightline.vim - materia](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/materia.png) + +### material + +![lightline.vim - material](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/material.png) + +### molokai + +![lightline.vim - molokai](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/molokai.png) + +### nord + +![lightline.vim - nord](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/nord.png) + +### seoul256 + +![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256.png) + +### one + +![lightline.vim - one](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one.png) + +### srcery_drk + +![lightline.vim - srcery_drk](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/srcery_drk.png) + +### simpleblack + +![lightline.vim - simpleblack](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/simpleblack.png) + +### landscape + +![lightline.vim - landscape](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape.png) + +### 16color + +![lightline.vim - 16color](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color.png) diff --git a/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md b/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md index ccd5bf8d..24dba3f5 100644 --- a/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md +++ b/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md @@ -5,9 +5,12 @@ Closes # --- ### New Version Info -- [ ] Derive a new version number. Increment the: - - [ ] `MAJOR` version when you make incompatible API changes - - [ ] `MINOR` version when you add functionality in a backwards-compatible manner - - [ ] `PATCH` version when you make backwards-compatible bug fixes +#### Author's Instructions +- [ ] Derive a new `MAJOR.MINOR.PATCH` version number. Increment the: + - `MAJOR` version when you make incompatible API changes + - `MINOR` version when you add functionality in a backwards-compatible manner + - `PATCH` version when you make backwards-compatible bug fixes - [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. -- [ ] Tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` +#### Collaborator's Instructions +- [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary. +- [ ] After merge, tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` diff --git a/sources_non_forked/nerdtree/CHANGELOG.md b/sources_non_forked/nerdtree/CHANGELOG.md index 9e494175..ac12c9f0 100644 --- a/sources_non_forked/nerdtree/CHANGELOG.md +++ b/sources_non_forked/nerdtree/CHANGELOG.md @@ -1,19 +1,42 @@ -# Change Log +# NERDTree Change Log -#### 5.3... -- **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) -#### 5.2... -- **.9**: Suppress events for intermediate window/tab/buffer changes [#1026](https://github.com/scrooloose/nerdtree/pull/1026) + + +#### 6.2 +- **.1**: Menu option, 'copy path to clipboard' is aware of VIM clipboard option (jhzn) [#1056](https://github.com/scrooloose/nerdtree/pull/1056) +- **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/scrooloose/nerdtree/pull/1032) +#### 6.1 +- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/scrooloose/nerdtree/pull/1049) +- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048) +- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047) +- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045) +- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) +#### 6.0 +- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) +- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) +#### 5.3 +- **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/scrooloose/nerdtree/pull/1038) +- **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/scrooloose/nerdtree/pull/1037) +- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/scrooloose/nerdtree/pull/1031) +- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/scrooloose/nerdtree/pull/1029) +#### 5.2 +- **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/scrooloose/nerdtree/pull/1026) - **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021) -- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! [#1019](https://github.com/scrooloose/nerdtree/pull/1019) -- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017) +- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/scrooloose/nerdtree/pull/1019) +- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. (PhilRunninger) [#1017](https://github.com/scrooloose/nerdtree/pull/1017) - **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016) - **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015) - **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014) - **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/scrooloose/nerdtree/pull/1013) - **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) - **.0**: Expand functionality of `` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011) -#### 5.1... +#### 5.1 - **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/scrooloose/nerdtree/pull/1009) - **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/scrooloose/nerdtree/pull/1008) - **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007) diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown index 75b311a6..9e539523 100644 --- a/sources_non_forked/nerdtree/README.markdown +++ b/sources_non_forked/nerdtree/README.markdown @@ -17,27 +17,62 @@ included documentation. Installation ------------ +Below are just some of the methods for installing NERDTree. Do not follow all of these instructions; just pick your favorite one. Other plugin managers exist, and NERDTree should install just fine with any of them. + +#### Vim 8+ packages + +If you are using VIM version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: + +```bash +git clone https://github.com/scrooloose/nerdtree.git ~/.vim/pack/vendor/start/nerdtree +vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q +``` + +Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you nee d to take. + #### [pathogen.vim](https://github.com/tpope/vim-pathogen) - git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree +In the terminal, +```bash +git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree +``` +In your vimrc, +```vim +call pathogen#infect() +syntax on +filetype plugin indent on +``` -Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`, and check out `:help NERDTree.txt`. +Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. +#### [Vundle.vim](https://github.com/VundleVim/Vundle.vim) +```vim +call vundle#begin() +Plugin 'scrooloose/nerdtree' +call vundle#end() +``` + +#### [vim-plug](https://github.com/junegunn/vim-plug) +```vim +call plug#begin() +Plug 'scrooloose/nerdtree' +call plug#end() +``` #### [apt-vim](https://github.com/egalpin/apt-vim) +```bash +apt-vim install -y https://github.com/scrooloose/nerdtree.git +``` - apt-vim install -y https://github.com/scrooloose/nerdtree.git - -F.A.Q. +F.A.Q. (here, and in the [Wiki](https://github.com/scrooloose/nerdtree/wiki)) ------ -> Is there any support for `git` flags? +#### Is there any support for `git` flags? Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin). --- - -> Can I have the nerdtree on every tab automatically? +#### Can I have the nerdtree on every tab automatically? Nope. If this is something you want then chances are you aren't using tabs and buffers as they were intended to be used. Read this @@ -46,53 +81,65 @@ http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) --- -> How can I open a NERDTree automatically when vim starts up? +#### How can I open a NERDTree automatically when vim starts up? Stick this in your vimrc: `autocmd vimenter * NERDTree` --- -> How can I open a NERDTree automatically when vim starts up if no files were specified? +#### How can I open a NERDTree automatically when vim starts up if no files were specified? Stick this in your vimrc: - - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +```vim +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +``` Note: Now start vim with plain `vim`, not `vim .` --- -> How can I open NERDTree automatically when vim starts up on opening a directory? +#### What if I'm also opening a saved session, for example `vim -S session_file.vim`? I don't want NERDTree to open in that scenario. +```vim +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif +``` - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif +--- +#### How can I open NERDTree automatically when vim starts up on opening a directory? +```vim +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif +``` This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. Note: Executing `vim ~/some-directory` will open NERDTree and a new edit window. `exe 'cd '.argv()[0]` sets the `pwd` of the new edit window to `~/some-directory` --- -> How can I map a specific key or shortcut to open NERDTree? +#### How can I map a specific key or shortcut to open NERDTree? Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): - - map :NERDTreeToggle +```vim +map :NERDTreeToggle +``` --- -> How can I close vim if the only window left open is a NERDTree? +#### How can I close vim if the only window left open is a NERDTree? Stick this in your vimrc: - - autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +```vim +autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +``` --- -> Can I have different highlighting for different file extensions? +#### Can I have different highlighting for different file extensions? See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 --- -> How can I change default arrows? +#### How can I change default arrows? Use these variables in your vimrc. Note that below are default arrow symbols - - let g:NERDTreeDirArrowExpandable = '▸' - let g:NERDTreeDirArrowCollapsible = '▾' +```vim +let g:NERDTreeDirArrowExpandable = '▸' +let g:NERDTreeDirArrowCollapsible = '▾' +``` diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim index 4391565e..76c076e9 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -4,24 +4,33 @@ endif let g:loaded_nerdtree_autoload = 1 let s:rootNERDTreePath = resolve(expand(":p:h:h")) + +"FUNCTION: nerdtree#version(...) {{{1 +" If any value is given as an argument, the entire line of text from the +" change log is shown for the current version; otherwise, only the version +" number is shown. function! nerdtree#version(...) - let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash())) let l:text = 'Unknown' - let l:line = 0 - while l:line <= len(l:changelog) - if l:changelog[l:line] =~ '\d\+\.\d\+' - let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') - let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') - break - endif - let l:line += 1 - endwhile + try + let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash())) + let l:line = 0 + while l:line <= len(l:changelog) + if l:changelog[l:line] =~ '\d\+\.\d\+' + let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') + let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') + break + endif + let l:line += 1 + endwhile + catch + endtry return l:text endfunction " SECTION: General Functions {{{1 "============================================================ +"FUNCTION: nerdtree#slash() {{{2 function! nerdtree#slash() if nerdtree#runningWindows() @@ -49,7 +58,6 @@ function! nerdtree#and(x,y) if (l:x % 2) && (l:y % 2) let l:result += float2nr(pow(2, l:n)) endif - echomsg l:x . ", " . l:y . " => " l:result let l:x = float2nr(l:x / 2) let l:y = float2nr(l:y / 2) let l:n += 1 diff --git a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim index f0458680..4ba5b05f 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim @@ -72,6 +72,7 @@ function! nerdtree#ui_glue#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "FileNode", 'callback': s."openExplorer" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) endfunction @@ -283,6 +284,9 @@ endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 function! s:findAndRevealPath(pathStr) let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') + if !filereadable(l:pathStr) + let l:pathStr = fnamemodify(l:pathStr, ':h') + endif if empty(l:pathStr) call nerdtree#echoWarning('no file for the current buffer') diff --git a/sources_non_forked/nerdtree/doc/NERDTree.txt b/sources_non_forked/nerdtree/doc/NERDTree.txt index 14f70782..32b0b5d1 100644 --- a/sources_non_forked/nerdtree/doc/NERDTree.txt +++ b/sources_non_forked/nerdtree/doc/NERDTree.txt @@ -849,9 +849,17 @@ above nodes would then be sorted like this: > z110.txt < ------------------------------------------------------------------------------ - *NERDTreeChDirMode* + *NERDTreeUseTCD* +Values: 0 or 1. +Default: 0. -Values: 0, 1 or 2. +By default, NERDTree will use the `:cd` command to change the current working +directory. If this setting is turned on, and the `:tcd` command is available, it +will be used instead. + +------------------------------------------------------------------------------ + *NERDTreeChDirMode* +Values: 0, 1, 2, or 3. Default: 0. Use this setting to tell the script when (if at all) to change the current @@ -871,6 +879,9 @@ the CWD is changed whenever the tree root is changed. For example, if the CWD is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new root then the CWD will become /home/marty/foobar/baz. +If the set to 3, then it behaves the same as if set to 2, and the CWD is +changed whenever changing tabs to whatever the tree root is on that tab. + ------------------------------------------------------------------------------ *NERDTreeHighlightCursorline* Values: 0 or 1. @@ -980,7 +991,6 @@ then (to single click activate it) you must click somewhere in ------------------------------------------------------------------------------ *NERDTreeQuitOnOpen* - Values: 0,1,2 or 3. Default: 0 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim b/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim index 05e82d97..874c09dc 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim @@ -62,9 +62,10 @@ function! s:MenuController._echoPrompt() if self.isMinimal() let selection = self.menuItems[self.selection].text + let keyword = matchstr(selection, "\([^ ]*") let shortcuts = map(copy(self.menuItems), "v:val['shortcut']") - let shortcuts[self.selection] = " " . split(selection)[0] . " " + let shortcuts[self.selection] = " " . keyword . " " echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): " else diff --git a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim index 705d4f9b..3e7ade8a 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim @@ -20,7 +20,7 @@ function! s:NERDTree.changeRoot(node) call self.root.open() "change dir to the dir of the new root if instructed to - if g:NERDTreeChDirMode ==# 2 + if g:NERDTreeChDirMode >= 2 call self.root.path.changeToDir() endif @@ -52,7 +52,7 @@ function! s:NERDTree.Close() endif call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1) - call nerdtree#exec("close", 1) + call nerdtree#exec("close", 0) if l:useWinId call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0) else @@ -148,12 +148,19 @@ function! s:NERDTree.GetWinNum() return bufwinnr(t:NERDTreeBufName) endif + " If WindowTree, there is no t:NERDTreeBufName variable. Search all windows. + for w in range(1,winnr('$')) + if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' + return w + endif + endfor + return -1 endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 function! s:NERDTree.IsOpen() - return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' + return s:NERDTree.GetWinNum() != -1 endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim index 5953eea2..fa0c9884 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -71,9 +71,9 @@ endfunction function! s:Opener._gotoTargetWin() if b:NERDTree.isWinTree() if self._where == 'v' - vsplit + call self._newVSplit() elseif self._where == 'h' - split + call self._newSplit() elseif self._where == 't' tabnew endif @@ -153,44 +153,18 @@ endfunction " FUNCTION: Opener._newSplit() {{{1 function! s:Opener._newSplit() - " Save the user's settings for splitbelow and splitright - let savesplitbelow=&splitbelow - let savesplitright=&splitright - - " 'there' will be set to a command to move from the split window - " back to the explorer window - " - " 'back' will be set to a command to move from the explorer window - " back to the newly split window - " - " 'right' and 'below' will be set to the settings needed for - " splitbelow and splitright IF the explorer is the only window. - " - let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" - let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" - let right= g:NERDTreeWinPos ==# "left" - let below=0 - - " Attempt to go to adjacent window - call nerdtree#exec(back, 1) - let onlyOneWin = (winnr("$") ==# 1) - - " If no adjacent window, set splitright and splitbelow appropriately + let savesplitright = &splitright if onlyOneWin - let &splitright=right - let &splitbelow=below - else - " found adjacent window - invert split direction - let &splitright=!right - let &splitbelow=!below + let &splitright = (g:NERDTreeWinPos ==# "left") endif - + " If only one window (ie. NERDTree), split vertically instead. let splitMode = onlyOneWin ? "vertical" : "" " Open the new window try - exec(splitMode." sp ") + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec(splitMode . " split",1) catch /^Vim\%((\a\+)\)\=:E37/ call g:NERDTree.CursorToTreeWin() throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." @@ -200,14 +174,12 @@ function! s:Opener._newSplit() "resize the tree window if no other window was open before if onlyOneWin - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call nerdtree#exec(there, 1) - exec("silent ". splitMode ." resize ". size) + let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec('silent '. splitMode .' resize '. size, 1) call nerdtree#exec('wincmd p', 0) endif - " Restore splitmode settings - let &splitbelow=savesplitbelow let &splitright=savesplitright endfunction @@ -215,7 +187,10 @@ endfunction function! s:Opener._newVSplit() let l:winwidth = winwidth('.') - if winnr('$') == 1 + let onlyOneWin = (winnr("$") ==# 1) + let savesplitright = &splitright + if onlyOneWin + let &splitright = (g:NERDTreeWinPos ==# "left") let l:winwidth = g:NERDTreeWinSize endif @@ -229,6 +204,7 @@ function! s:Opener._newVSplit() execute 'silent vertical resize ' . l:winwidth call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0) + let &splitright=savesplitright endfunction " FUNCTION: Opener.open(target) {{{1 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/path.vim b/sources_non_forked/nerdtree/lib/nerdtree/path.vim index d00bb898..ccb94238 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/path.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -87,8 +87,13 @@ function! s:Path.changeToDir() endif try - execute "cd " . dir - call nerdtree#echo("CWD is now: " . getcwd()) + if g:NERDTreeUseTCD && exists(":tcd") == 2 + execute "tcd " . dir + call nerdtree#echo("Tab's CWD is now: " . getcwd()) + else + execute "cd " . dir + call nerdtree#echo("CWD is now: " . getcwd()) + endif catch throw "NERDTree.PathChangeError: cannot change CWD to " . dir endtry 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 aa9dea6a..4015f0be 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim @@ -523,7 +523,8 @@ endfunction " Open an explorer window for this node in the previous window. The explorer " can be a NERDTree window or a netrw window. function! s:TreeDirNode.openExplorer() - call self.open({'where': 'p'}) + execute "wincmd p" + execute "edit ".self.path.str({'format':'Edit'}) endfunction " FUNCTION: TreeDirNode.openInNewTab(options) {{{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 d4c060fc..c14f62a9 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim @@ -246,6 +246,12 @@ function! s:TreeFileNode.openInNewTab(options) call self.open(extend({'where': 't'}, a:options)) endfunction +" FUNCTION: TreeFileNode.openExplorer() +function! s:TreeFileNode.openExplorer() + execute "wincmd p" + execute "edit ".self.path.getParent().str({'format':'Edit'}) +endfunction + " FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 " Places the cursor on the line number this node is rendered on " diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim index d384071d..5e8b3b64 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -355,12 +355,15 @@ endfunction " scroll position function! s:UI.saveScreenState() let win = winnr() - call g:NERDTree.CursorToTreeWin() let self._screenState = {} - let self._screenState['oldPos'] = getpos(".") - let self._screenState['oldTopLine'] = line("w0") - let self._screenState['oldWindowSize']= winwidth("") - call nerdtree#exec(win . "wincmd w", 1) + try + call g:NERDTree.CursorToTreeWin() + let self._screenState['oldPos'] = getpos(".") + let self._screenState['oldTopLine'] = line("w0") + let self._screenState['oldWindowSize']= winwidth("") + call nerdtree#exec(win . "wincmd w", 1) + catch + endtry endfunction " FUNCTION: s:UI.setShowHidden(val) {{{1 diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim index 0a5de8a4..4167df00 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -369,7 +369,11 @@ endfunction function! NERDTreeCopyPath() let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() if has("clipboard") - let @* = l:nodePath + if &clipboard == "unnamedplus" + let @+ = l:nodePath + else + let @* = l:nodePath + endif call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.") else call nerdtree#echo("The full path is: " . l:nodePath) diff --git a/sources_non_forked/nerdtree/plugin/NERD_tree.vim b/sources_non_forked/nerdtree/plugin/NERD_tree.vim index a8e26d4e..5faebaaf 100644 --- a/sources_non_forked/nerdtree/plugin/NERD_tree.vim +++ b/sources_non_forked/nerdtree/plugin/NERD_tree.vim @@ -48,6 +48,7 @@ call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) call s:initVariable("g:NERDTreeNaturalSort", 0) call s:initVariable("g:NERDTreeSortHiddenFirst", 1) +call s:initVariable("g:NERDTreeUseTCD", 0) call s:initVariable("g:NERDTreeChDirMode", 0) call s:initVariable("g:NERDTreeCreatePrefix", "silent") call s:initVariable("g:NERDTreeMinimalUI", 0) @@ -170,10 +171,10 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" + exec "autocmd BufLeave,WinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" "disallow insert mode in the NERDTree - exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" + exec "autocmd BufEnter,WinEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" augroup END if g:NERDTreeHijackNetrw @@ -183,6 +184,12 @@ if g:NERDTreeHijackNetrw augroup END endif +if g:NERDTreeChDirMode == 3 + augroup NERDTreeChDirOnTabSwitch + autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif + augroup END +endif + " SECTION: Public API {{{1 "============================================================ function! NERDTreeAddMenuItem(options) diff --git a/sources_non_forked/vim-abolish/.github/FUNDING.yml b/sources_non_forked/vim-abolish/.github/FUNDING.yml new file mode 100644 index 00000000..e2a49d11 --- /dev/null +++ b/sources_non_forked/vim-abolish/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: tpope +custom: ["https://www.paypal.me/vimpope"] diff --git a/sources_non_forked/vim-abolish/plugin/abolish.vim b/sources_non_forked/vim-abolish/plugin/abolish.vim index 4a97542e..3b71f944 100644 --- a/sources_non_forked/vim-abolish/plugin/abolish.vim +++ b/sources_non_forked/vim-abolish/plugin/abolish.vim @@ -215,7 +215,6 @@ function! s:SubComplete(A,L,P) endfunction function! s:Complete(A,L,P) - let g:L = a:L " Vim bug: :Abolish - calls this function with a:A equal to 0 if a:A =~# '^[^/?-]' && type(a:A) != type(0) return join(s:words(),"\n") @@ -314,7 +313,6 @@ function! s:normalize_options(flags) let opts = {} let flags = a:flags endif - let g:op1 = copy(opts) if flags =~# 'w' let opts.boundaries = 2 elseif flags =~# 'v' @@ -324,7 +322,6 @@ function! s:normalize_options(flags) endif let opts.case = (flags !~# 'I' ? get(opts,'case',1) : 0) let opts.flags = substitute(flags,'\C[avIiw]','','g') - let g:op2 = copy(opts) return opts endfunction @@ -622,7 +619,7 @@ endfunction nnoremap (abolish-coerce) coerce(nr2char(getchar())) nnoremap (abolish-coerce) coerce(nr2char(getchar())) -nnoremap (abolish-coerce-word) coerce(nr2char(getchar())).'iw' +nnoremap (abolish-coerce-word) coerce(nr2char(getchar())).'iw' " }}}1 diff --git a/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim b/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim index 41be4705..565defc7 100644 --- a/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim +++ b/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim @@ -1,11 +1,19 @@ " Vim filetype plugin file " Language: Mako " Maintainer: Randy Stauner -" Last Change: 2014-02-07 -" Version: 0.1 +" Last Change: 2019-09-06 +" Version: 0.2 if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 setlocal comments=:## setlocal commentstring=##%s + +if exists("loaded_matchit") + let b:match_ignorecase = 1 + let b:match_words = "<:>," . + \ "<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>," . + \ "<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>," . + \ "<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>" +endif diff --git a/sources_non_forked/vim-commentary/.github/FUNDING.yml b/sources_non_forked/vim-commentary/.github/FUNDING.yml new file mode 100644 index 00000000..e2a49d11 --- /dev/null +++ b/sources_non_forked/vim-commentary/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: tpope +custom: ["https://www.paypal.me/vimpope"] diff --git a/sources_non_forked/vim-commentary/doc/commentary.txt b/sources_non_forked/vim-commentary/doc/commentary.txt index b0485694..01f73dad 100644 --- a/sources_non_forked/vim-commentary/doc/commentary.txt +++ b/sources_non_forked/vim-commentary/doc/commentary.txt @@ -6,6 +6,9 @@ License: Same terms as Vim itself (see |license|) Comment stuff out. Then uncomment it later. Relies on 'commentstring' to be correctly set, or uses b:commentary_format if it is set. +Assign b:commentary_startofline to insert comment characters at column 1 +regardless of indentation. + *gc* gc{motion} Comment or uncomment lines that {motion} moves over. diff --git a/sources_non_forked/vim-commentary/plugin/commentary.vim b/sources_non_forked/vim-commentary/plugin/commentary.vim index 862ca820..2b0d1ec0 100644 --- a/sources_non_forked/vim-commentary/plugin/commentary.vim +++ b/sources_non_forked/vim-commentary/plugin/commentary.vim @@ -44,6 +44,12 @@ function! s:go(...) abort endif endfor + if get(b:, 'commentary_startofline') + let indent = '^' + else + let indent = '^\s*' + endif + for lnum in range(lnum1,lnum2) let line = getline(lnum) if strlen(r) > 2 && l.r !~# '\\' @@ -54,7 +60,7 @@ function! s:go(...) abort if uncomment let line = substitute(line,'\S.*\s\@'), '\d\+_'),'')) + return function(substitute(a:name,'^s:',matchstr(expand(''), '.*\zs\d\+_'),'')) endfunction function! s:sub(str,pat,rep) abort @@ -42,7 +42,7 @@ function! s:Uniq(list) abort endfunction function! s:winshell() abort - return has('win32') && &shellcmdflag !~# '^-' + return has('win32') && &shellcmdflag =~# '^/\|^-Command$' endfunction function! s:shellesc(arg) abort @@ -73,10 +73,13 @@ function! s:throw(string) abort endfunction function! s:DirCheck(...) abort - if empty(a:0 ? s:Dir(a:1) : s:Dir()) - return 'return ' . string('echoerr "fugitive: not a Git repository"') + if !empty(a:0 ? s:Dir(a:1) : s:Dir()) + return '' + elseif empty(bufname('')) + return 'return ' . string('echoerr "fugitive: working directory does not belong to a Git repository"') + else + return 'return ' . string('echoerr "fugitive: file does not belong to a Git repository"') endif - return '' endfunction function! s:Mods(mods, ...) abort @@ -135,6 +138,16 @@ function! s:executable(binary) abort return s:executables[a:binary] endfunction +function! s:DoAutocmd(cmd) abort + if v:version >= 704 || (v:version == 703 && has('patch442')) + return 'doautocmd ' . a:cmd + elseif &modelines > 0 + return 'try|set modelines=0|doautocmd ' . a:cmd . '|finally|set modelines=' . &modelines . '|endtry' + else + return 'doautocmd ' . a:cmd + endif +endfunction + let s:nowait = v:version >= 704 ? '' : '' function! s:Map(mode, lhs, rhs, ...) abort @@ -476,12 +489,21 @@ function! s:EchoExec(...) abort return 'checktime' endfunction +let s:head_cache = {} + function! fugitive#Head(...) abort let dir = a:0 > 1 ? a:2 : s:Dir() - if empty(dir) || !filereadable(fugitive#Find('.git/HEAD', dir)) + if empty(dir) return '' endif - let head = readfile(fugitive#Find('.git/HEAD', dir))[0] + let file = fugitive#Find('.git/HEAD', dir) + let ftime = getftime(file) + if ftime == -1 + return '' + elseif ftime != get(s:head_cache, dir, [-1])[0] + let s:head_cache[dir] = [ftime, readfile(file)[0]] + endif + let head = s:head_cache[dir][1] if head =~# '^ref: ' return substitute(head, '\C^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '') elseif head =~# '^\x\{40,\}$' @@ -579,39 +601,6 @@ function! s:add_methods(namespace, method_names) abort endfor endfunction -function! s:Command(command, line1, line2, range, bang, mods, arg, args) abort - try - if a:command =~# '^\l[[:alnum:]-]\+$' - return s:GitCommand(a:line1, a:line2, a:range, a:line2, a:bang, s:Mods(a:mods), '', a:command . ' ' . a:arg, [a:command] + a:args) - endif - return s:{a:command}Command(a:line1, a:line2, a:range, a:line2, a:bang, s:Mods(a:mods), '', a:arg, a:args) - catch /^fugitive:/ - return 'echoerr ' . string(v:exception) - endtry -endfunction - -let s:commands = [] -function! s:command(definition, ...) abort - let def = a:definition - if !has('patch-7.4.542') - let def = substitute(def, '-addr=\S\+ ', '', '') - endif - if !has('patch-8.1.560') - let def = substitute(def, '-addr=other ', '', '') - endif - if a:0 - call add(s:commands, def . ' execute s:Command(' . string(a:1) . ", , , +'', 0, '', , [])") - else - call add(s:commands, def) - endif -endfunction - -function! s:define_commands() abort - for command in s:commands - exe 'command! -buffer '.command - endfor -endfunction - let s:repo_prototype = {} let s:repos = {} @@ -727,6 +716,17 @@ function! s:DirRev(url) abort return [dir, (commit =~# '^.$' ? ':' : '') . commit . substitute(file, '^/', ':', '')] endfunction +let s:merge_heads = ['MERGE_HEAD', 'REBASE_HEAD', 'CHERRY_PICK_HEAD', 'REVERT_HEAD'] +function! s:MergeHead(...) abort + let dir = fugitive#Find('.git/', a:0 ? a:1 : s:Dir()) + for head in s:merge_heads + if filereadable(dir . head) + return head + endif + endfor + return '' +endfunction + function! s:Owner(path, ...) abort let dir = a:0 ? a:1 : s:Dir() if empty(dir) @@ -739,12 +739,11 @@ function! s:Owner(path, ...) abort return commit elseif commit ==# '2' return 'HEAD^{}' + elseif commit ==# '0' + return '' endif - if filereadable(actualdir . 'MERGE_HEAD') - let merge_head = 'MERGE_HEAD' - elseif filereadable(actualdir . 'REBASE_HEAD') - let merge_head = 'REBASE_HEAD' - else + let merge_head = s:MergeHead() + if empty(merge_head) return '' endif if commit ==# '3' @@ -967,17 +966,20 @@ function! fugitive#Object(...) abort let rev = '' endif let tree = s:Tree(dir) + let full = a:0 ? a:1 : @% + let full = fnamemodify(full, ':p' . (s:Slash(full) =~# '/$' ? '' : ':s?/$??')) if empty(rev) && empty(tree) + return FugitiveGitPath(full) elseif empty(rev) - let rev = fugitive#Path(a:0 ? a:1 : @%, './', dir) + let rev = fugitive#Path(full, './', dir) if rev =~# '^\./.git\%(/\|$\)' - return fnamemodify(a:0 ? a:1 : @%, ':p' . (rev =~# '/$' ? '' : ':s?/$??')) + return FugitiveGitPath(full) endif endif if rev !~# '^\.\%(/\|$\)' || s:cpath(getcwd(), tree) return rev else - return tree . rev[1:-1] + return FugitiveGitPath(tree . rev[1:-1]) endif endfunction @@ -1034,11 +1036,13 @@ endfunction function! s:Expand(rev, ...) abort if a:rev =~# '^:[0-3]$' - let file = a:rev . ':%' - elseif a:rev =~# '^>[~^]\|^>@{\|^>$' - let file = 'HEAD' . a:rev[1:-1] . ':%' + let file = len(expand('%')) ? a:rev . ':%' : '%' + elseif a:rev ==# '>' + let file = '%' + elseif a:rev =~# '^>[~^]' + let file = len(expand('%')) ? '!' . a:rev[1:-1] . ':%' : '%' elseif a:rev =~# '^>[> ]\@!' - let file = a:rev[1:-1] . ':%' + let file = len(expand('%')) ? a:rev[1:-1] . ':%' : '%' else let file = a:rev endif @@ -1382,43 +1386,15 @@ function! fugitive#buffer(...) abort return buffer endfunction -function! s:buffer_getvar(var) dict abort - throw "fugitive: A third-party plugin or vimrc is calling fugitive#buffer().getvar() which has been removed. Replace it with the local variable or getbufvar()" -endfunction - -function! s:buffer_getline(lnum) dict abort - throw "fugitive: A third-party plugin or vimrc is calling fugitive#buffer().getline() which has been removed. Replace it with getline() or getbufline()" -endfunction - function! s:buffer_repo() dict abort return fugitive#repo(self['#']) endfunction function! s:buffer_type(...) dict abort - return getbufvar(self['#'], 'fugitive_type') + return 'see b:fugitive_type' endfunction -function! s:buffer_spec() dict abort - throw "fugitive: A third-party plugin or vimrc is calling fugitive#buffer().spec() which has been removed. Replace it with bufname(), expand('%:p'), etc" -endfunction - -function! s:buffer_name() dict abort - throw "fugitive: A third-party plugin or vimrc is calling fugitive#buffer().name() which has been removed. Replace it with bufname(), expand('%:p'), etc" -endfunction - -function! s:buffer_commit() dict abort - throw "fugitive: A third-party plugin or vimrc is calling fugitive#buffer().commit() which has been removed. Replace it with matchstr(FugitiveParse()[0], '^\x\+')" -endfunction - -function! s:buffer_relative(...) dict abort - throw "fugitive: A third-party plugin or vimrc is calling fugitive#buffer().relative() which has been removed. Replace it with FugitivePath(@%, " . string(a:0 ? a:1 : '') . ")" -endfunction - -function! s:buffer_path(...) dict abort - throw "fugitive: A third-party plugin or vimrc is calling fugitive#buffer().path() which has been removed. Replace it with FugitivePath(@%, " . string(a:0 ? a:1 : '') . ")" -endfunction - -call s:add_methods('buffer',['getvar','getline','repo','type','spec','name','commit','path','relative']) +call s:add_methods('buffer', ['repo', 'type']) " Section: Completion @@ -1474,6 +1450,12 @@ function! fugitive#PathComplete(...) abort return call('fugitive#CompletePath', a:000) endfunction +function! s:CompleteHeads(dir) abort + 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]) +endfunction + function! fugitive#CompleteObject(base, ...) abort let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir() let cwd = getcwd() @@ -1488,8 +1470,7 @@ function! fugitive#CompleteObject(base, ...) abort if a:base =~# '^refs/' let results += map(s:GlobComplete(fugitive#CommonDir(dir) . '/', a:base . '*'), 's:Slash(v:val)') elseif a:base !~# '^\.\=/\|^:(' - let heads = ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'MERGE_HEAD', 'refs/'] - let heads += sort(s:LinesError(["rev-parse","--symbolic","--branches","--tags","--remotes"], dir)[0]) + let heads = s:CompleteHeads(dir) if filereadable(fugitive#Find('.git/refs/stash', dir)) let heads += ["stash"] let heads += sort(s:LinesError(["stash","list","--pretty=format:%gd"], dir)[0]) @@ -1539,9 +1520,8 @@ function! s:CompleteSub(subcommand, A, L, P, ...) abort endif endfunction -function! s:CompleteRevision(A, L, P) abort - return s:FilterEscape(['HEAD', 'FETCH_HEAD', 'MERGE_HEAD', 'ORIG_HEAD'] + - \ s:LinesError('rev-parse', '--symbolic', '--branches', '--tags', '--remotes')[0], a:A) +function! s:CompleteRevision(A, L, P, ...) abort + return s:FilterEscape(s:CompleteHeads(s:Dir()), a:A) endfunction function! s:CompleteRemote(A, L, P) abort @@ -1623,7 +1603,7 @@ function! s:AddHeader(key, value) abort endwhile call append(before - 1, [a:key . ':' . (len(a:value) ? ' ' . a:value : '')]) if before == 1 && line('$') == 2 - silent 2delete _ + silent keepjumps 2delete _ endif endfunction @@ -1646,54 +1626,109 @@ function! fugitive#BufReadStatus() abort if s:cpath(fnamemodify($GIT_INDEX_FILE !=# '' ? $GIT_INDEX_FILE : fugitive#Find('.git/index'), ':p')) !=# s:cpath(amatch) let cmd += ['-c', 'GIT_INDEX_FILE=' . amatch] endif - let cmd += ['status', '--porcelain', '-bz'] - let [output, message, exec_error] = s:NullError(cmd) - if exec_error - throw 'fugitive: ' . message - endif - let head = matchstr(output[0], '^## \zs\S\+\ze\%($\| \[\)') - let pull = '' - if head =~# '\.\.\.' - let [head, pull] = split(head, '\.\.\.') - let branch = head - elseif head ==# 'HEAD' || empty(head) - let head = FugitiveHead(11) - let branch = '' - else - let branch = head - endif - - let b:fugitive_status = {'Staged': {}, 'Unstaged': {}} + let b:fugitive_files = {'Staged': {}, 'Unstaged': {}} let [staged, unstaged, untracked] = [[], [], []] - let i = 0 - while i < len(output) - let line = output[i] - let file = line[3:-1] - let files = file - let i += 1 - if line[2] !=# ' ' - continue + let props = {} + + if fugitive#GitVersion(2, 11) + let cmd += ['status', '--porcelain=v2', '-bz'] + let [output, message, exec_error] = s:NullError(cmd) + if exec_error + throw 'fugitive: ' . message endif - if line[0:1] =~# '[RC]' - let files = output[i] . ' -> ' . file + + let i = 0 + while i < len(output) + let line = output[i] + let prop = matchlist(line, '# \(\S\+\) \(.*\)') + if len(prop) + let props[prop[1]] = prop[2] + elseif line[0] ==# '?' + call add(untracked, {'type': 'File', 'status': line[0], 'filename': line[2:-1]}) + elseif line[0] !=# '#' + if line[0] ==# 'u' + let file = matchstr(line, '^.\{37\} \x\{40,\} \x\{40,\} \x\{40,\} \zs.*$') + else + let file = matchstr(line, '^.\{30\} \x\{40,\} \x\{40,\} \zs.*$') + endif + if line[0] ==# '2' + let i += 1 + let file = matchstr(file, ' \zs.*') + let files = output[i] . ' -> ' . file + else + let files = file + endif + let sub = matchstr(line, '^[12u] .. \zs....') + if line[2] !=# '.' + call add(staged, {'type': 'File', 'status': line[2], 'filename': files, 'sub': sub}) + endif + if line[3] !=# '.' + call add(unstaged, {'type': 'File', 'status': get({'C':'M','M':'?','U':'?'}, matchstr(sub, 'S\.*\zs[CMU]'), line[3]), 'filename': file, 'sub': sub}) + endif + endif let i += 1 + endwhile + let branch = substitute(get(props, 'branch.head', '(unknown)'), '\C^(\%(detached\|unknown\))$', '', '') + if len(branch) + let head = branch + elseif has_key(props, 'branch.oid') + let head = props['branch.oid'][0:10] + else + let head = FugitiveHead(11) endif - if line[0] !~# '[ ?!#]' - call add(staged, {'type': 'File', 'status': line[0], 'filename': files}) + let pull = get(props, 'branch.upstream', '') + else " git < 2.11 + let cmd += ['status', '--porcelain', '-bz'] + let [output, message, exec_error] = s:NullError(cmd) + if exec_error + throw 'fugitive: ' . message endif - if line[0:1] ==# '??' - call add(untracked, {'type': 'File', 'status': line[1], 'filename': files}) - elseif line[1] !~# '[ !#]' - call add(unstaged, {'type': 'File', 'status': line[1], 'filename': files}) + + while get(output, 0, '') =~# '^\l\+:' + call remove(output, 0) + endwhile + let head = matchstr(output[0], '^## \zs\S\+\ze\%($\| \[\)') + let pull = '' + if head =~# '\.\.\.' + let [head, pull] = split(head, '\.\.\.') + let branch = head + elseif head ==# 'HEAD' || empty(head) + let head = FugitiveHead(11) + let branch = '' + else + let branch = head endif - endwhile + + let i = 0 + while i < len(output) + let line = output[i] + let file = line[3:-1] + let files = file + let i += 1 + if line[2] !=# ' ' + continue + endif + if line[0:1] =~# '[RC]' + let files = output[i] . ' -> ' . file + let i += 1 + endif + if line[0] !~# '[ ?!#]' + call add(staged, {'type': 'File', 'status': line[0], 'filename': files, 'sub': ''}) + endif + if line[0:1] ==# '??' + call add(untracked, {'type': 'File', 'status': line[1], 'filename': files}) + elseif line[1] !~# '[ !#]' + call add(unstaged, {'type': 'File', 'status': line[1], 'filename': file, 'sub': ''}) + endif + endwhile + endif for dict in staged - let b:fugitive_status['Staged'][dict.filename] = dict.status + let b:fugitive_files['Staged'][dict.filename] = dict endfor for dict in unstaged - let b:fugitive_status['Unstaged'][dict.filename] = dict.status + let b:fugitive_files['Unstaged'][dict.filename] = dict endfor let config = fugitive#Config() @@ -1720,12 +1755,12 @@ function! fugitive#BufReadStatus() abort let push = pull endif - if len(pull) + if len(pull) && get(props, 'branch.ab') !~# ' -0$' let unpulled = s:QueryLog(head . '..' . pull) else let unpulled = [] endif - if len(push) + if len(push) && !(push ==# pull && get(props, 'branch.ab') =~# '^+0 ') let unpushed = s:QueryLog(push . '..' . head) else let unpushed = [] @@ -1889,7 +1924,7 @@ function! fugitive#FileWriteCmd(...) abort let amatch = a:0 ? a:1 : expand('') let autype = a:0 > 1 ? 'Buf' : 'File' if exists('#' . autype . 'WritePre') - execute 'doautocmd ' . autype . 'WritePre ' . s:fnameescape(amatch) + execute s:DoAutocmd(autype . 'WritePre ' . s:fnameescape(amatch)) endif try let [dir, commit, file] = s:DirCommitFile(amatch) @@ -1907,7 +1942,7 @@ function! fugitive#FileWriteCmd(...) abort if !exec_error setlocal nomodified if exists('#' . autype . 'WritePost') - execute 'doautocmd ' . autype . 'WritePost ' . s:fnameescape(amatch) + execute s:DoAutocmd(autype . 'WritePost ' . s:fnameescape(amatch)) endif return '' else @@ -1918,8 +1953,6 @@ function! fugitive#FileWriteCmd(...) abort endtry endfunction -let s:nomodeline = (v:version >= 704 ? '' : '') - function! fugitive#BufReadCmd(...) abort let amatch = a:0 ? a:1 : expand('') try @@ -1991,7 +2024,7 @@ function! fugitive#BufReadCmd(...) abort if b:fugitive_display_format call s:ReplaceCmd([dir, 'cat-file', b:fugitive_type, rev]) else - call s:ReplaceCmd([dir, 'show', '--no-color', '--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b', rev]) + call s:ReplaceCmd([dir, 'show', '--no-color', '-m', '--first-parent', '--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b', rev]) keepjumps call search('^parent ') if getline('.') ==# 'parent ' silent keepjumps delete_ @@ -2028,8 +2061,8 @@ function! fugitive#BufReadCmd(...) abort endtry setlocal modifiable - return 'silent doautocmd' . s:nomodeline . - \ ' BufReadPost' . (modifiable ? '' : '|setl nomodifiable') + return 'silent ' . s:DoAutocmd('BufReadPost') . + \ (modifiable ? '' : '|setl nomodifiable') catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry @@ -2103,11 +2136,11 @@ augroup END " Section: :Git -function! s:GitCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort +function! fugitive#Command(line1, line2, range, bang, mods, arg) abort let dir = s:Dir() let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir)) if empty(args) - let cmd = s:StatusCommand(a:line1, a:line2, a:range, a:count, a:bang, a:mods, a:reg, '', []) + 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], '!') @@ -2120,7 +2153,7 @@ function! s:GitCommand(line1, line2, range, count, bang, mods, reg, arg, args) a if exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' try exe s:DirCheck(dir) - return 'exe ' . string(s:{name}Subcommand(a:line1, a:count, a:range, a:bang, a:mods, args[1:-1])) . after + return 'exe ' . string(s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, args[1:-1])) . after catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry @@ -2128,18 +2161,19 @@ function! s:GitCommand(line1, line2, range, count, bang, mods, reg, arg, args) a if a:bang || args[0] =~# '^-P$\|^--no-pager$\|diff\%(tool\)\@!\|log\|^show$' || \ (args[0] ==# 'stash' && get(args, 1, '') ==# 'show') || \ (args[0] ==# 'help' || get(args, 1, '') ==# '--help') && !s:HasOpt(args, '--web') - return s:OpenExec((a:count > 0 ? a:count : '') . (a:count ? 'split' : 'edit'), a:mods, args, dir) . after + 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') || \ index(['--paginate', '-p'], args[0]) >= 0 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:count ? 'split' : 'edit') . ' term://' . s:fnameescape(s:UserCommand(dir, args)) . '|startinsert' . after + return mods . (a:line2 ? 'split' : 'edit') . ' term://' . s:fnameescape(s:UserCommand(dir, args)) . assign . '|startinsert' . after elseif has('terminal') if &autowrite || &autowriteall | silent! wall | endif - return 'exe ' . string(mods . 'terminal ' . (a:count ? '' : '++curwin ') . join(map(s:UserCommandList(dir) + args, 's:fnameescape(v:val)'))) . after + return 'exe ' . string(mods . 'terminal ' . (a:line2 ? '' : '++curwin ') . join(map(s:UserCommandList(dir) + args, 's:fnameescape(v:val)'))) . assign . after endif endif if has('gui_running') && !has('win32') @@ -2149,7 +2183,9 @@ function! s:GitCommand(line1, line2, range, count, bang, mods, reg, arg, args) a if has('nvim') && executable('env') let pre .= 'env GIT_TERMINAL_PROMPT=0 ' endif - return 'exe ' . string('!' . escape(pre . s:UserCommand(dir, args), '!#%')) . after + return 'exe ' . string('noautocmd !' . escape(pre . s:UserCommand(dir, args), '!#%')) . + \ '|call fugitive#ReloadStatus(' . string(dir) . ', 1)' . + \ after endfunction let s:exec_paths = {} @@ -2177,7 +2213,7 @@ function! s:Aliases(dir) abort return s:aliases[a:dir] endfunction -function! fugitive#CompleteGit(lead, ...) abort +function! fugitive#Complete(lead, ...) abort let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir() let pre = a:0 > 1 ? strpart(a:1, 0, a:2) : '' let subcmd = matchstr(pre, '\u\w*[! ] *\zs[[:alnum:]-]\+\ze ') @@ -2193,35 +2229,24 @@ function! fugitive#CompleteGit(lead, ...) abort return filter(results, 'strpart(v:val, 0, strlen(a:lead)) ==# a:lead') endfunction -function! fugitive#Complete(...) abort - return call('fugitive#CompleteGit', a:000) -endfunction - -call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,fugitive#CompleteGit Git", "Git") -call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,fugitive#CompleteGit G", "Git") - " Section: :Gcd, :Glcd -function! s:DirComplete(A, L, P) abort +function! fugitive#CdComplete(A, L, P) abort return filter(fugitive#CompletePath(a:A), 'v:val =~# "/$"') endfunction -function! s:DirArg(path) abort +function! fugitive#Cd(path, ...) abort let path = substitute(a:path, '^:/:\=\|^:(\%(top\|top,literal\|literal,top\|literal\))', '', '') - if path =~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)' - return path - else - return FugitiveVimPath((empty(s:Tree()) ? s:Dir() : s:Tree()) . '/' . path) + if path !~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)' + let dir = s:Dir() + exe s:DirCheck(dir) + let path = (empty(s:Tree(dir)) ? dir : s:Tree(dir)) . '/' . path endif + return (a:0 && a:1 ? 'lcd ' : 'cd ') . s:fnameescape(FugitiveVimPath(path)) endfunction -call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Gcd :exe s:DirCheck()|exe 'cd' s:fnameescape(s:DirArg())") -call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe s:DirCheck()|exe 'lcd' s:fnameescape(s:DirArg())") - " Section: :Gstatus -call s:command("-bar -bang -range=-1 -addr=other Gstatus", "Status") - function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args, ...) abort let dir = a:0 ? a:1 : s:Dir() exe s:DirCheck(dir) @@ -2341,8 +2366,23 @@ function! s:StageSeek(info, fallback) abort return exists('backup') ? backup : line - 1 endfunction -function! s:ReloadStatus(...) abort - call s:ExpireStatus(-1) +function! s:DoAutocmdChanged(dir) abort + let dir = a:dir is# -2 ? '' : FugitiveGitDir(a:dir) + if empty(dir) || !exists('#User#FugitiveChanged') || exists('g:fugitive_event') + return '' + endif + try + let g:fugitive_event = dir + exe s:DoAutocmd('User FugitiveChanged') + finally + unlet! g:fugitive_event + " Force statusline reload with the buffer's Git dir + let &ro = &ro + endtry + return '' +endfunction + +function! s:ReloadStatusBuffer(...) abort if get(b:, 'fugitive_type', '') !=# 'index' return '' endif @@ -2354,6 +2394,13 @@ function! s:ReloadStatus(...) abort return '' endfunction +function! s:ReloadStatus(...) abort + call s:ExpireStatus(-1) + call s:ReloadStatusBuffer(a:0 ? a:1 : line('.')) + exe s:DoAutocmdChanged(-1) + return '' +endfunction + let s:last_time = reltime() if !exists('s:last_times') let s:last_times = {} @@ -2361,12 +2408,16 @@ endif function! s:ExpireStatus(bufnr) abort if a:bufnr == -2 + let s:head_cache = {} let s:last_time = reltime() return '' endif let dir = s:Dir(a:bufnr) if len(dir) let s:last_times[s:cpath(dir)] = reltime() + if has_key(s:head_cache, dir) + call remove(s:head_cache, dir) + endif endif return '' endfunction @@ -2382,13 +2433,13 @@ function! s:ReloadWinStatus(...) abort return endif if !exists('b:fugitive_reltime') - exe s:ReloadStatus() + exe s:ReloadStatusBuffer() return endif let t = b:fugitive_reltime if reltimestr(reltime(s:last_time, t)) =~# '-\|\d\{10\}\.' || \ reltimestr(reltime(get(s:last_times, s:cpath(s:Dir()), t), t)) =~# '-\|\d\{10\}\.' - exe s:ReloadStatus() + exe s:ReloadStatusBuffer() endif endfunction @@ -2417,28 +2468,42 @@ function! s:ReloadTabStatus(...) abort endfunction function! fugitive#ReloadStatus(...) abort - call s:ExpireStatus(a:0 ? a:1 : -2) - if a:0 > 1 ? a:2 : s:CanAutoReloadStatus() + call s:ExpireStatus(a:0 ? a:1 : -1) + if a:0 > 1 ? a:2 : 1 let t = reltime() let t:fugitive_reload_status = t for tabnr in exists('*settabvar') ? range(1, tabpagenr('$')) : [] call settabvar(tabnr, 'fugitive_reload_status', t) endfor call s:ReloadTabStatus() + exe s:DoAutocmdChanged(a:0 ? a:1 : -1) else call s:ReloadWinStatus() endif + return '' endfunction -function! s:CanAutoReloadStatus() abort - return get(g:, 'fugitive_autoreload_status', !has('win32')) +function! fugitive#EfmDir(...) abort + let dir = matchstr(a:0 ? a:1 : &errorformat, '\c,%\\&\%(git\|fugitive\)_\=dir=\zs\%(\\.\|[^,]\)*') + let dir = substitute(dir, '%%', '%', 'g') + let dir = substitute(dir, '\\\ze[\,]', '', 'g') + return dir endfunction augroup fugitive_status autocmd! autocmd BufWritePost * call fugitive#ReloadStatus(-1, 0) - autocmd ShellCmdPost * nested call fugitive#ReloadStatus() - autocmd BufDelete term://* nested call fugitive#ReloadStatus() + autocmd ShellCmdPost,ShellFilterPost * nested call fugitive#ReloadStatus(-2, 0) + autocmd BufDelete * nested + \ if getbufvar(+expand(''), 'buftype') ==# 'terminal' | + \ if !empty(FugitiveGitDir(+expand(''))) | + \ call fugitive#ReloadStatus(+expand(''), 1) | + \ else | + \ call fugitive#ReloadStatus(-2, 0) | + \ endif | + \ endif + autocmd QuickFixCmdPost make,lmake,[cl]file,[cl]getfile nested + \ call fugitive#ReloadStatus(fugitive#EfmDir(), 1) if !has('win32') autocmd FocusGained * call fugitive#ReloadStatus(-2, 0) endif @@ -2487,6 +2552,7 @@ function! s:StageInfo(...) abort \ 'paths': map(reverse(split(text, ' -> ')), 's:Tree() . "/" . v:val'), \ 'commit': matchstr(getline(lnum), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze '), \ 'status': matchstr(getline(lnum), '^[A-Z?]\ze \|^\%(\x\x\x\)\@!\l\+\ze [0-9a-f]'), + \ 'sub': get(get(get(b:fugitive_files, section, {}), text, {}), 'sub', ''), \ 'index': index} endfunction @@ -2503,7 +2569,7 @@ function! s:Selection(arg1, ...) abort endif let first = arg1 if arg2 < 0 - let last = first - arg2 + 1 + let last = first - arg2 - 1 elseif arg2 > 0 let last = arg2 else @@ -2608,7 +2674,7 @@ endfunction function! s:Do(action, visual) abort let line = getline('.') let reload = 0 - if !a:0 && !v:count && line =~# '^[A-Z][a-z]' + if !a:visual && !v:count && line =~# '^[A-Z][a-z]' let header = matchstr(line, '^\S\+\ze:') if len(header) && exists('*s:Do' . a:action . header . 'Header') let reload = s:Do{a:action}{header}Header(matchstr(line, ': \zs.*')) > 0 @@ -2656,8 +2722,9 @@ function! s:Do(action, visual) abort return '' endfunction -function! s:StageReveal(...) abort - let begin = a:0 ? a:1 : line('.') +function! s:StageReveal() abort + exe 'normal! zv' + let begin = line('.') if getline(begin) =~# '^@' let end = begin + 1 while getline(end) =~# '^[ \+-]' @@ -2935,7 +3002,15 @@ function! s:StageDiff(diff) abort let lnum = line('.') let info = s:StageInfo(lnum) let prefix = info.offset > 0 ? '+' . info.offset : '' - if empty(info.paths) && info.section ==# 'Staged' + if info.sub =~# '^S' + if info.section ==# 'Staged' + return 'Git! 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] + else + return 'Git! diff --no-ext-diff --submodule=diff -- ' . info.paths[0] + endif + elseif empty(info.paths) && info.section ==# 'Staged' return 'Git! diff --no-ext-diff --cached' elseif empty(info.paths) return 'Git! diff --no-ext-diff' @@ -3029,10 +3104,28 @@ function! s:StageDelete(lnum1, lnum2, count) abort if empty(info.paths) continue endif - let hash = s:TreeChomp('hash-object', '-w', '--', info.paths[0]) - if empty(hash) + let sub = get(get(get(b:fugitive_files, info.section, {}), info.filename, {}), 'sub') + if sub =~# '^S' + if info.status ==# 'A' + continue + endif + if info.section ==# 'Staged' + call s:TreeChomp('reset', '--', info.paths[0]) + endif + if info.status =~# '[MD]' + call s:TreeChomp('submodule', 'update', '--', info.paths[0]) + call add(restore, ':Git -C ' . info.relative[0] . ' checkout -') + endif continue endif + if info.status ==# 'D' + let undo = 'Gremove' + elseif info.paths[0] =~# '/$' + let err .= '|echoerr ' . string('fugitive: will not delete directory ' . string(info.relative[0])) + break + else + let undo = 'Gread ' . s:TreeChomp('hash-object', '-w', '--', info.paths[0])[0:10] + endif if info.patch call s:StageApply(info, 1, info.section ==# 'Staged' ? ['--index'] : []) elseif info.status ==# '?' @@ -3042,7 +3135,7 @@ function! s:StageDelete(lnum1, lnum2, count) abort elseif a:count == 3 call s:TreeChomp('checkout', '--theirs', '--', info.paths[0]) elseif info.status =~# '[ADU]' && - \ get(b:fugitive_status[info.section ==# 'Staged' ? 'Unstaged' : 'Staged'], info.filename, '') =~# '[AU]' + \ get(b:fugitive_files[info.section ==# 'Staged' ? 'Unstaged' : 'Staged'], info.filename, {'status': ''}).status =~# '[AU]' call s:TreeChomp('checkout', info.section ==# 'Staged' ? '--ours' : '--theirs', '--', info.paths[0]) elseif info.status ==# 'U' call s:TreeChomp('rm', '--', info.paths[0]) @@ -3053,17 +3146,21 @@ function! s:StageDelete(lnum1, lnum2, count) abort else call s:TreeChomp('checkout', 'HEAD^{}', '--', info.paths[0]) endif - call add(restore, ':Gsplit ' . s:fnameescape(info.relative[0]) . '|Gread ' . hash[0:6]) + call add(restore, ':Gsplit ' . s:fnameescape(info.relative[0]) . '|' . undo) endfor catch /^fugitive:/ - let err = '|echoerr ' . string(v:exception) + let err .= '|echoerr ' . string(v:exception) endtry if empty(restore) return err[1:-1] endif exe s:ReloadStatus() call s:StageReveal() - return 'checktime|redraw|echomsg ' . string('To restore, ' . join(restore, '|')) . err + if len(restore) + return 'checktime|redraw|echomsg ' . string('To restore, ' . join(restore, '|')) . err + else + return 'checktime|redraw' . err + endif endfunction function! s:StageIgnore(lnum1, lnum2, count) abort @@ -3356,14 +3453,14 @@ function! s:RevertSubcommand(line1, line2, range, bang, mods, args) abort let no_commit = s:HasOpt(a:args, '-n', '--no-commit', '--no-edit', '--abort', '--continue', '--quit') let cmd = s:UserCommand(dir, ['revert'] + (no_commit ? [] : ['-n']) + a:args) let [out, exec_error] = s:SystemError(cmd) - call fugitive#ReloadStatus(-1, 1) + call fugitive#ReloadStatus(dir, 1) if no_commit || exec_error return 'echo ' . string(substitute(out, "\n$", '', '')) endif return s:CommitSubcommand(a:line1, a:line2, a:range, a:bang, a:mods, [], dir) endfunction -function! s:CommitComplete(A, L, P) abort +function! fugitive#CommitComplete(A, L, P) abort if a:A =~# '^--fixup=\|^--squash=' let commits = s:LinesError(['log', '--pretty=format:%s', '@{upstream}..'])[0] let pre = matchstr(a:A, '^--\w*=''\=') . ':/^' @@ -3380,7 +3477,7 @@ function! s:CommitComplete(A, L, P) abort return [] endfunction -function! s:RevertComplete(A, L, P) abort +function! fugitive#RevertComplete(A, L, P) abort return s:CompleteSub('revert', a:A, a:L, a:P, function('s:CompleteRevision')) endfunction @@ -3398,20 +3495,17 @@ function! s:FinishCommit() abort return '' endfunction -call s:command("-nargs=? -range=-1 -complete=customlist,s:CommitComplete Gcommit", "commit") -call s:command("-nargs=? -range=-1 -complete=customlist,s:RevertComplete Grevert", "revert") - " Section: :Gmerge, :Grebase, :Gpull -function! s:MergeComplete(A, L, P) abort +function! fugitive#MergeComplete(A, L, P) abort return s:CompleteSub('merge', a:A, a:L, a:P, function('s:CompleteRevision')) endfunction -function! s:RebaseComplete(A, L, P) abort +function! fugitive#RebaseComplete(A, L, P) abort return s:CompleteSub('rebase', a:A, a:L, a:P, function('s:CompleteRevision')) endfunction -function! s:PullComplete(A, L, P) abort +function! fugitive#PullComplete(A, L, P) abort return s:CompleteSub('pull', a:A, a:L, a:P, function('s:CompleteRemote')) endfunction @@ -3678,21 +3772,17 @@ augroup fugitive_merge \ endif augroup END -call s:command("-nargs=? -bang -complete=customlist,s:MergeComplete Gmerge", "merge") -call s:command("-nargs=? -bang -complete=customlist,s:RebaseComplete Grebase", "rebase") -call s:command("-nargs=? -bang -complete=customlist,s:PullComplete Gpull", "pull") - " Section: :Ggrep, :Glog if !exists('g:fugitive_summary_format') let g:fugitive_summary_format = '%s' endif -function! s:GrepComplete(A, L, P) abort +function! fugitive#GrepComplete(A, L, P) abort return s:CompleteSub('grep', a:A, a:L, a:P) endfunction -function! s:LogComplete(A, L, P) abort +function! fugitive#LogComplete(A, L, P) abort return s:CompleteSub('log', a:A, a:L, a:P) endfunction @@ -3752,12 +3842,13 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort redraw call s:QuickfixCreate(listnr, {'title': (listnr < 0 ? ':Ggrep ' : ':Glgrep ') . s:fnameescape(args)}) let tempfile = tempname() - if v:version >= 704 | exe 'silent doautocmd QuickFixCmdPre ' (listnr < 0 ? 'Ggrep' : 'Glgrep') | endif + let event = listnr < 0 ? 'grep-fugitive' : 'lgrep-fugitive' + silent exe s:DoAutocmd('QuickFixCmdPre ' . event) exe '!' . escape(s:UserCommand(dir, 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') - if v:version >= 704 | exe 'silent doautocmd QuickFixCmdPost ' (listnr < 0 ? 'Ggrep' : 'Glgrep') | endif + silent exe s:DoAutocmd('QuickFixCmdPost ' . event) if !has('gui_running') redraw endif @@ -3835,7 +3926,7 @@ function! s:LogParse(state, dir, line) abort return [] endfunction -function! s:Log(type, bang, line1, count, args, legacy) abort +function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort let dir = s:Dir() exe s:DirCheck(dir) let listnr = a:type =~# '^l' ? 0 : -1 @@ -3899,26 +3990,19 @@ function! s:Log(type, bang, line1, count, args, legacy) abort if fugitive#GitVersion(1, 9) call extend(cmd, ['-c', 'diff.context=0', '-c', 'diff.noprefix=false', 'log']) else - call extend(cmd, ['log', '-U0', '--no-patch']) + call extend(cmd, ['log', '-U0', '-s']) endif call extend(cmd, \ ['--no-color', '--no-ext-diff', '--pretty=format:fugitive ' . format] + \ args + paths + extra) let state.target = path let title = (listnr < 0 ? ':Gclog ' : ':Gllog ') . s:fnameescape(args + paths) - if empty(paths + extra) && a:legacy && len(s:Relative('/')) + if empty(paths + extra) && empty(a:type) && 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, title, s:UserCommandList(dir) + cmd, !a:bang, s:function('s:LogParse'), state, dir) . after endfunction -call s:command("-bang -nargs=? -range=-1 -addr=windows -complete=customlist,s:GrepComplete Ggrep", "grep") -call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Gcgrep :execute s:GrepSubcommand(-1, -1, 0, 0, '', )") -call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:GrepSubcommand(0, 0, 0, 0, '', )") -call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Glog :exe s:Log('c',0,,,, 1)") -call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gclog :exe s:Log('c',0,,,, 0)") -call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gllog :exe s:Log('l',0,,,, 0)") - " Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread function! s:UsableWin(nr) abort @@ -3928,22 +4012,76 @@ function! s:UsableWin(nr) abort \ index(['nofile','help','quickfix'], getbufvar(winbufnr(a:nr), '&buftype')) < 0 endfunction -function! s:OpenParse(args) abort - let pre = [] +function! s:OpenParse(args, wants_cmd) abort + let opts = [] + let cmds = [] let args = copy(a:args) - while !empty(args) && args[0] =~# '^+' - call add(pre, ' ' . escape(remove(args, 0), ' |"')) + while !empty(args) + if args[0] =~# '^++' + call add(opts, ' ' . escape(remove(args, 0), ' |"')) + elseif a:wants_cmd && args[0] =~# '^+' + call add(cmds, remove(args, 0)[1:-1]) + else + break + endif endwhile if len(args) let file = join(args) elseif empty(expand('%')) - let file = ':' + let file = '' elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('./') !~# '^\./\.git\>' - let file = ':0:%' + let file = '>:0' else - let file = '%' + let file = '>' endif - return [s:Expand(file), join(pre)] + let dir = s:Dir() + let efile = s:Expand(file) + let url = fugitive#Find(efile, dir) + + if a:wants_cmd && file[0] ==# '>' && efile[0] !=# '>' && get(b:, 'fugitive_type', '') isnot# 'tree' && &filetype !=# 'netrw' + let line = line('.') + if expand('%:p') !=# url + let diffcmd = 'diff' + let from = s:DirRev(@%)[1] + let to = s:DirRev(url)[1] + if empty(from) && empty(to) + let diffcmd = 'diff-files' + let args = ['--', expand('%:p'), url] + elseif empty(to) + let args = [from, '--', url] + elseif empty(from) + let args = [to, '--', expand('%:p')] + let reverse = 1 + else + let args = [from, to] + endif + let [res, exec_error] = s:LinesError([dir, diffcmd, '-U0'] + args) + if !exec_error + call filter(res, 'v:val =~# "^@@ "') + call map(res, 'substitute(v:val, ''[-+]\d\+\zs '', ",1 ", "g")') + call map(res, 'matchlist(v:val, ''^@@ -\(\d\+\),\(\d\+\) +\(\d\+\),\(\d\+\) @@'')[1:4]') + if exists('reverse') + call map(res, 'v:val[2:3] + v:val[0:1]') + endif + call filter(res, 'v:val[0] < '.line('.')) + let hunk = get(res, -1, [0,0,0,0]) + if hunk[0] + hunk[1] > line('.') + let line = hunk[2] + max([1 - hunk[3], 0]) + else + let line = hunk[2] + max([hunk[3], 1]) + line('.') - hunk[0] - max([hunk[1], 1]) + endif + endif + endif + call insert(cmds, line) + endif + + let pre = join(opts, '') + if len(cmds) > 1 + let pre .= ' +' . escape(join(map(cmds, '"exe ".string(v:val)'), '|'), ' |"') + elseif len(cmds) + let pre .= ' +' . escape(cmds[0], ' |"') + endif + return [url, pre] endfunction function! s:DiffClose() abort @@ -4004,16 +4142,14 @@ function! s:OpenExec(cmd, mods, args, ...) abort return 'echo ' . string(':!' . s:UserCommand(dir, a:args)) endfunction -function! s:Open(cmd, bang, mods, arg, args) abort +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())) endif - exe s:DirCheck() let mods = s:Mods(a:mods) try - let [file, pre] = s:OpenParse(a:args) - let file = s:Generate(file) + let [file, pre] = s:OpenParse(a:args, 1) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry @@ -4026,7 +4162,7 @@ function! s:Open(cmd, bang, mods, arg, args) abort return mods . a:cmd . pre . ' ' . s:fnameescape(file) endfunction -function! s:ReadCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort +function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort let mods = s:Mods(a:mods) let after = a:count if a:count < 0 @@ -4042,13 +4178,11 @@ function! s:ReadCommand(line1, line2, range, count, bang, mods, reg, arg, args) 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() + call fugitive#ReloadStatus(dir, 1) return 'redraw|echo '.string(':!'.s:UserCommand(dir, args)) endif - exe s:DirCheck() try - let [file, pre] = s:OpenParse(a:args) - let file = s:Generate(file) + let [file, pre] = s:OpenParse(a:args, 0) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry @@ -4061,30 +4195,25 @@ function! s:ReadCommand(line1, line2, range, count, bang, mods, reg, arg, args) return mods . after . 'read' . pre . ' ' . s:fnameescape(file) . '|' . delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '') endfunction -function! s:ReadComplete(A,L,P) abort - if a:L =~# '^\w\+!' - return fugitive#CompleteGit(a:A, a:L, a:P) +function! fugitive#EditComplete(A, L, P) abort + if a:A =~# '^>' + return map(s:FilterEscape(s:CompleteHeads(s:Dir()), a:A[1:-1]), "'>' . v:val") else return fugitive#CompleteObject(a:A, a:L, a:P) endif endfunction -call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Ge execute s:Open('edit', 0, '', , [])") -call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gedit execute s:Open('edit', 0, '', , [])") -call s:command("-bar -bang -nargs=* -complete=customlist,s:ReadComplete Gpedit execute s:Open('pedit', 0, '', , [])") -call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:ReadComplete Gsplit execute s:Open(( > 0 ? : '').( ? 'split' : 'edit'), 0, '', , [])") -call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:ReadComplete Gvsplit execute s:Open(( > 0 ? : '').( ? 'vsplit' : 'edit!'), 0, '', , [])") -call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:ReadComplete -addr=tabs Gtabedit execute s:Open(( >= 0 ? : '').'tabedit', 0, '', , [])") -call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:ReadComplete Gread", "Read") +function! fugitive#ReadComplete(A, L, P) abort + if a:L =~# '^\w\+!' + return fugitive#Complete(a:A, a:L, a:P) + else + return fugitive#EditComplete(a:A, a:L, a:P) + endif +endfunction " Section: :Gwrite, :Gwq -call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gwrite", "Write") -call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gw", "Write") -call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gwq", "Wq") - -function! s:WriteCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort - exe s:DirCheck() +function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abort if exists('b:fugitive_commit_arguments') return 'write|bdelete' elseif expand('%:t') == 'COMMIT_EDITMSG' && $GIT_INDEX_FILE != '' @@ -4125,6 +4254,7 @@ function! s:WriteCommand(line1, line2, range, count, bang, mods, reg, arg, args) if file =~# '^fugitive:' return 'write' . (a:bang ? '! ' : ' ') . s:fnameescape(file) endif + exe s:DirCheck() let always_permitted = s:cpath(fugitive#Real(@%), file) && empty(s:DirCommitFile(@%)[1]) if !always_permitted && !a:bang && (len(s:TreeChomp('diff', '--name-status', 'HEAD', '--', file)) || len(s:TreeChomp('ls-files', '--others', '--', file))) let v:errmsg = 'fugitive: file has uncommitted changes (use ! to override)' @@ -4199,7 +4329,7 @@ function! s:WriteCommand(line1, line2, range, count, bang, mods, reg, arg, args) unlet! restorewinnr let zero = s:Generate(':0:'.file) - silent execute 'doautocmd' s:nomodeline 'BufWritePost' s:fnameescape(zero) + silent exe s:DoAutocmd('BufWritePost ' . s:fnameescape(zero)) for tab in range(1,tabpagenr('$')) for winnr in range(1,tabpagewinnr(tab,'$')) let bufnr = tabpagebuflist(tab)[winnr-1] @@ -4228,16 +4358,16 @@ function! s:WriteCommand(line1, line2, range, count, bang, mods, reg, arg, args) endif endfor endfor - call fugitive#ReloadStatus() + call fugitive#ReloadStatus(-1, 1) return 'checktime' endfunction -function! s:WqCommand(...) abort - let bang = a:5 ? '!' : '' +function! fugitive#WqCommand(...) abort + let bang = a:4 ? '!' : '' if exists('b:fugitive_commit_arguments') return 'wq'.bang endif - let result = call(s:function('s:WriteCommand'),a:000) + let result = call('fugitive#WriteCommand', a:000) if result =~# '^\%(write\|wq\|echoerr\)' return s:sub(result,'^write','wq') else @@ -4252,11 +4382,11 @@ augroup END " Section: :Gpush, :Gfetch -function! s:PushComplete(A, L, P) abort +function! fugitive#PushComplete(A, L, P) abort return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompleteRemote')) endfunction -function! s:FetchComplete(A, L, P) abort +function! fugitive#FetchComplete(A, L, P) abort return s:CompleteSub('fetch', a:A, a:L, a:P, function('s:CompleteRemote')) endfunction @@ -4277,7 +4407,8 @@ function! s:Dispatch(bang, cmd, args) abort let [mp, efm, cc] = [&l:mp, &l:efm, get(b:, 'current_compiler', '')] try let b:current_compiler = 'git' - let &l:errorformat = s:common_efm + 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) if exists(':Make') == 2 Make @@ -4290,7 +4421,7 @@ function! s:Dispatch(bang, cmd, args) abort endif silent noautocmd make! redraw! - return 'call fugitive#Cwindow()|call fugitive#ReloadStatus()' + return 'call fugitive#Cwindow()|silent ' . s:DoAutocmd('ShellCmdPost') endif finally let [&l:mp, &l:efm, b:current_compiler] = [mp, efm, cc] @@ -4309,15 +4440,8 @@ function! s:FetchSubcommand(line1, line2, range, bang, mods, args) abort return s:Dispatch(a:bang ? '!' : '', 'fetch', a:args) endfunction -call s:command("-nargs=? -bang -complete=customlist,s:PushComplete Gpush", "push") -call s:command("-nargs=? -bang -complete=customlist,s:FetchComplete Gfetch", "fetch") - " Section: :Gdiff -call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#CompleteObject Gdiffsplit :execute s:Diff(1, 0, '', )") -call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#CompleteObject Gvdiffsplit :execute s:Diff(0, 0, 'vertical ', )") -call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#CompleteObject Ghdiffsplit :execute s:Diff(0, 0, '', )") - augroup fugitive_diff autocmd! autocmd BufWinLeave * @@ -4332,7 +4456,6 @@ augroup END function! s:can_diffoff(buf) abort return getwinvar(bufwinnr(a:buf), '&diff') && - \ !empty(s:Dir(a:buf)) && \ !empty(getwinvar(bufwinnr(a:buf), 'fugitive_diff_restore')) endfunction @@ -4434,25 +4557,26 @@ function! s:IsConflicted() abort return len(@%) && !empty(s:ChompDefault('', 'ls-files', '--unmerged', '--', expand('%:p'))) endfunction -function! s:Diff(autodir, keepfocus, mods, ...) abort - if exists(':DiffGitCached') && !a:0 - return s:Mods(a:mods) . 'DiffGitCached' - endif - exe s:DirCheck() - let args = copy(a:000) +function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort + let args = copy(a:args) let post = '' if get(args, 0) =~# '^+' let post = remove(args, 0)[1:-1] endif + if exists(':DiffGitCached') && empty(args) + return s:Mods(a:mods) . 'DiffGitCached' . (len(post) ? '|' . post : '') + endif let commit = s:DirCommitFile(@%)[1] if a:mods =~# '\' let mods = substitute(a:mods, '\', '', 'g') - tab split + let pre = 'tab split' else let mods = 'keepalt ' . a:mods + let pre = '' endif let back = exists('*win_getid') ? 'call win_gotoid(' . win_getid() . ')' : 'wincmd p' if (empty(args) || args[0] ==# ':') && a:keepfocus + exe s:DirCheck() if empty(commit) && s:IsConflicted() let parents = [s:Relative(':2:'), s:Relative(':3:')] elseif empty(commit) @@ -4466,6 +4590,7 @@ function! s:Diff(autodir, keepfocus, mods, ...) abort endif try if exists('parents') && len(parents) > 1 + exe pre let mods = (a:autodir ? s:diff_modifier(len(parents) + 1) : '') . s:Mods(mods, 'leftabove') let nr = bufnr('') execute mods 'split' s:fnameescape(s:Generate(parents[0])) @@ -4492,11 +4617,14 @@ function! s:Diff(autodir, keepfocus, mods, ...) abort let arg = join(args, ' ') if arg ==# '' return post - elseif arg ==# '/' + elseif arg ==# ':/' + exe s:DirCheck() let file = s:Relative() elseif arg ==# ':' + exe s:DirCheck() let file = s:Relative(':0:') elseif arg =~# '^:\d$' + exe s:DirCheck() let file = s:Relative(arg . ':') else try @@ -4513,15 +4641,17 @@ function! s:Diff(autodir, keepfocus, mods, ...) abort let file = s:Relative(':1:') let post = 'echohl WarningMsg|echo "Use :Gdiffsplit! for 3 way diff"|echohl NONE|' . post else + exe s:DirCheck() let file = s:Relative(':0:') endif let spec = s:Generate(file) if spec =~# '^fugitive:' && empty(s:DirCommitFile(spec)[2]) let spec = FugitiveVimPath(spec . s:Relative('/')) endif + exe pre let restore = s:diff_restore() let w:fugitive_diff_restore = restore - if s:CompareAge(commit, s:DirCommitFile(spec)[1]) < 0 + if len(spec) && s:CompareAge(commit, s:DirCommitFile(spec)[1]) < 0 let mods = s:Mods(mods, 'rightbelow') else let mods = s:Mods(mods, 'leftabove') @@ -4554,26 +4684,31 @@ endfunction " Section: :Gmove, :Gremove function! s:Move(force, rename, destination) abort + let dir = s:Dir() + exe s:DirCheck(dir) + 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\+:\|^/' let destination = a:destination elseif a:destination =~# '^:/:\=' - let destination = s:Tree() . substitute(a:destination, '^:/:\=', '', '') + let destination = s:Tree(dir) . substitute(a:destination, '^:/:\=', '', '') elseif a:destination =~# '^:(\%(top\|top,literal\|literal,top\))' - let destination = s:Tree() . matchstr(a:destination, ')\zs.*') + let destination = s:Tree(dir) . matchstr(a:destination, ')\zs.*') elseif a:destination =~# '^:(literal)' let destination = simplify(getcwd() . '/' . matchstr(a:destination, ')\zs.*')) elseif a:rename let destination = expand('%:p:s?[\/]$??:h') . '/' . a:destination else - let destination = s:Tree() . '/' . a:destination + let destination = s:Tree(dir) . '/' . a:destination endif let destination = s:Slash(destination) if isdirectory(@%) setlocal noswapfile endif - let [message, exec_error] = s:ChompError(['mv'] + (a:force ? ['-f'] : []) + ['--', expand('%:p'), destination]) + let [message, exec_error] = s:ChompError(['mv'] + (a:force ? ['-f'] : []) + ['--', expand('%:p'), destination], dir) if exec_error let v:errmsg = 'fugitive: '.message return 'echoerr v:errmsg' @@ -4581,19 +4716,19 @@ function! s:Move(force, rename, destination) abort if isdirectory(destination) let destination = fnamemodify(s:sub(destination,'/$','').'/'.expand('%:t'),':.') endif - call fugitive#ReloadStatus() + let reload = '|call fugitive#ReloadStatus(' . string(dir) . ', 1)' if empty(s:DirCommitFile(@%)[1]) if isdirectory(destination) - return 'keepalt edit '.s:fnameescape(destination) + return 'keepalt edit '.s:fnameescape(destination) . reload else - return 'keepalt saveas! '.s:fnameescape(destination) + return 'keepalt saveas! '.s:fnameescape(destination) . reload endif else - return 'file '.s:fnameescape(s:Generate(':0:'.destination)) + return 'file '.s:fnameescape(fugitive#Find(':0:'.destination, dir)) . reload endif endfunction -function! s:RenameComplete(A,L,P) abort +function! fugitive#RenameComplete(A,L,P) abort if a:A =~# '^[.:]\=/' return fugitive#CompletePath(a:A) else @@ -4602,37 +4737,43 @@ function! s:RenameComplete(A,L,P) abort endif endfunction +function! fugitive#MoveCommand(line1, line2, range, bang, mods, arg, args) abort + return s:Move(a:bang, 0, a:arg) +endfunction + +function! fugitive#RenameCommand(line1, line2, range, bang, mods, arg, args) abort + return s:Move(a:bang, 1, a:arg) +endfunction + function! s:Remove(after, force) abort - if s:DirCommitFile(@%)[1] ==# '' + let dir = s:Dir() + exe s:DirCheck(dir) + if len(@%) && s:DirCommitFile(@%)[1] ==# '' let cmd = ['rm'] elseif s:DirCommitFile(@%)[1] ==# '0' let cmd = ['rm','--cached'] else - let v:errmsg = 'fugitive: rm not supported here' - return 'echoerr v:errmsg' + return 'echoerr ' . string('fugitive: rm not supported for this buffer') endif if a:force let cmd += ['--force'] endif - let [message, exec_error] = s:ChompError(cmd + ['--', expand('%:p')]) + let [message, exec_error] = s:ChompError(cmd + ['--', expand('%:p')], dir) if exec_error let v:errmsg = 'fugitive: '.s:sub(message,'error:.*\zs\n\(.*-f.*',' (add ! to force)') return 'echoerr '.string(v:errmsg) else - call fugitive#ReloadStatus() - return a:after . (a:force ? '!' : '') + return a:after . (a:force ? '!' : ''). '|call fugitive#ReloadStatus(' . string(dir) . ', 1)' endif endfunction -augroup fugitive_remove - autocmd! - autocmd User Fugitive if s:DirCommitFile(@%)[1] =~# '^0\=$' | - \ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,fugitive#CompletePath Gmove :execute s:Move(0,0,)" | - \ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,s:RenameComplete Grename :execute s:Move(0,1,)" | - \ exe "command! -buffer -bar -bang Gremove :execute s:Remove('edit',0)" | - \ exe "command! -buffer -bar -bang Gdelete :execute s:Remove('bdelete',0)" | - \ endif -augroup END +function! fugitive#RemoveCommand(line1, line2, range, bang, mods, arg, args) abort + return s:Remove('edit', a:bang) +endfunction + +function! fugitive#DeleteCommand(line1, line2, range, bang, mods, arg, args) abort + return s:Remove('bdelete', a:bang) +endfunction " Section: :Gblame @@ -4670,11 +4811,11 @@ function! s:BlameCommitFileLnum(...) abort let commit = matchstr(line, '^\^\=\zs\x\+') if commit =~# '^0\+$' let commit = '' - elseif line !~# '^\^' && has_key(state, 'blame_reverse_end') + elseif has_key(state, 'blame_reverse_end') let commit = get(s:LinesError('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\+ \)\@ 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'] call extend(cmd, filter(copy(flags), 'v:val !~# "\\v^%(-b|--%(no-)=color-.*|--progress)$"')) @@ -4805,9 +4944,10 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort else silent! execute '%write !'.basecmd.' > '.temp.' 2> '.error endif + let l:shell_error = v:shell_error redraw try - if v:shell_error + if l:shell_error let lines = readfile(error) if empty(lines) let lines = readfile(temp) @@ -4893,6 +5033,9 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort if exists('+relativenumber') setlocal norelativenumber endif + if exists('+signcolumn') + setlocal signcolumn=no + endif execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1) call s:Map('n', 'A', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze [0-9:/+-][0-9:/+ -]* \\d\\+)')+1+v:count)", '') call s:Map('n', 'C', ":exe 'vertical resize '.(linechars('^\\S\\+')+1+v:count)", '') @@ -4915,16 +5058,16 @@ function! s:BlameCommit(cmd, ...) abort let [commit, path, lnum] = s:BlameCommitFileLnum(line, state) if empty(commit) && len(path) && has_key(state, 'blame_reverse_end') let path = (len(state.blame_reverse_end) ? state.blame_reverse_end . ':' : ':(top)') . path - return s:Open(mods . a:cmd, 0, '', '+' . lnum . ' ' . s:fnameescape(path), ['+' . lnum, path]) + return fugitive#Open(mods . a:cmd, 0, '', '+' . lnum . ' ' . s:fnameescape(path), ['+' . lnum, path]) endif if commit =~# '^0*$' return 'echoerr ' . string('fugitive: no commit') endif if line =~# '^\^' && !has_key(state, 'blame_reverse_end') let path = commit . ':' . path - return s:Open(mods . a:cmd, 0, '', '+' . lnum . ' ' . s:fnameescape(path), ['+' . lnum, path]) + return fugitive#Open(mods . a:cmd, 0, '', '+' . lnum . ' ' . s:fnameescape(path), ['+' . lnum, path]) endif - let cmd = s:Open(mods . a:cmd, 0, '', commit, [commit]) + let cmd = fugitive#Open(mods . a:cmd, 0, '', commit, [commit]) if cmd =~# '^echoerr' return cmd endif @@ -5028,10 +5171,10 @@ function! fugitive#BlameSyntax() abort 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 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') - syn match FugitiveblameBoundaryIgnore "^\^\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite + syn match FugitiveblameBoundaryIgnore "^\^[*?]*\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite else syn match FugitiveblameBoundary "^\^" endif @@ -5106,8 +5249,8 @@ function! s:BlameFileType() abort if &modifiable return '' endif - call s:Map('n', '', ':help fugitive-:Gblame', '') - call s:Map('n', 'g?', ':help fugitive-:Gblame', '') + call s:Map('n', '', ':help :Gblame', '') + call s:Map('n', 'g?', ':help :Gblame', '') if mapcheck('q', 'n') =~# '^$\|bdelete' call s:Map('n', 'q', ':exe BlameQuit()echohl WarningMsgecho ":Gblame q is deprecated in favor of gq"echohl NONE', '') endif @@ -5130,15 +5273,11 @@ augroup fugitive_blame autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('')), 'fugitive_leave') augroup END -call s:command('-buffer -bang -range=-1 -nargs=? -complete=customlist,s:BlameComplete Gblame', 'blame') - " Section: :Gbrowse -call s:command("-bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse", "Browse") - let s:redirects = {} -function! s:BrowseCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort +function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abort let dir = s:Dir() exe s:DirCheck(dir) try @@ -5164,13 +5303,13 @@ function! s:BrowseCommand(line1, line2, range, count, bang, mods, reg, arg, args else let expanded = s:Expand(rev) endif - let cdir = FugitiveVimPath(fugitive#CommonDir(s:Dir())) + let cdir = FugitiveVimPath(fugitive#CommonDir(dir)) for subdir in ['tags/', 'heads/', 'remotes/'] if expanded !~# '^[./]' && filereadable(cdir . '/refs/' . subdir . expanded) let expanded = '.git/refs/' . subdir . expanded endif endfor - let full = s:Generate(expanded) + let full = fugitive#Find(expanded, dir) let commit = '' if full =~? '^fugitive:' let [pathdir, commit, path] = s:DirCommitFile(full) @@ -5188,10 +5327,10 @@ function! s:BrowseCommand(line1, line2, range, count, bang, mods, reg, arg, args let path = '.git/' . full[strlen(dir)+1:-1] let type = '' else - let path = full[strlen(s:Tree(dir))+1:-1] + let path = fugitive#Path(full, '/')[1:-1] if path =~# '^\.git/' let type = '' - elseif isdirectory(full) + elseif isdirectory(full) || empty(path) let type = 'tree' else let type = 'blob' @@ -5476,10 +5615,10 @@ 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 :Gcommit - nnoremap c :Gcommit - nnoremap cv :Gcommit -v - nnoremap cv :Gcommit -v + nnoremap c :Git commit + nnoremap c :Git commit + nnoremap cv :Git commit -v + nnoremap cv :Git commit -v nnoremap ca :Gcommit --amend nnoremap cc :Gcommit nnoremap ce :Gcommit --amend --no-edit @@ -5491,23 +5630,23 @@ function! fugitive#MapJumps(...) abort nnoremap cRw :Gcommit --reset-author --amend --only nnoremap cf :Gcommit --fixup==SquashArgument() nnoremap cF :Grebase --autosquash=RebaseArgument()Gcommit --fixup==SquashArgument() - nnoremap cs :Gcommit --squash==SquashArgument() - nnoremap cS :Grebase --autosquash=RebaseArgument()Gcommit --squash==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 - nnoremap cr :Grevert - nnoremap cr :Grevert + nnoremap cr :Git revert + nnoremap cr :Git revert nnoremap crc :Grevert =SquashArgument() nnoremap crn :Grevert --no-commit =SquashArgument() nnoremap cr? :help fugitive_cr - nnoremap cm :Gmerge - nnoremap cm :Gmerge + nnoremap cm :Git merge + nnoremap cm :Git merge nnoremap cm? :help fugitive_cm - nnoremap cz :G stash - nnoremap cz :G stash + 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 . '}']) @@ -5517,17 +5656,17 @@ function! fugitive#MapJumps(...) abort nnoremap czz :exe EchoExec(['stash'] + (v:count > 1 ? ['--all'] : v:count ? ['--include-untracked'] : [])) nnoremap cz? :help fugitive_cz - nnoremap co :G checkout - nnoremap co :G checkout + nnoremap co :Git checkout + nnoremap co :Git checkout nnoremap coo :exe EchoExec(['checkout'] + split(SquashArgument()) + ['--']) nnoremap co? :help fugitive_co - nnoremap cb :G branch - nnoremap cb :G branch + nnoremap cb :Git branch + nnoremap cb :Git branch nnoremap cb? :help fugitive_cb - nnoremap r :Grebase - nnoremap r :Grebase + nnoremap r :Git rebase + nnoremap r :Git rebase nnoremap ri :Grebase --interactive=RebaseArgument() nnoremap rf :Grebase --autosquash=RebaseArgument() nnoremap ru :Grebase --interactive @{upstream} @@ -5545,8 +5684,8 @@ function! fugitive#MapJumps(...) abort call s:Map('n', '.', ": =fnameescape(fugitive#Real(@%))") call s:Map('x', '.', ": =fnameescape(fugitive#Real(@%))") - call s:Map('n', 'g?', ":help fugitive-mappings", '') - call s:Map('n', '', ":help fugitive-mappings", '') + call s:Map('n', 'g?', ":help fugitive-map", '') + call s:Map('n', '', ":help fugitive-map", '') endif endfunction @@ -5795,7 +5934,8 @@ endfunction " Section: Statusline function! fugitive#Statusline(...) abort - if empty(s:Dir()) + let dir = s:Dir(bufnr('')) + if empty(dir) return '' endif let status = '' @@ -5803,7 +5943,7 @@ function! fugitive#Statusline(...) abort if len(commit) let status .= ':' . commit[0:6] endif - let status .= '('.FugitiveHead(7).')' + let status .= '('.FugitiveHead(7, dir).')' return '[Git'.status.']' endfunction @@ -5880,37 +6020,19 @@ augroup END function! fugitive#Init() abort if exists('#User#FugitiveBoot') - try - let [save_mls, &modelines] = [&mls, 0] - doautocmd User FugitiveBoot - finally - let &mls = save_mls - endtry - endif - if !exists('g:fugitive_no_maps') - call s:Map('c', '', 'fnameescape(fugitive#Object(@%))', '') - call s:Map('n', 'y', ':call setreg(v:register, fugitive#Object(@%))', '') - endif - if expand('%:p') =~# ':[\/][\/]' - let &l:path = s:sub(&path, '^\.%(,|$)', '') + exe s:DoAutocmd('User FugitiveBoot') endif let dir = s:Dir() - if stridx(&tags, escape(dir, ', ')) == -1 + if &tags !~# '\.git' && @% !~# '\.git' && !exists('s:tags_warning') let actualdir = fugitive#Find('.git/', dir) if filereadable(actualdir . 'tags') - let &l:tags = escape(actualdir . 'tags', ', ').','.&tags - endif - if &filetype !=# '' && filereadable(actualdir . &filetype . '.tags') - let &l:tags = escape(actualdir . &filetype . '.tags', ', ').','.&tags + let s:tags_warning = 1 + echohl WarningMsg + echo "Fugitive .git/tags support removed in favor of `:set tags^=./.git/tags;`" + echohl NONE endif endif - try - let [save_mls, &modelines] = [&mls, 0] - call s:define_commands() - doautocmd User Fugitive - finally - let &mls = save_mls - endtry + exe s:DoAutocmd('User Fugitive') endfunction function! fugitive#is_git_dir(path) abort diff --git a/sources_non_forked/vim-fugitive/doc/fugitive.txt b/sources_non_forked/vim-fugitive/doc/fugitive.txt index d4750ddc..999bfdf1 100644 --- a/sources_non_forked/vim-fugitive/doc/fugitive.txt +++ b/sources_non_forked/vim-fugitive/doc/fugitive.txt @@ -15,186 +15,63 @@ COMMANDS *fugitive-commands* These commands are local to the buffers in which they work (generally, buffers that are part of Git repositories). - *fugitive-:G* *fugitive-:Gstatus* -:G Bring up a summary window vaguely akin to git-status. -:Gstatus Press g? or see |fugitive-mappings| for usage. - - *fugitive-:Git* + *:Git* *fugitive-:G* :Git {args} Run an arbitrary git command. Similar to :!git [args] :G {args} but chdir to the repository tree first. For some subcommands, a Fugitive command is called instead. - Invoking :Git push will call :Gpush for example. - *fugitive-:Git!* + *:Git!* :Git! {args} Like |:Git|, but capture the output into a temp file, :Git --no-pager {args} 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. - *fugitive-:Gcd* -:Gcd [directory] |:cd| relative to the repository. + *:Gstatus* +:Git Bring up a summary window vaguely akin to git-status. +:G Press g? or see |fugitive-maps| for usage. +:Gstatus - *fugitive-:Glcd* -:Glcd [directory] |:lcd| relative to the repository. - - *fugitive-:Gcommit* -:Gcommit [args] A wrapper around git-commit. Unless the arguments - given would skip the invocation of an editor (e.g., + *:Git-commit* *:Gcommit* +:Git commit [args] A wrapper around git-commit. Unless the arguments +:Gcommit [args] given would skip the invocation of an editor (e.g., -m), a split window will be used to obtain a commit message, or a new tab if -v is given. Write and close the window (:wq) to finish the commit. To cancel, use an empty message. - *fugitive-:Grevert* -:Grevert [args] A wrapper around git-revert. Similar to |:Gcommit|. + *:Git-revert* *:Grevert* +:Git revert [args] A wrapper around git-revert. Similar to |:Gcommit|. +:Grevert [args] - *fugitive-:Gmerge* -:Gmerge [args] Calls git-merge and loads errors and conflicted files - into the |quickfix| list. Opens a |:Gcommit| style + *:Git-merge* *:Gmerge* +:Git merge [args] Calls git-merge and loads errors and conflicted files +:Gmerge [args] into the |quickfix| list. Opens a |:Gcommit| style split window for the commit message if the merge succeeds. If called during a merge conflict, the conflicted files from the current index are loaded into the |quickfix| list. - *fugitive-:Gpull* -:Gpull [args] Like |:Gmerge|, but for git-pull. + *:Git-pull* *:Gpull* +:Git pull [args] Like |:Gmerge|, but for git-pull. +:Gpull [args] - *fugitive-:Grebase* -:Grebase [args] Like |:Gmerge|, but for git-rebase. Interactive - rebase is experimentally supported. + *:Git-rebase* *:Grebase* +:Git rebase [args] Like |:Gmerge|, but for git-rebase. Interactive +:Grebase [args] rebase is experimentally supported. - *fugitive-:Gpush* -:Gpush [args] Invoke git-push, load the results into the |quickfix| - list, and invoke |:cwindow| to reveal any errors. + *:Git-push* *:Gpush* +:Git push [args] Invoke git-push, load the results into the |quickfix| +:Gpush [args] list, and invoke |:cwindow| to reveal any errors. |:Dispatch| is used if available for asynchronous invocation. - *fugitive-:Gfetch* -:Gfetch [args] Like |:Gpush|, but for git-fetch. + *:Git-fetch* *:Gfetch* +:Git fetch [args] Like |:Gpush|, but for git-fetch. +:Gfetch [args] - *fugitive-:Ggrep* *fugitive-:Gcgrep* -:Ggrep[!] [args] |:grep|[!] with git-grep as 'grepprg'. - - *fugitive-:Glgrep* -:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'. - - *fugitive-:Gclog* *fugitive-:Glog* -:Gclog[!] [args] Use git-log [args] to load the commit history into the -:Glog[!] [args] |quickfix| list. Jump to the first commit unless [!] - is given. - -:{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given - range of the current file into the |quickfix| list. - The cursor is positioned on the first line of the - first diff hunk for each commit. Use :0Gclog to - target the entire file. - - *fugitive-:Gllog* -:Gllog [args] Like |:Gclog|, but use the location list instead of the - |quickfix| list. - - *fugitive-:Gedit* *fugitive-:Ge* -:Gedit [object] |:edit| a |fugitive-object|. - - *fugitive-:Gsplit* -:Gsplit [object] |:split| a |fugitive-object|. - - *fugitive-:Gvsplit* -:Gvsplit [object] |:vsplit| a |fugitive-object|. - - *fugitive-:Gtabedit* -:Gtabedit [object] |:tabedit| a |fugitive-object|. - - *fugitive-:Gpedit* -:Gpedit [object] |:pedit| a |fugitive-object|. - -:Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!* -:Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-: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. - - *fugitive-:Gread* -:Gread [object] Empty the buffer and |:read| a |fugitive-object|. - When the argument is omitted, this is similar to - git-checkout on a work tree file or git-add on a stage - file, but without writing anything to disk. - -:{range}Gread [object] |:read| in a |fugitive-object| after {range}. - - *fugitive-:Gread!* -:Gread! [args] Empty the buffer and |:read| the output of a Git - command. For example, :Gread! show HEAD:%. - -:{range}Gread! [args] |:read| the output of a Git command after {range}. - - *fugitive-:Gw* *fugitive-:Gwrite* -:Gwrite Write to the current file's path and stage the results. - When run in a work tree file, it is effectively git - add. Elsewhere, it is effectively git-checkout. A - great deal of effort is expended to behave sensibly - when the work tree or index version of the file is - open in another buffer. - -:Gwrite {path} You can give |:Gwrite| an explicit path of where in - the work tree to write. You can also give a path like - :0:foo.txt or :0:% to write to just that stage in - the index. - - *fugitive-:Gwq* -:Gwq [path] Like |:Gwrite| followed by |:quit| if the write - succeeded. - -:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write - succeeded. - - *fugitive-:Gdiffsplit* -:Gdiffsplit [object] Perform a |vimdiff| against the given file, or if a - commit is given, the current file in that commit. - With no argument, the version in the index or work - tree is used. The newer of the two files is placed to - the right or bottom, depending on 'diffopt' and the - width of the window relative to 'textwidth'. Use - Vim's |do| and |dp| to stage and unstage changes. - - *fugitive-:Gdiffsplit!* -:Gdiffsplit! Diff against any and all direct ancestors, retaining - focus on the current window. During a merge conflict, - this is a three-way diff against the "ours" and - "theirs" ancestors. Additional d2o and d3o maps are - provided to to obtain the hunk from the "ours" or - "theirs" ancestor, respectively. - -:Gdiffsplit! {object} Like |:Gdiffsplit|, but retain focus on the current - window. - - *fugitive-:Gvdiffsplit* -:Gvdiffsplit [object] Like |:Gdiffsplit|, but always split vertically. - - *fugitive-:Ghdiffsplit* *fugitive-:Gsdiff* -:Ghdiffsplit [object] Like |:Gdiffsplit|, but always split horizontally. - - *fugitive-:Gmove* -:Gmove {destination} Wrapper around git-mv that renames the buffer - afterward. Add a ! to pass -f. - - *fugitive-:Grename* -:Grename {destination} Like |:Gmove| but operates relative to the parent - directory of the current file. - - *fugitive-: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. - - *fugitive-:Gremove* -:Gremove Like :Gdelete, but keep the (now empty) buffer around. - - *fugitive-:Gblame* -:Gblame [flags] Run git-blame [flags] on the current file and open the - results in a scroll-bound vertical split. The + *:Git-blame* *:Gblame* +:Git blame [flags] Run git-blame [flags] on the current file and open the +:Gblame [flags] results in a scroll-bound vertical split. The following maps, which work on the cursor line commit where sensible, are provided: @@ -215,10 +92,138 @@ that are part of Git repositories). :[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 - scrollbinding is used. You can also give an arbitrary +:Git blame ... scrollbinding is used. You can also give an arbitrary filename. - *fugitive-:Gbrowse* + *: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] + + *:Gclog* *:Glog* +:Gclog[!] [args] Use git-log [args] to load the commit history into the +:Glog[!] [args] |quickfix| list. Jump to the first commit unless [!] + is given. + +:{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given + range of the current file into the |quickfix| list. + The cursor is positioned on the first line of the + first diff hunk for each commit. Use :0Gclog to + target the entire file. + + *:Gllog* +:Gllog [args] Like |:Gclog|, but use the location list instead of the + |quickfix| list. + + *:Gcd* +:Gcd [directory] |:cd| relative to the repository. + + *:Glcd* +:Glcd [directory] |:lcd| relative to the repository. + + *:Gedit* *fugitive-:Ge* +:Gedit [object] |:edit| a |fugitive-object|. + + *:Gsplit* +:Gsplit [object] |:split| a |fugitive-object|. + + *:Gvsplit* +:Gvsplit [object] |:vsplit| a |fugitive-object|. + + *:Gtabedit* +:Gtabedit [object] |:tabedit| a |fugitive-object|. + + *: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 + git-checkout on a work tree file or git-add on a stage + file, but without writing anything to disk. + +:{range}Gread [object] |:read| in a |fugitive-object| after {range}. + + *:Gread!* *fugitive-:Gr!* +:Gread! [args] Empty the buffer and |:read| the output of a Git + command. For example, :Gread! show HEAD:%. + +:{range}Gread! [args] |:read| the output of a Git command after {range}. + + *:Gwrite* *fugitive-:Gw* +:Gwrite Write to the current file's path and stage the results. + When run in a work tree file, it is effectively git + add. Elsewhere, it is effectively git-checkout. A + great deal of effort is expended to behave sensibly + when the work tree or index version of the file is + open in another buffer. + +:Gwrite {path} You can give |:Gwrite| an explicit path of where in + the work tree to write. You can also give a path like + :0:foo.txt or :0:% to write to just that stage in + the index. + + *:Gwq* +:Gwq [path] Like |:Gwrite| followed by |:quit| if the write + succeeded. + +:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write + succeeded. + + *:Gdiffsplit* +:Gdiffsplit [object] Perform a |vimdiff| against the given file, or if a + commit is given, the current file in that commit. + With no argument, the version in the index or work + tree is used. The newer of the two files is placed to + the right or bottom, depending on 'diffopt' and the + width of the window relative to 'textwidth'. Use + Vim's |do| and |dp| to stage and unstage changes. + + *:Gdiffsplit!* +:Gdiffsplit! Diff against any and all direct ancestors, retaining + focus on the current window. During a merge conflict, + this is a three-way diff against the "ours" and + "theirs" ancestors. Additional d2o and d3o maps are + provided to to obtain the hunk from the "ours" or + "theirs" ancestor, respectively. + +:Gdiffsplit! {object} Like |:Gdiffsplit|, but retain focus on the current + window. + + *:Gvdiffsplit* +:Gvdiffsplit [object] Like |:Gdiffsplit|, but always split vertically. + + *:Ghdiffsplit* *:Gsdiff* +:Ghdiffsplit [object] Like |:Gdiffsplit|, but always split horizontally. + + *: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 + directory of the current file. + + *: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. + + *: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 @@ -244,15 +249,15 @@ that are part of Git repositories). :[range]Gbrowse! [args] Like :Gbrowse, but put the URL on the clipboard rather than opening it. -MAPPINGS *fugitive-mappings* +MAPS *fugitive-maps* -These mappings are available in both the |:Gstatus| buffer and Fugitive object -buffers, although not all mappings make sense in all buffers. Mappings that +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. - *fugitive-staging-mappings* -Staging/unstaging mappings ~ + *fugitive-staging-maps* +Staging/unstaging maps ~ *fugitive_s* s Stage (add) the file or hunk under the cursor. @@ -294,7 +299,7 @@ P under the cursor. On untracked files, this instead calls |:Git| add --intent-to-add. *fugitive_d* -Diff mappings ~ +Diff maps ~ *fugitive_dp* dp Invoke |:Git!| diff on the file under the cursor. Deprecated in favor of inline diffs. @@ -315,8 +320,8 @@ dq Close all but one diff buffer, and |:diffoff|! the *fugitive_d?* d? Show this help. - *fugitive-navigation-mappings* -Navigation mappings ~ + *fugitive-navigation-maps* +Navigation maps ~ *fugitive_* Open the file or |fugitive-object| under the cursor. @@ -426,7 +431,7 @@ gi Open .git/info/exclude in a split. Use a count to open .gitignore. *fugitive_c* -Commit mappings ~ +Commit maps ~ cc Create a commit. @@ -455,7 +460,7 @@ cS Create a `squash!` commit for the commit under the cA Create a `squash!` commit for the commit under the cursor and edit the message. -c Populate command line with ":Gcommit ". +c Populate command line with ":Git commit ". *fugitive_cr* crc Revert the commit under the cursor. @@ -463,28 +468,28 @@ crc Revert the commit under the cursor. crn Revert the commit under the cursor in the index and work tree, but do not actually commit the changes. -cr Populate command line with ":Grevert ". +cr Populate command line with ":Git revert ". *fugitive_cm* -cm Populate command line with ":Gmerge ". +cm Populate command line with ":Git merge ". c? Show this help. *fugitive_cb* *fugitive_co* -Checkout/branch mappings ~ +Checkout/branch maps ~ coo Check out the commit under the cursor. -cb Populate command line with ":G branch ". +cb Populate command line with ":Git branch ". -co Populate command line with ":G checkout ". +co Populate command line with ":Git checkout ". cb? Show this help. co? *fugitive_cz* -Stash mappings ~ +Stash maps ~ czz Push stash. Pass a [count] of 1 to add `--include-untracked` or 2 to add `--all`. @@ -502,12 +507,12 @@ czP Pop topmost stash, or stash@{count}. czp Pop topmost stash, or stash@{count}, preserving the index. -cz Populate command line with ":G stash ". +cz Populate command line with ":Git stash ". cz? Show this help. *fugitive_r* -Rebase mappings ~ +Rebase maps ~ ri Perform an interactive rebase. Uses ancestor of u commit under cursor as upstream if available. @@ -538,12 +543,12 @@ rm Perform an interactive rebase with the commit under rd Perform an interactive rebase with the commit under the cursor set to `drop`. -r Populate command line with ":Grebase ". +r Populate command line with ":Git rebase ". r? Show this help. - *fugitive-misc-mappings* -Miscellaneous mappings ~ + *fugitive-misc-maps* +Miscellaneous maps ~ *fugitive_gq* *fugitive_q* gq Close the status buffer. @@ -553,10 +558,10 @@ gq Close the status buffer. cursor prepopulated. *fugitive_g?* -g? Show help for |fugitive-mappings|. +g? Show help for |fugitive-maps|. - *fugitive-global-mappings* -Global mappings ~ + *fugitive-global-maps* +Global maps ~ *fugitive_c_CTRL-R_CTRL-G* On the command line, recall the path to the current @@ -566,6 +571,11 @@ Global mappings ~ *fugitive_y_CTRL-G* ["x]y Yank the path to the current |fugitive-object|. + *g:fugitive_no_maps* +Global maps can be disabled with the g:fugitive_no_maps option. +> + let g:fugitive_no_maps = 1 +< SPECIFYING OBJECTS *fugitive-object* *fugitive-revision* Fugitive objects are either work tree files or Git revisions as defined in the @@ -581,7 +591,7 @@ master^ The parent of the commit referenced by master master...other The merge base of master and other master: The tree referenced by master ./master The file named master in the working directory -:(top)master The file named master in the the work tree +:(top)master The file named master in the work tree Makefile The file named Makefile in the work tree @^:Makefile The file named Makefile in the parent of HEAD :Makefile The file named Makefile in the index (writable) diff --git a/sources_non_forked/vim-fugitive/plugin/fugitive.vim b/sources_non_forked/vim-fugitive/plugin/fugitive.vim index b7d191fd..be3b99bb 100644 --- a/sources_non_forked/vim-fugitive/plugin/fugitive.vim +++ b/sources_non_forked/vim-fugitive/plugin/fugitive.vim @@ -1,6 +1,6 @@ " fugitive.vim - A Git wrapper so awesome, it should be illegal " Maintainer: Tim Pope -" Version: 3.0 +" Version: 3.1 " GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim if exists('g:loaded_fugitive') @@ -9,8 +9,15 @@ endif let g:loaded_fugitive = 1 function! FugitiveGitDir(...) abort - if !a:0 || a:1 ==# -1 - return get(b:, 'git_dir', '') + if !a:0 || type(a:1) == type(0) && a:1 < 0 + if exists('g:fugitive_event') + return g:fugitive_event + endif + let dir = get(b:, 'git_dir', '') + if empty(dir) && (empty(bufname('')) || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|prompt\)$') + return FugitiveExtractGitDir(getcwd()) + endif + return dir elseif type(a:1) == type(0) return getbufvar(a:1, 'git_dir') elseif type(a:1) == type('') @@ -150,16 +157,16 @@ function! s:Tree(path) abort let config = readfile(config_file,'',10) call filter(config,'v:val =~# "^\\s*worktree *="') if len(config) == 1 - let worktree = s:Slash(FugitiveVimPath(matchstr(config[0], '= *\zs.*'))) + let worktree = FugitiveVimPath(matchstr(config[0], '= *\zs.*')) endif elseif filereadable(dir . '/gitdir') - let worktree = s:Slash(fnamemodify(FugitiveVimPath(readfile(dir . '/gitdir')[0]), ':h')) + let worktree = fnamemodify(FugitiveVimPath(readfile(dir . '/gitdir')[0]), ':h') if worktree ==# '.' unlet! worktree endif endif if exists('worktree') - let s:worktree_for_dir[dir] = worktree + let s:worktree_for_dir[dir] = s:Slash(resolve(worktree)) let s:dir_for_worktree[s:worktree_for_dir[dir]] = dir endif endif @@ -278,17 +285,28 @@ function! s:ProjectionistDetect() abort endif endfunction +let g:io_fugitive = { + \ 'simplify': function('fugitive#simplify'), + \ 'resolve': function('fugitive#resolve'), + \ 'getftime': function('fugitive#getftime'), + \ 'getfsize': function('fugitive#getfsize'), + \ 'getftype': function('fugitive#getftype'), + \ 'filereadable': function('fugitive#filereadable'), + \ 'filewritable': function('fugitive#filewritable'), + \ 'isdirectory': function('fugitive#isdirectory'), + \ 'getfperm': function('fugitive#getfperm'), + \ 'setfperm': function('fugitive#setfperm'), + \ 'readfile': function('fugitive#readfile'), + \ 'writefile': function('fugitive#writefile'), + \ 'glob': function('fugitive#glob'), + \ 'delete': function('fugitive#delete'), + \ 'Real': function('FugitiveReal')} + augroup fugitive autocmd! autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand(':p')) autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('')), ':p')) - autocmd User NERDTreeInit,NERDTreeNewRoot - \ if exists('b:NERDTree.root.path.str') | - \ call FugitiveDetect(b:NERDTree.root.path.str()) | - \ endif - autocmd VimEnter * if empty(expand(''))|call FugitiveDetect(getcwd())|endif - autocmd CmdWinEnter * call FugitiveDetect(expand('#:p')) autocmd FileType git \ if len(FugitiveGitDir()) | @@ -324,7 +342,10 @@ augroup fugitive \ silent doautocmd BufNewFile | \ endif - autocmd BufReadCmd fugitive://*//* exe fugitive#BufReadCmd() + autocmd BufReadCmd fugitive://*//* exe fugitive#BufReadCmd() | + \ if &path =~# '^\.\%(,\|$\)' | + \ let &l:path = substitute(&path, '^\.,\=', '', '') | + \ endif autocmd BufWriteCmd fugitive://*//[0-3]/* exe fugitive#BufWriteCmd() autocmd FileReadCmd fugitive://*//* exe fugitive#FileReadCmd() autocmd FileWriteCmd fugitive://*//[0-3]/* exe fugitive#FileWriteCmd() @@ -337,19 +358,93 @@ augroup fugitive autocmd User ProjectionistDetect call s:ProjectionistDetect() augroup END -let g:io_fugitive = { - \ 'simplify': function('fugitive#simplify'), - \ 'resolve': function('fugitive#resolve'), - \ 'getftime': function('fugitive#getftime'), - \ 'getfsize': function('fugitive#getfsize'), - \ 'getftype': function('fugitive#getftype'), - \ 'filereadable': function('fugitive#filereadable'), - \ 'filewritable': function('fugitive#filewritable'), - \ 'isdirectory': function('fugitive#isdirectory'), - \ 'getfperm': function('fugitive#getfperm'), - \ 'setfperm': function('fugitive#setfperm'), - \ 'readfile': function('fugitive#readfile'), - \ 'writefile': function('fugitive#writefile'), - \ 'glob': function('fugitive#glob'), - \ 'delete': function('fugitive#delete'), - \ 'Real': function('FugitiveReal')} +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, "", )' + +exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(, , +"", 0, "", )' + +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 " . )' + +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 -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 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, "", , [])' +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", 0, "", , [])' +exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open(( > 0 ? : "").( ? "split" : "edit"), 0, "", , [])' +exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open(( > 0 ? : "").( ? "vsplit" : "edit!"), 0, "", , [])' +exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open(( >= 0 ? : "")."tabedit", 0, "", , [])' + +if exists(':Gr') != 2 + exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(, , +"", 0, "", , [])' +endif +exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gread exe fugitive#ReadCommand(, , +"", 0, "", , [])' + +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdiffsplit exe fugitive#Diffsplit(1, 0, "", , [])' +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ghdiffsplit exe fugitive#Diffsplit(0, 0, "", , [])' +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gvdiffsplit exe fugitive#Diffsplit(0, 0, "vert ", , [])' + +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe fugitive#WriteCommand(, , +"", 0, "", , [])' +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 -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' + +if get(g:, 'fugitive_no_maps') + finish +endif + +let s:nowait = v:version >= 704 ? '' : '' + +function! s:Map(mode, lhs, rhs, ...) abort + for mode in split(a:mode, '\zs') + let flags = (a:0 ? a:1 : '') . (a:rhs =~# '' ? '' : '