diff --git a/sources_non_forked/ale/ale_linters/astro/eslint.vim b/sources_non_forked/ale/ale_linters/astro/eslint.vim new file mode 100644 index 00000000..9fb51ad2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/astro/eslint.vim @@ -0,0 +1,11 @@ +" Author: Hyuksang Kwon <gwonhyuksang@gmail.com> +" Description: eslint for astro files + +call ale#linter#Define('astro', { +\ 'name': 'eslint', +\ 'output_stream': 'both', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), +\ 'command': function('ale#handlers#eslint#GetCommand'), +\ 'callback': 'ale#handlers#eslint#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim b/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim index 3c44c92f..5942e08d 100644 --- a/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim +++ b/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim @@ -15,7 +15,7 @@ function! ale_linters#cmake#cmake_lint#Command(buffer) abort let l:executable = ale_linters#cmake#cmake_lint#Executable(a:buffer) let l:options = ale#Var(a:buffer, 'cmake_cmake_lint_options') - return ale#Escape(l:executable) . ' ' . l:options . ' %t' + return ale#Escape(l:executable) . ' ' . l:options . ' %s' endfunction function! ale_linters#cmake#cmake_lint#Handle(buffer, lines) abort diff --git a/sources_non_forked/ale/ale_linters/css/stylelint.vim b/sources_non_forked/ale/ale_linters/css/stylelint.vim index e508f392..ceb42461 100644 --- a/sources_non_forked/ale/ale_linters/css/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/css/stylelint.vim @@ -11,6 +11,7 @@ endfunction call ale#linter#Define('css', { \ 'name': 'stylelint', +\ 'output_stream': 'both', \ 'executable': {b -> ale#path#FindExecutable(b, 'css_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, diff --git a/sources_non_forked/ale/ale_linters/dart/analysis_server.vim b/sources_non_forked/ale/ale_linters/dart/analysis_server.vim index a6870da9..12a5d590 100644 --- a/sources_non_forked/ale/ale_linters/dart/analysis_server.vim +++ b/sources_non_forked/ale/ale_linters/dart/analysis_server.vim @@ -1,6 +1,7 @@ " Author: Nelson Yeung <nelsyeung@gmail.com> " Description: Check Dart files with dart analysis server LSP +call ale#Set('dart_analysis_server_enable_language_server', 1) call ale#Set('dart_analysis_server_executable', 'dart') function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort @@ -12,12 +13,19 @@ function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort endfunction function! ale_linters#dart#analysis_server#GetCommand(buffer) abort + let l:language_server = ale#Var(a:buffer, 'dart_analysis_server_enable_language_server') let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable') let l:dart = resolve(exepath(l:executable)) - - return '%e ' + let l:output = '%e ' \ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot' \ . ' --lsp' + + " Enable new language-server command + if l:language_server == 1 + let l:output = '%e language-server --protocol=lsp' + endif + + return l:output endfunction call ale#linter#Define('dart', { diff --git a/sources_non_forked/ale/ale_linters/elm/ls.vim b/sources_non_forked/ale/ale_linters/elm/ls.vim index 38a5b234..111f3ac2 100644 --- a/sources_non_forked/ale/ale_linters/elm/ls.vim +++ b/sources_non_forked/ale/ale_linters/elm/ls.vim @@ -16,7 +16,7 @@ function! ale_linters#elm#ls#GetProjectRoot(buffer) abort return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : '' endfunction -function! ale_linters#elm#ls#GetOptions(buffer) abort +function! ale_linters#elm#ls#GetInitializationOptions(buffer) abort return { \ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'), \ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'), @@ -37,5 +37,5 @@ call ale#linter#Define('elm', { \ 'command': '%e --stdio', \ 'project_root': function('ale_linters#elm#ls#GetProjectRoot'), \ 'language': 'elm', -\ 'initialization_options': function('elm_ls#GetOptions') +\ 'initialization_options': function('ale_linters#elm#ls#GetInitializationOptions') \}) diff --git a/sources_non_forked/ale/ale_linters/erlang/elvis.vim b/sources_non_forked/ale/ale_linters/erlang/elvis.vim index 0fb85c07..321a6c72 100644 --- a/sources_non_forked/ale/ale_linters/erlang/elvis.vim +++ b/sources_non_forked/ale/ale_linters/erlang/elvis.vim @@ -26,9 +26,27 @@ function! s:AbbreviateMessage(text) abort endfunction function! s:GetCommand(buffer) abort - let l:file = ale#Escape(expand('#' . a:buffer . ':.')) + let l:cwd = s:GetCwd(a:buffer) - return '%e rock --output-format=parsable ' . l:file + let l:file = !empty(l:cwd) + \ ? expand('#' . a:buffer . ':p')[len(l:cwd) + 1:] + \ : expand('#' . a:buffer . ':.') + + return '%e rock --output-format=parsable ' . ale#Escape(l:file) +endfunction + +function! s:GetCwd(buffer) abort + let l:markers = ['elvis.config', 'rebar.lock', 'erlang.mk'] + + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:marker in l:markers + if filereadable(l:path . '/' . l:marker) + return l:path + endif + endfor + endfor + + return '' endfunction call ale#linter#Define('erlang', { @@ -36,5 +54,6 @@ call ale#linter#Define('erlang', { \ 'callback': 'ale_linters#erlang#elvis#Handle', \ 'executable': {b -> ale#Var(b, 'erlang_elvis_executable')}, \ 'command': function('s:GetCommand'), +\ 'cwd': function('s:GetCwd'), \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/erlang/erlang_ls.vim b/sources_non_forked/ale/ale_linters/erlang/erlang_ls.vim index b747e454..0f070459 100644 --- a/sources_non_forked/ale/ale_linters/erlang/erlang_ls.vim +++ b/sources_non_forked/ale/ale_linters/erlang/erlang_ls.vim @@ -21,7 +21,14 @@ function! s:GetCommand(buffer) abort endfunction function! s:FindProjectRoot(buffer) abort - let l:markers = ['_build/', 'erlang_ls.config', 'rebar.lock'] + let l:markers = [ + \ '_checkouts/', + \ '_build/', + \ 'deps/', + \ 'erlang_ls.config', + \ 'rebar.lock', + \ 'erlang.mk', + \] " This is a way to find Erlang/OTP root (the one that is managed " by kerl or asdf). Useful if :ALEGoToDefinition takes us there. diff --git a/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim b/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim index 5d555a8d..bd984fef 100644 --- a/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim +++ b/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim @@ -3,29 +3,13 @@ call ale#Set('erlang_syntaxerl_executable', 'syntaxerl') -function! ale_linters#erlang#syntaxerl#RunHelpCommand(buffer) abort - let l:executable = ale#Var(a:buffer, 'erlang_syntaxerl_executable') - - return ale#command#Run( - \ a:buffer, - \ ale#Escape(l:executable) . ' -h', - \ function('ale_linters#erlang#syntaxerl#GetCommand'), - \) -endfunction - -function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output, meta) abort - let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1 - - return '%e' . (l:use_b_option ? ' -b %s %t' : ' %t') -endfunction - function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort let l:pattern = '\v\C:(\d+):( warning:)? (.+)' let l:loclist = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:loclist, { - \ 'lnum': l:match[1] + 0, + \ 'lnum': str2nr(l:match[1]), \ 'text': l:match[3], \ 'type': empty(l:match[2]) ? 'E' : 'W', \}) @@ -34,9 +18,27 @@ function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort return l:loclist endfunction +function! s:GetExecutable(buffer) abort + return ale#Var(a:buffer, 'erlang_syntaxerl_executable') +endfunction + +function! s:GetCommand(buffer) abort + let l:Callback = function('s:GetCommandFromHelpOutput') + + return ale#command#Run(a:buffer, '%e -h', l:Callback, { + \ 'executable': s:GetExecutable(a:buffer), + \}) +endfunction + +function! s:GetCommandFromHelpOutput(buffer, output, metadata) abort + let l:has_b_option = match(a:output, '\V\C-b, --base\>') > -1 + + return l:has_b_option ? '%e -b %s %t' : '%e %t' +endfunction + call ale#linter#Define('erlang', { \ 'name': 'syntaxerl', -\ 'executable': {b -> ale#Var(b, 'erlang_syntaxerl_executable')}, -\ 'command': {b -> ale_linters#erlang#syntaxerl#RunHelpCommand(b)}, \ 'callback': 'ale_linters#erlang#syntaxerl#Handle', +\ 'executable': function('s:GetExecutable'), +\ 'command': function('s:GetCommand'), \}) diff --git a/sources_non_forked/ale/ale_linters/glimmer/embertemplatelint.vim b/sources_non_forked/ale/ale_linters/glimmer/embertemplatelint.vim new file mode 100644 index 00000000..10b54bb4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/glimmer/embertemplatelint.vim @@ -0,0 +1,6 @@ +" Author: Sam Saffron <sam.saffron@gmail.com> +" Description: Ember-template-lint for checking GJS (Glimmer JS) files + +scriptencoding utf-8 + +call ale#handlers#embertemplatelint#DefineLinter('glimmer') diff --git a/sources_non_forked/ale/ale_linters/go/golangci_lint.vim b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim index 78087b5e..a3643370 100644 --- a/sources_non_forked/ale/ale_linters/go/golangci_lint.vim +++ b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim @@ -3,7 +3,7 @@ call ale#Set('go_golangci_lint_options', '') call ale#Set('go_golangci_lint_executable', 'golangci-lint') -call ale#Set('go_golangci_lint_package', 0) +call ale#Set('go_golangci_lint_package', 1) function! ale_linters#go#golangci_lint#GetCommand(buffer) abort let l:filename = expand('#' . a:buffer . ':t') diff --git a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim index 14fa3b2e..62b5db03 100644 --- a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim +++ b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim @@ -1,62 +1,6 @@ " Author: Adrian Zalewski <aazalewski@hotmail.com> " Description: Ember-template-lint for checking Handlebars files -call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint') -call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0)) +scriptencoding utf-8 -function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort - return ale#path#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [ - \ 'node_modules/.bin/ember-template-lint', - \]) -endfunction - -function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer, version) abort - if ale#semver#GTE(a:version, [4, 0, 0]) - " --json was removed in favor of --format=json in ember-template-lint@4.0.0 - return '%e --format=json --filename %s' - endif - - return '%e --json --filename %s' -endfunction - -function! ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck(buffer) abort - return ale#semver#RunWithVersionCheck( - \ a:buffer, - \ ale_linters#handlebars#embertemplatelint#GetExecutable(a:buffer), - \ '%e --version', - \ function('ale_linters#handlebars#embertemplatelint#GetCommand'), - \) -endfunction - -function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort - let l:output = [] - let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) - - for l:error in get(values(l:json), 0, []) - if has_key(l:error, 'fatal') - call add(l:output, { - \ 'lnum': get(l:error, 'line', 1), - \ 'col': get(l:error, 'column', 1), - \ 'text': l:error.message, - \ 'type': l:error.severity == 1 ? 'W' : 'E', - \}) - else - call add(l:output, { - \ 'lnum': l:error.line, - \ 'col': l:error.column, - \ 'text': l:error.rule . ': ' . l:error.message, - \ 'type': l:error.severity == 1 ? 'W' : 'E', - \}) - endif - endfor - - return l:output -endfunction - -call ale#linter#Define('handlebars', { -\ 'name': 'embertemplatelint', -\ 'aliases': ['ember-template-lint'], -\ 'executable': function('ale_linters#handlebars#embertemplatelint#GetExecutable'), -\ 'command': function('ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck'), -\ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle', -\}) +call ale#handlers#embertemplatelint#DefineLinter('handlebars') diff --git a/sources_non_forked/ale/ale_linters/html/stylelint.vim b/sources_non_forked/ale/ale_linters/html/stylelint.vim index 6b7aba40..c191c468 100644 --- a/sources_non_forked/ale/ale_linters/html/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/html/stylelint.vim @@ -21,6 +21,7 @@ endfunction call ale#linter#Define('html', { \ 'name': 'stylelint', +\ 'output_stream': 'both', \ 'executable': function('ale_linters#html#stylelint#GetExecutable'), \ 'command': function('ale_linters#html#stylelint#GetCommand'), \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', diff --git a/sources_non_forked/ale/ale_linters/hurl/hurlfmt.vim b/sources_non_forked/ale/ale_linters/hurl/hurlfmt.vim new file mode 100644 index 00000000..fa4252da --- /dev/null +++ b/sources_non_forked/ale/ale_linters/hurl/hurlfmt.vim @@ -0,0 +1,69 @@ +" Description: Hurl linter using hurlfmt --check. +" https://hurl.dev/ + +call ale#Set('hurl_hurlfmt_executable', 'hurlfmt') + +function! ale_linters#hurl#hurlfmt#GetCommand(buffer) abort + return '%e' + \ . ' --check --no-color ' +endfunction + +function! ale_linters#hurl#hurlfmt#HandleOutput(buffer, lines) abort + " Matches patterns: + " + " error: Parsing space + " --> test.hurl:11:48 + " | + " 8 | header "Content-Type"= "application/json; charset=utf-8" + " | ^ expecting a space + " | + " + " error: Parsing URL + " --> test.hurl:11:48 + " | + " 11 | PUT https://jsonplaceholder.typicode.com/posts/{post_id}} + " | ^ illegal character <{> + " | + " + " Note: hurlfmt seems to report always the first error only so we assume + " there is only one error to make parsing easier. + let l:output = [] + + if empty(a:lines) + return l:output + endif + + let l:pattern = '\v(error|warning): (.+) --\> (.+):(\d+):(\d+) .+ \^ (.+) |' + let l:lines = join(a:lines, ' ') + + for l:match in ale#util#GetMatches(l:lines, l:pattern) + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': match[4] + 0, + \ 'col': match[5] + 0, + \ 'end_col': match[5] + 0, + \ 'text': match[2] . ' : ' . match[6], + \ 'type': (match[1] is# 'error') ? 'E' : 'W' + \}) + endfor + + return l:output +endfunction + +function! ale_linters#hurl#hurlfmt#GetType(severity) abort + if a:severity is? 'convention' + \|| a:severity is? 'warning' + \|| a:severity is? 'refactor' + return 'W' + endif + + return 'E' +endfunction + +call ale#linter#Define('hurl', { +\ 'name': 'hurlfmt', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'hurl_hurlfmt_executable')}, +\ 'command': function('ale_linters#hurl#hurlfmt#GetCommand'), +\ 'callback': 'ale_linters#hurl#hurlfmt#HandleOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/biome.vim b/sources_non_forked/ale/ale_linters/javascript/biome.vim new file mode 100644 index 00000000..17714de1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/biome.vim @@ -0,0 +1,11 @@ +" Author: Filip Gospodinov <f@gospodinov.ch> +" Description: biome for JavaScript files + +call ale#linter#Define('javascript', { +\ 'name': 'biome', +\ 'lsp': 'stdio', +\ 'language': function('ale#handlers#biome#GetLanguage'), +\ 'executable': function('ale#handlers#biome#GetExecutable'), +\ 'command': '%e lsp-proxy', +\ 'project_root': function('ale#handlers#biome#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/json/biome.vim b/sources_non_forked/ale/ale_linters/json/biome.vim new file mode 100644 index 00000000..086ee44a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/biome.vim @@ -0,0 +1,10 @@ +" Description: biome for json files + +call ale#linter#Define('json', { +\ 'name': 'biome', +\ 'lsp': 'stdio', +\ 'language': function('ale#handlers#biome#GetLanguage'), +\ 'executable': function('ale#handlers#biome#GetExecutable'), +\ 'command': '%e lsp-proxy', +\ 'project_root': function('ale#handlers#biome#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/jsonc/biome.vim b/sources_non_forked/ale/ale_linters/jsonc/biome.vim new file mode 100644 index 00000000..5a691093 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/jsonc/biome.vim @@ -0,0 +1,10 @@ +" Description: biome for jsonc files + +call ale#linter#Define('jsonc', { +\ 'name': 'biome', +\ 'lsp': 'stdio', +\ 'language': function('ale#handlers#biome#GetLanguage'), +\ 'executable': function('ale#handlers#biome#GetExecutable'), +\ 'command': '%e lsp-proxy', +\ 'project_root': function('ale#handlers#biome#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/less/stylelint.vim b/sources_non_forked/ale/ale_linters/less/stylelint.vim index 83f784c4..9430fe9b 100644 --- a/sources_non_forked/ale/ale_linters/less/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/less/stylelint.vim @@ -12,6 +12,7 @@ endfunction call ale#linter#Define('less', { \ 'name': 'stylelint', +\ 'output_stream': 'both', \ 'executable': {b -> ale#path#FindExecutable(b, 'less_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, diff --git a/sources_non_forked/ale/ale_linters/odin/ols.vim b/sources_non_forked/ale/ale_linters/odin/ols.vim new file mode 100644 index 00000000..242dea0e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/odin/ols.vim @@ -0,0 +1,19 @@ +" Author: Benjamin Block <https://github.com/benjamindblock> +" Description: A language server for Odin. + +function! ale_linters#odin#ols#GetProjectRoot(buffer) abort + return fnamemodify('', ':h') +endfunction + +call ale#Set('odin_ols_executable', 'ols') +call ale#Set('odin_ols_config', {}) + +call ale#linter#Define('odin', { +\ 'name': 'ols', +\ 'lsp': 'stdio', +\ 'language': 'odin', +\ 'lsp_config': {b -> ale#Var(b, 'odin_ols_config')}, +\ 'executable': {b -> ale#Var(b, 'odin_ols_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#odin#ols#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/phpstan.vim b/sources_non_forked/ale/ale_linters/php/phpstan.vim index b0d2a8d3..a0942530 100644 --- a/sources_non_forked/ale/ale_linters/php/phpstan.vim +++ b/sources_non_forked/ale/ale_linters/php/phpstan.vim @@ -57,12 +57,14 @@ function! ale_linters#php#phpstan#Handle(buffer, lines) abort return l:output endif - for l:err in l:res.files[expand('#' . a:buffer .':p')].messages - call add(l:output, { - \ 'lnum': l:err.line, - \ 'text': l:err.message, - \ 'type': 'E', - \}) + for l:key in keys(l:res.files) + for l:err in l:res.files[l:key].messages + call add(l:output, { + \ 'lnum': l:err.line, + \ 'text': l:err.message, + \ 'type': 'E', + \}) + endfor endfor return l:output diff --git a/sources_non_forked/ale/ale_linters/python/bandit.vim b/sources_non_forked/ale/ale_linters/python/bandit.vim index 9cfca7c0..ba48c3a8 100644 --- a/sources_non_forked/ale/ale_linters/python/bandit.vim +++ b/sources_non_forked/ale/ale_linters/python/bandit.vim @@ -7,6 +7,7 @@ call ale#Set('python_bandit_use_config', 1) call ale#Set('python_bandit_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_bandit_auto_pipenv', 0) call ale#Set('python_bandit_auto_poetry', 0) +call ale#Set('python_bandit_auto_uv', 0) function! ale_linters#python#bandit#GetExecutable(buffer) abort if ( @@ -23,6 +24,11 @@ function! ale_linters#python#bandit#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_bandit_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_bandit', ['bandit']) endfunction @@ -39,7 +45,7 @@ function! ale_linters#python#bandit#GetCommand(buffer) abort endif endif - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run bandit' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/flake8.vim b/sources_non_forked/ale/ale_linters/python/flake8.vim index 9950614a..12dca84a 100644 --- a/sources_non_forked/ale/ale_linters/python/flake8.vim +++ b/sources_non_forked/ale/ale_linters/python/flake8.vim @@ -7,6 +7,7 @@ call ale#Set('python_flake8_use_global', get(g:, 'ale_use_global_executables', 0 call ale#Set('python_flake8_change_directory', 'project') call ale#Set('python_flake8_auto_pipenv', 0) call ale#Set('python_flake8_auto_poetry', 0) +call ale#Set('python_flake8_auto_uv', 0) function! s:UsingModule(buffer) abort return ale#Var(a:buffer, 'python_flake8_options') =~# ' *-m flake8' @@ -23,6 +24,11 @@ function! ale_linters#python#flake8#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_flake8_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + if !s:UsingModule(a:buffer) return ale#python#FindExecutable(a:buffer, 'python_flake8', ['flake8']) endif @@ -68,7 +74,7 @@ endfunction function! ale_linters#python#flake8#GetCommand(buffer, version) abort let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run flake8' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/flakehell.vim b/sources_non_forked/ale/ale_linters/python/flakehell.vim index ffe87e29..9ff0f18f 100644 --- a/sources_non_forked/ale/ale_linters/python/flakehell.vim +++ b/sources_non_forked/ale/ale_linters/python/flakehell.vim @@ -7,6 +7,7 @@ call ale#Set('python_flakehell_use_global', get(g:, 'ale_use_global_executables' call ale#Set('python_flakehell_change_directory', 'project') call ale#Set('python_flakehell_auto_pipenv', 0) call ale#Set('python_flakehell_auto_poetry', 0) +call ale#Set('python_flakehell_auto_uv', 0) function! s:UsingModule(buffer) abort return ale#Var(a:buffer, 'python_flakehell_executable') is? 'python' @@ -23,6 +24,11 @@ function! ale_linters#python#flakehell#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_flakehell_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + if !s:UsingModule(a:buffer) return ale#python#FindExecutable(a:buffer, 'python_flakehell', ['flakehell']) endif @@ -68,7 +74,7 @@ endfunction function! ale_linters#python#flakehell#GetCommand(buffer, version) abort let l:executable = ale_linters#python#flakehell#GetExecutable(a:buffer) - if (l:executable =~? 'pipenv\|poetry$') + if (l:executable =~? 'pipenv\|poetry\|uv$') let l:exec_args = ' run flakehell' elseif (l:executable is? 'python') let l:exec_args = ' -m flakehell' diff --git a/sources_non_forked/ale/ale_linters/python/jedils.vim b/sources_non_forked/ale/ale_linters/python/jedils.vim index e82abd1b..46b2896b 100644 --- a/sources_non_forked/ale/ale_linters/python/jedils.vim +++ b/sources_non_forked/ale/ale_linters/python/jedils.vim @@ -4,6 +4,8 @@ call ale#Set('python_jedils_executable', 'jedi-language-server') call ale#Set('python_jedils_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_jedils_auto_pipenv', 0) +call ale#Set('python_jedils_auto_poetry', 0) +call ale#Set('python_jedils_auto_uv', 0) function! ale_linters#python#jedils#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_jedils_auto_pipenv')) @@ -11,12 +13,22 @@ function! ale_linters#python#jedils#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_jedils_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_jedils_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_jedils', ['jedi-language-server']) endfunction function! ale_linters#python#jedils#GetCommand(buffer) abort let l:executable = ale_linters#python#jedils#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run jedi-language-server' \ : '' let l:env_string = '' diff --git a/sources_non_forked/ale/ale_linters/python/mypy.vim b/sources_non_forked/ale/ale_linters/python/mypy.vim index 9d469a1a..586a4381 100644 --- a/sources_non_forked/ale/ale_linters/python/mypy.vim +++ b/sources_non_forked/ale/ale_linters/python/mypy.vim @@ -8,6 +8,7 @@ call ale#Set('python_mypy_options', '') call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_mypy_auto_pipenv', 0) call ale#Set('python_mypy_auto_poetry', 0) +call ale#Set('python_mypy_auto_uv', 0) function! ale_linters#python#mypy#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_mypy_auto_pipenv')) @@ -20,6 +21,11 @@ function! ale_linters#python#mypy#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_mypy_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy']) endfunction @@ -43,7 +49,7 @@ endfunction function! ale_linters#python#mypy#GetCommand(buffer) abort let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run mypy' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/prospector.vim b/sources_non_forked/ale/ale_linters/python/prospector.vim index 3623bda0..c40f25c5 100644 --- a/sources_non_forked/ale/ale_linters/python/prospector.vim +++ b/sources_non_forked/ale/ale_linters/python/prospector.vim @@ -3,6 +3,7 @@ call ale#Set('python_prospector_auto_pipenv', 0) call ale#Set('python_prospector_auto_poetry', 0) +call ale#Set('python_prospector_auto_uv', 0) let g:ale_python_prospector_executable = \ get(g:, 'ale_python_prospector_executable', 'prospector') @@ -23,13 +24,18 @@ function! ale_linters#python#prospector#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_prospector_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_prospector', ['prospector']) endfunction function! ale_linters#python#prospector#GetCommand(buffer) abort let l:executable = ale_linters#python#prospector#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run prospector' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pycln.vim b/sources_non_forked/ale/ale_linters/python/pycln.vim index 917a9757..774c6b04 100644 --- a/sources_non_forked/ale/ale_linters/python/pycln.vim +++ b/sources_non_forked/ale/ale_linters/python/pycln.vim @@ -7,6 +7,7 @@ call ale#Set('python_pycln_use_global', get(g:, 'ale_use_global_executables', 0) call ale#Set('python_pycln_change_directory', 1) call ale#Set('python_pycln_auto_pipenv', 0) call ale#Set('python_pycln_auto_poetry', 0) +call ale#Set('python_pycln_auto_uv', 0) call ale#Set('python_pycln_config_file', '') function! ale_linters#python#pycln#GetExecutable(buffer) abort @@ -20,6 +21,11 @@ function! ale_linters#python#pycln#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pycln_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pycln', ['pycln']) endfunction @@ -36,7 +42,7 @@ endfunction function! ale_linters#python#pycln#GetCommand(buffer, version) abort let l:executable = ale_linters#python#pycln#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pycln' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim index 3fb94d69..bd3584b8 100644 --- a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim @@ -6,6 +6,7 @@ call ale#Set('python_pycodestyle_options', '') call ale#Set('python_pycodestyle_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pycodestyle_auto_pipenv', 0) call ale#Set('python_pycodestyle_auto_poetry', 0) +call ale#Set('python_pycodestyle_auto_uv', 0) function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycodestyle_auto_pipenv')) @@ -18,13 +19,18 @@ function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pycodestyle_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pycodestyle', ['pycodestyle']) endfunction function! ale_linters#python#pycodestyle#GetCommand(buffer) abort let l:executable = ale_linters#python#pycodestyle#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pycodestyle' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim index ef0d818c..b012dd43 100644 --- a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim @@ -6,6 +6,7 @@ call ale#Set('python_pydocstyle_options', '') call ale#Set('python_pydocstyle_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pydocstyle_auto_pipenv', 0) call ale#Set('python_pydocstyle_auto_poetry', 0) +call ale#Set('python_pydocstyle_auto_uv', 0) function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pydocstyle_auto_pipenv')) @@ -18,12 +19,17 @@ function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pydocstyle_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pydocstyle', ['pydocstyle']) endfunction function! ale_linters#python#pydocstyle#GetCommand(buffer) abort let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pydocstyle' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pyflakes.vim b/sources_non_forked/ale/ale_linters/python/pyflakes.vim index 2567c533..fc0a3fa7 100644 --- a/sources_non_forked/ale/ale_linters/python/pyflakes.vim +++ b/sources_non_forked/ale/ale_linters/python/pyflakes.vim @@ -5,6 +5,7 @@ call ale#Set('python_pyflakes_executable', 'pyflakes') call ale#Set('python_pyflakes_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pyflakes_auto_pipenv', 0) call ale#Set('python_pyflakes_auto_poetry', 0) +call ale#Set('python_pyflakes_auto_uv', 0) function! ale_linters#python#pyflakes#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflakes_auto_pipenv')) @@ -17,13 +18,18 @@ function! ale_linters#python#pyflakes#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyflakes_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pyflakes', ['pyflakes']) endfunction function! ale_linters#python#pyflakes#GetCommand(buffer) abort let l:executable = ale_linters#python#pyflakes#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pyflakes' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pylama.vim b/sources_non_forked/ale/ale_linters/python/pylama.vim index 14f8071a..6555b409 100644 --- a/sources_non_forked/ale/ale_linters/python/pylama.vim +++ b/sources_non_forked/ale/ale_linters/python/pylama.vim @@ -6,6 +6,7 @@ call ale#Set('python_pylama_options', '') call ale#Set('python_pylama_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pylama_auto_pipenv', 0) call ale#Set('python_pylama_auto_poetry', 0) +call ale#Set('python_pylama_auto_uv', 0) call ale#Set('python_pylama_change_directory', 1) function! ale_linters#python#pylama#GetExecutable(buffer) abort @@ -19,12 +20,17 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pylama_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama']) endfunction function! ale_linters#python#pylama#RunWithVersionCheck(buffer) abort let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pylama' \ : '' @@ -53,7 +59,7 @@ endfunction function! ale_linters#python#pylama#GetCommand(buffer, version) abort let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pylama' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pylint.vim b/sources_non_forked/ale/ale_linters/python/pylint.vim index 2ce5376f..90aa5f1c 100644 --- a/sources_non_forked/ale/ale_linters/python/pylint.vim +++ b/sources_non_forked/ale/ale_linters/python/pylint.vim @@ -7,6 +7,7 @@ call ale#Set('python_pylint_use_global', get(g:, 'ale_use_global_executables', 0 call ale#Set('python_pylint_change_directory', 1) call ale#Set('python_pylint_auto_pipenv', 0) call ale#Set('python_pylint_auto_poetry', 0) +call ale#Set('python_pylint_auto_uv', 0) call ale#Set('python_pylint_use_msg_id', 0) function! ale_linters#python#pylint#GetExecutable(buffer) abort @@ -20,6 +21,11 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pylint_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint']) endfunction @@ -38,7 +44,7 @@ endfunction function! ale_linters#python#pylint#GetCommand(buffer, version) abort let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pylint' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pylsp.vim b/sources_non_forked/ale/ale_linters/python/pylsp.vim index a1c31018..d3db6e82 100644 --- a/sources_non_forked/ale/ale_linters/python/pylsp.vim +++ b/sources_non_forked/ale/ale_linters/python/pylsp.vim @@ -6,6 +6,7 @@ call ale#Set('python_pylsp_options', '') call ale#Set('python_pylsp_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pylsp_auto_pipenv', 0) call ale#Set('python_pylsp_auto_poetry', 0) +call ale#Set('python_pylsp_auto_uv', 0) call ale#Set('python_pylsp_config', {}) function! ale_linters#python#pylsp#GetExecutable(buffer) abort @@ -19,6 +20,11 @@ function! ale_linters#python#pylsp#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pylsp_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pylsp', ['pylsp']) endfunction @@ -37,7 +43,7 @@ endfunction function! ale_linters#python#pylsp#GetCommand(buffer) abort let l:executable = ale_linters#python#pylsp#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pylsp' \ : '' let l:env_string = '' diff --git a/sources_non_forked/ale/ale_linters/python/pyre.vim b/sources_non_forked/ale/ale_linters/python/pyre.vim index 5e5786f9..177f1cb5 100644 --- a/sources_non_forked/ale/ale_linters/python/pyre.vim +++ b/sources_non_forked/ale/ale_linters/python/pyre.vim @@ -5,6 +5,7 @@ call ale#Set('python_pyre_executable', 'pyre') call ale#Set('python_pyre_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pyre_auto_pipenv', 0) call ale#Set('python_pyre_auto_poetry', 0) +call ale#Set('python_pyre_auto_uv', 0) function! ale_linters#python#pyre#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyre_auto_pipenv')) @@ -17,12 +18,17 @@ function! ale_linters#python#pyre#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyre_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pyre', ['pyre']) endfunction function! ale_linters#python#pyre#GetCommand(buffer) abort let l:executable = ale_linters#python#pyre#GetExecutable(a:buffer) - let l:exec_args = (l:executable =~? 'pipenv\|poetry$' ? ' run pyre' : '') . ' persistent' + let l:exec_args = (l:executable =~? 'pipenv\|poetry\|uv$' ? ' run pyre' : '') . ' persistent' return ale#Escape(l:executable) . l:exec_args endfunction diff --git a/sources_non_forked/ale/ale_linters/python/pyright.vim b/sources_non_forked/ale/ale_linters/python/pyright.vim index e41f7f14..993ed075 100644 --- a/sources_non_forked/ale/ale_linters/python/pyright.vim +++ b/sources_non_forked/ale/ale_linters/python/pyright.vim @@ -3,6 +3,7 @@ call ale#Set('python_pyright_executable', 'pyright-langserver') call ale#Set('python_pyright_config', {}) call ale#Set('python_pyright_auto_pipenv', 0) call ale#Set('python_pyright_auto_poetry', 0) +call ale#Set('python_pyright_auto_uv', 0) " Force the cwd of the server to be the same as the project root to " fix issues with treating local files matching first or third party library @@ -59,12 +60,17 @@ function! ale_linters#python#pyright#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyright_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pyright', ['pyright-langserver']) endfunction function! ale_linters#python#pyright#GetCommand(buffer) abort let l:executable = ale_linters#python#pyright#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pyright-langserver' \ : '' let l:env_string = '' diff --git a/sources_non_forked/ale/ale_linters/python/refurb.vim b/sources_non_forked/ale/ale_linters/python/refurb.vim index 1ae77b77..7f92948a 100644 --- a/sources_non_forked/ale/ale_linters/python/refurb.vim +++ b/sources_non_forked/ale/ale_linters/python/refurb.vim @@ -7,6 +7,7 @@ call ale#Set('python_refurb_use_global', get(g:, 'ale_use_global_executables', 0 call ale#Set('python_refurb_change_directory', 1) call ale#Set('python_refurb_auto_pipenv', 0) call ale#Set('python_refurb_auto_poetry', 0) +call ale#Set('python_refurb_auto_uv', 0) function! ale_linters#python#refurb#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_refurb_auto_pipenv')) @@ -19,6 +20,11 @@ function! ale_linters#python#refurb#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_refurb_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_refurb', ['refurb']) endfunction @@ -35,7 +41,7 @@ endfunction function! ale_linters#python#refurb#GetCommand(buffer) abort let l:executable = ale_linters#python#refurb#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run refurb' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/ruff.vim b/sources_non_forked/ale/ale_linters/python/ruff.vim index c4f8ad1b..25ae2d91 100644 --- a/sources_non_forked/ale/ale_linters/python/ruff.vim +++ b/sources_non_forked/ale/ale_linters/python/ruff.vim @@ -7,6 +7,7 @@ call ale#Set('python_ruff_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_ruff_change_directory', 1) call ale#Set('python_ruff_auto_pipenv', 0) call ale#Set('python_ruff_auto_poetry', 0) +call ale#Set('python_ruff_auto_uv', 0) call ale#fix#registry#Add('ruff', \ 'ale#fixers#ruff#Fix', @@ -25,6 +26,11 @@ function! ale_linters#python#ruff#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_ruff_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_ruff', ['ruff']) endfunction @@ -41,13 +47,18 @@ endfunction function! ale_linters#python#ruff#GetCommand(buffer, version) abort let l:executable = ale_linters#python#ruff#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run ruff' \ : '' - " NOTE: ruff version `0.0.69` supports liniting input from stdin + " NOTE: ruff 0.3.0 deprecates `ruff <path>` in favor of `ruff check <path>` + let l:exec_args = l:exec_args + \ . (ale#semver#GTE(a:version, [0, 3, 0]) ? ' check' : '') + + " NOTE: ruff version `0.0.69` supports linting input from stdin " NOTE: ruff version `0.1.0` deprecates `--format text` return ale#Escape(l:executable) . l:exec_args . ' -q' + \ . ' --no-fix' \ . ale#Pad(ale#Var(a:buffer, 'python_ruff_options')) \ . (ale#semver#GTE(a:version, [0, 1, 0]) ? ' --output-format json-lines' : ' --format json-lines') \ . (ale#semver#GTE(a:version, [0, 0, 69]) ? ' --stdin-filename %s -' : ' %s') @@ -56,17 +67,25 @@ endfunction function! ale_linters#python#ruff#Handle(buffer, lines) abort let l:output = [] + " Read all lines of ruff output and parse use all the valid JSONL lines. for l:line in a:lines - let l:item = json_decode(l:line) - call add(l:output, { - \ 'lnum': l:item.location.row, - \ 'col': l:item.location.column, - \ 'end_lnum': l:item.end_location.row, - \ 'end_col': l:item.end_location.column - 1, - \ 'code': l:item.code, - \ 'text': l:item.message, - \ 'type': l:item.code =~? '\vE\d+' ? 'E' : 'W', - \}) + try + let l:item = json_decode(l:line) + catch + let l:item = v:null + endtry + + if !empty(l:item) + call add(l:output, { + \ 'lnum': l:item.location.row, + \ 'col': l:item.location.column, + \ 'end_lnum': l:item.end_location.row, + \ 'end_col': l:item.end_location.column - 1, + \ 'code': l:item.code, + \ 'text': l:item.message, + \ 'type': l:item.code =~? '\vE\d+' ? 'E' : 'W', + \}) + endif endfor return l:output diff --git a/sources_non_forked/ale/ale_linters/python/unimport.vim b/sources_non_forked/ale/ale_linters/python/unimport.vim index 71fd80f0..06dbc436 100644 --- a/sources_non_forked/ale/ale_linters/python/unimport.vim +++ b/sources_non_forked/ale/ale_linters/python/unimport.vim @@ -5,6 +5,7 @@ call ale#Set('python_unimport_options', '') call ale#Set('python_unimport_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_unimport_auto_pipenv', 0) call ale#Set('python_unimport_auto_poetry', 0) +call ale#Set('python_unimport_auto_uv', 0) function! ale_linters#python#unimport#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_unimport_auto_pipenv')) @@ -17,12 +18,17 @@ function! ale_linters#python#unimport#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_unimport_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_unimport', ['unimport']) endfunction function! ale_linters#python#unimport#GetCommand(buffer) abort let l:executable = ale_linters#python#unimport#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run unimport' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/vulture.vim b/sources_non_forked/ale/ale_linters/python/vulture.vim index a7ba1860..2ac05e43 100644 --- a/sources_non_forked/ale/ale_linters/python/vulture.vim +++ b/sources_non_forked/ale/ale_linters/python/vulture.vim @@ -5,6 +5,9 @@ call ale#Set('python_vulture_executable', 'vulture') call ale#Set('python_vulture_options', '') call ale#Set('python_vulture_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_vulture_change_directory', 1) +call ale#Set('python_vulture_auto_pipenv', 0) +call ale#Set('python_vulture_auto_poetry', 0) +call ale#Set('python_vulture_auto_uv', 0) " The directory to change to before running vulture function! s:GetDir(buffer) abort @@ -16,6 +19,21 @@ function! s:GetDir(buffer) abort endfunction function! ale_linters#python#vulture#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_vulture_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_vulture_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_vulture_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_vulture', ['vulture']) endfunction @@ -29,7 +47,7 @@ endfunction function! ale_linters#python#vulture#GetCommand(buffer) abort let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run vulture' \ : '' let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory') diff --git a/sources_non_forked/ale/ale_linters/ruby/steep.vim b/sources_non_forked/ale/ale_linters/ruby/steep.vim new file mode 100644 index 00000000..4fd52620 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/steep.vim @@ -0,0 +1,172 @@ +call ale#Set('ruby_steep_executable', 'steep') +call ale#Set('ruby_steep_options', '') + +" Find the nearest dir containing a Steepfile +function! ale_linters#ruby#steep#FindRoot(buffer) abort + for l:name in ['Steepfile'] + let l:dir = fnamemodify( + \ ale#path#FindNearestFile(a:buffer, l:name), + \ ':h' + \) + + if l:dir isnot# '.' && isdirectory(l:dir) + return l:dir + endif + endfor + + return '' +endfunction + +" Rename path relative to root +function! ale_linters#ruby#steep#RelativeToRoot(buffer, path) abort + let l:separator = has('win32') ? '\' : '/' + let l:steep_root = ale_linters#ruby#steep#FindRoot(a:buffer) + + " path isn't under root + if l:steep_root is# '' + return '' + endif + + let l:steep_root_prefix = l:steep_root . l:separator + + " win32 path separators get interpreted by substitute, escape them + if has('win32') + let l:steep_root_pat = substitute(l:steep_root_prefix, '\\', '\\\\', 'g') + else + let l:steep_root_pat = l:steep_root_prefix + endif + + return substitute(a:path, l:steep_root_pat, '', '') +endfunction + +function! ale_linters#ruby#steep#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_steep_executable') + + " steep check needs to apply some config from the file path so: + " - steep check can't use stdin (no path) + " - steep check can't use %t (path outside of project) + " => we can only use %s + + " somehow :ALEInfo shows that ALE still appends '< %t' to the command + " => luckily steep check ignores stdin + + " somehow steep has a problem with absolute path to file but a path + " relative to Steepfile directory works: + " see https://github.com/soutaro/steep/pull/975 + " => change to Steepfile directory and remove leading path + + let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p') + let l:buffer_filename = fnameescape(l:buffer_filename) + + let l:relative = ale_linters#ruby#steep#RelativeToRoot(a:buffer, l:buffer_filename) + + " if file is not under steep root, steep can't type check + if l:relative is# '' + " don't execute + return '' + endif + + return ale#ruby#EscapeExecutable(l:executable, 'steep') + \ . ' check ' + \ . ale#Var(a:buffer, 'ruby_steep_options') + \ . ' ' . fnameescape(l:relative) +endfunction + +function! ale_linters#ruby#steep#GetType(severity) abort + if a:severity is? 'information' + \|| a:severity is? 'hint' + return 'I' + endif + + if a:severity is? 'warning' + return 'W' + endif + + return 'E' +endfunction + +" Handle output from steep +function! ale_linters#ruby#steep#HandleOutput(buffer, lines) abort + let l:output = [] + + let l:in = 0 + let l:item = {} + + for l:line in a:lines + " Look for first line of a message block + " If not in-message (l:in == 0) that's expected + " If in-message (l:in > 0) that's less expected but let's recover + let l:match = matchlist(l:line, '^\([^:]*\):\([0-9]*\):\([0-9]*\): \[\([^]]*\)\] \(.*\)') + + if len(l:match) > 0 + " Something is lingering: recover by pushing what is there + if len(l:item) > 0 + call add(l:output, l:item) + let l:item = {} + endif + + let l:filename = l:match[1] + + " Steep's reported column is offset by 1 (zero-indexed?) + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 1, + \ 'type': ale_linters#ruby#steep#GetType(l:match[4]), + \ 'text': l:match[5], + \} + + " Done with this line, mark being in-message and go on with next line + let l:in = 1 + continue + endif + + " We're past the first line of a message block + if l:in > 0 + " Look for code in subsequent lines of the message block + if l:line =~# '^│ Diagnostic ID:' + let l:match = matchlist(l:line, '^│ Diagnostic ID: \(.*\)') + + if len(l:match) > 0 + let l:item.code = l:match[1] + endif + + " Done with the line + continue + endif + + " Look for last line of the message block + if l:line =~# '^└' + " Done with the line, mark looking for underline and go on with the next line + let l:in = 2 + continue + endif + + " Look for underline right after last line + if l:in == 2 + let l:match = matchlist(l:line, '\([~][~]*\)') + + if len(l:match) > 0 + let l:item.end_col = l:item['col'] + len(l:match[1]) - 1 + endif + + call add(l:output, l:item) + + " Done with the line, mark looking for first line and go on with the next line + let l:in = 0 + let l:item = {} + continue + endif + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'steep', +\ 'executable': {b -> ale#Var(b, 'ruby_steep_executable')}, +\ 'language': 'ruby', +\ 'command': function('ale_linters#ruby#steep#GetCommand'), +\ 'project_root': function('ale_linters#ruby#steep#FindRoot'), +\ 'callback': 'ale_linters#ruby#steep#HandleOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/sass/stylelint.vim b/sources_non_forked/ale/ale_linters/sass/stylelint.vim index 22abef9b..651d7fd5 100644 --- a/sources_non_forked/ale/ale_linters/sass/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sass/stylelint.vim @@ -5,6 +5,7 @@ call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', call ale#linter#Define('sass', { \ 'name': 'stylelint', +\ 'output_stream': 'both', \ 'executable': {b -> ale#path#FindExecutable(b, 'sass_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, diff --git a/sources_non_forked/ale/ale_linters/scss/stylelint.vim b/sources_non_forked/ale/ale_linters/scss/stylelint.vim index fea4ea8f..4f82a98a 100644 --- a/sources_non_forked/ale/ale_linters/scss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/scss/stylelint.vim @@ -11,6 +11,7 @@ endfunction call ale#linter#Define('scss', { \ 'name': 'stylelint', +\ 'output_stream': 'both', \ 'executable': {b -> ale#path#FindExecutable(b, 'scss_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, diff --git a/sources_non_forked/ale/ale_linters/sql/sqlfluff.vim b/sources_non_forked/ale/ale_linters/sql/sqlfluff.vim index 0ec062bd..4381e1ab 100644 --- a/sources_non_forked/ale/ale_linters/sql/sqlfluff.vim +++ b/sources_non_forked/ale/ale_linters/sql/sqlfluff.vim @@ -11,7 +11,7 @@ function! ale_linters#sql#sqlfluff#Executable(buffer) abort return ale#Var(a:buffer, 'sql_sqlfluff_executable') endfunction -function! ale_linters#sql#sqlfluff#Command(buffer) abort +function! ale_linters#sql#sqlfluff#Command(buffer, version) abort let l:executable = ale_linters#sql#sqlfluff#Executable(a:buffer) let l:options = ale#Var(a:buffer, 'sql_sqlfluff_options') @@ -35,7 +35,7 @@ function! ale_linters#sql#sqlfluff#Command(buffer) abort return l:cmd endfunction -function! ale_linters#sql#sqlfluff#Handle(buffer, lines) abort +function! ale_linters#sql#sqlfluff#Handle(buffer, version, lines) abort let l:output = [] let l:json_lines = ale#util#FuzzyJSONDecode(a:lines, []) @@ -50,16 +50,31 @@ function! ale_linters#sql#sqlfluff#Handle(buffer, lines) abort return l:output endif - for l:violation in get(l:json, 'violations', []) - call add(l:output, { - \ 'filename': l:json.filepath, - \ 'lnum': l:violation.line_no, - \ 'col': l:violation.line_pos, - \ 'text': l:violation.description, - \ 'code': l:violation.code, - \ 'type': 'W', - \}) - endfor + if ale#semver#GTE(a:version, [3, 0, 0]) + for l:violation in get(l:json, 'violations', []) + call add(l:output, { + \ 'filename': l:json.filepath, + \ 'lnum': l:violation.start_line_no, + \ 'end_lnum': l:violation.end_line_no, + \ 'col': l:violation.start_line_pos, + \ 'end_col': l:violation.end_line_pos, + \ 'text': l:violation.description, + \ 'code': l:violation.code, + \ 'type': 'W', + \}) + endfor + else + for l:violation in get(l:json, 'violations', []) + call add(l:output, { + \ 'filename': l:json.filepath, + \ 'lnum': l:violation.line_no, + \ 'col': l:violation.line_pos, + \ 'text': l:violation.description, + \ 'code': l:violation.code, + \ 'type': 'W', + \}) + endfor + endif return l:output endfunction @@ -67,6 +82,19 @@ endfunction call ale#linter#Define('sql', { \ 'name': 'sqlfluff', \ 'executable': function('ale_linters#sql#sqlfluff#Executable'), -\ 'command': function('ale_linters#sql#sqlfluff#Command'), -\ 'callback': 'ale_linters#sql#sqlfluff#Handle', +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#sql#sqlfluff#Executable(buffer), +\ '%e --version', +\ function('ale_linters#sql#sqlfluff#Command'), +\ )}, +\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#sql#sqlfluff#Executable(buffer), +\ '%e --version', +\ {buffer, version -> ale_linters#sql#sqlfluff#Handle( +\ buffer, +\ l:version, +\ lines)}, +\ )}, \}) diff --git a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim index b60e38ed..652e15d2 100644 --- a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim @@ -12,6 +12,7 @@ endfunction call ale#linter#Define('stylus', { \ 'name': 'stylelint', +\ 'output_stream': 'both', \ 'executable': {b -> ale#path#FindExecutable(b, 'stylus_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, diff --git a/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim b/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim index 879ff0ca..a12191b8 100644 --- a/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim @@ -13,6 +13,7 @@ endfunction call ale#linter#Define('sugarss', { \ 'name': 'stylelint', +\ 'output_stream': 'both', \ 'executable': {b -> ale#path#FindExecutable(b, 'sugarss_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, diff --git a/sources_non_forked/ale/ale_linters/tex/chktex.vim b/sources_non_forked/ale/ale_linters/tex/chktex.vim index 160baf0d..9e7be587 100644 --- a/sources_non_forked/ale/ale_linters/tex/chktex.vim +++ b/sources_non_forked/ale/ale_linters/tex/chktex.vim @@ -1,29 +1,34 @@ " Author: Andrew Balmos - <andrew@balmos.org> " Description: chktex for LaTeX files -let g:ale_tex_chktex_executable = -\ get(g:, 'ale_tex_chktex_executable', 'chktex') +call ale#Set('tex_chktex_executable', 'chktex') +call ale#Set('tex_chktex_options', '-I') -let g:ale_tex_chktex_options = -\ get(g:, 'ale_tex_chktex_options', '-I') +function! ale_linters#tex#chktex#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'tex_chktex_executable') +endfunction -function! ale_linters#tex#chktex#GetCommand(buffer) abort - " Check for optional .chktexrc - let l:chktex_config = ale#path#FindNearestFile( - \ a:buffer, - \ '.chktexrc') +function! ale_linters#tex#chktex#GetCommand(buffer, version) abort + let l:options = '' - let l:command = ale#Var(a:buffer, 'tex_chktex_executable') " Avoid bug when used without -p (last warning has gibberish for a filename) - let l:command .= ' -v0 -p stdin -q' + let l:options .= ' -v0 -p stdin -q' - if !empty(l:chktex_config) - let l:command .= ' -l ' . ale#Escape(l:chktex_config) + " Avoid bug of reporting wrong column when using tabs (issue #723) + if ale#semver#GTE(a:version, [1, 7, 7]) + let l:options .= ' -S TabSize=1' endif - let l:command .= ' ' . ale#Var(a:buffer, 'tex_chktex_options') + " Check for optional .chktexrc + let l:chktex_config = ale#path#FindNearestFile(a:buffer, '.chktexrc') - return l:command + if !empty(l:chktex_config) + let l:options .= ' -l ' . ale#Escape(l:chktex_config) + endif + + let l:options .= ' ' . ale#Var(a:buffer, 'tex_chktex_options') + + return '%e' . l:options endfunction function! ale_linters#tex#chktex#Handle(buffer, lines) abort @@ -48,7 +53,12 @@ endfunction call ale#linter#Define('tex', { \ 'name': 'chktex', -\ 'executable': 'chktex', -\ 'command': function('ale_linters#tex#chktex#GetCommand'), +\ 'executable': function('ale_linters#tex#chktex#GetExecutable'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#tex#chktex#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#tex#chktex#GetCommand'), +\ )}, \ 'callback': 'ale_linters#tex#chktex#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/typescript/biome.vim b/sources_non_forked/ale/ale_linters/typescript/biome.vim new file mode 100644 index 00000000..1730da51 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/biome.vim @@ -0,0 +1,11 @@ +" Author: Filip Gospodinov <f@gospodinov.ch> +" Description: biome for TypeScript files + +call ale#linter#Define('typescript', { +\ 'name': 'biome', +\ 'lsp': 'stdio', +\ 'language': function('ale#handlers#biome#GetLanguage'), +\ 'executable': function('ale#handlers#biome#GetExecutable'), +\ 'command': '%e lsp-proxy', +\ 'project_root': function('ale#handlers#biome#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/slang.vim b/sources_non_forked/ale/ale_linters/verilog/slang.vim new file mode 100644 index 00000000..40299a34 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/slang.vim @@ -0,0 +1,53 @@ +" Author: Alvin Rolling <alvinrolling@gmail.com> +" Description: slang for verilog files + +" Set this option to change Slang lint options +if !exists('g:ale_verilog_slang_options') + let g:ale_verilog_slang_options = '' +endif + +" --lint-only +function! ale_linters#verilog#slang#GetCommand(buffer) abort + return 'slang -Weverything ' + \ . '-I%s:h ' + \ . ale#Var(a:buffer, 'verilog_slang_options') .' ' + \ . '%t' +endfunction + +function! s:RemoveUnicodeQuotes(text) abort + let l:text = a:text + let l:text = substitute(l:text, '[`´‘’]', '''', 'g') + let l:text = substitute(l:text, '[“”]', '"', 'g') + + return l:text +endfunction + +function! ale_linters#verilog#slang#Handle(buffer, lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+)?:?(\d+)?:? ([^:]+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ 'type': (l:match[4] is# 'error') ? 'E' : 'W', + \ 'text': s:RemoveUnicodeQuotes(l:match[5]), + \} + + if !empty(l:match[3]) + let l:item.col = str2nr(l:match[3]) + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('verilog', { +\ 'name': 'slang', +\ 'output_stream': 'stderr', +\ 'executable': 'slang', +\ 'command': function('ale_linters#verilog#slang#GetCommand'), +\ 'callback': 'ale_linters#verilog#slang#Handle', +\ 'read_buffer': 0, +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/actionlint.vim b/sources_non_forked/ale/ale_linters/yaml/actionlint.vim index 75fe3162..5afe6d48 100644 --- a/sources_non_forked/ale/ale_linters/yaml/actionlint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/actionlint.vim @@ -5,6 +5,11 @@ call ale#Set('yaml_actionlint_executable', 'actionlint') call ale#Set('yaml_actionlint_options', '') function! ale_linters#yaml#actionlint#GetCommand(buffer) abort + " Only execute actionlint on YAML files in /.github/ paths. + if expand('#' . a:buffer . ':p') !~# '\v[/\\]\.github[/\\]' + return '' + endif + let l:options = ale#Var(a:buffer, 'yaml_actionlint_options') if l:options !~# '-no-color' @@ -15,21 +20,33 @@ function! ale_linters#yaml#actionlint#GetCommand(buffer) abort let l:options .= ale#Pad('-oneline') endif - return '%e' . ale#Pad(l:options) + return '%e' . ale#Pad(l:options) . ' - ' endfunction function! ale_linters#yaml#actionlint#Handle(buffer, lines) abort " Matches patterns line the following: ".github/workflows/main.yml:19:0: could not parse as YAML: yaml: line 19: mapping values are not allowed in this context [yaml-syntax] - let l:pattern = '\v^.*:(\d+):(\d+): (.+) \[(.+)\]$' + let l:pattern = '\v^.{-}:(\d+):(\d+): (.+) \[(.+)\]$' let l:output = [] + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[4] + let l:text = l:match[3] + + " Handle sub-linter errors like the following: + "validate.yml:19:9: shellcheck reported issue in this script: SC2086:info:1:15: Double quote to prevent globbing and word splitting [shellcheck] + if l:code is# 'shellcheck' + let l:shellcheck_match = matchlist(l:text, '\v^.+: (SC\d{4}):.+:\d+:\d+: (.+)$') + let l:text = l:shellcheck_match[2] + let l:code = 'shellcheck ' . l:shellcheck_match[1] + endif + let l:item = { \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 0, - \ 'text': l:match[3], - \ 'code': l:match[4], + \ 'text': l:text, + \ 'code': l:code, \ 'type': 'E', \} diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 251bdcc5..210ee038 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -35,22 +35,94 @@ function! ale#definition#UpdateTagStack() abort endif endfunction +function! ale#definition#FormatTSServerResponse(response_item, options) abort + if get(a:options, 'open_in') is# 'quickfix' + return { + \ 'filename': a:response_item.file, + \ 'lnum': a:response_item.start.line, + \ 'col': a:response_item.start.offset, + \} + else + return { + \ 'filename': a:response_item.file, + \ 'line': a:response_item.start.line, + \ 'column': a:response_item.start.offset, + \} + endif +endfunction + function! ale#definition#HandleTSServerResponse(conn_id, response) abort if has_key(a:response, 'request_seq') \&& has_key(s:go_to_definition_map, a:response.request_seq) let l:options = remove(s:go_to_definition_map, a:response.request_seq) if get(a:response, 'success', v:false) is v:true && !empty(a:response.body) - let l:filename = a:response.body[0].file - let l:line = a:response.body[0].start.line - let l:column = a:response.body[0].start.offset + let l:item_list = [] - call ale#definition#UpdateTagStack() - call ale#util#Open(l:filename, l:line, l:column, l:options) + for l:response_item in a:response.body + call add( + \ l:item_list, + \ ale#definition#FormatTSServerResponse(l:response_item, l:options) + \) + endfor + + if empty(l:item_list) + call ale#util#Execute('echom ''No definitions found''') + elseif len(l:item_list) == 1 + let l:filename = l:item_list[0].filename + + if get(l:options, 'open_in') is# 'quickfix' + let l:line = l:item_list[0].lnum + let l:column = l:item_list[0].col + else + let l:line = l:item_list[0].line + let l:column = l:item_list[0].column + endif + + call ale#definition#UpdateTagStack() + call ale#util#Open(l:filename, l:line, l:column, l:options) + else + if get(l:options, 'open_in') is# 'quickfix' + call setqflist([], 'r') + call setqflist(l:item_list, 'a') + call ale#util#Execute('cc 1') + else + call ale#definition#UpdateTagStack() + call ale#preview#ShowSelection(l:item_list, l:options) + endif + endif endif endif endfunction +function! ale#definition#FormatLSPResponse(response_item, options) abort + if has_key(a:response_item, 'targetUri') + " LocationLink items use targetUri + let l:uri = a:response_item.targetUri + let l:line = a:response_item.targetRange.start.line + 1 + let l:column = a:response_item.targetRange.start.character + 1 + else + " LocationLink items use uri + let l:uri = a:response_item.uri + let l:line = a:response_item.range.start.line + 1 + let l:column = a:response_item.range.start.character + 1 + endif + + if get(a:options, 'open_in') is# 'quickfix' + return { + \ 'filename': ale#util#ToResource(l:uri), + \ 'lnum': l:line, + \ 'col': l:column, + \} + else + return { + \ 'filename': ale#util#ToResource(l:uri), + \ 'line': l:line, + \ 'column': l:column, + \} + endif +endfunction + function! ale#definition#HandleLSPResponse(conn_id, response) abort if has_key(a:response, 'id') \&& has_key(s:go_to_definition_map, a:response.id) @@ -65,21 +137,29 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort let l:result = [] endif - for l:item in l:result - if has_key(l:item, 'targetUri') - " LocationLink items use targetUri - let l:uri = l:item.targetUri - let l:line = l:item.targetRange.start.line + 1 - let l:column = l:item.targetRange.start.character + 1 - else - " LocationLink items use uri - let l:uri = l:item.uri - let l:line = l:item.range.start.line + 1 - let l:column = l:item.range.start.character + 1 - endif + let l:item_list = [] + for l:response_item in l:result + call add(l:item_list, + \ ale#definition#FormatLSPResponse(l:response_item, l:options) + \) + endfor + + if empty(l:item_list) + call ale#util#Execute('echom ''No definitions found''') + elseif len(l:item_list) == 1 call ale#definition#UpdateTagStack() + let l:uri = ale#util#ToURI(l:item_list[0].filename) + + if get(l:options, 'open_in') is# 'quickfix' + let l:line = l:item_list[0].lnum + let l:column = l:item_list[0].col + else + let l:line = l:item_list[0].line + let l:column = l:item_list[0].column + endif + let l:uri_handler = ale#uri#GetURIHandler(l:uri) if l:uri_handler is# v:null @@ -88,9 +168,16 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort else call l:uri_handler.OpenURILink(l:uri, l:line, l:column, l:options, a:conn_id) endif - - break - endfor + else + if get(l:options, 'open_in') is# 'quickfix' + call setqflist([], 'r') + call setqflist(l:item_list, 'a') + call ale#util#Execute('cc 1') + else + call ale#definition#UpdateTagStack() + call ale#preview#ShowSelection(l:item_list, l:options) + endif + endif endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index 050cc6c7..661fa1e1 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -37,6 +37,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['bib'], \ 'description': 'Format bib files using bibclean.', \ }, +\ 'biome': { +\ 'function': 'ale#fixers#biome#Fix', +\ 'suggested_filetypes': ['javascript', 'typescript', 'json', 'jsonc'], +\ 'description': 'Fix JavaScript and TypeScript using biome.', +\ }, \ 'black': { \ 'function': 'ale#fixers#black#Fix', \ 'suggested_filetypes': ['python'], @@ -98,6 +103,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['javascript', 'css', 'html'], \ 'description': 'Apply fecs format to a file.', \ }, +\ 'hurlfmt': { +\ 'function': 'ale#fixers#hurlfmt#Fix', +\ 'suggested_filetypes': ['hurl'], +\ 'description': 'Fix hurl files with hurlfmt.', +\ }, \ 'tidy': { \ 'function': 'ale#fixers#tidy#Fix', \ 'suggested_filetypes': ['html'], @@ -127,7 +137,7 @@ let s:default_registry = { \ }, \ 'eslint': { \ 'function': 'ale#fixers#eslint#Fix', -\ 'suggested_filetypes': ['javascript', 'typescript'], +\ 'suggested_filetypes': ['javascript', 'typescript', 'astro'], \ 'description': 'Apply eslint --fix to a file.', \ }, \ 'mix_format': { @@ -142,7 +152,7 @@ let s:default_registry = { \ }, \ 'prettier': { \ 'function': 'ale#fixers#prettier#Fix', -\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'svelte', 'html', 'yaml', 'openapi', 'ruby'], +\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'svelte', 'html', 'yaml', 'openapi', 'ruby', 'astro'], \ 'description': 'Apply prettier to a file.', \ }, \ 'prettier_eslint': { @@ -291,6 +301,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['solidity'], \ 'description': 'Fix Solidity files with forge fmt.', \ }, +\ 'gleam_format': { +\ 'function': 'ale#fixers#gleam_format#Fix', +\ 'suggested_filetypes': ['gleam'], +\ 'description': 'Fix Gleam files with gleam format.', +\ }, \ 'gofmt': { \ 'function': 'ale#fixers#gofmt#Fix', \ 'suggested_filetypes': ['go'], @@ -546,6 +561,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['html', 'htmldjango'], \ 'description': 'Fix HTML files with html-beautify from js-beautify.', \ }, +\ 'htmlbeautifier': { +\ 'function': 'ale#fixers#htmlbeautifier#Fix', +\ 'suggested_filetypes': ['eruby'], +\ 'description': 'Fix ERB files with htmlbeautifier gem.', +\ }, \ 'lua-format': { \ 'function': 'ale#fixers#lua_format#Fix', \ 'suggested_filetypes': ['lua'], @@ -641,6 +661,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['nickel'], \ 'description': 'Fix nickel files with nickel format', \ }, +\ 'rubyfmt': { +\ 'function': 'ale#fixers#rubyfmt#Fix', +\ 'suggested_filetypes': ['ruby'], +\ 'description': 'A formatter for Ruby source code', +\ }, \} " Reset the function registry to the default entries. diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim b/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim index e2ad6536..c2530051 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim @@ -4,22 +4,40 @@ call ale#Set('python_autoflake_executable', 'autoflake') call ale#Set('python_autoflake_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_autoflake_options', '') +call ale#Set('python_autoflake_auto_pipenv', 0) +call ale#Set('python_autoflake_auto_poetry', 0) +call ale#Set('python_autoflake_auto_uv', 0) + +function! ale#fixers#autoflake#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_autoflake_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_autoflake_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_autoflake_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_autoflake', ['autoflake']) +endfunction function! ale#fixers#autoflake#Fix(buffer) abort - let l:executable = ale#python#FindExecutable( - \ a:buffer, - \ 'python_autoflake', - \ ['autoflake'], - \) + let l:executable = ale#fixers#autoflake#GetExecutable(a:buffer) - if !executable(l:executable) - return 0 - endif + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + \ ? ' run autoflake' + \ : '' let l:options = ale#Var(a:buffer, 'python_autoflake_options') return { - \ 'command': ale#Escape(l:executable) + \ 'command': ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --in-place ' \ . ' %t', diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim index 700d36b5..686da124 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim @@ -4,23 +4,41 @@ call ale#Set('python_autoimport_executable', 'autoimport') call ale#Set('python_autoimport_options', '') call ale#Set('python_autoimport_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_autoimport_auto_pipenv', 0) +call ale#Set('python_autoimport_auto_poetry', 0) +call ale#Set('python_autoimport_auto_uv', 0) + +function! ale#fixers#autoimport#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_autoimport_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_autoimport_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_autoimport_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_autoimport', ['autoimport']) +endfunction function! ale#fixers#autoimport#Fix(buffer) abort + let l:executable = ale#fixers#autoimport#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + \ ? ' run autoimport' + \ : '' + let l:options = ale#Var(a:buffer, 'python_autoimport_options') - let l:executable = ale#python#FindExecutable( - \ a:buffer, - \ 'python_autoimport', - \ ['autoimport'], - \) - - if !executable(l:executable) - return 0 - endif - return { \ 'cwd': '%s:h', - \ 'command': ale#Escape(l:executable) + \ 'command': ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -', \} diff --git a/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim b/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim index 5798d827..6b5adfce 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim @@ -4,22 +4,40 @@ call ale#Set('python_autopep8_executable', 'autopep8') call ale#Set('python_autopep8_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_autopep8_options', '') +call ale#Set('python_autopep8_auto_pipenv', 0) +call ale#Set('python_autopep8_auto_poetry', 0) +call ale#Set('python_autopep8_auto_uv', 0) + +function! ale#fixers#autopep8#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_autopep8_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_autopep8_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_autopep8_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_autopep8', ['autopep8']) +endfunction function! ale#fixers#autopep8#Fix(buffer) abort - let l:executable = ale#python#FindExecutable( - \ a:buffer, - \ 'python_autopep8', - \ ['autopep8'], - \) + let l:executable = ale#fixers#autopep8#GetExecutable(a:buffer) - if !executable(l:executable) - return 0 - endif + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + \ ? ' run autopep8' + \ : '' let l:options = ale#Var(a:buffer, 'python_autopep8_options') return { - \ 'command': ale#Escape(l:executable) + \ 'command': ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -', \} diff --git a/sources_non_forked/ale/autoload/ale/fixers/biome.vim b/sources_non_forked/ale/autoload/ale/fixers/biome.vim index 3a45fa3e..63c0fdbc 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/biome.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/biome.vim @@ -1,17 +1,12 @@ -" Author: Akiomi Kamakura <akiomik@gmail.com> -" Description: Fixing files with biome (ex.rome). - function! ale#fixers#biome#Fix(buffer) abort let l:executable = ale#handlers#biome#GetExecutable(a:buffer) - let l:options = ale#Var(a:buffer, 'javascript_biome_options') - let l:node = ale#Var(a:buffer, 'javascript_biome_node_executable') + let l:options = ale#Var(a:buffer, 'biome_options') + let l:apply = ale#Var(a:buffer, 'biome_fixer_apply_unsafe') ? '--apply-unsafe' : '--apply' return { - \ 'command': (has('win32') ? (ale#Escape(l:node) . ' ') : '') - \ . ale#Escape(l:executable) - \ . ' check --apply' - \ . ale#Pad(l:options) - \ . ' %t', \ 'read_temporary_file': 1, + \ 'command': ale#Escape(l:executable) . ' check ' . l:apply + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/black.vim b/sources_non_forked/ale/autoload/ale/fixers/black.vim index 4a88c5cd..4fe239ff 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/black.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/black.vim @@ -6,6 +6,7 @@ call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0) call ale#Set('python_black_options', '') call ale#Set('python_black_auto_pipenv', 0) call ale#Set('python_black_auto_poetry', 0) +call ale#Set('python_black_auto_uv', 0) call ale#Set('python_black_change_directory', 1) function! ale#fixers#black#GetExecutable(buffer) abort @@ -19,6 +20,11 @@ function! ale#fixers#black#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_black_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_black', ['black']) endfunction @@ -26,7 +32,7 @@ function! ale#fixers#black#Fix(buffer) abort let l:executable = ale#fixers#black#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry$' + if l:executable =~? 'pipenv\|poetry\|uv$' call extend(l:cmd, ['run', 'black']) endif diff --git a/sources_non_forked/ale/autoload/ale/fixers/htmlbeautifier.vim b/sources_non_forked/ale/autoload/ale/fixers/htmlbeautifier.vim new file mode 100644 index 00000000..756d4a05 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/htmlbeautifier.vim @@ -0,0 +1,13 @@ +" Author: Arash Mousavi <arash-m> +" Description: Support for HTML Beautifier https://github.com/threedaymonk/htmlbeautifier + +call ale#Set('eruby_htmlbeautifier_executable', 'htmlbeautifier') + +function! ale#fixers#htmlbeautifier#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'eruby_htmlbeautifier_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/hurlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/hurlfmt.vim new file mode 100644 index 00000000..fc19fa83 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/hurlfmt.vim @@ -0,0 +1,15 @@ +call ale#Set('hurl_hurlfmt_executable', 'hurlfmt') + +function! ale#fixers#hurlfmt#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'hurl_hurlfmt_executable') + + return ale#Escape(l:executable) + \ . ' --out hurl' +endfunction + +function! ale#fixers#hurlfmt#Fix(buffer) abort + return { + \ 'command': ale#fixers#hurlfmt#GetCommand(a:buffer) + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/isort.vim b/sources_non_forked/ale/autoload/ale/fixers/isort.vim index 6eb6a67c..c4eef3cc 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/isort.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/isort.vim @@ -6,6 +6,7 @@ call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0) call ale#Set('python_isort_options', '') call ale#Set('python_isort_auto_pipenv', 0) call ale#Set('python_isort_auto_poetry', 0) +call ale#Set('python_isort_auto_uv', 0) function! ale#fixers#isort#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv')) @@ -18,6 +19,11 @@ function! ale#fixers#isort#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_isort_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort']) endfunction @@ -25,7 +31,7 @@ function! ale#fixers#isort#GetCmd(buffer) abort let l:executable = ale#fixers#isort#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry$' + if l:executable =~? 'pipenv\|poetry\|uv$' call extend(l:cmd, ['run', 'isort']) endif @@ -36,7 +42,7 @@ function! ale#fixers#isort#FixForVersion(buffer, version) abort let l:executable = ale#fixers#isort#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry$' + if l:executable =~? 'pipenv\|poetry\|uv$' call extend(l:cmd, ['run', 'isort']) endif diff --git a/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim b/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim index c8f9c7b0..96c6445c 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim @@ -4,6 +4,7 @@ call ale#Set('php_cs_fixer_executable', 'php-cs-fixer') call ale#Set('php_cs_fixer_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('php_cs_fixer_options', '') +call ale#Set('php_cs_fixer_fix_options', '') function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort return ale#path#FindExecutable(a:buffer, 'php_cs_fixer', [ @@ -18,7 +19,8 @@ function! ale#fixers#php_cs_fixer#Fix(buffer) abort return { \ 'command': ale#Escape(l:executable) \ . ' ' . ale#Var(a:buffer, 'php_cs_fixer_options') - \ . ' fix %t', + \ . ' fix ' . ale#Var(a:buffer, 'php_cs_fixer_fix_options') + \ . ' %t', \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim index 8a67e2ff..c9210e63 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim @@ -79,6 +79,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort \ 'openapi': 'yaml', \ 'html': 'html', \ 'ruby': 'ruby', + \ 'astro': 'astro', \} for l:filetype in l:filetypes diff --git a/sources_non_forked/ale/autoload/ale/fixers/pycln.vim b/sources_non_forked/ale/autoload/ale/fixers/pycln.vim index 1f61d083..4ee2373d 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/pycln.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/pycln.vim @@ -7,6 +7,7 @@ call ale#Set('python_pycln_use_global', get(g:, 'ale_use_global_executables', 0) call ale#Set('python_pycln_change_directory', 1) call ale#Set('python_pycln_auto_pipenv', 0) call ale#Set('python_pycln_auto_poetry', 0) +call ale#Set('python_pycln_auto_uv', 0) call ale#Set('python_pycln_config_file', '') function! ale#fixers#pycln#GetCwd(buffer) abort @@ -31,12 +32,17 @@ function! ale#fixers#pycln#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pycln_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pycln', ['pycln']) endfunction function! ale#fixers#pycln#GetCommand(buffer) abort let l:executable = ale#fixers#pycln#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pycln' \ : '' @@ -47,7 +53,7 @@ function! ale#fixers#pycln#FixForVersion(buffer, version) abort let l:executable = ale#fixers#pycln#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry$' + if l:executable =~? 'pipenv\|poetry\|uv$' call extend(l:cmd, ['run', 'pycln']) endif diff --git a/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim b/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim index 81c0f05e..f6f289e3 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim @@ -7,6 +7,7 @@ call ale#Set('python_pyflyby_use_global', get(g:, 'ale_use_global_executables', call ale#Set('python_pyflyby_options', '') call ale#Set('python_pyflyby_auto_pipenv', 0) call ale#Set('python_pyflyby_auto_poetry', 0) +call ale#Set('python_pyflyby_auto_uv', 0) function! ale#fixers#pyflyby#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflyby_auto_pipenv')) @@ -19,6 +20,11 @@ function! ale#fixers#pyflyby#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyflyby_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pyflyby', ['tidy-imports']) endfunction @@ -27,7 +33,7 @@ function! ale#fixers#pyflyby#Fix(buffer) abort let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry$' + if l:executable =~? 'pipenv\|poetry\|uv$' call extend(l:cmd, ['run', 'tidy-imports']) endif diff --git a/sources_non_forked/ale/autoload/ale/fixers/reorder_python_imports.vim b/sources_non_forked/ale/autoload/ale/fixers/reorder_python_imports.vim index 42a0a6e2..3cc76a9f 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/reorder_python_imports.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/reorder_python_imports.vim @@ -4,22 +4,40 @@ call ale#Set('python_reorder_python_imports_executable', 'reorder-python-imports') call ale#Set('python_reorder_python_imports_options', '') call ale#Set('python_reorder_python_imports_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_reorder_python_imports_auto_pipenv', 0) +call ale#Set('python_reorder_python_imports_auto_poetry', 0) +call ale#Set('python_reorder_python_imports_auto_uv', 0) + +function! ale#fixers#reorder_python_imports#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_reorder_python_imports_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_reorder_python_imports_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_reorder_python_imports_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_reorder_python_imports', ['reorder-python-imports']) +endfunction function! ale#fixers#reorder_python_imports#Fix(buffer) abort - let l:executable = ale#python#FindExecutable( - \ a:buffer, - \ 'python_reorder_python_imports', - \ ['reorder-python-imports'], - \) + let l:executable = ale#fixers#reorder_python_imports#GetExecutable(a:buffer) - if !executable(l:executable) - return 0 - endif + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + \ ? ' run reorder-python-imports' + \ : '' let l:options = ale#Var(a:buffer, 'python_reorder_python_imports_options') return { - \ 'command': ale#Escape(l:executable) + \ 'command': ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') . ' -', \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ruff.vim b/sources_non_forked/ale/autoload/ale/fixers/ruff.vim index 56bcf3df..c2bea3e3 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/ruff.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/ruff.vim @@ -7,6 +7,7 @@ call ale#Set('python_ruff_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_ruff_change_directory', 1) call ale#Set('python_ruff_auto_pipenv', 0) call ale#Set('python_ruff_auto_poetry', 0) +call ale#Set('python_ruff_auto_uv', 0) function! ale#fixers#ruff#GetCwd(buffer) abort if ale#Var(a:buffer, 'python_ruff_change_directory') @@ -30,12 +31,17 @@ function! ale#fixers#ruff#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_ruff_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_ruff', ['ruff']) endfunction function! ale#fixers#ruff#GetCommand(buffer) abort let l:executable = ale#fixers#ruff#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run ruff' \ : '' @@ -46,10 +52,15 @@ function! ale#fixers#ruff#FixForVersion(buffer, version) abort let l:executable = ale#fixers#ruff#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry$' + if l:executable =~? 'pipenv\|poetry\|uv$' call extend(l:cmd, ['run', 'ruff']) endif + " NOTE: ruff 0.5.0 removes `ruff <path>` in favor of `ruff check <path>` + if ale#semver#GTE(a:version, [0, 5, 0]) + call extend(l:cmd, ['check']) + endif + let l:options = ale#Var(a:buffer, 'python_ruff_options') if !empty(l:options) diff --git a/sources_non_forked/ale/autoload/ale/fixers/ruff_format.vim b/sources_non_forked/ale/autoload/ale/fixers/ruff_format.vim index 86858745..e852dd24 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/ruff_format.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/ruff_format.vim @@ -7,6 +7,7 @@ call ale#Set('python_ruff_format_use_global', get(g:, 'ale_use_global_executable call ale#Set('python_ruff_format_change_directory', 1) call ale#Set('python_ruff_format_auto_pipenv', 0) call ale#Set('python_ruff_format_auto_poetry', 0) +call ale#Set('python_ruff_format_auto_uv', 0) function! ale#fixers#ruff_format#GetCwd(buffer) abort if ale#Var(a:buffer, 'python_ruff_format_change_directory') @@ -30,12 +31,17 @@ function! ale#fixers#ruff_format#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_ruff_format_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_ruff_format', ['ruff']) endfunction function! ale#fixers#ruff_format#GetCommand(buffer) abort let l:executable = ale#fixers#ruff_format#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run ruff' \ : '' @@ -46,7 +52,7 @@ function! ale#fixers#ruff_format#Fix(buffer) abort let l:executable = ale#fixers#ruff_format#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry$' + if l:executable =~? 'pipenv\|poetry\|uv$' call extend(l:cmd, ['run', 'ruff']) endif diff --git a/sources_non_forked/ale/autoload/ale/fixers/yapf.vim b/sources_non_forked/ale/autoload/ale/fixers/yapf.vim index f04bb1f9..22822a6e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/yapf.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/yapf.vim @@ -3,17 +3,35 @@ call ale#Set('python_yapf_executable', 'yapf') call ale#Set('python_yapf_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_yapf_auto_pipenv', 0) +call ale#Set('python_yapf_auto_poetry', 0) +call ale#Set('python_yapf_auto_uv', 0) + +function! ale#fixers#yapf#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_yapf_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_yapf_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_yapf_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_yapf', ['yapf']) +endfunction function! ale#fixers#yapf#Fix(buffer) abort - let l:executable = ale#python#FindExecutable( - \ a:buffer, - \ 'python_yapf', - \ ['yapf'], - \) + let l:executable = ale#fixers#yapf#GetExecutable(a:buffer) - if !executable(l:executable) - return 0 - endif + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + \ ? ' run yapf' + \ : '' let l:config = ale#path#FindNearestFile(a:buffer, '.style.yapf') let l:config_options = !empty(l:config) @@ -21,6 +39,6 @@ function! ale#fixers#yapf#Fix(buffer) abort \ : '' return { - \ 'command': ale#Escape(l:executable) . l:config_options, + \ 'command': ale#Escape(l:executable) . l:exec_args . l:config_options, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/biome.vim b/sources_non_forked/ale/autoload/ale/handlers/biome.vim index 8d75e3bc..b22c1c46 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/biome.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/biome.vim @@ -1,14 +1,58 @@ -" Author: Akiomi Kamakura <akiomik@gmail.com> -" Description: Functions for working with biome, for fixing files. +" Author: Filip Gospodinov <f@gospodinov.ch> +" Description: Functions for working with biome, for checking or fixing files. -call ale#Set('javascript_biome_node_executable', 'node.exe') -call ale#Set('javascript_biome_executable', 'biome') -call ale#Set('javascript_biome_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('javascript_biome_options', '') +call ale#Set('biome_executable', 'biome') +call ale#Set('biome_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('biome_options', '') +call ale#Set('biome_fixer_apply_unsafe', 0) +call ale#Set('biome_lsp_project_root', '') function! ale#handlers#biome#GetExecutable(buffer) abort - return ale#path#FindExecutable(a:buffer, 'javascript_biome', [ + return ale#path#FindExecutable(a:buffer, 'biome', [ + \ 'node_modules/@biomejs/cli-linux-x64/biome', + \ 'node_modules/@biomejs/cli-linux-arm64/biome', + \ 'node_modules/@biomejs/cli-win32-x64/biome.exe', + \ 'node_modules/@biomejs/cli-win32-arm64/biome.exe', + \ 'node_modules/@biomejs/cli-darwin-x64/biome', + \ 'node_modules/@biomejs/cli-darwin-arm64/biome', \ 'node_modules/.bin/biome', - \ 'node_modules/@biomejs/biome/bin/biome', \]) endfunction + +function! ale#handlers#biome#GetLanguage(buffer) abort + return getbufvar(a:buffer, '&filetype') +endfunction + +function! ale#handlers#biome#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'biome_lsp_project_root') + + if !empty(l:project_root) + return l:project_root + endif + + let l:possible_project_roots = [ + \ 'biome.json', + \ 'biome.jsonc', + \ 'package.json', + \ '.git', + \ bufname(a:buffer), + \] + + for l:possible_root in l:possible_project_roots + let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root) + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root) + endif + + if !empty(l:project_root) + " dir:p expands to /full/path/to/dir/ whereas + " file:p expands to /full/path/to/file (no trailing slash) + " Appending '/' ensures that :h:h removes the path's last segment + " regardless of whether it is a directory or not. + return fnamemodify(l:project_root . '/', ':p:h:h') + endif + endfor + + return '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/cspell.vim b/sources_non_forked/ale/autoload/ale/handlers/cspell.vim index 6137bdeb..a59002bb 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/cspell.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/cspell.vim @@ -11,12 +11,31 @@ function! ale#handlers#cspell#GetExecutable(buffer) abort \) endfunction +function! ale#handlers#cspell#GetLanguageId(buffer) abort + let l:filetype = getbufvar(a:buffer, '&filetype') + + if l:filetype is# 'tex' + " Vim's tex corresponds to latex language-id in cspell + return 'latex' + elseif l:filetype is# 'plaintex' + " Vim's plaintex corresponds to tex language-id in cspell + return 'tex' + else + " Fallback to filetype for everything else. + return l:filetype + endif +endfunction + function! ale#handlers#cspell#GetCommand(buffer) abort let l:executable = ale#handlers#cspell#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'cspell_options') + let l:language_id = ale#handlers#cspell#GetLanguageId(a:buffer) + + let l:language_id_option = empty(l:language_id) ? '' : '--language-id="' . l:language_id . '"' return ale#node#Executable(a:buffer, l:executable) \ . ' lint --no-color --no-progress --no-summary' + \ . ale#Pad(l:language_id_option) \ . ale#Pad(l:options) \ . ' -- stdin' endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/embertemplatelint.vim b/sources_non_forked/ale/autoload/ale/handlers/embertemplatelint.vim new file mode 100644 index 00000000..d2e83400 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/embertemplatelint.vim @@ -0,0 +1,66 @@ +" Author: Adrian Zalewski <aazalewski@hotmail.com> +" Description: Ember-template-lint for checking Handlebars files + +function! ale#handlers#embertemplatelint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [ + \ 'node_modules/.bin/ember-template-lint', + \]) +endfunction + +function! ale#handlers#embertemplatelint#GetCommand(buffer, version) abort + if ale#semver#GTE(a:version, [4, 0, 0]) + " --json was removed in favor of --format=json in ember-template-lint@4.0.0 + return '%e --format=json --filename %s' + endif + + return '%e --json --filename %s' +endfunction + +function! ale#handlers#embertemplatelint#GetCommandWithVersionCheck(buffer) abort + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ ale#handlers#embertemplatelint#GetExecutable(a:buffer), + \ '%e --version', + \ function('ale#handlers#embertemplatelint#GetCommand'), + \) +endfunction + +function! ale#handlers#embertemplatelint#Handle(buffer, lines) abort + let l:output = [] + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) + + for l:error in get(values(l:json), 0, []) + if has_key(l:error, 'fatal') + call add(l:output, { + \ 'lnum': get(l:error, 'line', 1), + \ 'col': get(l:error, 'column', 1), + \ 'text': l:error.message, + \ 'type': l:error.severity == 1 ? 'W' : 'E', + \}) + else + call add(l:output, { + \ 'lnum': l:error.line, + \ 'col': l:error.column, + \ 'text': l:error.rule . ': ' . l:error.message, + \ 'type': l:error.severity == 1 ? 'W' : 'E', + \}) + endif + endfor + + return l:output +endfunction + +function! ale#handlers#embertemplatelint#DefineLinter(filetype) abort + call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint') + call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0)) + + call ale#linter#Define(a:filetype, { + \ 'name': 'embertemplatelint', + \ 'aliases': ['ember-template-lint'], + \ 'executable': function('ale#handlers#embertemplatelint#GetExecutable'), + \ 'command': function('ale#handlers#embertemplatelint#GetCommandWithVersionCheck'), + \ 'callback': 'ale#handlers#embertemplatelint#Handle', + \}) +endfunction + + diff --git a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim index 374460bc..eea06f51 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim @@ -18,7 +18,11 @@ call ale#Set('javascript_eslint_suppress_missing_config', 0) function! ale#handlers#eslint#FindConfig(buffer) abort for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) for l:basename in [ + \ 'eslint.config.js', + \ 'eslint.config.mjs', + \ 'eslint.config.cjs', \ '.eslintrc.js', + \ '.eslintrc.cjs', \ '.eslintrc.yaml', \ '.eslintrc.yml', \ '.eslintrc.json', @@ -41,31 +45,7 @@ endfunction " Given a buffer, return an appropriate working directory for ESLint. function! ale#handlers#eslint#GetCwd(buffer) abort - " ESLint 6 loads plugins/configs/parsers from the project root - " By default, the project root is simply the CWD of the running process. - " https://github.com/eslint/rfcs/blob/master/designs/2018-simplified-package-loading/README.md - " https://github.com/dense-analysis/ale/issues/2787 - " - " If eslint is installed in a directory which contains the buffer, assume - " it is the ESLint project root. Otherwise, use nearest node_modules. - " Note: If node_modules not present yet, can't load local deps anyway. - let l:executable = ale#path#FindNearestExecutable(a:buffer, s:executables) - - if !empty(l:executable) - let l:modules_index = strridx(l:executable, 'node_modules') - let l:modules_root = l:modules_index > -1 ? l:executable[0:l:modules_index - 2] : '' - - let l:sdks_index = strridx(l:executable, ale#path#Simplify('.yarn/sdks')) - let l:sdks_root = l:sdks_index > -1 ? l:executable[0:l:sdks_index - 2] : '' - else - let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules') - let l:modules_root = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : '' - - let l:sdks_dir = ale#path#FindNearestDirectory(a:buffer, ale#path#Simplify('.yarn/sdks')) - let l:sdks_root = !empty(l:sdks_dir) ? fnamemodify(l:sdks_dir, ':h:h:h') : '' - endif - - return strlen(l:modules_root) > strlen(l:sdks_root) ? l:modules_root : l:sdks_root + return ale#path#Dirname(ale#handlers#eslint#FindConfig(a:buffer)) endfunction function! ale#handlers#eslint#GetCommand(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim index fd540e8e..002c4651 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim @@ -49,6 +49,7 @@ function! ale#handlers#shellcheck#GetCommand(buffer, version) abort let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect') let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : '' + let l:format = ale#semver#GTE(a:version, [0, 7, 0]) ? 'json1' : 'gcc' if l:dialect is# 'auto' let l:dialect = ale#handlers#shellcheck#GetDialectArgument(a:buffer) @@ -59,10 +60,69 @@ function! ale#handlers#shellcheck#GetCommand(buffer, version) abort \ . (!empty(l:options) ? ' ' . l:options : '') \ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '') \ . l:external_option - \ . ' -f gcc -' + \ . ' -f ' . l:format . ' -' endfunction -function! ale#handlers#shellcheck#Handle(buffer, lines) abort +function! s:HandleShellcheckJSON(buffer, lines) abort + try + let l:errors = json_decode(a:lines[0]) + catch + return [] + endtry + + if !has_key(l:errors, 'comments') + return [] + endif + + let l:output = [] + + for l:error in l:errors['comments'] + if l:error['level'] is# 'error' + let l:type = 'E' + elseif l:error['level'] is# 'info' + let l:type = 'I' + elseif l:error['level'] is# 'style' + let l:type = 'I' + else + let l:type = 'W' + endif + + let l:item = { + \ 'lnum': l:error['line'], + \ 'type': l:type, + \ 'text': l:error['message'], + \ 'code': 'SC' . l:error['code'], + \ 'detail': l:error['message'] . "\n\nFor more information:\n https://www.shellcheck.net/wiki/SC" . l:error['code'], + \} + + if has_key(l:error, 'column') + let l:item.col = l:error['column'] + endif + + if has_key(l:error, 'endColumn') + let l:item.end_col = l:error['endColumn'] - 1 + endif + + if has_key(l:error, 'endLine') + let l:item.end_lnum = l:error['endLine'] + endif + + + " If the filename is something like <stdin>, <nofile> or -, then + " this is an error for the file we checked. + if has_key(l:error, 'file') + if l:error['file'] isnot# '-' && l:error['file'][0] isnot# '<' + let l:item['filename'] = l:error['file'] + endif + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +function! s:HandleShellcheckGCC(buffer, lines) abort let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+) \[([^\]]+)\]$' let l:output = [] @@ -80,6 +140,7 @@ function! ale#handlers#shellcheck#Handle(buffer, lines) abort \ 'type': l:type, \ 'text': l:match[5], \ 'code': l:match[6], + \ 'detail': l:match[5] . "\n\nFor more information:\n https://www.shellcheck.net/wiki/" . l:match[6], \} if !empty(l:match[3]) @@ -98,6 +159,12 @@ function! ale#handlers#shellcheck#Handle(buffer, lines) abort return l:output endfunction +function! ale#handlers#shellcheck#Handle(buffer, version, lines) abort + return ale#semver#GTE(a:version, [0, 7, 0]) + \ ? s:HandleShellcheckJSON(a:buffer, a:lines) + \ : s:HandleShellcheckGCC(a:buffer, a:lines) +endfunction + function! ale#handlers#shellcheck#DefineLinter(filetype) abort " This global variable can be set with a string of comma-separated error " codes to exclude from shellcheck. For example: @@ -118,6 +185,14 @@ function! ale#handlers#shellcheck#DefineLinter(filetype) abort \ '%e --version', \ function('ale#handlers#shellcheck#GetCommand'), \ )}, - \ 'callback': 'ale#handlers#shellcheck#Handle', + \ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck( + \ buffer, + \ ale#Var(buffer, 'sh_shellcheck_executable'), + \ '%e --version', + \ {buffer, version -> ale#handlers#shellcheck#Handle( + \ buffer, + \ l:version, + \ lines)}, + \ )}, \}) endfunction diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim index 1202e08e..a42766eb 100644 --- a/sources_non_forked/ale/autoload/ale/hover.vim +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -117,10 +117,10 @@ function! ale#hover#ParseLSPResult(contents) abort for l:line in split(l:item, "\n") if l:fence_language is v:null " Look for the start of a code fence. (```python, etc.) - let l:match = matchlist(l:line, '^``` *\([^ ]\+\) *$') + let l:match = matchlist(l:line, '^``` *\([^ ]\+\)\? *$') if !empty(l:match) - let l:fence_language = l:match[1] + let l:fence_language = len(l:match) > 1 ? l:match[1] : 'text' if !empty(l:marked_list) call add(l:fence_lines, '') diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim index 20104fbc..618557d7 100644 --- a/sources_non_forked/ale/autoload/ale/linter.vim +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -40,6 +40,7 @@ let s:default_ale_linter_aliases = { " NOTE: Update the g:ale_linters documentation when modifying this. let s:default_ale_linters = { \ 'apkbuild': ['apkbuild_lint', 'secfixes_check'], +\ 'astro': ['eslint'], \ 'csh': ['shell'], \ 'elixir': ['credo', 'dialyxir', 'dogma'], \ 'go': ['gofmt', 'golangci-lint', 'gopls', 'govet'], @@ -47,9 +48,9 @@ let s:default_ale_linters = { \ 'hack': ['hack'], \ 'help': [], \ 'inko': ['inko'], -\ 'json': ['jsonlint', 'spectral', 'vscodejson'], +\ 'json': ['biome', 'jsonlint', 'spectral', 'vscodejson'], \ 'json5': [], -\ 'jsonc': [], +\ 'jsonc': ['biome'], \ 'perl': ['perlcritic'], \ 'perl6': [], \ 'python': ['flake8', 'mypy', 'pylint', 'pyright', 'ruff'], @@ -60,7 +61,7 @@ let s:default_ale_linters = { \ 'vue': ['eslint', 'vls'], \ 'zsh': ['shell'], \ 'v': ['v'], -\ 'yaml': ['spectral', 'yaml-language-server', 'yamllint'], +\ 'yaml': ['actionlint', 'spectral', 'yaml-language-server', 'yamllint'], \} " Testing/debugging helper to unload all linters. diff --git a/sources_non_forked/ale/autoload/ale/python.vim b/sources_non_forked/ale/autoload/ale/python.vim index 2c7e0049..9eb198fb 100644 --- a/sources_non_forked/ale/autoload/ale/python.vim +++ b/sources_non_forked/ale/autoload/ale/python.vim @@ -3,6 +3,7 @@ call ale#Set('python_auto_pipenv', '0') call ale#Set('python_auto_poetry', '0') +call ale#Set('python_auto_uv', '0') let s:sep = has('win32') ? '\' : '/' " bin is used for Unix virtualenv directories, and Scripts is for Windows. @@ -43,6 +44,7 @@ function! ale#python#FindProjectRootIni(buffer) abort \|| filereadable(l:path . '/poetry.lock') \|| filereadable(l:path . '/pyproject.toml') \|| filereadable(l:path . '/.tool-versions') + \|| filereadable(l:path . '/uv.lock') return l:path endif endfor @@ -192,3 +194,8 @@ endfunction function! ale#python#PoetryPresent(buffer) abort return findfile('poetry.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' endfunction + +" Detects whether a poetry environment is present. +function! ale#python#UvPresent(buffer) abort + return findfile('uv.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim index 15517bf8..e78ce468 100644 --- a/sources_non_forked/ale/autoload/ale/sign.vim +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -161,7 +161,7 @@ endfunction function! s:GroupCmd() abort if s:supports_sign_groups - return ' group=ale ' + return ' group=ale_signs ' else return ' ' endif @@ -180,13 +180,13 @@ 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)' + " line=4 id=1 group=ale_signs name=ALEErrorSign + " строка=1 id=1000001 группа=ale_signs имя=ALEErrorSign + " 行=1 識別子=1000001 グループ=ale_signs 名前=ALEWarningSign + " línea=12 id=1000001 grupo=ale_signs nombre=ALEWarningSign + " riga=1 id=1000001 gruppo=ale_signs nome=ALEWarningSign + " Zeile=235 id=1000001 Gruppe=ale_signs Name=ALEErrorSign + let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=ale_signs>.*\=(ALE[a-zA-Z]+Sign)' else " Matches output like : " line=4 id=1 name=ALEErrorSign @@ -203,7 +203,7 @@ endfunction " Given a buffer number, return a List of placed signs [line, id, group] function! ale#sign#ParseSignsWithGetPlaced(buffer) abort - let l:signs = sign_getplaced(a:buffer, { 'group': s:supports_sign_groups ? 'ale' : '' })[0].signs + let l:signs = sign_getplaced(a:buffer, { 'group': s:supports_sign_groups ? 'ale_signs' : '' })[0].signs let l:result = [] let l:is_dummy_sign_set = 0 @@ -489,7 +489,7 @@ endfunction " Remove all signs. function! ale#sign#Clear() abort if s:supports_sign_groups - sign unplace group=ale * + sign unplace group=ale_signs * else sign unplace * endif diff --git a/sources_non_forked/ale/doc/ale-astro.txt b/sources_non_forked/ale/doc/ale-astro.txt new file mode 100644 index 00000000..0132aa80 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-astro.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE Astro Integration *ale-astro-options* + + +=============================================================================== +eslint *ale-astro-eslint* + +See |ale-javascript-eslint| for information about the available options. + +=============================================================================== +prettier *ale-astro-prettier* + +See |ale-javascript-prettier| for information about the available options. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-dart.txt b/sources_non_forked/ale/doc/ale-dart.txt index 4824e82e..8761515e 100644 --- a/sources_non_forked/ale/doc/ale-dart.txt +++ b/sources_non_forked/ale/doc/ale-dart.txt @@ -27,6 +27,19 @@ g:ale_dart_analysis_server_executable *g:ale_dart_analysis_server_executable* This variable can be set to change the path of dart. +g:ale_dart_analysis_server_enable_language_server + *g:ale_dart_analysis_server_enable_language_server* + *b:ale_dart_analysis_server_enable_language_server* + Type: |Number| + Default: `1` + + When set to `1`, ALE will use the new `dart language-server` command, + available from Dart version 2.16.0, to launch the language server. When set + to `0`, ALE will instead use the deprecated + `./snapshots/analysis_server.dart.snapshot --lsp` command used by older + versions of Dart. + + =============================================================================== dart-analyze *ale-dart-analyze* diff --git a/sources_non_forked/ale/doc/ale-eruby.txt b/sources_non_forked/ale/doc/ale-eruby.txt index 65bd8a30..82fe685a 100644 --- a/sources_non_forked/ale/doc/ale-eruby.txt +++ b/sources_non_forked/ale/doc/ale-eruby.txt @@ -7,6 +7,7 @@ There are four linters for `eruby` files: - `erblint` - `erubis` - `erubi` +- `htmlbeautifier` - `ruumba` `erb` is in the Ruby standard library and is mostly universal. `erubis` is the @@ -47,6 +48,18 @@ g:ale_eruby_erblint_options *g:ale_ruby_erblint_options* This variable can be change to modify flags given to erblint. +=============================================================================== +htmlbeautifier *ale-eruby-htmlbeautifier* + +g:ale_eruby_htmlbeautifier_executable *g:ale_eruby_htmlbeautifier_executable* + *b:ale_eruby_htmlbeautifier_executable* + Type: |String| + Default: `'htmlbeautifier'` + + Override the invoked htmlbeautifier binary. This is useful for running + htmlbeautifier from binstubs or a bundle. + + =============================================================================== ruumba *ale-eruby-ruumba* diff --git a/sources_non_forked/ale/doc/ale-hurl.txt b/sources_non_forked/ale/doc/ale-hurl.txt new file mode 100644 index 00000000..6c4d726b --- /dev/null +++ b/sources_non_forked/ale/doc/ale-hurl.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE Hurl Integration *ale-hurl-options* + + +=============================================================================== +hurlfmt *ale-hurl-hurlfmt* + +g:ale_hurl_hurlfmt_executable *g:ale_hurl_hurlfmt_executable* + *b:ale_hurl_hurlfmt_executable* + Type: |String| + Default: `'hurlfmt'` + + Override the invoked hurlfmt binary. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-javascript.txt b/sources_non_forked/ale/doc/ale-javascript.txt index a55cd643..7e594f2a 100644 --- a/sources_non_forked/ale/doc/ale-javascript.txt +++ b/sources_non_forked/ale/doc/ale-javascript.txt @@ -25,6 +25,12 @@ To this: > < +=============================================================================== +biome *ale-javascript-biome* + +Check the docs over at |ale-typescript-biome|. + + =============================================================================== clang-format *ale-javascript-clangformat* diff --git a/sources_non_forked/ale/doc/ale-json.txt b/sources_non_forked/ale/doc/ale-json.txt index 7b240373..8822a697 100644 --- a/sources_non_forked/ale/doc/ale-json.txt +++ b/sources_non_forked/ale/doc/ale-json.txt @@ -2,6 +2,12 @@ ALE JSON Integration *ale-json-options* +=============================================================================== +biome *ale-json-biome* + +Check the docs over at |ale-typescript-biome|. + + =============================================================================== clang-format *ale-json-clangformat* diff --git a/sources_non_forked/ale/doc/ale-jsonc.txt b/sources_non_forked/ale/doc/ale-jsonc.txt index 92247cd4..b05fa6e6 100644 --- a/sources_non_forked/ale/doc/ale-jsonc.txt +++ b/sources_non_forked/ale/doc/ale-jsonc.txt @@ -2,6 +2,12 @@ ALE JSONC Integration *ale-jsonc-options* +=============================================================================== +biome *ale-jsonc-biome* + +Check the docs over at |ale-typescript-biome|. + + =============================================================================== eslint *ale-jsonc-eslint* diff --git a/sources_non_forked/ale/doc/ale-odin.txt b/sources_non_forked/ale/doc/ale-odin.txt new file mode 100644 index 00000000..826411de --- /dev/null +++ b/sources_non_forked/ale/doc/ale-odin.txt @@ -0,0 +1,29 @@ +=============================================================================== +ALE Odin Integration *ale-odin-options* + *ale-integration-odin* + +=============================================================================== +Integration Information + + Currently, the only supported linter for Odin is ols. + +=============================================================================== +ols *ale-odin-ols* + +g:ale_odin_ols_executable *g:ale_odin_ols_executable* + *b:ale_odin_ols_executable* + Type: |String| + Default: `'ols'` + + This variable can be modified to change the executable path for `ols`. + + +g:ale_odin_ols_config *g:ale_odin_ols_config* + *b:ale_odin_ols_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for ols. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt index ec118c5a..4798baaf 100644 --- a/sources_non_forked/ale/doc/ale-python.txt +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -20,6 +20,15 @@ g:ale_python_auto_poetry *g:ale_python_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_auto_uv *g:ale_python_auto_uv* + *b:ale_python_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + g:ale_python_auto_virtualenv *g:ale_python_auto_virtualenv* *b:ale_python_auto_virtualenv* Type: |Number| @@ -96,6 +105,33 @@ g:ale_python_autoflake_use_global *g:ale_python_autoflake_use_global* See |ale-integrations-local-executables| +g:ale_python_autoflake_auto_pipenv *g:ale_python_autoflake_auto_pipenv* + *b:ale_python_autoflake_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_autoflake_auto_poetry *g:ale_python_autoflake_auto_poetry* + *b:ale_python_autoflake_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_autoflake_auto_uv *g:ale_python_autoflake_auto_uv* + *b:ale_python_autoflake_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== autoimport *ale-python-autoimport* @@ -123,6 +159,33 @@ g:ale_python_autoimport_use_global *g:ale_python_autoimport_use_global* See |ale-integrations-local-executables| +g:ale_python_autoimport_auto_pipenv *g:ale_python_autoimport_auto_pipenv* + *b:ale_python_autoimport_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_autoimport_auto_poetry *g:ale_python_autoimport_auto_poetry* + *b:ale_python_autoimport_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_autoimport_auto_uv *g:ale_python_autoimport_auto_uv* + *b:ale_python_autoimport_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== autopep8 *ale-python-autopep8* @@ -150,6 +213,33 @@ g:ale_python_autopep8_use_global *g:ale_python_autopep8_use_global* See |ale-integrations-local-executables| +g:ale_python_autopep8_auto_pipenv *g:ale_python_autopep8_auto_pipenv* + *b:ale_python_autopep8_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_autopep8_auto_poetry *g:ale_python_autopep8_auto_poetry* + *b:ale_python_autopep8_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_autopep8_auto_uv *g:ale_python_autopep8_auto_uv* + *b:ale_python_autopep8_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== bandit *ale-python-bandit* @@ -210,6 +300,15 @@ g:ale_python_bandit_auto_poetry *g:ale_python_bandit_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_bandit_auto_uv *g:ale_python_bandit_auto_uv* + *b:ale_python_bandit_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== black *ale-python-black* @@ -255,6 +354,15 @@ g:ale_python_black_auto_poetry *g:ale_python_black_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_black_auto_uv *g:ale_python_black_auto_uv* + *b:ale_python_black_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + g:ale_python_black_change_directory *g:ale_python_black_change_directory* *b:ale_python_black_change_directory* Type: |Number| @@ -345,6 +453,15 @@ g:ale_python_flake8_auto_poetry *g:ale_python_flake8_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_flake8_auto_uv *g:ale_python_flake8_auto_uv* + *b:ale_python_flake8_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== flakehell *ale-python-flakehell* @@ -410,6 +527,15 @@ g:ale_python_flakehell_auto_poetry *g:ale_python_flakehell_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_flakehell_auto_uv *g:ale_python_flakehell_auto_uv* + *b:ale_python_flakehell_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== isort *ale-python-isort* @@ -455,6 +581,15 @@ g:ale_python_isort_auto_poetry *g:ale_python_isort_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_isort_auto_uv *g:ale_python_isort_auto_uv* + *b:ale_python_isort_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== mypy *ale-python-mypy* @@ -483,6 +618,15 @@ g:ale_python_mypy_auto_poetry *g:ale_python_mypy_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_mypy_auto_uv *g:ale_python_mypy_auto_uv* + *b:ale_python_mypy_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + g:ale_python_mypy_executable *g:ale_python_mypy_executable* *b:ale_python_mypy_executable* Type: |String| @@ -591,6 +735,15 @@ g:ale_python_prospector_auto_poetry *g:ale_python_prospector_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_prospector_auto_uv *g:ale_python_prospector_auto_uv* + *b:ale_python_prospector_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== pycln *ale-python-pycln* @@ -663,6 +816,15 @@ g:ale_python_pycln_auto_poetry *g:ale_python_pycln_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_pycln_auto_uv *g:ale_python_pycln_auto_uv* + *b:ale_python_pycln_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== pycodestyle *ale-python-pycodestyle* @@ -712,6 +874,15 @@ g:ale_python_pycodestyle_auto_poetry *g:ale_python_pycodestyle_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_pycodestyle_auto_uv *g:ale_python_pycodestyle_auto_uv* + *b:ale_python_pycodestyle_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== pydocstyle *ale-python-pydocstyle* @@ -761,6 +932,15 @@ g:ale_python_pydocstyle_auto_poetry *g:ale_python_pydocstyle_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_pydocstyle_auto_uv *g:ale_python_pydocstyle_auto_uv* + *b:ale_python_pydocstyle_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== pyflakes *ale-python-pyflakes* @@ -793,6 +973,15 @@ g:ale_python_pyflakes_auto_poetry *g:ale_python_pyflakes_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_pyflakes_auto_uv *g:ale_python_pyflakes_auto_uv* + *b:ale_python_pyflakes_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== pyflyby *ale-python-pyflyby* @@ -839,6 +1028,15 @@ g:ale_python_pyflyby_auto_poetry *g:ale_python_pyflyby_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_pyflyby_auto_uv *g:ale_python_pyflyby_auto_uv* + *b:ale_python_pyflyby_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== pylama *ale-python-pylama* @@ -902,6 +1100,14 @@ g:ale_python_pylama_auto_poetry *g:ale_python_pylama_auto_poetry* Detect whether the file is inside a poetry, and set the executable to `poetry` if true. This is overridden by a manually-set executable. +g:ale_python_pylama_auto_uv *g:ale_python_pylama_auto_uv* + *b:ale_python_pylama_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + =============================================================================== pylint *ale-python-pylint* @@ -976,6 +1182,15 @@ g:ale_python_pylint_auto_poetry *g:ale_python_pylint_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_pylint_auto_uv *g:ale_python_pylint_auto_uv* + *b:ale_python_pylint_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + g:ale_python_pylint_use_msg_id *g:ale_python_pylint_use_msg_id* *b:ale_python_pylint_use_msg_id* Type: |Number| @@ -1028,6 +1243,15 @@ g:ale_python_pylsp_auto_poetry *g:ale_python_pylsp_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_pylsp_auto_uv *g:ale_python_pylsp_auto_uv* + *b:ale_python_pylsp_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + g:ale_python_pylsp_config *g:ale_python_pylsp_config* *b:ale_python_pylsp_config* Type: |Dictionary| @@ -1109,6 +1333,15 @@ g:ale_python_pyre_auto_poetry *g:ale_python_pyre_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_pyre_auto_uv *g:ale_python_pyre_auto_uv* + *b:ale_python_pyre_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== pyright *ale-python-pyright* @@ -1168,6 +1401,33 @@ g:ale_python_pyright_config *g:ale_python_pyright_config* \} < +g:ale_python_pyright_auto_pipenv *g:ale_python_pyright_auto_pipenv* + *b:ale_python_pyright_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pyright_auto_poetry *g:ale_python_pyright_auto_poetry* + *b:ale_python_pyright_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pyright_auto_uv *g:ale_python_pyright_auto_uv* + *b:ale_python_pyright_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== refurb *ale-python-refurb* @@ -1229,6 +1489,15 @@ g:ale_python_refurb_auto_poetry *g:ale_python_refurb_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_refurb_auto_uv *g:ale_python_refurb_auto_uv* + *b:ale_python_refurb_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== reorder-python-imports *ale-python-reorder_python_imports* @@ -1259,6 +1528,36 @@ g:ale_python_reorder_python_imports_use_global See |ale-integrations-local-executables| +g:ale_python_reorder_python_imports_auto_pipenv + *g:ale_python_reorder_python_imports_auto_pipenv* + *b:ale_python_reorder_python_imports_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_reorder_python_imports_auto_poetry + *g:ale_python_reorder_python_imports_auto_poetry* + *b:ale_python_reorder_python_imports_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_reorder_python_imports_auto_uv + *g:ale_python_reorder_python_imports_auto_uv* + *b:ale_python_reorder_python_imports_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== ruff *ale-python-ruff* @@ -1322,6 +1621,15 @@ g:ale_python_ruff_auto_poetry *g:ale_python_ruff_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_ruff_auto_uv *g:ale_python_ruff_auto_uv* + *b:ale_python_ruff_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== ruff-format *ale-python-ruff-format* @@ -1386,6 +1694,15 @@ g:ale_python_ruff_format_auto_poetry *g:ale_python_ruff_format_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_ruff_format_auto_uv *g:ale_python_ruff_format_auto_uv* + *b:ale_python_ruff_format_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== unimport *ale-python-unimport* @@ -1410,6 +1727,15 @@ g:ale_python_unimport_auto_poetry *g:ale_python_unimport_auto_poetry* if true. This is overridden by a manually-set executable. +g:ale_python_unimport_auto_uv *g:ale_python_unimport_auto_uv* + *b:ale_python_unimport_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + g:ale_python_unimport_executable *g:ale_python_unimport_executable* *b:ale_python_unimport_executable* Type: |String| @@ -1476,6 +1802,32 @@ g:ale_python_vulture_use_global *g:ale_python_vulture_use_global* See |ale-integrations-local-executables| +g:ale_python_vulture_auto_pipenv *g:ale_python_vulture_auto_pipenv* + *b:ale_python_vulture_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_vulture_auto_poetry *g:ale_python_vulture_auto_poetry* + *b:ale_python_vulture_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_vulture_auto_uv *g:ale_python_vulture_auto_uv* + *b:ale_python_vulture_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + =============================================================================== yapf *ale-python-yapf* @@ -1496,5 +1848,32 @@ g:ale_python_yapf_use_global *g:ale_python_yapf_use_global* See |ale-integrations-local-executables| +g:ale_python_yapf_auto_pipenv *g:ale_python_yapf_auto_pipenv* + *b:ale_python_yapf_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_yapf_auto_poetry *g:ale_python_yapf_auto_poetry* + *b:ale_python_yapf_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_yapf_auto_uv *g:ale_python_yapf_auto_uv* + *b:ale_python_yapf_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== 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 ff9aa798..ff5a371f 100644 --- a/sources_non_forked/ale/doc/ale-ruby.txt +++ b/sources_non_forked/ale/doc/ale-ruby.txt @@ -258,6 +258,24 @@ g:ale_ruby_syntax_tree_options *g:ale_ruby_syntax_tree_options* This variable can be changed to modify flags given to SyntaxTree. +=============================================================================== +rubyfmt *ale-ruby-rubyfmt* + +g:ale_ruby_rubyfmt_executable *g:ale_ruby_rubyfmt_executable* + *b:ale_ruby_rubyfmt_executable* + Type: |String| + Default: `'rubyfmt'` + + This option can be changed to change the path for `rubyfmt`. + + +g:ale_ruby_rubyfmt_options *g:ale_ruby_rubyfmt_options* + *b:ale_ruby_rubyfmt_options* + Type: |String| + Default: `''` + + This option can be changed to pass extra options to `'rubyfmt'`. + =============================================================================== 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 aa49a1b1..ec787d22 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 @@ -37,6 +37,9 @@ Notes: * ASM * `gcc` * `llvm-mc` +* Astro + * `eslint` + * `prettier` * AVRA * `avra` * Awk @@ -182,6 +185,7 @@ Notes: * `erblint` * `erubi` * `erubis` + * `htmlbeautifier` * `ruumba` * Erlang * `SyntaxErl` @@ -202,6 +206,9 @@ Notes: * `fusion-lint` * Git Commit Messages * `gitlint` +* Gleam + * `gleam_format` + * `gleamlsp` * GLSL * `glslang` * `glslls` @@ -271,6 +278,8 @@ Notes: * `rustywind` * `tidy` * `write-good` +* Hurl + * `hurlfmt` * Idris * `idris` * Ink @@ -290,6 +299,7 @@ Notes: * `javalsp` * `uncrustify` * JavaScript + * `biome` * `clang-format` * `cspell` * `deno` @@ -307,6 +317,7 @@ Notes: * `xo` * JSON * `VSCode JSON language server` + * `biome` * `clang-format` * `cspell` * `dprint` @@ -319,6 +330,7 @@ Notes: * JSON5 * `eslint` * JSONC + * `biome` * `eslint` * Jsonnet * `jsonnet-lint` @@ -418,6 +430,8 @@ Notes: * `ocamllsp` * `ocp-indent` * `ols` +* Odin + * `ols` * OpenApi * `ibm_validator` * `prettier` @@ -558,10 +572,12 @@ Notes: * `reek` * `rubocop` * `ruby` + * `rubyfmt` * `rufo` * `solargraph` * `sorbet` * `standardrb` + * `steep` * `syntax_tree` * Rust * `cargo`!! @@ -650,6 +666,7 @@ Notes: * TOML * `dprint` * TypeScript + * `biome` * `cspell` * `deno` * `dprint` @@ -669,6 +686,7 @@ Notes: * Verilog * `hdl-checker` * `iverilog` + * slang * `verilator` * `vlog` * `xvlog` diff --git a/sources_non_forked/ale/doc/ale-typescript.txt b/sources_non_forked/ale/doc/ale-typescript.txt index ab3f17bd..22fbe7b4 100644 --- a/sources_non_forked/ale/doc/ale-typescript.txt +++ b/sources_non_forked/ale/doc/ale-typescript.txt @@ -2,6 +2,56 @@ ALE TypeScript Integration *ale-typescript-options* +=============================================================================== +biome *ale-typescript-biome* + +g:ale_biome_executable *g:ale_biome_executable* + *b:ale_biome_executable* + Type: |String| + Default: `'biome'` + + +g:ale_biome_options *g:ale_biome_options* + *b:ale_biome_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to `biome check` when + applying fixes. + + +g:ale_biome_use_global *g:ale_biome_use_global* + *b:ale_biome_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_biome_fixer_apply_unsafe *g:ale_biome_fixer_apply_unsafe* + *b:ale_biome_fixer_apply_unsafe* + Type: |Number| + Default: `0` + + If set to `1`, biome will apply unsafe fixes along with safe fixes. + + +g:ale_biome_lsp_project_root *g:ale_biome_lsp_project_root* + *b:ale_biome_lsp_project_root* + Type: |String| + Default: `''` + + If this variable is left unset, ALE will try to find the project root by + executing the following steps in the given order: + + 1. Find an ancestor directory containing a biome.json. + 2. Find an ancestor directory containing a biome.jsonc. + 3. Find an ancestor directory containing a package.json. + 4. Find an ancestor directory containing a .git folder. + 5. Use the directory of the current buffer (if the buffer was opened from + a file). + + =============================================================================== cspell *ale-typescript-cspell* diff --git a/sources_non_forked/ale/doc/ale-verilog.txt b/sources_non_forked/ale/doc/ale-verilog.txt index 611ed2f9..83e4f31e 100644 --- a/sources_non_forked/ale/doc/ale-verilog.txt +++ b/sources_non_forked/ale/doc/ale-verilog.txt @@ -3,7 +3,7 @@ ALE Verilog/SystemVerilog Integration *ale-verilog-options* =============================================================================== -ALE can use six different linters for Verilog HDL: +ALE can use seven different linters for Verilog HDL: HDL Checker Using `hdl_checker --lsp` @@ -11,6 +11,9 @@ ALE can use six different linters for Verilog HDL: iverilog: Using `iverilog -t null -Wall` + slang: + Using `slang -Weverything` + verilator Using `verilator --lint-only -Wall` @@ -21,7 +24,7 @@ ALE can use six different linters for Verilog HDL: Using `xvlog` Yosys - Using `ysoys -Q -T -p 'read_verilog'` + Using `yosys -Q -T -p 'read_verilog'` By default, both 'verilog' and 'systemverilog' filetypes are checked. @@ -64,6 +67,15 @@ iverilog *ale-verilog-iverilog* No additional options +=============================================================================== +slang *ale-verilog-slang* + +g:ale_verilog_slang_option *g:ale_verilog_slang_options* + *b:ale_verilog_slang_options* + Type: String + Default: '' + + This variable can be changed to modify 'slang' command arguments. =============================================================================== verilator *ale-verilog-verilator* @@ -73,7 +85,7 @@ g:ale_verilog_verilator_options *g:ale_verilog_verilator_options* Type: |String| Default: `''` - This variable can be changed to modify 'verilator' command arguments + This variable can be changed to modify 'verilator' command arguments. For example `'-sv --default-language "1800-2012"'` if you want to enable SystemVerilog parsing and select the 2012 version of the language. diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index 5f7999b8..d9be7682 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -186,11 +186,11 @@ script like so. > exec docker run -i --rm -v "$(pwd):/data" cytopia/pylint "$@" < -You will run to run Docker commands with `-i` in order to read from stdin. +You will want to run Docker commands with `-i` in order to read from stdin. With the above script in mind, you might configure ALE to lint your Python project with `pylint` by providing the path to the script to execute, and -mappings which describe how to between the two file systems in your +mappings which describe how to change between the two file systems in your `python.vim` |ftplugin| file, like so: > if expand('%:p') =~# '^/home/w0rp/git/test-pylint/' @@ -1670,7 +1670,7 @@ g:ale_linters *g:ale_linters* \ 'vue': ['eslint', 'vls'], \ 'zsh': ['shell'], \ 'v': ['v'], - \ 'yaml': ['spectral', 'yaml-language-server', 'yamllint'], + \ 'yaml': ['actionlint', 'spectral', 'yaml-language-server', 'yamllint'], \} < This option can be used to enable only a particular set of linters for a @@ -2899,6 +2899,9 @@ documented in additional help files. asm.....................................|ale-asm-options| gcc...................................|ale-asm-gcc| llvm_mc...............................|ale-asm-llvm_mc| + astro...................................|ale-astro-options| + eslint................................|ale-astro-eslint| + prettier..............................|ale-astro-prettier| avra....................................|ale-avra-options| avra..................................|ale-avra-avra| awk.....................................|ale-awk-options| @@ -3020,6 +3023,7 @@ documented in additional help files. eruby...................................|ale-eruby-options| erb-formatter.........................|ale-eruby-erbformatter| erblint...............................|ale-eruby-erblint| + htmlbeautifier........................|ale-eruby-htmlbeautifier| ruumba................................|ale-eruby-ruumba| fish....................................|ale-fish-options| fish_indent...........................|ale-fish-fish_indent| @@ -3031,6 +3035,9 @@ documented in additional help files. fusion-lint...........................|ale-fuse-fusionlint| git commit..............................|ale-gitcommit-options| gitlint...............................|ale-gitcommit-gitlint| + gleam...................................|ale-gleam-options| + gleam_format..........................|ale-gleam-gleam_format| + gleamlsp..............................|ale-gleam-gleamlsp| glsl....................................|ale-glsl-options| glslang...............................|ale-glsl-glslang| glslls................................|ale-glsl-glslls| @@ -3095,6 +3102,8 @@ documented in additional help files. tidy..................................|ale-html-tidy| vscodehtml............................|ale-html-vscode| write-good............................|ale-html-write-good| + hurl....................................|ale-hurl-options| + hurlfmt...............................|ale-hurl-hurlfmt| idris...................................|ale-idris-options| idris.................................|ale-idris-idris| ink.....................................|ale-ink-options| @@ -3114,6 +3123,7 @@ documented in additional help files. eclipselsp............................|ale-java-eclipselsp| uncrustify............................|ale-java-uncrustify| javascript..............................|ale-javascript-options| + biome.................................|ale-javascript-biome| clang-format..........................|ale-javascript-clangformat| cspell................................|ale-javascript-cspell| deno..................................|ale-javascript-deno| @@ -3130,6 +3140,7 @@ documented in additional help files. standard..............................|ale-javascript-standard| xo....................................|ale-javascript-xo| json....................................|ale-json-options| + biome.................................|ale-json-biome| clang-format..........................|ale-json-clangformat| cspell................................|ale-json-cspell| dprint................................|ale-json-dprint| @@ -3141,6 +3152,7 @@ documented in additional help files. spectral..............................|ale-json-spectral| vscodejson............................|ale-json-vscode| jsonc...................................|ale-jsonc-options| + biome.................................|ale-jsonc-biome| eslint................................|ale-jsonc-eslint| jsonnet.................................|ale-jsonnet-options| jsonnetfmt............................|ale-jsonnet-jsonnetfmt| @@ -3220,6 +3232,8 @@ documented in additional help files. ols...................................|ale-ocaml-ols| ocamlformat...........................|ale-ocaml-ocamlformat| ocp-indent............................|ale-ocaml-ocp-indent| + odin....................................|ale-odin-options| + ols...................................|ale-odin-ols| openapi.................................|ale-openapi-options| ibm_validator.........................|ale-openapi-ibm-validator| prettier..............................|ale-openapi-prettier| @@ -3350,6 +3364,7 @@ documented in additional help files. sorbet................................|ale-ruby-sorbet| standardrb............................|ale-ruby-standardrb| syntax_tree...........................|ale-ruby-syntax_tree| + rubyfmt...............................|ale-ruby-rubyfmt| rust....................................|ale-rust-options| analyzer..............................|ale-rust-analyzer| cargo.................................|ale-rust-cargo| @@ -3436,6 +3451,7 @@ documented in additional help files. toml....................................|ale-toml-options| dprint................................|ale-toml-dprint| typescript..............................|ale-typescript-options| + biome.................................|ale-typescript-biome| cspell................................|ale-typescript-cspell| deno..................................|ale-typescript-deno| dprint................................|ale-typescript-dprint| @@ -3453,6 +3469,7 @@ documented in additional help files. verilog/systemverilog...................|ale-verilog-options| hdl-checker...........................|ale-verilog-hdl-checker| iverilog..............................|ale-verilog-iverilog| + slang.................................|ale-verilog-slang| verilator.............................|ale-verilog-verilator| vlog..................................|ale-verilog-vlog| xvlog.................................|ale-verilog-xvlog| diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 47934fa0..054e9596 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -183,6 +183,9 @@ let g:ale_python_auto_pipenv = get(g:, 'ale_python_auto_pipenv', 0) " Enable automatic detection of poetry for Python linters. let g:ale_python_auto_poetry = get(g:, 'ale_python_auto_poetry', 0) +" Enable automatic detection of uv for Python linters. +let g:ale_python_auto_uv = get(g:, 'ale_python_auto_uv', 0) + " Enable automatic adjustment of environment variables for Python linters. " The variables are set based on ALE's virtualenv detection. let g:ale_python_auto_virtualenv = get(g:, 'ale_python_auto_virtualenv', 0) diff --git a/sources_non_forked/ale/supported-tools.md b/sources_non_forked/ale/supported-tools.md index 6431cfe6..f49b5a02 100644 --- a/sources_non_forked/ale/supported-tools.md +++ b/sources_non_forked/ale/supported-tools.md @@ -46,6 +46,9 @@ formatting. * ASM * [gcc](https://gcc.gnu.org) * [llvm-mc](https://llvm.org) +* Astro + * [eslint](http://eslint.org/) + * [prettier](https://github.com/prettier/prettier) * AVRA * [avra](https://github.com/Ro5bert/avra) * Awk @@ -191,6 +194,7 @@ formatting. * [erblint](https://github.com/Shopify/erb-lint) * [erubi](https://github.com/jeremyevans/erubi) * [erubis](https://github.com/kwatch/erubis) + * [htmlbeautifier](https://github.com/threedaymonk/htmlbeautifier) * [ruumba](https://github.com/ericqweinstein/ruumba) * Erlang * [SyntaxErl](https://github.com/ten0s/syntaxerl) @@ -211,6 +215,9 @@ formatting. * [fusion-lint](https://github.com/RyanSquared/fusionscript) * Git Commit Messages * [gitlint](https://github.com/jorisroovers/gitlint) +* Gleam + * [gleam_format](https://github.com/gleam-lang/gleam) + * [gleamlsp](https://github.com/gleam-lang/gleam) * GLSL * [glslang](https://github.com/KhronosGroup/glslang) * [glslls](https://github.com/svenstaro/glsl-language-server) @@ -280,6 +287,8 @@ formatting. * [rustywind](https://github.com/avencera/rustywind) * [tidy](http://www.html-tidy.org/) * [write-good](https://github.com/btford/write-good) +* Hurl + * [hurlfmt](https://hurl.dev) * Idris * [idris](http://www.idris-lang.org/) * Ink @@ -299,6 +308,7 @@ formatting. * [javalsp](https://github.com/georgewfraser/vscode-javac) * [uncrustify](https://github.com/uncrustify/uncrustify) * JavaScript + * [biome](https://biomejs.dev/) * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [deno](https://deno.land/) @@ -316,6 +326,7 @@ formatting. * [xo](https://github.com/sindresorhus/xo) * JSON * [VSCode JSON language server](https://github.com/hrsh7th/vscode-langservers-extracted) + * [biome](https://biomejs.dev/) * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning: * [dprint](https://dprint.dev) @@ -328,6 +339,7 @@ formatting. * JSON5 * [eslint](http://eslint.org/) :warning: * JSONC + * [biome](https://biomejs.dev/) * [eslint](http://eslint.org/) :warning: * Jsonnet * [jsonnet-lint](https://jsonnet.org/learning/tools.html) @@ -427,6 +439,8 @@ formatting. * [ocamllsp](https://github.com/ocaml/ocaml-lsp) * [ocp-indent](https://github.com/OCamlPro/ocp-indent) * [ols](https://github.com/freebroccolo/ocaml-language-server) +* Odin + * [ols](https://github.com/DanielGavin/ols) * OpenApi * [ibm_validator](https://github.com/IBM/openapi-validator) * [prettier](https://github.com/prettier/prettier) @@ -567,10 +581,12 @@ formatting. * [reek](https://github.com/troessner/reek) * [rubocop](https://github.com/bbatsov/rubocop) * [ruby](https://www.ruby-lang.org) + * [rubyfmt](https://github.com/fables-tales/rubyfmt) * [rufo](https://github.com/ruby-formatter/rufo) * [solargraph](https://solargraph.org) * [sorbet](https://github.com/sorbet/sorbet) * [standardrb](https://github.com/testdouble/standard) + * [steep](https://github.com/soutaro/steep) * [syntax_tree](https://github.com/ruby-syntax-tree/syntax_tree) * Rust * [cargo](https://github.com/rust-lang/cargo) :floppy_disk: (see `:help ale-integration-rust` for configuration instructions) @@ -659,6 +675,7 @@ formatting. * TOML * [dprint](https://dprint.dev) * TypeScript + * [biome](https://biomejs.dev/) * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [deno](https://deno.land/) * [dprint](https://dprint.dev/) @@ -678,6 +695,7 @@ formatting. * Verilog * [hdl-checker](https://pypi.org/project/hdl-checker) * [iverilog](https://github.com/steveicarus/iverilog) + * [slang](https://github.com/MikePopoloski/slang) * [verilator](http://www.veripool.org/projects/verilator/wiki/Intro) * [vlog](https://www.mentor.com/products/fv/questa/) * [xvlog](https://www.xilinx.com/products/design-tools/vivado.html) @@ -708,7 +726,7 @@ formatting. * XML * [xmllint](http://xmlsoft.org/xmllint.html) * YAML - * [actionlint](https://github.com/rhysd/actionlint) :warning: + * [actionlint](https://github.com/rhysd/actionlint) * [circleci](https://circleci.com/docs/2.0/local-cli) :floppy_disk: :warning: * [gitlablint](https://github.com/elijah-roberts/gitlab-lint) * [prettier](https://github.com/prettier/prettier) diff --git a/sources_non_forked/ale/test-files/python/no_uv/whatever.py b/sources_non_forked/ale/test-files/python/no_uv/whatever.py new file mode 100644 index 00000000..e69de29b diff --git a/sources_non_forked/bufexplorer/.gitignore b/sources_non_forked/bufexplorer/.gitignore index 42d5d592..0d0e6876 100644 --- a/sources_non_forked/bufexplorer/.gitignore +++ b/sources_non_forked/bufexplorer/.gitignore @@ -4,3 +4,7 @@ dist.bat *.zip tags *.sw[a-p] + +# Github token. +github_token + diff --git a/sources_non_forked/bufexplorer/.goreleaser.yaml b/sources_non_forked/bufexplorer/.goreleaser.yaml new file mode 100644 index 00000000..4a1fa1cc --- /dev/null +++ b/sources_non_forked/bufexplorer/.goreleaser.yaml @@ -0,0 +1,54 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +#version: 1 + +env_files: + # GoReleaser requires an API token with the 'repo' scope selected to deploy + # the artifacts to GitHub. You can create one here + # https://github.com/settings/tokens/new. + github_token: ./github_token + +#before: +# hooks: +# # You may remove this if you don't use go modules. +# - go mod tidy +# # you may remove this if you don't need go generate +# - go generate ./... + +builds: + - skip: true + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: '{{ .Tag }}-next' + +changelog: + use: github-native + sort: asc + +release: + draft: false + replace_existing_draft: true diff --git a/sources_non_forked/bufexplorer/doc/bufexplorer.txt b/sources_non_forked/bufexplorer/doc/bufexplorer.txt index 6e1e1b51..6f82611e 100644 --- a/sources_non_forked/bufexplorer/doc/bufexplorer.txt +++ b/sources_non_forked/bufexplorer/doc/bufexplorer.txt @@ -1,7 +1,7 @@ -*bufexplorer.txt* Buffer Explorer Last Change: 01 May 2023 +*bufexplorer.txt* Buffer Explorer Last Change: 13 Aug 2024 Buffer Explorer *buffer-explorer* *bufexplorer* - Version 7.4.26 + Version 7.4.27 Plugin for easily exploring (or browsing) Vim|:buffers|. @@ -263,6 +263,10 @@ The default is 1. =============================================================================== CHANGE LOG *bufexplorer-changelog* +7.4.27 May 30, 2024 + - Thanks to GitHub user NotNormallyAGitUser, for the recommendation to + change the display of the relative path to replace $HOME with "~". + This save valuable screen real estate. 7.4.26 May 01, 2023 What's Changed - wipe explorer buffer on hide by @basharh in @@ -795,9 +799,9 @@ TODO *bufexplorer-todo* =============================================================================== CREDITS *bufexplorer-credits* -Author: Jeff Lanzarotta <delux256-vim at outlook dot com> +Author: Jeff Lanzarotta <my name at gmail dot com> -Credit must go out to Bram Moolenaar and all the Vim developers for +Credit must go out to Bram Moolenaar (RIP) and all the Vim developers for making the world's best editor (IMHO). I also want to thank everyone who helped and gave me suggestions. I wouldn't want to leave anyone out so I won't list names. @@ -805,7 +809,7 @@ won't list names. =============================================================================== COPYRIGHT *bufexplorer-copyright* -Copyright (c) 2001-2022, Jeff Lanzarotta +Copyright (c) 2001-2024, Jeff Lanzarotta All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/sources_non_forked/bufexplorer/how_to_release.txt b/sources_non_forked/bufexplorer/how_to_release.txt new file mode 100644 index 00000000..f3f565d8 --- /dev/null +++ b/sources_non_forked/bufexplorer/how_to_release.txt @@ -0,0 +1,16 @@ +https://goreleaser.com/quick-start/ + +To make a release... + +1. Make changes. +2. Commit and push changes. +3. git tag -a v7.4.27 -m "Release v7.4.27." +4. git push origin v7.4.27 +5. goreleaser release --clean +6. Go to github and make the release. + +If something happens and the tag is messed up, you will need to delete the +local and remote tag and release again. To delete the tag: + +1. git tag -d v7.4.27 +2. git push --delete origin v7.4.27 diff --git a/sources_non_forked/bufexplorer/plugin/bufexplorer.vim b/sources_non_forked/bufexplorer/plugin/bufexplorer.vim index c5c04e71..f5a74613 100644 --- a/sources_non_forked/bufexplorer/plugin/bufexplorer.vim +++ b/sources_non_forked/bufexplorer/plugin/bufexplorer.vim @@ -1,5 +1,5 @@ "============================================================================ -" Copyright: Copyright (c) 2001-2023, Jeff Lanzarotta +" Copyright: Copyright (c) 2001-2024, Jeff Lanzarotta " All rights reserved. " " Redistribution and use in source and binary forms, with or @@ -36,7 +36,7 @@ " Name Of File: bufexplorer.vim " Description: Buffer Explorer Vim Plugin " Maintainer: Jeff Lanzarotta (my name at gmail dot com) -" Last Changed: Monday, 01 May 2023 +" Last Changed: Tuesday, 13 August 2024 " Version: See g:bufexplorer_version for version number. " Usage: This file should reside in the plugin directory and be " automatically sourced. @@ -74,7 +74,7 @@ endif "1}}} " Version number -let g:bufexplorer_version = "7.4.26" +let g:bufexplorer_version = "7.4.27" " Plugin Code {{{1 " Check for Vim version {{{2 @@ -770,12 +770,12 @@ function! s:BuildBufferList() " Are we to split the path and file name? if g:bufExplorerSplitOutPathName let type = (g:bufExplorerShowRelativePath) ? "relativepath" : "path" - let path = buf[type] + let path = substitute( buf[type], $HOME."\\>", "~", "" ) let pad = (g:bufExplorerShowUnlisted) ? s:allpads.shortname : s:listedpads.shortname let line .= buf.shortname." ".strpart(pad.path, s:StringWidth(buf.shortname)) else let type = (g:bufExplorerShowRelativePath) ? "relativename" : "fullname" - let path = buf[type] + let path = substitute( buf[type], $HOME."\\>", "~", "" ) let line .= path endif diff --git a/sources_non_forked/copilot.vim/.github/workflows/auto-close-pr.yml b/sources_non_forked/copilot.vim/.github/workflows/auto-close-pr.yml new file mode 100644 index 00000000..043c2a92 --- /dev/null +++ b/sources_non_forked/copilot.vim/.github/workflows/auto-close-pr.yml @@ -0,0 +1,20 @@ +name: Auto-close PR +on: + pull_request_target: + types: [opened, reopened] + +jobs: + close: + name: Run + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - run: | + gh pr close ${{ github.event.pull_request.number }} --comment \ + "At the moment we are not accepting contributions to the repository. + + Feedback for Copilot.vim can be given in the [Copilot community discussions](https://github.com/orgs/community/discussions/categories/copilot)." + env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/sources_non_forked/copilot.vim/README.md b/sources_non_forked/copilot.vim/README.md index 9f15e9a9..c6b8dae9 100644 --- a/sources_non_forked/copilot.vim/README.md +++ b/sources_non_forked/copilot.vim/README.md @@ -1,4 +1,4 @@ -# Copilot.vim +# GitHub Copilot for Vim and Neovim GitHub Copilot uses OpenAI Codex to suggest code and entire functions in real-time right from your editor. Trained on billions of lines of public @@ -48,7 +48,7 @@ Terms](https://docs.github.com/en/site-policy/github-terms/github-terms-for-addi git clone https://github.com/github/copilot.vim.git ` $HOME/AppData/Local/nvim/pack/github/start/copilot.vim -4. Start Neovim and invoke `:Copilot setup`. +4. Start Vim/Neovim and invoke `:Copilot setup`. [Node.js]: https://nodejs.org/en/download/ [Neovim]: https://github.com/neovim/neovim/releases/latest diff --git a/sources_non_forked/copilot.vim/autoload/copilot.vim b/sources_non_forked/copilot.vim/autoload/copilot.vim index 920aa72f..5016a039 100644 --- a/sources_non_forked/copilot.vim/autoload/copilot.vim +++ b/sources_non_forked/copilot.vim/autoload/copilot.vim @@ -1,11 +1,6 @@ -if exists('g:autoloaded_copilot') - finish -endif -let g:autoloaded_copilot = 1 - scriptencoding utf-8 -let s:has_nvim_ghost_text = has('nvim-0.6') && exists('*nvim_buf_get_mark') +let s:has_nvim_ghost_text = has('nvim-0.7') && exists('*nvim_buf_get_mark') let s:vim_minimum_version = '9.0.0185' let s:has_vim_ghost_text = has('patch-' . s:vim_minimum_version) && has('textprop') let s:has_ghost_text = s:has_nvim_ghost_text || s:has_vim_ghost_text @@ -39,81 +34,68 @@ function! s:EditorConfiguration() abort \ } endfunction -function! s:StatusNotification(params, ...) abort - let status = get(a:params, 'status', '') - if status ==? 'error' - let s:agent_error = a:params.message - else - unlet! s:agent_error - endif -endfunction - function! copilot#Init(...) abort - call timer_start(0, { _ -> s:Start() }) + call copilot#util#Defer({ -> exists('s:client') || s:Start() }) endfunction function! s:Running() abort - return exists('s:agent.job') || exists('s:agent.client_id') + return exists('s:client.job') || exists('s:client.client_id') endfunction function! s:Start() abort - if s:Running() + if s:Running() || exists('s:client.startup_error') return endif - let s:agent = copilot#agent#New({'methods': { - \ 'statusNotification': function('s:StatusNotification'), - \ 'PanelSolution': function('copilot#panel#Solution'), - \ 'PanelSolutionsDone': function('copilot#panel#SolutionsDone'), - \ 'copilot/openURL': function('s:OpenURL'), - \ }, - \ 'editorConfiguration' : s:EditorConfiguration()}) + let s:client = copilot#client#New({'editorConfiguration' : s:EditorConfiguration()}) endfunction function! s:Stop() abort - if exists('s:agent') - let agent = remove(s:, 'agent') - call agent.Close() + if exists('s:client') + let client = remove(s:, 'client') + call client.Close() endif endfunction -function! copilot#Agent() abort +function! copilot#Client() abort call s:Start() - return s:agent + return s:client endfunction -function! copilot#RunningAgent() abort +function! copilot#RunningClient() abort if s:Running() - return s:agent + return s:client else return v:null endif endfunction -function! s:NodeVersionWarning() abort - if exists('s:agent.node_version') && s:agent.node_version =~# '^16\.' +if has('nvim-0.7') && !has(luaeval('vim.version().api_prerelease') ? 'nvim-0.8.1' : 'nvim-0.8.0') + let s:editor_warning = 'Neovim 0.7 support is deprecated and will be dropped in a future release of copilot.vim.' +endif +if has('vim_starting') && exists('s:editor_warning') + call copilot#logger#Warn(s:editor_warning) +endif +function! s:EditorVersionWarning() abort + if exists('s:editor_warning') echohl WarningMsg - echo "Warning: Node.js 16 is approaching end of life and support will be dropped in a future release of copilot.vim." - echohl NONE - elseif exists('s:agent.node_version_warning') - echohl WarningMsg - echo 'Warning:' s:agent.node_version_warning - echohl NONE + echo 'Warning: ' . s:editor_warning + echohl None endif endfunction function! copilot#Request(method, params, ...) abort - let agent = copilot#Agent() - return call(agent.Request, [a:method, a:params] + a:000) + let client = copilot#Client() + return call(client.Request, [a:method, a:params] + a:000) endfunction function! copilot#Call(method, params, ...) abort - let agent = copilot#Agent() - return call(agent.Call, [a:method, a:params] + a:000) + let client = copilot#Client() + return call(client.Call, [a:method, a:params] + a:000) endfunction function! copilot#Notify(method, params, ...) abort - let agent = copilot#Agent() - return call(agent.Notify, [a:method, a:params] + a:000) + let client = copilot#Client() + return call(client.Notify, [a:method, a:params] + a:000) endfunction function! copilot#NvimNs() abort @@ -125,37 +107,21 @@ function! copilot#Clear() abort call timer_stop(remove(g:, '_copilot_timer')) endif if exists('b:_copilot') - call copilot#agent#Cancel(get(b:_copilot, 'first', {})) - call copilot#agent#Cancel(get(b:_copilot, 'cycling', {})) + call copilot#client#Cancel(get(b:_copilot, 'first', {})) + call copilot#client#Cancel(get(b:_copilot, 'cycling', {})) endif call s:UpdatePreview() unlet! b:_copilot return '' endfunction -function! s:Reject(bufnr) abort - try - let dict = getbufvar(a:bufnr, '_copilot') - if type(dict) == v:t_dict && !empty(get(dict, 'shown_choices', {})) - call copilot#Request('notifyRejected', {'uuids': keys(dict.shown_choices)}) - let dict.shown_choices = {} - endif - catch - call copilot#logger#Exception() - endtry -endfunction - function! copilot#Dismiss() abort - call s:Reject('%') call copilot#Clear() call s:UpdatePreview() return '' endfunction let s:filetype_defaults = { - \ 'yaml': 0, - \ 'markdown': 0, - \ 'help': 0, \ 'gitcommit': 0, \ 'gitrebase': 0, \ 'hgcommit': 0, @@ -192,26 +158,41 @@ endfunction function! copilot#Enabled() abort return get(g:, 'copilot_enabled', 1) \ && empty(s:BufferDisabled()) - \ && empty(copilot#Agent().StartupError()) endfunction +let s:inline_invoked = 1 +let s:inline_automatic = 2 + function! copilot#Complete(...) abort if exists('g:_copilot_timer') call timer_stop(remove(g:, '_copilot_timer')) endif - let params = copilot#doc#Params() - if !exists('b:_copilot.params') || b:_copilot.params !=# params - let b:_copilot = {'params': params, 'first': - \ copilot#Request('getCompletions', params)} + let target = [bufnr(''), getbufvar('', 'changedtick'), line('.'), col('.')] + if !exists('b:_copilot.target') || b:_copilot.target !=# target + if exists('b:_copilot.first') + call copilot#client#Cancel(b:_copilot.first) + endif + if exists('b:_copilot.cycling') + call copilot#client#Cancel(b:_copilot.cycling) + endif + let params = { + \ 'textDocument': {'uri': bufnr('')}, + \ 'position': copilot#util#AppendPosition(), + \ 'formattingOptions': {'insertSpaces': &expandtab ? v:true : v:false, 'tabSize': shiftwidth()}, + \ 'context': {'triggerKind': s:inline_automatic}} + let b:_copilot = { + \ 'target': target, + \ 'params': params, + \ 'first': copilot#Request('textDocument/inlineCompletion', params)} let g:_copilot_last = b:_copilot endif let completion = b:_copilot.first if !a:0 return completion.Await() else - call copilot#agent#Result(completion, a:1) + call copilot#client#Result(completion, function(a:1, [b:_copilot])) if a:0 > 1 - call copilot#agent#Error(completion, a:2) + call copilot#client#Error(completion, function(a:2, [b:_copilot])) endif endif endfunction @@ -221,37 +202,37 @@ function! s:HideDuringCompletion() abort endfunction function! s:SuggestionTextWithAdjustments() abort + let empty = ['', 0, 0, {}] try if mode() !~# '^[iR]' || (s:HideDuringCompletion() && pumvisible()) || !exists('b:_copilot.suggestions') - return ['', 0, 0, ''] + return empty endif let choice = get(b:_copilot.suggestions, b:_copilot.choice, {}) - if !has_key(choice, 'range') || choice.range.start.line != line('.') - 1 || type(choice.text) !=# v:t_string - return ['', 0, 0, ''] + if !has_key(choice, 'range') || choice.range.start.line != line('.') - 1 || type(choice.insertText) !=# v:t_string + return empty endif let line = getline('.') let offset = col('.') - 1 - let choice_text = strpart(line, 0, copilot#doc#UTF16ToByteIdx(line, choice.range.start.character)) . choice.text + let choice_text = strpart(line, 0, copilot#util#UTF16ToByteIdx(line, choice.range.start.character)) . substitute(choice.insertText, "\n*$", '', '') let typed = strpart(line, 0, offset) - let end_offset = copilot#doc#UTF16ToByteIdx(line, choice.range.end.character) + let end_offset = copilot#util#UTF16ToByteIdx(line, choice.range.end.character) if end_offset < 0 let end_offset = len(line) endif let delete = strpart(line, offset, end_offset - offset) - let uuid = get(choice, 'uuid', '') if typed =~# '^\s*$' let leading = matchstr(choice_text, '^\s\+') let unindented = strpart(choice_text, len(leading)) if strpart(typed, 0, len(leading)) == leading && unindented !=# delete - return [unindented, len(typed) - len(leading), strchars(delete), uuid] + return [unindented, len(typed) - len(leading), strchars(delete), choice] endif elseif typed ==# strpart(choice_text, 0, offset) - return [strpart(choice_text, offset), 0, strchars(delete), uuid] + return [strpart(choice_text, offset), 0, strchars(delete), choice] endif catch call copilot#logger#Exception() endtry - return ['', 0, 0, ''] + return empty endfunction @@ -271,12 +252,12 @@ function! s:GetSuggestionsCyclingCallback(context, result) abort let callbacks = remove(a:context, 'cycling_callbacks') let seen = {} for suggestion in a:context.suggestions - let seen[suggestion.text] = 1 + let seen[suggestion.insertText] = 1 endfor - for suggestion in get(a:result, 'completions', []) - if !has_key(seen, suggestion.text) + for suggestion in get(a:result, 'items', []) + if !has_key(seen, suggestion.insertText) call add(a:context.suggestions, suggestion) - let seen[suggestion.text] = 1 + let seen[suggestion.insertText] = 1 endif endfor for Callback in callbacks @@ -290,9 +271,11 @@ function! s:GetSuggestionsCycling(callback) abort elseif exists('b:_copilot.cycling') call a:callback(b:_copilot) elseif exists('b:_copilot.suggestions') + let params = deepcopy(b:_copilot.first.params) + let params.context.triggerKind = s:inline_invoked let b:_copilot.cycling_callbacks = [a:callback] - let b:_copilot.cycling = copilot#Request('getCompletionsCycling', - \ b:_copilot.first.params, + let b:_copilot.cycling = copilot#Request('textDocument/inlineCompletion', + \ params, \ function('s:GetSuggestionsCyclingCallback', [b:_copilot]), \ function('s:GetSuggestionsCyclingCallback', [b:_copilot]), \ ) @@ -310,10 +293,10 @@ function! copilot#Previous() abort endfunction function! copilot#GetDisplayedSuggestion() abort - let [text, outdent, delete, uuid] = s:SuggestionTextWithAdjustments() + let [text, outdent, delete, item] = s:SuggestionTextWithAdjustments() return { - \ 'uuid': uuid, + \ 'item': item, \ 'text': text, \ 'outdentSize': outdent, \ 'deleteSize': delete} @@ -330,8 +313,8 @@ endfunction function! s:UpdatePreview() abort try - let [text, outdent, delete, uuid] = s:SuggestionTextWithAdjustments() - let text = split(text, "\n", 1) + let [text, outdent, delete, item] = s:SuggestionTextWithAdjustments() + let text = split(text, "\r\n\\=\\|\n", 1) if empty(text[-1]) call remove(text, -1) endif @@ -348,7 +331,7 @@ function! s:UpdatePreview() abort call s:ClearPreview() if s:has_nvim_ghost_text let data = {'id': 1} - let data.virt_text_win_col = virtcol('.') - 1 + let data.virt_text_pos = 'overlay' let append = strpart(getline('.'), col('.') - 1 + delete) let data.virt_text = [[text[0] . append . repeat(' ', delete - len(text[0])), s:hlgroup]] if len(text) > 1 @@ -361,8 +344,27 @@ function! s:UpdatePreview() abort endif let data.hl_mode = 'combine' call nvim_buf_set_extmark(0, copilot#NvimNs(), line('.')-1, col('.')-1, data) - else - call prop_add(line('.'), col('.'), {'type': s:hlgroup, 'text': text[0]}) + elseif s:has_vim_ghost_text + let new_suffix = text[0] + let current_suffix = getline('.')[col('.') - 1 :] + let inset = '' + while delete > 0 && !empty(new_suffix) + let last_char = matchstr(new_suffix, '.$') + let new_suffix = matchstr(new_suffix, '^.\{-\}\ze.$') + if last_char ==# matchstr(current_suffix, '.$') + if !empty(inset) + call prop_add(line('.'), col('.') + len(current_suffix), {'type': s:hlgroup, 'text': inset}) + let inset = '' + endif + let current_suffix = matchstr(current_suffix, '^.\{-\}\ze.$') + let delete -= 1 + else + let inset = last_char . inset + endif + endwhile + if !empty(new_suffix . inset) + call prop_add(line('.'), col('.'), {'type': s:hlgroup, 'text': new_suffix . inset}) + endif for line in text[1:] call prop_add(line('.'), 0, {'type': s:hlgroup, 'text_align': 'below', 'text': line}) endfor @@ -370,28 +372,35 @@ function! s:UpdatePreview() abort call prop_add(line('.'), col('$'), {'type': s:annot_hlgroup, 'text': ' ' . annot}) endif endif - if !has_key(b:_copilot.shown_choices, uuid) - let b:_copilot.shown_choices[uuid] = v:true - call copilot#Request('notifyShown', {'uuid': uuid}) - endif + call copilot#Notify('textDocument/didShowCompletion', {'item': item}) catch return copilot#logger#Exception() endtry endfunction -function! s:HandleTriggerResult(result) abort - if !exists('b:_copilot') - return +function! s:HandleTriggerResult(state, result) abort + let a:state.suggestions = type(a:result) == type([]) ? a:result : get(empty(a:result) ? {} : a:result, 'items', []) + let a:state.choice = 0 + if get(b:, '_copilot') is# a:state + call s:UpdatePreview() + endif +endfunction + +function! s:HandleTriggerError(state, result) abort + let a:state.suggestions = [] + let a:state.choice = 0 + let a:state.error = a:result + if get(b:, '_copilot') is# a:state + call s:UpdatePreview() endif - let b:_copilot.suggestions = get(a:result, 'completions', []) - let b:_copilot.choice = 0 - let b:_copilot.shown_choices = {} - call s:UpdatePreview() endfunction function! copilot#Suggest() abort + if !s:Running() + return '' + endif try - call copilot#Complete(function('s:HandleTriggerResult'), function('s:HandleTriggerResult')) + call copilot#Complete(function('s:HandleTriggerResult'), function('s:HandleTriggerError')) catch call copilot#logger#Exception() endtry @@ -400,30 +409,52 @@ endfunction function! s:Trigger(bufnr, timer) abort let timer = get(g:, '_copilot_timer', -1) - unlet! g:_copilot_timer if a:bufnr !=# bufnr('') || a:timer isnot# timer || mode() !=# 'i' return endif + unlet! g:_copilot_timer return copilot#Suggest() endfunction -function! copilot#IsMapped() abort - return get(g:, 'copilot_assume_mapped') || - \ hasmapto('copilot#Accept(', 'i') -endfunction - -function! copilot#Schedule(...) abort - if !s:has_ghost_text || !copilot#Enabled() || !copilot#IsMapped() +function! copilot#Schedule() abort + if !s:has_ghost_text || !s:Running() || !copilot#Enabled() call copilot#Clear() return endif call s:UpdatePreview() - let delay = a:0 ? a:1 : get(g:, 'copilot_idle_delay', 15) + let delay = get(g:, 'copilot_idle_delay', 45) + call timer_stop(get(g:, '_copilot_timer', -1)) let g:_copilot_timer = timer_start(delay, function('s:Trigger', [bufnr('')])) endfunction -function! copilot#OnInsertLeave() abort - return copilot#Clear() +function! s:Attach(bufnr, ...) abort + try + return copilot#Client().Attach(a:bufnr) + catch + call copilot#logger#Exception() + endtry +endfunction + +function! copilot#OnFileType() abort + if empty(s:BufferDisabled()) && &l:modifiable && &l:buflisted + call copilot#util#Defer(function('s:Attach'), bufnr('')) + endif +endfunction + +function! s:Focus(bufnr, ...) abort + if s:Running() && copilot#Client().IsAttached(a:bufnr) + call copilot#Client().Notify('textDocument/didFocus', {'textDocument': {'uri': copilot#Client().Attach(a:bufnr).uri}}) + endif +endfunction + +function! copilot#OnBufEnter() abort + let bufnr = bufnr('') + call copilot#util#Defer(function('s:Focus'), bufnr) +endfunction + +function! copilot#OnInsertLeavePre() abort + call copilot#Clear() + call s:ClearPreview() endfunction function! copilot#OnInsertEnter() abort @@ -443,7 +474,6 @@ function! copilot#OnCursorMovedI() abort endfunction function! copilot#OnBufUnload() abort - call s:Reject(+expand('<abuf>')) endfunction function! copilot#OnVimLeavePre() abort @@ -468,11 +498,19 @@ function! copilot#Accept(...) abort if empty(text) let text = s.text endif - call copilot#Request('notifyAccepted', {'uuid': s.uuid, 'acceptedLength': copilot#doc#UTF16Width(text)}) + if text ==# s.text && has_key(s.item, 'command') + call copilot#Request('workspace/executeCommand', s.item.command) + else + let line_text = strpart(getline('.'), 0, col('.') - 1) . text + call copilot#Notify('textDocument/didPartiallyAcceptCompletion', { + \ 'item': s.item, + \ 'acceptedLength': copilot#util#UTF16Width(line_text) - s.item.range.start.character}) + endif call s:ClearPreview() let s:suggestion_text = text + let recall = text =~# "\n" ? "\<C-R>\<C-O>=" : "\<C-R>\<C-R>=" return repeat("\<Left>\<Del>", s.outdentSize) . repeat("\<Del>", s.deleteSize) . - \ "\<C-R>\<C-O>=copilot#TextQueuedForInsertion()\<CR>" . (a:0 > 1 ? '' : "\<End>") + \ recall . "copilot#TextQueuedForInsertion()\<CR>" . (a:0 > 1 ? '' : "\<End>") endif let default = get(g:, 'copilot_tab_fallback', pumvisible() ? "\<C-N>" : "\t") if !a:0 @@ -525,21 +563,6 @@ function! copilot#Browser() abort endif endfunction -function! s:OpenURL(params) abort - echo a:params.target - let browser = copilot#Browser() - if empty(browser) - return v:false - endif - let status = {} - call copilot#job#Stream(browser + [a:params.target], v:null, v:null, function('s:BrowserCallback', [status])) - let time = reltime() - while empty(status) && reltimefloat(reltime(time)) < 1 - sleep 10m - endwhile - return get(status, 'code') ? v:false : v:true -endfunction - let s:commands = {} function! s:EnabledStatusMessage() abort @@ -550,8 +573,6 @@ function! s:EnabledStatusMessage() abort else return "Vim " . s:vim_minimum_version . " required to support ghost text" endif - elseif !copilot#IsMapped() - return '<Tab> map has been disabled or is claimed by another plugin' elseif !get(g:, 'copilot_enabled', 1) return 'Disabled globally by :Copilot disable' elseif buf_disabled is# 5 @@ -572,7 +593,7 @@ function! s:EnabledStatusMessage() abort endfunction function! s:VerifySetup() abort - let error = copilot#Agent().StartupError() + let error = copilot#Client().StartupError() if !empty(error) echo 'Copilot: ' . error return @@ -589,6 +610,12 @@ function! s:VerifySetup() abort echo 'Copilot: Telemetry terms not accepted. Invoke :Copilot setup' return endif + + if status.status ==# 'NotAuthorized' + echo "Copilot: You don't have access to GitHub Copilot. Sign up by visiting https://github.com/settings/copilot" + return + endif + return 1 endfunction @@ -597,31 +624,22 @@ function! s:commands.status(opts) abort return endif + if exists('s:client.status.status') && s:client.status.status =~# 'Warning\|Error' + echo 'Copilot: ' . s:client.status.status + if !empty(get(s:client.status, 'message', '')) + echon ': ' . s:client.status.message + endif + return + endif + let status = s:EnabledStatusMessage() if !empty(status) echo 'Copilot: ' . status return endif - let startup_error = copilot#Agent().StartupError() - if !empty(startup_error) - echo 'Copilot: ' . startup_error - return - endif - - if exists('s:agent_error') - echo 'Copilot: ' . s:agent_error - return - endif - - let status = copilot#Call('checkStatus', {}) - if status.status ==# 'NotAuthorized' - echo 'Copilot: Not authorized' - return - endif - - echo 'Copilot: Enabled and online' - call s:NodeVersionWarning() + echo 'Copilot: Ready' + call s:EditorVersionWarning() endfunction function! s:commands.signout(opts) abort @@ -635,7 +653,7 @@ function! s:commands.signout(opts) abort endfunction function! s:commands.setup(opts) abort - let startup_error = copilot#Agent().StartupError() + let startup_error = copilot#Client().StartupError() if !empty(startup_error) echo 'Copilot: ' . startup_error return @@ -645,7 +663,7 @@ function! s:commands.setup(opts) abort let status = copilot#Call('checkStatus', {}) if has_key(status, 'user') - let data = {} + let data = {'status': 'AlreadySignedIn', 'user': status.user} else let data = copilot#Call('signInInitiate', {}) endif @@ -653,23 +671,25 @@ function! s:commands.setup(opts) abort if has_key(data, 'verificationUri') let uri = data.verificationUri if has('clipboard') - let @+ = data.userCode - let @* = data.userCode + try + let @+ = data.userCode + catch + endtry + try + let @* = data.userCode + catch + endtry endif - call s:Echo("First copy your one-time code: " . data.userCode) + let codemsg = "First copy your one-time code: " . data.userCode . "\n" try if len(&mouse) let mouse = &mouse set mouse= endif if get(a:opts, 'bang') - call s:Echo("In your browser, visit " . uri) + call s:Echo(codemsg . "In your browser, visit " . uri) elseif len(browser) - call s:Echo("Press ENTER to open GitHub in your browser") - let c = getchar() - while c isnot# 13 && c isnot# 10 && c isnot# 0 - let c = getchar() - endwhile + call input(codemsg . "Press ENTER to open GitHub in your browser\n") let status = {} call copilot#job#Stream(browser + [uri], v:null, v:null, function('s:BrowserCallback', [status])) let time = reltime() @@ -682,9 +702,9 @@ function! s:commands.setup(opts) abort call s:Echo("Opened " . uri) endif else - call s:Echo("Could not find browser. Visit " . uri) + call s:Echo(codemsg . "Could not find browser. Visit " . uri) endif - call s:Echo("Waiting (could take up to 5 seconds)") + call s:Echo("Waiting (could take up to 10 seconds)") let request = copilot#Request('signInConfirm', {'userCode': data.userCode}).Wait() finally if exists('mouse') @@ -696,6 +716,8 @@ function! s:commands.setup(opts) abort else let status = request.result endif + elseif get(data, 'status', '') isnot# 'AlreadySignedIn' + return 'echoerr ' . string('Copilot: Something went wrong') endif let user = get(status, 'user', '<unknown>') @@ -704,22 +726,46 @@ function! s:commands.setup(opts) abort endfunction let s:commands.auth = s:commands.setup +let s:commands.signin = s:commands.setup function! s:commands.help(opts) abort return a:opts.mods . ' help ' . (len(a:opts.arg) ? ':Copilot_' . a:opts.arg : 'copilot') endfunction function! s:commands.version(opts) abort - let info = copilot#agent#EditorInfo() - echo 'copilot.vim ' .info.editorPluginInfo.version - echo info.editorInfo.name . ' ' . info.editorInfo.version - if exists('s:agent.node_version') - echo 'dist/agent.js ' . s:agent.Call('getVersion', {}).version - echo 'Node.js ' . s:agent.node_version - call s:NodeVersionWarning() + echo 'copilot.vim ' .copilot#client#EditorPluginInfo().version + let editorInfo = copilot#client#EditorInfo() + echo editorInfo.name . ' ' . editorInfo.version + if s:Running() + let versions = s:client.Request('getVersion', {}) + if exists('s:client.serverInfo.version') + echo s:client.serverInfo.name . ' ' . s:client.serverInfo.version + else + echo 'GitHub Copilot Language Server ' . versions.Await().version + endif + if exists('s:client.node_version') + echo 'Node.js ' . s:client.node_version + else + echo 'Node.js ' . substitute(get(versions.Await(), 'runtimeVersion', '?'), '^node/', '', 'g') + endif else - echo 'dist/agent.js not running' + echo 'Not running' + if exists('s:client.node_version') + echo 'Node.js ' . s:client.node_version + endif endif + if has('win32') + echo 'Windows' + elseif has('macunix') + echo 'macOS' + elseif !has('unix') + echo 'Unknown OS' + elseif isdirectory('/sys/kernel') + echo 'Linux' + else + echo 'UNIX' + endif + call s:EditorVersionWarning() endfunction function! s:UpdateEditorConfiguration() abort @@ -743,11 +789,8 @@ endfunction function! s:commands.restart(opts) abort call s:Stop() - let err = copilot#Agent().StartupError() - if !empty(err) - return 'echoerr ' . string('Copilot: ' . err) - endif - echo 'Copilot: Restarting agent.' + echo 'Copilot: Restarting language server' + call s:Start() endfunction function! s:commands.disable(opts) abort @@ -766,6 +809,10 @@ function! s:commands.panel(opts) abort endif endfunction +function! s:commands.log(opts) abort + return a:opts.mods . ' split +$ copilot:///log' +endfunction + function! copilot#CommandComplete(arg, lead, pos) abort let args = matchstr(strpart(a:lead, 0, a:pos), 'C\%[opilot][! ] *\zs.*') if args !~# ' ' @@ -779,33 +826,28 @@ endfunction function! copilot#Command(line1, line2, range, bang, mods, arg) abort let cmd = matchstr(a:arg, '^\%(\\.\|\S\)\+') let arg = matchstr(a:arg, '\s\zs\S.*') - if cmd ==# 'log' - return a:mods . ' split +$ ' . fnameescape(copilot#logger#File()) - endif if !empty(cmd) && !has_key(s:commands, tr(cmd, '-', '_')) return 'echoerr ' . string('Copilot: unknown command ' . string(cmd)) endif try - let err = copilot#Agent().StartupError() - if !empty(err) - return 'echo ' . string('Copilot: ' . err) - endif - try - let opts = copilot#Call('checkStatus', {'options': {'localChecksOnly': v:true}}) - catch - call copilot#logger#Exception() - let opts = {'status': 'VimException'} - endtry if empty(cmd) - if opts.status ==# 'VimException' - return a:mods . ' split +$ ' . fnameescape(copilot#logger#File()) - elseif opts.status !=# 'OK' && opts.status !=# 'MaybeOK' - let cmd = 'setup' + if !s:Running() + let cmd = 'restart' else - let cmd = 'panel' + try + let opts = copilot#Call('checkStatus', {'options': {'localChecksOnly': v:true}}) + if opts.status !=# 'OK' && opts.status !=# 'MaybeOK' + let cmd = 'setup' + else + let cmd = 'panel' + endif + catch + call copilot#logger#Exception() + let cmd = 'log' + endtry endif endif - call extend(opts, {'line1': a:line1, 'line2': a:line2, 'range': a:range, 'bang': a:bang, 'mods': a:mods, 'arg': arg}) + let opts = {'line1': a:line1, 'line2': a:line2, 'range': a:range, 'bang': a:bang, 'mods': a:mods, 'arg': arg} let retval = s:commands[tr(cmd, '-', '_')](opts) if type(retval) == v:t_string return retval diff --git a/sources_non_forked/copilot.vim/autoload/copilot/agent.vim b/sources_non_forked/copilot.vim/autoload/copilot/agent.vim deleted file mode 100644 index b53a8478..00000000 --- a/sources_non_forked/copilot.vim/autoload/copilot/agent.vim +++ /dev/null @@ -1,603 +0,0 @@ -if exists('g:autoloaded_copilot_agent') - finish -endif -let g:autoloaded_copilot_agent = 1 - -scriptencoding utf-8 - -let s:plugin_version = '1.13.0' - -let s:error_exit = -1 - -let s:root = expand('<sfile>:h:h:h') - -if !exists('s:instances') - let s:instances = {} -endif - -" allow sourcing this file to reload the Lua file too -if has('nvim') - lua package.loaded._copilot = nil -endif - -let s:jobstop = function(exists('*jobstop') ? 'jobstop' : 'job_stop') -function! s:Kill(agent, ...) abort - if has_key(a:agent, 'job') - call s:jobstop(a:agent.job) - endif -endfunction - -function! s:AgentClose() dict abort - if !has_key(self, 'job') - return - endif - if exists('*chanclose') - call chanclose(self.job, 'stdin') - else - call ch_close_in(self.job) - endif - call copilot#logger#Info('agent stopped') - call timer_start(2000, function('s:Kill', [self])) -endfunction - -function! s:LogSend(request, line) abort - return '--> ' . a:line -endfunction - -function! s:RejectRequest(request, error) abort - if a:request.status ==# 'canceled' - return - endif - let a:request.waiting = {} - call remove(a:request, 'resolve') - let reject = remove(a:request, 'reject') - let a:request.status = 'error' - let a:request.error = a:error - for Cb in reject - let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'error', Cb]))] = 1 - endfor -endfunction - -function! s:Send(agent, request) abort - try - call ch_sendexpr(a:agent.job, a:request) - return v:true - catch /^Vim\%((\a\+)\)\=:E631:/ - return v:false - endtry -endfunction - -function! s:AgentNotify(method, params) dict abort - return s:Send(self, {'method': a:method, 'params': a:params}) -endfunction - -function! s:RequestWait() dict abort - while self.status ==# 'running' - sleep 1m - endwhile - while !empty(get(self, 'waiting', {})) - sleep 1m - endwhile - return self -endfunction - -function! s:RequestAwait() dict abort - call self.Wait() - if has_key(self, 'result') - return self.result - endif - throw 'copilot#agent(' . self.error.code . '): ' . self.error.message -endfunction - -function! s:RequestAgent() dict abort - return get(s:instances, self.agent_id, v:null) -endfunction - -if !exists('s:id') - let s:id = 0 -endif - -function! s:SetUpRequest(agent, id, method, params, ...) abort - let request = { - \ 'agent_id': a:agent.id, - \ 'id': a:id, - \ 'method': a:method, - \ 'params': a:params, - \ 'Agent': function('s:RequestAgent'), - \ 'Wait': function('s:RequestWait'), - \ 'Await': function('s:RequestAwait'), - \ 'Cancel': function('s:RequestCancel'), - \ 'resolve': [], - \ 'reject': [], - \ 'status': 'running'} - let a:agent.requests[a:id] = request - let args = a:000[2:-1] - if len(args) - if !empty(a:1) - call add(request.resolve, { v -> call(a:1, [v] + args)}) - endif - if !empty(a:2) - call add(request.reject, { v -> call(a:2, [v] + args)}) - endif - return request - endif - if a:0 && !empty(a:1) - call add(request.resolve, a:1) - endif - if a:0 > 1 && !empty(a:2) - call add(request.reject, a:2) - endif - return request -endfunction - -function! s:UrlEncode(str) abort - return substitute(iconv(a:str, 'latin1', 'utf-8'),'[^A-Za-z0-9._~!$&''()*+,;=:@/-]','\="%".printf("%02X",char2nr(submatch(0)))','g') -endfunction - -let s:slash = exists('+shellslash') ? '\' : '/' -function! s:UriFromBufnr(bufnr) abort - let absolute = tr(bufname(a:bufnr), s:slash, '/') - if absolute !~# '^\a\+:\|^/\|^$' && getbufvar(a:bufnr, 'buftype') =~# '^\%(nowrite\)\=$' - let absolute = substitute(tr(getcwd(), s:slash, '/'), '/\=$', '/', '') . absolute - endif - if has('win32') && absolute =~# '^\a://\@!' - return 'file:///' . strpart(absolute, 0, 2) . s:UrlEncode(strpart(absolute, 2)) - elseif absolute =~# '^/' - return 'file://' . s:UrlEncode(absolute) - elseif absolute =~# '^\a[[:alnum:].+-]*:\|^$' - return absolute - else - return '' - endif -endfunction - -function! s:BufferText(bufnr) abort - return join(getbufline(a:bufnr, 1, '$'), "\n") . "\n" -endfunction - -function! s:LogMessage(params) abort - call copilot#logger#Raw(get(a:params, 'level', 3), get(a:params, 'message', '')) -endfunction - -function! s:ShowMessageRequest(params) abort - let choice = inputlist([a:params.message . "\n\nRequest Actions:"] + - \ map(copy(get(a:params, 'actions', [])), { i, v -> (i + 1) . '. ' . v.title})) - return choice > 0 ? get(a:params.actions, choice - 1, v:null) : v:null -endfunction - -function! s:SendRequest(agent, request) abort - if empty(s:Send(a:agent, a:request)) && has_key(a:agent.requests, a:request.id) - call s:RejectRequest(remove(a:agent.requests, a:request.id), {'code': 257, 'message': 'Write failed'}) - endif -endfunction - -function! s:AgentRequest(method, params, ...) dict abort - let s:id += 1 - let request = {'method': a:method, 'params': deepcopy(a:params), 'id': s:id} - for doc in filter([get(request.params, 'doc', {}), get(request.params, 'textDocument',{})], 'type(get(v:val, "uri", "")) == v:t_number') - let bufnr = doc.uri - let doc.uri = s:UriFromBufnr(doc.uri) - let uri = doc.uri - let languageId = copilot#doc#LanguageForFileType(getbufvar(bufnr, '&filetype')) - let doc_version = getbufvar(bufnr, 'changedtick') - if has_key(self.open_buffers, bufnr) && ( - \ self.open_buffers[bufnr].uri !=# doc.uri || - \ self.open_buffers[bufnr].languageId !=# languageId) - call remove(self.open_buffers, bufnr) - sleep 1m - endif - if !has_key(self.open_buffers, bufnr) - let td_item = { - \ 'uri': doc.uri, - \ 'version': doc_version, - \ 'languageId': languageId, - \ 'text': s:BufferText(bufnr)} - call self.Notify('textDocument/didOpen', {'textDocument': td_item}) - let self.open_buffers[bufnr] = { - \ 'uri': doc.uri, - \ 'version': doc_version, - \ 'languageId': languageId} - else - let vtd_id = { - \ 'uri': doc.uri, - \ 'version': doc_version} - call self.Notify('textDocument/didChange', { - \ 'textDocument': vtd_id, - \ 'contentChanges': [{'text': s:BufferText(bufnr)}]}) - let self.open_buffers[bufnr].version = doc_version - endif - let doc.version = doc_version - endfor - call timer_start(0, { _ -> s:SendRequest(self, request) }) - return call('s:SetUpRequest', [self, s:id, a:method, a:params] + a:000) -endfunction - -function! s:AgentCall(method, params, ...) dict abort - let request = call(self.Request, [a:method, a:params] + a:000) - if a:0 - return request - endif - return request.Await() -endfunction - -function! s:AgentCancel(request) dict abort - if has_key(self.requests, get(a:request, 'id', '')) - call remove(self.requests, a:request.id) - call self.Notify('$/cancelRequest', {'id': a:request.id}) - endif - if get(a:request, 'status', '') ==# 'running' - let a:request.status = 'canceled' - endif -endfunction - -function! s:RequestCancel() dict abort - let agent = self.Agent() - if !empty(agent) - call agent.Cancel(self) - elseif get(self, 'status', '') ==# 'running' - let self.status = 'canceled' - endif - return self -endfunction - -function! s:DispatchMessage(agent, handler, id, params, ...) abort - try - let response = {'result': call(a:handler, [a:params])} - if response.result is# 0 - let response.result = v:null - endif - catch - call copilot#logger#Exception() - let response = {'error': {'code': -32000, 'message': v:exception}} - endtry - if !empty(a:id) - call s:Send(a:agent, extend({'id': a:id}, response)) - endif - return response -endfunction - -function! s:OnMessage(agent, body, ...) abort - if !has_key(a:body, 'method') - return s:OnResponse(a:agent, a:body) - endif - let request = a:body - let id = get(request, 'id', v:null) - let params = get(request, 'params', v:null) - if has_key(a:agent.methods, request.method) - return s:DispatchMessage(a:agent, a:agent.methods[request.method], id, params) - elseif !empty(id) - call s:Send(a:agent, {"id": id, "error": {"code": -32700, "message": "Method not found: " . request.method}}) - endif -endfunction - -function! s:OnResponse(agent, response, ...) abort - let response = a:response - let id = get(a:response, 'id', v:null) - if !has_key(a:agent.requests, id) - return - endif - let request = remove(a:agent.requests, id) - if request.status ==# 'canceled' - return - endif - let request.waiting = {} - let resolve = remove(request, 'resolve') - let reject = remove(request, 'reject') - if has_key(response, 'result') - let request.status = 'success' - let request.result = response.result - for Cb in resolve - let request.waiting[timer_start(0, function('s:Callback', [request, 'result', Cb]))] = 1 - endfor - else - let request.status = 'error' - let request.error = response.error - for Cb in reject - let request.waiting[timer_start(0, function('s:Callback', [request, 'error', Cb]))] = 1 - endfor - endif -endfunction - -function! s:OnErr(agent, line, ...) abort - call copilot#logger#Debug('<-! ' . a:line) -endfunction - -function! s:OnExit(agent, code, ...) abort - let a:agent.exit_status = a:code - if has_key(a:agent, 'job') - call remove(a:agent, 'job') - endif - if has_key(a:agent, 'client_id') - call remove(a:agent, 'client_id') - endif - let code = a:code < 0 || a:code > 255 ? 256 : a:code - for id in sort(keys(a:agent.requests), { a, b -> +a > +b }) - call s:RejectRequest(remove(a:agent.requests, id), {'code': code, 'message': 'Agent exited', 'data': {'status': a:code}}) - endfor - call timer_start(0, { _ -> get(s:instances, a:agent.id) is# a:agent ? remove(s:instances, a:agent.id) : {} }) - call copilot#logger#Info('agent exited with status ' . a:code) -endfunction - -function! copilot#agent#LspInit(agent_id, initialize_result) abort - if !has_key(s:instances, a:agent_id) - return - endif - let instance = s:instances[a:agent_id] - call timer_start(0, { _ -> s:GetCapabilitiesResult(a:initialize_result, instance)}) -endfunction - -function! copilot#agent#LspExit(agent_id, code, signal) abort - if !has_key(s:instances, a:agent_id) - return - endif - let instance = remove(s:instances, a:agent_id) - call s:OnExit(instance, a:code) -endfunction - -function! copilot#agent#LspResponse(agent_id, opts, ...) abort - if !has_key(s:instances, a:agent_id) - return - endif - call s:OnResponse(s:instances[a:agent_id], a:opts) -endfunction - -function! s:LspRequest(method, params, ...) dict abort - let id = v:lua.require'_copilot'.lsp_request(self.id, a:method, a:params) - if id isnot# v:null - return call('s:SetUpRequest', [self, id, a:method, a:params] + a:000) - endif - if has_key(self, 'client_id') - call copilot#agent#LspExit(self.client_id, -1, -1) - endif - throw 'copilot#agent: LSP client not available' -endfunction - -function! s:LspClose() dict abort - if !has_key(self, 'client_id') - return - endif - return luaeval('vim.lsp.get_client_by_id(_A).stop()', self.client_id) -endfunction - -function! s:LspNotify(method, params) dict abort - return v:lua.require'_copilot'.rpc_notify(self.id, a:method, a:params) -endfunction - -function! copilot#agent#LspHandle(agent_id, request) abort - if !has_key(s:instances, a:agent_id) - return - endif - return s:OnMessage(s:instances[a:agent_id], a:request) -endfunction - -function! s:GetNodeVersion(command) abort - let out = [] - let err = [] - let status = copilot#job#Stream(a:command + ['--version'], function('add', [out]), function('add', [err])) - let string = matchstr(join(out, ''), '^v\zs\d\+\.[^[:space:]]*') - if status != 0 - let string = '' - endif - let major = str2nr(string) - let minor = str2nr(matchstr(string, '\.\zs\d\+')) - return {'status': status, 'string': string, 'major': major, 'minor': minor} -endfunction - -function! s:Command() abort - if !has('nvim-0.6') && v:version < 900 - return [v:null, '', 'Vim version too old'] - endif - let node = get(g:, 'copilot_node_command', '') - if empty(node) - let node = ['node'] - elseif type(node) == type('') - let node = [expand(node)] - endif - if !executable(get(node, 0, '')) - if get(node, 0, '') ==# 'node' - return [v:null, '', 'Node.js not found in PATH'] - else - return [v:null, '', 'Node.js executable `' . get(node, 0, '') . "' not found"] - endif - endif - let node_version = s:GetNodeVersion(node) - let warning = '' - if !get(g:, 'copilot_ignore_node_version') && node_version.major < 18 && get(node, 0, '') !=# 'node' && executable('node') - let node_version_from_path = s:GetNodeVersion(['node']) - if node_version_from_path.major >= 18 - let warning = 'Ignoring g:copilot_node_command: Node.js ' . node_version.string . ' is end-of-life' - let node = ['node'] - let node_version = node_version_from_path - endif - endif - if node_version.status != 0 - return [v:null, '', 'Node.js exited with status ' . node_version.status] - endif - if !get(g:, 'copilot_ignore_node_version') - if node_version.major == 0 - return [v:null, node_version.string, 'Could not determine Node.js version'] - elseif node_version.major < 16 || node_version.major == 16 && node_version.minor < 14 || node_version.major == 17 && node_version.minor < 3 - " 16.14+ and 17.3+ still work for now, but are end-of-life - return [v:null, node_version.string, 'Node.js version 18.x or newer required but found ' . node_version.string] - endif - endif - let agent = get(g:, 'copilot_agent_command', '') - if empty(agent) || !filereadable(agent) - let agent = s:root . '/dist/agent.js' - if !filereadable(agent) - return [v:null, node_version.string, 'Could not find dist/agent.js (bad install?)'] - endif - endif - return [node + [agent, '--stdio'], node_version.string, warning] -endfunction - -function! s:UrlDecode(str) abort - return substitute(a:str, '%\(\x\x\)', '\=iconv(nr2char("0x".submatch(1)), "utf-8", "latin1")', 'g') -endfunction - -function! copilot#agent#EditorInfo() abort - if !exists('s:editor_version') - if has('nvim') - let s:editor_version = matchstr(execute('version'), 'NVIM v\zs[^[:space:]]\+') - else - let s:editor_version = (v:version / 100) . '.' . (v:version % 100) . (exists('v:versionlong') ? printf('.%04d', v:versionlong % 1000) : '') - endif - endif - let info = { - \ 'editorInfo': {'name': has('nvim') ? 'Neovim': 'Vim', 'version': s:editor_version}, - \ 'editorPluginInfo': {'name': 'copilot.vim', 'version': s:plugin_version}} - if type(get(g:, 'copilot_proxy')) == v:t_string - let proxy = g:copilot_proxy - else - let proxy = '' - endif - let match = matchlist(proxy, '\c^\%([^:]\+://\)\=\%(\([^/#]\+@\)\)\=\%(\([^/:#]\+\)\|\[\([[:xdigit:]:]\+\)\]\)\%(:\(\d\+\)\)\=\%(/\|$\|?strict_\=ssl=\(.*\)\)') - if !empty(match) - let info.networkProxy = {'host': match[2] . match[3], 'port': empty(match[4]) ? 80 : +match[4]} - if match[5] =~? '^[0f]' - let info.networkProxy.rejectUnauthorized = v:false - elseif match[5] =~? '^[1t]' - let info.networkProxy.rejectUnauthorized = v:true - elseif exists('g:copilot_proxy_strict_ssl') - let info.networkProxy.rejectUnauthorized = empty(g:copilot_proxy_strict_ssl) ? v:false : v:true - endif - if !empty(match[1]) - let info.networkProxy.username = s:UrlDecode(matchstr(match[1], '^[^:@]*')) - let info.networkProxy.password = s:UrlDecode(matchstr(match[1], ':\zs[^@]*')) - endif - endif - return info -endfunction - -function! s:GetCapabilitiesResult(result, agent) abort - let a:agent.capabilities = get(a:result, 'capabilities', {}) - let info = copilot#agent#EditorInfo() - call a:agent.Request('setEditorInfo', extend({'editorConfiguration': a:agent.editorConfiguration}, info)) -endfunction - -function! s:GetCapabilitiesError(error, agent) abort - if a:error.code == s:error_exit - let a:agent.startup_error = 'Agent exited with status ' . a:error.data.status - else - let a:agent.startup_error = 'Unexpected error ' . a:error.code . ' calling agent: ' . a:error.message - call a:agent.Close() - endif -endfunction - -function! s:AgentStartupError() dict abort - while (has_key(self, 'job') || has_key(self, 'client_id')) && !has_key(self, 'startup_error') && !has_key(self, 'capabilities') - sleep 10m - endwhile - if has_key(self, 'capabilities') - return '' - else - return get(self, 'startup_error', 'Something unexpected went wrong spawning the agent') - endif -endfunction - -function! copilot#agent#New(...) abort - let opts = a:0 ? a:1 : {} - let instance = {'requests': {}, - \ 'editorConfiguration': get(opts, 'editorConfiguration', {}), - \ 'Close': function('s:AgentClose'), - \ 'Notify': function('s:AgentNotify'), - \ 'Request': function('s:AgentRequest'), - \ 'Call': function('s:AgentCall'), - \ 'Cancel': function('s:AgentCancel'), - \ 'StartupError': function('s:AgentStartupError'), - \ } - let instance.methods = extend({ - \ 'LogMessage': function('s:LogMessage'), - \ 'window/logMessage': function('s:LogMessage'), - \ }, get(opts, 'methods', {})) - let [command, node_version, command_error] = s:Command() - if len(command_error) - if empty(command) - let instance.id = -1 - let instance.startup_error = command_error - return instance - else - let instance.node_version_warning = command_error - endif - endif - let instance.node_version = node_version - if has('nvim') - call extend(instance, { - \ 'Close': function('s:LspClose'), - \ 'Notify': function('s:LspNotify'), - \ 'Request': function('s:LspRequest')}) - let instance.client_id = v:lua.require'_copilot'.lsp_start_client(command, keys(instance.methods)) - let instance.id = instance.client_id - else - let state = {'headers': {}, 'mode': 'headers', 'buffer': ''} - let instance.open_buffers = {} - let instance.methods = extend({'window/showMessageRequest': function('s:ShowMessageRequest')}, instance.methods) - let instance.job = job_start(command, { - \ 'cwd': copilot#job#Cwd(), - \ 'in_mode': 'lsp', - \ 'out_mode': 'lsp', - \ 'out_cb': { j, d -> timer_start(0, function('s:OnMessage', [instance, d])) }, - \ 'err_cb': { j, d -> timer_start(0, function('s:OnErr', [instance, d])) }, - \ 'exit_cb': { j, d -> timer_start(0, function('s:OnExit', [instance, d])) }, - \ }) - let instance.id = exists('*jobpid') ? jobpid(instance.job) : job_info(instance.job).process - let capabilities = {'workspace': {'workspaceFolders': v:true}, 'copilot': {}} - for name in keys(instance.methods) - if name =~# '^copilot/' - let capabilities.copilot[matchstr(name, '/\zs.*')] = v:true - endif - endfor - let request = instance.Request('initialize', {'capabilities': capabilities}, function('s:GetCapabilitiesResult'), function('s:GetCapabilitiesError'), instance) - endif - let s:instances[instance.id] = instance - return instance -endfunction - -function! copilot#agent#Cancel(request) abort - if type(a:request) == type({}) && has_key(a:request, 'Cancel') - call a:request.Cancel() - endif -endfunction - -function! s:Callback(request, type, callback, timer) abort - call remove(a:request.waiting, a:timer) - if has_key(a:request, a:type) - call a:callback(a:request[a:type]) - endif -endfunction - -function! copilot#agent#Result(request, callback) abort - if has_key(a:request, 'resolve') - call add(a:request.resolve, a:callback) - elseif has_key(a:request, 'result') - let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'result', a:callback]))] = 1 - endif -endfunction - -function! copilot#agent#Error(request, callback) abort - if has_key(a:request, 'reject') - call add(a:request.reject, a:callback) - elseif has_key(a:request, 'error') - let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'error', a:callback]))] = 1 - endif -endfunction - -function! s:CloseBuffer(bufnr) abort - for instance in values(s:instances) - try - if has_key(instance, 'job') && has_key(instance.open_buffers, a:bufnr) - let buffer = remove(instance.open_buffers, a:bufnr) - call instance.Notify('textDocument/didClose', {'textDocument': {'uri': buffer.uri}}) - endif - catch - call copilot#logger#Exception() - endtry - endfor -endfunction - -augroup copilot_agent - autocmd! - if !has('nvim') - autocmd BufUnload * call s:CloseBuffer(+expand('<abuf>')) - endif -augroup END diff --git a/sources_non_forked/copilot.vim/autoload/copilot/client.vim b/sources_non_forked/copilot.vim/autoload/copilot/client.vim new file mode 100644 index 00000000..c811062e --- /dev/null +++ b/sources_non_forked/copilot.vim/autoload/copilot/client.vim @@ -0,0 +1,764 @@ +scriptencoding utf-8 + +let s:plugin_version = copilot#version#String() + +let s:error_canceled = {'code': -32800, 'message': 'Canceled'} +let s:error_exit = {'code': -32097, 'message': 'Process exited'} +let s:error_connection_inactive = {'code': -32096, 'message': 'Connection inactive'} + +let s:root = expand('<sfile>:h:h:h') + +if !exists('s:instances') + let s:instances = {} +endif + +" allow sourcing this file to reload the Lua file too +if has('nvim') + lua package.loaded._copilot = nil +endif + +function! s:Warn(msg) abort + if !empty(get(g:, 'copilot_no_startup_warnings')) + return + endif + echohl WarningMsg + echomsg 'Copilot: ' . a:msg + echohl NONE +endfunction + +function! s:VimClose() dict abort + if !has_key(self, 'job') + return + endif + let job = self.job + if has_key(self, 'kill') + call job_stop(job, 'kill') + call copilot#logger#Warn('Process forcefully terminated') + return + endif + let self.kill = v:true + let self.shutdown = self.Request('shutdown', {}, function(self.Notify, ['exit'])) + call timer_start(2000, { _ -> job_stop(job, 'kill') }) + call copilot#logger#Debug('Process shutdown initiated') +endfunction + +function! s:LogSend(request, line) abort + return '--> ' . a:line +endfunction + +function! s:RejectRequest(request, error) abort + if a:request.status !=# 'running' + return + endif + let a:request.waiting = {} + call remove(a:request, 'resolve') + let reject = remove(a:request, 'reject') + let a:request.status = 'error' + let a:request.error = deepcopy(a:error) + for Cb in reject + let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'error', Cb]))] = 1 + endfor + if index([s:error_canceled.code, s:error_connection_inactive.code], a:error.code) != -1 + return + endif + let msg = 'Method ' . a:request.method . ' errored with E' . a:error.code . ': ' . json_encode(a:error.message) + if empty(reject) + call copilot#logger#Error(msg) + else + call copilot#logger#Debug(msg) + endif +endfunction + +function! s:AfterInitialized(fn, ...) dict abort + call add(self.after_initialized, function(a:fn, a:000)) +endfunction + +function! s:Send(instance, request) abort + if !has_key(a:instance, 'job') + return v:false + endif + try + call ch_sendexpr(a:instance.job, a:request) + return v:true + catch /^Vim\%((\a\+)\)\=:E906:/ + let a:instance.kill = v:true + let job = remove(a:instance, 'job') + call job_stop(job) + call timer_start(2000, { _ -> job_stop(job, 'kill') }) + call copilot#logger#Warn('Terminating process after failed write') + return v:false + catch /^Vim\%((\a\+)\)\=:E631:/ + return v:false + endtry +endfunction + +function! s:VimNotify(method, params) dict abort + let request = {'method': a:method, 'params': a:params} + call self.AfterInitialized(function('s:Send', [self, request])) +endfunction + +function! s:RequestWait() dict abort + while self.status ==# 'running' + sleep 1m + endwhile + while !empty(get(self, 'waiting', {})) + sleep 1m + endwhile + return self +endfunction + +function! s:RequestAwait() dict abort + call self.Wait() + if has_key(self, 'result') + return self.result + endif + throw 'Copilot:E' . self.error.code . ': ' . self.error.message +endfunction + +function! s:RequestClient() dict abort + return get(s:instances, self.client_id, v:null) +endfunction + +if !exists('s:id') + let s:id = 0 +endif +if !exists('s:progress_token_id') + let s:progress_token_id = 0 +endif + +function! s:SetUpRequest(instance, id, method, params, progress, ...) abort + let request = { + \ 'client_id': a:instance.id, + \ 'id': a:id, + \ 'method': a:method, + \ 'params': a:params, + \ 'Client': function('s:RequestClient'), + \ 'Wait': function('s:RequestWait'), + \ 'Await': function('s:RequestAwait'), + \ 'Cancel': function('s:RequestCancel'), + \ 'resolve': [], + \ 'reject': [], + \ 'progress': a:progress, + \ 'status': 'running'} + let args = a:000[2:-1] + if len(args) + if !empty(a:1) + call add(request.resolve, { v -> call(a:1, [v] + args)}) + endif + if !empty(a:2) + call add(request.reject, { v -> call(a:2, [v] + args)}) + endif + return request + endif + if a:0 && !empty(a:1) + call add(request.resolve, a:1) + endif + if a:0 > 1 && !empty(a:2) + call add(request.reject, a:2) + endif + return request +endfunction + +function! s:UrlEncode(str) abort + return substitute(iconv(a:str, 'latin1', 'utf-8'),'[^A-Za-z0-9._~!$&''()*+,;=:@/-]','\="%".printf("%02X",char2nr(submatch(0)))','g') +endfunction + +let s:slash = exists('+shellslash') ? '\' : '/' +function! s:UriFromBufnr(bufnr) abort + let absolute = tr(bufname(a:bufnr), s:slash, '/') + if absolute !~# '^\a\+:\|^/\|^$' && getbufvar(a:bufnr, 'buftype') =~# '^\%(nowrite\)\=$' + let absolute = substitute(tr(getcwd(), s:slash, '/'), '/\=$', '/', '') . absolute + endif + return s:UriFromPath(absolute) +endfunction + +function! s:UriFromPath(absolute) abort + let absolute = a:absolute + if has('win32') && absolute =~# '^\a://\@!' + return 'file:///' . strpart(absolute, 0, 2) . s:UrlEncode(strpart(absolute, 2)) + elseif absolute =~# '^/' + return 'file://' . s:UrlEncode(absolute) + elseif absolute =~# '^\a[[:alnum:].+-]*:\|^$' + return absolute + else + return '' + endif +endfunction + +function! s:BufferText(bufnr) abort + return join(getbufline(a:bufnr, 1, '$'), "\n") . "\n" +endfunction + +let s:valid_request_key = '^\%(id\|method\|params\)$' +function! s:SendRequest(instance, request, ...) abort + if !has_key(a:instance, 'job') || get(a:instance, 'shutdown', a:request) isnot# a:request + return s:RejectRequest(a:request, s:error_connection_inactive) + endif + let json = filter(copy(a:request), 'v:key =~# s:valid_request_key') + if empty(s:Send(a:instance, json)) && has_key(a:request, 'id') && has_key(a:instance.requests, a:request.id) + call s:RejectRequest(remove(a:instance.requests, a:request.id), {'code': -32099, 'message': 'Write failed'}) + endif +endfunction + +function! s:RegisterWorkspaceFolderForBuffer(instance, buf) abort + let root = getbufvar(a:buf, 'workspace_folder') + if type(root) != v:t_string + return + endif + let root = s:UriFromPath(substitute(root, '[\/]$', '', '')) + if empty(root) || has_key(a:instance.workspaceFolders, root) + return + endif + let a:instance.workspaceFolders[root] = v:true + call a:instance.Notify('workspace/didChangeWorkspaceFolders', {'event': {'added': [{'uri': root, 'name': fnamemodify(root, ':t')}], 'removed': []}}) +endfunction + +function! s:PreprocessParams(instance, params) abort + let bufnr = v:null + for doc in filter([get(a:params, 'textDocument', {})], 'type(get(v:val, "uri", "")) == v:t_number') + let bufnr = doc.uri + call s:RegisterWorkspaceFolderForBuffer(a:instance, bufnr) + call extend(doc, a:instance.Attach(bufnr)) + endfor + let progress_tokens = [] + for key in keys(a:params) + if key =~# 'Token$' && type(a:params[key]) == v:t_func + let s:progress_token_id += 1 + let a:instance.progress[s:progress_token_id] = a:params[key] + call add(progress_tokens, s:progress_token_id) + let a:params[key] = s:progress_token_id + endif + endfor + return [bufnr, progress_tokens] +endfunction + +function! s:VimAttach(bufnr) dict abort + if !bufloaded(a:bufnr) + return {'uri': '', 'version': 0} + endif + let bufnr = a:bufnr + let doc = { + \ 'uri': s:UriFromBufnr(bufnr), + \ 'version': getbufvar(bufnr, 'changedtick', 0), + \ 'languageId': getbufvar(bufnr, '&filetype'), + \ } + if has_key(self.open_buffers, bufnr) && ( + \ self.open_buffers[bufnr].uri !=# doc.uri || + \ self.open_buffers[bufnr].languageId !=# doc.languageId) + call self.Notify('textDocument/didClose', {'textDocument': {'uri': self.open_buffers[bufnr].uri}}) + call remove(self.open_buffers, bufnr) + endif + if !has_key(self.open_buffers, bufnr) + call self.Notify('textDocument/didOpen', {'textDocument': extend({'text': s:BufferText(bufnr)}, doc)}) + let self.open_buffers[bufnr] = doc + else + call self.Notify('textDocument/didChange', { + \ 'textDocument': {'uri': doc.uri, 'version': doc.version}, + \ 'contentChanges': [{'text': s:BufferText(bufnr)}]}) + let self.open_buffers[bufnr].version = doc.version + endif + return doc +endfunction + +function! s:VimIsAttached(bufnr) dict abort + return bufloaded(a:bufnr) && has_key(self.open_buffers, a:bufnr) ? v:true : v:false +endfunction + +function! s:VimRequest(method, params, ...) dict abort + let s:id += 1 + let params = deepcopy(a:params) + let [_, progress] = s:PreprocessParams(self, params) + let request = call('s:SetUpRequest', [self, s:id, a:method, params, progress] + a:000) + call self.AfterInitialized(function('s:SendRequest', [self, request])) + let self.requests[s:id] = request + return request +endfunction + +function! s:Call(method, params, ...) dict abort + let request = call(self.Request, [a:method, a:params] + a:000) + if a:0 + return request + endif + return request.Await() +endfunction + +function! s:Cancel(request) dict abort + if has_key(self.requests, get(a:request, 'id', '')) + call self.Notify('$/cancelRequest', {'id': a:request.id}) + call s:RejectRequest(remove(self.requests, a:request.id), s:error_canceled) + endif +endfunction + +function! s:RequestCancel() dict abort + let instance = self.Client() + if !empty(instance) + call instance.Cancel(self) + elseif get(self, 'status', '') ==# 'running' + call s:RejectRequest(self, s:error_canceled) + endif + return self +endfunction + +function! s:DispatchMessage(instance, method, handler, id, params, ...) abort + try + let response = {'result': call(a:handler, [a:params, a:instance])} + if response.result is# 0 + let response.result = v:null + endif + catch + call copilot#logger#Exception('lsp.request.' . a:method) + let response = {'error': {'code': -32000, 'message': v:exception}} + endtry + if a:id isnot# v:null + call s:Send(a:instance, extend({'id': a:id}, response)) + endif + if !has_key(s:notifications, a:method) + return response + endif +endfunction + +function! s:OnMessage(instance, body, ...) abort + if !has_key(a:body, 'method') + return s:OnResponse(a:instance, a:body) + endif + let request = a:body + let id = get(request, 'id', v:null) + let params = get(request, 'params', v:null) + if has_key(a:instance.methods, request.method) + return s:DispatchMessage(a:instance, request.method, a:instance.methods[request.method], id, params) + elseif id isnot# v:null + call s:Send(a:instance, {"id": id, "error": {"code": -32700, "message": "Method not found: " . request.method}}) + call copilot#logger#Debug('Unexpected request ' . request.method . ' called with ' . json_encode(params)) + elseif request.method !~# '^\$/' + call copilot#logger#Debug('Unexpected notification ' . request.method . ' called with ' . json_encode(params)) + endif +endfunction + +function! s:OnResponse(instance, response, ...) abort + let response = a:response + let id = get(a:response, 'id', v:null) + if !has_key(a:instance.requests, id) + return + endif + let request = remove(a:instance.requests, id) + for progress_token in request.progress + if has_key(a:instance.progress, progress_token) + call remove(a:instance.progress, progress_token) + endif + endfor + if request.status !=# 'running' + return + endif + if has_key(response, 'result') + let request.waiting = {} + let resolve = remove(request, 'resolve') + call remove(request, 'reject') + let request.status = 'success' + let request.result = response.result + for Cb in resolve + let request.waiting[timer_start(0, function('s:Callback', [request, 'result', Cb]))] = 1 + endfor + else + call s:RejectRequest(request, response.error) + endif +endfunction + +function! s:OnErr(instance, ch, line, ...) abort + if !has_key(a:instance, 'serverInfo') + call copilot#logger#Bare('<-! ' . a:line) + endif +endfunction + +function! s:OnExit(instance, code, ...) abort + let a:instance.exit_status = a:code + if has_key(a:instance, 'job') + call remove(a:instance, 'job') + endif + if has_key(a:instance, 'client_id') + call remove(a:instance, 'client_id') + endif + let message = 'Process exited with status ' . a:code + if a:code >= 18 && a:code < 100 + let message = 'Node.js too old. ' . + \ (get(a:instance.node, 0, 'node') ==# 'node' ? 'Upgrade' : 'Change g:copilot_node_command') . + \ ' to ' . a:code . '.x or newer' + endif + if !has_key(a:instance, 'serverInfo') && !has_key(a:instance, 'startup_error') + let a:instance.startup_error = message + endif + for id in sort(keys(a:instance.requests), { a, b -> +a > +b }) + call s:RejectRequest(remove(a:instance.requests, id), s:error_exit) + endfor + if has_key(a:instance, 'after_initialized') + let a:instance.AfterInitialized = function('copilot#util#Defer') + for Fn in remove(a:instance, 'after_initialized') + call copilot#util#Defer(Fn) + endfor + endif + call copilot#util#Defer({ -> get(s:instances, a:instance.id) is# a:instance ? remove(s:instances, a:instance.id) : {} }) + if a:code == 0 + call copilot#logger#Info(message) + else + call copilot#logger#Warn(message) + if !has_key(a:instance, 'kill') + call copilot#util#Defer(function('s:Warn'), message) + endif + endif +endfunction + +function! copilot#client#LspInit(id, initialize_result) abort + if !has_key(s:instances, a:id) + return + endif + call s:PostInit(a:initialize_result, s:instances[a:id]) +endfunction + +function! copilot#client#LspExit(id, code, signal) abort + if !has_key(s:instances, a:id) + return + endif + let instance = remove(s:instances, a:id) + call s:OnExit(instance, a:code) +endfunction + +function! copilot#client#LspResponse(id, opts, ...) abort + if !has_key(s:instances, a:id) + return + endif + call s:OnResponse(s:instances[a:id], a:opts) +endfunction + +function! s:NvimAttach(bufnr) dict abort + if !bufloaded(a:bufnr) + return {'uri': '', 'version': 0} + endif + call luaeval('pcall(vim.lsp.buf_attach_client, _A[1], _A[2])', [a:bufnr, self.id]) + return luaeval('{uri = vim.uri_from_bufnr(_A), version = vim.lsp.util.buf_versions[_A]}', a:bufnr) +endfunction + +function! s:NvimIsAttached(bufnr) dict abort + return bufloaded(a:bufnr) ? luaeval('vim.lsp.buf_is_attached(_A[1], _A[2])', [a:bufnr, self.id]) : v:false +endfunction + +function! s:NvimRequest(method, params, ...) dict abort + let params = deepcopy(a:params) + let [bufnr, progress] = s:PreprocessParams(self, params) + let request = call('s:SetUpRequest', [self, v:null, a:method, params, progress] + a:000) + call self.AfterInitialized(function('s:NvimDoRequest', [self, request, bufnr])) + return request +endfunction + +function! s:NvimDoRequest(client, request, bufnr) abort + let request = a:request + if has_key(a:client, 'client_id') && !has_key(a:client, 'kill') + let request.id = eval("v:lua.require'_copilot'.lsp_request(a:client.id, a:request.method, a:request.params, a:bufnr)") + endif + if request.id isnot# v:null + let a:client.requests[request.id] = request + else + if has_key(a:client, 'client_id') + call copilot#client#LspExit(a:client.client_id, -1, -1) + endif + call copilot#util#Defer(function('s:RejectRequest'), request, s:error_connection_inactive) + endif + return request +endfunction + +function! s:NvimClose() dict abort + if !has_key(self, 'client_id') + return + endif + let self.kill = v:true + return luaeval('vim.lsp.get_client_by_id(_A).stop()', self.client_id) +endfunction + +function! s:NvimNotify(method, params) dict abort + call self.AfterInitialized(function('s:NvimDoNotify', [self.client_id, a:method, a:params])) +endfunction + +function! s:NvimDoNotify(client_id, method, params) abort + return eval("v:lua.require'_copilot'.rpc_notify(a:client_id, a:method, a:params)") +endfunction + +function! copilot#client#LspHandle(id, request) abort + if !has_key(s:instances, a:id) + return + endif + return s:OnMessage(s:instances[a:id], a:request) +endfunction + +let s:script_name = 'dist/language-server.js' +function! s:Command() abort + if !has('nvim-0.7') && v:version < 900 + return [[], [], 'Vim version too old'] + endif + let script = get(g:, 'copilot_command', '') + if type(script) == type('') + let script = [expand(script)] + endif + if empty(script) || !filereadable(script[0]) + let script = [s:root . '/' . s:script_name] + if !filereadable(script[0]) + return [[], [], 'Could not find ' . s:script_name . ' (bad install?)'] + endif + elseif script[0] !~# '\.js$' + return [[], script + ['--stdio'], ''] + endif + let node = get(g:, 'copilot_node_command', '') + if empty(node) + let node = ['node'] + elseif type(node) == type('') + let node = [expand(node)] + endif + if !executable(get(node, 0, '')) + if get(node, 0, '') ==# 'node' + return [[], [], 'Node.js not found in PATH'] + else + return [[], [], 'Node.js executable `' . get(node, 0, '') . "' not found"] + endif + endif + return [node, script + ['--stdio'], ''] +endfunction + +function! s:UrlDecode(str) abort + return substitute(a:str, '%\(\x\x\)', '\=iconv(nr2char("0x".submatch(1)), "utf-8", "latin1")', 'g') +endfunction + +function! copilot#client#EditorInfo() abort + if !exists('s:editor_version') + if has('nvim') + let s:editor_version = matchstr(execute('version'), 'NVIM v\zs[^[:space:]]\+') + else + let s:editor_version = (v:version / 100) . '.' . (v:version % 100) . (exists('v:versionlong') ? printf('.%04d', v:versionlong % 10000) : '') + endif + endif + return {'name': has('nvim') ? 'Neovim': 'Vim', 'version': s:editor_version} +endfunction + +function! copilot#client#EditorPluginInfo() abort + return {'name': 'copilot.vim', 'version': s:plugin_version} +endfunction + +function! copilot#client#Settings() abort + let settings = { + \ 'http': { + \ 'proxy': get(g:, 'copilot_proxy', v:null), + \ 'proxyStrictSSL': get(g:, 'copilot_proxy_strict_ssl', v:null)}, + \ 'github-enterprise': {'uri': get(g:, 'copilot_auth_provider_url', v:null)}, + \ } + if type(settings.http.proxy) ==# v:t_string && settings.http.proxy =~# '^[^/]\+$' + let settings.http.proxy = 'http://' . settings.http.proxy + endif + if type(get(g:, 'copilot_settings')) == v:t_dict + call extend(settings, g:copilot_settings) + endif + return settings +endfunction + +function! s:PostInit(result, instance) abort + let a:instance.serverInfo = get(a:result, 'serverInfo', {}) + if !has_key(a:instance, 'node_version') && has_key(a:result.serverInfo, 'nodeVersion') + let a:instance.node_version = a:result.serverInfo.nodeVersion + endif + let a:instance.AfterInitialized = function('copilot#util#Defer') + for Fn in remove(a:instance, 'after_initialized') + call copilot#util#Defer(Fn) + endfor +endfunction + +function! s:InitializeResult(result, instance) abort + call s:Send(a:instance, {'method': 'initialized', 'params': {}}) + call s:PostInit(a:result, a:instance) +endfunction + +function! s:InitializeError(error, instance) abort + if !has_key(a:instance, 'startup_error') + let a:instance.startup_error = 'Unexpected error E' . a:error.code . ' initializing language server: ' . a:error.message + call a:instance.Close() + endif +endfunction + +function! s:StartupError() dict abort + while (has_key(self, 'job') || has_key(self, 'client_id')) && !has_key(self, 'startup_error') && !has_key(self, 'serverInfo') + sleep 10m + endwhile + if has_key(self, 'serverInfo') + return '' + else + return get(self, 'startup_error', 'Something unexpected went wrong spawning the language server') + endif +endfunction + +function! s:StatusNotification(params, instance) abort + let a:instance.status = a:params +endfunction + +function! s:Nop(...) abort + return v:null +endfunction + +function! s:False(...) abort + return v:false +endfunction + +function! s:Progress(params, instance) abort + if has_key(a:instance.progress, a:params.token) + call a:instance.progress[a:params.token](a:params.value) + endif +endfunction + +let s:notifications = { + \ '$/progress': function('s:Progress'), + \ 'featureFlagsNotification': function('s:Nop'), + \ 'statusNotification': function('s:StatusNotification'), + \ 'window/logMessage': function('copilot#handlers#window_logMessage'), + \ } + +let s:vim_handlers = { + \ 'window/showMessageRequest': function('copilot#handlers#window_showMessageRequest'), + \ 'window/showDocument': function('copilot#handlers#window_showDocument'), + \ } + +let s:vim_capabilities = { + \ 'workspace': {'workspaceFolders': v:true}, + \ 'window': {'showDocument': {'support': v:true}}, + \ } + +function! copilot#client#New(...) abort + let opts = a:0 ? a:1 : {} + let instance = {'requests': {}, + \ 'progress': {}, + \ 'workspaceFolders': {}, + \ 'after_initialized': [], + \ 'status': {'status': 'Starting', 'message': ''}, + \ 'AfterInitialized': function('s:AfterInitialized'), + \ 'Close': function('s:Nop'), + \ 'Notify': function('s:False'), + \ 'Request': function('s:VimRequest'), + \ 'Attach': function('s:Nop'), + \ 'IsAttached': function('s:False'), + \ 'Call': function('s:Call'), + \ 'Cancel': function('s:Cancel'), + \ 'StartupError': function('s:StartupError'), + \ } + let instance.methods = copy(s:notifications) + let [node, argv, command_error] = s:Command() + if !empty(command_error) + let instance.id = -1 + let instance.startup_error = command_error + call copilot#logger#Error(command_error) + return instance + endif + let instance.node = node + let command = node + argv + let opts = {} + let opts.initializationOptions = { + \ 'editorInfo': copilot#client#EditorInfo(), + \ 'editorPluginInfo': copilot#client#EditorPluginInfo(), + \ } + let opts.workspaceFolders = [] + let settings = extend(copilot#client#Settings(), get(opts, 'editorConfiguration', {})) + if type(get(g:, 'copilot_workspace_folders')) == v:t_list + for folder in g:copilot_workspace_folders + if type(folder) == v:t_string && !empty(folder) && folder !~# '\*\*\|^/$' + for path in glob(folder . '/', 0, 1) + let uri = s:UriFromPath(substitute(path, '[\/]*$', '', '')) + call add(opts.workspaceFolders, {'uri': uri, 'name': fnamemodify(uri, ':t')}) + endfor + elseif type(folder) == v:t_dict && has_key(v:t_dict, 'uri') && !empty(folder.uri) && has_key(folder, 'name') + call add(opts.workspaceFolders, folder) + endif + endfor + endif + for folder in opts.workspaceFolders + let instance.workspaceFolders[folder.uri] = v:true + endfor + if has('nvim') + call extend(instance, { + \ 'Close': function('s:NvimClose'), + \ 'Notify': function('s:NvimNotify'), + \ 'Request': function('s:NvimRequest'), + \ 'Attach': function('s:NvimAttach'), + \ 'IsAttached': function('s:NvimIsAttached'), + \ }) + let instance.client_id = eval("v:lua.require'_copilot'.lsp_start_client(command, keys(instance.methods), opts, settings)") + let instance.id = instance.client_id + else + call extend(instance, { + \ 'Close': function('s:VimClose'), + \ 'Notify': function('s:VimNotify'), + \ 'Attach': function('s:VimAttach'), + \ 'IsAttached': function('s:VimIsAttached'), + \ }) + let state = {'headers': {}, 'mode': 'headers', 'buffer': ''} + let instance.open_buffers = {} + let instance.methods = extend(s:vim_handlers, instance.methods) + let instance.job = job_start(command, { + \ 'cwd': copilot#job#Cwd(), + \ 'noblock': 1, + \ 'stoponexit': '', + \ 'in_mode': 'lsp', + \ 'out_mode': 'lsp', + \ 'out_cb': { j, d -> copilot#util#Defer(function('s:OnMessage'), instance, d) }, + \ 'err_cb': function('s:OnErr', [instance]), + \ 'exit_cb': { j, d -> copilot#util#Defer(function('s:OnExit'), instance, d) }, + \ }) + let instance.id = job_info(instance.job).process + let opts.capabilities = s:vim_capabilities + let opts.processId = getpid() + let request = instance.Request('initialize', opts, function('s:InitializeResult'), function('s:InitializeError'), instance) + call call(remove(instance.after_initialized, 0), []) + call instance.Notify('workspace/didChangeConfiguration', {'settings': settings}) + endif + let s:instances[instance.id] = instance + return instance +endfunction + +function! copilot#client#Cancel(request) abort + if type(a:request) == type({}) && has_key(a:request, 'Cancel') + call a:request.Cancel() + endif +endfunction + +function! s:Callback(request, type, callback, timer) abort + call remove(a:request.waiting, a:timer) + if has_key(a:request, a:type) + call a:callback(a:request[a:type]) + endif +endfunction + +function! copilot#client#Result(request, callback) abort + if has_key(a:request, 'resolve') + call add(a:request.resolve, a:callback) + elseif has_key(a:request, 'result') + let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'result', a:callback]))] = 1 + endif +endfunction + +function! copilot#client#Error(request, callback) abort + if has_key(a:request, 'reject') + call add(a:request.reject, a:callback) + elseif has_key(a:request, 'error') + let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'error', a:callback]))] = 1 + endif +endfunction + +function! s:CloseBuffer(bufnr) abort + for instance in values(s:instances) + try + if has_key(instance, 'job') && has_key(instance.open_buffers, a:bufnr) + let buffer = remove(instance.open_buffers, a:bufnr) + call instance.Notify('textDocument/didClose', {'textDocument': {'uri': buffer.uri}}) + endif + catch + call copilot#logger#Exception() + endtry + endfor +endfunction + +augroup copilot_close + autocmd! + if !has('nvim') + autocmd BufUnload * call s:CloseBuffer(+expand('<abuf>')) + endif +augroup END diff --git a/sources_non_forked/copilot.vim/autoload/copilot/doc.vim b/sources_non_forked/copilot.vim/autoload/copilot/doc.vim deleted file mode 100644 index e442e530..00000000 --- a/sources_non_forked/copilot.vim/autoload/copilot/doc.vim +++ /dev/null @@ -1,116 +0,0 @@ -if exists('g:autoloaded_copilot_prompt') - finish -endif -let g:autoloaded_copilot_prompt = 1 - -scriptencoding utf-8 - -let s:slash = exists('+shellslash') ? '\' : '/' - -function copilot#doc#UTF16Width(str) abort - return strchars(substitute(a:str, "\\%#=2[^\u0001-\uffff]", " ", 'g')) -endfunction - -if exists('*utf16idx') - - function! copilot#doc#UTF16ToByteIdx(str, utf16_idx) abort - return byteidx(a:str, a:utf16_idx, 1) - endfunction - -elseif has('nvim') - - function! copilot#doc#UTF16ToByteIdx(str, utf16_idx) abort - try - return v:lua.vim.str_byteindex(a:str, a:utf16_idx, 1) - catch /^Vim(return):E5108:/ - return -1 - endtry - endfunction - -else - - function! copilot#doc#UTF16ToByteIdx(str, utf16_idx) abort - if copilot#doc#UTF16Width(a:str) < a:utf16_idx - return -1 - endif - let end_offset = len(a:str) - while copilot#doc#UTF16Width(strpart(a:str, 0, end_offset)) > a:utf16_idx && end_offset > 0 - let end_offset -= 1 - endwhile - return end_offset - endfunction - -endif - - -let s:language_normalization_map = { - \ "bash": "shellscript", - \ "bst": "bibtex", - \ "cs": "csharp", - \ "cuda": "cuda-cpp", - \ "dosbatch": "bat", - \ "dosini": "ini", - \ "gitcommit": "git-commit", - \ "gitrebase": "git-rebase", - \ "make": "makefile", - \ "objc": "objective-c", - \ "objcpp": "objective-cpp", - \ "ps1": "powershell", - \ "raku": "perl6", - \ "sh": "shellscript", - \ "text": "plaintext", - \ } -function copilot#doc#LanguageForFileType(filetype) abort - let filetype = substitute(a:filetype, '\..*', '', '') - return get(s:language_normalization_map, empty(filetype) ? "text" : filetype, filetype) -endfunction - -function! s:RelativePath(absolute) abort - if exists('b:copilot_relative_path') - return b:copilot_relative_path - elseif exists('b:copilot_root') - let root = b:copilot_root - elseif len(get(b:, 'projectionist', {})) - let root = sort(keys(b:projectionist), { a, b -> a < b })[0] - else - let root = getcwd() - endif - let root = tr(root, s:slash, '/') . '/' - if strpart(tr(a:absolute, 'A-Z', 'a-z'), 0, len(root)) ==# tr(root, 'A-Z', 'a-z') - return strpart(a:absolute, len(root)) - else - return fnamemodify(a:absolute, ':t') - endif -endfunction - -function! copilot#doc#Get() abort - let absolute = tr(@%, s:slash, '/') - if absolute !~# '^\a\+:\|^/\|^$' && &buftype =~# '^\%(nowrite\)\=$' - let absolute = substitute(tr(getcwd(), s:slash, '/'), '/\=$', '/', '') . absolute - endif - let doc = { - \ 'uri': bufnr(''), - \ 'version': getbufvar('', 'changedtick'), - \ 'relativePath': s:RelativePath(absolute), - \ 'insertSpaces': &expandtab ? v:true : v:false, - \ 'tabSize': shiftwidth(), - \ 'indentSize': shiftwidth(), - \ } - let line = getline('.') - let col_byte = col('.') - (mode() =~# '^[iR]' || empty(line)) - let col_utf16 = copilot#doc#UTF16Width(strpart(line, 0, col_byte)) - let doc.position = {'line': line('.') - 1, 'character': col_utf16} - return doc -endfunction - -function! copilot#doc#Params(...) abort - let extra = a:0 ? a:1 : {} - let params = extend({'doc': extend(copilot#doc#Get(), get(extra, 'doc', {}))}, extra, 'keep') - let params.textDocument = { - \ 'uri': params.doc.uri, - \ 'version': params.doc.version, - \ 'relativePath': params.doc.relativePath, - \ } - let params.position = params.doc.position - return params -endfunction diff --git a/sources_non_forked/copilot.vim/autoload/copilot/handlers.vim b/sources_non_forked/copilot.vim/autoload/copilot/handlers.vim new file mode 100644 index 00000000..a73186fe --- /dev/null +++ b/sources_non_forked/copilot.vim/autoload/copilot/handlers.vim @@ -0,0 +1,31 @@ +function! copilot#handlers#window_logMessage(params, ...) abort + call copilot#logger#Raw(get(a:params, 'type', 6), get(a:params, 'message', '')) +endfunction + +function! copilot#handlers#window_showMessageRequest(params, ...) abort + let choice = inputlist([a:params.message . "\n\nRequest Actions:"] + + \ map(copy(get(a:params, 'actions', [])), { i, v -> (i + 1) . '. ' . v.title})) + return choice > 0 ? get(a:params.actions, choice - 1, v:null) : v:null +endfunction + +function! s:BrowserCallback(into, code) abort + let a:into.code = a:code +endfunction + +function! copilot#handlers#window_showDocument(params, ...) abort + echo a:params.uri + if empty(get(a:params, 'external')) + return {'success': v:false} + endif + let browser = copilot#Browser() + if empty(browser) + return {'success': v:false} + endif + let status = {} + call copilot#job#Stream(browser + [a:params.uri], v:null, v:null, function('s:BrowserCallback', [status])) + let time = reltime() + while empty(status) && reltimefloat(reltime(time)) < 1 + sleep 10m + endwhile + return {'success': get(status, 'code') ? v:false : v:true} +endfunction diff --git a/sources_non_forked/copilot.vim/autoload/copilot/job.vim b/sources_non_forked/copilot.vim/autoload/copilot/job.vim index 212e8e62..39904a8d 100644 --- a/sources_non_forked/copilot.vim/autoload/copilot/job.vim +++ b/sources_non_forked/copilot.vim/autoload/copilot/job.vim @@ -1,11 +1,6 @@ -if exists('g:autoloaded_copilot_job') - finish -endif -let g:autoloaded_copilot_job = 1 - scriptencoding utf-8 -function copilot#job#Nop(...) abort +function! copilot#job#Nop(...) abort endfunction function! s:Jobs(job_or_jobs) abort diff --git a/sources_non_forked/copilot.vim/autoload/copilot/logger.vim b/sources_non_forked/copilot.vim/autoload/copilot/logger.vim index 105e3f9b..923a1c11 100644 --- a/sources_non_forked/copilot.vim/autoload/copilot/logger.vim +++ b/sources_non_forked/copilot.vim/autoload/copilot/logger.vim @@ -1,8 +1,3 @@ -if exists('g:autoloaded_copilot_log') - finish -endif -let g:autoloaded_copilot_log = 1 - if !exists('s:log_file') let s:log_file = tempname() . '-copilot.log' try @@ -11,35 +6,59 @@ if !exists('s:log_file') endtry endif -function! copilot#logger#File() abort - return s:log_file +let s:logs = [] + +function! copilot#logger#BufReadCmd() abort + try + setlocal modifiable noreadonly + silent call deletebufline('', 1, '$') + if !empty(s:logs) + call setline(1, s:logs) + endif + finally + setlocal buftype=nofile bufhidden=wipe nobuflisted nomodified nomodifiable + endtry endfunction +let s:level_prefixes = ['', '[ERROR] ', '[WARN] ', '[INFO] ', '[DEBUG] ', '[DEBUG] '] + function! copilot#logger#Raw(level, message) abort - if $COPILOT_AGENT_VERBOSE !~# '^\%(1\|true\)$' && a:level < 1 - return - endif let lines = type(a:message) == v:t_list ? copy(a:message) : split(a:message, "\n", 1) + let lines[0] = strftime('[%Y-%m-%d %H:%M:%S] ') . get(s:level_prefixes, a:level, '[UNKNOWN] ') . get(lines, 0, '') try if !filewritable(s:log_file) return endif call map(lines, { k, L -> type(L) == v:t_func ? call(L, []) : L }) - call writefile(lines, s:log_file, 'a') + call extend(s:logs, lines) + let overflow = len(s:logs) - get(g:, 'copilot_log_history', 10000) + if overflow > 0 + call remove(s:logs, 0, overflow - 1) + endif + let bufnr = bufnr('copilot:///log') + if bufnr > 0 && bufloaded(bufnr) + call setbufvar(bufnr, '&modifiable', 1) + call setbufline(bufnr, 1, s:logs) + call setbufvar(bufnr, '&modifiable', 0) + for winid in win_findbuf(bufnr) + if has('nvim') && winid != win_getid() + call nvim_win_set_cursor(winid, [len(s:logs), 0]) + endif + endfor + endif catch endtry endfunction -function! copilot#logger#Trace(...) abort - call copilot#logger#Raw(-1, a:000) -endfunction - function! copilot#logger#Debug(...) abort - call copilot#logger#Raw(0, a:000) + if empty(get(g:, 'copilot_debug')) + return + endif + call copilot#logger#Raw(4, a:000) endfunction function! copilot#logger#Info(...) abort - call copilot#logger#Raw(1, a:000) + call copilot#logger#Raw(3, a:000) endfunction function! copilot#logger#Warn(...) abort @@ -47,26 +66,40 @@ function! copilot#logger#Warn(...) abort endfunction function! copilot#logger#Error(...) abort - call copilot#logger#Raw(3, a:000) + call copilot#logger#Raw(1, a:000) endfunction -function! copilot#logger#Exception() abort +function! copilot#logger#Bare(...) abort + call copilot#logger#Raw(0, a:000) +endfunction + +function! copilot#logger#Exception(...) abort if !empty(v:exception) && v:exception !=# 'Vim:Interrupt' call copilot#logger#Error('Exception: ' . v:exception . ' @ ' . v:throwpoint) - let agent = copilot#RunningAgent() - if !empty(agent) + let client = copilot#RunningClient() + if !empty(client) + let [_, type, code, message; __] = matchlist(v:exception, '^\%(\(^[[:alnum:]_#]\+\)\%((\a\+)\)\=\%(\(:E-\=\d\+\)\)\=:\s*\)\=\(.*\)$') let stacklines = [] - for frame in split(substitute(substitute(v:throwpoint, ', \S\+ \(\d\+\)$', '[\1]', ''), '^function ', '', ''), '\.\@<!\.\.\.\@!') - if frame =~# '[\/]' - call add(stacklines, '[redacted]') + for frame in split(substitute(v:throwpoint, ', \S\+ \(\d\+\)$', '[\1]', ''), '\.\@<!\.\.\.\@!') + let fn_line = matchlist(frame, '^\%(function \)\=\(\S\+\)\[\(\d\+\)\]$') + if !empty(fn_line) + call add(stacklines, {'function': substitute(fn_line[1], '^<SNR>\d\+_', '<SID>', ''), 'lineno': +fn_line[2]}) + elseif frame =~# ' Autocmds for "\*"$' + call add(stacklines, {'function': frame}) + elseif frame =~# ' Autocmds for ".*"$' + call add(stacklines, {'function': substitute(frame, ' for ".*"$', ' for "[redacted]"', '')}) else - call add(stacklines, substitute(frame, '^<SNR>\d\+_', '<SID>', '')) + call add(stacklines, {'function': '[redacted]'}) endif endfor - call agent.Request('telemetry/exception', { - \ 'origin': 'copilot.vim', - \ 'stacktrace': join([v:exception] + stacklines, "\n") - \ }) + return client.Request('telemetry/exception', { + \ 'transaction': a:0 ? a:1 : '', + \ 'platform': 'other', + \ 'exception_detail': [{ + \ 'type': type . code, + \ 'value': message, + \ 'stacktrace': stacklines}] + \ }, v:null, function('copilot#util#Nop')) endif endif endfunction diff --git a/sources_non_forked/copilot.vim/autoload/copilot/panel.vim b/sources_non_forked/copilot.vim/autoload/copilot/panel.vim index 072ef948..4e25237e 100644 --- a/sources_non_forked/copilot.vim/autoload/copilot/panel.vim +++ b/sources_non_forked/copilot.vim/autoload/copilot/panel.vim @@ -1,8 +1,3 @@ -if exists('g:autoloaded_copilot_panel') - finish -endif -let g:autoloaded_copilot_panel = 1 - scriptencoding utf-8 if !exists('s:panel_id') @@ -11,29 +6,35 @@ endif let s:separator = repeat('─', 72) -function! s:Solutions(state) abort - return sort(values(get(a:state, 'solutions', {})), { a, b -> a.score < b.score }) -endfunction - -function! s:Render(panel_id) abort - let bufnr = bufnr('^' . a:panel_id . '$') - let state = getbufvar(bufnr, 'copilot_panel') - if !bufloaded(bufnr) || type(state) != v:t_dict +function! s:Render(state) abort + let bufnr = bufnr('^' . a:state.panel . '$') + let state = a:state + if !bufloaded(bufnr) return endif - let sorted = s:Solutions(state) - if !empty(get(state, 'status', '')) - let lines = ['Error: ' . state.status] + let sorted = a:state.items + if !empty(get(a:state, 'error')) + let lines = ['Error: ' . a:state.error.message] + let sorted = [] + elseif get(a:state, 'percentage') == 100 + let lines = ['Synthesized ' . (len(sorted) == 1 ? '1 completion' : len(sorted) . ' completions')] else - let target = get(state, 'count_target', '?') - let received = has_key(state, 'status') ? target : len(sorted) - let lines = ['Synthesiz' . (has_key(state, 'status') ? 'ed ' : 'ing ') . received . '/' . target . ' solutions (Duplicates hidden)'] + let lines = [substitute('Synthesizing ' . matchstr(get(a:state, 'message', ''), '\d\+\%(/\d\+\)\=') . ' completions', ' \+', ' ', 'g')] endif if len(sorted) - call add(lines, 'Press <CR> on a solution to accept') + call add(lines, 'Press <CR> on a completion to accept') endif - for solution in sorted - let lines += [s:separator] + split(solution.displayText, "\n", 1) + let leads = {} + for item in sorted + let insert = split(item.insertText, "\r\n\\=\\|\n", 1) + let insert[0] = strpart(a:state.line, 0, copilot#util#UTF16ToByteIdx(a:state.line, item.range.start.character)) . insert[0] + let lines += [s:separator] + insert + if !has_key(leads, string(item.range.start)) + let match = insert[0 : a:state.position.line - item.range.start.line] + let match[-1] = strpart(match[-1], 0, copilot#util#UTF16ToByteIdx(match[-1], a:state.position.character)) + call map(match, { k, v -> escape(v, '][^$.*\~') }) + let leads[string(item.range.start)] = join(match, '\n') + endif endfor try call setbufvar(bufnr, '&modifiable', 1) @@ -41,64 +42,61 @@ function! s:Render(panel_id) abort call setbufline(bufnr, 1, lines) finally call setbufvar(bufnr, '&modifiable', 0) - call setbufvar(bufnr, '&readonly', 1) endtry + call clearmatches() + call matchadd('CopilotSuggestion', '\C^' . s:separator . '\n\zs\%(' . join(sort(values(leads), { a, b -> len(b) - len(a) }), '\|') . '\)', 10, 4) endfunction -function! copilot#panel#Solution(params, ...) abort - let state = getbufvar('^' . a:params.panelId . '$', 'copilot_panel') - if !bufloaded(a:params.panelId) || type(state) != v:t_dict - return - endif - let state.solutions[a:params.solutionId] = a:params - call s:Render(a:params.panelId) +function! s:PartialResult(state, value) abort + let items = type(a:value) == v:t_list ? a:value : a:value.items + call extend(a:state.items, items) + call s:Render(a:state) endfunction -function! copilot#panel#SolutionsDone(params, ...) abort - let state = getbufvar('^' . a:params.panelId . '$', 'copilot_panel') - if !bufloaded(a:params.panelId) || type(state) != v:t_dict - call copilot#logger#Debug('SolutionsDone: ' . a:params.panelId) - return +function! s:WorkDone(state, value) abort + if has_key(a:value, 'message') + let a:state.message = a:value.message + endif + if has_key(a:value, 'percentage') + let a:state.percentage = a:value.percentage + call s:Render(a:state) endif - let state.status = get(a:params, 'message', '') - call s:Render(a:params.panelId) endfunction function! copilot#panel#Accept(...) abort let state = get(b:, 'copilot_panel', {}) - let solutions = s:Solutions(state) - if empty(solutions) + if empty(state.items) return '' endif if !has_key(state, 'bufnr') || !bufloaded(get(state, 'bufnr', -1)) return "echoerr 'Buffer was closed'" endif let at = a:0 ? a:1 : line('.') - let solution_index = 0 + let index = 0 for lnum in range(1, at) if getline(lnum) ==# s:separator - let solution_index += 1 + let index += 1 endif endfor - if solution_index > 0 && solution_index <= len(solutions) - let solution = solutions[solution_index - 1] - let lnum = solution.range.start.line + 1 + if index > 0 && index <= len(state.items) + let item = state.items[index - 1] + let lnum = item.range.start.line + 1 if getbufline(state.bufnr, lnum) !=# [state.line] - return 'echoerr "Buffer has changed since synthesizing solution"' + return 'echoerr "Buffer has changed since synthesizing completion"' endif - let lines = split(solution.displayText, "\n", 1) - let old_first = getline(solution.range.start.line + 1) - let lines[0] = strpart(old_first, 0, copilot#doc#UTF16ToByteIdx(old_first, solution.range.start.character)) . lines[0] - let old_last = getline(solution.range.end.line + 1) - let lines[-1] .= strpart(old_last, copilot#doc#UTF16ToByteIdx(old_last, solution.range.start.character)) - call setbufline(state.bufnr, solution.range.start.line + 1, lines[0]) - call appendbufline(state.bufnr, solution.range.start.line + 1, lines[1:-1]) - call copilot#Request('notifyAccepted', {'uuid': solution.solutionId}) + let lines = split(item.insertText, "\n", 1) + let old_first = getbufline(state.bufnr, item.range.start.line + 1)[0] + let lines[0] = strpart(old_first, 0, copilot#util#UTF16ToByteIdx(old_first, item.range.start.character)) . lines[0] + let old_last = getbufline(state.bufnr, item.range.end.line + 1)[0] + let lines[-1] .= strpart(old_last, copilot#util#UTF16ToByteIdx(old_last, item.range.end.character)) + call deletebufline(state.bufnr, item.range.start.line + 1, item.range.end.line + 1) + call appendbufline(state.bufnr, item.range.start.line, lines) + call copilot#Request('workspace/executeCommand', item.command) bwipeout let win = bufwinnr(state.bufnr) if win > 0 exe win . 'wincmd w' - exe solution.range.start.line + len(lines) + exe item.range.start.line + len(lines) if state.was_insert startinsert! else @@ -112,49 +110,58 @@ endfunction function! s:Initialize(state) abort let &l:filetype = 'copilot' . (empty(a:state.filetype) ? '' : '.' . a:state.filetype) let &l:tabstop = a:state.tabstop - call clearmatches() - call matchadd('CopilotSuggestion', '\C^' . s:separator . '\n\zs' . escape(a:state.line, '][^$.*\~'), 10, 4) nmap <buffer><script> <CR> <Cmd>exe copilot#panel#Accept()<CR> nmap <buffer><script> [[ <Cmd>call search('^─\{9,}\n.', 'bWe')<CR> nmap <buffer><script> ]] <Cmd>call search('^─\{9,}\n.', 'We')<CR> endfunction function! s:BufReadCmd() abort - setlocal bufhidden=wipe buftype=nofile nobuflisted readonly nomodifiable + setlocal bufhidden=wipe buftype=nofile nobuflisted nomodifiable let state = get(b:, 'copilot_panel') if type(state) != v:t_dict return endif call s:Initialize(state) - call s:Render(expand('<amatch>')) + call s:Render(state) return '' endfunction +function! s:Result(state, result) abort + let a:state.percentage = 100 + call s:PartialResult(a:state, a:result) +endfunction + +function! s:Error(state, error) abort + let a:state.error = a:error + call s:Render(a:state) +endfunction + function! copilot#panel#Open(opts) abort let s:panel_id += 1 - let state = {'solutions': {}, 'filetype': &filetype, 'line': getline('.'), 'bufnr': bufnr(''), 'tabstop': &tabstop} - let bufname = 'copilot:///' . s:panel_id - let params = copilot#doc#Params({'panelId': bufname}) - let state.was_insert = mode() =~# '^[iR]' + let state = {'items': [], 'filetype': &filetype, 'was_insert': mode() =~# '^[iR]', 'bufnr': bufnr(''), 'tabstop': &tabstop} + let state.panel = 'copilot:///panel/' . s:panel_id if state.was_insert + let state.position = copilot#util#AppendPosition() stopinsert else - let params.doc.position.character = copilot#doc#UTF16Width(state.line) - let params.position.character = params.doc.position.character + let state.position = {'line': a:opts.line1 >= 1 ? a:opts.line1 - 1 : 0, 'character': copilot#util#UTF16Width(getline('.'))} endif - let response = copilot#Request('getPanelCompletions', params).Wait() - if response.status ==# 'error' - return 'echoerr ' . string(response.error.message) - endif - let state.count_target = response.result.solutionCountTarget - exe substitute(a:opts.mods, '\C\<tab\>', '-tab', 'g') 'keepalt split' bufname + let state.line = getline(state.position.line + 1) + let params = { + \ 'textDocument': {'uri': state.bufnr}, + \ 'position': state.position, + \ 'partialResultToken': function('s:PartialResult', [state]), + \ 'workDoneToken': function('s:WorkDone', [state]), + \ } + let response = copilot#Request('textDocument/copilotPanelCompletion', params, function('s:Result', [state]), function('s:Error', [state])) + exe substitute(a:opts.mods, '\C\<tab\>', '-tab', 'g') 'keepalt split' state.panel let b:copilot_panel = state call s:Initialize(state) - call s:Render(@%) + call s:Render(state) return '' endfunction augroup github_copilot_panel autocmd! - autocmd BufReadCmd copilot:///* exe s:BufReadCmd() + autocmd BufReadCmd copilot:///panel/* exe s:BufReadCmd() augroup END diff --git a/sources_non_forked/copilot.vim/autoload/copilot/util.vim b/sources_non_forked/copilot.vim/autoload/copilot/util.vim new file mode 100644 index 00000000..ed5aff0c --- /dev/null +++ b/sources_non_forked/copilot.vim/autoload/copilot/util.vim @@ -0,0 +1,61 @@ +let s:deferred = [] + +function! copilot#util#Nop(...) abort + return v:null +endfunction + +function! copilot#util#Defer(fn, ...) abort + call add(s:deferred, function(a:fn, a:000)) + return timer_start(0, function('s:RunDeferred')) +endfunction + +function! s:RunDeferred(...) abort + if empty(s:deferred) + return + endif + let Fn = remove(s:deferred, 0) + call timer_start(0, function('s:RunDeferred')) + call call(Fn, []) +endfunction + +function! copilot#util#UTF16Width(str) abort + return strchars(substitute(a:str, "\\%#=2[^\u0001-\uffff]", " ", 'g')) +endfunction + +if exists('*utf16idx') + + function! copilot#util#UTF16ToByteIdx(str, utf16_idx) abort + return byteidx(a:str, a:utf16_idx, 1) + endfunction + +elseif has('nvim') + + function! copilot#util#UTF16ToByteIdx(str, utf16_idx) abort + try + return v:lua.vim.str_byteindex(a:str, a:utf16_idx, 1) + catch /^Vim(return):E5108:/ + return -1 + endtry + endfunction + +else + + function! copilot#util#UTF16ToByteIdx(str, utf16_idx) abort + if copilot#util#UTF16Width(a:str) < a:utf16_idx + return -1 + endif + let end_offset = len(a:str) + while copilot#util#UTF16Width(strpart(a:str, 0, end_offset)) > a:utf16_idx && end_offset > 0 + let end_offset -= 1 + endwhile + return end_offset + endfunction + +endif + +function! copilot#util#AppendPosition() abort + let line = getline('.') + let col_byte = col('.') - (mode() =~# '^[iR]' || empty(line)) + let col_utf16 = copilot#util#UTF16Width(strpart(line, 0, col_byte)) + return {'line': line('.') - 1, 'character': col_utf16} +endfunction diff --git a/sources_non_forked/copilot.vim/autoload/copilot/version.vim b/sources_non_forked/copilot.vim/autoload/copilot/version.vim index 253ed8ed..5d9c5e76 100644 --- a/sources_non_forked/copilot.vim/autoload/copilot/version.vim +++ b/sources_non_forked/copilot.vim/autoload/copilot/version.vim @@ -1,3 +1,3 @@ function! copilot#version#String() abort - return '1.18.0' + return '1.40.0' endfunction diff --git a/sources_non_forked/copilot.vim/dist/agent.js b/sources_non_forked/copilot.vim/dist/agent.js deleted file mode 100644 index 96558e4a..00000000 Binary files a/sources_non_forked/copilot.vim/dist/agent.js and /dev/null differ diff --git a/sources_non_forked/copilot.vim/dist/agent.js.map b/sources_non_forked/copilot.vim/dist/agent.js.map deleted file mode 100644 index 5d099ea4..00000000 Binary files a/sources_non_forked/copilot.vim/dist/agent.js.map and /dev/null differ diff --git a/sources_non_forked/copilot.vim/dist/compiled/darwin/arm64/kerberos.node b/sources_non_forked/copilot.vim/dist/compiled/darwin/arm64/kerberos.node index db324d64..8ed9eaaa 100644 Binary files a/sources_non_forked/copilot.vim/dist/compiled/darwin/arm64/kerberos.node and b/sources_non_forked/copilot.vim/dist/compiled/darwin/arm64/kerberos.node differ diff --git a/sources_non_forked/copilot.vim/dist/compiled/darwin/x64/kerberos.node b/sources_non_forked/copilot.vim/dist/compiled/darwin/x64/kerberos.node index 0a8a59a2..44a517ba 100644 Binary files a/sources_non_forked/copilot.vim/dist/compiled/darwin/x64/kerberos.node and b/sources_non_forked/copilot.vim/dist/compiled/darwin/x64/kerberos.node differ diff --git a/sources_non_forked/copilot.vim/dist/compiled/win32/x64/kerberos.node b/sources_non_forked/copilot.vim/dist/compiled/win32/x64/kerberos.node index 42e944f2..d7369250 100644 Binary files a/sources_non_forked/copilot.vim/dist/compiled/win32/x64/kerberos.node and b/sources_non_forked/copilot.vim/dist/compiled/win32/x64/kerberos.node differ diff --git a/sources_non_forked/copilot.vim/dist/crypt32.node b/sources_non_forked/copilot.vim/dist/crypt32.node index 597cdd31..a48c6a14 100644 Binary files a/sources_non_forked/copilot.vim/dist/crypt32.node and b/sources_non_forked/copilot.vim/dist/crypt32.node differ diff --git a/sources_non_forked/copilot.vim/dist/language-server.js b/sources_non_forked/copilot.vim/dist/language-server.js new file mode 100644 index 00000000..0429e164 Binary files /dev/null and b/sources_non_forked/copilot.vim/dist/language-server.js differ diff --git a/sources_non_forked/copilot.vim/dist/language-server.js.map b/sources_non_forked/copilot.vim/dist/language-server.js.map new file mode 100644 index 00000000..4beb144a Binary files /dev/null and b/sources_non_forked/copilot.vim/dist/language-server.js.map differ diff --git a/sources_non_forked/copilot.vim/dist/resources/cl100k/tokenizer_cushman002.json b/sources_non_forked/copilot.vim/dist/resources/cl100k/tokenizer_cushman002.json deleted file mode 100644 index 4b9703f5..00000000 Binary files a/sources_non_forked/copilot.vim/dist/resources/cl100k/tokenizer_cushman002.json and /dev/null differ diff --git a/sources_non_forked/copilot.vim/dist/resources/cl100k/vocab_cushman002.bpe b/sources_non_forked/copilot.vim/dist/resources/cl100k/vocab_cushman002.bpe deleted file mode 100644 index c5f96939..00000000 Binary files a/sources_non_forked/copilot.vim/dist/resources/cl100k/vocab_cushman002.bpe and /dev/null differ diff --git a/sources_non_forked/copilot.vim/dist/resources/cl100k_base.tiktoken.noindex b/sources_non_forked/copilot.vim/dist/resources/cl100k_base.tiktoken.noindex new file mode 100644 index 00000000..dfec64c2 Binary files /dev/null and b/sources_non_forked/copilot.vim/dist/resources/cl100k_base.tiktoken.noindex differ diff --git a/sources_non_forked/copilot.vim/dist/resources/o200k_base.tiktoken.noindex b/sources_non_forked/copilot.vim/dist/resources/o200k_base.tiktoken.noindex new file mode 100644 index 00000000..d842cf81 Binary files /dev/null and b/sources_non_forked/copilot.vim/dist/resources/o200k_base.tiktoken.noindex differ diff --git a/sources_non_forked/copilot.vim/doc/copilot.txt b/sources_non_forked/copilot.vim/doc/copilot.txt index 95130e95..72c5596d 100644 --- a/sources_non_forked/copilot.vim/doc/copilot.txt +++ b/sources_non_forked/copilot.vim/doc/copilot.txt @@ -28,10 +28,10 @@ COMMANDS *:Copilot* *:Copilot_panel* :Copilot panel Open a window with up to 10 completions for the - current buffer. Use <CR> to accept a solution. Maps - are also provided for [[ and ]] to jump from solution - to solution. This is the default command if :Copilot - is called without an argument. + current buffer. Use <CR> to accept a completion. + Maps are also provided for [[ and ]] to jump from + completion to completion. This is the default command + if :Copilot is called without an argument. *:Copilot_version* :Copilot version Show version information. @@ -75,12 +75,13 @@ g:copilot_node_command Tell Copilot what `node` binary to use with \ "~/.nodenv/versions/18.18.0/bin/node" < *g:copilot_proxy* -g:copilot_proxy Tell Copilot what proxy server to use. This is a - string in the format of `hostname:port` or - `username:password@host:port`. +g:copilot_proxy Tell Copilot what proxy server to use. > - let g:copilot_proxy = 'localhost:3128' + let g:copilot_proxy = 'http://localhost:3128' < + If this is not set, Copilot will use the value of + environment variables like $HTTPS_PROXY. + *g:copilot_proxy_strict_ssl* g:copilot_proxy_strict_ssl Corporate proxies sometimes use a man-in-the-middle @@ -90,6 +91,23 @@ g:copilot_proxy_strict_ssl > let g:copilot_proxy_strict_ssl = v:false < + You can also tell Node.js to disable SSL verification + by setting the $NODE_TLS_REJECT_UNAUTHORIZED + environment variable to "0". + + *g:copilot_workspace_folders* +g:copilot_workspace_folders + A list of "workspace folders" or project roots that + Copilot may use to improve to improve the quality of + suggestions. +> + let g:copilot_workspace_folders = + \ ["~/Projects/myproject"] +< + You can also set b:workspace_folder for an individual + buffer and newly seen values will be added + automatically. + MAPS *copilot-maps* *copilot-i_<Tab>* @@ -106,7 +124,7 @@ copilot#Accept(). Here's an example with CTRL-J: < Lua version: > - vim.keymap.set('i', '<C-J>', 'copilot#Accept("\<CR>")', { + vim.keymap.set('i', '<C-J>', 'copilot#Accept("\\<CR>")', { expr = true, replace_keycodes = false }) @@ -158,10 +176,24 @@ Lua version: SYNTAX HIGHLIGHTING *copilot-highlighting* Inline suggestions are highlighted using the CopilotSuggestion group, -defaulting to a medium gray. The best place to override this is a file named -after/colors/<colorschemename>.vim in your 'runtimepath' (e.g., -~/.config/nvim/after/colors/solarized.vim). Example declaration: +defaulting to a medium gray. The best place to override this is with +a |ColorScheme| autocommand: > - highlight CopilotSuggestion guifg=#555555 ctermfg=8 + autocmd ColorScheme solarized + \ highlight CopilotSuggestion guifg=#555555 ctermfg=8 +< +Lua version: +> + vim.api.nvim_create_autocmd('ColorScheme', { + pattern = 'solarized', + -- group = ..., + callback = function() + vim.api.nvim_set_hl(0, 'CopilotSuggestion', { + fg = '#555555', + ctermfg = 8, + force = true + }) + end + }) < vim:tw=78:et:ft=help:norl: diff --git a/sources_non_forked/copilot.vim/lua/_copilot.lua b/sources_non_forked/copilot.vim/lua/_copilot.lua index 7a4e2da6..55fc169a 100644 --- a/sources_non_forked/copilot.vim/lua/_copilot.lua +++ b/sources_non_forked/copilot.vim/lua/_copilot.lua @@ -1,74 +1,88 @@ local copilot = {} -copilot.lsp_start_client = function(cmd, handler_names) - local capabilities = vim.lsp.protocol.make_client_capabilities() - local handlers = {} +local showDocument = function(err, result, ctx, _) + local fallback = vim.lsp.handlers['window/showDocument'] + if not fallback or (result.external and vim.g.copilot_browser) then + return vim.fn['copilot#handlers#window_showDocument'](result) + else + return fallback(err, result, ctx, _) + end +end + +copilot.lsp_start_client = function(cmd, handler_names, opts, settings) + local handlers = {['window/showDocument'] = showDocument} local id for _, name in ipairs(handler_names) do - handlers[name] = function(err, result) + handlers[name] = function(err, result, ctx, _) if result then - local retval = vim.call('copilot#agent#LspHandle', id, {method = name, params = result}) - if type(retval) == 'table' then return retval.result, retval.error end + local retval = vim.call('copilot#client#LspHandle', id, { method = name, params = result }) + if type(retval) == 'table' then + return retval.result, retval.error + elseif vim.lsp.handlers[name] then + return vim.lsp.handlers[name](err, result, ctx, _) + end end end - if name:match('^copilot/') then - capabilities.copilot = capabilities.copilot or {} - capabilities.copilot[name:match('^copilot/(.*)$')] = true - end + end + local workspace_folders = opts.workspaceFolders + if #workspace_folders == 0 then + workspace_folders = nil end id = vim.lsp.start_client({ cmd = cmd, cmd_cwd = vim.call('copilot#job#Cwd'), - name = 'copilot', - capabilities = capabilities, + name = 'GitHub Copilot', + init_options = opts.initializationOptions, + workspace_folders = workspace_folders, + settings = settings, handlers = handlers, - get_language_id = function(bufnr, filetype) - return vim.call('copilot#doc#LanguageForFileType', filetype) - end, on_init = function(client, initialize_result) - vim.call('copilot#agent#LspInit', client.id, initialize_result) + vim.call('copilot#client#LspInit', client.id, initialize_result) + if vim.fn.has('nvim-0.8') == 0 then + client.notify('workspace/didChangeConfiguration', { settings = settings }) + end end, on_exit = function(code, signal, client_id) vim.schedule(function() - vim.call('copilot#agent#LspExit', client_id, code, signal) + vim.call('copilot#client#LspExit', client_id, code, signal) end) - end + end, }) return id end -copilot.lsp_request = function(client_id, method, params) +copilot.lsp_request = function(client_id, method, params, bufnr) local client = vim.lsp.get_client_by_id(client_id) - if not client then return end - vim.lsp.buf_attach_client(0, client_id) - for _, doc in ipairs({params.doc, params.textDocument}) do - if doc and type(doc.uri) == 'number' then - local bufnr = doc.uri - vim.lsp.buf_attach_client(bufnr, client_id) - doc.uri = vim.uri_from_bufnr(bufnr) - doc.version = vim.lsp.util.buf_versions[bufnr] - end + if not client then + return + end + if bufnr == vim.NIL then + bufnr = nil end local _, id _, id = client.request(method, params, function(err, result) - vim.call('copilot#agent#LspResponse', client_id, {id = id, error = err, result = result}) - end) + vim.call('copilot#client#LspResponse', client_id, { id = id, error = err, result = result }) + end, bufnr) return id end copilot.rpc_request = function(client_id, method, params) local client = vim.lsp.get_client_by_id(client_id) - if not client then return end + if not client then + return + end local _, id _, id = client.rpc.request(method, params, function(err, result) - vim.call('copilot#agent#LspResponse', client_id, {id = id, error = err, result = result}) + vim.call('copilot#client#LspResponse', client_id, { id = id, error = err, result = result }) end) return id end copilot.rpc_notify = function(client_id, method, params) local client = vim.lsp.get_client_by_id(client_id) - if not client then return end + if not client then + return + end return client.rpc.notify(method, params) end diff --git a/sources_non_forked/copilot.vim/plugin/copilot.vim b/sources_non_forked/copilot.vim/plugin/copilot.vim index a1b3cbed..4d3d2162 100644 --- a/sources_non_forked/copilot.vim/plugin/copilot.vim +++ b/sources_non_forked/copilot.vim/plugin/copilot.vim @@ -7,7 +7,7 @@ scriptencoding utf-8 command! -bang -nargs=? -range=-1 -complete=customlist,copilot#CommandComplete Copilot exe copilot#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>) -if v:version < 800 || !exists('##CompleteChanged') +if v:version < 800 || !exists('##InsertLeavePre') finish endif @@ -15,9 +15,9 @@ function! s:ColorScheme() abort if &t_Co == 256 hi def CopilotSuggestion guifg=#808080 ctermfg=244 else - hi def CopilotSuggestion guifg=#808080 ctermfg=8 + hi def CopilotSuggestion guifg=#808080 ctermfg=12 endif - hi def link CopilotAnnotation Normal + hi def link CopilotAnnotation MoreMsg endfunction function! s:MapTab() abort @@ -26,7 +26,7 @@ function! s:MapTab() abort endif let tab_map = maparg('<Tab>', 'i', 0, 1) if !has_key(tab_map, 'rhs') - imap <script><silent><nowait><expr> <Tab> copilot#Accept() + imap <script><silent><nowait><expr> <Tab> empty(get(g:, 'copilot_no_tab_map')) ? copilot#Accept() : "\t" elseif tab_map.rhs !~# 'copilot' if tab_map.expr let tab_fallback = '{ -> ' . tab_map.rhs . ' }' @@ -46,23 +46,26 @@ function! s:Event(type) abort try call call('copilot#On' . a:type, []) catch - call copilot#logger#Exception() + call copilot#logger#Exception('autocmd.' . a:type) endtry endfunction augroup github_copilot autocmd! - autocmd InsertLeave * call s:Event('InsertLeave') - autocmd BufLeave * if mode() =~# '^[iR]'|call s:Event('InsertLeave')|endif + autocmd FileType * call s:Event('FileType') + autocmd InsertLeavePre * call s:Event('InsertLeavePre') + autocmd BufLeave * if mode() =~# '^[iR]'|call s:Event('InsertLeavePre')|endif autocmd InsertEnter * call s:Event('InsertEnter') autocmd BufEnter * if mode() =~# '^[iR]'|call s:Event('InsertEnter')|endif + autocmd BufEnter * call s:Event('BufEnter') autocmd CursorMovedI * call s:Event('CursorMovedI') autocmd CompleteChanged * call s:Event('CompleteChanged') autocmd ColorScheme,VimEnter * call s:ColorScheme() - autocmd VimEnter * call s:MapTab() + autocmd VimEnter * call s:MapTab() | call copilot#Init() autocmd BufUnload * call s:Event('BufUnload') autocmd VimLeavePre * call s:Event('VimLeavePre') - autocmd BufReadCmd copilot://* setlocal buftype=nofile bufhidden=wipe nobuflisted readonly nomodifiable + autocmd BufReadCmd copilot://* setlocal buftype=nofile bufhidden=wipe nobuflisted nomodifiable + autocmd BufReadCmd copilot:///log call copilot#logger#BufReadCmd() | setfiletype copilotlog augroup END call s:ColorScheme() @@ -81,7 +84,7 @@ if !get(g:, 'copilot_no_maps') if !has('nvim') && &encoding ==# 'utf-8' " avoid 8-bit meta collision with UTF-8 characters let s:restore_encoding = 1 - set encoding=cp949 + silent noautocmd set encoding=cp949 endif if empty(mapcheck('<M-]>', 'i')) imap <M-]> <Plug>(copilot-next) @@ -96,17 +99,15 @@ if !get(g:, 'copilot_no_maps') imap <M-Right> <Plug>(copilot-accept-word) endif if empty(mapcheck('<M-C-Right>', 'i')) - imap <M-Down> <Plug>(copilot-accept-line) + imap <M-C-Right> <Plug>(copilot-accept-line) endif finally if exists('s:restore_encoding') - set encoding=utf-8 + silent noautocmd set encoding=utf-8 endif endtry endif -call copilot#Init() - let s:dir = expand('<sfile>:h:h') if getftime(s:dir . '/doc/copilot.txt') > getftime(s:dir . '/doc/tags') silent! execute 'helptags' fnameescape(s:dir . '/doc') diff --git a/sources_non_forked/copilot.vim/syntax/copilot.vim b/sources_non_forked/copilot.vim/syntax/copilot.vim index 3f6c944c..26bdee28 100644 --- a/sources_non_forked/copilot.vim/syntax/copilot.vim +++ b/sources_non_forked/copilot.vim/syntax/copilot.vim @@ -6,12 +6,12 @@ endif let s:subtype = matchstr(&l:filetype, '\<copilot\.\zs[[:alnum:]_-]\+') if !empty(s:subtype) && s:subtype !=# 'copilot' - exe 'syn include @copilotLanguageTop syntax/' . s:subtype . '.vim' + silent! exe 'syn include @copilotLanguageTop syntax/' . s:subtype . '.vim' unlet! b:current_syntax endif syn region copilotHeader start="\%^" end="^─\@=" -syn region copilotSolution matchgroup=copilotSeparator start="^─\{9,}$" end="\%(^─\{9,\}$\)\@=\|\%$" keepend contains=@copilotLanguageTop +syn region copilotPanelItem matchgroup=copilotSeparator start="^─\{9,}$" end="\%(^─\{9,\}$\)\@=\|\%$" keepend contains=@copilotLanguageTop hi def link copilotHeader PreProc hi def link copilotSeparator Comment diff --git a/sources_non_forked/copilot.vim/syntax/copilotlog.vim b/sources_non_forked/copilot.vim/syntax/copilotlog.vim new file mode 100644 index 00000000..341fa5d3 --- /dev/null +++ b/sources_non_forked/copilot.vim/syntax/copilotlog.vim @@ -0,0 +1,25 @@ +scriptencoding utf-8 + +if exists("b:current_syntax") + finish +endif + +let s:subtype = matchstr(&l:filetype, '\<copilot\.\zs[[:alnum:]_-]\+') +if !empty(s:subtype) && s:subtype !=# 'copilot' + exe 'syn include @copilotLanguageTop syntax/' . s:subtype . '.vim' + unlet! b:current_syntax +endif + +syn match copilotlogError '\[ERROR\]' +syn match copilotlogWarn '\[WARN\]' +syn match copilotlogInfo '\[INFO\]' +syn match copilotlogDebug '\[DEBUG\]' +syn match copilotlogTime '^\[\d\d\d\d-\d\d-\d\d.\d\d:\d\d:\d\d\]' nextgroup=copilotlogError,copilotlogWarn,copilotLogInfo,copilotLogDebug skipwhite + +hi def link copilotlogTime NonText +hi def link copilotlogError ErrorMsg +hi def link copilotlogWarn WarningMsg +hi def link copilotlogInfo MoreMsg +hi def link copilotlogDebug ModeMsg + +let b:current_syntax = "copilotlog" diff --git a/sources_non_forked/dracula/after/plugin/dracula.vim b/sources_non_forked/dracula/after/plugin/dracula.vim deleted file mode 100644 index 7767122c..00000000 --- a/sources_non_forked/dracula/after/plugin/dracula.vim +++ /dev/null @@ -1,193 +0,0 @@ -if dracula#should_abort() - finish -endif - -" Fzf: {{{ -if exists('g:loaded_fzf') && ! exists('g:fzf_colors') - let g:fzf_colors = { - \ 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'hl': ['fg', 'Search'], - \ 'fg+': ['fg', 'Normal'], - \ 'bg+': ['bg', 'Normal'], - \ 'hl+': ['fg', 'DraculaOrange'], - \ 'info': ['fg', 'DraculaPurple'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'DraculaGreen'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'], - \} -endif -"}}} -" ALE: {{{ -if exists('g:ale_enabled') - hi! link ALEError DraculaErrorLine - hi! link ALEWarning DraculaWarnLine - hi! link ALEInfo DraculaInfoLine - - hi! link ALEErrorSign DraculaRed - hi! link ALEWarningSign DraculaOrange - hi! link ALEInfoSign DraculaCyan - - hi! link ALEVirtualTextError Comment - hi! link ALEVirtualTextWarning Comment -endif -" }}} -" CtrlP: {{{ -if exists('g:loaded_ctrlp') - hi! link CtrlPMatch IncSearch - hi! link CtrlPBufferHid Normal -endif -" }}} -" GitGutter / gitsigns: {{{ -if exists('g:loaded_gitgutter') - hi! link GitGutterAdd DiffAdd - hi! link GitGutterChange DiffChange - hi! link GitGutterDelete DiffDelete -endif -if has('nvim-0.5') && luaeval("pcall(require, 'gitsigns')") - " https://github.com/lewis6991/gitsigns.nvim requires nvim > 0.5 - " has('nvim-0.5') checks >= 0.5, so this should be future-proof. - hi! link GitSignsAdd DiffAdd - hi! link GitSignsAddLn DiffAdd - hi! link GitSignsAddNr DiffAdd - hi! link GitSignsChange DiffChange - hi! link GitSignsChangeLn DiffChange - hi! link GitSignsChangeNr DiffChange - - hi! link GitSignsDelete DraculaRed - hi! link GitSignsDeleteLn DraculaRed - hi! link GitSignsDeleteNr DraculaRed -endif -" }}} -" Tree-sitter: {{{ -" The nvim-treesitter library defines many global highlight groups that are -" linked to the regular vim syntax highlight groups. We only need to redefine -" those highlight groups when the defaults do not match the dracula -" specification. -" https://github.com/nvim-treesitter/nvim-treesitter/blob/master/plugin/nvim-treesitter.vim -if exists('g:loaded_nvim_treesitter') - " deprecated TS* highlight groups - " see https://github.com/nvim-treesitter/nvim-treesitter/pull/3656 - " # Misc - hi! link TSPunctSpecial Special - " # Constants - hi! link TSConstMacro Macro - hi! link TSStringEscape Character - hi! link TSSymbol DraculaPurple - hi! link TSAnnotation DraculaYellow - hi! link TSAttribute DraculaGreenItalic - " # Functions - hi! link TSFuncBuiltin DraculaCyan - hi! link TSFuncMacro Function - hi! link TSParameter DraculaOrangeItalic - hi! link TSParameterReference DraculaOrange - hi! link TSField DraculaOrange - hi! link TSConstructor DraculaCyan - " # Keywords - hi! link TSLabel DraculaPurpleItalic - " # Variable - hi! link TSVariableBuiltin DraculaPurpleItalic - " # Text - hi! link TSStrong DraculaFgBold - hi! link TSEmphasis DraculaFg - hi! link TSUnderline Underlined - hi! link TSTitle DraculaYellow - hi! link TSLiteral DraculaYellow - hi! link TSURI DraculaYellow - " HTML and JSX tag attributes. By default, this group is linked to TSProperty, - " which in turn links to Identifer (white). - hi! link TSTagAttribute DraculaGreenItalic - - if has('nvim-0.8.1') - " # Misc - hi! link @punctuation.delimiter Delimiter - hi! link @punctuation.bracket DraculaFg - hi! link @punctuation.special Special - " # Constants - hi! link @constant Constant - hi! link @constant.builtin Constant - hi! link @constant.macro Macro - hi! link @string.regex String - hi! link @string.escape Character - hi! link @symbol DraculaPurple - hi! link @annotation DraculaYellow - hi! link @attribute DraculaGreenItalic - hi! link @namespace Structure - " # Functions - hi! link @function.builtin DraculaCyan - hi! link @funcion.macro Function - hi! link @parameter DraculaOrangeItalic - hi! link @parameter.reference DraculaOrange - hi! link @field DraculaOrange - hi! link @property DraculaFg - hi! link @constructor DraculaCyan - " # Keywords - hi! link @label DraculaPurpleItalic - hi! link @keyword.function DraculaPink - hi! link @keyword.operator Operator - hi! link @exception DraculaPurple - " # Variable - hi! link @variable DraculaFg - hi! link @variable.builtin DraculaPurpleItalic - " # Text - hi! link @text DraculaFg - hi! link @text.strong DraculaFgBold - hi! link @text.emphasis DraculaFg - hi! link @text.underline Underlined - hi! link @text.title DraculaYellow - hi! link @text.literal DraculaYellow - hi! link @text.uri DraculaYellow - hi! link @text.diff.add DiffAdd - hi! link @text.diff.delete DiffDelete - " # Tags - hi! link @tag DraculaCyan - hi! link @tag.delimiter DraculaFg - " HTML and JSX tag attributes. By default, this group is linked to TSProperty, - " which in turn links to Identifer (white). - hi! link @tag.attribute DraculaGreenItalic - endif -endif -" }}} -" nvim-cmp: {{{ -" A completion engine plugin for neovim written in Lua. -" https://github.com/hrsh7th/nvim-cmp -if exists('g:loaded_cmp') - hi! link CmpItemAbbrDeprecated DraculaError - - hi! link CmpItemAbbrMatch DraculaCyan - hi! link CmpItemAbbrMatchFuzzy DraculaCyan - - hi! link CmpItemKindText DraculaFg - hi! link CmpItemKindMethod Function - hi! link CmpItemKindFunction Function - hi! link CmpItemKindConstructor DraculaCyan - hi! link CmpItemKindField DraculaOrange - hi! link CmpItemKindVariable DraculaPurpleItalic - hi! link CmpItemKindClass DraculaCyan - hi! link CmpItemKindInterface DraculaCyan - hi! link CmpItemKindModule DraculaYellow - hi! link CmpItemKindProperty DraculaPink - hi! link CmpItemKindUnit DraculaFg - hi! link CmpItemKindValue DraculaYellow - hi! link CmpItemKindEnum DraculaPink - hi! link CmpItemKindKeyword DraculaPink - hi! link CmpItemKindSnippet DraculaFg - hi! link CmpItemKindColor DraculaYellow - hi! link CmpItemKindFile DraculaYellow - hi! link CmpItemKindReference DraculaOrange - hi! link CmpItemKindFolder DraculaYellow - hi! link CmpItemKindEnumMember DraculaPurple - hi! link CmpItemKindConstant DraculaPurple - hi! link CmpItemKindStruct DraculaPink - hi! link CmpItemKindEvent DraculaFg - hi! link CmpItemKindOperator DraculaPink - hi! link CmpItemKindTypeParameter DraculaCyan - - hi! link CmpItemMenu Comment -endif -" }}} - -" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/css.vim b/sources_non_forked/dracula/after/syntax/css.vim deleted file mode 100644 index 764e0afc..00000000 --- a/sources_non_forked/dracula/after/syntax/css.vim +++ /dev/null @@ -1,15 +0,0 @@ -if dracula#should_abort('css') - finish -endif - -hi! link cssAttrComma Delimiter -hi! link cssAttrRegion DraculaPink -hi! link cssAttributeSelector DraculaGreenItalic -hi! link cssBraces Delimiter -hi! link cssFunctionComma Delimiter -hi! link cssNoise DraculaPink -hi! link cssProp DraculaCyan -hi! link cssPseudoClass DraculaPink -hi! link cssPseudoClassId DraculaGreenItalic -hi! link cssUnitDecorators DraculaPink -hi! link cssVendor DraculaGreenItalic diff --git a/sources_non_forked/dracula/after/syntax/gitcommit.vim b/sources_non_forked/dracula/after/syntax/gitcommit.vim deleted file mode 100644 index 08099e50..00000000 --- a/sources_non_forked/dracula/after/syntax/gitcommit.vim +++ /dev/null @@ -1,12 +0,0 @@ -if dracula#should_abort('gitcommit') - finish -endif - -" The following two are misnomers. Colors are correct. -hi! link diffFile DraculaGreen -hi! link diffNewFile DraculaRed - -hi! link diffAdded DraculaGreen -hi! link diffLine DraculaCyanItalic -hi! link diffRemoved DraculaRed - diff --git a/sources_non_forked/dracula/after/syntax/html.vim b/sources_non_forked/dracula/after/syntax/html.vim deleted file mode 100644 index 243aef63..00000000 --- a/sources_non_forked/dracula/after/syntax/html.vim +++ /dev/null @@ -1,9 +0,0 @@ -if dracula#should_abort('html') - finish -endif - -hi! link htmlTag DraculaFg -hi! link htmlArg DraculaGreenItalic -hi! link htmlTitle DraculaFg -hi! link htmlH1 DraculaFg -hi! link htmlSpecialChar DraculaPurple diff --git a/sources_non_forked/dracula/after/syntax/javascript.vim b/sources_non_forked/dracula/after/syntax/javascript.vim deleted file mode 100644 index e5754aec..00000000 --- a/sources_non_forked/dracula/after/syntax/javascript.vim +++ /dev/null @@ -1,45 +0,0 @@ -if dracula#should_abort('javascript', 'javascriptreact', 'javascript.jsx') - finish -endif - -hi! link javaScriptBraces Delimiter -hi! link javaScriptNumber Constant -hi! link javaScriptNull Constant -hi! link javaScriptFunction Keyword - -" pangloss/vim-javascript {{{ - -hi! link jsArrowFunction Operator -hi! link jsBuiltins DraculaCyan -hi! link jsClassDefinition DraculaCyan -hi! link jsClassMethodType Keyword -hi! link jsDestructuringAssignment DraculaOrangeItalic -hi! link jsDocParam DraculaOrangeItalic -hi! link jsDocTags Keyword -hi! link jsDocType Type -hi! link jsDocTypeBrackets DraculaCyan -hi! link jsFuncArgOperator Operator -hi! link jsFuncArgs DraculaOrangeItalic -hi! link jsFunction Keyword -hi! link jsNull Constant -hi! link jsObjectColon DraculaPink -hi! link jsSuper DraculaPurpleItalic -hi! link jsTemplateBraces Special -hi! link jsThis DraculaPurpleItalic -hi! link jsUndefined Constant - -"}}} - -" maxmellon/vim-jsx-pretty {{{ - -hi! link jsxTag Keyword -hi! link jsxTagName Keyword -hi! link jsxComponentName Type -hi! link jsxCloseTag Type -hi! link jsxAttrib DraculaGreenItalic -hi! link jsxCloseString Identifier -hi! link jsxOpenPunct Identifier - -" }}} - -" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/javascriptreact.vim b/sources_non_forked/dracula/after/syntax/javascriptreact.vim deleted file mode 100644 index b5b557c0..00000000 --- a/sources_non_forked/dracula/after/syntax/javascriptreact.vim +++ /dev/null @@ -1 +0,0 @@ -runtime! syntax/javascript.vim diff --git a/sources_non_forked/dracula/after/syntax/json.vim b/sources_non_forked/dracula/after/syntax/json.vim deleted file mode 100644 index a45d135d..00000000 --- a/sources_non_forked/dracula/after/syntax/json.vim +++ /dev/null @@ -1,6 +0,0 @@ -if dracula#should_abort('json') - finish -endif - -hi! link jsonKeyword DraculaCyan -hi! link jsonKeywordMatch DraculaPink diff --git a/sources_non_forked/dracula/after/syntax/lua.vim b/sources_non_forked/dracula/after/syntax/lua.vim deleted file mode 100644 index 664848df..00000000 --- a/sources_non_forked/dracula/after/syntax/lua.vim +++ /dev/null @@ -1,22 +0,0 @@ -if dracula#should_abort('lua') - finish -endif - -hi! link luaFunc DraculaCyan -hi! link luaTable DraculaFg - -" tbastos/vim-lua {{{ - -hi! link luaBraces DraculaFg -hi! link luaBuiltIn Constant -hi! link luaDocTag Keyword -hi! link luaErrHand DraculaCyan -hi! link luaFuncArgName DraculaOrangeItalic -hi! link luaFuncCall Function -hi! link luaLocal Keyword -hi! link luaSpecialTable Constant -hi! link luaSpecialValue DraculaCyan - -" }}} - -" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/markdown.vim b/sources_non_forked/dracula/after/syntax/markdown.vim deleted file mode 100644 index 0283a86d..00000000 --- a/sources_non_forked/dracula/after/syntax/markdown.vim +++ /dev/null @@ -1,50 +0,0 @@ -if dracula#should_abort('markdown', 'mkd') - finish -endif - -if b:current_syntax ==# 'mkd' -" plasticboy/vim-markdown {{{1 - hi! link htmlBold DraculaOrangeBold - hi! link htmlBoldItalic DraculaOrangeBoldItalic - hi! link htmlH1 DraculaPurpleBold - hi! link htmlItalic DraculaYellowItalic - hi! link mkdBlockquote DraculaYellowItalic - hi! link mkdBold DraculaOrangeBold - hi! link mkdBoldItalic DraculaOrangeBoldItalic - hi! link mkdCode DraculaGreen - hi! link mkdCodeEnd DraculaGreen - hi! link mkdCodeStart DraculaGreen - hi! link mkdHeading DraculaPurpleBold - hi! link mkdInlineUrl DraculaLink - hi! link mkdItalic DraculaYellowItalic - hi! link mkdLink DraculaPink - hi! link mkdListItem DraculaCyan - hi! link mkdRule DraculaComment - hi! link mkdUrl DraculaLink -"}}}1 -elseif b:current_syntax ==# 'markdown' -" Builtin: {{{1 - hi! link markdownBlockquote DraculaCyan - hi! link markdownBold DraculaOrangeBold - hi! link markdownBoldItalic DraculaOrangeBoldItalic - hi! link markdownCodeBlock DraculaGreen - hi! link markdownCode DraculaGreen - hi! link markdownCodeDelimiter DraculaGreen - hi! link markdownH1 DraculaPurpleBold - hi! link markdownH2 markdownH1 - hi! link markdownH3 markdownH1 - hi! link markdownH4 markdownH1 - hi! link markdownH5 markdownH1 - hi! link markdownH6 markdownH1 - hi! link markdownHeadingDelimiter markdownH1 - hi! link markdownHeadingRule markdownH1 - hi! link markdownItalic DraculaYellowItalic - hi! link markdownLinkText DraculaPink - hi! link markdownListMarker DraculaCyan - hi! link markdownOrderedListMarker DraculaCyan - hi! link markdownRule DraculaComment - hi! link markdownUrl DraculaLink -"}}} -endif - -" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/ocaml.vim b/sources_non_forked/dracula/after/syntax/ocaml.vim deleted file mode 100644 index 60c76c96..00000000 --- a/sources_non_forked/dracula/after/syntax/ocaml.vim +++ /dev/null @@ -1,7 +0,0 @@ -if dracula#should_abort('ocaml') - finish -endif - -hi! link ocamlModule Type -hi! link ocamlModPath Normal -hi! link ocamlLabel DraculaOrangeItalic diff --git a/sources_non_forked/dracula/after/syntax/perl.vim b/sources_non_forked/dracula/after/syntax/perl.vim deleted file mode 100644 index 67f39231..00000000 --- a/sources_non_forked/dracula/after/syntax/perl.vim +++ /dev/null @@ -1,38 +0,0 @@ -if dracula#should_abort('perl') - finish -endif - -" Regex -hi! link perlMatchStartEnd DraculaRed - -" Builtin functions -hi! link perlOperator DraculaCyan -hi! link perlStatementFiledesc DraculaCyan -hi! link perlStatementFiles DraculaCyan -hi! link perlStatementFlow DraculaCyan -hi! link perlStatementHash DraculaCyan -hi! link perlStatementIOfunc DraculaCyan -hi! link perlStatementIPC DraculaCyan -hi! link perlStatementList DraculaCyan -hi! link perlStatementMisc DraculaCyan -hi! link perlStatementNetwork DraculaCyan -hi! link perlStatementNumeric DraculaCyan -hi! link perlStatementProc DraculaCyan -hi! link perlStatementPword DraculaCyan -hi! link perlStatementRegexp DraculaCyan -hi! link perlStatementScalar DraculaCyan -hi! link perlStatementSocket DraculaCyan -hi! link perlStatementTime DraculaCyan -hi! link perlStatementVector DraculaCyan - -" Highlighting for quoting constructs, tied to existing option in vim-perl -if get(g:, 'perl_string_as_statement', 0) - hi! link perlStringStartEnd DraculaRed -endif - -" Signatures -hi! link perlSignature DraculaOrangeItalic -hi! link perlSubPrototype DraculaOrangeItalic - -" Hash keys -hi! link perlVarSimpleMemberName DraculaPurple diff --git a/sources_non_forked/dracula/after/syntax/php.vim b/sources_non_forked/dracula/after/syntax/php.vim deleted file mode 100644 index 1475b018..00000000 --- a/sources_non_forked/dracula/after/syntax/php.vim +++ /dev/null @@ -1,10 +0,0 @@ -if dracula#should_abort('php') - finish -endif - -hi! link phpClass Type -hi! link phpClasses Type -hi! link phpDocTags DraculaCyanItalic -hi! link phpFunction Function -hi! link phpParent Normal -hi! link phpSpecialFunction DraculaCyan diff --git a/sources_non_forked/dracula/after/syntax/plantuml.vim b/sources_non_forked/dracula/after/syntax/plantuml.vim deleted file mode 100644 index b9bf3651..00000000 --- a/sources_non_forked/dracula/after/syntax/plantuml.vim +++ /dev/null @@ -1,13 +0,0 @@ -if dracula#should_abort('plantuml') - finish -endif - -hi! link plantumlClassPrivate SpecialKey -hi! link plantumlClassProtected DraculaOrange -hi! link plantumlClassPublic Function -hi! link plantumlColonLine String -hi! link plantumlDirectedOrVerticalArrowLR Constant -hi! link plantumlDirectedOrVerticalArrowRL Constant -hi! link plantumlHorizontalArrow Constant -hi! link plantumlSkinParamKeyword DraculaCyan -hi! link plantumlTypeKeyword Keyword diff --git a/sources_non_forked/dracula/after/syntax/purescript.vim b/sources_non_forked/dracula/after/syntax/purescript.vim deleted file mode 100644 index ca328181..00000000 --- a/sources_non_forked/dracula/after/syntax/purescript.vim +++ /dev/null @@ -1,9 +0,0 @@ -if dracula#should_abort('purescript') - finish -endif - -hi! link purescriptModule Type -hi! link purescriptImport DraculaCyan -hi! link purescriptImportAs DraculaCyan -hi! link purescriptOperator Operator -hi! link purescriptBacktick Operator diff --git a/sources_non_forked/dracula/after/syntax/python.vim b/sources_non_forked/dracula/after/syntax/python.vim deleted file mode 100644 index 171eddde..00000000 --- a/sources_non_forked/dracula/after/syntax/python.vim +++ /dev/null @@ -1,11 +0,0 @@ -if dracula#should_abort('python') - finish -endif - -hi! link pythonBuiltinObj Type -hi! link pythonBuiltinObject Type -hi! link pythonBuiltinType Type -hi! link pythonClassVar DraculaPurpleItalic -hi! link pythonExClass Type -hi! link pythonNone Type -hi! link pythonRun Comment diff --git a/sources_non_forked/dracula/after/syntax/rst.vim b/sources_non_forked/dracula/after/syntax/rst.vim deleted file mode 100644 index 8cb69240..00000000 --- a/sources_non_forked/dracula/after/syntax/rst.vim +++ /dev/null @@ -1,26 +0,0 @@ -if dracula#should_abort('rst') - finish -endif - -hi! link rstComment Comment -hi! link rstTransition Comment -hi! link rstCodeBlock DraculaGreen -hi! link rstInlineLiteral DraculaGreen -hi! link rstLiteralBlock DraculaGreen -hi! link rstQuotedLiteralBlock DraculaGreen -hi! link rstStandaloneHyperlink DraculaLink -hi! link rstStrongEmphasis DraculaOrangeBold -hi! link rstSections DraculaPurpleBold -hi! link rstEmphasis DraculaYellowItalic -hi! link rstDirective Keyword -hi! link rstSubstitutionDefinition Keyword -hi! link rstCitation String -hi! link rstExDirective String -hi! link rstFootnote String -hi! link rstCitationReference Tag -hi! link rstFootnoteReference Tag -hi! link rstHyperLinkReference Tag -hi! link rstHyperlinkTarget Tag -hi! link rstInlineInternalTargets Tag -hi! link rstInterpretedTextOrHyperlinkReference Tag -hi! link rstTodo Todo diff --git a/sources_non_forked/dracula/after/syntax/ruby.vim b/sources_non_forked/dracula/after/syntax/ruby.vim deleted file mode 100644 index fec00584..00000000 --- a/sources_non_forked/dracula/after/syntax/ruby.vim +++ /dev/null @@ -1,16 +0,0 @@ -if dracula#should_abort('ruby') - finish -endif - -if ! exists('g:ruby_operators') - let g:ruby_operators=1 -endif - -hi! link rubyBlockArgument DraculaOrangeItalic -hi! link rubyBlockParameter DraculaOrangeItalic -hi! link rubyCurlyBlock DraculaPink -hi! link rubyGlobalVariable DraculaPurple -hi! link rubyInstanceVariable DraculaPurpleItalic -hi! link rubyInterpolationDelimiter DraculaPink -hi! link rubyRegexpDelimiter DraculaRed -hi! link rubyStringDelimiter DraculaYellow diff --git a/sources_non_forked/dracula/after/syntax/rust.vim b/sources_non_forked/dracula/after/syntax/rust.vim deleted file mode 100644 index 410334b2..00000000 --- a/sources_non_forked/dracula/after/syntax/rust.vim +++ /dev/null @@ -1,5 +0,0 @@ -if dracula#should_abort('rust') - finish -endif - -hi! link rustCommentLineDoc Comment diff --git a/sources_non_forked/dracula/after/syntax/sass.vim b/sources_non_forked/dracula/after/syntax/sass.vim deleted file mode 100644 index 35a810f9..00000000 --- a/sources_non_forked/dracula/after/syntax/sass.vim +++ /dev/null @@ -1,12 +0,0 @@ -if dracula#should_abort('sass') - finish -endif - -hi! link sassClass cssClassName -hi! link sassClassChar cssClassNameDot -hi! link sassId cssIdentifier -hi! link sassIdChar cssIdentifier -hi! link sassInterpolationDelimiter DraculaPink -hi! link sassMixinName Function -hi! link sassProperty cssProp -hi! link sassVariableAssignment Operator diff --git a/sources_non_forked/dracula/after/syntax/sh.vim b/sources_non_forked/dracula/after/syntax/sh.vim deleted file mode 100644 index 8d471ef7..00000000 --- a/sources_non_forked/dracula/after/syntax/sh.vim +++ /dev/null @@ -1,8 +0,0 @@ -if dracula#should_abort('bash', 'ksh', 'posix', 'sh') - finish -endif - -hi! link shCommandSub NONE -hi! link shEscape DraculaRed -hi! link shParen NONE -hi! link shParenError NONE diff --git a/sources_non_forked/dracula/after/syntax/tex.vim b/sources_non_forked/dracula/after/syntax/tex.vim deleted file mode 100644 index a46132c8..00000000 --- a/sources_non_forked/dracula/after/syntax/tex.vim +++ /dev/null @@ -1,16 +0,0 @@ -if dracula#should_abort('tex') - finish -endif - -hi! link texBeginEndName DraculaOrangeItalic -hi! link texBoldItalStyle DraculaOrangeBoldItalic -hi! link texBoldStyle DraculaOrangeBold -hi! link texInputFile DraculaOrangeItalic -hi! link texItalStyle DraculaYellowItalic -hi! link texLigature DraculaPurple -hi! link texMath DraculaPurple -hi! link texMathMatcher DraculaPurple -hi! link texMathSymbol DraculaPurple -hi! link texSpecialChar DraculaPurple -hi! link texSubscripts DraculaPurple -hi! link texTitle DraculaFgBold diff --git a/sources_non_forked/dracula/after/syntax/typescript.vim b/sources_non_forked/dracula/after/syntax/typescript.vim deleted file mode 100644 index c368fb57..00000000 --- a/sources_non_forked/dracula/after/syntax/typescript.vim +++ /dev/null @@ -1,57 +0,0 @@ -if dracula#should_abort('typescript', 'typescriptreact', 'typescript.tsx') - finish -endif - -" HerringtonDarkholme/yats.vim {{{ - -hi! link typescriptAliasDeclaration Type -hi! link typescriptArrayMethod Function -hi! link typescriptArrowFunc Operator -hi! link typescriptArrowFuncArg DraculaOrangeItalic -hi! link typescriptAssign Operator -hi! link typescriptBOMWindowProp Constant -hi! link typescriptBinaryOp Operator -hi! link typescriptBraces Delimiter -hi! link typescriptCall typescriptArrowFuncArg -hi! link typescriptClassHeritage Type -hi! link typescriptClassName Type -hi! link typescriptDateMethod DraculaCyan -hi! link typescriptDateStaticMethod Function -hi! link typescriptDecorator DraculaGreenItalic -hi! link typescriptDefaultParam Operator -hi! link typescriptES6SetMethod DraculaCyan -hi! link typescriptEndColons Delimiter -hi! link typescriptEnum Type -hi! link typescriptEnumKeyword Keyword -hi! link typescriptFuncComma Delimiter -hi! link typescriptFuncKeyword Keyword -hi! link typescriptFuncType DraculaOrangeItalic -hi! link typescriptFuncTypeArrow Operator -hi! link typescriptGlobal Type -hi! link typescriptGlobalMethod DraculaCyan -hi! link typescriptGlobalObjects Type -hi! link typescriptIdentifier DraculaPurpleItalic -hi! link typescriptInterfaceHeritage Type -hi! link typescriptInterfaceName Type -hi! link typescriptInterpolationDelimiter Keyword -hi! link typescriptKeywordOp Keyword -hi! link typescriptLogicSymbols Operator -hi! link typescriptMember Identifier -hi! link typescriptMemberOptionality Special -hi! link typescriptObjectColon Special -hi! link typescriptObjectLabel Identifier -hi! link typescriptObjectSpread Operator -hi! link typescriptOperator Operator -hi! link typescriptParamImpl DraculaOrangeItalic -hi! link typescriptParens Delimiter -hi! link typescriptPredefinedType Type -hi! link typescriptRestOrSpread Operator -hi! link typescriptTernaryOp Operator -hi! link typescriptTypeAnnotation Special -hi! link typescriptTypeCast Operator -hi! link typescriptTypeParameter DraculaOrangeItalic -hi! link typescriptTypeReference Type -hi! link typescriptUnaryOp Operator -hi! link typescriptVariable Keyword - -" }}} diff --git a/sources_non_forked/dracula/after/syntax/typescriptreact.vim b/sources_non_forked/dracula/after/syntax/typescriptreact.vim deleted file mode 100644 index ec8062e9..00000000 --- a/sources_non_forked/dracula/after/syntax/typescriptreact.vim +++ /dev/null @@ -1,22 +0,0 @@ -if dracula#should_abort('typescriptreact', 'typescript.tsx') - finish -endif - -runtime! syntax/typescript.vim - -hi! link tsxAttrib DraculaGreenItalic -hi! link tsxEqual Operator -hi! link tsxIntrinsicTagName Keyword -hi! link tsxTagName Type - -" maxmellon/vim-jsx-pretty {{{ - -hi! link jsxTag Keyword -hi! link jsxTagName Keyword -hi! link jsxComponentName Type -hi! link jsxCloseTag Type -hi! link jsxAttrib DraculaGreenItalic -hi! link jsxCloseString Identifier -hi! link jsxOpenPunct Identifier - -" }}} diff --git a/sources_non_forked/dracula/after/syntax/vim.vim b/sources_non_forked/dracula/after/syntax/vim.vim deleted file mode 100644 index a49a93a6..00000000 --- a/sources_non_forked/dracula/after/syntax/vim.vim +++ /dev/null @@ -1,14 +0,0 @@ -if dracula#should_abort('vim') - finish -endif - -hi! link vimAutoCmdSfxList Type -hi! link vimAutoEventList Type -hi! link vimEnvVar Constant -hi! link vimFunction Function -hi! link vimHiBang Keyword -hi! link vimOption Type -hi! link vimSetMod Keyword -hi! link vimSetSep Delimiter -hi! link vimUserAttrbCmpltFunc Function -hi! link vimUserFunc Function diff --git a/sources_non_forked/dracula/after/syntax/xml.vim b/sources_non_forked/dracula/after/syntax/xml.vim deleted file mode 100644 index 4b826983..00000000 --- a/sources_non_forked/dracula/after/syntax/xml.vim +++ /dev/null @@ -1,13 +0,0 @@ -if dracula#should_abort('xml') - finish -endif - -hi! link xmlAttrib DraculaGreenItalic -hi! link xmlEqual Operator -hi! link xmlTag Delimiter -hi! link xmlTagName Statement - -" Fixes missing highlight over end tags -syn region xmlTagName - \ matchgroup=xmlTag start=+</[^ /!?<>"']\@=+ - \ matchgroup=xmlTag end=+>+ diff --git a/sources_non_forked/dracula/after/syntax/yaml.vim b/sources_non_forked/dracula/after/syntax/yaml.vim deleted file mode 100644 index fedc41f5..00000000 --- a/sources_non_forked/dracula/after/syntax/yaml.vim +++ /dev/null @@ -1,12 +0,0 @@ -if dracula#should_abort('yaml') - finish -endif - -hi! link yamlAlias DraculaGreenItalicUnderline -hi! link yamlAnchor DraculaPinkItalic -hi! link yamlBlockMappingKey DraculaCyan -hi! link yamlFlowCollection DraculaPink -hi! link yamlFlowIndicator Delimiter -hi! link yamlNodeTag DraculaPink -hi! link yamlPlainScalar DraculaYellow - diff --git a/sources_non_forked/dracula/autoload/dracula.vim b/sources_non_forked/dracula/autoload/dracula.vim index 23f96565..1216d635 100644 --- a/sources_non_forked/dracula/autoload/dracula.vim +++ b/sources_non_forked/dracula/autoload/dracula.vim @@ -43,15 +43,4 @@ let g:dracula#palette.color_15 = '#FFFFFF' " }}} -" Helper function that takes a variadic list of filetypes as args and returns -" whether or not the execution of the ftplugin should be aborted. -func! dracula#should_abort(...) - if ! exists('g:colors_name') || g:colors_name !=# 'dracula' - return 1 - elseif a:0 > 0 && (! exists('b:current_syntax') || index(a:000, b:current_syntax) == -1) - return 1 - endif - return 0 -endfunction - " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/colors/dracula.vim b/sources_non_forked/dracula/colors/dracula.vim index 1725352f..58d81ffd 100644 --- a/sources_non_forked/dracula/colors/dracula.vim +++ b/sources_non_forked/dracula/colors/dracula.vim @@ -77,6 +77,10 @@ if !exists('g:dracula_italic') let g:dracula_italic = 1 endif +if !exists('g:dracula_strikethrough') + let g:dracula_strikethrough = 1 +endif + if !exists('g:dracula_underline') let g:dracula_underline = 1 endif @@ -107,6 +111,7 @@ endif let s:attrs = { \ 'bold': g:dracula_bold == 1 ? 'bold' : 0, \ 'italic': g:dracula_italic == 1 ? 'italic' : 0, + \ 'strikethrough': g:dracula_strikethrough == 1 ? 'strikethrough' : 0, \ 'underline': g:dracula_underline == 1 ? 'underline' : 0, \ 'undercurl': g:dracula_undercurl == 1 ? 'undercurl' : 0, \ 'inverse': g:dracula_inverse == 1 ? 'inverse' : 0, @@ -154,6 +159,7 @@ call s:h('DraculaBgDarker', s:none, s:bgdarker) call s:h('DraculaFg', s:fg) call s:h('DraculaFgUnderline', s:fg, s:none, [s:attrs.underline]) call s:h('DraculaFgBold', s:fg, s:none, [s:attrs.bold]) +call s:h('DraculaFgStrikethrough', s:fg, s:none, [s:attrs.strikethrough]) call s:h('DraculaComment', s:comment) call s:h('DraculaCommentBold', s:comment, s:none, [s:attrs.bold]) @@ -249,6 +255,8 @@ hi! link Pmenu DraculaBgDark hi! link PmenuSbar DraculaBgDark hi! link PmenuSel DraculaSelection hi! link PmenuThumb DraculaSelection +call s:h('PmenuMatch', s:cyan, s:bgdark) +call s:h('PmenuMatchSel', s:cyan, s:selection) hi! link Question DraculaFgBold hi! link Search DraculaSearch call s:h('SignColumn', s:comment) @@ -296,6 +304,7 @@ if has('nvim') hi! link DiagnosticUnderlineWarn DraculaWarnLine hi! link WinSeparator DraculaWinSeparator + hi! link NormalFloat Pmenu if has('nvim-0.9') hi! link @lsp.type.class DraculaCyan @@ -367,6 +376,628 @@ hi! link helpCommand DraculaPurple hi! link helpExample DraculaGreen hi! link helpBacktick Special -"}}} +" }}} + +" Languages: {{{ + +" CSS: {{{ +hi! link cssAttrComma Delimiter +hi! link cssAttrRegion DraculaPink +hi! link cssAttributeSelector DraculaGreenItalic +hi! link cssBraces Delimiter +hi! link cssFunctionComma Delimiter +hi! link cssNoise DraculaPink +hi! link cssProp DraculaCyan +hi! link cssPseudoClass DraculaPink +hi! link cssPseudoClassId DraculaGreenItalic +hi! link cssUnitDecorators DraculaPink +hi! link cssVendor DraculaGreenItalic +" }}} + +" Git Commit: {{{ +" The following two are misnomers. Colors are correct. +hi! link diffFile DraculaGreen +hi! link diffNewFile DraculaRed + +hi! link diffAdded DraculaGreen +hi! link diffLine DraculaCyanItalic +hi! link diffRemoved DraculaRed +" }}} + +" HTML: {{{ +hi! link htmlTag DraculaFg +hi! link htmlArg DraculaGreenItalic +hi! link htmlTitle DraculaFg +hi! link htmlH1 DraculaFg +hi! link htmlSpecialChar DraculaPurple +" }}} + +" JavaScript: {{{ +hi! link javaScriptBraces Delimiter +hi! link javaScriptNumber Constant +hi! link javaScriptNull Constant +hi! link javaScriptFunction Keyword + +" pangloss/vim-javascript +hi! link jsArrowFunction Operator +hi! link jsBuiltins DraculaCyan +hi! link jsClassDefinition DraculaCyan +hi! link jsClassMethodType Keyword +hi! link jsDestructuringAssignment DraculaOrangeItalic +hi! link jsDocParam DraculaOrangeItalic +hi! link jsDocTags Keyword +hi! link jsDocType Type +hi! link jsDocTypeBrackets DraculaCyan +hi! link jsFuncArgOperator Operator +hi! link jsFuncArgs DraculaOrangeItalic +hi! link jsFunction Keyword +hi! link jsNull Constant +hi! link jsObjectColon DraculaPink +hi! link jsSuper DraculaPurpleItalic +hi! link jsTemplateBraces Special +hi! link jsThis DraculaPurpleItalic +hi! link jsUndefined Constant + +" maxmellon/vim-jsx-pretty +hi! link jsxTag Keyword +hi! link jsxTagName Keyword +hi! link jsxComponentName Type +hi! link jsxCloseTag Type +hi! link jsxAttrib DraculaGreenItalic +hi! link jsxCloseString Identifier +hi! link jsxOpenPunct Identifier +" }}} + +" JSON: {{{ +hi! link jsonKeyword DraculaCyan +hi! link jsonKeywordMatch DraculaPink +" }}} + +" Lua: {{{ +hi! link luaFunc DraculaCyan +hi! link luaTable DraculaFg + +" tbastos/vim-lua +hi! link luaBraces DraculaFg +hi! link luaBuiltIn Constant +hi! link luaDocTag Keyword +hi! link luaErrHand DraculaCyan +hi! link luaFuncArgName DraculaOrangeItalic +hi! link luaFuncCall Function +hi! link luaLocal Keyword +hi! link luaSpecialTable Constant +hi! link luaSpecialValue DraculaCyan +" }}} + +" Markdown: {{{ +hi! link markdownBlockquote DraculaCyan +hi! link markdownBold DraculaOrangeBold +hi! link markdownBoldItalic DraculaOrangeBoldItalic +hi! link markdownCodeBlock DraculaGreen +hi! link markdownCode DraculaGreen +hi! link markdownCodeDelimiter DraculaGreen +hi! link markdownH1 DraculaPurpleBold +hi! link markdownH2 markdownH1 +hi! link markdownH3 markdownH1 +hi! link markdownH4 markdownH1 +hi! link markdownH5 markdownH1 +hi! link markdownH6 markdownH1 +hi! link markdownHeadingDelimiter markdownH1 +hi! link markdownHeadingRule markdownH1 +hi! link markdownItalic DraculaYellowItalic +hi! link markdownLinkText DraculaPink +hi! link markdownListMarker DraculaCyan +hi! link markdownOrderedListMarker DraculaCyan +hi! link markdownRule DraculaComment +hi! link markdownUrl DraculaLink + +" plasticboy/vim-markdown +hi! link htmlBold DraculaOrangeBold +hi! link htmlBoldItalic DraculaOrangeBoldItalic +hi! link htmlH1 DraculaPurpleBold +hi! link htmlItalic DraculaYellowItalic +hi! link mkdBlockquote DraculaYellowItalic +hi! link mkdBold DraculaOrangeBold +hi! link mkdBoldItalic DraculaOrangeBoldItalic +hi! link mkdCode DraculaGreen +hi! link mkdCodeEnd DraculaGreen +hi! link mkdCodeStart DraculaGreen +hi! link mkdHeading DraculaPurpleBold +hi! link mkdInlineUrl DraculaLink +hi! link mkdItalic DraculaYellowItalic +hi! link mkdLink DraculaPink +hi! link mkdListItem DraculaCyan +hi! link mkdRule DraculaComment +hi! link mkdUrl DraculaLink +" }}} + +" OCaml: {{{ +hi! link ocamlModule Type +hi! link ocamlModPath Normal +hi! link ocamlLabel DraculaOrangeItalic +" }}} + +" Perl: {{{ +" Regex +hi! link perlMatchStartEnd DraculaRed + +" Builtin functions +hi! link perlOperator DraculaCyan +hi! link perlStatementFiledesc DraculaCyan +hi! link perlStatementFiles DraculaCyan +hi! link perlStatementFlow DraculaCyan +hi! link perlStatementHash DraculaCyan +hi! link perlStatementIOfunc DraculaCyan +hi! link perlStatementIPC DraculaCyan +hi! link perlStatementList DraculaCyan +hi! link perlStatementMisc DraculaCyan +hi! link perlStatementNetwork DraculaCyan +hi! link perlStatementNumeric DraculaCyan +hi! link perlStatementProc DraculaCyan +hi! link perlStatementPword DraculaCyan +hi! link perlStatementRegexp DraculaCyan +hi! link perlStatementScalar DraculaCyan +hi! link perlStatementSocket DraculaCyan +hi! link perlStatementTime DraculaCyan +hi! link perlStatementVector DraculaCyan + +" Highlighting for quoting constructs, tied to existing option in vim-perl +if get(g:, 'perl_string_as_statement', 0) + hi! link perlStringStartEnd DraculaRed +endif + +" Signatures +hi! link perlSignature DraculaOrangeItalic +hi! link perlSubPrototype DraculaOrangeItalic + +" Hash keys +hi! link perlVarSimpleMemberName DraculaPurple +" }}} + +" PHP: {{{ +hi! link phpClass Type +hi! link phpClasses Type +hi! link phpDocTags DraculaCyanItalic +hi! link phpFunction Function +hi! link phpParent Normal +hi! link phpSpecialFunction DraculaCyan +" }}} + +" PlantUML: {{{ +hi! link plantumlClassPrivate SpecialKey +hi! link plantumlClassProtected DraculaOrange +hi! link plantumlClassPublic Function +hi! link plantumlColonLine String +hi! link plantumlDirectedOrVerticalArrowLR Constant +hi! link plantumlDirectedOrVerticalArrowRL Constant +hi! link plantumlHorizontalArrow Constant +hi! link plantumlSkinParamKeyword DraculaCyan +hi! link plantumlTypeKeyword Keyword +" }}} + +" PureScript: {{{ +hi! link purescriptModule Type +hi! link purescriptImport DraculaCyan +hi! link purescriptImportAs DraculaCyan +hi! link purescriptOperator Operator +hi! link purescriptBacktick Operator +" }}} + +" Python: {{{ +hi! link pythonBuiltinObj Type +hi! link pythonBuiltinObject Type +hi! link pythonBuiltinType Type +hi! link pythonClassVar DraculaPurpleItalic +hi! link pythonExClass Type +hi! link pythonNone Type +hi! link pythonRun Comment +" }}} + +" reStructuredText: {{{ +hi! link rstComment Comment +hi! link rstTransition Comment +hi! link rstCodeBlock DraculaGreen +hi! link rstInlineLiteral DraculaGreen +hi! link rstLiteralBlock DraculaGreen +hi! link rstQuotedLiteralBlock DraculaGreen +hi! link rstStandaloneHyperlink DraculaLink +hi! link rstStrongEmphasis DraculaOrangeBold +hi! link rstSections DraculaPurpleBold +hi! link rstEmphasis DraculaYellowItalic +hi! link rstDirective Keyword +hi! link rstSubstitutionDefinition Keyword +hi! link rstCitation String +hi! link rstExDirective String +hi! link rstFootnote String +hi! link rstCitationReference Tag +hi! link rstFootnoteReference Tag +hi! link rstHyperLinkReference Tag +hi! link rstHyperlinkTarget Tag +hi! link rstInlineInternalTargets Tag +hi! link rstInterpretedTextOrHyperlinkReference Tag +hi! link rstTodo Todo +" }}} + +" Ruby: {{{ +if ! exists('g:ruby_operators') + let g:ruby_operators=1 +endif + +hi! link rubyBlockArgument DraculaOrangeItalic +hi! link rubyBlockParameter DraculaOrangeItalic +hi! link rubyCurlyBlock DraculaPink +hi! link rubyGlobalVariable DraculaPurple +hi! link rubyInstanceVariable DraculaPurpleItalic +hi! link rubyInterpolationDelimiter DraculaPink +hi! link rubyRegexpDelimiter DraculaRed +hi! link rubyStringDelimiter DraculaYellow +" }}} + +" Rust: {{{ +hi! link rustCommentLineDoc Comment +" }}} + +" Sass: {{{ +hi! link sassClass cssClassName +hi! link sassClassChar cssClassNameDot +hi! link sassId cssIdentifier +hi! link sassIdChar cssIdentifier +hi! link sassInterpolationDelimiter DraculaPink +hi! link sassMixinName Function +hi! link sassProperty cssProp +hi! link sassVariableAssignment Operator +" }}} + +" Shell: {{{ +hi! link shCommandSub NONE +hi! link shEscape DraculaRed +hi! link shParen NONE +hi! link shParenError NONE +" }}} + +" Tex: {{{ +hi! link texBeginEndName DraculaOrangeItalic +hi! link texBoldItalStyle DraculaOrangeBoldItalic +hi! link texBoldStyle DraculaOrangeBold +hi! link texInputFile DraculaOrangeItalic +hi! link texItalStyle DraculaYellowItalic +hi! link texLigature DraculaPurple +hi! link texMath DraculaPurple +hi! link texMathMatcher DraculaPurple +hi! link texMathSymbol DraculaPurple +hi! link texSpecialChar DraculaPurple +hi! link texSubscripts DraculaPurple +hi! link texTitle DraculaFgBold +" }}} + +" Typescript: {{{ +hi! link typescriptAliasDeclaration Type +hi! link typescriptArrayMethod Function +hi! link typescriptArrowFunc Operator +hi! link typescriptArrowFuncArg DraculaOrangeItalic +hi! link typescriptAssign Operator +hi! link typescriptBOMWindowProp Constant +hi! link typescriptBinaryOp Operator +hi! link typescriptBraces Delimiter +hi! link typescriptCall typescriptArrowFuncArg +hi! link typescriptClassHeritage Type +hi! link typescriptClassName Type +hi! link typescriptDateMethod DraculaCyan +hi! link typescriptDateStaticMethod Function +hi! link typescriptDecorator DraculaGreenItalic +hi! link typescriptDefaultParam Operator +hi! link typescriptES6SetMethod DraculaCyan +hi! link typescriptEndColons Delimiter +hi! link typescriptEnum Type +hi! link typescriptEnumKeyword Keyword +hi! link typescriptFuncComma Delimiter +hi! link typescriptFuncKeyword Keyword +hi! link typescriptFuncType DraculaOrangeItalic +hi! link typescriptFuncTypeArrow Operator +hi! link typescriptGlobal Type +hi! link typescriptGlobalMethod DraculaCyan +hi! link typescriptGlobalObjects Type +hi! link typescriptIdentifier DraculaPurpleItalic +hi! link typescriptInterfaceHeritage Type +hi! link typescriptInterfaceName Type +hi! link typescriptInterpolationDelimiter Keyword +hi! link typescriptKeywordOp Keyword +hi! link typescriptLogicSymbols Operator +hi! link typescriptMember Identifier +hi! link typescriptMemberOptionality Special +hi! link typescriptObjectColon Special +hi! link typescriptObjectLabel Identifier +hi! link typescriptObjectSpread Operator +hi! link typescriptOperator Operator +hi! link typescriptParamImpl DraculaOrangeItalic +hi! link typescriptParens Delimiter +hi! link typescriptPredefinedType Type +hi! link typescriptRestOrSpread Operator +hi! link typescriptTernaryOp Operator +hi! link typescriptTypeAnnotation Special +hi! link typescriptTypeCast Operator +hi! link typescriptTypeParameter DraculaOrangeItalic +hi! link typescriptTypeReference Type +hi! link typescriptUnaryOp Operator +hi! link typescriptVariable Keyword + +hi! link tsxAttrib DraculaGreenItalic +hi! link tsxEqual Operator +hi! link tsxIntrinsicTagName Keyword +hi! link tsxTagName Type +" }}} + +" Vim: {{{ +hi! link vimAutoCmdSfxList Type +hi! link vimAutoEventList Type +hi! link vimEnvVar Constant +hi! link vimFunction Function +hi! link vimHiBang Keyword +hi! link vimOption Type +hi! link vimSetMod Keyword +hi! link vimSetSep Delimiter +hi! link vimUserAttrbCmpltFunc Function +hi! link vimUserFunc Function +" }}} + +" XML: {{{ +hi! link xmlAttrib DraculaGreenItalic +hi! link xmlEqual Operator +hi! link xmlTag Delimiter +hi! link xmlTagName Statement + +" Fixes missing highlight over end tags +syn region xmlTagName + \ matchgroup=xmlTag start=+</[^ /!?<>"']\@=+ + \ matchgroup=xmlTag end=+>+ +" }}} + +" YAML: {{{ +hi! link yamlAlias DraculaGreenItalicUnderline +hi! link yamlAnchor DraculaPinkItalic +hi! link yamlBlockMappingKey DraculaCyan +hi! link yamlFlowCollection DraculaPink +hi! link yamlFlowIndicator Delimiter +hi! link yamlNodeTag DraculaPink +hi! link yamlPlainScalar DraculaYellow +" }}} + +" }}} + +" Plugins: {{{ + +" junegunn/fzf {{{ +if ! exists('g:fzf_colors') + let g:fzf_colors = { + \ 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Search'], + \ 'fg+': ['fg', 'Normal'], + \ 'bg+': ['bg', 'Normal'], + \ 'hl+': ['fg', 'DraculaOrange'], + \ 'info': ['fg', 'DraculaPurple'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'DraculaGreen'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'], + \} +endif +" }}} + +" dense-analysis/ale {{{ +hi! link ALEError DraculaErrorLine +hi! link ALEWarning DraculaWarnLine +hi! link ALEInfo DraculaInfoLine + +hi! link ALEErrorSign DraculaRed +hi! link ALEWarningSign DraculaOrange +hi! link ALEInfoSign DraculaCyan + +hi! link ALEVirtualTextError Comment +hi! link ALEVirtualTextWarning Comment +" }}} + +" ctrlpvim/ctrlp.vim: {{{ +hi! link CtrlPMatch IncSearch +hi! link CtrlPBufferHid Normal +" }}} + +" airblade/vim-gitgutter {{{ +hi! link GitGutterAdd DiffAdd +hi! link GitGutterChange DiffChange +hi! link GitGutterDelete DiffDelete +" }}} + +" Neovim-only plugins {{{ +if has('nvim') + + " nvim-treesitter/nvim-treesitter: {{{ + " The nvim-treesitter library defines many global highlight groups that are + " linked to the regular vim syntax highlight groups. We only need to redefine + " those highlight groups when the defaults do not match the dracula + " specification. + " https://github.com/nvim-treesitter/nvim-treesitter/blob/master/plugin/nvim-treesitter.vim + + " deprecated TS* highlight groups + " see https://github.com/nvim-treesitter/nvim-treesitter/pull/3656 + " # Misc + hi! link TSPunctSpecial Special + " # Constants + hi! link TSConstMacro Macro + hi! link TSStringEscape Character + hi! link TSSymbol DraculaPurple + hi! link TSAnnotation DraculaYellow + hi! link TSAttribute DraculaGreenItalic + " # Functions + hi! link TSFuncBuiltin DraculaCyan + hi! link TSFuncMacro Function + hi! link TSParameter DraculaOrangeItalic + hi! link TSParameterReference DraculaOrange + hi! link TSField DraculaOrange + hi! link TSConstructor DraculaCyan + " # Keywords + hi! link TSLabel DraculaPurpleItalic + " # Variable + hi! link TSVariableBuiltin DraculaPurpleItalic + " # Text + hi! link TSStrong DraculaFgBold + hi! link TSEmphasis DraculaFg + hi! link TSUnderline Underlined + hi! link TSTitle DraculaYellow + hi! link TSLiteral DraculaYellow + hi! link TSURI DraculaYellow + " HTML and JSX tag attributes. By default, this group is linked to TSProperty, + " which in turn links to Identifer (white). + hi! link TSTagAttribute DraculaGreenItalic + + if has('nvim-0.8.1') + " # Misc + hi! link @punctuation.delimiter Delimiter + hi! link @punctuation.bracket DraculaFg + hi! link @punctuation.special Special + hi! link @punctuation Delimiter + " # Constants + hi! link @constant Constant + hi! link @constant.builtin Constant + hi! link @constant.macro Macro + hi! link @string.regex @string.special + hi! link @string.escape @string.special + hi! link @string String + hi! link @string.regexp @string.special + hi! link @string.special SpecialChar + hi! link @string.special.symbol DraculaPurple + hi! link @string.special.url Underlined + hi! link @symbol DraculaPurple + hi! link @annotation DraculaYellow + hi! link @attribute DraculaGreenItalic + hi! link @namespace Structure + hi! link @module Structure + hi! link @module.builtin Special + " # Functions + hi! link @function.builtin DraculaCyan + hi! link @funcion.macro Function + hi! link @function Function + hi! link @parameter DraculaOrangeItalic + hi! link @parameter.reference DraculaOrange + hi! link @field DraculaOrange + hi! link @property DraculaFg + hi! link @constructor DraculaCyan + " # Keywords + hi! link @label DraculaPurpleItalic + hi! link @keyword.function DraculaPink + hi! link @keyword.operator Operator + hi! link @keyword Keyword + hi! link @exception DraculaPurple + hi! link @operator Operator + " # Types + hi! link @type Type + hi! link @type.builtin Special + hi! link @character Character + hi! link @character.special SpecialChar + hi! link @boolean Boolean + hi! link @number Number + hi! link @number.float Float + " # Variable + hi! link @variable DraculaFg + hi! link @variable.builtin DraculaPurpleItalic + hi! link @variable.parameter DraculaOrangeItalic + hi! link @variable.member DraculaOrange + " # Text + hi! link @text DraculaFg + hi! link @text.strong DraculaFgBold + hi! link @text.emphasis DraculaFg + hi! link @text.underline Underlined + hi! link @text.title DraculaYellow + hi! link @text.literal DraculaYellow + hi! link @text.uri DraculaYellow + hi! link @text.diff.add DiffAdd + hi! link @text.diff.delete DiffDelete + + hi! link @markup.strong DraculaFgBold + hi! link @markup.italic DraculaFgItalic + hi! link @markup.strikethrough DraculaFgStrikethrough + hi! link @markup.underline Underlined + + hi! link @markup Special + hi! link @markup.heading DraculaYellow + hi! link @markup.link Underlined + hi! link @markup.link.uri DraculaYellow + hi! link @markup.link.label SpecialChar + hi! link @markup.raw DraculaYellow + hi! link @markup.list Special + + hi! link @comment Comment + hi! link @comment.error DiagnosticError + hi! link @comment.warning DiagnosticWarn + hi! link @comment.note DiagnosticInfo + hi! link @comment.todo Todo + + hi! link @diff.plus Added + hi! link @diff.minus Removed + hi! link @diff.delta Changed + + " # Tags + hi! link @tag DraculaCyan + hi! link @tag.delimiter DraculaFg + " HTML and JSX tag attributes. By default, this group is linked to TSProperty, + " which in turn links to Identifer (white). + hi! link @tag.attribute DraculaGreenItalic + endif + " }}} + + " hrsh7th/nvim-cmp {{{ + hi! link CmpItemAbbrDeprecated DraculaError + + hi! link CmpItemAbbrMatch DraculaCyan + hi! link CmpItemAbbrMatchFuzzy DraculaCyan + + hi! link CmpItemKindText DraculaFg + hi! link CmpItemKindMethod Function + hi! link CmpItemKindFunction Function + hi! link CmpItemKindConstructor DraculaCyan + hi! link CmpItemKindField DraculaOrange + hi! link CmpItemKindVariable DraculaPurpleItalic + hi! link CmpItemKindClass DraculaCyan + hi! link CmpItemKindInterface DraculaCyan + hi! link CmpItemKindModule DraculaYellow + hi! link CmpItemKindProperty DraculaPink + hi! link CmpItemKindUnit DraculaFg + hi! link CmpItemKindValue DraculaYellow + hi! link CmpItemKindEnum DraculaPink + hi! link CmpItemKindKeyword DraculaPink + hi! link CmpItemKindSnippet DraculaFg + hi! link CmpItemKindColor DraculaYellow + hi! link CmpItemKindFile DraculaYellow + hi! link CmpItemKindReference DraculaOrange + hi! link CmpItemKindFolder DraculaYellow + hi! link CmpItemKindEnumMember DraculaPurple + hi! link CmpItemKindConstant DraculaPurple + hi! link CmpItemKindStruct DraculaPink + hi! link CmpItemKindEvent DraculaFg + hi! link CmpItemKindOperator DraculaPink + hi! link CmpItemKindTypeParameter DraculaCyan + + hi! link CmpItemMenu Comment + " }}} + + " lewis6991/gitsigns.nvim {{{ + hi! link GitSignsAdd DiffAdd + hi! link GitSignsAddLn DiffAdd + hi! link GitSignsAddNr DiffAdd + hi! link GitSignsChange DiffChange + hi! link GitSignsChangeLn DiffChange + hi! link GitSignsChangeNr DiffChange + + hi! link GitSignsDelete DraculaRed + hi! link GitSignsDeleteLn DraculaRed + hi! link GitSignsDeleteNr DraculaRed + " }}} + +endif +" }}} + +" }}} " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0 et: diff --git a/sources_non_forked/dracula/doc/dracula.txt b/sources_non_forked/dracula/doc/dracula.txt index 80e44f19..5dc6a663 100644 --- a/sources_non_forked/dracula/doc/dracula.txt +++ b/sources_non_forked/dracula/doc/dracula.txt @@ -78,6 +78,10 @@ Include bold attributes in highlighting > Include italic attributes in highlighting > let g:dracula_italic = 1 +* *g:dracula_strikethrough* +Include strikethrough attributes in highlighting > + let g:dracula_strikethrough = 1 + * *g:dracula_underline* Include underline attributes in highlighting > let g:dracula_underline = 1 @@ -110,19 +114,44 @@ Include background fill colors > CUSTOMIZATION *dracula-customization* Like all colorschemes, Dracula is easy to customize with |autocmd|. Make use -of the |ColorScheme| event as in the following examples. +of the |ColorScheme| event as in the following examples. Like all autocommands, +it's best to put all of your personal changes in an |augroup|: > -It would be a good idea to put all of your personal changes in an |augroup|, -which you can do with the following code: > - augroup dracula_customization - au! - " autocmds... + augroup DraculaCustomization + autocmd! + " Change the highlight group used with vim-gitgutter. + autocmd ColorScheme dracula highlight! link GitGutterDelete DraculaRed augroup END -> -- To add underline styling to |hl-CursorLine|, you can use the following: > - autocmd ColorScheme dracula hi CursorLine cterm=underline term=underline + colorscheme dracula < + +The autocommand must be defined before the colorscheme is set. To overwrite +any highlight link that is already established in `colors/dracula.vim`, you +will need to use the bang (!) modifier on the |hi-link| command. + +For more than one customization, it will be easier to define a function that +can be called from the autocommand: > + + function! s:customize_dracula() abort + " Link a highlight group to a predefined highlight group. + " See `colors/dracula.vim` for all predefined highlight groups. + " To overwrite a highlight link created in `colors/dracula.vim`, you + " will need to use the bang (!) modifier + highlight! link GitGutterDelete DraculaRed + + " Customize existing highlight groups, for example adding underline. + highlight CursorLine cterm=underline term=underline + endfunction + + augroup DraculaCustomization + autocmd! + autocmd ColorScheme dracula call s:customize_dracula() + augroup END + + colorscheme dracula +< + ============================================================================== LICENSE *dracula-license* diff --git a/sources_non_forked/editorconfig-vim/README.md b/sources_non_forked/editorconfig-vim/README.md index 961c9ae2..d25ac18e 100644 --- a/sources_non_forked/editorconfig-vim/README.md +++ b/sources_non_forked/editorconfig-vim/README.md @@ -6,6 +6,15 @@ This is an [EditorConfig][] plugin for Vim. This plugin can be found on both [GitHub][] and [Vim online][]. +## Bundled versions + +Depending on which version of Vim or Neovim you are using, you might not need to +specifically install this plugin at all: + +* Vim 9.0.1799 and above comes bundled with [a recent stable version of this + plugin][]. +* Neovim 0.9 and above comes with [its own Lua-based implementation][]. + ## Installation To install this plugin, you can use one of the following ways: @@ -138,6 +147,8 @@ Feel free to submit bugs, feature requests, and other issues to the [PreserveNoEOL]: http://www.vim.org/scripts/script.php?script_id=4550 [Tim Pope's fugitive]: https://github.com/tpope/vim-fugitive [Vim online]: http://www.vim.org/scripts/script.php?script_id=3934 +[a recent stable version of this plugin]: https://github.com/vim/vim/pull/12902 +[its own Lua-based implementation]: https://github.com/neovim/neovim/commit/ab9a2c49253413dbbb31756a3eeddb354a663035 [Vundle]: https://github.com/gmarik/Vundle.vim [archive]: https://github.com/editorconfig/editorconfig-vim/archive/master.zip [contribution guidelines]: https://github.com/editorconfig/editorconfig/blob/master/CONTRIBUTING.md#submitting-an-issue diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim index c10c0366..3c5df54e 100644 --- a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim @@ -1,6 +1,6 @@ " autoload/editorconfig_core/ini.vim: Config-file parser for " editorconfig-core-vimscript and editorconfig-vim. -" Modifed from the Python core's ini.py. +" Modified from the Python core's ini.py. " Copyright (c) 2012-2019 EditorConfig Team {{{2 " All rights reserved. diff --git a/sources_non_forked/lightline.vim/.github/workflows/ci.yaml b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml index d1ccd883..1531fc94 100644 --- a/sources_non_forked/lightline.vim/.github/workflows/ci.yaml +++ b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml @@ -3,9 +3,12 @@ name: CI on: push: branches: - - master + - master pull_request: +permissions: + contents: read + jobs: test: name: Test @@ -13,27 +16,29 @@ jobs: strategy: matrix: vim: - - v9.0.0000 - - v8.2.0000 - - v8.1.0000 - - v8.0.0000 - - v7.4 - - v7.3 + - v9.1.0000 + - v9.0.0000 + - v8.2.0000 + - v8.1.0000 + - v8.0.0000 + - v7.4 + - v7.3 + fail-fast: false steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Checkout vim-themis - uses: actions/checkout@v3 - with: - repository: thinca/vim-themis - path: vim-themis - ref: v1.6.0 - - name: Setup Vim - uses: rhysd/action-setup-vim@v1 - id: vim - with: - version: ${{ matrix.vim }} - - name: Test - env: - THEMIS_VIM: ${{ steps.vim.outputs.executable }} - run: ./vim-themis/bin/themis --reporter spec + - name: Checkout code + uses: actions/checkout@v4 + - name: Checkout vim-themis + uses: actions/checkout@v4 + with: + repository: thinca/vim-themis + path: vim-themis + ref: v1.6.0 + - name: Setup Vim + uses: rhysd/action-setup-vim@v1 + id: vim + with: + version: ${{ matrix.vim }} + - name: Test + env: + THEMIS_VIM: ${{ steps.vim.outputs.executable }} + run: ./vim-themis/bin/themis --reporter spec diff --git a/sources_non_forked/lightline.vim/LICENSE b/sources_non_forked/lightline.vim/LICENSE index 93dc399e..9a73d00f 100644 --- a/sources_non_forked/lightline.vim/LICENSE +++ b/sources_non_forked/lightline.vim/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2022 itchyny +Copyright (c) 2013-2024 itchyny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sources_non_forked/nerdtree/CHANGELOG.md b/sources_non_forked/nerdtree/CHANGELOG.md index fc3edbed..ba25bf16 100644 --- a/sources_non_forked/nerdtree/CHANGELOG.md +++ b/sources_non_forked/nerdtree/CHANGELOG.md @@ -13,6 +13,16 @@ - Pull Request Title n (PR Author) [PR Number](Link to PR) --> #### 7.1 +- **.3**: + - docs: update FAQ snippets containing quit command. (rzvxa) [#1417](https://github.com/preservim/nerdtree/pull/1417) + - feat: jump to bookmark table shortcut. (ds2606, rzvxa) [#1394](https://github.com/preservim/nerdtree/pull/1394) + - fix: typo in docs for show file lines setting. (lothardp) [#1426](https://github.com/preservim/nerdtree/pull/1426) +- **.2**: + - fix: GetWinNum regex pattern. (rzvxa) [#1409](https://github.com/preservim/nerdtree/pull/1409) + - fix: session restore for nerdtree buffers. (rzvxa) [#1405](https://github.com/preservim/nerdtree/pull/1405) +- **.1**: + - fix: change default binding of filelines to `FL`. (rzvxa) [#1400](https://github.com/preservim/nerdtree/pull/1400) + - fix: toggle zoom resizing. (ds2606) [#1395](https://github.com/preservim/nerdtree/pull/1395) - **.0**: - fix: typo in the docs. (bl4kraven) [#1390](https://github.com/preservim/nerdtree/pull/1390) - feat: add NERDTreeExplore command. (msibal6) [#1389](https://github.com/preservim/nerdtree/pull/1389) diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown index 210ec312..93a844a5 100644 --- a/sources_non_forked/nerdtree/README.markdown +++ b/sources_non_forked/nerdtree/README.markdown @@ -150,6 +150,24 @@ autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in ### How can I close Vim or a tab automatically when NERDTree is the last window? +Because of the changes in how Vim handles its `autocmd` and layout locking `quit` command is no longer available in Vim9 auto commands, Depending on which version you're running select one of these solutions. + +__NeoVim users should be able to choose either one of them!__ + +#### Vim9 + +```vim +" Exit Vim if NERDTree is the only window remaining in the only tab. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif +``` +--- +```vim +" Close the tab if NERDTree is the only window remaining in it. +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif +``` + +#### Vim8 or older + ```vim " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim index 1c10ec80..d7246dc5 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -234,6 +234,38 @@ function! nerdtree#pathEquals(lhs, rhs) abort endif endfunction +"FUNCTION: nerdtree#onBufLeave() {{{2 +" used for handling the nerdtree BufLeave/WinLeave events. +function! nerdtree#onBufLeave() abort + " detect whether we are in the middle of sourcing a session. + " if it is a buffer from the sourced session we need to restore it. + if exists('g:SessionLoad') && !exists('b:NERDTree') + let bname = bufname('%') + " is the buffer for a tab tree? + if bname =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'tab_\d\+$' + " rename loaded buffer and mark it as trash to prevent this event + " getting fired again + exec 'file TRASH_' . bname + " delete the trash buffer + exec 'bwipeout!' + " rescue the tab tree at the current working directory + call g:NERDTreeCreator.CreateTabTree(getcwd()) + " is the buffer for a window tree? + elseif bname =~# '^' . g:NERDTreeCreator.BufNamePrefix(). 'win_\d\+$' + " rescue the window tree at the current working directory + call g:NERDTreeCreator.CreateWindowTree(getcwd()) + else " unknown buffer type + " rename buffer to mark it as broken. + exec 'file BROKEN_' . bname + call nerdtree#echoError('Failed to restore "' . bname . '" from session. Is this session created with an older version of NERDTree?') + endif + else + if g:NERDTree.IsOpen() + call b:NERDTree.ui.saveScreenState() + endif + endif +endfunction + " SECTION: View Functions {{{1 "============================================================ diff --git a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim index 1610d098..c5c96181 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim @@ -70,6 +70,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpBookmarks, 'scope': 'all', 'callback': s.'jumpToBookmarks' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' }) @@ -496,6 +497,21 @@ function! s:jumpToSibling(node, forward) abort call b:NERDTree.ui.centerView() endfunction +" FUNCTION: s:jumpToBookmarks() {{{1 +" moves the cursor to the bookmark table +function! s:jumpToBookmarks() abort + try + if b:NERDTree.ui.getShowBookmarks() + call g:NERDTree.CursorToBookmarkTable() + else + call b:NERDTree.ui.setShowBookmarks(1) + endif + catch /^NERDTree/ + call nerdtree#echoError('Failed to jump to the bookmark table') + return + endtry +endfunction + " FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 " Open the Bookmark that has the specified name. This function provides the " implementation for the :OpenBookmark command. diff --git a/sources_non_forked/nerdtree/doc/NERDTree.txt b/sources_non_forked/nerdtree/doc/NERDTree.txt index 9b8b6ba8..f8a1fdc1 100644 --- a/sources_non_forked/nerdtree/doc/NERDTree.txt +++ b/sources_non_forked/nerdtree/doc/NERDTree.txt @@ -287,7 +287,7 @@ I........Toggle whether hidden files displayed......................|NERDTree-I| f........Toggle whether the file filters are used...................|NERDTree-f| F........Toggle whether files are displayed.........................|NERDTree-F| B........Toggle whether the bookmark table is displayed.............|NERDTree-B| -L........Toggle whether the number of lines in files is displayed...|NERDTree-L| +L........Toggle whether the number of lines in files is displayed..|NERDTree-FL| q........Close the NERDTree window..................................|NERDTree-q| A........Zoom (maximize/minimize) the NERDTree window...............|NERDTree-A| @@ -603,8 +603,8 @@ Applies to: no restrictions. Toggles whether the bookmarks table is displayed. ------------------------------------------------------------------------------ - *NERDTree-L* -Default key: L + *NERDTree-FL* +Default key: FL Map setting: *NERDTreeMapToggleFileLines* Applies to: no restrictions. @@ -1073,18 +1073,18 @@ mapping and is useful for drastically shrinking the tree when you are navigating to a different part of the tree. ------------------------------------------------------------------------------ - *NERDTreeShowFilesLines* + *NERDTreeFileLines* Values: 0 or 1. Default: 0. If this setting is set to 1 then the NERDTree shows number of lines for each file. -This setting can be toggled dynamically, per tree, with the |NERDTree-L| +This setting can be toggled dynamically, per tree, with the |NERDTree-FL| mapping. Use one of the follow lines for this setting: > - let NERDTreeShowFilesLines=0 - let NERDTreeShowFilesLines=1 + let NERDTreeFileLines=0 + let NERDTreeFileLines=1 < ------------------------------------------------------------------------------ *NERDTreeShowHidden* diff --git a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim index 7e1940b8..e794e0d9 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim @@ -118,7 +118,7 @@ function! s:Creator.createWindowTree(dir) "we need a unique name for each window tree buffer to ensure they are "all independent - exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName() + exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName('win') call self._createNERDTree(path, 'window') let b:NERDTree._previousBuf = bufnr(previousBuf) @@ -210,7 +210,7 @@ function! s:Creator._createTreeWin() let l:splitSize = g:NERDTreeWinSize if !g:NERDTree.ExistsForTab() - let t:NERDTreeBufName = self._nextBufferName() + let t:NERDTreeBufName = self._nextBufferName('tab') silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new' silent! execute 'edit ' . t:NERDTreeBufName silent! execute l:splitDirection . ' resize '. l:splitSize @@ -244,10 +244,22 @@ function! s:Creator.New() return newCreator endfunction -" FUNCTION: s:Creator._nextBufferName() {{{1 -" returns the buffer name for the next nerd tree -function! s:Creator._nextBufferName() - let name = s:Creator.BufNamePrefix() . self._nextBufferNumber() +" FUNCTION: s:Creator._nextBufferName(type='') {{{1 +" gets an optional buffer type of either 'tab' or 'win'. +" returns the buffer name for the next nerd tree of such type. +function! s:Creator._nextBufferName(...) + if a:0 > 0 + let type = a:1 + else + let type = '' + end + let name = s:Creator.BufNamePrefix() + if type ==# 'tab' + let name = name . 'tab_' + elseif type ==# 'win' + let name = name . 'win_' + endif + let name = name . self._nextBufferNumber() return name endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim index 61a11a96..1af5346a 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim @@ -144,7 +144,7 @@ function! s:NERDTree.GetWinNum() " 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\+$' + if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'win_\d\+$' return w endif endfor diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim index dffdecde..867e04b1 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -62,6 +62,7 @@ function! s:UI._dumpHelp() let help .= "\"\n\" ----------------------------\n" let help .= "\" Bookmark table mappings~\n" let help .= "\" double-click,\n" + let help .= '" '. g:NERDTreeMapJumpBookmarks .": jump to bookmark table\n" let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n" let help .= '" '. g:NERDTreeMapPreview .": preview file\n" let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n" @@ -482,10 +483,10 @@ function! s:UI.toggleIgnoreFilter() call self.centerView() endfunction -" FUNCTION: s:UI.toggleShowBookmarks() {{{1 -" Toggle the visibility of the Bookmark table. -function! s:UI.toggleShowBookmarks() - let self._showBookmarks = !self._showBookmarks +" FUNCTION: s:UI.setShowBookmarks() {{{1 +" Sets the visibility of the Bookmark table. +function! s:UI.setShowBookmarks(value) + let self._showBookmarks = a:value if self.getShowBookmarks() call self.nerdtree.render() @@ -503,6 +504,12 @@ function! s:UI.toggleShowBookmarks() call self.centerView() endfunction +" FUNCTION: s:UI.toggleShowBookmarks() {{{1 +" Toggle the visibility of the Bookmark table. +function! s:UI.toggleShowBookmarks() + call self.setShowBookmarks(!self._showBookmarks) +endfunction + " FUNCTION: s:UI.toggleShowFiles() {{{1 " toggles the display of hidden files function! s:UI.toggleShowFiles() diff --git a/sources_non_forked/nerdtree/plugin/NERD_tree.vim b/sources_non_forked/nerdtree/plugin/NERD_tree.vim index a4276701..84c04fda 100644 --- a/sources_non_forked/nerdtree/plugin/NERD_tree.vim +++ b/sources_non_forked/nerdtree/plugin/NERD_tree.vim @@ -101,6 +101,7 @@ endif "SECTION: Init variable calls for key mappings {{{2 let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>') +let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'gb') let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o') let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C') let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd') @@ -131,7 +132,7 @@ let g:NERDTreeMapToggleBookmarks = get(g:, 'NERDTreeMapToggleBookmarks', 'B') let g:NERDTreeMapToggleFiles = get(g:, 'NERDTreeMapToggleFiles', 'F') let g:NERDTreeMapToggleFilters = get(g:, 'NERDTreeMapToggleFilters', 'f') let g:NERDTreeMapToggleHidden = get(g:, 'NERDTreeMapToggleHidden', 'I') -let g:NERDTreeMapToggleFileLines = get(g:, 'NERDTreeMapToggleFileLines', 'L') +let g:NERDTreeMapToggleFileLines = get(g:, 'NERDTreeMapToggleFileLines', 'FL') let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A') let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u') let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U') @@ -151,7 +152,7 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif' + exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* call nerdtree#onBufLeave()' "disallow insert mode in the NERDTree exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert' diff --git a/sources_non_forked/typescript-vim/README.md b/sources_non_forked/typescript-vim/README.md index a8809983..8030231e 100644 --- a/sources_non_forked/typescript-vim/README.md +++ b/sources_non_forked/typescript-vim/README.md @@ -1,8 +1,18 @@ -Typescript Syntax for Vim +An old Typescript Syntax for Vim ========================= +--- + +NOTE: This Typescript syntax was created before Typescript's 1.0 release, more than a decade ago. I hope it +has been helpful but there are now other options available. Vim has included +[Typescript syntax](https://github.com/vim/vim/blob/master/runtime/syntax/typescript.vim) for some years, +which receives more frequent updates at its own [repository](https://github.com/HerringtonDarkholme/yats.vim). +Neovim can also use a [treesitter grammar](https://github.com/tree-sitter/tree-sitter-typescript) for highlighting. + +--- + Syntax file and other settings for [TypeScript](http://typescriptlang.org). The -syntax file is taken from this [blog +syntax file was originally from this 2012 [blog post](https://docs.microsoft.com/en-us/archive/blogs/interoperability/sublime-text-vi-emacs-typescript-enabled). Checkout [Tsuquyomi](https://github.com/Quramy/tsuquyomi) for omni-completion diff --git a/sources_non_forked/typescript-vim/syntax/typescript.vim b/sources_non_forked/typescript-vim/syntax/typescript.vim index f2738166..311ed075 100644 --- a/sources_non_forked/typescript-vim/syntax/typescript.vim +++ b/sources_non_forked/typescript-vim/syntax/typescript.vim @@ -113,7 +113,7 @@ syntax keyword typescriptStorageClass let var const syntax keyword typescriptOperator delete new instanceof typeof syntax keyword typescriptBoolean true false syntax keyword typescriptNull null undefined -syntax keyword typescriptMessage alert confirm prompt status +syntax keyword typescriptMessage alert confirm prompt syntax keyword typescriptGlobal self top parent syntax keyword typescriptDeprecated escape unescape all applets alinkColor bgColor fgColor linkColor vlinkColor xmlEncoding "}}} @@ -129,7 +129,7 @@ syntax keyword typescriptGlobalNodeObjects module exports global process __dirn syntax keyword typescriptExceptions try catch throw finally Error EvalError RangeError ReferenceError SyntaxError TypeError URIError -syntax keyword typescriptReserved constructor declare as interface module abstract enum int short export interface static byte extends long super char final native synchronized class float package throws goto private transient debugger implements protected volatile double import public type namespace from get set keyof +syntax keyword typescriptReserved constructor declare as interface module abstract enum int short export interface static byte extends long super char final native synchronized class float package throws goto private transient debugger implements protected volatile double import public type namespace from get set keyof satisfies "}}} "" typescript/DOM/HTML/CSS specified things"{{{ diff --git a/sources_non_forked/vim-commentary/README.markdown b/sources_non_forked/vim-commentary/README.markdown index 8486f8a2..328ae979 100644 --- a/sources_non_forked/vim-commentary/README.markdown +++ b/sources_non_forked/vim-commentary/README.markdown @@ -26,6 +26,10 @@ support: git clone https://tpope.io/vim/commentary.git vim -u NONE -c "helptags commentary/doc" -c q +Make sure this line is in your vimrc, if it isn't already: + + filetype plugin indent on + ## FAQ > My favorite file type isn't supported! diff --git a/sources_non_forked/vim-commentary/plugin/commentary.vim b/sources_non_forked/vim-commentary/plugin/commentary.vim index 53701066..ed056a45 100644 --- a/sources_non_forked/vim-commentary/plugin/commentary.vim +++ b/sources_non_forked/vim-commentary/plugin/commentary.vim @@ -108,7 +108,6 @@ nnoremap <expr> <Plug>Commentary <SID>go() nnoremap <expr> <Plug>CommentaryLine <SID>go() . '_' onoremap <silent> <Plug>Commentary :<C-U>call <SID>textobject(get(v:, 'operator', '') ==# 'c')<CR> nnoremap <silent> <Plug>ChangeCommentary c:<C-U>call <SID>textobject(1)<CR> -nmap <silent> <Plug>CommentaryUndo :echoerr "Change your <Plug>CommentaryUndo map to <Plug>Commentary<Plug>Commentary"<CR> if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# '' xmap gc <Plug>Commentary @@ -118,4 +117,6 @@ if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# '' nmap gcu <Plug>Commentary<Plug>Commentary endif +nmap <silent> <Plug>CommentaryUndo :echoerr "Change your <Plug>CommentaryUndo map to <Plug>Commentary<Plug>Commentary"<CR> + " vim:set et sw=2: diff --git a/sources_non_forked/vim-fugitive/autoload/fugitive.vim b/sources_non_forked/vim-fugitive/autoload/fugitive.vim index 19d2d08c..17fd04d3 100644 --- a/sources_non_forked/vim-fugitive/autoload/fugitive.vim +++ b/sources_non_forked/vim-fugitive/autoload/fugitive.vim @@ -140,7 +140,7 @@ endfunction function! s:Mods(mods, ...) abort let mods = substitute(a:mods, '\C<mods>', '', '') let mods = mods =~# '\S$' ? mods . ' ' : mods - if a:0 && mods !~# '\<\%(aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright\|tab\)\>' + if a:0 && mods !~# '\<\d*\%(aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright\|tab\)\>' let default = a:1 if default ==# 'SpanOrigin' if s:OriginBufnr() > 0 && (mods =~# '\<vertical\>' ? &winfixheight : &winfixwidth) @@ -273,7 +273,11 @@ function! s:TempScript(...) abort if !filereadable(temp) call writefile(['#!/bin/sh'] + a:000, temp) endif - return FugitiveGitPath(temp) + let temp = FugitiveGitPath(temp) + if temp =~# '\s' + let temp = '"' . temp . '"' + endif + return temp endfunction function! s:DoAutocmd(...) abort @@ -1007,7 +1011,7 @@ function! s:StdoutToFile(out, cmd, ...) abort throw 'fugitive: Vim 8 or higher required to use ' . &shell else let cmd = fugitive#ShellCommand(a:cmd) - return s:SystemError(' (' . cmd . ' >' . a:out . ') ') + return call('s:SystemError', [' (' . cmd . ' >' . (len(a:out) ? a:out : '/dev/null') . ') '] + a:000) endif endfunction @@ -1118,7 +1122,7 @@ function! fugitive#Config(...) abort let callback = a:000[1:-1] endif elseif a:0 >= 2 && type(a:2) == type({}) && has_key(a:2, 'GetAll') - return get(fugitive#ConfigGetAll(a:1, a:2), 0, default) + return get(fugitive#ConfigGetAll(a:1, a:2), -1, default) elseif a:0 >= 2 let dir = s:Dir(a:2) let name = a:1 @@ -1200,7 +1204,7 @@ function! s:config_GetAll(name) dict abort endfunction function! s:config_Get(name, ...) dict abort - return get(self.GetAll(a:name), 0, a:0 ? a:1 : '') + return get(self.GetAll(a:name), -1, a:0 ? a:1 : '') endfunction function! s:config_GetRegexp(pattern) dict abort @@ -1235,12 +1239,15 @@ function! s:SshParseHost(value) abort return '^\%(' . join(patterns, '\|') . '\)$' . join(negates, '') endfunction -function! s:SshParseConfig(into, root, file, ...) abort - if !filereadable(a:file) +function! s:SshParseConfig(into, root, file) abort + try + let lines = readfile(a:file) + catch return a:into - endif - let host = a:0 ? a:1 : '^\%(.*\)$' - for line in readfile(a:file) + endtry + let host = '^\%(.*\)$' + while !empty(lines) + let line = remove(lines, 0) let key = tolower(matchstr(line, '^\s*\zs\w\+\ze\s')) let value = matchstr(line, '^\s*\w\+\s\+\zs.*\S') if key ==# 'match' @@ -1248,26 +1255,25 @@ function! s:SshParseConfig(into, root, file, ...) abort elseif key ==# 'host' let host = s:SshParseHost(value) elseif key ==# 'include' - call s:SshParseInclude(a:into, a:root, host, value) + for glob in split(value) + if glob !~# '^[~/]' + let glob = a:root . glob + endif + for included in reverse(split(glob(glob), "\n")) + try + call extend(lines, readfile(included), 'keep') + catch + endtry + endfor + endfor elseif len(key) && len(host) call extend(a:into, {key : []}, 'keep') call add(a:into[key], [host, value]) endif - endfor + endwhile return a:into endfunction -function! s:SshParseInclude(into, root, host, value) abort - for glob in split(a:value) - if glob !~# '^/' - let glob = a:root . glob - endif - for file in split(glob(glob), "\n") - call s:SshParseConfig(a:into, a:root, file, a:host) - endfor - endfor -endfunction - unlet! s:ssh_config function! fugitive#SshConfig(host, ...) abort if !exists('s:ssh_config') @@ -1530,7 +1536,7 @@ function! s:QuickfixCreate(nr, opts) abort endfunction function! s:QuickfixOpen(nr, mods) abort - let mods = substitute(s:Mods(a:mods), '\<tab\>', '', '') + let mods = substitute(s:Mods(a:mods), '\<\d*tab\>', '', '') return mods . (a:nr < 0 ? 'c' : 'l').'open' . (mods =~# '\<vertical\>' ? ' 20' : '') endfunction @@ -2599,26 +2605,39 @@ function! s:Format(val) abort endif endfunction -function! s:AddHeader(key, value) abort +function! s:AddHeader(to, key, value) abort if empty(a:value) return endif - let before = 1 - while !empty(getline(before)) - let before += 1 - endwhile - call append(before - 1, [a:key . ':' . (len(a:value) ? ' ' . a:value : '')]) - if before == 1 && line('$') == 2 - silent keepjumps 2delete _ - endif + call add(a:to.lines, a:key . ':' . (len(a:value) ? ' ' . a:value : '')) endfunction -function! s:AddSection(label, lines, ...) abort +function! s:AddSection(to, label, lines, ...) abort let note = a:0 ? a:1 : '' if empty(a:lines) && empty(note) return endif - call append(line('$'), ['', a:label . (len(note) ? ': ' . note : ' (' . len(a:lines) . ')')] + s:Format(a:lines)) + call extend(a:to.lines, ['', a:label . (len(note) ? ': ' . note : ' (' . len(a:lines) . ')')] + s:Format(a:lines)) +endfunction + +function! s:AddDiffSection(to, stat, label, files) abort + if empty(a:files) + return + endif + let diff_section = a:stat.diff[a:label] + let expanded = a:stat.expanded[a:label] + let was_expanded = get(getbufvar(a:stat.bufnr, 'fugitive_expanded', {}), a:label, {}) + call extend(a:to.lines, ['', a:label . ' (' . len(a:files) . ')']) + for file in a:files + call add(a:to.lines, s:Format(file)) + if has_key(was_expanded, file.filename) + let [diff, start] = s:StageInlineGetDiff(diff_section, file) + if len(diff) + let expanded[file.filename] = [start] + call extend(a:to.lines, diff) + endif + endif + endfor endfunction function! s:QueryLog(refspec, limit, dir) abort @@ -2640,12 +2659,12 @@ function! s:QueryLogRange(old, new, dir) abort return s:QueryLog([a:old . '..' . a:new], 256, a:dir) endfunction -function! s:AddLogSection(label, log) abort +function! s:AddLogSection(to, label, log) abort if empty(a:log.entries) return endif let label = a:label . ' (' . len(a:log.entries) . (a:log.overflow ? '+' : '') . ')' - call append(line('$'), ['', label] + s:Format(a:log.entries)) + call extend(a:to.lines, ['', label] + s:Format(a:log.entries)) endfunction let s:rebase_abbrevs = { @@ -2662,51 +2681,79 @@ let s:rebase_abbrevs = { \ 'b': 'break', \ } -function! fugitive#BufReadStatus(cmdbang) abort - let amatch = s:Slash(expand('%:p')) - unlet! b:fugitive_reltime b:fugitive_type +function! s:MapStatus() abort + call fugitive#MapJumps() + call s:Map('n', '-', ":<C-U>execute <SID>Do('Toggle',0)<CR>", '<silent>') + call s:Map('x', '-', ":<C-U>execute <SID>Do('Toggle',1)<CR>", '<silent>') + call s:Map('n', 's', ":<C-U>execute <SID>Do('Stage',0)<CR>", '<silent>') + call s:Map('x', 's', ":<C-U>execute <SID>Do('Stage',1)<CR>", '<silent>') + call s:Map('n', 'u', ":<C-U>execute <SID>Do('Unstage',0)<CR>", '<silent>') + call s:Map('x', 'u', ":<C-U>execute <SID>Do('Unstage',1)<CR>", '<silent>') + call s:Map('n', 'U', ":<C-U>Git reset -q<CR>", '<silent>') + call s:MapMotion('gu', "exe <SID>StageJump(v:count, 'Untracked', 'Unstaged')") + call s:MapMotion('gU', "exe <SID>StageJump(v:count, 'Unstaged', 'Untracked')") + call s:MapMotion('gs', "exe <SID>StageJump(v:count, 'Staged')") + call s:MapMotion('gp', "exe <SID>StageJump(v:count, 'Unpushed')") + call s:MapMotion('gP', "exe <SID>StageJump(v:count, 'Unpulled')") + call s:MapMotion('gr', "exe <SID>StageJump(v:count, 'Rebasing')") + call s:Map('n', 'C', ":echoerr 'fugitive: C has been removed in favor of cc'<CR>", '<silent><unique>') + call s:Map('n', 'a', ":<C-U>execute <SID>Do('Toggle',0)<CR>", '<silent>') + call s:Map('n', 'i', ":<C-U>execute <SID>NextExpandedHunk(v:count1)<CR>", '<silent>') + call s:Map('n', "=", ":<C-U>execute <SID>StageInline('toggle',line('.'),v:count)<CR>", '<silent>') + call s:Map('n', "<", ":<C-U>execute <SID>StageInline('hide', line('.'),v:count)<CR>", '<silent>') + call s:Map('n', ">", ":<C-U>execute <SID>StageInline('show', line('.'),v:count)<CR>", '<silent>') + call s:Map('x', "=", ":<C-U>execute <SID>StageInline('toggle',line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>", '<silent>') + call s:Map('x', "<", ":<C-U>execute <SID>StageInline('hide', line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>", '<silent>') + call s:Map('x', ">", ":<C-U>execute <SID>StageInline('show', line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>", '<silent>') + call s:Map('n', 'D', ":echoerr 'fugitive: D has been removed in favor of dd'<CR>", '<silent><unique>') + call s:Map('n', 'dd', ":<C-U>execute <SID>StageDiff('Gdiffsplit')<CR>", '<silent>') + call s:Map('n', 'dh', ":<C-U>execute <SID>StageDiff('Ghdiffsplit')<CR>", '<silent>') + call s:Map('n', 'ds', ":<C-U>execute <SID>StageDiff('Ghdiffsplit')<CR>", '<silent>') + call s:Map('n', 'dp', ":<C-U>execute <SID>StageDiffEdit()<CR>", '<silent>') + call s:Map('n', 'dv', ":<C-U>execute <SID>StageDiff('Gvdiffsplit')<CR>", '<silent>') + call s:Map('n', 'd?', ":<C-U>help fugitive_d<CR>", '<silent>') + call s:Map('n', 'P', ":<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR>", '<silent>') + call s:Map('x', 'P', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>') + call s:Map('n', 'p', ":<C-U>if v:count<Bar>silent exe <SID>GF('pedit')<Bar>else<Bar>echoerr 'Use = for inline diff, I for :Git add/reset --patch, 1p for :pedit'<Bar>endif<CR>", '<silent>') + call s:Map('x', 'p', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>') + call s:Map('n', 'I', ":<C-U>execute <SID>StagePatch(line('.'),line('.'), 1)<CR>", '<silent>') + call s:Map('x', 'I', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"), 1)<CR>", '<silent>') + call s:Map('n', 'gq', ":<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>", '<silent>') + call s:Map('n', 'R', ":echohl WarningMsg<Bar>echo 'Reloading is automatic. Use :e to force'<Bar>echohl NONE<CR>", '<silent>') + call s:Map('n', 'g<Bar>', ":<C-U>echoerr 'Changed to X'<CR>", '<silent><unique>') + call s:Map('x', 'g<Bar>', ":<C-U>echoerr 'Changed to X'<CR>", '<silent><unique>') + call s:Map('n', 'X', ":<C-U>execute <SID>StageDelete(line('.'), 0, v:count)<CR>", '<silent>') + call s:Map('x', 'X', ":<C-U>execute <SID>StageDelete(line(\"'<\"), line(\"'>\"), v:count)<CR>", '<silent>') + call s:Map('n', 'gI', ":<C-U>execute <SID>StageIgnore(line('.'), line('.'), v:count)<CR>", '<silent>') + call s:Map('x', 'gI', ":<C-U>execute <SID>StageIgnore(line(\"'<\"), line(\"'>\"), v:count)<CR>", '<silent>') + call s:Map('n', '.', ':<C-U> <C-R>=<SID>StageArgs(0)<CR><Home>') + call s:Map('x', '.', ':<C-U> <C-R>=<SID>StageArgs(1)<CR><Home>') +endfunction + +function! s:StatusProcess(result, stat) abort + let stat = a:stat + let status_exec = a:stat.status + let config = a:stat.config + let dir = s:Dir(config) try - let config = fugitive#Config() - - let dir = s:Dir() - let cmd = [dir] - if amatch !~# '^fugitive:' && s:cpath($GIT_INDEX_FILE !=# '' ? resolve(s:GitIndexFileEnv()) : fugitive#Find('.git/index', dir)) !=# s:cpath(amatch) - let cmd += [{'env': {'GIT_INDEX_FILE': FugitiveGitPath(amatch)}}] - endif - - if fugitive#GitVersion(2, 15) - call add(cmd, '--no-optional-locks') - endif - - let tree = s:Tree(dir) - if !empty(tree) - let status_cmd = cmd + ['status', '-bz'] - call add(status_cmd, fugitive#GitVersion(2, 11) ? '--porcelain=v2' : '--porcelain') - let status = fugitive#Execute(status_cmd, function('len')) - endif - - doautocmd BufReadPre - setlocal noreadonly modifiable nomodeline buftype=nowrite - let b:fugitive_files = {'Staged': {}, 'Unstaged': {}} - let [staged, unstaged, untracked] = [[], [], []] - let props = {} + let stat.props = {} - if !exists('status') - let branch = FugitiveHead(0, dir) - let head = FugitiveHead(11, dir) + if empty(status_exec) + let stat.branch = FugitiveHead(0, config) - elseif fugitive#Wait(status).exit_status - throw 'fugitive: ' . s:JoinChomp(status.stderr) + elseif status_exec.exit_status + let stat.error = s:JoinChomp(status_exec.stderr) + return - elseif status.args[-1] ==# '--porcelain=v2' - let output = split(tr(join(status.stdout, "\1"), "\1\n", "\n\1"), "\1", 1)[0:-2] + elseif status_exec.args[-1] ==# '--porcelain=v2' + let output = split(tr(join(status_exec.stdout, "\1"), "\1\n", "\n\1"), "\1", 1)[0:-2] 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] + let stat.props[prop[1]] = prop[2] elseif line[0] ==# '?' call add(untracked, {'type': 'File', 'status': line[0], 'filename': line[2:-1], 'relative': [line[2:-1]]}) elseif line[0] !=# '#' @@ -2734,29 +2781,18 @@ function! fugitive#BufReadStatus(cmdbang) abort 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, dir) - endif + let stat.branch = substitute(get(stat.props, 'branch.head', '(unknown)'), '\C^(\%(detached\|unknown\))$', '', '') else - let output = split(tr(join(status.stdout, "\1"), "\1\n", "\n\1"), "\1", 1)[0:-2] + let output = split(tr(join(status_exec.stdout, "\1"), "\1\n", "\n\1"), "\1", 1)[0:-2] while get(output, 0, '') =~# '^\l\+:' call remove(output, 0) endwhile - let head = matchstr(output[0], '^## \zs\S\+\ze\%($\| \[\)') - if head =~# '\.\.\.' - let head = split(head, '\.\.\.')[0] - let branch = head - elseif head ==# 'HEAD' || empty(head) - let head = FugitiveHead(11, dir) - let branch = '' + let branch = matchstr(output[0], '^## \zs\S\+\ze\%($\| \[\)') + if branch =~# '\.\.\.' + let stat.branch = split(branch, '\.\.\.')[0] else - let branch = head + let stat.branch = branch ==# 'HEAD' ? '' : branch endif let i = 0 @@ -2785,22 +2821,26 @@ function! fugitive#BufReadStatus(cmdbang) abort endwhile endif - let diff_cmd = cmd + ['-c', 'diff.suppressBlankEmpty=false', '-c', 'core.quotePath=false', 'diff', '--color=never', '--no-ext-diff', '--no-prefix'] - let diff = {'Staged': {'stdout': ['']}, 'Unstaged': {'stdout': ['']}} + let diff_cmd = stat.cmd + ['-c', 'diff.suppressBlankEmpty=false', '-c', 'core.quotePath=false', 'diff', '--color=never', '--no-ext-diff', '--no-prefix'] + let stat.diff = {'Staged': {'stdout': ['']}, 'Unstaged': {'stdout': ['']}} if len(staged) - let diff['Staged'] = fugitive#Execute(diff_cmd + ['--cached'], function('len')) + let stat.diff['Staged'] = fugitive#Execute(diff_cmd + ['--cached'], function('len')) endif if len(unstaged) - let diff['Unstaged'] = fugitive#Execute(diff_cmd + ['--'] + map(copy(unstaged), 'tree . "/" . v:val.relative[0]'), function('len')) + let stat.diff['Unstaged'] = fugitive#Execute(diff_cmd + ['--'] + map(copy(unstaged), 'stat.work_tree . "/" . v:val.relative[0]'), function('len')) endif + let [stat.staged, stat.unstaged, stat.untracked] = [staged, unstaged, untracked] + + let stat.files = {'Staged': {}, 'Unstaged': {}} for dict in staged - let b:fugitive_files['Staged'][dict.filename] = dict + let stat.files['Staged'][dict.filename] = dict endfor for dict in unstaged - let b:fugitive_files['Unstaged'][dict.filename] = dict + let stat.files['Unstaged'][dict.filename] = dict endfor + let branch = stat.branch let fetch_remote = config.Get('branch.' . branch . '.remote', 'origin') let push_remote = config.Get('branch.' . branch . '.pushRemote', \ config.Get('remote.pushDefault', fetch_remote)) @@ -2810,25 +2850,13 @@ function! fugitive#BufReadStatus(cmdbang) abort if push_remote !=# '.' && empty(config.Get('remote.' . push_remote . '.push', config.Get('remote.' . push_remote . '.fetch'))) let push_remote = '' endif + let stat.fetch_remote = fetch_remote + let stat.push_remote = push_remote - let pull_type = 'Pull' - if empty(fetch_remote) || empty(branch) - let pull_ref = '' - elseif fetch_remote ==# '.' - let pull_ref = config.Get('branch.' . branch . '.merge', 'refs/heads/' . branch) + if empty(stat.fetch_remote) || empty(branch) + let stat.merge = '' else - let pull_ref = substitute(config.Get('branch.' . branch . '.merge', 'refs/heads/' . branch), '^refs/heads/', 'refs/remotes/' . fetch_remote . '/', '') - endif - if len(pull_ref) - let rebase = FugitiveConfigGet('branch.' . branch . '.rebase', config) - if empty(rebase) - let rebase = FugitiveConfigGet('pull.rebase', config) - endif - if rebase =~# '^\%(true\|yes\|on\|1\|interactive\|merges\|preserve\)$' - let pull_type = 'Rebase' - elseif rebase =~# '^\%(false\|no|off\|0\|\)$' - let pull_type = 'Merge' - endif + let stat.merge = config.Get('branch.' . branch . '.merge') endif let push_default = FugitiveConfigGet('push.default', config) @@ -2836,13 +2864,46 @@ function! fugitive#BufReadStatus(cmdbang) abort let push_default = fugitive#GitVersion(2) ? 'simple' : 'matching' endif if push_default ==# 'upstream' - let push_ref = pull_ref - elseif empty(push_remote) || empty(branch) - let push_ref = '' - elseif push_remote ==# '.' - let push_ref = 'refs/heads/' . branch + let stat.push = stat.merge + elseif empty(stat.push_remote) || empty(branch) + let stat.push = '' else - let push_ref = 'refs/remotes/' . push_remote . '/' . branch + let stat.push = 'refs/heads/' . branch + endif + + let stat.pull_type = 'Pull' + if len(stat.merge) + let rebase = FugitiveConfigGet('branch.' . branch . '.rebase', config) + if empty(rebase) + let rebase = FugitiveConfigGet('pull.rebase', config) + endif + if rebase =~# '^\%(true\|yes\|on\|1\|interactive\|merges\|preserve\)$' + let stat.pull_type = 'Rebase' + elseif rebase =~# '^\%(false\|no|off\|0\|\)$' + let stat.pull_type = 'Merge' + endif + endif + endtry +endfunction + +function! s:StatusRender(stat) abort + try + let stat = a:stat + call fugitive#Wait(stat.running) + if has_key(stat, 'error') + return 'echoerr ' . string('fugitive: ' . stat.error) + endif + let [staged, unstaged, untracked, config] = [stat.staged, stat.unstaged, stat.untracked, stat.config] + let dir = s:Dir(config) + + let pull_ref = stat.merge + if stat.fetch_remote !=# '.' + let pull_ref = substitute(pull_ref, '^refs/heads/', 'refs/remotes/' . stat.fetch_remote . '/', '') + endif + + let push_ref = stat.push + if stat.push_remote !=# '.' + let push_ref = substitute(push_ref, '^refs/heads/', 'refs/remotes/' . stat.push_remote . '/', '') endif let push_short = substitute(push_ref, '^refs/\w\+/', '', '') @@ -2854,19 +2915,15 @@ function! fugitive#BufReadStatus(cmdbang) abort let rebasing_dir = fugitive#Find('.git/rebase-apply/', dir) endif + call fugitive#Wait(stat.rev_parse) + let head = empty(stat.branch) ? stat.rev_parse.stdout[0] : stat.branch + let rebasing = [] let rebasing_head = 'detached HEAD' if exists('rebasing_dir') && filereadable(rebasing_dir . 'git-rebase-todo') let rebasing_head = substitute(readfile(rebasing_dir . 'head-name')[0], '\C^refs/heads/', '', '') - let len = 11 + let len = len(stat.rev_parse.stdout[0]) let lines = readfile(rebasing_dir . 'git-rebase-todo') - for line in lines - let hash = matchstr(line, '^[^a-z].*\s\zs[0-9a-f]\{4,\}\ze\.\.') - if len(hash) - let len = len(hash) - break - endif - endfor if getfsize(rebasing_dir . 'done') > 0 let done = readfile(rebasing_dir . 'done') call map(done, 'substitute(v:val, ''^\l\+\>'', "done", "")') @@ -2900,42 +2957,33 @@ function! fugitive#BufReadStatus(cmdbang) abort endif endif - let b:fugitive_diff = diff - if a:cmdbang - unlet! b:fugitive_expanded - endif - let expanded = get(b:, 'fugitive_expanded', {'Staged': {}, 'Unstaged': {}}) - let b:fugitive_expanded = {'Staged': {}, 'Unstaged': {}} - - silent keepjumps %delete_ - - call s:AddHeader('Head', head) - call s:AddHeader(pull_type, pull_short) + let stat.expanded = {'Staged': {}, 'Unstaged': {}} + let to = {'lines': []} + call s:AddHeader(to, 'Head', head) + call s:AddHeader(to, stat.pull_type, pull_short) if push_ref !=# pull_ref - call s:AddHeader('Push', push_short) + call s:AddHeader(to, 'Push', push_short) endif - if empty(tree) + if empty(stat.work_tree) if get(fugitive#ConfigGetAll('core.bare', config), 0, '') !~# '^\%(false\|no|off\|0\|\)$' - call s:AddHeader('Bare', 'yes') + call s:AddHeader(to, 'Bare', 'yes') else - call s:AddHeader('Error', s:worktree_error) + call s:AddHeader(to, 'Error', s:worktree_error) endif endif if get(fugitive#ConfigGetAll('advice.statusHints', config), 0, 'true') !~# '^\%(false\|no|off\|0\|\)$' - call s:AddHeader('Help', 'g?') + call s:AddHeader(to, 'Help', 'g?') endif - call s:AddSection('Rebasing ' . rebasing_head, rebasing) - call s:AddSection(get(get(sequencing, 0, {}), 'status', '') ==# 'revert' ? 'Reverting' : 'Cherry Picking', sequencing) - call s:AddSection('Untracked', untracked) - call s:AddSection('Unstaged', unstaged) - let unstaged_end = len(unstaged) ? line('$') : 0 - call s:AddSection('Staged', staged) - let staged_end = len(staged) ? line('$') : 0 + call s:AddSection(to, 'Rebasing ' . rebasing_head, rebasing) + call s:AddSection(to, get(get(sequencing, 0, {}), 'tous', '') ==# 'revert' ? 'Reverting' : 'Cherry Picking', sequencing) + call s:AddSection(to, 'Untracked', untracked) + call s:AddDiffSection(to, stat, 'Unstaged', unstaged) + call s:AddDiffSection(to, stat, 'Staged', staged) let unique_push_ref = push_ref ==# pull_ref ? '' : push_ref let unpushed_push = s:QueryLogRange(unique_push_ref, head, dir) - if get(props, 'branch.ab') =~# '^+0 ' + if get(stat.props, 'branch.ab') =~# '^+0 ' let unpushed_pull = {'error': 0, 'overflow': 0, 'entries': []} else let unpushed_pull = s:QueryLogRange(pull_ref, head, dir) @@ -2945,90 +2993,90 @@ function! fugitive#BufReadStatus(cmdbang) abort if unpushed_push.error == 1 let unpushed_push = unpushed_pull endif - call s:AddLogSection('Unpushed to ' . push_short, unpushed_push) - call s:AddLogSection('Unpushed to ' . pull_short, unpushed_pull) + call s:AddLogSection(to, 'Unpushed to ' . push_short, unpushed_push) + call s:AddLogSection(to, 'Unpushed to ' . pull_short, unpushed_pull) if unpushed_push.error && unpushed_pull.error && empty(rebasing) && - \ !empty(push_remote . fetch_remote) - call s:AddLogSection('Unpushed to *', s:QueryLog([head, '--not', '--remotes'], 256, dir)) + \ !empty(stat.push_remote . stat.fetch_remote) + call s:AddLogSection(to, 'Unpushed to *', s:QueryLog([head, '--not', '--remotes'], 256, dir)) endif - call s:AddLogSection('Unpulled from ' . push_short, s:QueryLogRange(head, unique_push_ref, dir)) - if len(pull_ref) && get(props, 'branch.ab') !~# ' -0$' - call s:AddLogSection('Unpulled from ' . pull_short, s:QueryLogRange(head, pull_ref, dir)) + call s:AddLogSection(to, 'Unpulled from ' . push_short, s:QueryLogRange(head, unique_push_ref, dir)) + if len(pull_ref) && get(stat.props, 'branch.ab') !~# ' -0$' + call s:AddLogSection(to, 'Unpulled from ' . pull_short, s:QueryLogRange(head, pull_ref, dir)) endif - setlocal nomodified readonly noswapfile - doautocmd BufReadPost - setlocal nomodifiable + let bufnr = stat.bufnr + setlocal noreadonly modifiable + if len(to.lines) < line('$') + silent keepjumps execute (len(to.lines)+1) . ',$delete_' + endif + call setline(1, to.lines) + call setbufvar(bufnr, 'fugitive_status', stat) + call setbufvar(bufnr, 'fugitive_expanded', stat.expanded) + setlocal nomodified readonly nomodifiable + return '' + finally + let b:fugitive_type = 'index' + endtry +endfunction + +function! s:StatusRetrieve(bufnr, ...) abort + let amatch = s:Slash(fnamemodify(bufname(a:bufnr), ':p')) + let dir = s:Dir(a:bufnr) + let config = fugitive#Config(dir, function('len')) + + let cmd = [dir] + if amatch !~# '^fugitive:' && s:cpath($GIT_INDEX_FILE !=# '' ? resolve(s:GitIndexFileEnv()) : fugitive#Find('.git/index', dir)) !=# s:cpath(amatch) + let cmd += [{'env': {'GIT_INDEX_FILE': FugitiveGitPath(amatch)}}] + endif + + if fugitive#GitVersion(2, 15) + call add(cmd, '--no-optional-locks') + endif + + let rev_parse_cmd = cmd + ['rev-parse', '--short', 'HEAD', '--'] + + let stat = {'bufnr': a:bufnr, 'reltime': reltime(), 'work_tree': s:Tree(dir), 'cmd': cmd, 'config': config} + if empty(stat.work_tree) + let stat.rev_parse = call('fugitive#Execute', [rev_parse_cmd, function('s:StatusProcess'), stat] + a:000) + let stat.status = {} + let stat.running = stat.rev_parse + else + let stat.rev_parse = fugitive#Execute(rev_parse_cmd) + let status_cmd = cmd + ['status', '-bz', fugitive#GitVersion(2, 11) ? '--porcelain=v2' : '--porcelain'] + let stat.status = call('fugitive#Execute', [status_cmd, function('s:StatusProcess'), stat] + a:000) + let stat.running = stat.status + endif + return stat +endfunction + +function! fugitive#BufReadStatus(cmdbang) abort + exe s:VersionCheck() + if a:cmdbang + unlet! b:fugitive_expanded + endif + let b:fugitive_type = 'index' + let stat = s:StatusRetrieve(bufnr('')) + try + let b:fugitive_loading = stat + doautocmd <nomodeline> BufReadPre + + setlocal readonly nomodifiable noswapfile nomodeline buftype=nowrite + call s:MapStatus() + + call s:StatusRender(stat) + + doautocmd <nomodeline> BufReadPost if &bufhidden ==# '' setlocal bufhidden=delete endif if !exists('b:dispatch') let b:dispatch = ':Git fetch --all' endif - call fugitive#MapJumps() - call s:Map('n', '-', ":<C-U>execute <SID>Do('Toggle',0)<CR>", '<silent>') - call s:Map('x', '-', ":<C-U>execute <SID>Do('Toggle',1)<CR>", '<silent>') - call s:Map('n', 's', ":<C-U>execute <SID>Do('Stage',0)<CR>", '<silent>') - call s:Map('x', 's', ":<C-U>execute <SID>Do('Stage',1)<CR>", '<silent>') - call s:Map('n', 'u', ":<C-U>execute <SID>Do('Unstage',0)<CR>", '<silent>') - call s:Map('x', 'u', ":<C-U>execute <SID>Do('Unstage',1)<CR>", '<silent>') - call s:Map('n', 'U', ":<C-U>Git reset -q<CR>", '<silent>') - call s:MapMotion('gu', "exe <SID>StageJump(v:count, 'Untracked', 'Unstaged')") - call s:MapMotion('gU', "exe <SID>StageJump(v:count, 'Unstaged', 'Untracked')") - call s:MapMotion('gs', "exe <SID>StageJump(v:count, 'Staged')") - call s:MapMotion('gp', "exe <SID>StageJump(v:count, 'Unpushed')") - call s:MapMotion('gP', "exe <SID>StageJump(v:count, 'Unpulled')") - call s:MapMotion('gr', "exe <SID>StageJump(v:count, 'Rebasing')") - call s:Map('n', 'C', ":echoerr 'fugitive: C has been removed in favor of cc'<CR>", '<silent><unique>') - call s:Map('n', 'a', ":<C-U>execute <SID>Do('Toggle',0)<CR>", '<silent>') - call s:Map('n', 'i', ":<C-U>execute <SID>NextExpandedHunk(v:count1)<CR>", '<silent>') - call s:Map('n', "=", ":<C-U>execute <SID>StageInline('toggle',line('.'),v:count)<CR>", '<silent>') - call s:Map('n', "<", ":<C-U>execute <SID>StageInline('hide', line('.'),v:count)<CR>", '<silent>') - call s:Map('n', ">", ":<C-U>execute <SID>StageInline('show', line('.'),v:count)<CR>", '<silent>') - call s:Map('x', "=", ":<C-U>execute <SID>StageInline('toggle',line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>", '<silent>') - call s:Map('x', "<", ":<C-U>execute <SID>StageInline('hide', line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>", '<silent>') - call s:Map('x', ">", ":<C-U>execute <SID>StageInline('show', line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>", '<silent>') - call s:Map('n', 'D', ":echoerr 'fugitive: D has been removed in favor of dd'<CR>", '<silent><unique>') - call s:Map('n', 'dd', ":<C-U>execute <SID>StageDiff('Gdiffsplit')<CR>", '<silent>') - call s:Map('n', 'dh', ":<C-U>execute <SID>StageDiff('Ghdiffsplit')<CR>", '<silent>') - call s:Map('n', 'ds', ":<C-U>execute <SID>StageDiff('Ghdiffsplit')<CR>", '<silent>') - call s:Map('n', 'dp', ":<C-U>execute <SID>StageDiffEdit()<CR>", '<silent>') - call s:Map('n', 'dv', ":<C-U>execute <SID>StageDiff('Gvdiffsplit')<CR>", '<silent>') - call s:Map('n', 'd?', ":<C-U>help fugitive_d<CR>", '<silent>') - call s:Map('n', 'P', ":<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR>", '<silent>') - call s:Map('x', 'P', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>') - call s:Map('n', 'p', ":<C-U>if v:count<Bar>silent exe <SID>GF('pedit')<Bar>else<Bar>echoerr 'Use = for inline diff, P for :Git add/reset --patch, 1p for :pedit'<Bar>endif<CR>", '<silent>') - call s:Map('x', 'p', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>') - call s:Map('n', 'I', ":<C-U>execute <SID>StagePatch(line('.'),line('.'))<CR>", '<silent>') - call s:Map('x', 'I', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>') - call s:Map('n', 'gq', ":<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>", '<silent>') - call s:Map('n', 'R', ":echohl WarningMsg<Bar>echo 'Reloading is automatic. Use :e to force'<Bar>echohl NONE<CR>", '<silent>') - call s:Map('n', 'g<Bar>', ":<C-U>echoerr 'Changed to X'<CR>", '<silent><unique>') - call s:Map('x', 'g<Bar>', ":<C-U>echoerr 'Changed to X'<CR>", '<silent><unique>') - call s:Map('n', 'X', ":<C-U>execute <SID>StageDelete(line('.'), 0, v:count)<CR>", '<silent>') - call s:Map('x', 'X', ":<C-U>execute <SID>StageDelete(line(\"'<\"), line(\"'>\"), v:count)<CR>", '<silent>') - call s:Map('n', 'gI', ":<C-U>execute <SID>StageIgnore(line('.'), line('.'), v:count)<CR>", '<silent>') - call s:Map('x', 'gI', ":<C-U>execute <SID>StageIgnore(line(\"'<\"), line(\"'>\"), v:count)<CR>", '<silent>') - call s:Map('n', '.', ':<C-U> <C-R>=<SID>StageArgs(0)<CR><Home>') - call s:Map('x', '.', ':<C-U> <C-R>=<SID>StageArgs(1)<CR><Home>') setlocal filetype=fugitive - for [lnum, section] in [[staged_end, 'Staged'], [unstaged_end, 'Unstaged']] - while len(getline(lnum)) - let filename = matchstr(getline(lnum), '^[A-Z?] \zs.*') - if has_key(expanded[section], filename) - call s:StageInline('show', lnum) - endif - let lnum -= 1 - endwhile - endfor - - let b:fugitive_reltime = reltime() return s:DoAutocmd('User FugitiveIndex') - catch /^fugitive:/ - return 'echoerr ' . string(v:exception) finally - let b:fugitive_type = 'index' + call setbufvar(stat.bufnr, 'fugitive_loading', {}) endtry endfunction @@ -3094,15 +3142,16 @@ endfunction function! fugitive#BufReadCmd(...) abort let amatch = a:0 ? a:1 : expand('<amatch>') + let [dir, rev] = s:DirRev(amatch) + if empty(dir) + return 'echo "Invalid Fugitive URL"' + endif + call s:InitializeBuffer(dir) + if rev ==# ':' + return fugitive#BufReadStatus(v:cmdbang) + endif try - let [dir, rev] = s:DirRev(amatch) - if empty(dir) - return 'echo "Invalid Fugitive URL"' - endif - call s:InitializeBuffer(dir) - if rev ==# ':' - return fugitive#BufReadStatus(v:cmdbang) - elseif rev =~# '^:\d$' + if rev =~# '^:\d$' let b:fugitive_type = 'stage' else let r = fugitive#Execute([dir, 'cat-file', '-t', rev]) @@ -3172,7 +3221,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, '-c', 'diff.noprefix=false', '-c', 'log.showRoot=false', '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]) + call s:ReplaceCmd([dir, '-c', 'diff.noprefix=false', '-c', 'log.showRoot=false', '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%B', rev]) keepjumps 1 keepjumps call search('^parent ') if getline('.') ==# 'parent ' @@ -3329,8 +3378,9 @@ function! s:TempReadPost(file) abort if !&modifiable call s:Map('n', 'gq', ":<C-U>bdelete<CR>", '<silent> <unique>') endif + return 'doautocmd <nomodeline> User FugitivePager' endif - return s:DoAutocmd('User FugitivePager') + return '' endfunction function! s:TempDelete(file) abort @@ -3395,7 +3445,7 @@ function! s:RunEdit(state, tmp, job) abort let sentinel = a:state.file . '.edit' let file = FugitiveVimPath(readfile(sentinel, '', 1)[0]) try - if !&equalalways && a:state.mods !~# '\<tab\>' && 3 > (a:state.mods =~# '\<vert' ? winwidth(0) : winheight(0)) + if !&equalalways && a:state.mods !~# '\<\d*tab\>' && 3 > (a:state.mods =~# '\<vert' ? winwidth(0) : winheight(0)) let noequalalways = 1 setglobal equalalways endif @@ -3746,6 +3796,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg, ...) abort let flags = [] let pager = -1 let explicit_pathspec_option = 0 + let did_expand_alias = 0 while len(args) if args[0] ==# '-c' && len(args) > 1 call extend(flags, remove(args, 0, 1)) @@ -3762,8 +3813,18 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg, ...) abort call add(flags, remove(args, 0)) elseif args[0] =~# '^-C$\|^--\%(exec-path=\|git-dir=\|work-tree=\|bare$\)' return 'echoerr ' . string('fugitive: ' . args[0] . ' is not supported') - else + elseif did_expand_alias break + else + let alias = FugitiveConfigGet('alias.' . get(args, 0, ''), config) + if get(args, 1, '') !=# '--help' && alias !~# '^$\|^!\|[\"'']' && !filereadable(s:VimExecPath() . '/git-' . args[0]) + \ && !(has('win32') && filereadable(s:VimExecPath() . '/git-' . args[0] . '.exe')) + call remove(args, 0) + call extend(args, split(alias, '\s\+'), 'keep') + let did_expand_alias = 1 + else + break + endif endif endwhile if !explicit_pathspec_option @@ -3795,12 +3856,6 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg, ...) abort let cmd = s:StatusCommand(a:line1, a:line2, a:range, curwin ? 0 : a:line2, a:bang, a:mods, '', '', [], options) return (empty(cmd) ? 'exe' : cmd) . after endif - let alias = FugitiveConfigGet('alias.' . get(args, 0, ''), config) - if get(args, 1, '') !=# '--help' && alias !~# '^$\|^!\|[\"'']' && !filereadable(s:VimExecPath() . '/git-' . args[0]) - \ && !(has('win32') && filereadable(s:VimExecPath() . '/git-' . args[0] . '.exe')) - call remove(args, 0) - call extend(args, split(alias, '\s\+'), 'keep') - endif let name = substitute(get(args, 0, ''), '\%(^\|-\)\(\l\)', '\u\1', 'g') if pager is# -1 && name =~# '^\a\+$' && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' try @@ -3895,6 +3950,9 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg, ...) abort \ 'GIT_SEQUENCE_EDITOR': editor, \ 'GIT_PAGER': 'cat', \ 'PAGER': 'cat'}, 'keep') + if s:executable('col') + let env.MANPAGER = 'col -b' + endif if len($GPG_TTY) && !has_key(env, 'GPG_TTY') let env.GPG_TTY = '' let did_override_gpg_tty = 1 @@ -4280,7 +4338,7 @@ function! s:DoAutocmdChanged(dir) abort endfunction function! s:ReloadStatusBuffer() abort - if get(b:, 'fugitive_type', '') !=# 'index' + if get(b:, 'fugitive_type', '') !=# 'index' || !empty(get(b:, 'fugitive_loading')) return '' endif let original_lnum = line('.') @@ -4319,14 +4377,14 @@ function! s:ExpireStatus(bufnr) abort endfunction function! s:ReloadWinStatus(...) abort - if get(b:, 'fugitive_type', '') !=# 'index' || &modified + if get(b:, 'fugitive_type', '') !=# 'index' || !empty(get(b:, 'fugitive_loading')) || &modified return endif - if !exists('b:fugitive_reltime') + if !exists('b:fugitive_status.reltime') exe call('s:ReloadStatusBuffer', a:000) return endif - let t = b:fugitive_reltime + let t = b:fugitive_status.reltime if reltimestr(reltime(s:last_time, t)) =~# '-\|\d\{10\}\.' || \ reltimestr(reltime(get(s:last_times, s:Tree() . '/', t), t)) =~# '-\|\d\{10\}\.' exe call('s:ReloadStatusBuffer', a:000) @@ -4334,6 +4392,15 @@ function! s:ReloadWinStatus(...) abort endfunction function! s:ReloadTabStatus() abort + if !exists('g:fugitive_did_change_at') + return + elseif exists('t:fugitive_reloaded_at') + let time_ahead = reltime(g:fugitive_did_change_at, t:fugitive_reloaded_at) + if reltimefloat(time_ahead) >= 0 + return + endif + endif + let t:fugitive_reloaded_at = reltime() let winnr = 1 while winnr <= winnr('$') if getbufvar(winbufnr(winnr), 'fugitive_type') ==# 'index' @@ -4352,17 +4419,12 @@ function! s:ReloadTabStatus() abort endif let winnr += 1 endwhile - unlet! t:fugitive_reload_status endfunction function! fugitive#DidChange(...) abort call s:ExpireStatus(a:0 ? a:1 : -1) if a:0 > 1 ? a:2 : (!a:0 || a:1 isnot# 0) - let t = reltime() - let t:fugitive_reload_status = t - for tabnr in range(1, tabpagenr('$')) - call settabvar(tabnr, 'fugitive_reload_status', t) - endfor + let g:fugitive_did_change_at = reltime() call s:ReloadTabStatus() else call s:ReloadWinStatus() @@ -4405,11 +4467,13 @@ augroup fugitive_status autocmd BufEnter index,index.lock,fugitive://*// \ call s:ReloadWinStatus() autocmd TabEnter * - \ if exists('t:fugitive_reload_status') | - \ call s:ReloadTabStatus() | - \ endif + \ call s:ReloadTabStatus() augroup END +function! s:StatusSectionFile(heading, filename) abort + return get(get(get(get(b:, 'fugitive_status', {}), 'files', {}), a:heading, {}), a:filename, {}) +endfunction + function! s:StageInfo(...) abort let lnum = a:0 ? a:1 : line('.') let sigil = matchstr(getline(lnum), '^[ @\+-]') @@ -4432,7 +4496,7 @@ function! s:StageInfo(...) abort endif endwhile let text = matchstr(getline(lnum), '^[A-Z?] \zs.*') - let file = get(get(b:fugitive_files, heading, {}), text, {}) + let file = s:StatusSectionFile(heading, text) let relative = get(file, 'relative', len(text) ? [text] : []) return {'section': matchstr(heading, '^\u\l\+'), \ 'heading': heading, @@ -4514,7 +4578,7 @@ function! s:Selection(arg1, ...) abort let results[-1].lnum = lnum elseif line =~# '^[A-Z?] ' let text = matchstr(line, '^[A-Z?] \zs.*') - let file = get(get(b:fugitive_files, template.heading, {}), text, {}) + let file = s:StatusSectionFile(template.heading, text) let relative = get(file, 'relative', len(text) ? [text] : []) call add(results, extend(deepcopy(template), { \ 'lnum': lnum, @@ -4815,6 +4879,29 @@ function! s:PatchSearchExpr(reverse) abort return a:reverse ? '#' : '*' endfunction +function! s:StageInlineGetDiff(diff_section, info) abort + let diff = [] + if a:info.status ==# 'U' + let diff_header = 'diff --cc ' . s:Quote(a:info.relative[0]) + else + let diff_header = 'diff --git ' . s:Quote(a:info.relative[-1]) . ' ' . s:Quote(a:info.relative[0]) + endif + let stdout = fugitive#Wait(a:diff_section).stdout + let start = index(stdout, diff_header) + if start == -1 + return [[], -1] + endif + let index = start + 1 + while get(stdout, index, '@@') !~# '^@@\|^diff ' + let index += 1 + endwhile + while get(stdout, index, '') =~# '^[@ \+-]' + call add(diff, stdout[index]) + let index += 1 + endwhile + return [diff, start] +endfunction + function! s:StageInline(mode, ...) abort if &filetype !=# 'fugitive' return '' @@ -4839,7 +4926,8 @@ function! s:StageInline(mode, ...) abort let lnum -= 1 endwhile let info = s:StageInfo(lnum) - if !has_key(b:fugitive_diff, info.section) + let diff_section = get(get(get(b:, 'fugitive_status', {}), 'diff', {}), info.section, {}) + if empty(diff_section) continue endif if getline(lnum + 1) =~# '^[ @\+-]' @@ -4855,29 +4943,10 @@ function! s:StageInline(mode, ...) abort endif continue endif - if !has_key(b:fugitive_diff, info.section) || info.status !~# '^[ADMRU]$' || a:mode ==# 'hide' + if info.status !~# '^[ADMRU]$' || a:mode ==# 'hide' continue endif - let mode = '' - let diff = [] - if info.status ==# 'U' - let diff_header = 'diff --cc ' . s:Quote(info.relative[0]) - else - let diff_header = 'diff --git ' . s:Quote(info.relative[-1]) . ' ' . s:Quote(info.relative[0]) - endif - let stdout = fugitive#Wait(b:fugitive_diff[info.section]).stdout - let start = index(stdout, diff_header) - if start == -1 - continue - endif - let index = start + 1 - while get(stdout, index, '@@') !~# '^@@\|^diff ' - let index += 1 - endwhile - while get(stdout, index, '') =~# '^[@ \+-]' - call add(diff, stdout[index]) - let index += 1 - endwhile + let [diff, start] = s:StageInlineGetDiff(diff_section, info) if len(diff) setlocal modifiable noreadonly silent call append(lnum, diff) @@ -4917,19 +4986,19 @@ function! s:StageDiff(diff) abort return 'Git --paginate diff --no-ext-diff' elseif len(info.paths) > 1 execute 'Gedit' . prefix s:fnameescape(':0:' . info.paths[0]) - return a:diff . '! @:'.s:fnameescape(info.paths[1]) + return 'keepalt ' . a:diff . '! @:'.s:fnameescape(info.paths[1]) elseif info.section ==# 'Staged' && info.sigil ==# '-' execute 'Gedit' prefix s:fnameescape(':0:'.info.paths[0]) - return a:diff . '! :0:%' + return 'keepalt ' . a:diff . '! :0:%' elseif info.section ==# 'Staged' execute 'Gedit' prefix s:fnameescape(':0:'.info.paths[0]) - return a:diff . '! @:%' + return 'keepalt ' . a:diff . '! @:%' elseif info.sigil ==# '-' execute 'Gedit' prefix s:fnameescape(':0:'.info.paths[0]) - return a:diff . '! :(top)%' + return 'keepalt ' . a:diff . '! :(top)%' else execute 'Gedit' prefix s:fnameescape(':(top)'.info.paths[0]) - return a:diff . '!' + return 'keepalt ' . a:diff . '!' endif endfunction @@ -4979,7 +5048,7 @@ function! s:StageApply(info, reverse, extra) abort endif let i = b:fugitive_expanded[info.section][info.filename][0] let head = [] - let diff_lines = fugitive#Wait(b:fugitive_diff[info.section]).stdout + let diff_lines = fugitive#Wait(b:fugitive_status.diff[info.section]).stdout while get(diff_lines, i, '@') !~# '^@' let line = diff_lines[i] if line ==# '--- /dev/null' @@ -5017,7 +5086,7 @@ function! s:StageDelete(lnum1, lnum2, count) abort endif continue endif - let sub = get(get(get(b:fugitive_files, info.section, {}), info.filename, {}), 'submodule') + let sub = get(s:StatusSectionFile(info.section, info.filename), 'submodule', '') if sub =~# '^S' && info.status ==# 'M' let undo = 'Git checkout ' . fugitive#RevParse('HEAD', FugitiveExtractGitDir(info.paths[0]))[0:10] . ' --' elseif sub =~# '^S' @@ -5041,19 +5110,19 @@ function! s:StageDelete(lnum1, lnum2, count) abort elseif info.status ==# '?' call s:TreeChomp('clean', '-f', '--', info.paths[0]) elseif a:count == 2 - if get(b:fugitive_files['Staged'], info.filename, {'status': ''}).status ==# 'D' + if get(s:StatusSectionFile('Staged', info.filename), 'status', '') ==# 'D' call delete(info.paths[0]) else call s:TreeChomp('checkout', '--ours', '--', info.paths[0]) endif elseif a:count == 3 - if get(b:fugitive_files['Unstaged'], info.filename, {'status': ''}).status ==# 'D' + if get(s:StatusSectionFile('Unstaged', info.filename), 'status', '') ==# 'D' call delete(info.paths[0]) else call s:TreeChomp('checkout', '--theirs', '--', info.paths[0]) endif elseif info.status =~# '[ADU]' && - \ get(b:fugitive_files[info.section ==# 'Staged' ? 'Unstaged' : 'Staged'], info.filename, {'status': ''}).status =~# '[AU]' + \ get(s:StatusSectionFile(info.section ==# 'Staged' ? 'Unstaged' : 'Staged', info.filename), 'status', '') =~# '[AU]' if get(g:, 'fugitive_conflict_x', 0) call s:TreeChomp('checkout', info.section ==# 'Unstaged' ? '--ours' : '--theirs', '--', info.paths[0]) else @@ -5126,11 +5195,12 @@ function! s:DoToggleHelpHeader(value) abort endfunction function! s:DoStagePushHeader(value) abort - let remote = matchstr(a:value, '\zs[^/]\+\ze/') - if empty(remote) - let remote = '.' + let stat = get(b:, 'fugitive_status', {}) + let remote = get(stat, 'push_remote', '') + let branch = substitute(get(stat, 'push', ''), '^ref/heads/', '', '') + if empty(remote) || empty(branch) + return endif - let branch = matchstr(a:value, '\%([^/]\+/\)\=\zs\S\+') call feedkeys(':Git push ' . remote . ' ' . branch) endfunction @@ -5139,15 +5209,13 @@ function! s:DoTogglePushHeader(value) abort endfunction function! s:DoStageUnpushedHeading(heading) abort - let remote = matchstr(a:heading, 'to \zs[^/]\+\ze/') - if empty(remote) - let remote = '.' - endif - let branch = matchstr(a:heading, 'to \%([^/]\+/\)\=\zs\S\+') - if branch ==# '*' + let stat = get(b:, 'fugitive_status', {}) + let remote = get(stat, 'push_remote', '') + let push = get(stat, 'push', '') + if empty(remote) || empty(push) return endif - call feedkeys(':Git push ' . remote . ' ' . '@:' . 'refs/heads/' . branch) + call feedkeys(':Git push ' . remote . ' ' . '@:' . push) endfunction function! s:DoToggleUnpushedHeading(heading) abort @@ -5155,15 +5223,13 @@ function! s:DoToggleUnpushedHeading(heading) abort endfunction function! s:DoStageUnpushed(record) abort - let remote = matchstr(a:record.heading, 'to \zs[^/]\+\ze/') - if empty(remote) - let remote = '.' - endif - let branch = matchstr(a:record.heading, 'to \%([^/]\+/\)\=\zs\S\+') - if branch ==# '*' + let stat = get(b:, 'fugitive_status', {}) + let remote = get(stat, 'push_remote', '') + let push = get(stat, 'push', '') + if empty(remote) || empty(push) return endif - call feedkeys(':Git push ' . remote . ' ' . a:record.commit . ':' . 'refs/heads/' . branch) + call feedkeys(':Git push ' . remote . ' ' . a:record.commit . ':' . push) endfunction function! s:DoToggleUnpushed(record) abort @@ -5261,10 +5327,11 @@ function! s:DoStageUntracked(record) abort return s:DoToggleUntracked(a:record) endfunction -function! s:StagePatch(lnum1,lnum2) abort +function! s:StagePatch(lnum1, lnum2, ...) abort let add = [] let reset = [] let intend = [] + let patch_only = a:0 && a:1 for lnum in range(a:lnum1,a:lnum2) let info = s:StageInfo(lnum) @@ -5277,6 +5344,13 @@ function! s:StagePatch(lnum1,lnum2) abort elseif empty(info.paths) && info.section ==# 'Untracked' execute 'tab Git add --interactive' break + elseif !patch_only && info.section ==# 'Unpushed' + if empty(info.commit) + call s:DoStageUnpushedHeading(info) + else + call s:DoStageUnpushed(info) + endif + return '' elseif empty(info.paths) continue endif @@ -5431,7 +5505,9 @@ function! s:ToolItems(state, from, to, offsets, text, ...) abort endif call add(items, item) endfor - let items[-1].context = {'diff': items[0:-2]} + if get(a:offsets, 0, '') isnot# 'none' + let items[-1].context = {'diff': items[0:-2]} + endif return [items[-1]] endfunction @@ -5487,6 +5563,10 @@ function! s:ToolParse(state, line) abort let [_, add, remove, to; __] = matchlist(a:line, '^\(\d\+\|-\)\t\(\d\+\|-\)\t\(.*\)') let [to, from] = s:ToolToFrom(to) return s:ToolItems(a:state, from, to, [], add ==# '-' ? 'Binary file' : '+' . add . ' -' . remove, add !=# '-') + elseif a:line =~# '^\f\+:\d\+: \D' + " --check + let [_, to, line, text; __] = matchlist(a:line, '^\(\f\+\):\(\d\+\):\s*\(.*\)$') + return s:ToolItems(a:state, to, to, ['none', line], text) elseif a:state.mode !=# 'diffhead' && a:state.mode !=# 'hunk' && len(a:line) || a:line =~# '^git: \|^usage: \|^error: \|^fatal: ' return [{'text': a:line}] endif @@ -5541,7 +5621,7 @@ function! s:ToolStream(line1, line2, range, bang, mods, options, args, state) ab for item in s:ToolParse(a:state, line) if len(get(item, 'filename', '')) && item.filename != filename call add(cmd, 'tabedit ' . s:fnameescape(item.filename)) - for i in reverse(range(len(get(item.context, 'diff', [])))) + for i in reverse(range(len(get(get(item, 'context', {}), 'diff', [])))) call add(cmd, (i ? 'rightbelow' : 'leftabove') . ' vertical Gdiffsplit! ' . s:fnameescape(item.context.diff[i].filename)) endfor call add(cmd, 'wincmd =') @@ -5714,7 +5794,7 @@ function! s:GrepOptions(args, dir) abort let options = {'name_only': 0, 'name_count': 0, 'line_number': 0} let tree = s:Tree(a:dir) let prefix = empty(tree) ? fugitive#Find(':0:', a:dir) : - \ s:cpath(getcwd(), tree) ? '' : s:VimSlash(tree . '/') + \ s:VimSlash(tree . '/') let options.prefix = prefix for arg in a:args if arg ==# '--' @@ -6042,6 +6122,7 @@ endfunction function! s:UsableWin(nr) abort return a:nr && !getwinvar(a:nr, '&previewwindow') && !getwinvar(a:nr, '&winfixwidth') && + \ !getwinvar(a:nr, '&winfixbuf') && \ (empty(getwinvar(a:nr, 'fugitive_status')) || getbufvar(winbufnr(a:nr), 'fugitive_type') !=# 'index') && \ index(['gitrebase', 'gitcommit'], getbufvar(winbufnr(a:nr), '&filetype')) < 0 && \ index(['nofile','help','quickfix', 'terminal'], getbufvar(winbufnr(a:nr), '&buftype')) < 0 @@ -6173,7 +6254,7 @@ function! fugitive#DiffClose() abort endfunction function! s:BlurStatus() abort - if (&previewwindow || exists('w:fugitive_status')) && get(b:,'fugitive_type', '') ==# 'index' + if (&previewwindow || getwinvar(winnr(), '&winfixbuf') is# 1 || exists('w:fugitive_status')) && get(b:, 'fugitive_type', '') ==# 'index' let winnrs = filter([winnr('#')] + range(1, winnr('$')), 's:UsableWin(v:val)') if len(winnrs) exe winnrs[0].'wincmd w' @@ -6544,9 +6625,9 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, ...) abort return s:Mods(a:mods) . 'DiffGitCached' . (len(post) ? '|' . post : '') endif let commit = s:DirCommitFile(@%)[1] - if a:mods =~# '\<tab\>' - let mods = substitute(a:mods, '\<tab\>', '', 'g') - let pre = 'tab split' + if a:mods =~# '\<\d*tab\>' + let mods = substitute(a:mods, '\<\d*tab\>', '', 'g') + let pre = matchstr(a:mods, '\<\d*tab\>') . 'edit' else let mods = 'keepalt ' . a:mods let pre = '' @@ -7024,15 +7105,16 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort endif return reload[1 : -1] endif - if a:mods =~# '\<tab\>' - silent tabedit % + let tabmod = matchstr(a:mods, '\<\d*tab\>') + let mods = substitute(a:mods, '\<\d*tab\>', '', 'g') + if !empty(tabmod) + silent execute tabmod . 'edit %' endif let temp_state.origin_bufnr = bufnr('') if exists('*win_getid') let temp_state.origin_winid = win_getid() endif let restore = [] - let mods = substitute(a:mods, '\<tab\>', '', 'g') for winnr in range(winnr('$'),1,-1) if getwinvar(winnr, '&scrollbind') if !&l:scrollbind @@ -7066,6 +7148,9 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort normal! zt execute current setlocal nonumber scrollbind nowrap foldcolumn=0 nofoldenable winfixwidth + if exists('&winfixbuf') + setlocal winfixbuf + endif if exists('+relativenumber') setlocal norelativenumber endif @@ -7208,7 +7293,7 @@ function! fugitive#BlameSyntax() abort exec 'syn match FugitiveblameOriginalFile "\s\%(\f\+\D\@<=\|\D\@=\f\+\)\%(\%(\s\+\d\+\)\=\s\%((\|\s*\d\+)\)\)\@=" contained nextgroup=FugitiveblameOriginalLineNumber,FugitiveblameAnnotation skipwhite' (s:HasOpt(flags, '--show-name', '-f') ? '' : conceal) exec 'syn match FugitiveblameOriginalLineNumber "\s*\d\+\%(\s(\)\@=" contained nextgroup=FugitiveblameAnnotation skipwhite' (s:HasOpt(flags, '--show-number', '-n') ? '' : conceal) exec 'syn match FugitiveblameOriginalLineNumber "\s*\d\+\%(\s\+\d\+)\)\@=" contained nextgroup=FugitiveblameShort skipwhite' (s:HasOpt(flags, '--show-number', '-n') ? '' : conceal) - syn match FugitiveblameShort " \d\+)" contained contains=FugitiveblameLineNumber + syn match FugitiveblameShort " \+\d\+)" contained contains=FugitiveblameLineNumber syn match FugitiveblameNotCommittedYet "(\@<=Not Committed Yet\>" contained containedin=FugitiveblameAnnotation hi def link FugitiveblameBoundary Keyword hi def link FugitiveblameHash Identifier @@ -7278,7 +7363,7 @@ function! s:BlameMaps(is_ftplugin) abort call s:Map('n', '-', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>', ft) call s:Map('n', 's', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>', ft) call s:Map('n', 'u', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>', ft) - call s:Map('n', 'P', ':<C-U>exe <SID>BlameJump("^".v:count1)<CR>', '<silent>', ft) + call s:Map('n', 'P', ':<C-U>if !v:count<Bar>echoerr "Use ~ (or provide a count)"<Bar>else<Bar>exe <SID>BlameJump("^".v:count1)<Bar>endif<CR>', '<silent>', ft) call s:Map('n', '~', ':<C-U>exe <SID>BlameJump("~".v:count1)<CR>', '<silent>', ft) call s:Map('n', 'i', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft) call s:Map('n', 'o', ':<C-U>exe <SID>BlameCommit("split")<CR>', '<silent>', ft) @@ -7356,6 +7441,8 @@ function! s:BrowserOpen(url, mods, echo_copy) abort return 'echo '.string(url).'|' . mods . 'call netrw#BrowseX('.string(url).', 0)' elseif exists('*netrw#NetrwBrowseX') return 'echo '.string(url).'|' . mods . 'call netrw#NetrwBrowseX('.string(url).', 0)' + elseif has('nvim-0.10') + return mods . 'echo luaeval("({vim.ui.open(_A)})[2] or _A", ' . string(url) . ')' else return 'echoerr ' . string('Netrw not found. Define your own :Browse to use :GBrowse') endif @@ -7908,10 +7995,10 @@ function! fugitive#MapJumps(...) abort endif call s:Map('n', 'D', ":echoerr 'fugitive: D has been removed in favor of dd'<CR>", '<silent><unique>') - call s:Map('n', 'dd', ":<C-U>call fugitive#DiffClose()<Bar>Gdiffsplit!<CR>", '<silent>') - call s:Map('n', 'dh', ":<C-U>call fugitive#DiffClose()<Bar>Ghdiffsplit!<CR>", '<silent>') - call s:Map('n', 'ds', ":<C-U>call fugitive#DiffClose()<Bar>Ghdiffsplit!<CR>", '<silent>') - call s:Map('n', 'dv', ":<C-U>call fugitive#DiffClose()<Bar>Gvdiffsplit!<CR>", '<silent>') + call s:Map('n', 'dd', ":<C-U>call fugitive#DiffClose()<Bar>keepalt Gdiffsplit!<CR>", '<silent>') + call s:Map('n', 'dh', ":<C-U>call fugitive#DiffClose()<Bar>keepalt Ghdiffsplit!<CR>", '<silent>') + call s:Map('n', 'ds', ":<C-U>call fugitive#DiffClose()<Bar>keepalt Ghdiffsplit!<CR>", '<silent>') + call s:Map('n', 'dv', ":<C-U>call fugitive#DiffClose()<Bar>keepalt Gvdiffsplit!<CR>", '<silent>') call s:Map('n', 'd?', ":<C-U>help fugitive_d<CR>", '<silent>') else @@ -7946,7 +8033,7 @@ function! fugitive#MapJumps(...) abort call s:Map('n', 'S', ':<C-U>echoerr "Use gO"<CR>', '<silent><unique>') call s:Map('n', 'dq', ":<C-U>call fugitive#DiffClose()<CR>", '<silent>') call s:Map('n', '-', ":<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>NavigateUp(v:count1))<Bar> if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))<Bar>call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')<Bar>endif<CR>", '<silent>') - call s:Map('n', 'P', ":<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<CR>", '<silent>') + call s:Map('n', 'P', ":<C-U>if !v:count<Bar>echoerr 'Use ~ (or provide a count)'<Bar>else<Bar>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<Bar>endif<CR>", '<silent>') call s:Map('n', '~', ":<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'~'.v:count1.<SID>Relative(':'))<CR>", '<silent>') call s:Map('n', 'C', ":<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR>", '<silent>') call s:Map('n', 'cp', ":<C-U>echoerr 'Use gC'<CR>", '<silent><unique>') @@ -8327,8 +8414,8 @@ function! fugitive#Foldtext() abort elseif &filetype ==# 'gitcommit' && line_foldstart =~# '^# .*:$' let lines = getline(v:foldstart, v:foldend) call filter(lines, 'v:val =~# "^#\t"') - cal map(lines, "s:sub(v:val, '^#\t%(modified: +|renamed: +)=', '')") - cal map(lines, "s:sub(v:val, '^([[:alpha:] ]+): +(.*)', '\\2 (\\1)')") + call map(lines, "s:sub(v:val, '^#\t%(modified: +|renamed: +)=', '')") + call map(lines, "s:sub(v:val, '^([[:alpha:] ]+): +(.*)', '\\2 (\\1)')") return line_foldstart.' '.join(lines, ', ') endif return foldtext() diff --git a/sources_non_forked/vim-fugitive/doc/fugitive.txt b/sources_non_forked/vim-fugitive/doc/fugitive.txt index d5d4300c..7d5c1070 100644 --- a/sources_non_forked/vim-fugitive/doc/fugitive.txt +++ b/sources_non_forked/vim-fugitive/doc/fugitive.txt @@ -18,6 +18,12 @@ that are part of Git repositories). *fugitive-:G* :G [args] Same as :Git, but two characters shorter. + *fugitive-summary* +:Git With no arguments, bring up a summary window vaguely + akin to git-status. If a summary window is already + open for the current repository, it is focused + instead. Press g? or see |fugitive-maps| for usage. + *:Git* :Git {args} Run an arbitrary git command and display any output. On UNIX this uses a pty and on other platforms it uses @@ -47,12 +53,6 @@ that are part of Git repositories). :{range}Git! -p {args} Run an arbitrary git command, and insert the output after {range} in the current buffer. - *fugitive-summary* -:Git With no arguments, bring up a summary window vaguely - akin to git-status. If a summary window is already - open for the current repository, it is focused - instead. Press g? or see |fugitive-maps| for usage. - *:Git_blame* :Git blame [flags] Run git-blame [flags] on the current file and open the results in a scroll-bound vertical split. The @@ -341,8 +341,8 @@ ds Perform a |:Ghdiffsplit| on the file under the cursor. dh *fugitive_dq* -dq Close all but one diff buffer, and |:diffoff|! the - last one. +dq Close all but the currently focused diff buffer, and + invoke |:diffoff|!. *fugitive_d?* d? Show this help. @@ -380,6 +380,9 @@ p Open the file or |fugitive-object| under the cursor in *fugitive_P* P Open the current file in the [count]th parent. + Experimental: In the "Unpushed" section of the status + buffer, this will populate the command line with a + ":Git push" command for the commit under the cursor. *fugitive_C* C Open the commit containing the current file. diff --git a/sources_non_forked/vim-fugitive/plugin/fugitive.vim b/sources_non_forked/vim-fugitive/plugin/fugitive.vim index d88fb8cc..86e65767 100644 --- a/sources_non_forked/vim-fugitive/plugin/fugitive.vim +++ b/sources_non_forked/vim-fugitive/plugin/fugitive.vim @@ -168,7 +168,7 @@ endfunction " argument can be either the object returned by FugitiveConfig(), or a Git " dir or buffer number to be passed along to FugitiveConfig(). function! FugitiveConfigGet(name, ...) abort - return get(call('FugitiveConfigGetAll', [a:name] + (a:0 ? [a:1] : [])), 0, get(a:, 2, '')) + return get(call('FugitiveConfigGetAll', [a:name] + (a:0 ? [a:1] : [])), -1, get(a:, 2, '')) endfunction " FugitiveConfigGetAll() is like FugitiveConfigGet() but returns a list of diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim index 01bacdcd..3fdac4a6 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim @@ -118,11 +118,16 @@ endfunction " }}} -function! gitgutter#git() +" Optional argument is buffer number +function! gitgutter#git(...) + let git = g:gitgutter_git_executable + if a:0 + let git .= ' -C '.gitgutter#utility#dir(a:1) + endif if empty(g:gitgutter_git_args) - return g:gitgutter_git_executable + return git else - return g:gitgutter_git_executable.' '.g:gitgutter_git_args + return git.' '.g:gitgutter_git_args endif endfunction @@ -258,9 +263,7 @@ function! gitgutter#difforig() if g:gitgutter_diff_relative_to ==# 'index' let index_name = gitgutter#utility#get_diff_base(bufnr).':'.gitgutter#utility#base_path(bufnr) - let cmd = gitgutter#utility#cd_cmd(bufnr, - \ gitgutter#git().' --no-pager show '.index_name - \ ) + let cmd = gitgutter#git(bufnr).' --no-pager show '.index_name " NOTE: this uses &shell to execute cmd. Perhaps we should use instead " gitgutter#utility's use_known_shell() / restore_shell() functions. silent! execute "read ++edit !" cmd diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim index 8b9f1301..988e4a2d 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim @@ -46,7 +46,7 @@ function! s:build_command(cmd) endif if has('win32') - return has('nvim') ? ['cmd.exe', '/c', a:cmd] : 'cmd.exe /c '.a:cmd + return has('nvim') ? a:cmd : 'cmd.exe /c '.a:cmd endif throw 'unknown os' diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim index 6325ca33..484b89d2 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim @@ -116,14 +116,14 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort " Write file from index to temporary file. let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#base_path(a:bufnr) - let cmd .= gitgutter#git().' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && (' + let cmd .= gitgutter#git(a:bufnr).' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && (' elseif a:from ==# 'working_tree' let from_file = gitgutter#utility#repo_path(a:bufnr, 1) endif " Call git-diff. - let cmd .= gitgutter#git().' --no-pager' + let cmd .= gitgutter#git(a:bufnr).' --no-pager' if gitgutter#utility#git_supports_command_line_config_override() let cmd .= ' -c "diff.autorefreshindex=0"' let cmd .= ' -c "diff.noprefix=false"' @@ -144,8 +144,6 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort let cmd .= ')' - let cmd = gitgutter#utility#cd_cmd(a:bufnr, cmd) - if g:gitgutter_async && gitgutter#async#available() call gitgutter#async#execute(cmd, a:bufnr, { \ 'out': function('gitgutter#diff#handler'), diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim index 7546917f..7eda8ac5 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim @@ -60,7 +60,8 @@ function! gitgutter#hunk#next_hunk(count) abort if hunk[2] > current_line let hunk_count += 1 if hunk_count == a:count - execute 'normal!' hunk[2] . 'Gzv' + let keys = &foldopen =~# '\<block\>' ? 'zv' : '' + execute 'normal!' hunk[2] . 'G' . keys if g:gitgutter_show_msg_on_hunk_jumping redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks)) endif @@ -90,8 +91,9 @@ function! gitgutter#hunk#prev_hunk(count) abort if hunk[2] < current_line let hunk_count += 1 if hunk_count == a:count + let keys = &foldopen =~# '\<block\>' ? 'zv' : '' let target = hunk[2] == 0 ? 1 : hunk[2] - execute 'normal!' target . 'Gzv' + execute 'normal!' target . 'G' . keys if g:gitgutter_show_msg_on_hunk_jumping redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks)) endif @@ -306,9 +308,8 @@ function! s:stage(hunk_diff) write let path = gitgutter#utility#repo_path(bufnr, 1) " Add file to index. - let cmd = gitgutter#utility#cd_cmd(bufnr, - \ gitgutter#git().' add '. - \ gitgutter#utility#shellescape(gitgutter#utility#filename(bufnr))) + let cmd = gitgutter#git(bufnr).' add '. + \ gitgutter#utility#shellescape(gitgutter#utility#filename(bufnr)) let [_, error_code] = gitgutter#utility#system(cmd) else return @@ -318,7 +319,7 @@ function! s:stage(hunk_diff) let diff = s:adjust_header(bufnr, a:hunk_diff) " Apply patch to index. let [_, error_code] = gitgutter#utility#system( - \ gitgutter#utility#cd_cmd(bufnr, gitgutter#git().' apply --cached --unidiff-zero - '), + \ gitgutter#git(bufnr).' apply --cached --unidiff-zero - ', \ diff) endif diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim index 9c2b9c38..d6579389 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim @@ -66,7 +66,7 @@ function! gitgutter#utility#is_active(bufnr) abort endfunction function! s:not_git_dir(bufnr) abort - return s:dir(a:bufnr) !~ '[/\\]\.git\($\|[/\\]\)' + return gitgutter#utility#dir(a:bufnr) !~ '[/\\]\.git\($\|[/\\]\)' endfunction function! s:is_file_buffer(bufnr) abort @@ -162,9 +162,8 @@ function! gitgutter#utility#set_repo_path(bufnr, continuation) abort " * -3 - assume unchanged call gitgutter#utility#setbufvar(a:bufnr, 'path', -1) - let cmd = gitgutter#utility#cd_cmd(a:bufnr, - \ gitgutter#git().' ls-files -v --error-unmatch --full-name -z -- '. - \ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr))) + let cmd = gitgutter#git(a:bufnr).' ls-files -v --error-unmatch --full-name -z -- '. + \ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr)) if g:gitgutter_async && gitgutter#async#available() && !has('vim_starting') let handler = copy(s:set_path_handler) @@ -193,9 +192,8 @@ endfunction function! gitgutter#utility#clean_smudge_filter_applies(bufnr) let filtered = gitgutter#utility#getbufvar(a:bufnr, 'filter', -1) if filtered == -1 - let cmd = gitgutter#utility#cd_cmd(a:bufnr, - \ gitgutter#git().' check-attr filter -- '. - \ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr))) + let cmd = gitgutter#git(a:bufnr).' check-attr filter -- '. + \ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr)) let [out, _] = gitgutter#utility#system(cmd) let filtered = out !~ 'unspecified' call gitgutter#utility#setbufvar(a:bufnr, 'filter', filtered) @@ -204,19 +202,6 @@ function! gitgutter#utility#clean_smudge_filter_applies(bufnr) endfunction -function! gitgutter#utility#cd_cmd(bufnr, cmd) abort - let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() && s:dos_shell() ? 'cd /d' : 'cd') - return cd.' '.s:dir(a:bufnr).' && '.a:cmd -endfunction - -function! s:unc_path(bufnr) - return s:abs_path(a:bufnr, 0) =~ '^\\\\' -endfunction - -function! s:dos_shell() - return &shell == 'cmd.exe' || &shell == 'command.com' -endfunction - function! s:use_known_shell() abort if has('unix') && &shell !=# 'sh' let [s:shell, s:shellcmdflag, s:shellredir, s:shellpipe, s:shellquote, s:shellxquote] = [&shell, &shellcmdflag, &shellredir, &shellpipe, &shellquote, &shellxquote] @@ -303,12 +288,12 @@ endfunction " Returns a dict of current path to original path at the given base. function! s:obtain_file_renames(bufnr, base) let renames = {} - let cmd = gitgutter#git() + let cmd = gitgutter#git(a:bufnr) if gitgutter#utility#git_supports_command_line_config_override() let cmd .= ' -c "core.safecrlf=false"' endif let cmd .= ' diff --diff-filter=R --name-status '.a:base - let [out, error_code] = gitgutter#utility#system(gitgutter#utility#cd_cmd(a:bufnr, cmd)) + let [out, error_code] = gitgutter#utility#system(cmd) if error_code " Assume the problem is the diff base. call gitgutter#utility#warn('g:gitgutter_diff_base ('.a:base.') is invalid') @@ -335,7 +320,8 @@ function! s:abs_path(bufnr, shellesc) return a:shellesc ? gitgutter#utility#shellescape(p) : p endfunction -function! s:dir(bufnr) abort +" Shellescaped +function! gitgutter#utility#dir(bufnr) abort return gitgutter#utility#shellescape(fnamemodify(s:abs_path(a:bufnr, 0), ':h')) endfunction diff --git a/sources_non_forked/vim-markdown/README.md b/sources_non_forked/vim-markdown/README.md index 250d3e5a..3ccf5325 100644 --- a/sources_non_forked/vim-markdown/README.md +++ b/sources_non_forked/vim-markdown/README.md @@ -68,8 +68,10 @@ The following commands are useful to open and close folds: - `zR`: opens all folds - `zm`: increases fold level throughout the buffer - `zM`: folds everything all the way -- `za`: open a fold your cursor is on -- `zA`: open a fold your cursor is on recursively +- `za`: toggle a fold your cursor is on +- `zA`: toggle a fold your cursor is on recursively +- `zo`: open a fold your cursor is on +- `zO`: open a fold your cursor is on recursively - `zc`: close a fold your cursor is on - `zC`: close a fold your cursor is on recursively diff --git a/sources_non_forked/vim-markdown/doc/vim-markdown.txt b/sources_non_forked/vim-markdown/doc/vim-markdown.txt index 4aa8270c..3e843571 100644 --- a/sources_non_forked/vim-markdown/doc/vim-markdown.txt +++ b/sources_non_forked/vim-markdown/doc/vim-markdown.txt @@ -102,9 +102,13 @@ The following commands are useful to open and close folds: *vim-markdown-zM* - 'zM': folds everything all the way *vim-markdown-za* -- 'za': open a fold your cursor is on +- 'za': toggle a fold your cursor is on *vim-markdown-zA* -- 'zA': open a fold your cursor is on recursively +- 'zA': toggle a fold your cursor is on recursively + *vim-markdown-zo* +- 'zo': open a fold your cursor is on + *vim-markdown-zO* +- 'zO': open a fold your cursor is on recursively *vim-markdown-zc* - 'zc': close a fold your cursor is on *vim-markdown-zC* diff --git a/sources_non_forked/vim-repeat/.github/FUNDING.yml b/sources_non_forked/vim-repeat/.github/FUNDING.yml deleted file mode 100644 index e2a49d11..00000000 --- a/sources_non_forked/vim-repeat/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -github: tpope -custom: ["https://www.paypal.me/vimpope"] diff --git a/sources_non_forked/vim-repeat/autoload/repeat.vim b/sources_non_forked/vim-repeat/autoload/repeat.vim index 97fea240..364d311c 100644 --- a/sources_non_forked/vim-repeat/autoload/repeat.vim +++ b/sources_non_forked/vim-repeat/autoload/repeat.vim @@ -44,7 +44,7 @@ " \ call <SID>MyFunction(v:register, ...)<Bar> " \ silent! call repeat#set("\<lt>Plug>MyMap")<CR> -if exists("g:loaded_repeat") || &cp || v:version < 700 +if exists("g:loaded_repeat") || &cp || v:version < 800 finish endif let g:loaded_repeat = 1 @@ -108,21 +108,10 @@ function! repeat#run(count) let c = g:repeat_count let s = g:repeat_sequence let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : '')) - if ((v:version == 703 && has('patch100')) || (v:version == 704 && !has('patch601'))) - exe 'norm ' . r . cnt . s - elseif v:version <= 703 - call feedkeys(r . cnt, 'n') - call feedkeys(s, '') - else - call feedkeys(s, 'i') - call feedkeys(r . cnt, 'ni') - endif + call feedkeys(s, 'i') + call feedkeys(r . cnt, 'ni') else - if ((v:version == 703 && has('patch100')) || (v:version == 704 && !has('patch601'))) - exe 'norm! '.(a:count ? a:count : '') . '.' - else - call feedkeys((a:count ? a:count : '') . '.', 'ni') - endif + call feedkeys((a:count ? a:count : '') . '.', 'ni') endif catch /^Vim(normal):/ let s:errmsg = v:errmsg @@ -135,18 +124,15 @@ function! repeat#errmsg() endfunction function! repeat#wrap(command,count) - let preserve = (g:repeat_tick == b:changedtick) - call feedkeys((a:count ? a:count : '').a:command, 'n') - exe (&foldopen =~# 'undo\|all' ? 'norm! zv' : '') - if preserve - let g:repeat_tick = b:changedtick - endif + let foldopen = &foldopen =~# 'undo\|all' ? 'zv' : '' + let preserve = g:repeat_tick == b:changedtick ? ":let g:repeat_tick = b:changedtick\r" : '' + return (a:count ? a:count : '') . a:command . preserve . foldopen endfunction nnoremap <silent> <Plug>(RepeatDot) :<C-U>if !repeat#run(v:count)<Bar>echoerr repeat#errmsg()<Bar>endif<CR> -nnoremap <silent> <Plug>(RepeatUndo) :<C-U>call repeat#wrap('u',v:count)<CR> -nnoremap <silent> <Plug>(RepeatUndoLine) :<C-U>call repeat#wrap('U',v:count)<CR> -nnoremap <silent> <Plug>(RepeatRedo) :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR> +nmap <silent><expr><script> <Plug>(RepeatUndo) repeat#wrap('u',v:count) +nmap <silent><expr><script> <Plug>(RepeatUndoLine) repeat#wrap('U',v:count) +nmap <silent><expr><script> <Plug>(RepeatRedo) repeat#wrap("\022",v:count) if !hasmapto('<Plug>(RepeatDot)', 'n') nmap . <Plug>(RepeatDot) diff --git a/sources_non_forked/vim-snipmate/Contributors.md b/sources_non_forked/vim-snipmate/Contributors.md index 82fbbd6b..1d091e85 100644 --- a/sources_non_forked/vim-snipmate/Contributors.md +++ b/sources_non_forked/vim-snipmate/Contributors.md @@ -42,6 +42,7 @@ additional contributions from: * [redpill](https://github.com/redpill) * [rglassett](http://github.com/rglassett) * [robhudson](https://github.com/robhudson) +* [roccomao](https://github.com/roccomao) * [shinymayhem](https://github.com/shinymayhem) * [Shraymonks](https://github.com/shraymonks) * [sickill](https://github.com/sickill) diff --git a/sources_non_forked/vim-snipmate/autoload/snipMate.vim b/sources_non_forked/vim-snipmate/autoload/snipMate.vim index bd0276fa..d50256e4 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipMate.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipMate.vim @@ -106,7 +106,7 @@ function! s:insert_snippet_text(snippet, lnum, col, indent) endfunction function! snipMate#placeholder_str(num, stops) abort - return snipMate#sniplist_str(a:stops[a:num].placeholder, a:stops) + return snipMate#sniplist_str(get(get(a:stops, a:num, {}), 'placeholder', []), a:stops) endfunction function! snipMate#sniplist_str(snippet, stops) abort @@ -176,7 +176,7 @@ function! s:build_loc_info(snippet, stops, lnum, col, seen_items) abort call s:add_update_objects(stub, seen_items) " if we've found a stop? - if len(item) > 2 && type(item[1]) != type({}) + if len(item) > 2 && type(item[1]) != type({}) && !exists('stub.items') let col = s:build_loc_info(item[1:-2], stops, lnum, col, seen_items) else let col += len(snipMate#placeholder_str(id, stops)) diff --git a/sources_non_forked/vim-snipmate/autoload/snipmate/jumping.vim b/sources_non_forked/vim-snipmate/autoload/snipmate/jumping.vim index 2b8085a3..04a3d20c 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipmate/jumping.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipmate/jumping.vim @@ -35,6 +35,7 @@ endfunction " Update state information to correspond to the given tab stop function! s:state_set_stop(backwards) dict abort call self.find_next_stop(a:backwards) + let self.cur_stop = self.stops[self.stop_no] let self.stop_len = (type(self.cur_stop.placeholder) == type(0)) \ ? self.cur_stop.placeholder @@ -43,13 +44,26 @@ function! s:state_set_stop(backwards) dict abort let self.end_col = self.start_col + self.stop_len let self.mirrors = get(self.cur_stop, 'mirrors', []) let self.old_mirrors = deepcopy(self.mirrors) + call cursor(self.cur_stop.line, self.cur_stop.col) + let self.prev_len = col('$') let self.changed = 0 - let ret = self.select_word() + + for mirror in self.mirrors + let mirror.oldSize = self.stop_len + endfor + + if exists("self.cur_stop.items") + let ret = self.select_item() + else + let ret = self.select_word() + endif + if (self.stop_no == 0 || self.stop_no == self.stop_count - 1) && !a:backwards call self.remove() endif + return ret endfunction @@ -62,11 +76,18 @@ function! s:state_jump_stop(backwards) dict abort " Store placeholder/location changes let self.cur_stop.col = self.start_col + unlet! self.cur_stop.placeholder " avoid type error for old parsing version + let self.cur_stop.placeholder = [strpart(getline('.'), + \ self.start_col - 1, self.end_col - self.start_col)] if self.changed call self.remove_nested() - unlet! self.cur_stop.placeholder " avoid type error for old parsing version - let self.cur_stop.placeholder = [strpart(getline('.'), - \ self.start_col - 1, self.end_col - self.start_col)] + + " Remove selection items if the stop has changed and the new placeholder + " is not one of the selection items + if exists('self.cur_stop.items') && + \ !count(self.cur_stop.items, self.cur_stop.placeholder) + call remove(self.cur_stop, 'items') + endif endif return self.set_stop(a:backwards) @@ -151,30 +172,14 @@ function! s:state_update_mirrors(change) dict abort let oldSize = strlen(newWord) endif - " Split the line into three parts: the mirror, what's before it, and - " what's after it. Then combine them using the new mirror string. - " Subtract one to go from column index to byte index - - let theline = getline(mirror.line) - - " part before the current mirror - let beginline = strpart(theline, 0, mirror.col - 1) - " current mirror transformation, and save size let wordMirror= substitute(newWord, get(mirror, 'pat', ''), get(mirror, 'sub', ''), get(mirror, 'flags', '')) let mirror.oldSize = strlen(wordMirror) - " end of the line, use the oldSize because with the transformation, - " the size of the mirror can be different from those of the snippet - let endline = strpart(theline, mirror.col + oldSize -1) - - " Update other object on the line + " Update other objects on the line call self.update(mirror, changeLen, mirror.oldSize - oldSize) - " reconstruct the line - let update = beginline.wordMirror.endline - - call setline(mirror.line, update) + call s:set_line(mirror.line, mirror.col, oldSize, wordMirror) endfor " Reposition the cursor in case a var updates on the same line but before @@ -194,7 +199,9 @@ function! s:state_find_update_objects(item) dict abort call add(item.update_objects, stop) endif + let placeholder_len = len(snipMate#sniplist_str(stop.placeholder, b:snip_state.stops)) for mirror in get(stop, 'mirrors', []) + let mirror.oldSize = placeholder_len if mirror.line == item.line && mirror.col > item.col call add(item.update_objects, mirror) endif @@ -222,9 +229,37 @@ function! s:state_update(item, change_len, mirror_change) dict abort endfor endfunction +" Split the line into three parts: the mirror, what's before it, and +" what's after it. Then combine them using the new mirror string. +" Subtract one to go from column index to byte index +function! s:set_line(line, col, len, word) + let theline = getline(a:line) + let begin = strpart(theline, 0, a:col - 1) + let end = strpart(theline, a:col + a:len - 1) + call setline(a:line, begin . a:word . end) +endfunction + +" If &cotl contains at least one of these three, we need to add one to our menu +" selection hack in s:state_select_item +function! s:cot_count() + let cotl = split(&cot, ',') + let c = (has('patch-9.0.0567') && count(cotl, 'longest')) + count(cotl, 'noinsert') + count(cotl, 'noselect') + return min([1, c]) +endfunction + +function! s:state_select_item() dict abort + let items = map(copy(self.cur_stop.items), 'snipMate#sniplist_str(v:val, b:snip_state.stops)') + call s:set_line(line('.'), self.start_col, self.end_col - self.start_col, '') + call complete(self.start_col, items) + for i in range(index(self.cur_stop.items, self.cur_stop.placeholder) + s:cot_count()) + call feedkeys("\<C-N>") + endfor + return '' +endfunction + call extend(s:state_proto, snipmate#util#add_methods(s:sfile(), 'state', \ [ 'remove', 'set_stop', 'jump_stop', 'remove_nested', - \ 'select_word', 'update_changes', 'update_mirrors', + \ 'select_word', 'update_changes', 'update_mirrors', 'select_item', \ 'find_next_stop', 'find_update_objects', 'update' ]), 'error') " vim:noet:sw=4:ts=4:ft=vim diff --git a/sources_non_forked/vim-snipmate/autoload/snipmate/parse.vim b/sources_non_forked/vim-snipmate/autoload/snipmate/parse.vim index 4cf60e90..017c4547 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipmate/parse.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipmate/parse.vim @@ -78,11 +78,32 @@ function! s:parser_varend() dict abort call extend(ret, self.placeholder()) elseif self.same('/') call add(ret, self.subst()) + elseif self.next == '|' + call add(ret, self.select()) endif call self.same('}') return ret endfunction +function! s:parser_select() dict abort + let items = [] + while self.same('|') + let str = self.text('|}') + call s:mark_vars_in_select(str) + call add(items, str) + endwhile + return ['select'] + items +endfunction + +function! s:mark_vars_in_select(str) + for item in a:str + if type(item) == type([]) + call add(item, { 'select' : 1 }) + endif + unlet! item " avoid E706 + endfor +endfunction + function! s:parser_placeholder() dict abort let ret = self.text('}') return empty(ret) ? [''] : ret @@ -171,6 +192,7 @@ endfunction function! s:parser_text(till) dict abort let ret = [] + let till = '\V\[' . escape(a:till, '\') . ']' let target = ret while self.pos < self.len @@ -206,7 +228,7 @@ function! s:parser_text(till) dict abort endif " Empty lines are ignored if this is tested at the start of an iteration - if self.next ==# a:till + if self.next =~# till break endif endwhile @@ -268,11 +290,26 @@ endfunction function! s:parser_create_stubs() dict abort for [id, dict] in items(self.vars) + + " only instance is in a selection, so remove it + if len(dict.instances) == 1 && type(dict.instances[0][-1]) == type({}) + \ && dict.instances[0][-1] == { 'select' : 1 } + call remove(self.vars, id) + continue + endif + for i in dict.instances if len(i) > 1 && type(i[1]) != type({}) if !has_key(dict, 'placeholder') - let dict.placeholder = i[1:] - call add(i, dict) + if type(i[1]) == type([]) && i[1][0] == 'select' + let dict.placeholder = i[1][1] + let dict.items = i[1][1:] + let i[1] = dict.placeholder + call add(i, dict) + else + let dict.placeholder = i[1:] + call add(i, dict) + endif else unlet i[1:] call s:create_mirror_stub(i, dict) @@ -281,6 +318,7 @@ function! s:parser_create_stubs() dict abort call s:create_mirror_stub(i, dict) endif endfor + if !has_key(dict, 'placeholder') let dict.placeholder = [] let j = 0 @@ -292,6 +330,7 @@ function! s:parser_create_stubs() dict abort call add(dict.instances[j], dict) call filter(dict.mirrors, 'v:val isnot oldstub') endif + unlet dict.instances endfor @@ -301,9 +340,13 @@ function! s:create_mirror_stub(mirror, dict) let mirror = a:mirror let dict = a:dict let stub = get(mirror, 1, {}) - call add(mirror, stub) - let dict.mirrors = get(dict, 'mirrors', []) - call add(dict.mirrors, stub) + if stub == { 'select' : 1 } + unlet mirror[1:] + else + call add(mirror, stub) + let dict.mirrors = get(dict, 'mirrors', []) + call add(dict.mirrors, stub) + endif endfunction function! snipmate#parse#snippet(text, ...) abort @@ -318,6 +361,6 @@ endfunction call extend(s:parser_proto, snipmate#util#add_methods(s:sfile(), 'parser', \ [ 'advance', 'same', 'id', 'add_var', 'var', 'varend', - \ 'line', 'string', 'create_stubs', 'pat', + \ 'line', 'string', 'create_stubs', 'pat', 'select', \ 'placeholder', 'subst', 'expr', 'text', 'parse', \ ]), 'error') diff --git a/sources_non_forked/vim-snipmate/doc/snipMate.txt b/sources_non_forked/vim-snipmate/doc/SnipMate.txt similarity index 98% rename from sources_non_forked/vim-snipmate/doc/snipMate.txt rename to sources_non_forked/vim-snipmate/doc/SnipMate.txt index 584b20bf..2082ed85 100644 --- a/sources_non_forked/vim-snipmate/doc/snipMate.txt +++ b/sources_non_forked/vim-snipmate/doc/SnipMate.txt @@ -482,6 +482,20 @@ empty string if it hasn't. The second returns the filename if it's been named, and "name" if it hasn't. The third returns the filename followed by "_foo" if it has been named, and an empty string if it hasn't. + *SnipMate-selections* +Selections~ + +Note: Version 1 of the parser is required for selections. + +In addition to providing sample text as a placeholder, you can specify a list +of options that the user can choose from via |popupmenu-completion|: +> + snippet todo + # ${1|TODO|FIXME|BUG}: $2 +< Notice that the : is replaced by the pipe |. Currently mirrors and +placeholders are not supported within selection text. If alterations are made +to the selected text, the stop becomes a regular stop, losing the selections. + *SnipMate-visual* The VISUAL Stop~ diff --git a/sources_non_forked/vim-snipmate/t/jumping.vim b/sources_non_forked/vim-snipmate/t/jumping.vim index 1c3ab0d3..7d2a92c0 100644 --- a/sources_non_forked/vim-snipmate/t/jumping.vim +++ b/sources_non_forked/vim-snipmate/t/jumping.vim @@ -74,8 +74,15 @@ describe 'snippet state' Expect b:snip_state.stop_no == 3 end - it 'does something at the ends' - " + it 'wraps around when going before the first or after the last stop' + let b:snip_state.stops = { 0 : {}, 1 : {}, 2 : {}, 3 : {} } + let b:snip_state.stop_count = 4 + let b:snip_state.stop_no = 3 + call b:snip_state.find_next_stop(0) + Expect b:snip_state.stop_no == 1 + let b:snip_state.stop_no = 1 + call b:snip_state.find_next_stop(1) + Expect b:snip_state.stop_no == 3 end end diff --git a/sources_non_forked/vim-snipmate/t/parser.vim b/sources_non_forked/vim-snipmate/t/parser.vim index 3c2aa6e5..65a28a62 100644 --- a/sources_non_forked/vim-snipmate/t/parser.vim +++ b/sources_non_forked/vim-snipmate/t/parser.vim @@ -1,6 +1,9 @@ describe 'snippet parser' before + " two optional arguments: + " first one: whether or not to create the stop stubs + " second one: whether or not to return the stops function! Parse(snippet, ...) let [snip, stops] = snipmate#parse#snippet(a:snippet, (a:0 ? a:1 : 1)) return (a:0 > 1 && a:2) ? [snip, stops] : snip @@ -149,4 +152,19 @@ describe 'snippet parser' Expect Parse("foo\n\nbar") == [['foo'], [''], ['bar']] end + it 'parses a selection as a special var named "select" with each item' + Expect Parse("${1|foo|bar|baz|select}") == + \ [[[1, ['select', 'foo', 'bar', 'baz', 'select']]]] + end + + it 'stores selection items in the var dictionary' + let [snip, stops] = Parse("${1|foo|bar|baz|select}", 0, 1) + Expect stops[1].items == ['foo', 'bar', 'baz', 'select'] + end + + it 'sets a selections placeholder to the first item' + let [snip, stops] = Parse("${1|foo|bar|baz|select}", 0, 1) + Expect stops[1].placeholder == 'foo' + end + end diff --git a/sources_non_forked/vim-snippets/UltiSnips/gitcommit.snippets b/sources_non_forked/vim-snippets/UltiSnips/gitcommit.snippets index e2f1ba5d..353aff74 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/gitcommit.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/gitcommit.snippets @@ -71,6 +71,10 @@ build(${1:scope}): ${2:title} ${0:${VISUAL}} endsnippet +snippet Co-authored-by "Co-authored-by:" +Co-authored-by: ${1:Author Name} <${2:Email}> +endsnippet + snippet sign "Signature" ------------------------------------------------------------------------------- ${1:Company Name} diff --git a/sources_non_forked/vim-snippets/snippets/gleam.snippets b/sources_non_forked/vim-snippets/snippets/gleam.snippets index a01e5407..de405697 100644 --- a/sources_non_forked/vim-snippets/snippets/gleam.snippets +++ b/sources_non_forked/vim-snippets/snippets/gleam.snippets @@ -1,98 +1,78 @@ snippet fn "fn" - fn ${1:function_name}(${2}) -> ${3:Nil} { - ${0:${VISUAL:todo}} - } + fn ${1:function_name}(${2}) -> ${3:Nil} { + ${0:${VISUAL:todo}} + } snippet pfn "pub fn" - pub fn ${1:function_name}(${2}) -> ${3:Nil} { - ${0:${VISUAL:todo}} - } + pub fn ${1:function_name}(${2}) -> ${3:Nil} { + ${0:${VISUAL:todo}} + } snippet test "test fn" - pub fn ${1:name}_test() { - ${0} - } + pub fn ${1:name}_test() { + ${0} + } snippet af "anonymous fn" - fn(${1}) { ${0:${VISUAL}} } + fn(${1}) { ${0:${VISUAL}} } snippet let "let binding" - let ${1} = ${0} + let ${1} = ${0} snippet l "let binding" - let ${1} = ${0} + let ${1} = ${0} snippet as "assert binding" - assert ${1} = ${0} - -snippet tr "try binding" - try ${1} = ${0} + let assert ${1} = ${0} snippet - "->" - -> ${0} + -> ${0} snippet case "case expression" - case ${1} { - ${2} -> ${0} - } + case ${1} { + ${2} -> ${0} + } snippet ty "type" - type ${1:Name} { - ${0:$1} - } + type ${1:Name} { + ${0:$1} + } snippet pty "pub type" - pub type ${1:Name} { - ${0:$1} - } + pub type ${1:Name} { + ${0:$1} + } snippet tya "type alias" - type ${1:Name} = - ${0:$1} + type ${1:Name} = + ${0:$1} snippet ptya "pub type alias" - pub type ${1:Name} = - ${0:$1} - -snippet ext "external type" - external type ${0} - -snippet pext "pub external type" - pub external type ${0} - -snippet exfn "external fn" - external fn ${1:function_name}(${2}) -> ${3} - = "${4}" "${0}" - -snippet pexfn "pub external fn" - pub external fn ${1:function_name}(${2}) -> ${3} - = "${4}" "${0}" + pub type ${1:Name} = + ${0:$1} snippet im "import" - import ${0:gleam/result} + import ${0:gleam/result} snippet im. "import exposing" - import ${1:gleam/result}.{${0}} + import ${1:gleam/result}.{${0}} snippet p "|>" - |> ${0} - -snippet tup "tuple()" - tuple(${0:${VISUAL}}) + |> ${0} snippet bl "block" - { - ${0:${VISUAL}} - } + { + ${0:${VISUAL}} + } snippet tf "fn(Type) -> Type" - fn(${1}) -> ${0} + fn(${1}) -> ${0} snippet seq "should.equal" - should.equal(${0:${VISUAL}}) + should.equal(${0:${VISUAL}}) snippet strue "should.be_true" - should.be_true(${0:${VISUAL}}) + should.be_true(${0:${VISUAL}}) snippet sfalse "should.be_false" - should.be_true(${0:${VISUAL}}) + should.be_false(${0:${VISUAL}}) diff --git a/sources_non_forked/vim-snippets/snippets/go.snippets b/sources_non_forked/vim-snippets/snippets/go.snippets index 7245252c..1c785f86 100644 --- a/sources_non_forked/vim-snippets/snippets/go.snippets +++ b/sources_non_forked/vim-snippets/snippets/go.snippets @@ -59,7 +59,7 @@ snippet in "interface" interface{} snippet inf "full interface " - interface ${1:name} { + type ${1:name} interface { ${2:/* methods */} } @@ -188,7 +188,7 @@ snippet sr "string" string snippet st "struct" - struct ${1:name} { + type ${1:name} struct { ${2:/* data */} } ${0} diff --git a/sources_non_forked/vim-snippets/snippets/markdown.snippets b/sources_non_forked/vim-snippets/snippets/markdown.snippets index 39ccecd7..a8b00cfb 100644 --- a/sources_non_forked/vim-snippets/snippets/markdown.snippets +++ b/sources_non_forked/vim-snippets/snippets/markdown.snippets @@ -5,7 +5,7 @@ # The suffix `c` stands for "Clipboard". snippet [ - [${1:text}](https://${2:address}) + [${1:text}](${2:address}) snippet [* [${1:link}](${2:`@*`}) snippet [c diff --git a/sources_non_forked/vim-snippets/snippets/ruby.snippets b/sources_non_forked/vim-snippets/snippets/ruby.snippets index da82185a..8aadb71d 100644 --- a/sources_non_forked/vim-snippets/snippets/ruby.snippets +++ b/sources_non_forked/vim-snippets/snippets/ruby.snippets @@ -612,6 +612,8 @@ snippet debug18 require 'ruby-debug'; debugger snippet pry require 'pry'; binding.pry +snippet irb + binding.irb snippet strf strftime('${1:%Y-%m-%d %H:%M:%S %z}')${0} # diff --git a/sources_non_forked/vim-snippets/snippets/systemverilog.snippets b/sources_non_forked/vim-snippets/snippets/systemverilog.snippets index f510750d..828a6de9 100644 --- a/sources_non_forked/vim-snippets/snippets/systemverilog.snippets +++ b/sources_non_forked/vim-snippets/snippets/systemverilog.snippets @@ -71,3 +71,594 @@ snippet pkg package ${1:package_name}; ${0} endpackage : $1 + +snippet uvm_object + // Class: $1 + // + class ${1:my_class} extends ${2:uvm_object}; + \`uvm_object_utils($1); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + $0 + endclass: $1 + + +snippet uvm_object_with_parameters + // Class: $1 + // + class ${1:my_class} #(${2:parameters}) extends ${3:uvm_object}; + typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t; + \`uvm_object_param_utils(this_type_t); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + $0 + endclass: $1 + + +snippet uvm_component + // Class: $1 + // + class ${1:my_class} extends ${2:uvm_component}; + \`uvm_component_utils($1); + + // Group: Configuration Object(s) + + // Var: config_obj + ${3:config_obj_t} config_obj; + + + // Group: Components + + + // Group: Variables + + + // Group: Functions + + // Constructor: new + function new(string name = "$1", uvm_component parent); + super.new(name, parent); + endfunction: new + + $0 + endclass: $1 + + +snippet uvm_component_with_parameters + // Class: $1 + // + class ${1:my_class} #(${2:parameters}) extends ${3:uvm_component}; + typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t; + \`uvm_component_param_utils(this_type_t); + + // Group: Configuration Object(s) + + // Var: config_obj + ${4:config_obj_t} config_obj; + + + // Group: Components + + + // Group: Variables + + + // Constructor: new + function new(string name = "$1", uvm_component parent); + super.new(name, parent); + endfunction: new + + $0 + endclass: $1 + + +snippet uvm_component_extended + // Class: $1 + // + class ${1:my_class} extends ${2:base_class}; + \`uvm_component_utils($1); + + // Group: Configuration Object(s) + + + // Group: Components + + + // Group: Variables + + + // Group: Functions + + // Constructor: new + function new(string name = "$1", uvm_component parent); + super.new(name, parent); + endfunction: new + + /*--- UVM Build Phases ---*/ + /*------------------------------------*/ + // Function: build_phase + extern function void build_phase(uvm_phase phase); + // Function: connect_phase + extern function void connect_phase(uvm_phase phase); + // Function: end_of_elaboration_phase + extern function void end_of_elaboration_phase(uvm_phase phase); + + /*--- UVM Run Phases ---*/ + /*------------------------------------*/ + // Function: start_of_simulation_phase + extern function void start_of_simulation_phase(uvm_phase phase); + // Function: reset_phase + extern task reset_phase(uvm_phase phase); + // Function: configure_phase + extern task configure_phase(uvm_phase phase); + // Function: main_phase + extern task main_phase(uvm_phase phase); + // Function: shutdown_phase + extern task shutdown_phase(uvm_phase phase); + + /*--- UVM Cleanup Phases ---*/ + /*------------------------------------*/ + // Function: extract_phase + extern function void extract_phase(uvm_phase phase); + // Function: report_phase + extern function void report_phase(uvm_phase phase); + $0 + endclass: $1 + + + /*----------------------------------------------------------------------------*/ + /* UVM Build Phases */ + /*----------------------------------------------------------------------------*/ + function void $1::build_phase(uvm_phase phase); + /* note: Do not call super.build_phase() from any class that is extended from an UVM base class! */ + /* For more information see UVM Cookbook v1800.2 p.503 */ + // super.build_phase(phase); + endfunction: build_phase + + + function void $1::connect_phase(uvm_phase phase); + super.connect_phase(phase); + endfunction: connect_phase + + + function void $1::end_of_elaboration_phase(uvm_phase phase); + super.end_of_elaboration_phase(phase); + endfunction: end_of_elaboration_phase + + + /*----------------------------------------------------------------------------*/ + /* UVM Run Phases */ + /*----------------------------------------------------------------------------*/ + function void $1::start_of_simulation_phase(uvm_phase phase); + super.start_of_simulation_phase(phase); + endfunction: start_of_simulation_phase + + + task $1::reset_phase(uvm_phase phase); + endtask: reset_phase + + + task $1::configure_phase(uvm_phase phase); + endtask: configure_phase + + + task $1::main_phase(uvm_phase phase); + endtask: main_phase + + + task $1::shutdown_phase(uvm_phase phase); + endtask: shutdown_phase + + + /*----------------------------------------------------------------------------*/ + /* UVM Cleanup Phases */ + /*----------------------------------------------------------------------------*/ + function void $1::report_phase(uvm_phase phase); + super.report_phase(phase); + endfunction: report_phase + + + function void $1::extract_phase(uvm_phase phase); + super.extract_phase(phase); + endfunction: extract_phase + + + +snippet uvm_sequence + // Class: $1 + // + class ${1:my_class} extends ${2:uvm_sequence}; + \`uvm_object_utils($1); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + + // Task: pre_start + // This task is a user-definable callback that is called before the optional + // execution of <pre_body>. + // extern virtual task pre_start(); + + // Task: pre_body + // This task is a user-definable callback that is called before the execution + // of <body> ~only~ when the sequence is started with <start>. + // If <start> is called with ~call_pre_post~ set to 0, ~pre_body~ is not called. + // extern virtual task pre_body(); + + // Task: pre_do + // This task is a user-definable callback task that is called ~on the parent + // sequence~, if any. The sequence has issued a wait_for_grant() call and after + // the sequencer has selected this sequence, and before the item is randomized. + // + // Although pre_do is a task, consuming simulation cycles may result in unexpected + // behavior on the driver. + // extern virtual task pre_do(bit is_item); + + // Function: mid_do + // This function is a user-definable callback function that is called after the + // sequence item has been randomized, and just before the item is sent to the + // driver. + // extern virtual function void mid_do(uvm_sequence_item this_item); + + // Task: body + // This is the user-defined task where the main sequence code resides. + extern virtual task body(); + + // Function: post_do + // This function is a user-definable callback function that is called after the + // driver has indicated that it has completed the item, using either this + // item_done or put methods. + // extern virtual function void post_do(uvm_sequence_item this_item); + + // Task: post_body + // This task is a user-definable callback task that is called after the execution + // of <body> ~only~ when the sequence is started with <start>. + // If <start> is called with ~call_pre_post~ set to 0, ~post_body~ is not called. + // extern virtual task post_body(); + + // Task: post_start + // This task is a user-definable callback that is called after the optional + // execution of <post_body>. + // extern virtual task post_start(); + $0 + endclass: $1 + +snippet uvm_sequence_with_parameters + // Class: $1 + // + class ${1:my_class} #(${2:parameters}) extends ${3:uvm_sequence}; + typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t; + \`uvm_object_param_utils(this_type_t); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + + // Task: pre_start + // This task is a user-definable callback that is called before the optional + // execution of <pre_body>. + // extern virtual task pre_start(); + + // Task: pre_body + // This task is a user-definable callback that is called before the execution + // of <body> ~only~ when the sequence is started with <start>. + // If <start> is called with ~call_pre_post~ set to 0, ~pre_body~ is not called. + // extern virtual task pre_body(); + + // Task: pre_do + // This task is a user-definable callback task that is called ~on the parent + // sequence~, if any. The sequence has issued a wait_for_grant() call and after + // the sequencer has selected this sequence, and before the item is randomized. + // + // Although pre_do is a task, consuming simulation cycles may result in unexpected + // behavior on the driver. + // extern virtual task pre_do(bit is_item); + + // Function: mid_do + // This function is a user-definable callback function that is called after the + // sequence item has been randomized, and just before the item is sent to the + // driver. + // extern virtual function void mid_do(uvm_sequence_item this_item); + + // Task: body + // This is the user-defined task where the main sequence code resides. + extern virtual task body(); + + // Function: post_do + // This function is a user-definable callback function that is called after the + // driver has indicated that it has completed the item, using either this + // item_done or put methods. + // extern virtual function void post_do(uvm_sequence_item this_item); + + // Task: post_body + // This task is a user-definable callback task that is called after the execution + // of <body> ~only~ when the sequence is started with <start>. + // If <start> is called with ~call_pre_post~ set to 0, ~post_body~ is not called. + // extern virtual task post_body(); + + // Task: post_start + // This task is a user-definable callback that is called after the optional + // execution of <post_body>. + // extern virtual task post_start(); + $0 + endclass: $1 + +snippet uvm_sequence_functions + // task ${1:my_class::}pre_start(); + // endtask: pre_start + + + // task $1pre_body(); + // endtask: pre_body + + + // task $1pre_do(bit is_item); + // endtask: pre_do + + + // function void $1mid_do(uvm_sequence_item this_item); + // endfunction: mid_do + + + task $1body(); + $0 + endtask: body + + + // function void $1post_do(uvm_sequence_item this_item); + // endfunction: post_do + + + // task $1post_body(); + // endtask: post_body + + + // task $1post_start(); + // endtask: post_start + + +snippet uvm_sequence_item + // Class: $1 + // + class ${1:my_class} extends ${2:uvm_sequence_item}; + typedef $1 this_type_t; + \`uvm_object_utils($1); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + + // Function: do_copy + // extern function void do_copy(uvm_object rhs); + // Function: do_compare + // extern function bit do_compare(uvm_object rhs, uvm_comparer comparer); + // Function: convert2string + // extern function string convert2string(); + // Function: do_print + // extern function void do_print(uvm_printer printer); + // Function: do_record + // extern function void do_record(uvm_recorder recorder); + // Function: do_pack + // extern function void do_pack(); + // Function: do_unpack + // extern function void do_unpack(); + $0 + endclass: $1 + + + /*----------------------------------------------------------------------------*/ + /* Constraints */ + /*----------------------------------------------------------------------------*/ + + + + + /*----------------------------------------------------------------------------*/ + /* Functions */ + /*----------------------------------------------------------------------------*/ + + + +snippet uvm_sequence_item_with_parameters + // Class: $1 + // + class ${1:my_class} #(${2:parameters}) extends ${3:uvm_sequence_item}; + typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t; + \`uvm_object_param_utils(this_type_t); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + + // Function: do_copy + // extern function void do_copy(uvm_object rhs); + // Function: do_compare + // extern function bit do_compare(uvm_object rhs, uvm_comparer comparer); + // Function: convert2string + // extern function string convert2string(); + // Function: do_print + // extern function void do_print(uvm_printer printer); + // Function: do_record + // extern function void do_record(uvm_recorder recorder); + // Function: do_pack + // extern function void do_pack(); + // Function: do_unpack + // extern function void do_unpack(); + $0 + endclass: $1 + + + /*----------------------------------------------------------------------------*/ + /* Constraints */ + /*----------------------------------------------------------------------------*/ + + + + + /*----------------------------------------------------------------------------*/ + /* Functions */ + /*----------------------------------------------------------------------------*/ + + + +snippet uvm_sequence_item_do_copy + function void ${1:my_class}${2:::}do_copy(uvm_object rhs); + this_type_t rhs_; + + if (!\$cast(rhs_, rhs)) begin + \`uvm_error({this.get_name(), ".do_copy()"}, "Cast failed!"); + return; + end + // \`uvm_info({this.get_name(), ".do_copy()"}, "Cast succeded.", UVM_HIGH); + + /* chain the copy with parent classes */ + super.do_copy(rhs); + + /* list of local properties to be copied */ + // <this.property_name = rhs_.property_name>; + endfunction: do_copy$0 + + + +snippet uvm_sequence_item_do_compare + function bit ${1:my_class}${2:::}do_compare(uvm_object rhs, uvm_comparer comparer); + this_type_t rhs_; + + if (!\$cast(rhs_, rhs)) begin + \`uvm_error({this.get_name(), ".do_compare()"}, "Cast failed!"); + return; + end + // \`uvm_info({this.get_name(), ".do_compare()"}, "Cast succeded.", UVM_HIGH); + + /* chain the compare with parent classes */ + do_compare = super.do_compare(rhs, comparer); + + /* list of local properties to be compared: */ + do_compare &= ( + // <this.property_name == rhs_.property_name> && + // <this.property_name == rhs_.property_name> + ); + endfunction: do_compare$0 + + + +snippet uvm_sequence_item_convert2string + function string ${1:my_class}${2:::}convert2string(); + string s; + + /* chain the convert2string with parent classes */ + s = super.convert2string(); + + /* list of local properties to be printed: */ + // guide 0---4---8--12--16--20--24--28--32--36--40--44--48-- + // s = {s, \$sformatf("property_label : 0x%0h\n", property_name)}; + // s = {s, \$sformatf("property_label : %0d\n", property_name)}; + + return s; + endfunction: convert2string$0 + + + +snippet uvm_sequence_item_do_print + function void ${1:my_class}${2:::}do_print(uvm_printer printer) + /* chain the print with parent classes */ + super.do_print(printer); + + /* list of local properties to be printed: */ + // printer.print_string("property_label", property_name); + // printer.print_field_int("property_label", property_name, \$bits(property_name), UVM_HEX); + endfunction: do_print$0 + +snippet uvm_sequence_item_do_record + function void ${1:my_class}${2:::}do_record(uvm_recorder recorder); + /* chain the record with parent classes */ + super.do_record(recorder); + + /* list of local properties to be recorded: */ + /* note: use uvm_record_int, uvm_record_string, uvm_record_time, uvm_record_real for known basic types. */ + // \`uvm_record_string("property_label", property_name); + // \`uvm_record_int("property_label", property_name, \$bits(property_name), UVM_HEX); + endfunction: do_record$0 + +snippet uvm_sequence_item_do_pack + function void ${1:my_class}${2:::}do_pack(uvm_packer packer); + /* chain the pack with parent classes */ + super.do_pack(packer); + + /* list of local properties to be packed: */ + // note: look up the appropriate macro(s) for your properties! + // \`uvm_pack_int(property_name); + // \`uvm_pack_queue(property_name); + // \`uvm_pack_string(property_name); + endfunction: do_pack$0 + +snippet uvm_sequence_item_do_unpack + function void ${1:my_class}${2:::}do_unpack(uvm_packer packer); + /* chain the unpack with parent classes */ + super.do_unpack(packer); + + /* list of local properties to be unpacked: */ + // note: look up the appropriate macro(s) for your properties! + // \`uvm_unpack_int(property_name); + // \`uvm_unpack_queue(property_name); + // \`uvm_unpack_string(property_name); + endfunction: do_unpack$0 +