diff --git a/sources_non_forked/ale/LICENSE b/sources_non_forked/ale/LICENSE index f8f3524d..584cc5b5 100644 --- a/sources_non_forked/ale/LICENSE +++ b/sources_non_forked/ale/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2019, w0rp +Copyright (c) 2016-2023, Dense Analysis All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/sources_non_forked/ale/ale_linters/ada/adals.vim b/sources_non_forked/ale/ale_linters/ada/adals.vim new file mode 100644 index 00000000..9a41e1df --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ada/adals.vim @@ -0,0 +1,26 @@ +" Author: Bartek Jasicki http://github.com/thindil +" Description: Support for Ada Language Server + +call ale#Set('ada_adals_executable', 'ada_language_server') +call ale#Set('ada_adals_project', 'default.gpr') +call ale#Set('ada_adals_encoding', 'utf-8') + +function! ale_linters#ada#adals#GetAdaLSConfig(buffer) abort + return { + \ 'ada.projectFile': ale#Var(a:buffer, 'ada_adals_project'), + \ 'ada.defaultCharset': ale#Var(a:buffer, 'ada_adals_encoding') + \} +endfunction + +function! ale_linters#ada#adals#GetRootDirectory(buffer) abort + return fnamemodify(bufname(a:buffer), ':p:h') +endfunction + +call ale#linter#Define('ada', { +\ 'name': 'adals', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'ada_adals_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#ada#adals#GetRootDirectory'), +\ 'lsp_config': function('ale_linters#ada#adals#GetAdaLSConfig') +\}) diff --git a/sources_non_forked/ale/ale_linters/ada/cspell.vim b/sources_non_forked/ale/ale_linters/ada/cspell.vim new file mode 100644 index 00000000..7342d2b6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ada/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Ada files. + +call ale#handlers#cspell#DefineLinter('ada') diff --git a/sources_non_forked/ale/ale_linters/ada/gcc.vim b/sources_non_forked/ale/ale_linters/ada/gcc.vim index 87496b81..5afc9ae3 100644 --- a/sources_non_forked/ale/ale_linters/ada/gcc.vim +++ b/sources_non_forked/ale/ale_linters/ada/gcc.vim @@ -18,7 +18,7 @@ function! ale_linters#ada#gcc#GetCommand(buffer) abort " -gnatc: Check syntax and semantics only (no code generation attempted) return '%e -x ada -c -gnatc' \ . ' -o ' . ale#Escape(l:out_file) - \ . ' -I ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . ' -I %s:h' \ . ale#Pad(ale#Var(a:buffer, 'ada_gcc_options')) \ . ' %t' endfunction diff --git a/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim b/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim index c4affa31..e15008c8 100644 --- a/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim +++ b/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim @@ -1,4 +1,4 @@ -" Author: Bjorn Neergaard +" Authors: Bjorn Neergaard , Vytautas Macionis " Description: ansible-lint for ansible-yaml files call ale#Set('ansible_ansible_lint_executable', 'ansible-lint') @@ -7,7 +7,7 @@ function! ale_linters#ansible#ansible_lint#GetExecutable(buffer) abort return ale#Var(a:buffer, 'ansible_ansible_lint_executable') endfunction -function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort +function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort for l:line in a:lines[:10] if match(l:line, '^Traceback') >= 0 return [{ @@ -18,39 +18,121 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort endif endfor - " Matches patterns line the following: - " - " test.yml:35: [EANSIBLE0002] Trailing whitespace - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$' + let l:version_group = ale#semver#GTE(a:version, [6, 0, 0]) ? '>=6.0.0' : + \ ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' : + \ '<5.0.0' let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:code = l:match[4] + if '>=6.0.0' is# l:version_group + let l:error_codes = { 'blocker': 'E', 'critical': 'E', 'major': 'W', 'minor': 'W', 'info': 'I' } + let l:linter_issues = ale#util#FuzzyJSONDecode(a:lines, []) - if l:code is# 'EANSIBLE0002' - \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') - " Skip warnings for trailing whitespace if the option is off. - continue - endif + for l:issue in l:linter_issues + if ale#path#IsBufferPath(a:buffer, l:issue.location.path) + if exists('l:issue.location.positions') + let l:coord_keyname = 'positions' + else + let l:coord_keyname = 'lines' + endif - if ale#path#IsBufferPath(a:buffer, l:match[1]) - call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'col': l:match[3] + 0, - \ 'text': l:match[5], - \ 'code': l:code, - \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', - \}) - endif - endfor + let l:column_member = printf( + \ 'l:issue.location.%s.begin.column', l:coord_keyname + \) + + call add(l:output, { + \ 'lnum': exists(l:column_member) ? l:issue.location[l:coord_keyname].begin.line : + \ l:issue.location[l:coord_keyname].begin, + \ 'col': exists(l:column_member) ? l:issue.location[l:coord_keyname].begin.column : 0, + \ 'text': l:issue.check_name, + \ 'detail': l:issue.description, + \ 'code': l:issue.severity, + \ 'type': l:error_codes[l:issue.severity], + \}) + endif + endfor + endif + + if '>=5.0.0' is# l:version_group + " Matches patterns line the following: + " test.yml:3:148: syntax-check 'var' is not a valid attribute for a Play + " roles/test/tasks/test.yml:8: [package-latest] [VERY_LOW] Package installs should not use latest + " D:\test\tasks\test.yml:8: [package-latest] [VERY_LOW] package installs should not use latest + let l:pattern = '\v^(%([a-zA-Z]:)?[^:]+):(\d+):%((\d+):)? %(\[([-[:alnum:]]+)\]) %(\[([_[:alnum:]]+)\]) (.*)$' + let l:error_codes = { 'VERY_HIGH': 'E', 'HIGH': 'E', 'MEDIUM': 'W', 'LOW': 'W', 'VERY_LOW': 'W', 'INFO': 'I' } + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if ale#path#IsBufferPath(a:buffer, l:match[1]) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[6], + \ 'code': l:match[4], + \ 'type': l:error_codes[l:match[5]], + \}) + endif + endfor + endif + + if '<5.0.0' is# l:version_group + " Matches patterns line the following: + " test.yml:35: [EANSIBLE0002] Trailing whitespace + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[4] + + if l:code is# 'EANSIBLE0002' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if ale#path#IsBufferPath(a:buffer, l:match[1]) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[5], + \ 'code': l:code, + \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', + \}) + endif + endfor + endif return l:output endfunction +function! ale_linters#ansible#ansible_lint#GetCommand(buffer, version) abort + let l:commands = { + \ '>=6.0.0': '%e --nocolor -f json -x yaml %s', + \ '>=5.0.0': '%e --nocolor --parseable-severity -x yaml %s', + \ '<5.0.0': '%e --nocolor -p %t' + \} + let l:command = ale#semver#GTE(a:version, [6, 0]) ? l:commands['>=6.0.0'] : + \ ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] : + \ l:commands['<5.0.0'] + + return l:command +endfunction + call ale#linter#Define('ansible', { \ 'name': 'ansible_lint', \ 'aliases': ['ansible', 'ansible-lint'], \ 'executable': function('ale_linters#ansible#ansible_lint#GetExecutable'), -\ 'command': '%e -p %t', -\ 'callback': 'ale_linters#ansible#ansible_lint#Handle', +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#ansible#ansible_lint#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#ansible#ansible_lint#GetCommand'), +\ )}, +\ 'lint_file': 1, +\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#ansible#ansible_lint#GetExecutable(buffer), +\ '%e --version', +\ {buffer, version -> ale_linters#ansible#ansible_lint#Handle( +\ buffer, +\ l:version, +\ lines)}, +\ )}, \}) diff --git a/sources_non_forked/ale/ale_linters/ansible/language_server.vim b/sources_non_forked/ale/ale_linters/ansible/language_server.vim new file mode 100644 index 00000000..0c064353 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ansible/language_server.vim @@ -0,0 +1,47 @@ +" Author: Horacio Sanson +" Description: Support ansible language server https://github.com/ansible/ansible-language-server/ + +call ale#Set('ansible_language_server_executable', 'ansible-language-server') +call ale#Set('ansible_language_server_config', {}) + +function! ale_linters#ansible#language_server#Executable(buffer) abort + return ale#Var(a:buffer, 'ansible_language_server_executable') +endfunction + +function! ale_linters#ansible#language_server#GetCommand(buffer) abort + let l:executable = ale_linters#ansible#language_server#Executable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +function! ale_linters#ansible#language_server#FindProjectRoot(buffer) abort + let l:dir = fnamemodify( + \ ale#path#FindNearestFile(a:buffer, 'ansible.cfg'), + \ ':h' + \) + + if l:dir isnot# '.' && isdirectory(l:dir) + return l:dir + endif + + let l:dir = fnamemodify( + \ ale#path#FindNearestDirectory(a:buffer, '.git'), + \ ':h:h' + \) + + if l:dir isnot# '.' && isdirectory(l:dir) + return l:dir + endif + + return '' +endfunction + +call ale#linter#Define('ansible', { +\ 'name': 'language_server', +\ 'aliases': ['ansible_language_server', 'ansible-language-server'], +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#ansible#language_server#Executable'), +\ 'command': function('ale_linters#ansible#language_server#GetCommand'), +\ 'project_root': function('ale_linters#ansible#language_server#FindProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'ansible_language_server_config')} +\}) diff --git a/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim b/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim new file mode 100644 index 00000000..285f5534 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim @@ -0,0 +1,12 @@ +" Author: Leo +" Description: apkbuild-lint from atools linter for APKBUILDs + +call ale#Set('apkbuild_apkbuild_lint_executable', 'apkbuild-lint') + +call ale#linter#Define('apkbuild', { +\ 'name': 'apkbuild_lint', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'apkbuild_apkbuild_lint_executable')}, +\ 'command': '%e %t', +\ 'callback': 'ale#handlers#atools#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim b/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim new file mode 100644 index 00000000..c65267fd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim @@ -0,0 +1,12 @@ +" Author: Leo +" Description: secfixes-check from atools linter for APKBUILDs + +call ale#Set('apkbuild_secfixes_check_executable', 'secfixes-check') + +call ale#linter#Define('apkbuild', { +\ 'name': 'secfixes_check', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'apkbuild_secfixes_check_executable')}, +\ 'command': '%e %t', +\ 'callback': 'ale#handlers#atools#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/asciidoc/cspell.vim b/sources_non_forked/ale/ale_linters/asciidoc/cspell.vim new file mode 100644 index 00000000..b228b2e8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for ASCIIDoc files. + +call ale#handlers#cspell#DefineLinter('asciidoc') diff --git a/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim b/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim new file mode 100644 index 00000000..8e8de7f3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim @@ -0,0 +1,5 @@ +" Author: Horacio Sanson (hsanson [ät] gmail.com) +" Description: languagetool for asciidoc files, copied from markdown. + + +call ale#handlers#languagetool#DefineLinter('asciidoc') diff --git a/sources_non_forked/ale/ale_linters/asm/gcc.vim b/sources_non_forked/ale/ale_linters/asm/gcc.vim index eecab6ef..cda38923 100644 --- a/sources_non_forked/ale/ale_linters/asm/gcc.vim +++ b/sources_non_forked/ale/ale_linters/asm/gcc.vim @@ -9,7 +9,7 @@ function! ale_linters#asm#gcc#GetCommand(buffer) abort " -fsyntax-only doesn't catch everything. return '%e -x assembler' \ . ' -o ' . g:ale#util#nul_file - \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . '-iquote %s:h' \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -' endfunction diff --git a/sources_non_forked/ale/ale_linters/asm/llvm_mc.vim b/sources_non_forked/ale/ale_linters/asm/llvm_mc.vim new file mode 100644 index 00000000..ebfd0064 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asm/llvm_mc.vim @@ -0,0 +1,37 @@ +" Author: uidops +" Description: llvm-mc linter for asm files + +call ale#Set('asm_llvm_mc_executable', 'llvm-mc') +call ale#Set('asm_llvm_mc_options', '') + +function! ale_linters#asm#llvm_mc#GetCommand(buffer) abort + return '%e --assemble' + \ . ' --filetype=asm' + \ . ' -o ' . g:ale#util#nul_file + \ . ' ' . ale#Var(a:buffer, 'asm_llvm_mc_options') +endfunction + +function! ale_linters#asm#llvm_mc#Handle(buffer, lines) abort + let l:pattern = '^.\+:\(\d\+\):\(\d\+\): \([^:]\+\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] =~? 'error' ? 'E' : 'W', + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('asm', { +\ 'name': 'llvm_mc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'asm_llvm_mc_executable')}, +\ 'command': function('ale_linters#asm#llvm_mc#GetCommand'), +\ 'callback': 'ale_linters#asm#llvm_mc#Handle', +\}) + 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 +" 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/avra/avra.vim b/sources_non_forked/ale/ale_linters/avra/avra.vim new file mode 100644 index 00000000..edf15c09 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/avra/avra.vim @@ -0,0 +1,36 @@ +" Author: Utkarsh Verma +" Description: AVRA linter for avra syntax. + +call ale#Set('avra_avra_executable', 'avra') +call ale#Set('avra_avra_options', '') + +function! ale_linters#avra#avra#GetCommand(buffer) abort + return '%e' + \ . ' %t' + \ . ale#Pad(ale#Var(a:buffer, 'avra_avra_options')) + \ . ' -o ' . g:ale#util#nul_file +endfunction + +function! ale_linters#avra#avra#Handle(buffer, lines) abort + " Note that we treat 'fatal' as errors. + let l:pattern = '^\S\+(\(\d\+\))\s\+:\s\+\(\S\+\)\s\+:\s\+\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2] =~? 'Error' ? 'E' : 'W', + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('avra', { +\ 'name': 'avra', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'avra_avra_executable')}, +\ 'command': function('ale_linters#avra#avra#GetCommand'), +\ 'callback': 'ale_linters#avra#avra#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/awk/gawk.vim b/sources_non_forked/ale/ale_linters/awk/gawk.vim index f795c57d..0c3212fd 100644 --- a/sources_non_forked/ale/ale_linters/awk/gawk.vim +++ b/sources_non_forked/ale/ale_linters/awk/gawk.vim @@ -1,5 +1,5 @@ " Author: kmarc -" Description: This file adds support for using GNU awk with sripts. +" Description: This file adds support for using GNU awk with scripts. call ale#Set('awk_gawk_executable', 'gawk') call ale#Set('awk_gawk_options', '') @@ -9,8 +9,9 @@ function! ale_linters#awk#gawk#GetCommand(buffer) abort " gawk from attempting to execute the body of the script " it is linting. return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }') + \ . ' --lint' \ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options')) - \ . ' -f %t --lint /dev/null' + \ . ' -f %t /dev/null' endfunction call ale#linter#Define('awk', { diff --git a/sources_non_forked/ale/ale_linters/bats/shellcheck.vim b/sources_non_forked/ale/ale_linters/bats/shellcheck.vim new file mode 100644 index 00000000..5c2a0ea9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bats/shellcheck.vim @@ -0,0 +1,4 @@ +" Author: Ian2020 +" Description: shellcheck linter for bats scripts. + +call ale#handlers#shellcheck#DefineLinter('bats') diff --git a/sources_non_forked/ale/ale_linters/bib/bibclean.vim b/sources_non_forked/ale/ale_linters/bib/bibclean.vim index 9056a9c3..f1610e00 100644 --- a/sources_non_forked/ale/ale_linters/bib/bibclean.vim +++ b/sources_non_forked/ale/ale_linters/bib/bibclean.vim @@ -18,7 +18,12 @@ function! ale_linters#bib#bibclean#get_type(str) abort endfunction function! ale_linters#bib#bibclean#match_msg(line) abort - return matchlist(a:line, '^\(.*\) "stdin", line \(.*\): \(.*\)$') + " Legacy message pattern works for bibclean <= v2.11.4. If empty, try + " the new message pattern for bibtex > v2.11.4 + let l:matches_legacy = matchlist(a:line, '^\(.*\) "stdin", line \(\d\+\): \(.*\)$') + + return ! empty(l:matches_legacy) ? l:matches_legacy + \ : matchlist(a:line, '^\(.*\) stdin:\(\d\+\):\(.*\)$') endfunction function! ale_linters#bib#bibclean#match_entry(line) abort diff --git a/sources_non_forked/ale/ale_linters/bicep/az_bicep.vim b/sources_non_forked/ale/ale_linters/bicep/az_bicep.vim new file mode 100644 index 00000000..f487ae0f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bicep/az_bicep.vim @@ -0,0 +1,69 @@ +" Author: Carl Smedstad +" Description: az_bicep for bicep files + +let g:ale_bicep_az_bicep_executable = +\ get(g:, 'ale_bicep_az_bicep_executable', 'az') + +let g:ale_bicep_az_bicep_options = +\ get(g:, 'ale_bicep_az_bicep_options', '') + +function! ale_linters#bicep#az_bicep#Executable(buffer) abort + return ale#Var(a:buffer, 'bicep_az_bicep_executable') +endfunction + +function! ale_linters#bicep#az_bicep#Command(buffer) abort + let l:executable = ale_linters#bicep#az_bicep#Executable(a:buffer) + let l:options = ale#Var(a:buffer, 'bicep_az_bicep_options') + + if has('win32') + let l:nullfile = 'NUL' + else + let l:nullfile = '/dev/null' + endif + + return ale#Escape(l:executable) + \ . ' bicep build --outfile ' + \ . l:nullfile + \ . ' --file ' + \ . '%s ' + \ . l:options +endfunction + +function! ale_linters#bicep#az_bicep#Handle(buffer, lines) abort + let l:pattern = '\v^([A-Z]+)?(:\s)?(.*)\((\d+),(\d+)\)\s:\s([a-zA-Z]*)\s([-a-zA-Z0-9]*):\s(.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[1] is# 'ERROR' + let l:type = 'E' + elseif l:match[1] is# 'WARNING' + let l:type = 'W' + elseif l:match[6] is# 'Error' + let l:type = 'E' + elseif l:match[6] is# 'Warning' + let l:type = 'W' + else + let l:type = 'I' + endif + + call add(l:output, { + \ 'filename': l:match[3], + \ 'lnum': l:match[4] + 0, + \ 'col': l:match[5] + 0, + \ 'type': l:type, + \ 'code': l:match[7], + \ 'text': l:match[8], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('bicep', { +\ 'name': 'az_bicep', +\ 'executable': function('ale_linters#bicep#az_bicep#Executable'), +\ 'command': function('ale_linters#bicep#az_bicep#Command'), +\ 'callback': 'ale_linters#bicep#az_bicep#Handle', +\ 'output_stream': 'stderr', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/bicep/bicep.vim b/sources_non_forked/ale/ale_linters/bicep/bicep.vim new file mode 100644 index 00000000..a5f0d7c6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bicep/bicep.vim @@ -0,0 +1,65 @@ +" Author: Carl Smedstad +" Description: bicep for bicep files + +let g:ale_bicep_bicep_executable = +\ get(g:, 'ale_bicep_bicep_executable', 'bicep') + +let g:ale_bicep_bicep_options = +\ get(g:, 'ale_bicep_bicep_options', '') + +function! ale_linters#bicep#bicep#Executable(buffer) abort + return ale#Var(a:buffer, 'bicep_bicep_executable') +endfunction + +function! ale_linters#bicep#bicep#Command(buffer) abort + let l:executable = ale_linters#bicep#bicep#Executable(a:buffer) + let l:options = ale#Var(a:buffer, 'bicep_bicep_options') + + if has('win32') + let l:nullfile = 'NUL' + else + let l:nullfile = '/dev/null' + endif + + return ale#Escape(l:executable) + \ . ' build --outfile ' + \ . l:nullfile + \ . ' ' + \ . l:options + \ . ' %s' +endfunction + +function! ale_linters#bicep#bicep#Handle(buffer, lines) abort + let l:pattern = '\v^(.*)\((\d+),(\d+)\)\s:\s([a-zA-Z]*)\s([-a-zA-Z0-9]*):\s(.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[4] is# 'Error' + let l:type = 'E' + elseif l:match[4] is# 'Warning' + let l:type = 'W' + else + let l:type = 'I' + endif + + call add(l:output, { + \ 'filename': l:match[1], + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': l:type, + \ 'code': l:match[5], + \ 'text': l:match[6], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('bicep', { +\ 'name': 'bicep', +\ 'executable': function('ale_linters#bicep#bicep#Executable'), +\ 'command': function('ale_linters#bicep#bicep#Command'), +\ 'callback': 'ale_linters#bicep#bicep#Handle', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/bitbake/oelint_adv.vim b/sources_non_forked/ale/ale_linters/bitbake/oelint_adv.vim new file mode 100644 index 00000000..fb85a9b9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bitbake/oelint_adv.vim @@ -0,0 +1,47 @@ +" Author: offa +" Description: oelint-adv for BitBake files + +call ale#Set('bitbake_oelint_adv_executable', 'oelint-adv') +call ale#Set('bitbake_oelint_adv_options', '') +call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg') + +function! ale_linters#bitbake#oelint_adv#Command(buffer) abort + let l:config_file = ale#path#FindNearestFile(a:buffer, + \ ale#Var(a:buffer, 'bitbake_oelint_adv_config')) + + return ((!empty(l:config_file)) + \ ? 'OELINT_CONFIG=' . ale#Escape(l:config_file) . ' ' + \ : '') + \ . '%e --quiet ' + \ . ale#Pad(ale#Var(a:buffer, 'bitbake_oelint_adv_options')) . '%s' +endfunction + +function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort + let l:pattern = '\v^(.+):(.+):(.+):(.+):(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:match[3] is# 'error' + \ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'), + \ 'text': StripAnsiCodes(l:match[5]), + \ 'code': l:match[4] + \ }) + endfor + + return l:output +endfunction + +function! StripAnsiCodes(line) abort + return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g') +endfunction + +call ale#linter#Define('bitbake', { +\ 'name': 'oelint_adv', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'bitbake_oelint_adv_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#bitbake#oelint_adv#Command'), +\ 'callback': 'ale_linters#bitbake#oelint_adv#Handle', +\ }) diff --git a/sources_non_forked/ale/ale_linters/bzl/buildifier.vim b/sources_non_forked/ale/ale_linters/bzl/buildifier.vim new file mode 100644 index 00000000..42cd3cd9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bzl/buildifier.vim @@ -0,0 +1,40 @@ +" Author: Chuck Grindel +" Description: Bazel Starlark lint support using buildifier. + +function! ale_linters#bzl#buildifier#GetCommand(buffer) abort + let l:executable = ale#Escape(ale#fixers#buildifier#GetExecutable(a:buffer)) + let l:options = ale#Var(a:buffer, 'bazel_buildifier_options') + let l:filename = ale#Escape(bufname(a:buffer)) + + let l:command = l:executable . ' -mode check -lint warn -path %s' + + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return l:command +endfunction + +function! ale_linters#bzl#buildifier#Handle(buffer, lines) abort + let l:pattern = '\v^[^:]+:(\d+):(\d+)?:?\s+(syntax error near)?(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3] . l:match[4], + \ 'type': l:match[3] is# 'syntax error near' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('bzl', { +\ 'name': 'buildifier', +\ 'output_stream': 'both', +\ 'executable': function('ale#fixers#buildifier#GetExecutable'), +\ 'command': function('ale_linters#bzl#buildifier#GetCommand'), +\ 'callback': function('ale_linters#bzl#buildifier#Handle'), +\}) diff --git a/sources_non_forked/ale/ale_linters/c/cc.vim b/sources_non_forked/ale/ale_linters/c/cc.vim new file mode 100644 index 00000000..35125f2f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cc.vim @@ -0,0 +1,67 @@ +" Author: w0rp +" Description: A C compiler linter for C files with gcc/clang, etc. + +call ale#Set('c_cc_executable', '') +call ale#Set('c_cc_options', '-std=c11 -Wall') +call ale#Set('c_cc_use_header_lang_flag', -1) +call ale#Set('c_cc_header_exts', ['h']) + +function! ale_linters#c#cc#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'c_cc_executable') + + " Default to either clang or gcc. + if l:executable is# '' + if ale#engine#IsExecutable(a:buffer, 'clang') + let l:executable = 'clang' + else + let l:executable = 'gcc' + endif + endif + + return l:executable +endfunction + +function! ale_linters#c#cc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:ale_flags = ale#Var(a:buffer, 'c_cc_options') + + if l:cflags =~# '-std=' + let l:ale_flags = substitute( + \ l:ale_flags, + \ '-std=\(c\|gnu\)[0-9]\{2\}', + \ '', + \ 'g') + endif + + " Select the correct language flag depending on the executable, options + " and file extension + let l:executable = ale_linters#c#cc#GetExecutable(a:buffer) + let l:use_header_lang_flag = ale#Var(a:buffer, 'c_cc_use_header_lang_flag') + let l:header_exts = ale#Var(a:buffer, 'c_cc_header_exts') + let l:lang_flag = ale#c#GetLanguageFlag( + \ a:buffer, + \ l:executable, + \ l:use_header_lang_flag, + \ l:header_exts, + \ 'c') + + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + " + " `-o /dev/null` or `-o null` is needed to catch all errors, + " -fsyntax-only doesn't catch everything. + return '%e -S -x ' . l:lang_flag + \ . ' -o ' . g:ale#util#nul_file + \ . ' -iquote %s:h' + \ . ale#Pad(l:cflags) + \ . ale#Pad(l:ale_flags) . ' -' +endfunction + +call ale#linter#Define('c', { +\ 'name': 'cc', +\ 'aliases': ['gcc', 'clang'], +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#c#cc#GetExecutable'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#cc#GetCommand'))}, +\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', +\}) diff --git a/sources_non_forked/ale/ale_linters/c/ccls.vim b/sources_non_forked/ale/ale_linters/c/ccls.vim index 9e3dafe9..9f105712 100644 --- a/sources_non_forked/ale/ale_linters/c/ccls.vim +++ b/sources_non_forked/ale/ale_linters/c/ccls.vim @@ -3,6 +3,7 @@ call ale#Set('c_ccls_executable', 'ccls') call ale#Set('c_ccls_init_options', {}) +call ale#Set('c_build_dir', '') call ale#linter#Define('c', { \ 'name': 'ccls', @@ -10,5 +11,5 @@ call ale#linter#Define('c', { \ 'executable': {b -> ale#Var(b, 'c_ccls_executable')}, \ 'command': '%e', \ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), -\ 'initialization_options': {b -> ale#Var(b, 'c_ccls_init_options')}, +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'c_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/c/clang.vim b/sources_non_forked/ale/ale_linters/c/clang.vim deleted file mode 100644 index 681101fc..00000000 --- a/sources_non_forked/ale/ale_linters/c/clang.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Author: Masahiro H https://github.com/mshr-h -" Description: clang linter for c files - -call ale#Set('c_clang_executable', 'clang') -call ale#Set('c_clang_options', '-std=c11 -Wall') - -function! ale_linters#c#clang#GetCommand(buffer, output) abort - let l:cflags = ale#c#GetCFlags(a:buffer, a:output) - - " -iquote with the directory the file is in makes #include work for - " headers in the same directory. - return '%e -S -x c -fsyntax-only' - \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -' -endfunction - -call ale#linter#Define('c', { -\ 'name': 'clang', -\ 'output_stream': 'stderr', -\ 'executable': {b -> ale#Var(b, 'c_clang_executable')}, -\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clang#GetCommand'))}, -\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', -\}) diff --git a/sources_non_forked/ale/ale_linters/c/clangcheck.vim b/sources_non_forked/ale/ale_linters/c/clangcheck.vim new file mode 100644 index 00000000..54dad47b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/clangcheck.vim @@ -0,0 +1,38 @@ +" Author: gagbo +" : luibo +" : Jorengarenar +" Description: clang-check linter for C files +" modified from cpp/clangcheck.vim to match for C + +call ale#Set('c_clangcheck_executable', 'clang-check') +call ale#Set('c_clangcheck_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#c#clangcheck#GetCommand(buffer) abort + let l:user_options = ale#Var(a:buffer, 'c_clangcheck_options') + + " Try to find compilation database to link automatically + let l:build_dir = ale#Var(a:buffer, 'c_build_dir') + + if empty(l:build_dir) + let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) + let l:build_dir = ale#path#Dirname(l:json_file) + endif + + " The extra arguments in the command are used to prevent .plist files from + " being generated. These are only added if no build directory can be + " detected. + return '%e -analyze %s' + \ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '') + \ . ale#Pad(l:user_options) + \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') +endfunction + +call ale#linter#Define('c', { +\ 'name': 'clangcheck', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'c_clangcheck_executable')}, +\ 'command': function('ale_linters#c#clangcheck#GetCommand'), +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/c/clangd.vim b/sources_non_forked/ale/ale_linters/c/clangd.vim index 79b600fa..c42d4497 100644 --- a/sources_non_forked/ale/ale_linters/c/clangd.vim +++ b/sources_non_forked/ale/ale_linters/c/clangd.vim @@ -3,9 +3,14 @@ call ale#Set('c_clangd_executable', 'clangd') call ale#Set('c_clangd_options', '') +call ale#Set('c_build_dir', '') function! ale_linters#c#clangd#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') endfunction call ale#linter#Define('c', { diff --git a/sources_non_forked/ale/ale_linters/c/clangtidy.vim b/sources_non_forked/ale/ale_linters/c/clangtidy.vim index f998866a..553cc23b 100644 --- a/sources_non_forked/ale/ale_linters/c/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/c/clangtidy.vim @@ -19,14 +19,17 @@ call ale#Set('c_clangtidy_options', '') call ale#Set('c_clangtidy_extra_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#c#clangtidy#GetCommand(buffer) abort +function! ale_linters#c#clangtidy#GetCommand(buffer, output) abort let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',') let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = '' " Get the extra options if we couldn't find a build directory. - let l:options = empty(l:build_dir) - \ ? ale#Var(a:buffer, 'c_clangtidy_options') - \ : '' + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'c_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + endif " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options') @@ -43,7 +46,7 @@ call ale#linter#Define('c', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')}, -\ 'command': function('ale_linters#c#clangtidy#GetCommand'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clangtidy#GetCommand'))}, \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/c/cppcheck.vim b/sources_non_forked/ale/ale_linters/c/cppcheck.vim index 309b2851..28c2861f 100644 --- a/sources_non_forked/ale/ale_linters/c/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/c/cppcheck.vim @@ -5,14 +5,14 @@ call ale#Set('c_cppcheck_executable', 'cppcheck') call ale#Set('c_cppcheck_options', '--enable=style') function! ale_linters#c#cppcheck#GetCommand(buffer) abort - let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer) let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer) let l:buffer_path_include = empty(l:compile_commands_option) \ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) \ : '' + let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') - return l:cd_command - \ . '%e -q --language=c' + return '%e -q --language=c' + \ . l:template \ . ale#Pad(l:compile_commands_option) \ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options')) \ . l:buffer_path_include @@ -23,6 +23,7 @@ call ale#linter#Define('c', { \ 'name': 'cppcheck', \ 'output_stream': 'both', \ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')}, +\ 'cwd': function('ale#handlers#cppcheck#GetCwd'), \ 'command': function('ale_linters#c#cppcheck#GetCommand'), \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/c/cpplint.vim b/sources_non_forked/ale/ale_linters/c/cpplint.vim new file mode 100644 index 00000000..4b997941 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cpplint.vim @@ -0,0 +1,20 @@ +" Author: Justin Huang +" Description: cpplint for c files + +call ale#Set('c_cpplint_executable', 'cpplint') +call ale#Set('c_cpplint_options', '') + +function! ale_linters#c#cpplint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'c_cpplint_options') + + return '%e' . ale#Pad(l:options) . ' %s' +endfunction + +call ale#linter#Define('c', { +\ 'name': 'cpplint', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'c_cpplint_executable')}, +\ 'command': function('ale_linters#c#cpplint#GetCommand'), +\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/c/cspell.vim b/sources_non_forked/ale/ale_linters/c/cspell.vim new file mode 100644 index 00000000..5f016548 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for C files. + +call ale#handlers#cspell#DefineLinter('c') diff --git a/sources_non_forked/ale/ale_linters/c/gcc.vim b/sources_non_forked/ale/ale_linters/c/gcc.vim deleted file mode 100644 index 1df1018e..00000000 --- a/sources_non_forked/ale/ale_linters/c/gcc.vim +++ /dev/null @@ -1,28 +0,0 @@ -" Author: w0rp -" Description: gcc linter for c files - -call ale#Set('c_gcc_executable', 'gcc') -call ale#Set('c_gcc_options', '-std=c11 -Wall') - -function! ale_linters#c#gcc#GetCommand(buffer, output) abort - let l:cflags = ale#c#GetCFlags(a:buffer, a:output) - - " -iquote with the directory the file is in makes #include work for - " headers in the same directory. - " - " `-o /dev/null` or `-o null` is needed to catch all errors, - " -fsyntax-only doesn't catch everything. - return '%e -S -x c' - \ . ' -o ' . g:ale#util#nul_file - \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -' -endfunction - -call ale#linter#Define('c', { -\ 'name': 'gcc', -\ 'output_stream': 'stderr', -\ 'executable': {b -> ale#Var(b, 'c_gcc_executable')}, -\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#gcc#GetCommand'))}, -\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', -\}) diff --git a/sources_non_forked/ale/ale_linters/c3/c3lsp.vim b/sources_non_forked/ale/ale_linters/c3/c3lsp.vim new file mode 100644 index 00000000..43cd89d8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c3/c3lsp.vim @@ -0,0 +1,22 @@ +" Author: Koni Marti +" Description: A Language Server implementation for C3 + +call ale#Set('c3_c3lsp_executable', 'c3lsp') +call ale#Set('c3_c3lsp_options', '') +call ale#Set('c3_c3lsp_init_options', {}) + +function! ale_linters#c3#c3lsp#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'c3_c3lsp_executable') + + return ale#Escape(l:executable) . ale#Pad(ale#Var(a:buffer, 'c3_c3lsp_options')) +endfunction + + +call ale#linter#Define('c3', { +\ 'name': 'c3lsp', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'c3_c3lsp_executable')}, +\ 'command': function('ale_linters#c3#c3lsp#GetCommand'), +\ 'project_root': function('ale#handlers#c3lsp#GetProjectRoot'), +\ 'lsp_config': {b -> ale#handlers#c3lsp#GetInitOpts(b, 'c3_c3lsp_init_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/cairo/scarb.vim b/sources_non_forked/ale/ale_linters/cairo/scarb.vim new file mode 100644 index 00000000..48212f0b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cairo/scarb.vim @@ -0,0 +1,31 @@ +" Author: 0xhyoga <0xhyoga@gmx.com>, +" Description: scarb for cairo files + +function! ale_linters#cairo#scarb#GetScarbExecutable(bufnr) abort + if ale#path#FindNearestFile(a:bufnr, 'Scarb.toml') isnot# '' + return 'scarb' + else + " if there is no Scarb.toml file, we don't use scarb even if it exists, + " so we return '', because executable('') apparently always fails + return '' + endif +endfunction + +function! ale_linters#cairo#scarb#GetCommand(buffer, version) abort + return 'scarb build' +endfunction + +call ale#linter#Define('cairo', { +\ 'name': 'scarb', +\ 'executable': function('ale_linters#cairo#scarb#GetScarbExecutable'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#cairo#scarb#GetScarbExecutable(buffer), +\ '%e --version', +\ function('ale_linters#cairo#scarb#GetCommand'), +\ )}, +\ 'callback': 'ale#handlers#cairo#HandleCairoErrors', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) + diff --git a/sources_non_forked/ale/ale_linters/cairo/sierra.vim b/sources_non_forked/ale/ale_linters/cairo/sierra.vim new file mode 100644 index 00000000..06eb87f4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cairo/sierra.vim @@ -0,0 +1,54 @@ +" Author: 0xHyoga <0xHyoga@gmx.com> +" Description: Report Starknet compile to sierra errors in cairo 1.0 code + +call ale#Set('cairo_sierra_executable', 'starknet-compile') +call ale#Set('cairo_sierra_options', '') + +function! ale_linters#cairo#sierra#Handle(buffer, lines) abort + " Matches patterns like the following: + " Error: Expected ';' but got '(' + " --> /path/to/file/file.cairo:1:10:) + let l:pattern = '\v(error|warning): (.*)$' + let l:line_and_column_pattern = '\v\.cairo:(\d+):(\d+)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + let l:match = matchlist(l:line, l:line_and_column_pattern) + + if len(l:match) > 0 + let l:index = len(l:output) - 1 + let l:output[l:index]['lnum'] = l:match[1] + 0 + let l:output[l:index]['col'] = l:match[2] + 0 + endif + else + let l:isError = l:match[1] is? 'Error' + + call add(l:output, { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': l:isError ? 'E' : 'W', + \}) + endif + endfor + + return l:output +endfunction + +function! ale_linters#cairo#sierra#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'cairo_sierra_executable') + + return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_sierra_options')) . ' %s' +endfunction + +call ale#linter#Define('cairo', { +\ 'name': 'sierra', +\ 'executable': {b -> ale#Var(b, 'cairo_sierra_executable')}, +\ 'command': function('ale_linters#cairo#sierra#GetCommand'), +\ 'callback': 'ale_linters#cairo#sierra#Handle', +\ 'output_stream': 'stderr', +\}) + diff --git a/sources_non_forked/ale/ale_linters/cairo/starknet.vim b/sources_non_forked/ale/ale_linters/cairo/starknet.vim new file mode 100644 index 00000000..d471cc89 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cairo/starknet.vim @@ -0,0 +1,39 @@ +" Author: 0xHyoga <0xHyoga@gmx.com> +" Description: Report starknet-compile errors in cairo code (pre-starknet +" 1.0). This is deprecated but kept for backwards compatability. + +call ale#Set('cairo_starknet_executable', 'starknet-compile') +call ale#Set('cairo_starknet_options', '') + +function! ale_linters#cairo#starknet#Handle(buffer, lines) abort + " Error always on the first line + " e.g ex01.cairo:20:6: Could not find module 'contracts.utils.ex00_base'. Searched in the following paths: + let l:pattern = '\v\.cairo:(\d+):(\d+):+ (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'type': 'E', + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +function! ale_linters#cairo#starknet#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'cairo_starknet_executable') + + return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_starknet_options')) . ' %s' +endfunction + +call ale#linter#Define('cairo', { +\ 'name': 'starknet', +\ 'executable': {b -> ale#Var(b, 'cairo_starknet_executable')}, +\ 'command': function('ale_linters#cairo#starknet#GetCommand'), +\ 'callback': 'ale_linters#cairo#starknet#Handle', +\ 'output_stream': 'stderr', +\}) + diff --git a/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim index 5dd11c12..b470cf0c 100644 --- a/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim +++ b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim @@ -1,10 +1,23 @@ " Author: Masashi Iizuka " Description: linter for clojure using clj-kondo https://github.com/borkdude/clj-kondo +call ale#Set('clojure_clj_kondo_options', '--cache') + +function! ale_linters#clojure#clj_kondo#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'clojure_clj_kondo_options') + + let l:command = 'clj-kondo' + \ . ale#Pad(l:options) + \ . ' --lint -' + \ . ' --filename %s' + + return l:command +endfunction + function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort " output format " ::: : - let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Exception|error|warning): ?(.+))$' + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+)?:(\d+)?:? ((Exception|error|warning): ?(.+))$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -29,6 +42,6 @@ call ale#linter#Define('clojure', { \ 'name': 'clj-kondo', \ 'output_stream': 'stdout', \ 'executable': 'clj-kondo', -\ 'command': 'clj-kondo --lint %t', +\ 'command': function('ale_linters#clojure#clj_kondo#GetCommand'), \ 'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim b/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim index d0ac7b28..16841431 100644 --- a/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim +++ b/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim @@ -29,6 +29,7 @@ endfunction call ale#linter#Define('cloudformation', { \ 'name': 'cloudformation', +\ 'aliases': ['cfn-lint'], \ 'executable': 'cfn-lint', \ 'command': 'cfn-lint --template %t --format parseable', \ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle', diff --git a/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim b/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim new file mode 100644 index 00000000..5942e08d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim @@ -0,0 +1,43 @@ +" Author: Carl Smedstad +" Description: cmake-lint for cmake files + +let g:ale_cmake_cmake_lint_executable = +\ get(g:, 'ale_cmake_cmake_lint_executable', 'cmake-lint') + +let g:ale_cmake_cmake_lint_options = +\ get(g:, 'ale_cmake_cmake_lint_options', '') + +function! ale_linters#cmake#cmake_lint#Executable(buffer) abort + return ale#Var(a:buffer, 'cmake_cmake_lint_executable') +endfunction + +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 . ' %s' +endfunction + +function! ale_linters#cmake#cmake_lint#Handle(buffer, lines) abort + let l:pattern = '\v^[^:]+:(\d+),?(\d+)?:\s\[([A-Z]\d+)\]\s(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': 'W', + \ 'code': l:match[3], + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('cmake', { +\ 'name': 'cmake_lint', +\ 'executable': function('ale_linters#cmake#cmake_lint#Executable'), +\ 'command': function('ale_linters#cmake#cmake_lint#Command'), +\ 'callback': 'ale_linters#cmake#cmake_lint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cc.vim b/sources_non_forked/ale/ale_linters/cpp/cc.vim new file mode 100644 index 00000000..1d35bb67 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cc.vim @@ -0,0 +1,67 @@ +" Author: w0rp +" Description: A C++ compiler linter for C++ files with gcc/clang, etc. + +call ale#Set('cpp_cc_executable', '') +call ale#Set('cpp_cc_options', '-std=c++14 -Wall') +call ale#Set('cpp_cc_use_header_lang_flag', -1) +call ale#Set('cpp_cc_header_exts', ['h', 'hpp']) + +function! ale_linters#cpp#cc#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'cpp_cc_executable') + + " Default to either clang++ or gcc. + if l:executable is# '' + if ale#engine#IsExecutable(a:buffer, 'clang++') + let l:executable = 'clang++' + else + let l:executable = 'gcc' + endif + endif + + return l:executable +endfunction + +function! ale_linters#cpp#cc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:ale_flags = ale#Var(a:buffer, 'cpp_cc_options') + + if l:cflags =~# '-std=' + let l:ale_flags = substitute( + \ l:ale_flags, + \ '-std=\(c\|gnu\)++[0-9]\{2\}', + \ '', + \ 'g') + endif + + " Select the correct language flag depending on the executable, options + " and file extension + let l:executable = ale_linters#cpp#cc#GetExecutable(a:buffer) + let l:use_header_lang_flag = ale#Var(a:buffer, 'cpp_cc_use_header_lang_flag') + let l:header_exts = ale#Var(a:buffer, 'cpp_cc_header_exts') + let l:lang_flag = ale#c#GetLanguageFlag( + \ a:buffer, + \ l:executable, + \ l:use_header_lang_flag, + \ l:header_exts, + \ 'c++') + + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + " + " `-o /dev/null` or `-o null` is needed to catch all errors, + " -fsyntax-only doesn't catch everything. + return '%e -S -x ' . l:lang_flag + \ . ' -o ' . g:ale#util#nul_file + \ . ' -iquote %s:h' + \ . ale#Pad(l:cflags) + \ . ale#Pad(l:ale_flags) . ' -' +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'cc', +\ 'aliases': ['gcc', 'clang', 'g++', 'clang++'], +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#cpp#cc#GetExecutable'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#cc#GetCommand'))}, +\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/ccls.vim b/sources_non_forked/ale/ale_linters/cpp/ccls.vim index b265ff70..38f8df9c 100644 --- a/sources_non_forked/ale/ale_linters/cpp/ccls.vim +++ b/sources_non_forked/ale/ale_linters/cpp/ccls.vim @@ -3,6 +3,7 @@ call ale#Set('cpp_ccls_executable', 'ccls') call ale#Set('cpp_ccls_init_options', {}) +call ale#Set('c_build_dir', '') call ale#linter#Define('cpp', { \ 'name': 'ccls', @@ -10,5 +11,5 @@ call ale#linter#Define('cpp', { \ 'executable': {b -> ale#Var(b, 'cpp_ccls_executable')}, \ 'command': '%e', \ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), -\ 'initialization_options': {b -> ale#Var(b, 'cpp_ccls_init_options')}, +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'cpp_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clang.vim b/sources_non_forked/ale/ale_linters/cpp/clang.vim deleted file mode 100644 index e48291eb..00000000 --- a/sources_non_forked/ale/ale_linters/cpp/clang.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Author: Tomota Nakamura -" Description: clang linter for cpp files - -call ale#Set('cpp_clang_executable', 'clang++') -call ale#Set('cpp_clang_options', '-std=c++14 -Wall') - -function! ale_linters#cpp#clang#GetCommand(buffer, output) abort - let l:cflags = ale#c#GetCFlags(a:buffer, a:output) - - " -iquote with the directory the file is in makes #include work for - " headers in the same directory. - return '%e -S -x c++ -fsyntax-only' - \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -' -endfunction - -call ale#linter#Define('cpp', { -\ 'name': 'clang', -\ 'output_stream': 'stderr', -\ 'executable': {b -> ale#Var(b, 'cpp_clang_executable')}, -\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clang#GetCommand'))}, -\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', -\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim index 7d32a57c..4cb04864 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim @@ -20,7 +20,7 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort " being generated. These are only added if no build directory can be " detected. return '%e -analyze %s' - \ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '') + \ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '') \ . ale#Pad(l:user_options) \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') endfunction diff --git a/sources_non_forked/ale/ale_linters/cpp/clangd.vim b/sources_non_forked/ale/ale_linters/cpp/clangd.vim index fab605f4..14f3fe55 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangd.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangd.vim @@ -3,9 +3,14 @@ call ale#Set('cpp_clangd_executable', 'clangd') call ale#Set('cpp_clangd_options', '') +call ale#Set('c_build_dir', '') function! ale_linters#cpp#clangd#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options')) + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') endfunction call ale#linter#Define('cpp', { diff --git a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim index 085bc332..fa9f8e31 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim @@ -13,14 +13,24 @@ call ale#Set('cpp_clangtidy_options', '') call ale#Set('cpp_clangtidy_extra_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort +function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',') let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = '' " Get the extra options if we couldn't find a build directory. - let l:options = empty(l:build_dir) - \ ? ale#Var(a:buffer, 'cpp_clangtidy_options') - \ : '' + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + + " Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file + " only when compile-commands.json file is not there. Adding these + " flags makes clang-tidy completely ignore compile commands. + if expand('#' . a:buffer) =~# '\.h$' + let l:options .= !empty(l:options) ? ' -x c++' : '-x c++' + endif + endif " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options') @@ -37,7 +47,7 @@ call ale#linter#Define('cpp', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'cpp_clangtidy_executable')}, -\ 'command': function('ale_linters#cpp#clangtidy#GetCommand'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clangtidy#GetCommand'))}, \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim index 7cd80dbc..eb86adf4 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim @@ -5,14 +5,14 @@ call ale#Set('cpp_cppcheck_executable', 'cppcheck') call ale#Set('cpp_cppcheck_options', '--enable=style') function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort - let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer) let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer) let l:buffer_path_include = empty(l:compile_commands_option) \ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) \ : '' + let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') - return l:cd_command - \ . '%e -q --language=c++' + return '%e -q --language=c++' + \ . l:template \ . ale#Pad(l:compile_commands_option) \ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options')) \ . l:buffer_path_include @@ -23,6 +23,7 @@ call ale#linter#Define('cpp', { \ 'name': 'cppcheck', \ 'output_stream': 'both', \ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')}, +\ 'cwd': function('ale#handlers#cppcheck#GetCwd'), \ 'command': function('ale_linters#cpp#cppcheck#GetCommand'), \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cspell.vim b/sources_non_forked/ale/ale_linters/cpp/cspell.vim new file mode 100644 index 00000000..ace4c3b2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for C++ files. + +call ale#handlers#cspell#DefineLinter('cpp') diff --git a/sources_non_forked/ale/ale_linters/cpp/gcc.vim b/sources_non_forked/ale/ale_linters/cpp/gcc.vim deleted file mode 100644 index 108d6d70..00000000 --- a/sources_non_forked/ale/ale_linters/cpp/gcc.vim +++ /dev/null @@ -1,29 +0,0 @@ -" Author: geam -" Description: gcc linter for cpp files -" -call ale#Set('cpp_gcc_executable', 'gcc') -call ale#Set('cpp_gcc_options', '-std=c++14 -Wall') - -function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort - let l:cflags = ale#c#GetCFlags(a:buffer, a:output) - - " -iquote with the directory the file is in makes #include work for - " headers in the same directory. - " - " `-o /dev/null` or `-o null` is needed to catch all errors, - " -fsyntax-only doesn't catch everything. - return '%e -S -x c++' - \ . ' -o ' . g:ale#util#nul_file - \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -' -endfunction - -call ale#linter#Define('cpp', { -\ 'name': 'gcc', -\ 'aliases': ['g++'], -\ 'output_stream': 'stderr', -\ 'executable': {b -> ale#Var(b, 'cpp_gcc_executable')}, -\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#gcc#GetCommand'))}, -\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', -\}) diff --git a/sources_non_forked/ale/ale_linters/crystal/crystal.vim b/sources_non_forked/ale/ale_linters/crystal/crystal.vim index 3c2fefb7..8a905b12 100644 --- a/sources_non_forked/ale/ale_linters/crystal/crystal.vim +++ b/sources_non_forked/ale/ale_linters/crystal/crystal.vim @@ -5,6 +5,10 @@ function! ale_linters#crystal#crystal#Handle(buffer, lines) abort let l:output = [] for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + if !has_key(l:error, 'file') + continue + endif + call add(l:output, { \ 'lnum': l:error.line + 0, \ 'col': l:error.column + 0, diff --git a/sources_non_forked/ale/ale_linters/cs/csc.vim b/sources_non_forked/ale/ale_linters/cs/csc.vim index 308abc77..5ee3de29 100644 --- a/sources_non_forked/ale/ale_linters/cs/csc.vim +++ b/sources_non_forked/ale/ale_linters/cs/csc.vim @@ -3,14 +3,10 @@ call ale#Set('cs_csc_source', '') call ale#Set('cs_csc_assembly_path', []) call ale#Set('cs_csc_assemblies', []) -function! s:GetWorkingDirectory(buffer) abort - let l:working_directory = ale#Var(a:buffer, 'cs_csc_source') +function! ale_linters#cs#csc#GetCwd(buffer) abort + let l:cwd = ale#Var(a:buffer, 'cs_csc_source') - if !empty(l:working_directory) - return l:working_directory - endif - - return expand('#' . a:buffer . ':p:h') + return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h') endfunction function! ale_linters#cs#csc#GetCommand(buffer) abort @@ -34,8 +30,7 @@ function! ale_linters#cs#csc#GetCommand(buffer) abort " The code is compiled as a module and the output is redirected to a " temporary file. - return ale#path#CdString(s:GetWorkingDirectory(a:buffer)) - \ . 'csc /unsafe' + return 'csc /unsafe' \ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options')) \ . ale#Pad(l:lib_option) \ . ale#Pad(l:r_option) @@ -57,8 +52,7 @@ function! ale_linters#cs#csc#Handle(buffer, lines) abort \ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$', \] let l:output = [] - - let l:dir = s:GetWorkingDirectory(a:buffer) + let l:dir = ale_linters#cs#csc#GetCwd(a:buffer) for l:match in ale#util#GetMatches(a:lines, l:patterns) if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS' @@ -89,6 +83,7 @@ call ale#linter#Define('cs',{ \ 'name': 'csc', \ 'output_stream': 'stdout', \ 'executable': 'csc', +\ 'cwd': function('ale_linters#cs#csc#GetCwd'), \ 'command': function('ale_linters#cs#csc#GetCommand'), \ 'callback': 'ale_linters#cs#csc#Handle', \ 'lint_file': 1 diff --git a/sources_non_forked/ale/ale_linters/cs/cspell.vim b/sources_non_forked/ale/ale_linters/cs/cspell.vim new file mode 100644 index 00000000..c62dd11b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cs/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for C# files. + +call ale#handlers#cspell#DefineLinter('cs') diff --git a/sources_non_forked/ale/ale_linters/cs/mcsc.vim b/sources_non_forked/ale/ale_linters/cs/mcsc.vim index 0e4e5667..2dd46661 100644 --- a/sources_non_forked/ale/ale_linters/cs/mcsc.vim +++ b/sources_non_forked/ale/ale_linters/cs/mcsc.vim @@ -3,14 +3,10 @@ call ale#Set('cs_mcsc_source', '') call ale#Set('cs_mcsc_assembly_path', []) call ale#Set('cs_mcsc_assemblies', []) -function! s:GetWorkingDirectory(buffer) abort - let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source') +function! ale_linters#cs#mcsc#GetCwd(buffer) abort + let l:cwd = ale#Var(a:buffer, 'cs_mcsc_source') - if !empty(l:working_directory) - return l:working_directory - endif - - return expand('#' . a:buffer . ':p:h') + return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h') endfunction function! ale_linters#cs#mcsc#GetCommand(buffer) abort @@ -34,8 +30,7 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort " The code is compiled as a module and the output is redirected to a " temporary file. - return ale#path#CdString(s:GetWorkingDirectory(a:buffer)) - \ . 'mcs -unsafe' + return 'mcs -unsafe' \ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options')) \ . ale#Pad(l:lib_option) \ . ale#Pad(l:r_option) @@ -58,7 +53,7 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort \] let l:output = [] - let l:dir = s:GetWorkingDirectory(a:buffer) + let l:dir = ale_linters#cs#mcsc#GetCwd(a:buffer) for l:match in ale#util#GetMatches(a:lines, l:patterns) if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS' @@ -89,6 +84,7 @@ call ale#linter#Define('cs',{ \ 'name': 'mcsc', \ 'output_stream': 'stderr', \ 'executable': 'mcs', +\ 'cwd': function('ale_linters#cs#mcsc#GetCwd'), \ 'command': function('ale_linters#cs#mcsc#GetCommand'), \ 'callback': 'ale_linters#cs#mcsc#Handle', \ 'lint_file': 1 diff --git a/sources_non_forked/ale/ale_linters/css/cspell.vim b/sources_non_forked/ale/ale_linters/css/cspell.vim new file mode 100644 index 00000000..d42375b4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/css/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for CSS files. + +call ale#handlers#cspell#DefineLinter('css') diff --git a/sources_non_forked/ale/ale_linters/css/stylelint.vim b/sources_non_forked/ale/ale_linters/css/stylelint.vim index 38cb0e0b..ceb42461 100644 --- a/sources_non_forked/ale/ale_linters/css/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/css/stylelint.vim @@ -11,7 +11,8 @@ endfunction call ale#linter#Define('css', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'css_stylelint', [ +\ 'output_stream': 'both', +\ 'executable': {b -> ale#path#FindExecutable(b, 'css_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#css#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/css/vscodecss.vim b/sources_non_forked/ale/ale_linters/css/vscodecss.vim new file mode 100644 index 00000000..2d59adf0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/css/vscodecss.vim @@ -0,0 +1,16 @@ +" Author: Dalius Dobravolskas +" Description: VSCode css language server + +function! ale_linters#css#vscodecss#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('css', { +\ 'name': 'vscodecss', +\ 'lsp': 'stdio', +\ 'executable': 'vscode-css-language-server', +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#css#vscodecss#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/cuda/clangd.vim b/sources_non_forked/ale/ale_linters/cuda/clangd.vim new file mode 100644 index 00000000..bfda821b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cuda/clangd.vim @@ -0,0 +1,23 @@ +" Author: Tommy Chiang +" Description: Clangd language server for CUDA (modified from Andrey +" Melentyev's implementation for C++) + +call ale#Set('cuda_clangd_executable', 'clangd') +call ale#Set('cuda_clangd_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#cuda#clangd#GetCommand(buffer) abort + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'cuda_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') +endfunction + +call ale#linter#Define('cuda', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'cuda_clangd_executable')}, +\ 'command': function('ale_linters#cuda#clangd#GetCommand'), +\ 'project_root': function('ale#c#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim index f3af07b6..2734f6ec 100644 --- a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim +++ b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim @@ -5,9 +5,6 @@ call ale#Set('cuda_nvcc_executable', 'nvcc') call ale#Set('cuda_nvcc_options', '-std=c++11') function! ale_linters#cuda#nvcc#GetCommand(buffer) abort - " Unused: use ale#util#nul_file - " let l:output_file = ale#util#Tempname() . '.ii' - " call ale#command#ManageFile(a:buffer, l:output_file) return '%e -cuda' \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))) \ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options')) diff --git a/sources_non_forked/ale/ale_linters/d/dmd.vim b/sources_non_forked/ale/ale_linters/d/dmd.vim index 14461ae6..f38e812c 100644 --- a/sources_non_forked/ale/ale_linters/d/dmd.vim +++ b/sources_non_forked/ale/ale_linters/d/dmd.vim @@ -1,64 +1,106 @@ " Author: w0rp " Description: "dmd for D files" -function! ale_linters#d#dmd#GetDUBCommand(buffer) abort +function! s:GetDUBCommand(buffer) abort " If we can't run dub, then skip this command. - if !executable('dub') + if executable('dub') " Returning an empty string skips to the DMD command. - return '' + let l:config = ale#d#FindDUBConfig(a:buffer) + + " To support older dub versions, we just change the directory to the + " directory where we found the dub config, and then run `dub describe` + " from that directory. + if !empty(l:config) + return [fnamemodify(l:config, ':h'), 'dub describe --data-list + \ --data=import-paths + \ --data=string-import-paths + \ --data=versions + \ --data=debug-versions + \'] + endif endif - let l:dub_file = ale#d#FindDUBConfig(a:buffer) - - if empty(l:dub_file) - return '' - endif - - " To support older dub versions, we just change the directory to - " the directory where we found the dub config, and then run `dub describe` - " from that directory. - return 'cd ' . ale#Escape(fnamemodify(l:dub_file, ':h')) - \ . ' && dub describe --import-paths' + return ['', ''] endfunction function! ale_linters#d#dmd#RunDUBCommand(buffer) abort - let l:command = ale_linters#d#dmd#GetDUBCommand(a:buffer) + let [l:cwd, l:command] = s:GetDUBCommand(a:buffer) if empty(l:command) " If we can't run DUB, just run DMD. return ale_linters#d#dmd#DMDCommand(a:buffer, [], {}) endif - return ale#command#Run(a:buffer, l:command, function('ale_linters#d#dmd#DMDCommand')) + return ale#command#Run( + \ a:buffer, + \ l:command, + \ function('ale_linters#d#dmd#DMDCommand'), + \ {'cwd': l:cwd}, + \) endfunction function! ale_linters#d#dmd#DMDCommand(buffer, dub_output, meta) abort let l:import_list = [] + let l:str_import_list = [] + let l:versions_list = [] + let l:deb_versions_list = [] + let l:list_ind = 1 + let l:seen_line = 0 - " Build a list of import paths generated from DUB, if available. + " Build a list of options generated from DUB, if available. + " DUB output each path or version on a single line. + " Each list is separated by a blank line. + " Empty list are represented by a blank line (followed and/or + " preceded by a separation blank line) for l:line in a:dub_output + " line still has end of line char on windows + let l:line = substitute(l:line, '[\r\n]*$', '', '') + if !empty(l:line) - " The arguments must be '-Ifilename', not '-I filename' - call add(l:import_list, '-I' . ale#Escape(l:line)) + if l:list_ind == 1 + call add(l:import_list, '-I' . ale#Escape(l:line)) + elseif l:list_ind == 2 + call add(l:str_import_list, '-J' . ale#Escape(l:line)) + elseif l:list_ind == 3 + call add(l:versions_list, '-version=' . ale#Escape(l:line)) + elseif l:list_ind == 4 + call add(l:deb_versions_list, '-debug=' . ale#Escape(l:line)) + endif + + let l:seen_line = 1 + elseif !l:seen_line + " if list is empty must skip one empty line + let l:seen_line = 1 + else + let l:seen_line = 0 + let l:list_ind += 1 endif endfor - return 'dmd '. join(l:import_list) . ' -o- -wi -vcolumns -c %t' + return 'dmd ' . join(l:import_list) . ' ' . + \ join(l:str_import_list) . ' ' . + \ join(l:versions_list) . ' ' . + \ join(l:deb_versions_list) . ' -o- -wi -vcolumns -c %t' endfunction function! ale_linters#d#dmd#Handle(buffer, lines) abort " Matches patterns lines like the following: " /tmp/tmp.qclsa7qLP7/file.d(1): Error: function declaration without return type. (Note that constructors are always named 'this') " /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read - let l:pattern = '^[^(]\+(\([0-9]\+\)\,\?\([0-9]*\)): \([^:]\+\): \(.\+\)' + let l:pattern = '\v^(\f+)\((\d+)(,(\d+))?\): (\w+): (.+)$' let l:output = [] + let l:dir = expand('#' . a:buffer . ':p:h') for l:match in ale#util#GetMatches(a:lines, l:pattern) + " If dmd was invoked with relative path, match[1] is relative, otherwise it is absolute. + " As we invoke dmd with the buffer path (in /tmp), this will generally be absolute already + let l:fname = ale#path#GetAbsPath(l:dir, l:match[1]) call add(l:output, { - \ 'lnum': l:match[1], - \ 'col': l:match[2], - \ 'type': l:match[3] is# 'Warning' ? 'W' : 'E', - \ 'text': l:match[4], + \ 'filename': l:fname, + \ 'lnum': l:match[2], + \ 'col': l:match[4], + \ 'type': l:match[5] is# 'Warning' || l:match[5] is# 'Deprecation' ? 'W' : 'E', + \ 'text': l:match[6], \}) endfor diff --git a/sources_non_forked/ale/ale_linters/dafny/dafny.vim b/sources_non_forked/ale/ale_linters/dafny/dafny.vim index b5b90675..8a114d22 100644 --- a/sources_non_forked/ale/ale_linters/dafny/dafny.vim +++ b/sources_non_forked/ale/ale_linters/dafny/dafny.vim @@ -1,4 +1,5 @@ " Author: Taylor Blau +call ale#Set('dafny_dafny_timelimit', 10) function! ale_linters#dafny#dafny#Handle(buffer, lines) abort let l:pattern = '\v(.*)\((\d+),(\d+)\): (.*): (.*)' @@ -6,7 +7,7 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'bufnr': a:buffer, + \ 'filename': l:match[1], \ 'col': l:match[3] + 0, \ 'lnum': l:match[2] + 0, \ 'text': l:match[5], @@ -14,13 +15,27 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort \ }) endfor + for l:match in ale#util#GetMatches(a:lines, '\v(.*)\((\d+),(\d+)\): (Verification of .{-} timed out after \d+ seconds)') + call add(l:output, { + \ 'filename': l:match[1], + \ 'col': l:match[3] + 0, + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \ }) + endfor + return l:output endfunction +function! ale_linters#dafny#dafny#GetCommand(buffer) abort + return printf('dafny %%s /compile:0 /timeLimit:%d', ale#Var(a:buffer, 'dafny_dafny_timelimit')) +endfunction + call ale#linter#Define('dafny', { \ 'name': 'dafny', \ 'executable': 'dafny', -\ 'command': 'dafny %s /compile:0', +\ 'command': function('ale_linters#dafny#dafny#GetCommand'), \ 'callback': 'ale_linters#dafny#dafny#Handle', \ 'lint_file': 1, \ }) diff --git a/sources_non_forked/ale/ale_linters/dart/analysis_server.vim b/sources_non_forked/ale/ale_linters/dart/analysis_server.vim new file mode 100644 index 00000000..12a5d590 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dart/analysis_server.vim @@ -0,0 +1,37 @@ +" Author: Nelson Yeung +" 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 + " Note: pub only looks for pubspec.yaml, there's no point in adding + " support for pubspec.yml + let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml') + + return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.' +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)) + 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', { +\ 'name': 'analysis_server', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'dart_analysis_server_executable')}, +\ 'command': function('ale_linters#dart#analysis_server#GetCommand'), +\ 'project_root': function('ale_linters#dart#analysis_server#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim b/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim new file mode 100644 index 00000000..7d67c31c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim @@ -0,0 +1,29 @@ +" Author: ghsang +" Description: Check Dart files with dart analyze + +call ale#Set('dart_analyze_executable', 'dart') + +function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort + let l:pattern = '\v([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let [l:type, l:filename, l:lnum, l:col, l:message, l:code] = l:match[1:6] + call add(l:output, { + \ 'type': l:type is# 'error' ? 'E' : l:type is# 'info' ? 'I' : 'W', + \ 'text': l:code . ': ' . l:message, + \ 'lnum': str2nr(l:lnum), + \ 'col': str2nr(l:col), + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('dart', { +\ 'name': 'dart_analyze', +\ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')}, +\ 'command': '%e analyze --fatal-infos %s', +\ 'callback': 'ale_linters#dart#dart_analyze#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim b/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim deleted file mode 100644 index 0a4d9742..00000000 --- a/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim +++ /dev/null @@ -1,36 +0,0 @@ -" Author: w0rp -" Description: Check Dart files with dartanalyzer - -call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer') - -function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort - let l:path = ale#path#FindNearestFile(a:buffer, '.packages') - - return '%e' - \ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '') - \ . ' %s' -endfunction - -function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort - let l:pattern = '\v^ ([a-z]+) . (.+) at (.+):(\d+):(\d+) . (.+)$' - let l:output = [] - - for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'type': l:match[1] is# 'error' ? 'E' : 'W', - \ 'text': l:match[6] . ': ' . l:match[2], - \ 'lnum': str2nr(l:match[4]), - \ 'col': str2nr(l:match[5]), - \}) - endfor - - return l:output -endfunction - -call ale#linter#Define('dart', { -\ 'name': 'dartanalyzer', -\ 'executable': {b -> ale#Var(b, 'dart_dartanalyzer_executable')}, -\ 'command': function('ale_linters#dart#dartanalyzer#GetCommand'), -\ 'callback': 'ale_linters#dart#dartanalyzer#Handle', -\ 'lint_file': 1, -\}) diff --git a/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim b/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim new file mode 100644 index 00000000..5a97d315 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim @@ -0,0 +1,31 @@ +call ale#Set('desktop_desktop_file_validate_options', '') + +" Example matches for pattern: +" +" foo.desktop: warning: key "TerminalOptions" in group ... +" foo.desktop: error: action "new-private-window" is defined, ... +let s:pattern = '\v^(.+): ([a-z]+): (.+)$' + +function! ale_linters#desktop#desktop_file_validate#Handle(buffer, lines) abort + " The error format doesn't specify lines, so we can just put all of the + " errors on line 1. + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'lnum': 1, + \ 'col': 1, + \ 'type': match[2] is? 'error' ? 'E' : 'W', + \ 'text': match[3], + \}}) +endfunction + +call ale#linter#Define('desktop', { +\ 'name': 'desktop_file_validate', +\ 'aliases': ['desktop-file-validate'], +\ 'executable': 'desktop-file-validate', +\ 'command': {b -> +\ '%e' +\ . ale#Pad(ale#Var(b, 'desktop_desktop_file_validate_options')) +\ . ' %t' +\ }, +\ 'callback': 'ale_linters#desktop#desktop_file_validate#Handle', +\ 'output_stream': 'both', +\}) diff --git a/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim b/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim index 95768b12..0c0ad533 100644 --- a/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim +++ b/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim @@ -32,14 +32,29 @@ function! ale_linters#dockerfile#dockerfile_lint#Handle(buffer, lines) abort let l:line = get(l:object, 'line', -1) let l:message = l:object['message'] - if get(l:object, 'description', 'None') isnot# 'None' - let l:message = l:message . '. ' . l:object['description'] + let l:link = get(l:object, 'reference_url', '') + + if type(l:link) == v:t_list + " Somehow, reference_url is returned as two-part list. + " Anchor markers in that list are sometimes duplicated. + " See https://github.com/projectatomic/dockerfile_lint/issues/134 + let l:link = join(l:link, '') + let l:link = substitute(l:link, '##', '#', '') endif + let l:detail = l:message + + if get(l:object, 'description', 'None') isnot# 'None' + let l:detail .= "\n\n" . l:object['description'] + endif + + let l:detail .= "\n\n" . l:link + call add(l:messages, { \ 'lnum': l:line, \ 'text': l:message, \ 'type': ale_linters#dockerfile#dockerfile_lint#GetType(l:type), + \ 'detail': l:detail, \}) endfor endfor diff --git a/sources_non_forked/ale/ale_linters/dockerfile/dockerlinter.vim b/sources_non_forked/ale/ale_linters/dockerfile/dockerlinter.vim new file mode 100644 index 00000000..6b35438f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dockerfile/dockerlinter.vim @@ -0,0 +1,69 @@ +" Author: Shad +" Description: dockerlinter linter for dockerfile + +call ale#Set('dockerfile_dockerlinter_executable', 'dockerlinter') +call ale#Set('dockerfile_dockerlinter_options', '') + +function! ale_linters#dockerfile#dockerlinter#GetType(type) abort + if a:type is? 'error' + return 'E' + elseif a:type is? 'warning' + return 'W' + endif + + return 'I' +endfunction + +function! ale_linters#dockerfile#dockerlinter#Handle(buffer, lines) abort + try + let l:data = json_decode(join(a:lines, '')) + catch + return [] + endtry + + if empty(l:data) + " Should never happen, but it's better to be on the safe side + return [] + endif + + let l:messages = [] + + for l:object in l:data + let l:line = get(l:object, 'lineNumber', -1) + let l:message = l:object['message'] + let l:type = l:object['level'] + let l:detail = l:message + let l:code = l:object['code'] + + if l:code =~# '^SC' + let l:link = 'https://www.shellcheck.net/wiki/' . l:code + else + let l:link = 'https://github.com/buddy-works/dockerfile-linter/blob/master/Rules.md#' . l:code + endif + + let l:detail = l:message . "\n\n" . l:link + + call add(l:messages, { + \ 'lnum': l:line, + \ 'code': l:code, + \ 'text': l:message, + \ 'type': ale_linters#dockerfile#dockerlinter#GetType(l:type), + \ 'detail': l:detail, + \}) + endfor + + return l:messages +endfunction + +function! ale_linters#dockerfile#dockerlinter#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'dockerfile_dockerlinter_options')) + \ . ' -j -f' + \ . ' %t' +endfunction + +call ale#linter#Define('dockerfile', { +\ 'name': 'dockerlinter', +\ 'executable': {b -> ale#Var(b, 'dockerfile_dockerlinter_executable')}, +\ 'command': function('ale_linters#dockerfile#dockerlinter#GetCommand'), +\ 'callback': 'ale_linters#dockerfile#dockerlinter#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim b/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim index e57cd76d..9a6a6258 100644 --- a/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim +++ b/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim @@ -3,13 +3,14 @@ " always, yes, never call ale#Set('dockerfile_hadolint_use_docker', 'never') call ale#Set('dockerfile_hadolint_docker_image', 'hadolint/hadolint') +call ale#Set('dockerfile_hadolint_options', '') function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort " Matches patterns line the following: " - " /dev/stdin:19 DL3001 Pipe chain should start with a raw value. + " -:19 DL3001 warning: Pipe chain should start with a raw value. " /dev/stdin:19:3 unexpected thing - let l:pattern = '\v^/dev/stdin:(\d+):?(\d+)? ((DL|SC)(\d+) )?(.+)$' + let l:pattern = '\v^%(/dev/stdin|-):(\d+):?(\d+)? ((DL|SC)(\d+) )?((.+)?: )?(.+)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -24,10 +25,22 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort let l:colnum = l:match[2] + 0 endif - let l:type = 'W' - let l:text = l:match[6] - let l:detail = l:match[6] + " Shellcheck knows a 'style' severity - pin it to info level as well. + if l:match[7] is# 'style' + let l:type = 'I' + elseif l:match[7] is# 'info' + let l:type = 'I' + elseif l:match[7] is# 'warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + let l:text = l:match[8] + let l:detail = l:match[8] let l:domain = 'https://github.com/hadolint/hadolint/wiki/' + let l:code = '' + let l:link = '' if l:match[4] is# 'SC' let l:domain = 'https://github.com/koalaman/shellcheck/wiki/' @@ -36,18 +49,26 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort if l:match[5] isnot# '' let l:code = l:match[4] . l:match[5] let l:link = ' ( ' . l:domain . l:code . ' )' + let l:text = l:code . ': ' . l:detail let l:detail = l:code . l:link . "\n\n" . l:detail else let l:type = 'E' + let l:detail = 'hadolint could not parse the file because of a syntax error.' endif - call add(l:output, { + let l:line_output = { \ 'lnum': l:lnum, \ 'col': l:colnum, \ 'type': l:type, \ 'text': l:text, \ 'detail': l:detail - \}) + \} + + if l:code isnot# '' + let l:line_output['code'] = l:code + endif + + call add(l:output, l:line_output) endfor return l:output @@ -82,12 +103,15 @@ endfunction function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer) + let l:opts = ale#Var(a:buffer, 'dockerfile_hadolint_options') . ' --no-color -' if l:command is# 'docker' - return 'docker run --rm -i ' . ale#Var(a:buffer, 'dockerfile_hadolint_docker_image') + return printf('docker run --rm -i %s hadolint %s', + \ ale#Var(a:buffer, 'dockerfile_hadolint_docker_image'), + \ l:opts) endif - return 'hadolint -' + return 'hadolint ' . l:opts endfunction diff --git a/sources_non_forked/ale/ale_linters/elixir/credo.vim b/sources_non_forked/ale/ale_linters/elixir/credo.vim index 317ecab3..d6a861f4 100644 --- a/sources_non_forked/ale/ale_linters/elixir/credo.vim +++ b/sources_non_forked/ale/ale_linters/elixir/credo.vim @@ -45,19 +45,27 @@ function! ale_linters#elixir#credo#GetMode() abort endif endfunction -function! ale_linters#elixir#credo#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) - let l:mode = ale_linters#elixir#credo#GetMode() +function! ale_linters#elixir#credo#GetConfigFile() abort + let l:config_file = get(g:, 'ale_elixir_credo_config_file', '') - return ale#path#CdString(l:project_root) - \ . 'mix help credo && ' + if empty(l:config_file) + return '' + endif + + return ' --config-file ' . l:config_file +endfunction + +function! ale_linters#elixir#credo#GetCommand(buffer) abort + return 'mix help credo && ' \ . 'mix credo ' . ale_linters#elixir#credo#GetMode() + \ . ale_linters#elixir#credo#GetConfigFile() \ . ' --format=flycheck --read-from-stdin %s' endfunction call ale#linter#Define('elixir', { \ 'name': 'credo', \ 'executable': 'mix', +\ 'cwd': function('ale#handlers#elixir#FindMixUmbrellaRoot'), \ 'command': function('ale_linters#elixir#credo#GetCommand'), \ 'callback': 'ale_linters#elixir#credo#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/cspell.vim b/sources_non_forked/ale/ale_linters/elixir/cspell.vim new file mode 100644 index 00000000..12dc271f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elixir/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Elixir files. + +call ale#handlers#cspell#DefineLinter('elixir') diff --git a/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim b/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim index c7da7757..9b8a5cda 100644 --- a/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim +++ b/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim @@ -25,17 +25,10 @@ function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#elixir#dialyxir#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) - - return ale#path#CdString(l:project_root) - \ . ' mix help dialyzer && mix dialyzer' -endfunction - call ale#linter#Define('elixir', { \ 'name': 'dialyxir', \ 'executable': 'mix', -\ 'command': function('ale_linters#elixir#dialyxir#GetCommand'), +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), +\ 'command': 'mix help dialyzer && mix dialyzer', \ 'callback': 'ale_linters#elixir#dialyxir#Handle', \}) - diff --git a/sources_non_forked/ale/ale_linters/elixir/dogma.vim b/sources_non_forked/ale/ale_linters/elixir/dogma.vim index 1c721158..28e7f420 100644 --- a/sources_non_forked/ale/ale_linters/elixir/dogma.vim +++ b/sources_non_forked/ale/ale_linters/elixir/dogma.vim @@ -29,17 +29,11 @@ function! ale_linters#elixir#dogma#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#elixir#dogma#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) - - return ale#path#CdString(l:project_root) - \ . ' mix help dogma && mix dogma %s --format=flycheck' -endfunction - call ale#linter#Define('elixir', { \ 'name': 'dogma', \ 'executable': 'mix', -\ 'command': function('ale_linters#elixir#dogma#GetCommand'), +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), +\ 'command': 'mix help dogma && mix dogma %s --format=flycheck', \ 'lint_file': 1, \ 'callback': 'ale_linters#elixir#dogma#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim b/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim index d5517de5..c7dda600 100644 --- a/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim +++ b/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim @@ -1,5 +1,5 @@ " Author: Jon Parise -" Description: ElixirLS integration (https://github.com/JakeBecker/elixir-ls) +" Description: ElixirLS integration (https://github.com/elixir-lsp/elixir-ls) call ale#Set('elixir_elixir_ls_release', 'elixir-ls') call ale#Set('elixir_elixir_ls_config', {}) @@ -12,7 +12,8 @@ function! ale_linters#elixir#elixir_ls#GetExecutable(buffer) abort endfunction call ale#linter#Define('elixir', { -\ 'name': 'elixir-ls', +\ 'name': 'elixir_ls', +\ 'aliases': ['elixir-ls', 'elixirls'], \ 'lsp': 'stdio', \ 'executable': function('ale_linters#elixir#elixir_ls#GetExecutable'), \ 'command': function('ale_linters#elixir#elixir_ls#GetExecutable'), diff --git a/sources_non_forked/ale/ale_linters/elixir/lexical.vim b/sources_non_forked/ale/ale_linters/elixir/lexical.vim new file mode 100644 index 00000000..ea13142e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elixir/lexical.vim @@ -0,0 +1,19 @@ +" Author: Axel Clark +" Description: Lexical integration (https://github.com/lexical-lsp/lexical) + +call ale#Set('elixir_lexical_release', 'lexical') + +function! ale_linters#elixir#lexical#GetExecutable(buffer) abort + let l:dir = ale#path#Simplify(ale#Var(a:buffer, 'elixir_lexical_release')) + let l:cmd = has('win32') ? '\start_lexical.bat' : '/start_lexical.sh' + + return l:dir . l:cmd +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'lexical', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#elixir#lexical#GetExecutable'), +\ 'command': function('ale_linters#elixir#lexical#GetExecutable'), +\ 'project_root': function('ale#handlers#elixir#FindMixUmbrellaRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/elixir/mix.vim b/sources_non_forked/ale/ale_linters/elixir/mix.vim index abf5d0aa..948c6d36 100644 --- a/sources_non_forked/ale/ale_linters/elixir/mix.vim +++ b/sources_non_forked/ale/ale_linters/elixir/mix.vim @@ -30,22 +30,15 @@ function! ale_linters#elixir#mix#Handle(buffer, lines) abort endfunction function! ale_linters#elixir#mix#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) - let l:temp_dir = ale#command#CreateDirectory(a:buffer) - let l:mix_build_path = has('win32') - \ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' &&' - \ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) - - return ale#path#CdString(l:project_root) - \ . l:mix_build_path - \ . ' mix compile %s' + return ale#Env('MIX_BUILD_PATH', l:temp_dir) . 'mix compile %s' endfunction call ale#linter#Define('elixir', { \ 'name': 'mix', \ 'executable': 'mix', +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), \ 'command': function('ale_linters#elixir#mix#GetCommand'), \ 'callback': 'ale_linters#elixir#mix#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/elm/elm_ls.vim b/sources_non_forked/ale/ale_linters/elm/ls.vim similarity index 54% rename from sources_non_forked/ale/ale_linters/elm/elm_ls.vim rename to sources_non_forked/ale/ale_linters/elm/ls.vim index 374ef8de..111f3ac2 100644 --- a/sources_non_forked/ale/ale_linters/elm/elm_ls.vim +++ b/sources_non_forked/ale/ale_linters/elm/ls.vim @@ -3,35 +3,39 @@ call ale#Set('elm_ls_executable', 'elm-language-server') call ale#Set('elm_ls_use_global', get(g:, 'ale_use_global_executables', 1)) -call ale#Set('elm_ls_elm_path', 'elm') -call ale#Set('elm_ls_elm_format_path', 'elm-format') -call ale#Set('elm_ls_elm_test_path', 'elm-test') -function! elm_ls#GetRootDir(buffer) abort +" elm-language-server will search for local and global binaries, if empty +call ale#Set('elm_ls_elm_path', '') +call ale#Set('elm_ls_elm_format_path', '') +call ale#Set('elm_ls_elm_test_path', '') +call ale#Set('elm_ls_elm_analyse_trigger', 'change') + +function! ale_linters#elm#ls#GetProjectRoot(buffer) abort let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : '' endfunction -function! elm_ls#GetOptions(buffer) abort +function! ale_linters#elm#ls#GetInitializationOptions(buffer) abort return { - \ 'runtime': 'node', \ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'), \ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'), \ 'elmTestPath': ale#Var(a:buffer, 'elm_ls_elm_test_path'), + \ 'elmAnalyseTrigger': ale#Var(a:buffer, 'elm_ls_elm_analyse_trigger'), \} endfunction call ale#linter#Define('elm', { -\ 'name': 'elm_ls', +\ 'name': 'ls', +\ 'aliases': ['elm_ls'], \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_ls', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'elm_ls', [ \ 'node_modules/.bin/elm-language-server', \ 'node_modules/.bin/elm-lsp', \ 'elm-lsp' \ ])}, \ 'command': '%e --stdio', -\ 'project_root': function('elm_ls#GetRootDir'), +\ '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/elm/make.vim b/sources_non_forked/ale/ale_linters/elm/make.vim index 6b93257f..a7f9ea7b 100644 --- a/sources_non_forked/ale/ale_linters/elm/make.vim +++ b/sources_non_forked/ale/ale_linters/elm/make.vim @@ -186,24 +186,23 @@ function! ale_linters#elm#make#IsTest(buffer) abort endif endfunction +function! ale_linters#elm#make#GetCwd(buffer) abort + let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) + + return !empty(l:root_dir) ? l:root_dir : '' +endfunction + " Return the command to execute the linter in the projects directory. " If it doesn't, then this will fail when imports are needed. function! ale_linters#elm#make#GetCommand(buffer) abort let l:executable = ale_linters#elm#make#GetExecutable(a:buffer) - let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer) let l:is_using_elm_test = l:executable =~# 'elm-test$' - if empty(l:root_dir) - let l:dir_set_cmd = '' - else - let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && ' - endif - " elm-test needs to know the path of elm-make if elm isn't installed globally. " https://github.com/rtfeldman/node-test-runner/blob/57728f10668f2d2ab3179e7e3208bcfa9a1f19aa/README.md#--compiler if l:is_v19 && l:is_using_elm_test - let l:elm_make_executable = ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) + let l:elm_make_executable = ale#path#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) let l:elm_test_compiler_flag = ' --compiler ' . l:elm_make_executable . ' ' else let l:elm_test_compiler_flag = ' ' @@ -213,7 +212,9 @@ function! ale_linters#elm#make#GetCommand(buffer) abort " a sort of flag to tell the compiler not to generate an output file, " which is why this is hard coded here. " Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253 - return l:dir_set_cmd . '%e make --report=json --output=/dev/null' . l:elm_test_compiler_flag . '%t' + return '%e make --report=json --output=/dev/null' + \ . l:elm_test_compiler_flag + \ . '%t' endfunction function! ale_linters#elm#make#GetExecutable(buffer) abort @@ -221,13 +222,13 @@ function! ale_linters#elm#make#GetExecutable(buffer) abort let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer) if l:is_test && l:is_v19 - return ale#node#FindExecutable( + return ale#path#FindExecutable( \ a:buffer, \ 'elm_make', \ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] \) else - return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) + return ale#path#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) endif endfunction @@ -235,6 +236,7 @@ call ale#linter#Define('elm', { \ 'name': 'make', \ 'executable': function('ale_linters#elm#make#GetExecutable'), \ 'output_stream': 'both', +\ 'cwd': function('ale_linters#elm#make#GetCwd'), \ 'command': function('ale_linters#elm#make#GetCommand'), \ 'callback': 'ale_linters#elm#make#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim b/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim index 7af64c4f..a97c9520 100644 --- a/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim +++ b/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim @@ -3,6 +3,11 @@ let g:ale_erlang_dialyzer_executable = \ get(g:, 'ale_erlang_dialyzer_executable', 'dialyzer') +let g:ale_erlang_dialyzer_options = +\ get(g:, 'ale_erlang_dialyzer_options', '-Wunmatched_returns' +\ . ' -Werror_handling' +\ . ' -Wrace_conditions' +\ . ' -Wunderspecs') let g:ale_erlang_dialyzer_plt_file = \ get(g:, 'ale_erlang_dialyzer_plt_file', '') let g:ale_erlang_dialyzer_rebar3_profile = @@ -15,10 +20,10 @@ endfunction function! ale_linters#erlang#dialyzer#FindPlt(buffer) abort let l:plt_file = '' let l:rebar3_profile = ale_linters#erlang#dialyzer#GetRebar3Profile(a:buffer) - let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build' . l:rebar3_profile) + let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build/' . l:rebar3_profile) if !empty(l:plt_file_directory) - let l:plt_file = split(globpath(l:plt_file_directory, '/*_plt'), '\n') + let l:plt_file = globpath(l:plt_file_directory, '*_plt', 0, 1) endif if !empty(l:plt_file) @@ -47,13 +52,12 @@ function! ale_linters#erlang#dialyzer#GetExecutable(buffer) abort endfunction function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'erlang_dialyzer_options') + let l:command = ale#Escape(ale_linters#erlang#dialyzer#GetExecutable(a:buffer)) \ . ' -n' \ . ' --plt ' . ale#Escape(ale_linters#erlang#dialyzer#GetPlt(a:buffer)) - \ . ' -Wunmatched_returns' - \ . ' -Werror_handling' - \ . ' -Wrace_conditions' - \ . ' -Wunderspecs' + \ . ' ' . l:options \ . ' %s' return l:command diff --git a/sources_non_forked/ale/ale_linters/erlang/elvis.vim b/sources_non_forked/ale/ale_linters/erlang/elvis.vim new file mode 100644 index 00000000..321a6c72 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/erlang/elvis.vim @@ -0,0 +1,59 @@ +" Author: Dmitri Vereshchagin +" Description: Elvis linter for Erlang files + +call ale#Set('erlang_elvis_executable', 'elvis') + +function! ale_linters#erlang#elvis#Handle(buffer, lines) abort + let l:pattern = '\v:(\d+):[^:]+:(.+)' + let l:loclist = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:loclist, { + \ 'lnum': str2nr(l:match[1]), + \ 'text': s:AbbreviateMessage(l:match[2]), + \ 'type': 'W', + \ 'sub_type': 'style', + \}) + endfor + + return l:loclist +endfunction + +function! s:AbbreviateMessage(text) abort + let l:pattern = '\v\c^(line \d+ is too long):.*$' + + return substitute(a:text, l:pattern, '\1.', '') +endfunction + +function! s:GetCommand(buffer) abort + let l:cwd = s:GetCwd(a:buffer) + + 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', { +\ 'name': 'elvis', +\ '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 new file mode 100644 index 00000000..15edd48e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/erlang/erlang_ls.vim @@ -0,0 +1,57 @@ +" Author: Dmitri Vereshchagin +" Description: LSP linter for Erlang files + +call ale#Set('erlang_erlang_ls_executable', 'erlang_ls') +call ale#Set('erlang_erlang_ls_log_dir', '') +call ale#Set('erlang_erlang_ls_log_level', 'info') + +function! s:GetCommand(buffer) abort + let l:log_dir = ale#Var(a:buffer, 'erlang_erlang_ls_log_dir') + let l:log_level = ale#Var(a:buffer, 'erlang_erlang_ls_log_level') + + let l:command = '%e' + + if !empty(l:log_dir) + let l:command .= ' --log-dir=' . ale#Escape(l:log_dir) + endif + + let l:command .= ' --log-level=' . ale#Escape(l:log_level) + + return l:command +endfunction + +function! s:FindProjectRoot(buffer) abort + 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. + let l:markers += ['.kerl_config'] + + for l:marker in l:markers + let l:path = l:marker[-1:] is# '/' + \ ? ale#path#FindNearestDirectory(a:buffer, l:marker) + \ : ale#path#FindNearestFile(a:buffer, l:marker) + + if !empty(l:path) + return ale#path#Dirname(l:path) + endif + endfor + + return '' +endfunction + +call ale#linter#Define('erlang', { +\ 'name': 'erlang_ls', +\ 'executable': {b -> ale#Var(b, 'erlang_erlang_ls_executable')}, +\ 'command': function('s:GetCommand'), +\ 'lsp': 'stdio', +\ 'project_root': function('s:FindProjectRoot'), +\ 'aliases': ['erlang-ls'], +\}) diff --git a/sources_non_forked/ale/ale_linters/erlang/erlc.vim b/sources_non_forked/ale/ale_linters/erlang/erlc.vim index a83bacc3..0c67a73f 100644 --- a/sources_non_forked/ale/ale_linters/erlang/erlc.vim +++ b/sources_non_forked/ale/ale_linters/erlang/erlc.vim @@ -1,14 +1,22 @@ " Author: Magnus Ottenklinger - https://github.com/evnu +let g:ale_erlang_erlc_executable = get(g:, 'ale_erlang_erlc_executable', 'erlc') let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '') +function! ale_linters#erlang#erlc#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'erlang_erlc_executable') +endfunction + function! ale_linters#erlang#erlc#GetCommand(buffer) abort let l:output_file = ale#util#Tempname() call ale#command#ManageFile(a:buffer, l:output_file) - return 'erlc -o ' . ale#Escape(l:output_file) - \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options') - \ . ' %t' + let l:command = ale#Escape(ale_linters#erlang#erlc#GetExecutable(a:buffer)) + \ . ' -o ' . ale#Escape(l:output_file) + \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options') + \ . ' %t' + + return l:command endfunction function! ale_linters#erlang#erlc#Handle(buffer, lines) abort @@ -17,7 +25,7 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort " error.erl:4: variable 'B' is unbound " error.erl:3: Warning: function main/0 is unused " error.erl:4: Warning: variable 'A' is unused - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (Warning: )?(.+)$' + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+:)? (Warning: )?(.+)$' " parse_transforms are a special case. The error message does not indicate a location: " error.erl: undefined parse transform 'some_parse_transform' @@ -57,8 +65,8 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort endif let l:line = l:match[2] - let l:warning_or_text = l:match[3] - let l:text = l:match[4] + let l:warning_or_text = l:match[4] + let l:text = l:match[5] " If this file is a header .hrl, ignore the following expected messages: " - 'no module definition' @@ -90,7 +98,7 @@ endfunction call ale#linter#Define('erlang', { \ 'name': 'erlc', -\ 'executable': 'erlc', +\ 'executable': function('ale_linters#erlang#erlc#GetExecutable'), \ 'command': function('ale_linters#erlang#erlc#GetCommand'), \ 'callback': 'ale_linters#erlang#erlc#Handle', \}) 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/eruby/erb.vim b/sources_non_forked/ale/ale_linters/eruby/erb.vim index f3438320..0ca157aa 100644 --- a/sources_non_forked/ale/ale_linters/eruby/erb.vim +++ b/sources_non_forked/ale/ale_linters/eruby/erb.vim @@ -11,7 +11,7 @@ function! ale_linters#eruby#erb#GetCommand(buffer) abort " Rails-flavored eRuby does not comply with the standard as understood by " ERB, so we'll have to do some substitution. This does not reduce the " effectiveness of the linter—the translated code is still evaluated. - return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c' + return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), trim_mode: %{-}).src') . '< %t | ruby -c' endfunction call ale#linter#Define('eruby', { diff --git a/sources_non_forked/ale/ale_linters/eruby/erblint.vim b/sources_non_forked/ale/ale_linters/eruby/erblint.vim new file mode 100644 index 00000000..19960185 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/eruby/erblint.vim @@ -0,0 +1,51 @@ +" Author: Roeland Moors - https://github.com/roelandmoors +" based on the ale ruumba and robocop linters +" Description: ERB Lint, support for https://github.com/Shopify/erb-lint + +call ale#Set('eruby_erblint_executable', 'erblint') +call ale#Set('eruby_erblint_options', '') + +function! ale_linters#eruby#erblint#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'erblint') + \ . ' --format json ' + \ . ale#Var(a:buffer, 'eruby_erblint_options') + \ . ' --stdin %s' +endfunction + +function! ale_linters#eruby#erblint#Handle(buffer, lines) abort + if empty(a:lines) + return [] + endif + + let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], []) + + if !has_key(l:errors, 'summary') + \|| l:errors['summary']['offenses'] == 0 + \|| empty(l:errors['files']) + return [] + endif + + let l:output = [] + + for l:error in l:errors['files'][0]['offenses'] + call add(l:output, { + \ 'lnum': l:error['location']['start_line'] + 0, + \ 'col': l:error['location']['start_column'] + 0, + \ 'end_col': l:error['location']['last_column'] + 0, + \ 'code': l:error['linter'], + \ 'text': l:error['message'], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('eruby', { +\ 'name': 'erblint', +\ 'executable': {b -> ale#Var(b, 'eruby_erblint_executable')}, +\ 'command': function('ale_linters#eruby#erblint#GetCommand'), +\ 'callback': 'ale_linters#eruby#erblint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim index e68bb51d..f415f1ab 100644 --- a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim +++ b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim @@ -8,10 +8,10 @@ call ale#Set('eruby_ruumba_options', '') function! ale_linters#eruby#ruumba#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'eruby_ruumba_executable') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'ruumba') + return ale#ruby#EscapeExecutable(l:executable, 'ruumba') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'eruby_ruumba_options') - \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) + \ . ' --stdin %s' endfunction function! ale_linters#eruby#ruumba#Handle(buffer, lines) abort diff --git a/sources_non_forked/ale/ale_linters/fortran/language_server.vim b/sources_non_forked/ale/ale_linters/fortran/language_server.vim index 00aa0577..c885b699 100644 --- a/sources_non_forked/ale/ale_linters/fortran/language_server.vim +++ b/sources_non_forked/ale/ale_linters/fortran/language_server.vim @@ -12,6 +12,7 @@ endfunction call ale#linter#Define('fortran', { \ 'name': 'language_server', +\ 'aliases': ['fortls'], \ 'lsp': 'stdio', \ 'executable': {b -> ale#Var(b, 'fortran_language_server_executable')}, \ 'command': '%e', diff --git a/sources_non_forked/ale/ale_linters/gleam/gleamlsp.vim b/sources_non_forked/ale/ale_linters/gleam/gleamlsp.vim new file mode 100644 index 00000000..f32d1434 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/gleam/gleamlsp.vim @@ -0,0 +1,18 @@ +" Author: Jonathan Palardt https://github.com/jpalardy +" Description: Support for Gleam Language Server + +call ale#Set('gleam_gleamlsp_executable', 'gleam') + +function! ale_linters#gleam#gleamlsp#GetProjectRoot(buffer) abort + let l:gleam_toml = ale#path#FindNearestFile(a:buffer, 'gleam.toml') + + return !empty(l:gleam_toml) ? fnamemodify(l:gleam_toml, ':p:h') : '' +endfunction + +call ale#linter#Define('gleam', { +\ 'name': 'gleamlsp', +\ 'lsp': 'stdio', +\ 'executable': {buffer -> ale#Var(buffer, 'gleam_gleamlsp_executable')}, +\ 'command': '%e lsp', +\ 'project_root': function('ale_linters#gleam#gleamlsp#GetProjectRoot'), +\}) 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 +" 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/glsl/glslang.vim b/sources_non_forked/ale/ale_linters/glsl/glslang.vim index bbddce90..54fc0caa 100644 --- a/sources_non_forked/ale/ale_linters/glsl/glslang.vim +++ b/sources_non_forked/ale/ale_linters/glsl/glslang.vim @@ -17,13 +17,15 @@ function! ale_linters#glsl#glslang#Handle(buffer, lines) abort " Matches patterns like the following: " " ERROR: 0:5: 'foo' : undeclared identifier - let l:pattern = '^\(.\+\): \(\d\+\):\(\d\+\): \(.\+\)' + " or when using options like -V or -G or --target-env + " ERROR: filename:5: 'foo' : undeclared identifier + let l:pattern = '^\(.\+\): \(.\+\):\(\d\+\): \(.\+\)' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { \ 'lnum': str2nr(l:match[3]), - \ 'col': str2nr(l:match[2]), + \ 'col' : 0, \ 'text': l:match[4], \ 'type': l:match[1] is# 'ERROR' ? 'E' : 'W', \}) diff --git a/sources_non_forked/ale/ale_linters/go/cspell.vim b/sources_non_forked/ale/ale_linters/go/cspell.vim new file mode 100644 index 00000000..f986a31a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Go files. + +call ale#handlers#cspell#DefineLinter('go') diff --git a/sources_non_forked/ale/ale_linters/go/gobuild.vim b/sources_non_forked/ale/ale_linters/go/gobuild.vim index 1dfb6daa..0342a230 100644 --- a/sources_non_forked/ale/ale_linters/go/gobuild.vim +++ b/sources_non_forked/ale/ale_linters/go/gobuild.vim @@ -6,17 +6,6 @@ call ale#Set('go_go_executable', 'go') call ale#Set('go_gobuild_options', '') -function! ale_linters#go#gobuild#GetCommand(buffer) abort - let l:options = ale#Var(a:buffer, 'go_gobuild_options') - - " Run go test in local directory with relative path - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) - \ . ale#Var(a:buffer, 'go_go_executable') . ' test' - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' -c -o /dev/null ./' -endfunction - function! ale_linters#go#gobuild#GetMatches(lines) abort " Matches patterns like the following: " @@ -50,7 +39,13 @@ call ale#linter#Define('go', { \ 'name': 'gobuild', \ 'aliases': ['go build'], \ 'executable': {b -> ale#Var(b, 'go_go_executable')}, -\ 'command': function('ale_linters#go#gobuild#GetCommand'), +\ 'cwd': '%s:h', +\ 'command': {b -> +\ ale#go#EnvString(b) +\ . ale#Escape(ale#Var(b, 'go_go_executable')) . ' test' +\ . ale#Pad(ale#Var(b, 'go_gobuild_options')) +\ . ' -c -o /dev/null ./' +\ }, \ 'output_stream': 'stderr', \ 'callback': 'ale_linters#go#gobuild#Handler', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/gofmt.vim b/sources_non_forked/ale/ale_linters/go/gofmt.vim index a233b422..b313f9ca 100644 --- a/sources_non_forked/ale/ale_linters/go/gofmt.vim +++ b/sources_non_forked/ale/ale_linters/go/gofmt.vim @@ -6,7 +6,6 @@ function! ale_linters#go#gofmt#GetCommand(buffer) abort \ . '%e -e %t' endfunction - call ale#linter#Define('go', { \ 'name': 'gofmt', \ 'output_stream': 'stderr', 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 dd0e975a..faa8068b 100644 --- a/sources_non_forked/ale/ale_linters/go/golangci_lint.vim +++ b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim @@ -1,9 +1,9 @@ " Author: Sascha Grunert " Description: Adds support of golangci-lint -call ale#Set('go_golangci_lint_options', '--enable-all') +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') @@ -12,38 +12,44 @@ function! ale_linters#go#golangci_lint#GetCommand(buffer) abort if l:lint_package - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) + return ale#go#EnvString(a:buffer) \ . '%e run ' \ . l:options + \ . ' --out-format=json' + \ . ' --show-stats=0' endif - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) + return ale#go#EnvString(a:buffer) \ . '%e run ' \ . ale#Escape(l:filename) \ . ' ' . l:options -endfunction - -function! ale_linters#go#golangci_lint#GetMatches(lines) abort - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?:?\s\*?(.+)$' - - return ale#util#GetMatches(a:lines, l:pattern) + \ . ' --out-format=json' + \ . ' --show-stats=0' endfunction function! ale_linters#go#golangci_lint#Handler(buffer, lines) abort let l:dir = expand('#' . a:buffer . ':p:h') let l:output = [] - for l:match in ale_linters#go#golangci_lint#GetMatches(a:lines) - " l:match[1] will already be an absolute path, output from - " golangci_lint + let l:matches = ale#util#FuzzyJSONDecode(a:lines, []) + + if empty(l:matches) + return [] + endif + + for l:match in l:matches['Issues'] + if l:match['FromLinter'] is# 'typecheck' + let l:msg_type = 'E' + else + let l:msg_type = 'W' + endif + call add(l:output, { - \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), - \ 'lnum': l:match[2] + 0, - \ 'col': l:match[3] + 0, - \ 'type': 'E', - \ 'text': l:match[4], + \ 'filename': ale#path#GetAbsPath(l:dir, fnamemodify(l:match['Pos']['Filename'], ':t')), + \ 'lnum': l:match['Pos']['Line'] + 0, + \ 'col': l:match['Pos']['Column'] + 0, + \ 'type': l:msg_type, + \ 'text': match['FromLinter'] . ' - ' . l:match['Text'], \}) endfor @@ -53,6 +59,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'golangci-lint', \ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#golangci_lint#GetCommand'), \ 'callback': 'ale_linters#go#golangci_lint#Handler', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/golint.vim b/sources_non_forked/ale/ale_linters/go/golint.vim deleted file mode 100644 index 79bfaeb5..00000000 --- a/sources_non_forked/ale/ale_linters/go/golint.vim +++ /dev/null @@ -1,21 +0,0 @@ -" Author: neersighted -" Description: golint for Go files - -call ale#Set('go_golint_executable', 'golint') -call ale#Set('go_golint_options', '') - -function! ale_linters#go#golint#GetCommand(buffer) abort - let l:options = ale#Var(a:buffer, 'go_golint_options') - - return ale#go#EnvString(a:buffer) . '%e' - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' %t' -endfunction - -call ale#linter#Define('go', { -\ 'name': 'golint', -\ 'output_stream': 'both', -\ 'executable': {b -> ale#Var(b, 'go_golint_executable')}, -\ 'command': function('ale_linters#go#golint#GetCommand'), -\ 'callback': 'ale#handlers#unix#HandleAsWarning', -\}) diff --git a/sources_non_forked/ale/ale_linters/go/gometalinter.vim b/sources_non_forked/ale/ale_linters/go/gometalinter.vim deleted file mode 100644 index eed9550a..00000000 --- a/sources_non_forked/ale/ale_linters/go/gometalinter.vim +++ /dev/null @@ -1,59 +0,0 @@ -" Author: Ben Reedy , Jeff Willette -" Description: Adds support for the gometalinter suite for Go files - -call ale#Set('go_gometalinter_options', '') -call ale#Set('go_gometalinter_executable', 'gometalinter') -call ale#Set('go_gometalinter_lint_package', 0) - -function! ale_linters#go#gometalinter#GetCommand(buffer) abort - let l:filename = expand('#' . a:buffer . ':t') - let l:options = ale#Var(a:buffer, 'go_gometalinter_options') - let l:lint_package = ale#Var(a:buffer, 'go_gometalinter_lint_package') - - " BufferCdString is used so that we can be sure the paths output from gometalinter can - " be calculated to absolute paths in the Handler - if l:lint_package - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) - \ . '%e' - \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' - endif - - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) - \ . '%e' - \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename)) - \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' -endfunction - -function! ale_linters#go#gometalinter#GetMatches(lines) abort - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?(warning|error):?\s\*?(.+)$' - - return ale#util#GetMatches(a:lines, l:pattern) -endfunction - -function! ale_linters#go#gometalinter#Handler(buffer, lines) abort - let l:dir = expand('#' . a:buffer . ':p:h') - let l:output = [] - - for l:match in ale_linters#go#gometalinter#GetMatches(a:lines) - " l:match[1] will already be an absolute path, output from gometalinter - call add(l:output, { - \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), - \ 'lnum': l:match[2] + 0, - \ 'col': l:match[3] + 0, - \ 'type': tolower(l:match[4]) is# 'warning' ? 'W' : 'E', - \ 'text': l:match[5], - \}) - endfor - - return l:output -endfunction - -call ale#linter#Define('go', { -\ 'name': 'gometalinter', -\ 'executable': {b -> ale#Var(b, 'go_gometalinter_executable')}, -\ 'command': function('ale_linters#go#gometalinter#GetCommand'), -\ 'callback': 'ale_linters#go#gometalinter#Handler', -\ 'lint_file': 1, -\}) diff --git a/sources_non_forked/ale/ale_linters/go/gopls.vim b/sources_non_forked/ale/ale_linters/go/gopls.vim index dcff5ec7..80909830 100644 --- a/sources_non_forked/ale/ale_linters/go/gopls.vim +++ b/sources_non_forked/ale/ale_linters/go/gopls.vim @@ -4,6 +4,8 @@ call ale#Set('go_gopls_executable', 'gopls') call ale#Set('go_gopls_options', '--mode stdio') +call ale#Set('go_gopls_init_options', {}) +call ale#Set('go_gopls_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#go#gopls#GetCommand(buffer) abort return ale#go#EnvString(a:buffer) @@ -28,7 +30,10 @@ endfunction call ale#linter#Define('go', { \ 'name': 'gopls', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#Var(b, 'go_gopls_executable')}, +\ 'executable': {b -> ale#path#FindExecutable(b, 'go_gopls', [ +\ ale#go#GetGoPathExecutable('bin/gopls'), +\ ])}, \ 'command': function('ale_linters#go#gopls#GetCommand'), \ 'project_root': function('ale_linters#go#gopls#FindProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'go_gopls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/go/gosimple.vim b/sources_non_forked/ale/ale_linters/go/gosimple.vim index ad52c621..490d15a9 100644 --- a/sources_non_forked/ale/ale_linters/go/gosimple.vim +++ b/sources_non_forked/ale/ale_linters/go/gosimple.vim @@ -1,15 +1,11 @@ " Author: Ben Reedy " Description: gosimple for Go files -function! ale_linters#go#gosimple#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) . ' ' - \ . ale#go#EnvString(a:buffer) . 'gosimple .' -endfunction - call ale#linter#Define('go', { \ 'name': 'gosimple', \ 'executable': 'gosimple', -\ 'command': function('ale_linters#go#gosimple#GetCommand'), +\ 'cwd': '%s:h', +\ 'command': {b -> ale#go#EnvString(b) . 'gosimple .'}, \ 'callback': 'ale#handlers#go#Handler', \ 'output_stream': 'both', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/gotype.vim b/sources_non_forked/ale/ale_linters/go/gotype.vim index 6a5149ca..8fd6df27 100644 --- a/sources_non_forked/ale/ale_linters/go/gotype.vim +++ b/sources_non_forked/ale/ale_linters/go/gotype.vim @@ -1,19 +1,23 @@ " Author: Jelte Fennema " Description: gotype for Go files -function! ale_linters#go#gotype#GetCommand(buffer) abort +function! ale_linters#go#gotype#GetExecutable(buffer) abort if expand('#' . a:buffer . ':p') =~# '_test\.go$' return '' endif - return ale#path#BufferCdString(a:buffer) . ' ' - \ . ale#go#EnvString(a:buffer) . 'gotype -e .' + return 'gotype' +endfunction + +function! ale_linters#go#gotype#GetCommand(buffer) abort + return ale#go#EnvString(a:buffer) . 'gotype -e .' endfunction call ale#linter#Define('go', { \ 'name': 'gotype', \ 'output_stream': 'stderr', -\ 'executable': 'gotype', +\ 'executable': function('ale_linters#go#gotype#GetExecutable'), +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#gotype#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/govet.vim b/sources_non_forked/ale/ale_linters/go/govet.vim index dddafe17..414c8b11 100644 --- a/sources_non_forked/ale/ale_linters/go/govet.vim +++ b/sources_non_forked/ale/ale_linters/go/govet.vim @@ -1,28 +1,21 @@ -" Author: neersighted +" Author: neersighted , John Eikenberry " Description: go vet for Go files -" -" Author: John Eikenberry -" Description: updated to work with go1.10 call ale#Set('go_go_executable', 'go') call ale#Set('go_govet_options', '') -function! ale_linters#go#govet#GetCommand(buffer) abort - let l:options = ale#Var(a:buffer, 'go_govet_options') - - return ale#path#BufferCdString(a:buffer) . ' ' - \ . ale#go#EnvString(a:buffer) - \ . ale#Var(a:buffer, 'go_go_executable') . ' vet ' - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' .' -endfunction - call ale#linter#Define('go', { \ 'name': 'govet', \ 'aliases': ['go vet'], \ 'output_stream': 'stderr', \ 'executable': {b -> ale#Var(b, 'go_go_executable')}, -\ 'command': function('ale_linters#go#govet#GetCommand'), +\ 'cwd': '%s:h', +\ 'command': {b -> +\ ale#go#EnvString(b) +\ . '%e vet' +\ . ale#Pad(ale#Var(b, 'go_govet_options')) +\ . ' .' +\ }, \ 'callback': 'ale#handlers#go#Handler', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/go/revive.vim b/sources_non_forked/ale/ale_linters/go/revive.vim new file mode 100644 index 00000000..b14b5ab9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/revive.vim @@ -0,0 +1,21 @@ +" Author: Penghui Liao +" Description: Adds support for revive + +call ale#Set('go_revive_executable', 'revive') +call ale#Set('go_revive_options', '') + +function! ale_linters#go#revive#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_revive_options') + + return ale#go#EnvString(a:buffer) . '%e' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'revive', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'go_revive_executable')}, +\ 'command': function('ale_linters#go#revive#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/go/staticcheck.vim b/sources_non_forked/ale/ale_linters/go/staticcheck.vim index ed40c6c2..36622440 100644 --- a/sources_non_forked/ale/ale_linters/go/staticcheck.vim +++ b/sources_non_forked/ale/ale_linters/go/staticcheck.vim @@ -1,32 +1,32 @@ " Author: Ben Reedy " Description: staticcheck for Go files +call ale#Set('go_staticcheck_executable', 'staticcheck') call ale#Set('go_staticcheck_options', '') -call ale#Set('go_staticcheck_lint_package', 0) +call ale#Set('go_staticcheck_lint_package', 1) +call ale#Set('go_staticcheck_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#go#staticcheck#GetCommand(buffer) abort - let l:filename = expand('#' . a:buffer . ':t') let l:options = ale#Var(a:buffer, 'go_staticcheck_options') let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package') let l:env = ale#go#EnvString(a:buffer) - " BufferCdString is used so that we can be sure the paths output from - " staticcheck can be calculated to absolute paths in the Handler if l:lint_package - return ale#path#BufferCdString(a:buffer) - \ . l:env . 'staticcheck' + return l:env . '%e' \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' endif - return ale#path#BufferCdString(a:buffer) - \ . l:env . 'staticcheck' + return l:env . '%e' \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' ' . ale#Escape(l:filename) + \ . ' %s:t' endfunction call ale#linter#Define('go', { \ 'name': 'staticcheck', -\ 'executable': 'staticcheck', +\ 'executable': {b -> ale#path#FindExecutable(b, 'go_staticcheck', [ +\ ale#go#GetGoPathExecutable('bin/staticcheck'), +\ ])}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#staticcheck#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', \ 'output_stream': 'both', diff --git a/sources_non_forked/ale/ale_linters/gohtmltmpl/djlint.vim b/sources_non_forked/ale/ale_linters/gohtmltmpl/djlint.vim new file mode 100644 index 00000000..79f1f8f4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/gohtmltmpl/djlint.vim @@ -0,0 +1,12 @@ +" Author: Adrian Vollmer +" Description: djlint for Django HTML template files + +call ale#Set('html_djlint_executable', 'djlint') +call ale#Set('html_djlint_options', '') + +call ale#linter#Define('gohtmltmpl', { +\ 'name': 'djlint', +\ 'executable': function('ale#handlers#djlint#GetExecutable'), +\ 'command': function('ale#handlers#djlint#GetCommand'), +\ 'callback': 'ale#handlers#djlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/graphql/eslint.vim b/sources_non_forked/ale/ale_linters/graphql/eslint.vim index 654b8c17..a98233e9 100644 --- a/sources_non_forked/ale/ale_linters/graphql/eslint.vim +++ b/sources_non_forked/ale/ale_linters/graphql/eslint.vim @@ -4,6 +4,7 @@ call ale#linter#Define('graphql', { \ 'name': 'eslint', \ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), \ 'command': function('ale#handlers#eslint#GetCommand'), -\ 'callback': 'ale#handlers#eslint#Handle', +\ 'callback': 'ale#handlers#eslint#HandleJSON', \}) diff --git a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim index d5029de1..6f1ca54a 100644 --- a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim +++ b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim @@ -1,15 +1,10 @@ " Author: Michiel Westerbeek " Description: Linter for GraphQL Schemas -function! ale_linters#graphql#gqlint#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . 'gqlint' - \ . ' --reporter=simple %t' -endfunction - call ale#linter#Define('graphql', { \ 'name': 'gqlint', \ 'executable': 'gqlint', -\ 'command': function('ale_linters#graphql#gqlint#GetCommand'), +\ 'cwd': '%s:h', +\ 'command': 'gqlint --reporter=simple %t', \ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/sources_non_forked/ale/ale_linters/groovy/npmgroovylint.vim b/sources_non_forked/ale/ale_linters/groovy/npmgroovylint.vim new file mode 100644 index 00000000..4141bd25 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/groovy/npmgroovylint.vim @@ -0,0 +1,46 @@ +" Author: lucas-str +" Description: Integration of npm-groovy-lint for Groovy files. + +call ale#Set('groovy_npmgroovylint_executable', 'npm-groovy-lint') +call ale#Set('groovy_npmgroovylint_options', '--loglevel warning') + +function! ale_linters#groovy#npmgroovylint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'groovy_npmgroovylint_options') + + return '%e --failon none --output json' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +function! ale_linters#groovy#npmgroovylint#Handle(buffer, lines) abort + let l:output = [] + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) + + for [l:filename, l:file] in items(get(l:json, 'files', {})) + for l:error in get(l:file, 'errors', []) + let l:output_line = { + \ 'filename': l:filename, + \ 'lnum': l:error.line, + \ 'text': l:error.msg, + \ 'type': toupper(l:error.severity[0]), + \} + + if has_key(l:error, 'range') + let l:output_line.col = l:error.range.start.character + let l:output_line.end_col = l:error.range.end.character + let l:output_line.end_lnum = l:error.range.end.line + endif + + call add(l:output, l:output_line) + endfor + endfor + + return l:output +endfunction + +call ale#linter#Define('groovy', { +\ 'name': 'npm-groovy-lint', +\ 'executable': {b -> ale#Var(b, 'groovy_npmgroovylint_executable')}, +\ 'command': function('ale_linters#groovy#npmgroovylint#GetCommand'), +\ 'callback': 'ale_linters#groovy#npmgroovylint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/handlebars/djlint.vim b/sources_non_forked/ale/ale_linters/handlebars/djlint.vim new file mode 100644 index 00000000..b192901f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/handlebars/djlint.vim @@ -0,0 +1,12 @@ +" Author: Adrian Vollmer +" Description: djlint for Django HTML template files + +call ale#Set('html_djlint_executable', 'djlint') +call ale#Set('html_djlint_options', '') + +call ale#linter#Define('handlebars', { +\ 'name': 'djlint', +\ 'executable': function('ale#handlers#djlint#GetExecutable'), +\ 'command': function('ale#handlers#djlint#GetCommand'), +\ 'callback': 'ale#handlers#djlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim index 74bd6a99..62b5db03 100644 --- a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim +++ b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim @@ -1,39 +1,6 @@ " Author: Adrian Zalewski " 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#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': 'ember-template-lint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'handlebars_embertemplatelint', [ -\ 'node_modules/.bin/ember-template-lint', -\ ])}, -\ 'command': '%e --json %t', -\ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle', -\}) +call ale#handlers#embertemplatelint#DefineLinter('handlebars') diff --git a/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim b/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim index f3f248f5..1bb31ebb 100644 --- a/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim +++ b/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim @@ -4,8 +4,7 @@ call ale#Set('haskell_cabal_ghc_options', '-fno-code -v0') function! ale_linters#haskell#cabal_ghc#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . 'cabal exec -- ghc ' + return 'cabal exec -- ghc ' \ . ale#Var(a:buffer, 'haskell_cabal_ghc_options') \ . ' %t' endfunction @@ -15,6 +14,7 @@ call ale#linter#Define('haskell', { \ 'aliases': ['cabal-ghc'], \ 'output_stream': 'stderr', \ 'executable': 'cabal', +\ 'cwd': '%s:h', \ 'command': function('ale_linters#haskell#cabal_ghc#GetCommand'), \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/cspell.vim b/sources_non_forked/ale/ale_linters/haskell/cspell.vim new file mode 100644 index 00000000..b0971a9e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Haskell files. + +call ale#handlers#cspell#DefineLinter('haskell') diff --git a/sources_non_forked/ale/ale_linters/haskell/hls.vim b/sources_non_forked/ale/ale_linters/haskell/hls.vim new file mode 100644 index 00000000..7f7f42e1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/hls.vim @@ -0,0 +1,66 @@ +" Author: Yen3 +" Description: A language server for haskell +" The file is based on hie.vim (author: Luxed +" ). It search more project root files. +" +call ale#Set('haskell_hls_executable', 'haskell-language-server-wrapper') +call ale#Set('haskell_hls_config', {}) + +function! ale_linters#haskell#hls#FindRootFile(buffer) abort + let l:serach_root_files = [ + \ 'stack.yaml', + \ 'cabal.project', + \ 'package.yaml', + \ 'hie.yaml' + \ ] + + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:root_file in l:serach_root_files + if filereadable(l:path . '/' . l:root_file) + " Add on / so fnamemodify(..., ':h') below keeps the path. + return l:path . '/' + endif + endfor + endfor + + return '' +endfunction + +function! ale_linters#haskell#hls#GetProjectRoot(buffer) abort + " Search for the project file first + let l:project_file = ale_linters#haskell#hls#FindRootFile(a:buffer) + + " If it's empty, search for the cabal file + if empty(l:project_file) + " Search all of the paths except for the root filesystem path. + let l:paths = join( + \ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2], + \ ',' + \) + let l:project_file = globpath(l:paths, '*.cabal') + endif + + " If we still can't find one, use the current file. + if empty(l:project_file) + let l:project_file = expand('#' . a:buffer . ':p') + endif + + return fnamemodify(l:project_file, ':h') +endfunction + +function! ale_linters#haskell#hls#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hls_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, + \ 'haskell-language-server-wrapper') + \ . ' --lsp' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'hls', +\ 'lsp': 'stdio', +\ 'command': function('ale_linters#haskell#hls#GetCommand'), +\ 'executable': {b -> ale#Var(b, 'haskell_hls_executable')}, +\ 'project_root': function('ale_linters#haskell#hls#GetProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'haskell_hls_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim b/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim index c345fe43..51ecc744 100644 --- a/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim +++ b/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim @@ -4,8 +4,7 @@ call ale#Set('haskell_stack_ghc_options', '-fno-code -v0') function! ale_linters#haskell#stack_ghc#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . ale#handlers#haskell#GetStackExecutable(a:buffer) + return ale#handlers#haskell#GetStackExecutable(a:buffer) \ . ' ghc -- ' \ . ale#Var(a:buffer, 'haskell_stack_ghc_options') \ . ' %t' @@ -16,6 +15,7 @@ call ale#linter#Define('haskell', { \ 'aliases': ['stack-ghc'], \ 'output_stream': 'stderr', \ 'executable': function('ale#handlers#haskell#GetStackExecutable'), +\ 'cwd': '%s:h', \ 'command': function('ale_linters#haskell#stack_ghc#GetCommand'), \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/help/cspell.vim b/sources_non_forked/ale/ale_linters/help/cspell.vim new file mode 100644 index 00000000..92eb9501 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/help/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for help files. + +call ale#handlers#cspell#DefineLinter('help') diff --git a/sources_non_forked/ale/ale_linters/html/angular.vim b/sources_non_forked/ale/ale_linters/html/angular.vim new file mode 100644 index 00000000..05caf59d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/angular.vim @@ -0,0 +1,56 @@ +" Author: w0rp +" Description: tsserver integration for ALE + +call ale#Set('html_angular_executable', 'ngserver') +call ale#Set('html_angular_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#html#angular#GetProjectRoot(buffer) abort + return ale#path#Dirname( + \ ale#path#FindNearestDirectory(a:buffer, 'node_modules') + \) +endfunction + +function! ale_linters#html#angular#GetExecutable(buffer) abort + return 'node' +endfunction + +function! ale_linters#html#angular#GetCommand(buffer) abort + let l:language_service_dir = ale#path#Simplify( + \ ale#path#FindNearestDirectory( + \ a:buffer, + \ 'node_modules/@angular/language-service' + \ ) + \) + + if empty(l:language_service_dir) + return '' + endif + + let l:language_service_dir = fnamemodify(l:language_service_dir, ':h') + let l:typescript_dir = ale#path#Simplify( + \ fnamemodify(l:language_service_dir, ':h:h') + \ . '/typescript' + \) + let l:script = ale#path#FindExecutable(a:buffer, 'html_angular', [ + \ 'node_modules/@angular/language-server/bin/ngserver', + \ 'node_modules/@angular/language-server/index.js', + \]) + + if !filereadable(l:script) + return '' + endif + + return ale#Escape('node') . ' ' . ale#Escape(l:script) + \ . ' --ngProbeLocations ' . ale#Escape(l:language_service_dir) + \ . ' --tsProbeLocations ' . ale#Escape(l:typescript_dir) + \ . ' --stdio' +endfunction + +call ale#linter#Define('html', { +\ 'name': 'angular', +\ 'aliases': ['angular-language-server', 'angularls'], +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#html#angular#GetExecutable'), +\ 'command': function('ale_linters#html#angular#GetCommand'), +\ 'project_root': function('ale_linters#html#angular#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/html/cspell.vim b/sources_non_forked/ale/ale_linters/html/cspell.vim new file mode 100644 index 00000000..743350ea --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for HTML files. + +call ale#handlers#cspell#DefineLinter('html') diff --git a/sources_non_forked/ale/ale_linters/html/djlint.vim b/sources_non_forked/ale/ale_linters/html/djlint.vim new file mode 100644 index 00000000..df75fb28 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/djlint.vim @@ -0,0 +1,14 @@ +" Author: Vivian De Smedt +" Description: Adds support for djlint + +call ale#Set('html_djlint_executable', 'djlint') +call ale#Set('html_djlint_options', '') + +call ale#linter#Define('html', { +\ 'name': 'djlint', +\ 'executable': function('ale#handlers#djlint#GetExecutable'), +\ 'command': function('ale#handlers#djlint#GetCommand'), +\ 'callback': 'ale#handlers#djlint#Handle', +\}) + +" vim:ts=4:sw=4:et: diff --git a/sources_non_forked/ale/ale_linters/html/eslint.vim b/sources_non_forked/ale/ale_linters/html/eslint.vim new file mode 100644 index 00000000..699f5301 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/eslint.vim @@ -0,0 +1,12 @@ +" Author: Victor Ananyev +" Description: eslint for js snippets in HTML files + + +call ale#linter#Define('html', { +\ '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/html/htmlhint.vim b/sources_non_forked/ale/ale_linters/html/htmlhint.vim index 3e01f51a..25bf5137 100644 --- a/sources_non_forked/ale/ale_linters/html/htmlhint.vim +++ b/sources_non_forked/ale/ale_linters/html/htmlhint.vim @@ -24,7 +24,7 @@ endfunction call ale#linter#Define('html', { \ 'name': 'htmlhint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'html_htmlhint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'html_htmlhint', [ \ 'node_modules/.bin/htmlhint', \ ])}, \ 'command': function('ale_linters#html#htmlhint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/html/stylelint.vim b/sources_non_forked/ale/ale_linters/html/stylelint.vim index ae8955f3..c191c468 100644 --- a/sources_non_forked/ale/ale_linters/html/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/html/stylelint.vim @@ -5,7 +5,7 @@ call ale#Set('html_stylelint_options', '') call ale#Set('html_stylelint_use_global', 0) function! ale_linters#html#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'html_stylelint', [ + return ale#path#FindExecutable(a:buffer, 'html_stylelint', [ \ 'node_modules/.bin/stylelint', \]) endfunction @@ -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/html/vscodehtml.vim b/sources_non_forked/ale/ale_linters/html/vscodehtml.vim new file mode 100644 index 00000000..46814a0b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/vscodehtml.vim @@ -0,0 +1,16 @@ +" Author: Dalius Dobravolskas +" Description: VSCode html language server + +function! ale_linters#html#vscodehtml#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('html', { +\ 'name': 'vscodehtml', +\ 'lsp': 'stdio', +\ 'executable': 'vscode-html-language-server', +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#html#vscodehtml#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/htmlangular/djlint.vim b/sources_non_forked/ale/ale_linters/htmlangular/djlint.vim new file mode 100644 index 00000000..b353d741 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/htmlangular/djlint.vim @@ -0,0 +1,12 @@ +" Author: Adrian Vollmer +" Description: djlint for Django HTML template files + +call ale#Set('html_djlint_executable', 'djlint') +call ale#Set('html_djlint_options', '') + +call ale#linter#Define('htmlangular', { +\ 'name': 'djlint', +\ 'executable': function('ale#handlers#djlint#GetExecutable'), +\ 'command': function('ale#handlers#djlint#GetCommand'), +\ 'callback': 'ale#handlers#djlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/htmldjango/djlint.vim b/sources_non_forked/ale/ale_linters/htmldjango/djlint.vim new file mode 100644 index 00000000..9327979f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/htmldjango/djlint.vim @@ -0,0 +1,12 @@ +" Author: Adrian Vollmer +" Description: djlint for Django HTML template files + +call ale#Set('html_djlint_executable', 'djlint') +call ale#Set('html_djlint_options', '') + +call ale#linter#Define('htmldjango', { +\ 'name': 'djlint', +\ 'executable': function('ale#handlers#djlint#GetExecutable'), +\ 'command': function('ale#handlers#djlint#GetCommand'), +\ 'callback': 'ale#handlers#djlint#Handle', +\}) 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/ink/ls.vim b/sources_non_forked/ale/ale_linters/ink/ls.vim new file mode 100644 index 00000000..00b2f323 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ink/ls.vim @@ -0,0 +1,35 @@ +" Author: Andreww Hayworth +" Description: Integrate ALE with ink-language-server + +call ale#Set('ink_ls_executable', 'ink-language-server') +call ale#Set('ink_ls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('ink_ls_initialization_options', {}) + +function! ale_linters#ink#ls#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'ink_ls', [ + \ 'ink-language-server', + \ 'node_modules/.bin/ink-language-server', + \]) +endfunction + +function! ale_linters#ink#ls#GetCommand(buffer) abort + let l:executable = ale_linters#ink#ls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +function! ale_linters#ink#ls#FindProjectRoot(buffer) abort + let l:main_file = get(ale#Var(a:buffer, 'ink_ls_initialization_options'), 'mainStoryPath', 'main.ink') + let l:config = ale#path#ResolveLocalPath(a:buffer, l:main_file, expand('#' . a:buffer . ':p')) + + return ale#path#Dirname(l:config) +endfunction + +call ale#linter#Define('ink', { +\ 'name': 'ink-language-server', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#ink#ls#GetExecutable'), +\ 'command': function('ale_linters#ink#ls#GetCommand'), +\ 'project_root': function('ale_linters#ink#ls#FindProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'ink_ls_initialization_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/inko/inko.vim b/sources_non_forked/ale/ale_linters/inko/inko.vim new file mode 100644 index 00000000..11558897 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/inko/inko.vim @@ -0,0 +1,33 @@ +" Author: Yorick Peterse +" Description: linting of Inko source code using the Inko compiler + +call ale#Set('inko_inko_executable', 'inko') + +function! ale_linters#inko#inko#GetCommand(buffer) abort + let l:include = '' + + " Include the tests source directory, but only for test files. + if expand('#' . a:buffer . ':p') =~? '\vtests[/\\]test[/\\]' + let l:test_dir = ale#path#FindNearestDirectory(a:buffer, 'tests') + + if isdirectory(l:test_dir) + let l:include = '--include ' . ale#Escape(l:test_dir) + endif + endif + + " We use %s instead of %t so the compiler determines the correct module + " names for the file being edited. Not doing so may lead to errors in + " certain cases. + return '%e build --check --format=json' + \ . ale#Pad(l:include) + \ . ' %s' +endfunction + +call ale#linter#Define('inko', { +\ 'name': 'inko', +\ 'executable': {b -> ale#Var(b, 'inko_inko_executable')}, +\ 'command': function('ale_linters#inko#inko#GetCommand'), +\ 'callback': 'ale#handlers#inko#Handle', +\ 'output_stream': 'stderr', +\ 'lint_file': 1 +\}) diff --git a/sources_non_forked/ale/ale_linters/java/checkstyle.vim b/sources_non_forked/ale/ale_linters/java/checkstyle.vim index 7901ff7e..1ccbc505 100644 --- a/sources_non_forked/ale/ale_linters/java/checkstyle.vim +++ b/sources_non_forked/ale/ale_linters/java/checkstyle.vim @@ -9,11 +9,12 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort let l:output = [] " modern checkstyle versions - let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$' + let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]' for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { \ 'type': l:match[1] is? 'WARN' ? 'W' : 'E', + \ 'sub_type': 'style', \ 'lnum': l:match[2] + 0, \ 'col': l:match[3] + 0, \ 'text': l:match[4], @@ -31,6 +32,7 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { \ 'type': l:match[3] is? 'warning' ? 'W' : 'E', + \ 'sub_type': 'style', \ 'lnum': l:match[2] + 0, \ 'text': l:match[4], \}) @@ -52,7 +54,7 @@ endfunction function! ale_linters#java#checkstyle#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'java_checkstyle_options') let l:config_option = ale#Var(a:buffer, 'java_checkstyle_config') - let l:config = l:options !~# '\v(^| )-c' && !empty(l:config_option) + let l:config = l:options !~# '\v(^| )-c ' && !empty(l:config_option) \ ? s:GetConfig(a:buffer, l:config_option) \ : '' diff --git a/sources_non_forked/ale/ale_linters/java/cspell.vim b/sources_non_forked/ale/ale_linters/java/cspell.vim new file mode 100644 index 00000000..a6eecc0b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/java/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Java files. + +call ale#handlers#cspell#DefineLinter('java') diff --git a/sources_non_forked/ale/ale_linters/java/eclipselsp.vim b/sources_non_forked/ale/ale_linters/java/eclipselsp.vim index 2648893b..ad7cbeb4 100644 --- a/sources_non_forked/ale/ale_linters/java/eclipselsp.vim +++ b/sources_non_forked/ale/ale_linters/java/eclipselsp.vim @@ -7,6 +7,7 @@ call ale#Set('java_eclipselsp_path', ale#path#Simplify($HOME . '/eclipse.jdt.ls' call ale#Set('java_eclipselsp_config_path', '') call ale#Set('java_eclipselsp_workspace_path', '') call ale#Set('java_eclipselsp_executable', 'java') +call ale#Set('java_eclipselsp_javaagent', '') function! ale_linters#java#eclipselsp#Executable(buffer) abort return ale#Var(a:buffer, 'java_eclipselsp_executable') @@ -19,25 +20,39 @@ endfunction function! ale_linters#java#eclipselsp#JarPath(buffer) abort let l:path = ale_linters#java#eclipselsp#TargetPath(a:buffer) - " Search jar file within repository path when manually built using mvn - let l:repo_path = l:path . '/org.eclipse.jdt.ls.product/target/repository' - let l:files = globpath(l:repo_path, '**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + if has('win32') + let l:platform = 'win32' + elseif has('macunix') + let l:platform = 'macosx' + else + let l:platform = 'linux' + endif - if len(l:files) == 1 + " Search jar file within repository path when manually built using mvn + let l:files = globpath(l:path, '**/'.l:platform.'/**/plugins/org.eclipse.equinox.launcher_*\.jar', 1, 1) + + if len(l:files) >= 1 return l:files[0] endif " Search jar file within VSCode extensions folder. - let l:files = globpath(l:path, '**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + let l:files = globpath(l:path, '**/'.l:platform.'/plugins/org.eclipse.equinox.launcher_*\.jar', 1, 1) - if len(l:files) == 1 + if len(l:files) >= 1 + return l:files[0] + endif + + " Search jar file within unzipped tar.gz file + let l:files = globpath(l:path, 'plugins/org.eclipse.equinox.launcher_*\.jar', 1, 1) + + if len(l:files) >= 1 return l:files[0] endif " Search jar file within system package path - let l:files = globpath('/usr/share/java/jdtls/plugins', 'org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + let l:files = globpath('/usr/share/java/jdtls/plugins', 'org.eclipse.equinox.launcher_*\.jar', 1, 1) - if len(l:files) == 1 + if len(l:files) >= 1 return l:files[0] endif @@ -100,12 +115,30 @@ function! ale_linters#java#eclipselsp#WorkspacePath(buffer) abort return ale#path#Dirname(ale#java#FindProjectRoot(a:buffer)) endfunction +function! ale_linters#java#eclipselsp#Javaagent(buffer) abort + let l:rets = [] + let l:raw = ale#Var(a:buffer, 'java_eclipselsp_javaagent') + + if empty(l:raw) + return '' + endif + + let l:jars = split(l:raw) + + for l:jar in l:jars + call add(l:rets, ale#Escape('-javaagent:' . l:jar)) + endfor + + return join(l:rets, ' ') +endfunction + function! ale_linters#java#eclipselsp#Command(buffer, version) abort let l:path = ale#Var(a:buffer, 'java_eclipselsp_path') let l:executable = ale_linters#java#eclipselsp#Executable(a:buffer) let l:cmd = [ ale#Escape(l:executable), + \ ale_linters#java#eclipselsp#Javaagent(a:buffer), \ '-Declipse.application=org.eclipse.jdt.ls.core.id1', \ '-Dosgi.bundles.defaultStartLevel=4', \ '-Declipse.product=org.eclipse.jdt.ls.core.product', @@ -147,7 +180,8 @@ function! ale_linters#java#eclipselsp#RunWithVersionCheck(buffer) abort return ale#command#Run( \ a:buffer, \ l:command, - \ function('ale_linters#java#eclipselsp#CommandWithVersion') + \ function('ale_linters#java#eclipselsp#CommandWithVersion'), + \ { 'output_stream': 'both' } \) endfunction @@ -158,4 +192,9 @@ call ale#linter#Define('java', { \ 'command': function('ale_linters#java#eclipselsp#RunWithVersionCheck'), \ 'language': 'java', \ 'project_root': function('ale#java#FindProjectRoot'), +\ 'initialization_options': { +\ 'extendedClientCapabilities': { +\ 'classFileContentsSupport': v:true +\ } +\ } \}) diff --git a/sources_non_forked/ale/ale_linters/java/javac.vim b/sources_non_forked/ale/ale_linters/java/javac.vim index 8bb52c0b..971e8de0 100644 --- a/sources_non_forked/ale/ale_linters/java/javac.vim +++ b/sources_non_forked/ale/ale_linters/java/javac.vim @@ -6,24 +6,19 @@ let s:classpath_sep = has('unix') ? ':' : ';' call ale#Set('java_javac_executable', 'javac') call ale#Set('java_javac_options', '') call ale#Set('java_javac_classpath', '') +call ale#Set('java_javac_sourcepath', '') function! ale_linters#java#javac#RunWithImportPaths(buffer) abort - let l:command = '' - let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') - - if !empty(l:pom_path) && executable('mvn') - let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h')) - \ . 'mvn dependency:build-classpath' - endif + let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer) " Try to use Gradle if Maven isn't available. if empty(l:command) - let l:command = ale#gradle#BuildClasspathCommand(a:buffer) + let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer) endif " Try to use Ant if Gradle and Maven aren't available if empty(l:command) - let l:command = ale#ant#BuildClasspathCommand(a:buffer) + let [l:cwd, l:command] = ale#ant#BuildClasspathCommand(a:buffer) endif if empty(l:command) @@ -33,17 +28,23 @@ function! ale_linters#java#javac#RunWithImportPaths(buffer) abort return ale#command#Run( \ a:buffer, \ l:command, - \ function('ale_linters#java#javac#GetCommand') + \ function('ale_linters#java#javac#GetCommand'), + \ {'cwd': l:cwd}, \) endfunction function! s:BuildClassPathOption(buffer, import_paths) abort " Filter out lines like [INFO], etc. let l:class_paths = filter(a:import_paths[:], 'v:val !~# ''[''') - call extend( - \ l:class_paths, - \ split(ale#Var(a:buffer, 'java_javac_classpath'), s:classpath_sep), - \) + let l:cls_path = ale#Var(a:buffer, 'java_javac_classpath') + + if !empty(l:cls_path) && type(l:cls_path) is v:t_string + call extend(l:class_paths, split(l:cls_path, s:classpath_sep)) + endif + + if !empty(l:cls_path) && type(l:cls_path) is v:t_list + call extend(l:class_paths, l:cls_path) + endif return !empty(l:class_paths) \ ? '-cp ' . ale#Escape(join(l:class_paths, s:classpath_sep)) @@ -79,6 +80,27 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort endif endif + let l:source_paths = [] + let l:source_path = ale#Var(a:buffer, 'java_javac_sourcepath') + + if !empty(l:source_path) && type(l:source_path) is v:t_string + let l:source_paths = split(l:source_path, s:classpath_sep) + endif + + if !empty(l:source_path) && type(l:source_path) is v:t_list + let l:source_paths = l:source_path + endif + + if !empty(l:source_paths) + for l:path in l:source_paths + let l:sp_path = ale#path#FindNearestDirectory(a:buffer, l:path) + + if !empty(l:sp_path) + call add(l:sp_dirs, l:sp_path) + endif + endfor + endif + if !empty(l:sp_dirs) let l:sp_option = '-sourcepath ' \ . ale#Escape(join(l:sp_dirs, s:classpath_sep)) @@ -89,8 +111,7 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort " Always run javac from the directory the file is in, so we can resolve " relative paths correctly. - return ale#path#BufferCdString(a:buffer) - \ . '%e -Xlint' + return '%e -Xlint' \ . ale#Pad(l:cp_option) \ . ale#Pad(l:sp_option) \ . ' -d ' . ale#Escape(l:class_file_directory) @@ -111,7 +132,9 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:col_pattern, l:symbol_pattern]) if empty(l:match[2]) && empty(l:match[3]) - let l:output[-1].col = len(l:match[1]) + if !empty(l:match[1]) && !empty(l:output) + let l:output[-1].col = len(l:match[1]) + endif elseif empty(l:match[3]) " Add symbols to 'cannot find symbol' errors. if l:output[-1].text is# 'error: cannot find symbol' @@ -133,6 +156,7 @@ endfunction call ale#linter#Define('java', { \ 'name': 'javac', \ 'executable': {b -> ale#Var(b, 'java_javac_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#java#javac#RunWithImportPaths'), \ 'output_stream': 'stderr', \ 'callback': 'ale_linters#java#javac#Handle', diff --git a/sources_non_forked/ale/ale_linters/java/javalsp.vim b/sources_non_forked/ale/ale_linters/java/javalsp.vim index baf584c8..fa3b0e2c 100644 --- a/sources_non_forked/ale/ale_linters/java/javalsp.vim +++ b/sources_non_forked/ale/ale_linters/java/javalsp.vim @@ -46,6 +46,7 @@ endfunction call ale#linter#Define('java', { \ 'name': 'javalsp', +\ 'aliases': ['java_language_server'], \ 'lsp': 'stdio', \ 'executable': function('ale_linters#java#javalsp#Executable'), \ 'command': function('ale_linters#java#javalsp#Command'), 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 +" 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/javascript/cspell.vim b/sources_non_forked/ale/ale_linters/javascript/cspell.vim new file mode 100644 index 00000000..5a496779 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for JavaScript files. + +call ale#handlers#cspell#DefineLinter('javascript') diff --git a/sources_non_forked/ale/ale_linters/javascript/deno.vim b/sources_non_forked/ale/ale_linters/javascript/deno.vim new file mode 100644 index 00000000..659eb855 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/deno.vim @@ -0,0 +1,11 @@ +" Author: Arnold Chand +" Description: Deno lsp linter for JavaScript files. + +call ale#linter#Define('javascript', { +\ 'name': 'deno', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#deno#GetExecutable'), +\ 'command': '%e lsp', +\ 'project_root': function('ale#handlers#deno#GetProjectRoot'), +\ 'initialization_options': function('ale#handlers#deno#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/eslint.vim b/sources_non_forked/ale/ale_linters/javascript/eslint.vim index 31fb413f..cf4de6ec 100644 --- a/sources_non_forked/ale/ale_linters/javascript/eslint.vim +++ b/sources_non_forked/ale/ale_linters/javascript/eslint.vim @@ -5,6 +5,7 @@ call ale#linter#Define('javascript', { \ '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/javascript/flow.vim b/sources_non_forked/ale/ale_linters/javascript/flow.vim index 3135e2e9..601bac33 100644 --- a/sources_non_forked/ale/ale_linters/javascript/flow.vim +++ b/sources_non_forked/ale/ale_linters/javascript/flow.vim @@ -22,7 +22,7 @@ function! ale_linters#javascript#flow#GetExecutable(buffer) abort return '' endif - return ale#node#FindExecutable(a:buffer, 'javascript_flow', [ + return ale#path#FindExecutable(a:buffer, 'javascript_flow', [ \ 'node_modules/.bin/flow', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim index accaaa73..9755ca4e 100644 --- a/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim +++ b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim @@ -17,9 +17,10 @@ function! ale_linters#javascript#flow_ls#FindProjectRoot(buffer) abort endfunction call ale#linter#Define('javascript', { -\ 'name': 'flow-language-server', +\ 'name': 'flow_ls', +\ 'aliaes': ['flow-language-server'], \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_flow_ls', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_flow_ls', [ \ 'node_modules/.bin/flow', \ ])}, \ 'command': '%e lsp --from ale-lsp', diff --git a/sources_non_forked/ale/ale_linters/javascript/jscs.vim b/sources_non_forked/ale/ale_linters/javascript/jscs.vim index 8905b3a1..ae3be68c 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jscs.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jscs.vim @@ -53,7 +53,7 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'jscs', -\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_jscs', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jscs', [ \ 'node_modules/.bin/jscs', \ ])}, \ 'command': function('ale_linters#javascript#jscs#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/javascript/jshint.vim b/sources_non_forked/ale/ale_linters/javascript/jshint.vim index d80a2250..26d4fda2 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jshint.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jshint.vim @@ -25,7 +25,7 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'jshint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_jshint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jshint', [ \ 'node_modules/.bin/jshint', \ ])}, \ 'command': function('ale_linters#javascript#jshint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/javascript/standard.vim b/sources_non_forked/ale/ale_linters/javascript/standard.vim index 4cd2c303..addf41dd 100644 --- a/sources_non_forked/ale/ale_linters/javascript/standard.vim +++ b/sources_non_forked/ale/ale_linters/javascript/standard.vim @@ -6,8 +6,10 @@ call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executabl call ale#Set('javascript_standard_options', '') function! ale_linters#javascript#standard#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + return ale#path#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/semistandard/bin/cmd.js', \ 'node_modules/.bin/standard', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim index 68c252c5..caf6972b 100644 --- a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim @@ -8,7 +8,7 @@ call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executabl call ale#linter#Define('javascript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_tsserver', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_tsserver', [ \ 'node_modules/.bin/tsserver', \ ])}, \ 'command': '%e', diff --git a/sources_non_forked/ale/ale_linters/javascript/xo.vim b/sources_non_forked/ale/ale_linters/javascript/xo.vim index e24f4a82..5e04ad5c 100644 --- a/sources_non_forked/ale/ale_linters/javascript/xo.vim +++ b/sources_non_forked/ale/ale_linters/javascript/xo.vim @@ -1,26 +1,9 @@ " Author: Daniel Lupu " Description: xo for JavaScript files -call ale#Set('javascript_xo_executable', 'xo') -call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('javascript_xo_options', '') - -function! ale_linters#javascript#xo#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_xo', [ - \ 'node_modules/.bin/xo', - \]) -endfunction - -function! ale_linters#javascript#xo#GetCommand(buffer) abort - return ale#Escape(ale_linters#javascript#xo#GetExecutable(a:buffer)) - \ . ' ' . ale#Var(a:buffer, 'javascript_xo_options') - \ . ' --reporter json --stdin --stdin-filename %s' -endfunction - -" xo uses eslint and the output format is the same call ale#linter#Define('javascript', { \ 'name': 'xo', -\ 'executable': function('ale_linters#javascript#xo#GetExecutable'), -\ 'command': function('ale_linters#javascript#xo#GetCommand'), -\ 'callback': 'ale#handlers#eslint#HandleJSON', +\ 'executable': function('ale#handlers#xo#GetExecutable'), +\ 'command': function('ale#handlers#xo#GetLintCommand'), +\ 'callback': 'ale#handlers#xo#HandleJSON', \}) diff --git a/sources_non_forked/ale/ale_linters/jinja/djlint.vim b/sources_non_forked/ale/ale_linters/jinja/djlint.vim new file mode 100644 index 00000000..fd52c954 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/jinja/djlint.vim @@ -0,0 +1,12 @@ +" Author: Adrian Vollmer +" Description: djlint for Django HTML template files + +call ale#Set('html_djlint_executable', 'djlint') +call ale#Set('html_djlint_options', '') + +call ale#linter#Define('jinja', { +\ 'name': 'djlint', +\ 'executable': function('ale#handlers#djlint#GetExecutable'), +\ 'command': function('ale#handlers#djlint#GetCommand'), +\ 'callback': 'ale#handlers#djlint#Handle', +\}) 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/json/cspell.vim b/sources_non_forked/ale/ale_linters/json/cspell.vim new file mode 100644 index 00000000..0d7314a4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for JSON files. + +call ale#handlers#cspell#DefineLinter('json') diff --git a/sources_non_forked/ale/ale_linters/json/eslint.vim b/sources_non_forked/ale/ale_linters/json/eslint.vim new file mode 100644 index 00000000..bdabb9fa --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/eslint.vim @@ -0,0 +1,16 @@ +" Author: João Pesce +" Description: eslint for JSON files. +" +" Requires eslint-plugin-jsonc or a similar plugin to work +" +" Uses the same funtcions as ale_linters/javascript/eslint.vim by w0rp +" + +call ale#linter#Define('json', { +\ '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/json/jq.vim b/sources_non_forked/ale/ale_linters/json/jq.vim new file mode 100644 index 00000000..ad1da269 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/jq.vim @@ -0,0 +1,24 @@ +" Author: jD91mZM2 +call ale#Set('json_jq_executable', 'jq') +call ale#Set('json_jq_options', '') +call ale#Set('json_jq_filters', '.') + +" Matches patterns like the following: +" parse error: Expected another key-value pair at line 4, column 3 +let s:pattern = 'parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' + +function! ale_linters#json#jq#Handle(buffer, lines) abort + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'text': match[1], + \ 'lnum': match[2] + 0, + \ 'col': match[3] + 0, + \}}) +endfunction + +call ale#linter#Define('json', { +\ 'name': 'jq', +\ 'executable': {b -> ale#Var(b, 'json_jq_executable')}, +\ 'output_stream': 'stderr', +\ 'command': '%e', +\ 'callback': 'ale_linters#json#jq#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/json/jsonlint.vim b/sources_non_forked/ale/ale_linters/json/jsonlint.vim index f677b488..812540af 100644 --- a/sources_non_forked/ale/ale_linters/json/jsonlint.vim +++ b/sources_non_forked/ale/ale_linters/json/jsonlint.vim @@ -4,7 +4,7 @@ call ale#Set('json_jsonlint_executable', 'jsonlint') call ale#Set('json_jsonlint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#json#jsonlint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'json_jsonlint', [ + return ale#path#FindExecutable(a:buffer, 'json_jsonlint', [ \ 'node_modules/.bin/jsonlint', \ 'node_modules/jsonlint/lib/cli.js', \]) diff --git a/sources_non_forked/ale/ale_linters/json/spectral.vim b/sources_non_forked/ale/ale_linters/json/spectral.vim new file mode 100644 index 00000000..14129c56 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/spectral.vim @@ -0,0 +1,14 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +call ale#Set('json_spectral_executable', 'spectral') +call ale#Set('json_spectral_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('json', { +\ 'name': 'spectral', +\ 'executable': {b -> ale#path#FindExecutable(b, 'json_spectral', [ +\ 'node_modules/.bin/spectral', +\ ])}, +\ 'command': '%e lint --ignore-unknown-format -q -f text %t', +\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput' +\}) diff --git a/sources_non_forked/ale/ale_linters/json/vscodejson.vim b/sources_non_forked/ale/ale_linters/json/vscodejson.vim new file mode 100644 index 00000000..be9eaf53 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/vscodejson.vim @@ -0,0 +1,32 @@ +" Author: Dalius Dobravolskas +" Description: VSCode json language server + +call ale#Set('json_vscodejson_executable', '') + +function! ale_linters#json#vscodejson#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'json_vscodejson_executable') + + if l:executable is# '' + if ale#engine#IsExecutable(a:buffer, 'vscode-json-languageserver') + let l:executable = 'vscode-json-languageserver' + else + let l:executable = 'vscode-json-language-server' + endif + endif + + return l:executable +endfunction + +function! ale_linters#json#vscodejson#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('json', { +\ 'name': 'vscodejson', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#json#vscodejson#GetExecutable'), +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#json#vscodejson#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/json5/eslint.vim b/sources_non_forked/ale/ale_linters/json5/eslint.vim new file mode 100644 index 00000000..6207f2d7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json5/eslint.vim @@ -0,0 +1,16 @@ +" Author: João Pesce +" Description: eslint for JSON5 files. +" +" Requires eslint-plugin-jsonc or a similar plugin to work +" +" Uses the same funtcions as ale_linters/javascript/eslint.vim by w0rp +" + +call ale#linter#Define('json5', { +\ '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/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/jsonc/eslint.vim b/sources_non_forked/ale/ale_linters/jsonc/eslint.vim new file mode 100644 index 00000000..1a5cc528 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/jsonc/eslint.vim @@ -0,0 +1,16 @@ +" Author: João Pesce +" Description: eslint for JSONC files. +" +" Requires eslint-plugin-jsonc or a similar plugin to work +" +" Uses the same funtcions as ale_linters/javascript/eslint.vim by w0rp +" + +call ale#linter#Define('jsonc', { +\ '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/jsonnet/jsonnet_lint.vim b/sources_non_forked/ale/ale_linters/jsonnet/jsonnet_lint.vim new file mode 100644 index 00000000..a5ebdc39 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/jsonnet/jsonnet_lint.vim @@ -0,0 +1,59 @@ +" Author: Trevor Whitney +" Description: jsonnet-lint for jsonnet files + +call ale#Set('jsonnet_jsonnet_lint_executable', 'jsonnet-lint') +call ale#Set('jsonnet_jsonnet_lint_options', '') + +function! ale_linters#jsonnet#jsonnet_lint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'jsonnet_jsonnet_lint_options') + + return '%e' + \ . ale#Pad(l:options) + \ . ' %t' +endfunction + + +function! ale_linters#jsonnet#jsonnet_lint#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " ERROR: foo.jsonnet:22:3-12 expected token OPERATOR but got (IDENTIFIER, "bar") + " ERROR: hoge.jsonnet:20:3 unexpected: "}" while parsing terminal + " ERROR: main.jsonnet:212:1-14 Expected , or ; but got (IDENTIFIER, "older_cluster") + let l:pattern = '^ERROR: [^:]*:\(\d\+\):\(\d\+\)\(-\d\+\)* \(.*\)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let line_number = l:match[1] + 0 + let column = l:match[2] + 0 + " l:match[3] has optional -14, when linter is showing a range + let text = l:match[4] + + + " vcol is Needed to indicate that the column is a character. + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': line_number, + \ 'vcol': 0, + \ 'col': column, + \ 'text': text, + \ 'type': 'E', + \ 'nr': -1, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('jsonnet', { +\ 'name': 'jsonnet_lint', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'jsonnet_jsonnet_lint_executable')}, +\ 'command': function('ale_linters#jsonnet#jsonnet_lint#GetCommand'), +\ 'callback': 'ale_linters#jsonnet#jsonnet_lint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/jsonnet/jsonnetfmt.vim b/sources_non_forked/ale/ale_linters/jsonnet/jsonnetfmt.vim new file mode 100644 index 00000000..8904019e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/jsonnet/jsonnetfmt.vim @@ -0,0 +1,52 @@ +" Authors: Trevor Whitney and Takuya Kosugiyama +" Description: jsonnetfmt for jsonnet files + +call ale#Set('jsonnet_jsonnetfmt_executable', 'jsonnetfmt') +call ale#Set('jsonnet_jsonnetfmt_options', '') + +function! ale_linters#jsonnet#jsonnetfmt#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'jsonnet_jsonnetfmt_options') + + return '%e' + \ . ale#Pad(l:options) + \ . ' %t' +endfunction + + +function! ale_linters#jsonnet#jsonnetfmt#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " STATIC ERROR: foo.jsonnet:22:3-12: expected token OPERATOR but got (IDENTIFIER, "bar") + " STATIC ERROR: hoge.jsonnet:20:3: unexpected: "}" while parsing terminal + let l:pattern = '^STATIC ERROR:[^:]*:\(\d\+\):\(\d\+\):*\(-\d\+\)* \(.*\)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + " vcol is Needed to indicate that the column is a character. + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'vcol': 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \ 'nr': -1, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('jsonnet', { +\ 'name': 'jsonnetfmt', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'jsonnet_jsonnetfmt_executable')}, +\ 'command': function('ale_linters#jsonnet#jsonnetfmt#GetCommand'), +\ 'callback': 'ale_linters#jsonnet#jsonnetfmt#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/julia/languageserver.vim b/sources_non_forked/ale/ale_linters/julia/languageserver.vim index 564bec39..fbfab517 100644 --- a/sources_non_forked/ale/ale_linters/julia/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/julia/languageserver.vim @@ -6,13 +6,14 @@ call ale#Set('julia_executable', 'julia') function! ale_linters#julia#languageserver#GetCommand(buffer) abort let l:julia_executable = ale#Var(a:buffer, 'julia_executable') - let l:cmd_string = 'using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);' + let l:cmd_string = 'using LanguageServer; using Pkg; import StaticLint; import SymbolServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, dirname(Pkg.Types.Context().env.project_file)); server.runlinter = true; run(server);' - return ale#Escape(l:julia_executable) . ' --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string) + return ale#Escape(l:julia_executable) . ' --project=@. --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string) endfunction call ale#linter#Define('julia', { \ 'name': 'languageserver', +\ 'aliases': ['julials'], \ 'lsp': 'stdio', \ 'executable': {b -> ale#Var(b, 'julia_executable')}, \ 'command': function('ale_linters#julia#languageserver#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim index 3c6854fa..e8bc924d 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim @@ -15,20 +15,15 @@ function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort let l:command = '' " exec maven/gradle only if classpath is not set - if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# '' + if !empty(ale#Var(a:buffer, 'kotlin_kotlinc_classpath')) return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {}) endif - let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') - - if !empty(l:pom_path) && executable('mvn') - let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h')) - \ . 'mvn dependency:build-classpath' - endif + let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer) " Try to use Gradle if Maven isn't available. if empty(l:command) - let l:command = ale#gradle#BuildClasspathCommand(a:buffer) + let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer) endif if empty(l:command) @@ -38,7 +33,8 @@ function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort return ale#command#Run( \ a:buffer, \ l:command, - \ function('ale_linters#kotlin#kotlinc#GetCommand') + \ function('ale_linters#kotlin#kotlinc#GetCommand'), + \ {'cwd': l:cwd}, \) endfunction @@ -174,6 +170,7 @@ endfunction call ale#linter#Define('kotlin', { \ 'name': 'kotlinc', \ 'executable': 'kotlinc', +\ 'output_stream': 'stderr', \ 'command': function('ale_linters#kotlin#kotlinc#RunWithImportPaths'), \ 'callback': 'ale_linters#kotlin#kotlinc#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim b/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim index f0384005..0bb64b19 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim @@ -6,5 +6,5 @@ call ale#linter#Define('kotlin', { \ 'executable': 'ktlint', \ 'command': function('ale#handlers#ktlint#GetCommand'), \ 'callback': 'ale#handlers#ktlint#Handle', -\ 'lint_file': 1 +\ 'output_stream': 'stderr' \}) diff --git a/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim b/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim index af78c0e0..18b153ae 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim @@ -21,6 +21,7 @@ endfunction call ale#linter#Define('kotlin', { \ 'name': 'languageserver', +\ 'aliaes': ['kotlin_language_server'], \ 'lsp': 'stdio', \ 'executable': {b -> ale#Var(b, 'kotlin_languageserver_executable')}, \ 'command': '%e', diff --git a/sources_non_forked/ale/ale_linters/less/lessc.vim b/sources_non_forked/ale/ale_linters/less/lessc.vim index 4ec8b00e..8e21f5b4 100644 --- a/sources_non_forked/ale/ale_linters/less/lessc.vim +++ b/sources_non_forked/ale/ale_linters/less/lessc.vim @@ -38,7 +38,7 @@ endfunction call ale#linter#Define('less', { \ 'name': 'lessc', -\ 'executable': {b -> ale#node#FindExecutable(b, 'less_lessc', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'less_lessc', [ \ 'node_modules/.bin/lessc', \ ])}, \ 'command': function('ale_linters#less#lessc#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/less/stylelint.vim b/sources_non_forked/ale/ale_linters/less/stylelint.vim index efb036c2..9430fe9b 100644 --- a/sources_non_forked/ale/ale_linters/less/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/less/stylelint.vim @@ -12,7 +12,8 @@ endfunction call ale#linter#Define('less', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'less_stylelint', [ +\ 'output_stream': 'both', +\ 'executable': {b -> ale#path#FindExecutable(b, 'less_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#less#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/lua/cspell.vim b/sources_non_forked/ale/ale_linters/lua/cspell.vim new file mode 100644 index 00000000..215b82f8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/lua/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Lua files. + +call ale#handlers#cspell#DefineLinter('lua') diff --git a/sources_non_forked/ale/ale_linters/lua/lua_language_server.vim b/sources_non_forked/ale/ale_linters/lua/lua_language_server.vim new file mode 100644 index 00000000..0892ad3b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/lua/lua_language_server.vim @@ -0,0 +1,15 @@ +" Author: w0rp +" Description: lua-language-server integration (https://github.com/LuaLS/lua-language-server) + +call ale#Set('lua_language_server_executable', 'lua-language-server') +call ale#Set('lua_language_server_config', {}) + +call ale#linter#Define('lua', { +\ 'name': 'lua_language_server', +\ 'aliases': ['lua-language-server', 'lua_ls'], +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'lua_language_server_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale#lua#FindProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'lua_language_server_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/lua/luacheck.vim b/sources_non_forked/ale/ale_linters/lua/luacheck.vim index 34be2b5a..16dc08a5 100644 --- a/sources_non_forked/ale/ale_linters/lua/luacheck.vim +++ b/sources_non_forked/ale/ale_linters/lua/luacheck.vim @@ -4,8 +4,43 @@ call ale#Set('lua_luacheck_executable', 'luacheck') call ale#Set('lua_luacheck_options', '') +function! s:IsInRuntimepath(buffer) abort + let l:runtimepath_dirs = split(&runtimepath, ',') + + for l:dir in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:runtime_dir in l:runtimepath_dirs + if l:dir is# l:runtime_dir + return 1 + endif + endfor + endfor + + return 0 +endfunction + function! ale_linters#lua#luacheck#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'lua_luacheck_options')) + let l:options = ale#Var(a:buffer, 'lua_luacheck_options') + + " Add `--globals vim` by default if the file is in runtimepath. + if l:options !~# '--globals' + let l:in_runtime = getbufvar(a:buffer, 'ale_in_runtimepath', v:null) + + if l:in_runtime is v:null + let l:in_runtime = s:IsInRuntimepath(a:buffer) + " Save the result of check this buffer so we only check once. + call setbufvar(a:buffer, 'ale_in_runtimepath', l:in_runtime) + endif + + if l:in_runtime + if !empty(l:options) + let l:options .= ' ' + endif + + let l:options .= '--globals vim' + endif + endif + + return '%e' . ale#Pad(l:options) \ . ' --formatter plain --codes --filename %s -' endfunction diff --git a/sources_non_forked/ale/ale_linters/lua/selene.vim b/sources_non_forked/ale/ale_linters/lua/selene.vim new file mode 100644 index 00000000..6b33cbfd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/lua/selene.vim @@ -0,0 +1,46 @@ +call ale#Set('lua_selene_executable', 'selene') +call ale#Set('lua_selene_options', '') + +function! ale_linters#lua#selene#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'lua_selene_options')) + \ . ' --display-style=json -' +endfunction + +function! ale_linters#lua#selene#Handle(buffer, lines) abort + let l:output = [] + + for l:line in a:lines + " as of version 0.17.0, selene has no way to suppress summary + " information when outputting json, so stop processing when we hit it + " (PR for this here: https://github.com/Kampfkarren/selene/pull/356) + if l:line is# 'Results:' + break + endif + + let l:json = json_decode(l:line) + let l:lint = { + \ 'lnum': l:json.primary_label.span.start_line + 1, + \ 'end_lnum': l:json.primary_label.span.end_line + 1, + \ 'col': l:json.primary_label.span.start_column + 1, + \ 'end_col': l:json.primary_label.span.end_column, + \ 'text': l:json.message, + \ 'code': l:json.code, + \ 'type': l:json.severity is# 'Warning' ? 'W' : 'E', + \} + + if has_key(l:json, 'notes') && len(l:json.notes) > 0 + let l:lint.detail = l:lint.text . "\n\n" . join(l:json.notes, "\n") + endif + + call add(l:output, l:lint) + endfor + + return l:output +endfunction + +call ale#linter#Define('lua', { +\ 'name': 'selene', +\ 'executable': {b -> ale#Var(b, 'lua_selene_executable')}, +\ 'command': function('ale_linters#lua#selene#GetCommand'), +\ 'callback': 'ale_linters#lua#selene#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/mail/languagetool.vim b/sources_non_forked/ale/ale_linters/mail/languagetool.vim index 330fb8ec..f68dab7a 100644 --- a/sources_non_forked/ale/ale_linters/mail/languagetool.vim +++ b/sources_non_forked/ale/ale_linters/mail/languagetool.vim @@ -1,4 +1,4 @@ -" Author: Vincent (wahrwolf [ät] wolfpit.net) +" Author: Vincent (wahrwolf [at] wolfpit.net) " Description: languagetool for mails diff --git a/sources_non_forked/ale/ale_linters/make/checkmake.vim b/sources_non_forked/ale/ale_linters/make/checkmake.vim index 5ebdf91e..fed01b5f 100644 --- a/sources_non_forked/ale/ale_linters/make/checkmake.vim +++ b/sources_non_forked/ale/ale_linters/make/checkmake.vim @@ -1,5 +1,7 @@ " Author: aurieh - https://github.com/aurieh +call ale#Set('make_checkmake_config', '') + function! ale_linters#make#checkmake#Handle(buffer, lines) abort let l:pattern = '\v^(\d+):(.+):(.+)$' let l:output = [] @@ -17,9 +19,19 @@ function! ale_linters#make#checkmake#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#make#checkmake#GetCommand(buffer) abort + let l:config = ale#Var(a:buffer, 'make_checkmake_config') + let l:cmd = 'checkmake' + \ . ' --format="{{.LineNumber}}:{{.Rule}}:{{.Violation}}{{\"\r\n\"}}"' + \ . (!empty(l:config) ? ' --config="' . l:config . '"' : '') + \ . ' %s' + + return l:cmd +endfunction + call ale#linter#Define('make', { \ 'name': 'checkmake', \ 'executable': 'checkmake', -\ 'command': 'checkmake %s --format="{{.LineNumber}}:{{.Rule}}:{{.Violation}}"', +\ 'command': function('ale_linters#make#checkmake#GetCommand'), \ 'callback': 'ale_linters#make#checkmake#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/markdown/cspell.vim b/sources_non_forked/ale/ale_linters/markdown/cspell.vim new file mode 100644 index 00000000..45c586cc --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Markdown files. + +call ale#handlers#cspell#DefineLinter('markdown') diff --git a/sources_non_forked/ale/ale_linters/markdown/languagetool.vim b/sources_non_forked/ale/ale_linters/markdown/languagetool.vim index d6bca22e..422a38c3 100644 --- a/sources_non_forked/ale/ale_linters/markdown/languagetool.vim +++ b/sources_non_forked/ale/ale_linters/markdown/languagetool.vim @@ -1,4 +1,4 @@ -" Author: Vincent (wahrwolf [ät] wolfpit.net) +" Author: Vincent (wahrwolf [at] wolfpit.net) " Description: languagetool for markdown files diff --git a/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim b/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim index e935cbfe..424c9f24 100644 --- a/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim +++ b/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim @@ -1,11 +1,27 @@ " Author: Ty-Lucas Kelley " Description: Adds support for markdownlint +call ale#Set('markdown_markdownlint_executable', 'markdownlint') +call ale#Set('markdown_markdownlint_options', '') + +function! ale_linters#markdown#markdownlint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'markdown_markdownlint_executable') +endfunction + +function! ale_linters#markdown#markdownlint#GetCommand(buffer) abort + let l:executable = ale_linters#markdown#markdownlint#GetExecutable(a:buffer) + + let l:options = ale#Var(a:buffer, 'markdown_markdownlint_options') + + return ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' %s' +endfunction + call ale#linter#Define('markdown', { \ 'name': 'markdownlint', -\ 'executable': 'markdownlint', +\ 'executable': function('ale_linters#markdown#markdownlint#GetExecutable'), \ 'lint_file': 1, \ 'output_stream': 'both', -\ 'command': 'markdownlint %s', +\ 'command': function('ale_linters#markdown#markdownlint#GetCommand'), \ 'callback': 'ale#handlers#markdownlint#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/markdown/marksman.vim b/sources_non_forked/ale/ale_linters/markdown/marksman.vim new file mode 100644 index 00000000..b23f0e05 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/marksman.vim @@ -0,0 +1,35 @@ +" Author: Peter Benjamin +" Description: Write Markdown with code assist and intelligence in the comfort of your favourite editor. + +call ale#Set('markdown_marksman_executable', 'marksman') + +function! ale_linters#markdown#marksman#GetCommand(buffer) abort + return '%e server' +endfunction + +function! ale_linters#markdown#marksman#GetProjectRoot(buffer) abort + " Find nearest .marksman.toml + let l:marksman_toml = ale#path#FindNearestFile(a:buffer, '.marksman.toml') + + if !empty(l:marksman_toml) + return fnamemodify(l:marksman_toml, ':h') + endif + + " Find nearest .git/ directory + let l:project_root = finddir('.git/..', expand('#' . a:buffer . '...').';') + + if !empty(l:project_root) + return l:project_root + endif + + return '' +endfunction + +call ale#linter#Define('markdown', { +\ 'name': 'marksman', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'markdown_marksman_executable')}, +\ 'command': function('ale_linters#markdown#marksman#GetCommand'), +\ 'project_root': function('ale_linters#markdown#marksman#GetProjectRoot'), +\ 'initialization_options': {}, +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/mdl.vim b/sources_non_forked/ale/ale_linters/markdown/mdl.vim index 305f5359..fd44de6e 100644 --- a/sources_non_forked/ale/ale_linters/markdown/mdl.vim +++ b/sources_non_forked/ale/ale_linters/markdown/mdl.vim @@ -17,18 +17,17 @@ function! ale_linters#markdown#mdl#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'markdown_mdl_options') return ale#Escape(l:executable) . l:exec_args - \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -j' . (!empty(l:options) ? ' ' . l:options : '') endfunction function! ale_linters#markdown#mdl#Handle(buffer, lines) abort - " matches: '(stdin):173: MD004 Unordered list style' - let l:pattern = ':\(\d*\): \(.*\)$' let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'text': l:match[2], + \ 'lnum': l:error['line'], + \ 'code': l:error['rule'] . '/' . join(l:error['aliases'], '/'), + \ 'text': l:error['description'], \ 'type': 'W', \}) endfor diff --git a/sources_non_forked/ale/ale_linters/markdown/pymarkdown.vim b/sources_non_forked/ale/ale_linters/markdown/pymarkdown.vim new file mode 100644 index 00000000..7700974b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/pymarkdown.vim @@ -0,0 +1,73 @@ + +call ale#Set('markdown_pymarkdown_executable', 'pymarkdown') +call ale#Set('markdown_pymarkdown_options', '') +call ale#Set('markdown_pymarkdown_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('markdown_pymarkdown_auto_pipenv', 0) +call ale#Set('markdown_pymarkdown_auto_poetry', 0) +call ale#Set('markdown_pymarkdown_auto_uv', 0) + +function! ale_linters#markdown#pymarkdown#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'markdown_pymarkdown_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'markdown_pymarkdown_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'markdown_pymarkdown_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + + return ale#python#FindExecutable(a:buffer, 'markdown_pymarkdown', ['pymarkdown']) +endfunction + +function! ale_linters#markdown#pymarkdown#GetCommand(buffer) abort + let l:executable = ale_linters#markdown#pymarkdown#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + \ ? ' run pymarkdown' + \ : '' + + return ale#Escape(l:executable) . l:exec_args + \ . ' ' + \ . ale#Var(a:buffer, 'markdown_pymarkdown_options') + \ . 'scan-stdin' +endfunction + +function! ale_linters#markdown#pymarkdown#Handle(buffer, lines) abort + let l:pattern = '\v^(\S*):(\d+):(\d+): ([A-Z]+\d+): (.*)$' + let l:output = [] + " lines are formatted as follows: + " sample.md:1:1: MD022: Headings should be surrounded by blank lines. [Expected: 1; Actual: 0; Below] (blanks-around-headings,blanks-around-headers) + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if(l:match[4] is# 'MD009') + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': l:match[4][0], + \ 'text': l:match[5], + \ 'code': l:match[4], + \} + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('markdown', { +\ 'name': 'pymarkdown', +\ 'executable': function('ale_linters#markdown#pymarkdown#GetExecutable'), +\ 'command': function('ale_linters#markdown#pymarkdown#GetCommand'), +\ 'callback': 'ale_linters#markdown#pymarkdown#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim index ed87d1ad..6085e7ef 100644 --- a/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim +++ b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim @@ -39,7 +39,7 @@ endfunction call ale#linter#Define('markdown', { \ 'name': 'remark_lint', \ 'aliases': ['remark-lint'], -\ 'executable': {b -> ale#node#FindExecutable(b, 'markdown_remark_lint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'markdown_remark_lint', [ \ 'node_modules/.bin/remark', \ ])}, \ 'command': function('ale_linters#markdown#remark_lint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/markdown/vale.vim b/sources_non_forked/ale/ale_linters/markdown/vale.vim index 838c4db2..06a64416 100644 --- a/sources_non_forked/ale/ale_linters/markdown/vale.vim +++ b/sources_non_forked/ale/ale_linters/markdown/vale.vim @@ -1,9 +1,24 @@ " Author: chew-z https://github.com/chew-z " Description: vale for Markdown files +call ale#Set('markdown_vale_executable', 'vale') +call ale#Set('markdown_vale_input_file', '%t') +call ale#Set('markdown_vale_options', '') + +function! ale_linters#markdown#vale#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'markdown_vale_executable') + let l:input_file = ale#Var(a:buffer, 'markdown_vale_input_file') + + " Defaults to `vale --output=JSON %t` + return ale#Escape(l:executable) + \ . ' --output=JSON ' + \ . ale#Var(a:buffer, 'markdown_vale_options') + \ . ' ' . l:input_file +endfunction + call ale#linter#Define('markdown', { \ 'name': 'vale', -\ 'executable': 'vale', -\ 'command': 'vale --output=JSON %t', +\ 'executable': {b -> ale#Var(b, 'markdown_vale_executable')}, +\ 'command': function('ale_linters#markdown#vale#GetCommand'), \ 'callback': 'ale#handlers#vale#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/matlab/mlint.vim b/sources_non_forked/ale/ale_linters/matlab/mlint.vim index f58f8b6d..e7daf37e 100644 --- a/sources_non_forked/ale/ale_linters/matlab/mlint.vim +++ b/sources_non_forked/ale/ale_linters/matlab/mlint.vim @@ -17,7 +17,7 @@ function! ale_linters#matlab#mlint#Handle(buffer, lines) abort let l:code = l:match[3] let l:text = l:match[4] - " Suppress erroneous waring about filename + " Suppress erroneous warning about filename " TODO: Enable this error when copying filename is supported if l:code is# 'FNDEF' continue diff --git a/sources_non_forked/ale/ale_linters/mercury/mmc.vim b/sources_non_forked/ale/ale_linters/mercury/mmc.vim index 8a9ccc0e..85969e10 100644 --- a/sources_non_forked/ale/ale_linters/mercury/mmc.vim +++ b/sources_non_forked/ale/ale_linters/mercury/mmc.vim @@ -5,12 +5,9 @@ call ale#Set('mercury_mmc_executable', 'mmc') call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100') function! ale_linters#mercury#mmc#GetCommand(buffer) abort - let l:module_name = expand('#' . a:buffer . ':t:r') - - return ale#path#BufferCdString(a:buffer) - \ . '%e --errorcheck-only ' + return '%e --errorcheck-only ' \ . ale#Var(a:buffer, 'mercury_mmc_options') - \ . ' ' . l:module_name + \ . ' %s:t:r' endfunction function! ale_linters#mercury#mmc#Handle(buffer, lines) abort @@ -34,6 +31,7 @@ call ale#linter#Define('mercury', { \ 'name': 'mmc', \ 'output_stream': 'stderr', \ 'executable': {b -> ale#Var(b, 'mercury_mmc_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#mercury#mmc#GetCommand'), \ 'callback': 'ale_linters#mercury#mmc#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/nasm/nasm.vim b/sources_non_forked/ale/ale_linters/nasm/nasm.vim index 347abc1b..c4f53629 100644 --- a/sources_non_forked/ale/ale_linters/nasm/nasm.vim +++ b/sources_non_forked/ale/ale_linters/nasm/nasm.vim @@ -7,10 +7,9 @@ call ale#Set('nasm_nasm_options', '') function! ale_linters#nasm#nasm#GetCommand(buffer) abort " Note that NASM requires a trailing slash for the -I option. let l:separator = has('win32') ? '\' : '/' - let l:path = fnamemodify(bufname(a:buffer), ':p:h') . l:separator let l:output_null = has('win32') ? 'NUL' : '/dev/null' - return '%e -X gnu -I ' . ale#Escape(l:path) + return '%e -X gnu -I %s:h' . l:separator \ . ale#Pad(ale#Var(a:buffer, 'nasm_nasm_options')) \ . ' %s' \ . ' -o ' . l:output_null diff --git a/sources_non_forked/ale/ale_linters/nim/nimcheck.vim b/sources_non_forked/ale/ale_linters/nim/nimcheck.vim index b5796dcd..b739ca04 100644 --- a/sources_non_forked/ale/ale_linters/nim/nimcheck.vim +++ b/sources_non_forked/ale/ale_linters/nim/nimcheck.vim @@ -1,6 +1,15 @@ " Author: Baabelfish " Description: Typechecking for nim files +let s:end_col_patterns = [ +\ '\v''([^'']+)'' is declared but not used.*', +\ '\videntifier expected, but found ''([^'']+)''', +\ '\vimported and not used: ''([^'']+)''.*', +\ '\vundeclared identifier: ''([^'']+)''', +\ '\v''([^'']+)'' cannot be assigned to', +\ '\vredefinition of ''([^'']+)'';', +\] + function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p:t') let l:pattern = '^\(.\+\.nim\)(\(\d\+\), \(\d\+\)) \(.\+\)' @@ -43,6 +52,11 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort let l:item.code = l:code_match[2] endif + " Find position end_col. + for l:col_match in ale#util#GetMatches(l:item.text, s:end_col_patterns) + let l:item.end_col = l:item.col + len(l:col_match[1]) - 1 + endfor + call add(l:output, l:item) endfor diff --git a/sources_non_forked/ale/ale_linters/nim/nimlsp.vim b/sources_non_forked/ale/ale_linters/nim/nimlsp.vim new file mode 100644 index 00000000..5d041043 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nim/nimlsp.vim @@ -0,0 +1,33 @@ +" Author: jeremija +" Description: Support for nimlsp (language server for nim) + +call ale#Set('nim_nimlsp_nim_sources', '') + +function! ale_linters#nim#nimlsp#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + + if !empty(l:project_root) + return fnamemodify(l:project_root, ':h:h') + endif + + return '' +endfunction + +function! ale_linters#nim#nimlsp#GetCommand(buffer) abort + let l:nim_sources = ale#Var(a:buffer, 'nim_nimlsp_nim_sources') + + if !empty(l:nim_sources) + let l:nim_sources = ale#Escape(l:nim_sources) + endif + + return '%e' . ale#Pad(l:nim_sources) +endfunction + +call ale#linter#Define('nim', { +\ 'name': 'nimlsp', +\ 'lsp': 'stdio', +\ 'executable': 'nimlsp', +\ 'command': function('ale_linters#nim#nimlsp#GetCommand'), +\ 'language': 'nim', +\ 'project_root': function('ale_linters#nim#nimlsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/nix/deadnix.vim b/sources_non_forked/ale/ale_linters/nix/deadnix.vim new file mode 100644 index 00000000..3e8aec66 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nix/deadnix.vim @@ -0,0 +1,13 @@ +call ale#Set('nix_deadnix_executable', 'deadnix') +call ale#Set('nix_deadnix_options', '') + +function! ale_linters#nix#deadnix#GetCommand(buffer) abort + return '%e -o json' . ale#Pad(ale#Var(a:buffer, 'nix_deadnix_options')) . ' -- %t' +endfunction + +call ale#linter#Define('nix', { +\ 'name': 'deadnix', +\ 'executable': {b -> ale#Var(b, 'nix_deadnix_executable')}, +\ 'command': function('ale_linters#nix#deadnix#GetCommand'), +\ 'callback': 'ale#handlers#deadnix#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/nix/nix.vim b/sources_non_forked/ale/ale_linters/nix/nix.vim index 0a0c5c3e..5d80f652 100644 --- a/sources_non_forked/ale/ale_linters/nix/nix.vim +++ b/sources_non_forked/ale/ale_linters/nix/nix.vim @@ -1,18 +1,51 @@ " Author: Alistair Bill <@alibabzo> +" Author: Maximilian Bosch " Description: nix-instantiate linter for nix files +function! ale_linters#nix#nix#Command(buffer, output, meta) abort + let l:version = a:output[0][22:] + + if l:version =~# '^\(1\|2.[0-3]\.\).*' + return 'nix-instantiate --parse -' + else + return 'nix-instantiate --log-format internal-json --parse -' + endif +endfunction + function! ale_linters#nix#nix#Handle(buffer, lines) abort - let l:pattern = '^\(.\+\): \(.\+\), at .*:\(\d\+\):\(\d\+\)$' let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': l:match[3] + 0, - \ 'col': l:match[4] + 0, - \ 'text': l:match[1] . ': ' . l:match[2], - \ 'type': l:match[1] =~# '^error' ? 'E' : 'W', - \}) - endfor + if empty(a:lines) + return l:output + endif + + if a:lines[0] =~# '^@nix .*' + for l:line in a:lines + if l:line =~# '^@nix .*' + let l:result = json_decode(strpart(l:line, 4)) + + if has_key(l:result, 'column') + call add(l:output, { + \ 'type': 'E', + \ 'lnum': l:result.line, + \ 'col': l:result.column, + \ 'text': l:result.raw_msg + \}) + endif + endif + endfor + else + let l:pattern = '^\(.\+\): \(.\+\) at .*:\(\d\+\):\(\d\+\)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[3] + 0, + \ 'col': l:match[4] + 0, + \ 'text': l:match[1] . ': ' . substitute(l:match[2], ',$', '', ''), + \ 'type': l:match[1] =~# '^error' ? 'E' : 'W', + \}) + endfor + endif return l:output endfunction @@ -21,6 +54,10 @@ call ale#linter#Define('nix', { \ 'name': 'nix', \ 'output_stream': 'stderr', \ 'executable': 'nix-instantiate', -\ 'command': 'nix-instantiate --parse -', +\ 'command': {buffer -> ale#command#Run( +\ buffer, +\ 'nix-instantiate --version', +\ function('ale_linters#nix#nix#Command') +\ )}, \ 'callback': 'ale_linters#nix#nix#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim b/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim new file mode 100644 index 00000000..99c0fbfa --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim @@ -0,0 +1,17 @@ +" Author: jD91mZM2 +" Description: rnix-lsp language client + +function! ale_linters#nix#rnix_lsp#GetProjectRoot(buffer) abort + " rnix-lsp does not yet use the project root, so getting it right is not + " important + return fnamemodify(a:buffer, ':h') +endfunction + +call ale#linter#Define('nix', { +\ 'name': 'rnix_lsp', +\ 'aliases': ['rnix'], +\ 'lsp': 'stdio', +\ 'executable': 'rnix-lsp', +\ 'command': '%e', +\ 'project_root': function('ale_linters#nix#rnix_lsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/nix/statix.vim b/sources_non_forked/ale/ale_linters/nix/statix.vim new file mode 100644 index 00000000..a90a68a6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nix/statix.vim @@ -0,0 +1,18 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: statix analysis and suggestions for Nix files + +call ale#Set('nix_statix_check_executable', 'statix') +call ale#Set('nix_statix_check_options', '') + +function! ale_linters#nix#statix#GetCommand(buffer) abort + return '%e check -o errfmt --stdin' + \ . ale#Pad(ale#Var(a:buffer, 'nix_statix_check_options')) +endfunction + +call ale#linter#Define('nix', { +\ 'name': 'statix', +\ 'executable': {b -> ale#Var(b, 'nix_statix_check_executable')}, +\ 'command': function('ale_linters#nix#statix#GetCommand'), +\ 'callback': 'ale#handlers#statix#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/nunjucks/djlint.vim b/sources_non_forked/ale/ale_linters/nunjucks/djlint.vim new file mode 100644 index 00000000..f71eac6e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nunjucks/djlint.vim @@ -0,0 +1,12 @@ +" Author: Adrian Vollmer +" Description: djlint for Django HTML template files + +call ale#Set('html_djlint_executable', 'djlint') +call ale#Set('html_djlint_options', '') + +call ale#linter#Define('nunjucks', { +\ 'name': 'djlint', +\ 'executable': function('ale#handlers#djlint#GetExecutable'), +\ 'command': function('ale#handlers#djlint#GetCommand'), +\ 'callback': 'ale#handlers#djlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/objc/ccls.vim b/sources_non_forked/ale/ale_linters/objc/ccls.vim index 51ecf056..7aef5325 100644 --- a/sources_non_forked/ale/ale_linters/objc/ccls.vim +++ b/sources_non_forked/ale/ale_linters/objc/ccls.vim @@ -3,6 +3,7 @@ call ale#Set('objc_ccls_executable', 'ccls') call ale#Set('objc_ccls_init_options', {}) +call ale#Set('c_build_dir', '') call ale#linter#Define('objc', { \ 'name': 'ccls', @@ -10,5 +11,5 @@ call ale#linter#Define('objc', { \ 'executable': {b -> ale#Var(b, 'objc_ccls_executable')}, \ 'command': '%e', \ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), -\ 'initialization_options': {b -> ale#Var(b, 'objc_ccls_init_options')}, +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'objc_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/objc/clang.vim b/sources_non_forked/ale/ale_linters/objc/clang.vim index 7873dccd..cafb97db 100644 --- a/sources_non_forked/ale/ale_linters/objc/clang.vim +++ b/sources_non_forked/ale/ale_linters/objc/clang.vim @@ -10,7 +10,7 @@ function! ale_linters#objc#clang#GetCommand(buffer) abort " -iquote with the directory the file is in makes #include work for " headers in the same directory. return 'clang -S -x objective-c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . '-iquote %s:h' \ . ' ' . ale#Var(a:buffer, 'objc_clang_options') . ' -' endfunction diff --git a/sources_non_forked/ale/ale_linters/objcpp/clang.vim b/sources_non_forked/ale/ale_linters/objcpp/clang.vim index 4dbe55b3..35a40c6f 100644 --- a/sources_non_forked/ale/ale_linters/objcpp/clang.vim +++ b/sources_non_forked/ale/ale_linters/objcpp/clang.vim @@ -10,7 +10,7 @@ function! ale_linters#objcpp#clang#GetCommand(buffer) abort " -iquote with the directory the file is in makes #include work for " headers in the same directory. return 'clang++ -S -x objective-c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . '-iquote %s:h' \ . ' ' . ale#Var(a:buffer, 'objcpp_clang_options') . ' -' endfunction diff --git a/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim b/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim new file mode 100644 index 00000000..4ff7419c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim @@ -0,0 +1,13 @@ +" Author: Risto Stevcev +" Description: The official language server for OCaml + +call ale#Set('ocaml_ocamllsp_use_opam', 1) + +call ale#linter#Define('ocaml', { +\ 'name': 'ocamllsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#ocamllsp#GetExecutable'), +\ 'command': function('ale#handlers#ocamllsp#GetCommand'), +\ 'language': function('ale#handlers#ocamllsp#GetLanguage'), +\ 'project_root': function('ale#handlers#ocamllsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/ocaml/ols.vim b/sources_non_forked/ale/ale_linters/ocaml/ols.vim index d8208c52..b26c7826 100644 --- a/sources_non_forked/ale/ale_linters/ocaml/ols.vim +++ b/sources_non_forked/ale/ale_linters/ocaml/ols.vim @@ -6,9 +6,10 @@ call ale#Set('ocaml_ols_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#linter#Define('ocaml', { \ 'name': 'ols', +\ 'aliases': ['ocaml-language-server'], \ 'lsp': 'stdio', \ 'executable': function('ale#handlers#ols#GetExecutable'), \ 'command': function('ale#handlers#ols#GetCommand'), -\ 'language_callback': 'ale#handlers#ols#GetLanguage', +\ 'language': function('ale#handlers#ols#GetLanguage'), \ 'project_root': function('ale#handlers#ols#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim b/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim new file mode 100644 index 00000000..799490f7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim @@ -0,0 +1,17 @@ +" Author: Andrey Popp -- @andreypopp +" Description: Report errors in OCaml code with Merlin + +if !exists('g:merlin') + finish +endif + +function! ale_linters#ocamlinterface#merlin#Handle(buffer, lines) abort + return merlin#ErrorLocList() +endfunction + +call ale#linter#Define('ocamlinterface', { +\ 'name': 'merlin', +\ 'executable': 'ocamlmerlin', +\ 'command': 'true', +\ 'callback': 'ale_linters#ocamlinterface#merlin#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim b/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim new file mode 100644 index 00000000..cd4bea80 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim @@ -0,0 +1,13 @@ +" Author: Risto Stevcev +" Description: The official language server for OCaml + +call ale#Set('ocaml_ocamllsp_use_opam', 1) + +call ale#linter#Define('ocamlinterface', { +\ 'name': 'ocamllsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#ocamllsp#GetExecutable'), +\ 'command': function('ale#handlers#ocamllsp#GetCommand'), +\ 'language': function('ale#handlers#ocamllsp#GetLanguage'), +\ 'project_root': function('ale#handlers#ocamllsp#GetProjectRoot'), +\}) 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 +" 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/openapi/ibm_validator.vim b/sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim new file mode 100644 index 00000000..446931a2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim @@ -0,0 +1,58 @@ +" Author: Horacio Sanson + +call ale#Set('openapi_ibm_validator_executable', 'lint-openapi') +call ale#Set('openapi_ibm_validator_options', '') + +function! ale_linters#openapi#ibm_validator#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'openapi_ibm_validator_options')) + \ . ' %t' +endfunction + +function! ale_linters#openapi#ibm_validator#Handle(buffer, lines) abort + let l:output = [] + let l:type = 'E' + let l:message = '' + let l:nr = -1 + + for l:line in a:lines + let l:match = matchlist(l:line, '^errors$') + + if !empty(l:match) + let l:type = 'E' + endif + + let l:match = matchlist(l:line, '^warnings$') + + if !empty(l:match) + let l:type = 'W' + endif + + let l:match = matchlist(l:line, '^ *Message : *\(.\+\)$') + + if !empty(l:match) + let l:message = l:match[1] + endif + + let l:match = matchlist(l:line, '^ *Line *: *\(\d\+\)$') + + if !empty(l:match) + let l:nr = l:match[1] + + call add(l:output, { + \ 'lnum': l:nr + 0, + \ 'col': 0, + \ 'text': l:message, + \ 'type': l:type, + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('openapi', { +\ 'name': 'ibm_validator', +\ 'executable': {b -> ale#Var(b, 'openapi_ibm_validator_executable')}, +\ 'command': function('ale_linters#openapi#ibm_validator#GetCommand'), +\ 'callback': 'ale_linters#openapi#ibm_validator#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/openapi/yamllint.vim b/sources_non_forked/ale/ale_linters/openapi/yamllint.vim new file mode 100644 index 00000000..2b8952cc --- /dev/null +++ b/sources_non_forked/ale/ale_linters/openapi/yamllint.vim @@ -0,0 +1,9 @@ +call ale#Set('yaml_yamllint_executable', 'yamllint') +call ale#Set('yaml_yamllint_options', '') + +call ale#linter#Define('openapi', { +\ 'name': 'yamllint', +\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')}, +\ 'command': function('ale#handlers#yamllint#GetCommand'), +\ 'callback': 'ale#handlers#yamllint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/openscad/sca2d.vim b/sources_non_forked/ale/ale_linters/openscad/sca2d.vim new file mode 100644 index 00000000..60804a13 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/openscad/sca2d.vim @@ -0,0 +1,24 @@ +" Description: SCA2D linter for OpenSCAD files + +call ale#Set('openscad_sca2d_executable', 'sca2d') +call ale#Set('openscad_sca2d_options', '') + +function! ale_linters#openscad#sca2d#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'openscad_sca2d_executable') +endfunction + +function! ale_linters#openscad#sca2d#GetCommand(buffer) abort + let l:executable = ale_linters#openscad#sca2d#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'openscad_sca2d_options') + + return ale#Escape(l:executable) . ale#Pad(l:options) . ' %s' +endfunction + +call ale#linter#Define('openscad', { +\ 'name': 'SCA2D', +\ 'aliases': ['sca2d'], +\ 'executable': function('ale_linters#openscad#sca2d#GetExecutable'), +\ 'command': function('ale_linters#openscad#sca2d#GetCommand'), +\ 'callback': 'ale#handlers#openscad#SCA2D_callback', +\ 'lint_file': 1, +\ }) diff --git a/sources_non_forked/ale/ale_linters/perl6/perl6.vim b/sources_non_forked/ale/ale_linters/perl6/perl6.vim index 68ef4769..444ae4d7 100644 --- a/sources_non_forked/ale/ale_linters/perl6/perl6.vim +++ b/sources_non_forked/ale/ale_linters/perl6/perl6.vim @@ -88,7 +88,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort try let l:json = json_decode(join(a:lines, '')) - catch /E474/ + catch /E474\|E491/ call add(l:output, { \ 'lnum': '1', \ 'text': 'Received output in the default Perl6 error format. See :ALEDetail for details', diff --git a/sources_non_forked/ale/ale_linters/php/cspell.vim b/sources_non_forked/ale/ale_linters/php/cspell.vim new file mode 100644 index 00000000..574df575 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for PHP files. + +call ale#handlers#cspell#DefineLinter('php') diff --git a/sources_non_forked/ale/ale_linters/php/intelephense.vim b/sources_non_forked/ale/ale_linters/php/intelephense.vim new file mode 100644 index 00000000..0fdcc93e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/intelephense.vim @@ -0,0 +1,32 @@ +" Author: Eric Stern , +" Arnold Chand +" Description: Intelephense language server integration for ALE + +call ale#Set('php_intelephense_executable', 'intelephense') +call ale#Set('php_intelephense_use_global', 1) +call ale#Set('php_intelephense_config', {}) + +function! ale_linters#php#intelephense#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#php#intelephense#GetInitializationOptions(buffer) abort + return ale#Var(a:buffer, 'php_intelephense_config') +endfunction + +call ale#linter#Define('php', { +\ 'name': 'intelephense', +\ 'lsp': 'stdio', +\ 'initialization_options': function('ale_linters#php#intelephense#GetInitializationOptions'), +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_intelephense', [])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#php#intelephense#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/langserver.vim b/sources_non_forked/ale/ale_linters/php/langserver.vim index fdd1bf2b..c3d89a00 100644 --- a/sources_non_forked/ale/ale_linters/php/langserver.vim +++ b/sources_non_forked/ale/ale_linters/php/langserver.vim @@ -19,7 +19,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'langserver', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'php_langserver', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_langserver', [ \ 'vendor/bin/php-language-server.php', \ ])}, \ 'command': 'php %e', diff --git a/sources_non_forked/ale/ale_linters/php/phan.vim b/sources_non_forked/ale/ale_linters/php/phan.vim index 53cb1ea9..50c6d6e6 100644 --- a/sources_non_forked/ale/ale_linters/php/phan.vim +++ b/sources_non_forked/ale/ale_linters/php/phan.vim @@ -39,7 +39,7 @@ function! ale_linters#php#phan#Handle(buffer, lines) abort let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$' else " /path/to/some-filename.php:18 ERRORTYPE message - let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$' + let l:pattern = '^\(.*\):\(\d\+\)\s\(\w\+\)\s\(.\+\)$' endif let l:output = [] @@ -49,13 +49,15 @@ function! ale_linters#php#phan#Handle(buffer, lines) abort let l:dict = { \ 'lnum': l:match[4] + 0, \ 'text': l:match[2], + \ 'filename': l:match[3], \ 'type': 'W', \} else let l:dict = { - \ 'lnum': l:match[1] + 0, - \ 'text': l:match[3], + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[4], \ 'type': 'W', + \ 'filename': l:match[1], \} endif diff --git a/sources_non_forked/ale/ale_linters/php/phpactor.vim b/sources_non_forked/ale/ale_linters/php/phpactor.vim new file mode 100644 index 00000000..b137eaf1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/phpactor.vim @@ -0,0 +1,23 @@ +" Author: Arizard +" Description: PHPactor integration for ALE + +" Copied from langserver.vim +function! ale_linters#php#phpactor#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phpactor', +\ 'lsp': 'stdio', +\ 'executable': 'phpactor', +\ 'command': '%e language-server', +\ 'project_root': function('ale_linters#php#phpactor#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/phpcs.vim b/sources_non_forked/ale/ale_linters/php/phpcs.vim index 11b81e84..ce47a13b 100644 --- a/sources_non_forked/ale/ale_linters/php/phpcs.vim +++ b/sources_non_forked/ale/ale_linters/php/phpcs.vim @@ -13,8 +13,7 @@ function! ale_linters#php#phpcs#GetCommand(buffer) abort \ ? '--standard=' . ale#Escape(l:standard) \ : '' - return ale#path#BufferCdString(a:buffer) - \ . '%e -s --report=emacs --stdin-path=%s' + return '%e -s --report=emacs --stdin-path=%s' \ . ale#Pad(l:standard_option) \ . ale#Pad(ale#Var(a:buffer, 'php_phpcs_options')) endfunction @@ -23,7 +22,7 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort " Matches against lines like the following: " " /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact) - let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\))$' + let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\)).*$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -45,10 +44,11 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpcs', -\ 'executable': {b -> ale#node#FindExecutable(b, 'php_phpcs', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_phpcs', [ \ 'vendor/bin/phpcs', \ 'phpcs' \ ])}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#php#phpcs#GetCommand'), \ 'callback': 'ale_linters#php#phpcs#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/php/phpmd.vim b/sources_non_forked/ale/ale_linters/php/phpmd.vim index 9b1d1e44..368a66c3 100644 --- a/sources_non_forked/ale/ale_linters/php/phpmd.vim +++ b/sources_non_forked/ale/ale_linters/php/phpmd.vim @@ -7,9 +7,9 @@ let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd') let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode') function! ale_linters#php#phpmd#GetCommand(buffer) abort - return '%e %s text' + return '%e %t text' \ . ale#Pad(ale#Var(a:buffer, 'php_phpmd_ruleset')) - \ . ' --ignore-violations-on-exit %t' + \ . ' --ignore-violations-on-exit' endfunction function! ale_linters#php#phpmd#Handle(buffer, lines) abort diff --git a/sources_non_forked/ale/ale_linters/php/phpstan.vim b/sources_non_forked/ale/ale_linters/php/phpstan.vim index 78f7dd10..d3c80393 100644 --- a/sources_non_forked/ale/ale_linters/php/phpstan.vim +++ b/sources_non_forked/ale/ale_linters/php/phpstan.vim @@ -1,4 +1,4 @@ -" Author: medains , ardis +" Author: medains , ardis , Arizard " Description: phpstan for PHP files " Set to change the ruleset @@ -6,6 +6,8 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '') let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '') let g:ale_php_phpstan_autoload = get(g:, 'ale_php_phpstan_autoload', '') +let g:ale_php_phpstan_memory_limit = get(g:, 'ale_php_phpstan_memory_limit', '') +call ale#Set('php_phpstan_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#phpstan#GetCommand(buffer, version) abort let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration') @@ -18,10 +20,14 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort \ ? ' -a ' . ale#Escape(l:autoload) \ : '' - let l:level = ale#Var(a:buffer, 'php_phpstan_level') - let l:config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon') + let l:memory_limit = ale#Var(a:buffer, 'php_phpstan_memory_limit') + let l:memory_limit_option = !empty(l:memory_limit) + \ ? ' --memory-limit=' . ale#Escape(l:memory_limit) + \ : '' - if empty(l:level) && empty(l:config_file_exists) + let l:level = ale#Var(a:buffer, 'php_phpstan_level') + + if empty(l:level) && empty(ale_linters#php#phpstan#FindConfigFile(a:buffer)) " if no configuration file is found, then use 4 as a default level let l:level = '4' endif @@ -31,44 +37,70 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort \ : '' let l:error_format = ale#semver#GTE(a:version, [0, 10, 3]) - \ ? ' --error-format raw' - \ : ' --errorFormat raw' + \ ? ' --error-format json' + \ : ' --errorFormat json' return '%e analyze --no-progress' \ . l:error_format \ . l:configuration_option \ . l:autoload_option \ . l:level_option + \ . l:memory_limit_option \ . ' %s' endfunction function! ale_linters#php#phpstan#Handle(buffer, lines) abort - " Matches against lines like the following: - " - " filename.php:15:message - " C:\folder\filename.php:15:message - let l:pattern = '^\([a-zA-Z]:\)\?[^:]\+:\(\d\+\):\(.*\)$' + let l:res = ale#util#FuzzyJSONDecode(a:lines, {'files': []}) let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'text': l:match[3], - \ 'type': 'E', - \}) + if type(l:res.files) is v:t_list + return l:output + endif + + 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 endfunction +function! ale_linters#php#phpstan#GetCwd(buffer) abort + let l:result = ale#path#Dirname(ale_linters#php#phpstan#FindConfigFile(a:buffer)) + + return empty(l:result) ? v:null : l:result +endfunction + +function! ale_linters#php#phpstan#FindConfigFile(buffer) abort + let l:result = ale#path#FindNearestFile(a:buffer, 'phpstan.neon') + + if empty(l:result) + let l:result = ale#path#FindNearestFile(a:buffer, 'phpstan.neon.dist') + endif + + return l:result +endfunction + call ale#linter#Define('php', { \ 'name': 'phpstan', -\ 'executable': {b -> ale#Var(b, 'php_phpstan_executable')}, +\ 'executable': {buffer -> ale#path#FindExecutable(buffer, 'php_phpstan', [ +\ 'vendor/bin/phpstan', +\ 'phpstan' +\ ])}, \ 'command': {buffer -> ale#semver#RunWithVersionCheck( \ buffer, -\ ale#Var(buffer, 'php_phpstan_executable'), +\ ale#path#FindExecutable(buffer, 'php_phpstan', [ +\ 'vendor/bin/phpstan', +\ 'phpstan' +\ ]), \ '%e --version', \ function('ale_linters#php#phpstan#GetCommand'), \ )}, \ 'callback': 'ale_linters#php#phpstan#Handle', +\ 'cwd': function('ale_linters#php#phpstan#GetCwd'), \}) diff --git a/sources_non_forked/ale/ale_linters/php/psalm.vim b/sources_non_forked/ale/ale_linters/php/psalm.vim index 3cdb026a..f1280057 100644 --- a/sources_non_forked/ale/ale_linters/php/psalm.vim +++ b/sources_non_forked/ale/ale_linters/php/psalm.vim @@ -1,21 +1,32 @@ " Author: Matt Brown " Description: plugin for Psalm, static analyzer for PHP -call ale#Set('psalm_langserver_executable', 'psalm-language-server') -call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_psalm_executable', 'psalm') +call ale#Set('php_psalm_options', '') +call ale#Set('php_psalm_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#psalm#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' endfunction +function! ale_linters#php#psalm#GetCommand(buffer) abort + return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'php_psalm_options')) +endfunction + call ale#linter#Define('php', { \ 'name': 'psalm', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [ -\ 'vendor/bin/psalm-language-server', +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_psalm', [ +\ 'vendor/bin/psalm', \ ])}, -\ 'command': '%e', +\ 'command': function('ale_linters#php#psalm#GetCommand'), \ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/php/tlint.vim b/sources_non_forked/ale/ale_linters/php/tlint.vim new file mode 100644 index 00000000..80bdd1f6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/tlint.vim @@ -0,0 +1,80 @@ +" Author: Jose Soto +" +" Description: Tighten Opinionated PHP Linting +" Website: https://github.com/tightenco/tlint + +call ale#Set('php_tlint_executable', 'tlint') +call ale#Set('php_tlint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_tlint_options', '') + +function! ale_linters#php#tlint#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if !empty(l:composer_path) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#php#tlint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'php_tlint', [ + \ 'vendor/bin/tlint', + \ 'tlint', + \]) +endfunction + +function! ale_linters#php#tlint#GetCommand(buffer) abort + let l:executable = ale_linters#php#tlint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'php_tlint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' lint %s' +endfunction + +function! ale_linters#php#tlint#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " ! There should be 1 space around `.` concatenations, and additional lines should always start with a `.` + " 22 : ` $something = 'a'.'name';` + " + let l:loop_count = 0 + let l:messages_pattern = '^\! \(.*\)' + let l:output = [] + let l:pattern = '^\(\d\+\) \:' + let l:temp_messages = [] + + for l:message in ale#util#GetMatches(a:lines, l:messages_pattern) + call add(l:temp_messages, l:message) + endfor + + let l:loop_count = 0 + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:num = l:match[1] + let l:text = l:temp_messages[l:loop_count] + + call add(l:output, { + \ 'lnum': l:num, + \ 'col': 0, + \ 'text': l:text, + \ 'type': 'W', + \ 'sub_type': 'style', + \}) + + let l:loop_count += 1 + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'tlint', +\ 'executable': function('ale_linters#php#tlint#GetExecutable'), +\ 'command': function('ale_linters#php#tlint#GetCommand'), +\ 'callback': 'ale_linters#php#tlint#Handle', +\ 'project_root': function('ale_linters#php#tlint#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/powershell/cspell.vim b/sources_non_forked/ale/ale_linters/powershell/cspell.vim new file mode 100644 index 00000000..4a66dbaa --- /dev/null +++ b/sources_non_forked/ale/ale_linters/powershell/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for PowerShell files. + +call ale#handlers#cspell#DefineLinter('powershell') diff --git a/sources_non_forked/ale/ale_linters/powershell/powershell.vim b/sources_non_forked/ale/ale_linters/powershell/powershell.vim index a63191fd..5f49f72c 100644 --- a/sources_non_forked/ale/ale_linters/powershell/powershell.vim +++ b/sources_non_forked/ale/ale_linters/powershell/powershell.vim @@ -12,6 +12,7 @@ endfunction " https://rkeithhill.wordpress.com/2007/10/30/powershell-quicktip-preparsing-scripts-to-check-for-syntax-errors/ function! ale_linters#powershell#powershell#GetCommand(buffer) abort let l:script = ['Param($Script); + \ $ErrorView = "Normal"; \ trap {$_;continue} & { \ $Contents = Get-Content -Path $Script; \ $Contents = [string]::Join([Environment]::NewLine, $Contents); diff --git a/sources_non_forked/ale/ale_linters/powershell/psscriptanalyzer.vim b/sources_non_forked/ale/ale_linters/powershell/psscriptanalyzer.vim index 4794d9d8..8a8b4b45 100644 --- a/sources_non_forked/ale/ale_linters/powershell/psscriptanalyzer.vim +++ b/sources_non_forked/ale/ale_linters/powershell/psscriptanalyzer.vim @@ -13,7 +13,7 @@ function! ale_linters#powershell#psscriptanalyzer#GetExecutable(buffer) abort return ale#Var(a:buffer, 'powershell_psscriptanalyzer_executable') endfunction -" Run Invoke-ScriptAnalyzer and output each linting message as 4 seperate lines +" Run Invoke-ScriptAnalyzer and output each linting message as 4 separate lines " for each parsing function! ale_linters#powershell#psscriptanalyzer#GetCommand(buffer) abort let l:exclude_option = ale#Var( diff --git a/sources_non_forked/ale/ale_linters/prolog/swipl.vim b/sources_non_forked/ale/ale_linters/prolog/swipl.vim index 5c601c40..82859eb0 100644 --- a/sources_non_forked/ale/ale_linters/prolog/swipl.vim +++ b/sources_non_forked/ale/ale_linters/prolog/swipl.vim @@ -35,10 +35,11 @@ function! s:Subst(format, vars) abort endfunction function! ale_linters#prolog#swipl#Handle(buffer, lines) abort - let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$' let l:output = [] let l:i = 0 + let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$' + while l:i < len(a:lines) let l:match = matchlist(a:lines[l:i], l:pattern) @@ -72,8 +73,17 @@ function! s:GetErrMsg(i, lines, text) abort let l:i = a:i + 1 let l:text = [] - while l:i < len(a:lines) && a:lines[l:i] =~# '^\s' - call add(l:text, s:Trim(a:lines[l:i])) + let l:pattern = '\v^(ERROR|Warning)?:?(.*)$' + + while l:i < len(a:lines) + let l:match = matchlist(a:lines[l:i], l:pattern) + + if empty(l:match) || empty(l:match[2]) + let l:i += 1 + break + endif + + call add(l:text, s:Trim(l:match[2])) let l:i += 1 endwhile diff --git a/sources_non_forked/ale/ale_linters/proto/buf_lint.vim b/sources_non_forked/ale/ale_linters/proto/buf_lint.vim new file mode 100644 index 00000000..a22f8e53 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/proto/buf_lint.vim @@ -0,0 +1,26 @@ +" Author: Alex McKinney +" Description: Run buf lint. + +call ale#Set('proto_buf_lint_executable', 'buf') +call ale#Set('proto_buf_lint_config', '') +call ale#Set('proto_buf_lint_options', '') + +function! ale_linters#proto#buf_lint#GetCommand(buffer) abort + let l:config = ale#Var(a:buffer, 'proto_buf_lint_config') + let l:options = ale#Var(a:buffer, 'proto_buf_lint_options') + + return '%e lint' + \ . (!empty(l:config) ? ' --config=' . ale#Escape(l:config) : '') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %s#include_package_files=true' +endfunction + +call ale#linter#Define('proto', { +\ 'name': 'buf_lint', +\ 'aliases': ['buf-lint'], +\ 'lint_file': 1, +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'proto_buf_lint_executable')}, +\ 'command': function('ale_linters#proto#buf_lint#GetCommand'), +\ 'callback': 'ale#handlers#go#Handler', +\}) diff --git a/sources_non_forked/ale/ale_linters/proto/protolint.vim b/sources_non_forked/ale/ale_linters/proto/protolint.vim new file mode 100644 index 00000000..2754c7b6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/proto/protolint.vim @@ -0,0 +1,24 @@ +" Author: Yohei Yoshimuta +" Description: run the protolint for Protocol Buffer files + +call ale#Set('proto_protolint_executable', 'protolint') +call ale#Set('proto_protolint_config', '') + +function! ale_linters#proto#protolint#GetCommand(buffer) abort + let l:config = ale#Var(a:buffer, 'proto_protolint_config') + + return '%e lint' + \ . (!empty(l:config) ? ' -config_path=' . ale#Escape(l:config) : '') + \ . ' -reporter=unix' + \ . ' %s' +endfunction + +call ale#linter#Define('proto', { +\ 'name': 'protolint', +\ 'lint_file': 1, +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'proto_protolint_executable')}, +\ 'command': function('ale_linters#proto#protolint#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsError', +\}) + diff --git a/sources_non_forked/ale/ale_linters/pug/puglint.vim b/sources_non_forked/ale/ale_linters/pug/puglint.vim index c819cc45..b552cc06 100644 --- a/sources_non_forked/ale/ale_linters/pug/puglint.vim +++ b/sources_non_forked/ale/ale_linters/pug/puglint.vim @@ -47,7 +47,7 @@ endfunction call ale#linter#Define('pug', { \ 'name': 'puglint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'pug_puglint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'pug_puglint', [ \ 'node_modules/.bin/pug-lint', \ ])}, \ 'output_stream': 'stderr', diff --git a/sources_non_forked/ale/ale_linters/puppet/languageserver.vim b/sources_non_forked/ale/ale_linters/puppet/languageserver.vim index 2078695f..c6b12662 100644 --- a/sources_non_forked/ale/ale_linters/puppet/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/puppet/languageserver.vim @@ -29,6 +29,7 @@ endfunction call ale#linter#Define('puppet', { \ 'name': 'languageserver', +\ 'aliases': ['puppet_languageserver'], \ 'lsp': 'stdio', \ 'executable': {b -> ale#Var(b, 'puppet_languageserver_executable')}, \ 'command': '%e --stdio', diff --git a/sources_non_forked/ale/ale_linters/puppet/puppet.vim b/sources_non_forked/ale/ale_linters/puppet/puppet.vim index ae648615..59228dc8 100644 --- a/sources_non_forked/ale/ale_linters/puppet/puppet.vim +++ b/sources_non_forked/ale/ale_linters/puppet/puppet.vim @@ -8,13 +8,15 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort " Error: Could not parse for environment production: Syntax error at ':' at /root/puppetcode/modules/nginx/manifests/init.pp:43:12 " Error: Could not parse for environment production: Syntax error at '='; expected '}' at /root/puppetcode/modules/pancakes/manifests/init.pp:5" " Error: Could not parse for environment production: Syntax error at 'parameter1' (file: /tmp/modules/mariadb/manifests/slave.pp, line: 4, column: 5) - let l:pattern = '^Error: .*: \(.\+\) \((file:\|at\) .\+\.pp\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)' + " Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11) + " Error: Could not parse for environment production: Syntax error at end of input (file: /tmp/modules/bob/manifests/init.pp) + let l:pattern = '^Error:\%(.*:\)\? \(.\+\) \((file:\|at\) .\+\.pp\(\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)\|)$\)' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': l:match[4] + 0, - \ 'col': l:match[6] + 0, + \ 'lnum': l:match[5] + 0, + \ 'col': l:match[7] + 0, \ 'text': l:match[1], \}) endfor diff --git a/sources_non_forked/ale/ale_linters/purescript/ls.vim b/sources_non_forked/ale/ale_linters/purescript/ls.vim index 1c5f937f..1eaf2af7 100644 --- a/sources_non_forked/ale/ale_linters/purescript/ls.vim +++ b/sources_non_forked/ale/ale_linters/purescript/ls.vim @@ -6,7 +6,7 @@ call ale#Set('purescript_ls_use_global', get(g:, 'ale_use_global_executables', 0 call ale#Set('purescript_ls_config', {}) function! ale_linters#purescript#ls#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'purescript_ls', [ + return ale#path#FindExecutable(a:buffer, 'purescript_ls', [ \ 'node_modules/.bin/purescript-language-server', \]) endfunction @@ -41,6 +41,7 @@ endfunction call ale#linter#Define('purescript', { \ 'name': 'purescript-language-server', +\ 'aliases': ['purescriptls'], \ 'lsp': 'stdio', \ 'executable': function('ale_linters#purescript#ls#GetExecutable'), \ 'command': function('ale_linters#purescript#ls#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/pyrex/cython.vim b/sources_non_forked/ale/ale_linters/pyrex/cython.vim index 84382ba1..247c3060 100644 --- a/sources_non_forked/ale/ale_linters/pyrex/cython.vim +++ b/sources_non_forked/ale/ale_linters/pyrex/cython.vim @@ -6,9 +6,7 @@ call ale#Set('pyrex_cython_executable', 'cython') call ale#Set('pyrex_cython_options', '--warning-extra') function! ale_linters#pyrex#cython#GetCommand(buffer) abort - let l:local_dir = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - - return '%e --working ' . l:local_dir . ' --include-dir ' . l:local_dir + return '%e --working %s:h --include-dir %s:h' \ . ale#Pad(ale#Var(a:buffer, 'pyrex_cython_options')) \ . ' --output-file ' . g:ale#util#nul_file . ' %t' endfunction diff --git a/sources_non_forked/ale/ale_linters/python/bandit.vim b/sources_non_forked/ale/ale_linters/python/bandit.vim index 554f5000..b343a1c5 100644 --- a/sources_non_forked/ale/ale_linters/python/bandit.vim +++ b/sources_non_forked/ale/ale_linters/python/bandit.vim @@ -6,6 +6,8 @@ call ale#Set('python_bandit_options', '') 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 ( @@ -15,6 +17,18 @@ function! ale_linters#python#bandit#GetExecutable(buffer) abort return 'pipenv' endif + if ( + \ ale#Var(a:buffer, 'python_auto_poetry') + \ || ale#Var(a:buffer, 'python_bandit_auto_poetry') + \) && ale#python#PoetryPresent(a:buffer) + 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 @@ -31,7 +45,7 @@ function! ale_linters#python#bandit#GetCommand(buffer) abort endif endif - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run bandit' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/cspell.vim b/sources_non_forked/ale/ale_linters/python/cspell.vim new file mode 100644 index 00000000..a2325311 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Python files. + +call ale#handlers#cspell#DefineLinter('python') diff --git a/sources_non_forked/ale/ale_linters/python/flake8.vim b/sources_non_forked/ale/ale_linters/python/flake8.vim index e2e7b743..2685f61a 100644 --- a/sources_non_forked/ale/ale_linters/python/flake8.vim +++ b/sources_non_forked/ale/ale_linters/python/flake8.vim @@ -4,8 +4,10 @@ call ale#Set('python_flake8_executable', 'flake8') call ale#Set('python_flake8_options', '') call ale#Set('python_flake8_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('python_flake8_change_directory', 1) +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' @@ -17,6 +19,16 @@ function! ale_linters#python#flake8#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_flake8_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 @@ -38,13 +50,31 @@ function! ale_linters#python#flake8#RunWithVersionCheck(buffer) abort \) endfunction +function! ale_linters#python#flake8#GetCwd(buffer) abort + let l:change_directory = ale#Var(a:buffer, 'python_flake8_change_directory') + let l:cwd = '' + + if l:change_directory is# 'project' + let l:project_root = ale#python#FindProjectRootIni(a:buffer) + + if !empty(l:project_root) + let l:cwd = l:project_root + endif + endif + + if (l:change_directory is# 'project' && empty(l:cwd)) + \|| l:change_directory is# 1 + \|| l:change_directory is# 'file' + let l:cwd = '%s:h' + endif + + return l:cwd +endfunction + function! ale_linters#python#flake8#GetCommand(buffer, version) abort - let l:cd_string = ale#Var(a:buffer, 'python_flake8_change_directory') - \ ? ale#path#BufferCdString(a:buffer) - \ : '' let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run flake8' \ : '' @@ -56,8 +86,7 @@ function! ale_linters#python#flake8#GetCommand(buffer, version) abort let l:options = ale#Var(a:buffer, 'python_flake8_options') - return l:cd_string - \ . ale#Escape(l:executable) . l:exec_args + return ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --format=default' \ . l:display_name_args . ' -' @@ -141,6 +170,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'flake8', \ 'executable': function('ale_linters#python#flake8#GetExecutable'), +\ 'cwd': function('ale_linters#python#flake8#GetCwd'), \ 'command': function('ale_linters#python#flake8#RunWithVersionCheck'), \ 'callback': 'ale_linters#python#flake8#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/python/flakehell.vim b/sources_non_forked/ale/ale_linters/python/flakehell.vim new file mode 100644 index 00000000..a5b466b8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/flakehell.vim @@ -0,0 +1,181 @@ +" Author: w0rp +" Description: flakehell for python files + +call ale#Set('python_flakehell_executable', 'flakehell') +call ale#Set('python_flakehell_options', '') +call ale#Set('python_flakehell_use_global', get(g:, 'ale_use_global_executables', 0)) +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' +endfunction + +function! ale_linters#python#flakehell#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_flakehell_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_flakehell_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 + + return ale#Var(a:buffer, 'python_flakehell_executable') +endfunction + +function! ale_linters#python#flakehell#RunWithVersionCheck(buffer) abort + let l:executable = ale_linters#python#flakehell#GetExecutable(a:buffer) + + let l:module_string = s:UsingModule(a:buffer) ? ' -m flakehell' : '' + let l:command = ale#Escape(l:executable) . l:module_string . ' --version' + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale_linters#python#flakehell#GetCommand'), + \) +endfunction + +function! ale_linters#python#flakehell#GetCwd(buffer) abort + let l:change_directory = ale#Var(a:buffer, 'python_flakehell_change_directory') + let l:cwd = '' + + if l:change_directory is# 'project' + let l:project_root = ale#python#FindProjectRootIni(a:buffer) + + if !empty(l:project_root) + let l:cwd = l:project_root + endif + endif + + if (l:change_directory is# 'project' && empty(l:cwd)) + \|| l:change_directory is# 1 + \|| l:change_directory is# 'file' + let l:cwd = '%s:h' + endif + + return l:cwd +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\|uv\)$') + let l:exec_args = ' run flakehell' + elseif (l:executable is? 'python') + let l:exec_args = ' -m flakehell' + else + let l:exec_args = '' + endif + + " Only include the --stdin-display-name argument if we can parse the + " flakehell version, and it is recent enough to support it. + let l:display_name_args = ale#semver#GTE(a:version, [0, 8, 0]) + \ ? ' --stdin-display-name %s' + \ : '' + + let l:options = ale#Var(a:buffer, 'python_flakehell_options') + + return ale#Escape(l:executable) + \ . l:exec_args + \ . (!empty(l:options) ? ' lint ' . l:options : ' lint') + \ . ' --format=default' + \ . l:display_name_args . ' -' +endfunction + +let s:end_col_pattern_map = { +\ 'F405': '\(.\+\) may be undefined', +\ 'F821': 'undefined name ''\([^'']\+\)''', +\ 'F999': '^''\([^'']\+\)''', +\ 'F841': 'local variable ''\([^'']\+\)''', +\} + +function! ale_linters#python#flakehell#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + + " Matches patterns line the following: + " + " Matches patterns line the following: + " + " stdin:6:6: E111 indentation is not a multiple of four + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: ([[:alnum:]]+):? (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[3] + + if (l:code is# 'W291' || l:code is# 'W293') + \ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if l:code is# 'W391' + \&& !ale#Var(a:buffer, 'warn_about_trailing_blank_lines') + " Skip warnings for trailing blank lines if the option is off + continue + endif + + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'vcol': 1, + \ 'text': l:match[4], + \ 'code': l:code, + \ 'type': 'W', + \} + + if l:code[:0] is# 'F' + if l:code isnot# 'F401' + let l:item.type = 'E' + endif + elseif l:code[:0] is# 'E' + let l:item.type = 'E' + + if l:code isnot# 'E999' && l:code isnot# 'E112' + let l:item.sub_type = 'style' + endif + elseif l:code[:0] is# 'W' + let l:item.sub_type = 'style' + endif + + let l:end_col_pattern = get(s:end_col_pattern_map, l:code, '') + + if !empty(l:end_col_pattern) + let l:end_col_match = matchlist(l:match[4], l:end_col_pattern) + + if !empty(l:end_col_match) + let l:item.end_col = l:item.col + len(l:end_col_match[1]) - 1 + endif + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'flakehell', +\ 'executable': function('ale_linters#python#flakehell#GetExecutable'), +\ 'cwd': function('ale_linters#python#flakehell#GetCwd'), +\ 'command': function('ale_linters#python#flakehell#RunWithVersionCheck'), +\ 'callback': 'ale_linters#python#flakehell#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/jedils.vim b/sources_non_forked/ale/ale_linters/python/jedils.vim new file mode 100644 index 00000000..2d4a97c3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/jedils.vim @@ -0,0 +1,51 @@ +" Author: Dalius Dobravolskas +" Description: https://github.com/pappasam/jedi-language-server + +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')) + \ && ale#python#PipenvPresent(a:buffer) + 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\|poetry\|uv\)$' + \ ? ' run jedi-language-server' + \ : '' + let l:env_string = '' + + if ale#Var(a:buffer, 'python_auto_virtualenv') + let l:env_string = ale#python#AutoVirtualenvEnvString(a:buffer) + endif + + return l:env_string . ale#Escape(l:executable) . l:exec_args +endfunction + +call ale#linter#Define('python', { +\ 'name': 'jedils', +\ 'aliases': ['jedi_language_server'], +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#python#jedils#GetExecutable'), +\ 'command': function('ale_linters#python#jedils#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/mypy.vim b/sources_non_forked/ale/ale_linters/python/mypy.vim index dc4044e6..27d2726b 100644 --- a/sources_non_forked/ale/ale_linters/python/mypy.vim +++ b/sources_non_forked/ale/ale_linters/python/mypy.vim @@ -3,9 +3,12 @@ call ale#Set('python_mypy_executable', 'mypy') call ale#Set('python_mypy_ignore_invalid_syntax', 0) +call ale#Set('python_mypy_show_notes', 1) 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')) @@ -13,11 +16,30 @@ function! ale_linters#python#mypy#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_mypy_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 " The directory to change to before running mypy -function! s:GetDir(buffer) abort +function! ale_linters#python#mypy#GetCwd(buffer) abort + " If we find a directory with "mypy.ini" in it use that, + " else try and find the "python project" root, or failing + " that, run from the same folder as the current file + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + if filereadable(l:path . '/mypy.ini') + return l:path + endif + endfor + let l:project_root = ale#python#FindProjectRoot(a:buffer) return !empty(l:project_root) @@ -26,24 +48,19 @@ function! s:GetDir(buffer) abort endfunction function! ale_linters#python#mypy#GetCommand(buffer) abort - let l:dir = s:GetDir(a:buffer) let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer) - - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run mypy' \ : '' - " We have to always switch to an explicit directory for a command so - " we can know with certainty the base path for the 'filename' keys below. - return ale#path#CdString(l:dir) - \ . ale#Escape(l:executable) . l:exec_args - \ . ' --show-column-numbers ' - \ . ale#Var(a:buffer, 'python_mypy_options') + return '%e' . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_mypy_options')) + \ . ' --show-column-numbers' \ . ' --shadow-file %s %t %s' endfunction function! ale_linters#python#mypy#Handle(buffer, lines) abort - let l:dir = s:GetDir(a:buffer) + let l:dir = ale_linters#python#mypy#GetCwd(a:buffer) " Look for lines like the following: " " file.py:4: error: No library stub file for module 'django.db' @@ -51,7 +68,16 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort " Lines like these should be ignored below: " " file.py:4: note: (Stub files are from https://github.com/python/typeshed) - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: (error|warning): (.+)$' + + let l:types = 'error|warning' + + if ale#Var(a:buffer, 'python_mypy_show_notes') + let l:types = 'error|warning|note' + endif + + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: (' + \ . l:types + \ . '): (.+)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -65,7 +91,7 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), \ 'lnum': l:match[2] + 0, \ 'col': l:match[3] + 0, - \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'type': l:match[4] is# 'error' ? 'E' : (l:match[4] is# 'note' ? 'I': 'W'), \ 'text': l:match[5], \}) endfor @@ -76,6 +102,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'mypy', \ 'executable': function('ale_linters#python#mypy#GetExecutable'), +\ 'cwd': function('ale_linters#python#mypy#GetCwd'), \ 'command': function('ale_linters#python#mypy#GetCommand'), \ 'callback': 'ale_linters#python#mypy#Handle', \ 'output_stream': 'both' diff --git a/sources_non_forked/ale/ale_linters/python/prospector.vim b/sources_non_forked/ale/ale_linters/python/prospector.vim index ee47012f..29aad060 100644 --- a/sources_non_forked/ale/ale_linters/python/prospector.vim +++ b/sources_non_forked/ale/ale_linters/python/prospector.vim @@ -2,6 +2,8 @@ " Description: prospector linter python files 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') @@ -17,13 +19,23 @@ function! ale_linters#python#prospector#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_prospector_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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$' + 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 new file mode 100644 index 00000000..23d48676 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pycln.vim @@ -0,0 +1,92 @@ +" Author: Yining +" Description: pycln as linter for python files + +call ale#Set('python_pycln_executable', 'pycln') +call ale#Set('python_pycln_options', '') +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 + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycln_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pycln_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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_linters#python#pycln#GetCwd(buffer) abort + if ale#Var(a:buffer, 'python_pycln_change_directory') + " Run from project root if found, else from buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '' +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\|uv\)$' + \ ? ' run pycln' + \ : '' + + let l:options = ale#Var(a:buffer, 'python_pycln_options') + let l:config_file = ale#Var(a:buffer, 'python_pycln_config_file') + let l:config_file = l:options !~# '\v(^| )--config ' && !empty(l:config_file) + \ ? ale#Escape(ale#path#Simplify(l:config_file)) + \ : '' + + " NOTE: pycln version `1.3.0` supports liniting input from stdin + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_pycln_options')) + \ . (empty(l:config_file) ? '' : ' --config ' . l:config_file) + \ . ' --check' + \ . (ale#semver#GTE(a:version, [1, 3, 0]) ? ' -' : ' %s') +endfunction + +function! ale_linters#python#pycln#Handle(buffer, lines) abort + " Example: tmp/test.py:3:0 'import os' would be removed! + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pycln', +\ 'executable': function('ale_linters#python#pycln#GetExecutable'), +\ 'cwd': function('ale_linters#python#pycln#GetCwd'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#python#pycln#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#python#pycln#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#python#pycln#Handle', +\ 'output_stream': 'both', +\ 'read_buffer': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim index fb521bc1..282e545b 100644 --- a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim @@ -5,6 +5,8 @@ call ale#Set('python_pycodestyle_executable', 'pycodestyle') 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')) @@ -12,13 +14,23 @@ function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pycodestyle_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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$' + 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 3901db4d..6293df7b 100644 --- a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim @@ -5,6 +5,8 @@ call ale#Set('python_pydocstyle_executable', 'pydocstyle') 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')) @@ -12,21 +14,28 @@ function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pydocstyle_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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:dir = fnamemodify(bufname(a:buffer), ':p:h') let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer) - - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pydocstyle' \ : '' - return ale#path#CdString(l:dir) - \ . ale#Escape(l:executable) . l:exec_args - \ . ' ' . ale#Var(a:buffer, 'python_pydocstyle_options') - \ . ' ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:t')) + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_pydocstyle_options')) + \ . ' %s' endfunction function! ale_linters#python#pydocstyle#Handle(buffer, lines) abort @@ -68,6 +77,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pydocstyle', \ 'executable': function('ale_linters#python#pydocstyle#GetExecutable'), +\ 'cwd': '%s:h', \ 'command': function('ale_linters#python#pydocstyle#GetCommand'), \ 'callback': 'ale_linters#python#pydocstyle#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/python/pyflakes.vim b/sources_non_forked/ale/ale_linters/python/pyflakes.vim index b5127022..f46772dc 100644 --- a/sources_non_forked/ale/ale_linters/python/pyflakes.vim +++ b/sources_non_forked/ale/ale_linters/python/pyflakes.vim @@ -4,6 +4,8 @@ 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')) @@ -11,13 +13,23 @@ function! ale_linters#python#pyflakes#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflakes_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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$' + 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 38dd2836..626974f8 100644 --- a/sources_non_forked/ale/ale_linters/python/pylama.vim +++ b/sources_non_forked/ale/ale_linters/python/pylama.vim @@ -5,6 +5,8 @@ call ale#Set('python_pylama_executable', 'pylama') 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 @@ -13,43 +15,75 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylama_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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#GetCommand(buffer) abort - let l:cd_string = '' +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\|uv\)$' + \ ? ' run pylama' + \ : '' + let l:command = ale#Escape(l:executable) . l:exec_args . ' --version' + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale_linters#python#pylama#GetCommand'), + \) +endfunction + +function! ale_linters#python#pylama#GetCwd(buffer) abort if ale#Var(a:buffer, 'python_pylama_change_directory') " Pylama loads its configuration from the current directory only, and " applies file masks using paths relative to the current directory. " Run from project root, if found, otherwise buffer dir. let l:project_root = ale#python#FindProjectRoot(a:buffer) - let l:cd_string = l:project_root isnot# '' - \ ? ale#path#CdString(l:project_root) - \ : ale#path#BufferCdString(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' endif + return '' +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$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pylama' \ : '' + " json format is added in version 8.1.4 + " https://github.com/klen/pylama/blob/develop/Changelog + let l:format_json_args = ale#semver#GTE(a:version, [8, 1, 4]) + \ ? ' --format json' + \ : '' + " Note: Using %t to lint changes would be preferable, but many pylama " checks use surrounding paths (e.g. C0103 module name, E0402 relative " import beyond top, etc.). Neither is ideal. - return l:cd_string - \ . ale#Escape(l:executable) . l:exec_args + return ale#Escape(l:executable) . l:exec_args \ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options')) + \ . l:format_json_args \ . ' %s' endfunction -function! ale_linters#python#pylama#Handle(buffer, lines) abort +function! ale_linters#python#pylama#Handle(buffer, version, lines) abort if empty(a:lines) return [] endif let l:output = ale#python#HandleTraceback(a:lines, 1) - let l:pattern = '\v^.{-}:([0-9]+):([0-9]+): +%(([A-Z][0-9]+):? +)?(.*)$' " First letter of error code is a pylint-compatible message type " http://pylint.pycqa.org/en/latest/user_guide/output.html#source-code-analysis-section @@ -69,16 +103,41 @@ function! ale_linters#python#pylama#Handle(buffer, lines) abort \ 'D': 'style', \} - for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': str2nr(l:match[1]), - \ 'col': str2nr(l:match[2]), - \ 'code': l:match[3], - \ 'type': get(l:pylint_type_to_ale_type, l:match[3][0], 'W'), - \ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:match[3][0], ''), - \ 'text': l:match[4], - \}) - endfor + if ale#semver#GTE(a:version, [8, 1, 4]) + try + let l:errors = json_decode(join(a:lines, '')) + catch + return l:output + endtry + + if empty(l:errors) + return l:output + endif + + for l:error in l:errors + call add(l:output, { + \ 'lnum': l:error['lnum'], + \ 'col': l:error['col'], + \ 'code': l:error['number'], + \ 'type': get(l:pylint_type_to_ale_type, l:error['etype'], 'W'), + \ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:error['etype'], ''), + \ 'text': printf('%s [%s]', l:error['message'], l:error['source']), + \}) + endfor + else + let l:pattern = '\v^.{-}:([0-9]+):([0-9]+): +%(([A-Z][0-9]+):? +)?(.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'code': l:match[3], + \ 'type': get(l:pylint_type_to_ale_type, l:match[3][0], 'W'), + \ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:match[3][0], ''), + \ 'text': l:match[4], + \}) + endfor + endif return l:output endfunction @@ -86,7 +145,16 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pylama', \ 'executable': function('ale_linters#python#pylama#GetExecutable'), -\ 'command': function('ale_linters#python#pylama#GetCommand'), -\ 'callback': 'ale_linters#python#pylama#Handle', +\ 'cwd': function('ale_linters#python#pylama#GetCwd'), +\ 'command': function('ale_linters#python#pylama#RunWithVersionCheck'), +\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#python#pylama#GetExecutable(buffer), +\ '%e --version', +\ {buffer, version -> ale_linters#python#pylama#Handle( +\ buffer, +\ l:version, +\ lines)}, +\ )}, \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/python/pylint.vim b/sources_non_forked/ale/ale_linters/python/pylint.vim index b16d5355..ba69d666 100644 --- a/sources_non_forked/ale/ale_linters/python/pylint.vim +++ b/sources_non_forked/ale/ale_linters/python/pylint.vim @@ -6,6 +6,8 @@ call ale#Set('python_pylint_options', '') 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 @@ -14,41 +16,56 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylint_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 -function! ale_linters#python#pylint#GetCommand(buffer) abort - let l:cd_string = '' - +function! ale_linters#python#pylint#GetCwd(buffer) abort if ale#Var(a:buffer, 'python_pylint_change_directory') " pylint only checks for pylintrc in the packages above its current " directory before falling back to user and global pylintrc. " Run from project root, if found, otherwise buffer dir. let l:project_root = ale#python#FindProjectRoot(a:buffer) - let l:cd_string = l:project_root isnot# '' - \ ? ale#path#CdString(l:project_root) - \ : ale#path#BufferCdString(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' endif - let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer) + return '' +endfunction - let l:exec_args = l:executable =~? 'pipenv$' +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\|uv\)$' \ ? ' run pylint' \ : '' - return l:cd_string - \ . ale#Escape(l:executable) . l:exec_args - \ . ' ' . ale#Var(a:buffer, 'python_pylint_options') + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_pylint_options')) \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n' + \ . (ale#semver#GTE(a:version, [2, 4, 0]) ? ' --from-stdin' : '') \ . ' %s' endfunction function! ale_linters#python#pylint#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + " Matches patterns like the following: " " test.py:4:4: W0101 (unreachable) Unreachable code let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+): ([[:alnum:]]+) \(([^(]*)\) (.*)$' - let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) "let l:failed = append(0, l:match) @@ -71,13 +88,19 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort let l:code_out = l:match[4] endif - call add(l:output, { + let l:item = { \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 1, \ 'text': l:match[5], \ 'code': l:code_out, - \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', - \}) + \ 'type': 'W', + \} + + if l:code[:0] is# 'E' + let l:item.type = 'E' + endif + + call add(l:output, l:item) endfor return l:output @@ -86,7 +109,18 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pylint', \ 'executable': function('ale_linters#python#pylint#GetExecutable'), -\ 'command': function('ale_linters#python#pylint#GetCommand'), +\ 'lint_file': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'python_pylint_executable'), +\ '%e --version', +\ {buffer, version -> !ale#semver#GTE(version, [2, 4, 0])}, +\ )}, +\ 'cwd': function('ale_linters#python#pylint#GetCwd'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'python_pylint_executable'), +\ '%e --version', +\ function('ale_linters#python#pylint#GetCommand'), +\ )}, \ 'callback': 'ale_linters#python#pylint#Handle', -\ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/python/pyls.vim b/sources_non_forked/ale/ale_linters/python/pyls.vim deleted file mode 100644 index c7f91430..00000000 --- a/sources_non_forked/ale/ale_linters/python/pyls.vim +++ /dev/null @@ -1,36 +0,0 @@ -" Author: aurieh -" Description: A language server for Python - -call ale#Set('python_pyls_executable', 'pyls') -call ale#Set('python_pyls_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('python_pyls_auto_pipenv', 0) -call ale#Set('python_pyls_config', {}) - -function! ale_linters#python#pyls#GetExecutable(buffer) abort - if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyls_auto_pipenv')) - \ && ale#python#PipenvPresent(a:buffer) - return 'pipenv' - endif - - return ale#python#FindExecutable(a:buffer, 'python_pyls', ['pyls']) -endfunction - -function! ale_linters#python#pyls#GetCommand(buffer) abort - let l:executable = ale_linters#python#pyls#GetExecutable(a:buffer) - - let l:exec_args = l:executable =~? 'pipenv$' - \ ? ' run pyls' - \ : '' - - return ale#Escape(l:executable) . l:exec_args -endfunction - -call ale#linter#Define('python', { -\ 'name': 'pyls', -\ 'lsp': 'stdio', -\ 'executable': function('ale_linters#python#pyls#GetExecutable'), -\ 'command': function('ale_linters#python#pyls#GetCommand'), -\ 'project_root': function('ale#python#FindProjectRoot'), -\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', -\ 'lsp_config': {b -> ale#Var(b, 'python_pyls_config')}, -\}) diff --git a/sources_non_forked/ale/ale_linters/python/pylsp.vim b/sources_non_forked/ale/ale_linters/python/pylsp.vim new file mode 100644 index 00000000..75ec3884 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pylsp.vim @@ -0,0 +1,67 @@ +" Author: aurieh +" Description: A language server for Python + +call ale#Set('python_pylsp_executable', 'pylsp') +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 + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylsp_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylsp_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 + +" 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 +" names being imported incorrectly. +function! ale_linters#python#pylsp#GetCwd(buffer) abort + let l:fake_linter = { + \ 'name': 'pylsp', + \ 'project_root': function('ale#python#FindProjectRoot'), + \} + let l:root = ale#lsp_linter#FindProjectRoot(a:buffer, l:fake_linter) + + return !empty(l:root) ? l:root : v:null +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\|uv\)$' + \ ? ' run pylsp' + \ : '' + let l:env_string = '' + + if ale#Var(a:buffer, 'python_auto_virtualenv') + let l:env_string = ale#python#AutoVirtualenvEnvString(a:buffer) + endif + + return l:env_string . ale#Escape(l:executable) . l:exec_args . ale#Pad(ale#Var(a:buffer, 'python_pylsp_options')) +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pylsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#python#pylsp#GetExecutable'), +\ 'cwd': function('ale_linters#python#pylsp#GetCwd'), +\ 'command': function('ale_linters#python#pylsp#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'lsp_config': {b -> ale#Var(b, 'python_pylsp_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pyre.vim b/sources_non_forked/ale/ale_linters/python/pyre.vim index 4edd80f7..745d669a 100644 --- a/sources_non_forked/ale/ale_linters/python/pyre.vim +++ b/sources_non_forked/ale/ale_linters/python/pyre.vim @@ -4,6 +4,8 @@ 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')) @@ -11,19 +13,32 @@ function! ale_linters#python#pyre#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyre_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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$' - \ ? ' run pyre persistent' - \ : ' persistent' + let l:exec_args = (l:executable =~? '\(pipenv\|poetry\|uv\)$' ? ' run pyre' : '') . ' persistent' return ale#Escape(l:executable) . l:exec_args endfunction +function! ale_linters#python#pyre#GetCwd(buffer) abort + let l:local_config = ale#path#FindNearestFile(a:buffer, '.pyre_configuration.local') + + return fnamemodify(l:local_config, ':h') +endfunction + call ale#linter#Define('python', { \ 'name': 'pyre', \ 'lsp': 'stdio', @@ -31,4 +46,5 @@ call ale#linter#Define('python', { \ 'command': function('ale_linters#python#pyre#GetCommand'), \ 'project_root': function('ale#python#FindProjectRoot'), \ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'cwd': function('ale_linters#python#pyre#GetCwd'), \}) diff --git a/sources_non_forked/ale/ale_linters/python/pyright.vim b/sources_non_forked/ale/ale_linters/python/pyright.vim new file mode 100644 index 00000000..95443a13 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pyright.vim @@ -0,0 +1,94 @@ +call ale#Set('python_pyright_use_global', get(g:, 'ale_use_global_executables', 0)) +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 +" names being imported incorrectly. +function! ale_linters#python#pyright#GetCwd(buffer) abort + let l:fake_linter = { + \ 'name': 'pyright', + \ 'project_root': function('ale#python#FindProjectRoot'), + \} + let l:root = ale#lsp_linter#FindProjectRoot(a:buffer, l:fake_linter) + + return !empty(l:root) ? l:root : v:null +endfunction + +function! ale_linters#python#pyright#GetConfig(buffer) abort + let l:config = deepcopy(ale#Var(a:buffer, 'python_pyright_config')) + + if !has_key(l:config, 'python') + let l:config.python = {} + endif + + if type(l:config.python) is v:t_dict + " Automatically detect the virtualenv path and use it. + if !has_key(l:config.python, 'venvPath') + let l:venv = ale#python#FindVirtualenv(a:buffer) + + if !empty(l:venv) + let l:config.python.venvPath = l:venv + endif + endif + + " Automatically use the version of Python in virtualenv. + if type(get(l:config.python, 'venvPath')) is v:t_string + \&& !empty(l:config.python.venvPath) + \&& !has_key(l:config.python, 'pythonPath') + let l:config.python.pythonPath = ale#path#Simplify( + \ l:config.python.venvPath + \ . (has('win32') ? '/Scripts/python' : '/bin/python') + \) + endif + endif + + return l:config +endfunction + +function! ale_linters#python#pyright#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyright_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyright_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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\|uv\)$' + \ ? ' run pyright-langserver' + \ : '' + let l:env_string = '' + + if ale#Var(a:buffer, 'python_auto_virtualenv') + let l:env_string = ale#python#AutoVirtualenvEnvString(a:buffer) + endif + + return l:env_string . ale#Escape(l:executable) . l:exec_args . ' --stdio' +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pyright', +\ 'lsp': 'stdio', +\ 'cwd': function('ale_linters#python#pyright#GetCwd'), +\ 'executable': function('ale_linters#python#pyright#GetExecutable'), +\ 'command': function('ale_linters#python#pyright#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'lsp_config': function('ale_linters#python#pyright#GetConfig'), +\}) diff --git a/sources_non_forked/ale/ale_linters/python/refurb.vim b/sources_non_forked/ale/ale_linters/python/refurb.vim new file mode 100644 index 00000000..1acd4cee --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/refurb.vim @@ -0,0 +1,79 @@ +" Author: Yining +" Description: refurb as linter for python files + +call ale#Set('python_refurb_executable', 'refurb') +call ale#Set('python_refurb_options', '') +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')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_refurb_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 + +function! ale_linters#python#refurb#GetCwd(buffer) abort + if ale#Var(a:buffer, 'python_refurb_change_directory') + " Run from project root if found, else from buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '' +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\|uv\)$' + \ ? ' run refurb' + \ : '' + + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_refurb_options')) + \ . ' %s' +endfunction + +function! ale_linters#python#refurb#Handle(buffer, lines) abort + "Example: path/to/file.py:3:17 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+)?:?\s*\[FURB(\d+)\]:\s*(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'code': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'refurb', +\ 'executable': function('ale_linters#python#refurb#GetExecutable'), +\ 'cwd': function('ale_linters#python#refurb#GetCwd'), +\ 'command': function('ale_linters#python#refurb#GetCommand'), +\ 'callback': 'ale_linters#python#refurb#Handle', +\ 'output_stream': 'both', +\ 'read_buffer': 0, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/ruff.vim b/sources_non_forked/ale/ale_linters/python/ruff.vim new file mode 100644 index 00000000..8eb55164 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/ruff.vim @@ -0,0 +1,107 @@ +" Author: Yining +" Description: ruff as linter for python files + +call ale#Set('python_ruff_executable', 'ruff') +call ale#Set('python_ruff_options', '') +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', +\ ['python'], +\ 'A python linter/fixer for Python written in Rust' +\) + +function! ale_linters#python#ruff#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_ruff_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_ruff_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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_linters#python#ruff#GetCwd(buffer) abort + if ale#Var(a:buffer, 'python_ruff_change_directory') + " Run from project root if found, else from buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '' +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\|uv\)$' + \ ? ' run ruff' + \ : '' + + " NOTE: ruff 0.3.0 deprecates `ruff ` in favor of `ruff check ` + 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') +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 + 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 +endfunction + +call ale#linter#Define('python', { +\ 'name': 'ruff', +\ 'executable': function('ale_linters#python#ruff#GetExecutable'), +\ 'cwd': function('ale_linters#python#ruff#GetCwd'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#python#ruff#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#python#ruff#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#python#ruff#Handle', +\ 'output_stream': 'both', +\ 'read_buffer': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/unimport.vim b/sources_non_forked/ale/ale_linters/python/unimport.vim new file mode 100644 index 00000000..1496fc42 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/unimport.vim @@ -0,0 +1,81 @@ +" Author: Author: Jon Parise + +call ale#Set('python_unimport_executable', 'unimport') +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')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_unimport_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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\|uv\)$' + \ ? ' run unimport' + \ : '' + + return '%e' . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_unimport_options')) + \ . ' --check' + \ . ' %t' +endfunction + + +function! ale_linters#python#unimport#GetCwd(buffer) abort + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) + \ ? l:project_root + \ : expand('#' . a:buffer . ':p:h') +endfunction + + +function! ale_linters#python#unimport#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + + " Matches lines like: + " + " urllib.parse at path/to/file.py:9 + let l:pattern = '\v(.+) at [^:]+:(\d+)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': 'W', + \ 'text': 'unused: ' . l:match[1], + \}) + endfor + + return l:output +endfunction + + +call ale#linter#Define('python', { +\ 'name': 'unimport', +\ 'executable': function('ale_linters#python#unimport#GetExecutable'), +\ 'cwd': function('ale_linters#python#unimport#GetCwd'), +\ 'command': function('ale_linters#python#unimport#GetCommand'), +\ 'callback': 'ale_linters#python#unimport#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/vulture.vim b/sources_non_forked/ale/ale_linters/python/vulture.vim index d328d262..c44638b9 100644 --- a/sources_non_forked/ale/ale_linters/python/vulture.vim +++ b/sources_non_forked/ale/ale_linters/python/vulture.vim @@ -5,7 +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,29 +18,43 @@ function! s:GetDir(buffer) abort \ : expand('#' . a:buffer . ':p:h') 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 +function! ale_linters#python#vulture#GetCwd(buffer) abort + if !ale#Var(a:buffer, 'python_vulture_change_directory') + return '' + endif + + return s:GetDir(a:buffer) +endfunction function! ale_linters#python#vulture#GetCommand(buffer) abort - let l:change_dir = ale#Var(a:buffer, 'python_vulture_change_directory') - \ ? ale#path#CdString(s:GetDir(a:buffer)) - \ : '' - let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer) - - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run vulture' \ : '' - let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory') \ ? ' .' \ : ' %s' - return l:change_dir - \ . ale#Escape(l:executable) . l:exec_args + return ale#Escape(l:executable) . l:exec_args \ . ' ' \ . ale#Var(a:buffer, 'python_vulture_options') \ . l:lint_dest @@ -74,6 +90,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'vulture', \ 'executable': function('ale_linters#python#vulture#GetExecutable'), +\ 'cwd': function('ale_linters#python#vulture#GetCwd'), \ 'command': function('ale_linters#python#vulture#GetCommand'), \ 'callback': 'ale_linters#python#vulture#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/r/languageserver.vim b/sources_non_forked/ale/ale_linters/r/languageserver.vim new file mode 100644 index 00000000..1ff23fa9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/r/languageserver.vim @@ -0,0 +1,28 @@ +" Author: Eric Zhao <21zhaoe@protonmail.com> +" Author: ourigen +" Description: Implementation of the Language Server Protocol for R. + +call ale#Set('r_languageserver_cmd', 'languageserver::run()') +call ale#Set('r_languageserver_config', {}) + +function! ale_linters#r#languageserver#GetCommand(buffer) abort + let l:cmd_string = ale#Var(a:buffer, 'r_languageserver_cmd') + + return 'Rscript --no-save --no-restore --no-site-file --no-init-file -e ' . ale#Escape(l:cmd_string) +endfunction + +function! ale_linters#r#languageserver#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, '.Rprofile') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : fnamemodify(a:buffer, ':h') +endfunction + +call ale#linter#Define('r', { +\ 'name': 'languageserver', +\ 'aliases': ['r_language_server'], +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'r_languageserver_config')}, +\ 'executable': 'Rscript', +\ 'command': function('ale_linters#r#languageserver#GetCommand'), +\ 'project_root': function('ale_linters#r#languageserver#GetProjectRoot') +\}) diff --git a/sources_non_forked/ale/ale_linters/r/lintr.vim b/sources_non_forked/ale/ale_linters/r/lintr.vim index 3164c06f..339ad2b0 100644 --- a/sources_non_forked/ale/ale_linters/r/lintr.vim +++ b/sources_non_forked/ale/ale_linters/r/lintr.vim @@ -1,5 +1,6 @@ " Author: Michel Lang , w0rp , -" Fenner Macrae +" Fenner Macrae , +" ourigen " Description: This file adds support for checking R code with lintr. let g:ale_r_lintr_options = get(g:, 'ale_r_lintr_options', 'with_defaults()') @@ -21,14 +22,13 @@ function! ale_linters#r#lintr#GetCommand(buffer) abort let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));' \ . l:lint_cmd - return ale#path#BufferCdString(a:buffer) - \ . 'Rscript --vanilla -e ' - \ . ale#Escape(l:cmd_string) . ' %t' + return 'Rscript --no-save --no-restore --no-site-file --no-init-file -e ' . ale#Escape(l:cmd_string) . ' %t' endfunction call ale#linter#Define('r', { \ 'name': 'lintr', \ 'executable': 'Rscript', +\ 'cwd': '%s:h', \ 'command': function('ale_linters#r#lintr#GetCommand'), \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'output_stream': 'both', diff --git a/sources_non_forked/ale/ale_linters/racket/langserver.vim b/sources_non_forked/ale/ale_linters/racket/langserver.vim new file mode 100644 index 00000000..ec80ed7b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/racket/langserver.vim @@ -0,0 +1,7 @@ +call ale#linter#Define('racket', { +\ 'name': 'racket_langserver', +\ 'lsp': 'stdio', +\ 'executable': 'racket', +\ 'command': '%e -l racket-langserver', +\ 'project_root': function('ale#racket#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/racket/raco.vim b/sources_non_forked/ale/ale_linters/racket/raco.vim index e5ee4fb4..5b26065f 100644 --- a/sources_non_forked/ale/ale_linters/racket/raco.vim +++ b/sources_non_forked/ale/ale_linters/racket/raco.vim @@ -14,6 +14,7 @@ function! ale_linters#racket#raco#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { + \ 'filename': l:match[2], \ 'lnum': l:match[3] + 0, \ 'col': l:match[4] + 0, \ 'type': 'E', diff --git a/sources_non_forked/ale/ale_linters/reason/ls.vim b/sources_non_forked/ale/ale_linters/reason/ls.vim index fb1114ae..a831b506 100644 --- a/sources_non_forked/ale/ale_linters/reason/ls.vim +++ b/sources_non_forked/ale/ale_linters/reason/ls.vim @@ -15,6 +15,7 @@ endfunction call ale#linter#Define('reason', { \ 'name': 'reason-language-server', +\ 'aliases': ['reason_ls'], \ 'lsp': 'stdio', \ 'executable': {buffer -> ale#Var(buffer, 'reason_ls_executable')}, \ 'command': '%e', diff --git a/sources_non_forked/ale/ale_linters/reason/ols.vim b/sources_non_forked/ale/ale_linters/reason/ols.vim index 66137e1b..e1f408f0 100644 --- a/sources_non_forked/ale/ale_linters/reason/ols.vim +++ b/sources_non_forked/ale/ale_linters/reason/ols.vim @@ -6,9 +6,10 @@ call ale#Set('reason_ols_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#linter#Define('reason', { \ 'name': 'ols', +\ 'aliases': ['ocaml-language-server'], \ 'lsp': 'stdio', \ 'executable': function('ale#handlers#ols#GetExecutable'), \ 'command': function('ale#handlers#ols#GetCommand'), -\ 'language_callback': 'ale#handlers#ols#GetLanguage', +\ 'language': function('ale#handlers#ols#GetLanguage'), \ 'project_root': function('ale#handlers#ols#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/rego/cspell.vim b/sources_non_forked/ale/ale_linters/rego/cspell.vim new file mode 100644 index 00000000..a54a5379 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rego/cspell.vim @@ -0,0 +1,4 @@ +scriptencoding utf-8 +" Description: cspell support for rego files. + +call ale#handlers#cspell#DefineLinter('rego') diff --git a/sources_non_forked/ale/ale_linters/rego/opacheck.vim b/sources_non_forked/ale/ale_linters/rego/opacheck.vim new file mode 100644 index 00000000..479091d3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rego/opacheck.vim @@ -0,0 +1,56 @@ +" Description: opa check for rego files + +call ale#Set('rego_opacheck_executable', 'opa') +call ale#Set('rego_opacheck_options', '') + +function! ale_linters#rego#opacheck#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'rego_opacheck_executable') +endfunction + +function! ale_linters#rego#opacheck#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'rego_opacheck_options') + + return ale#Escape(ale_linters#rego#opacheck#GetExecutable(a:buffer)) + \ . ' check %s:h --format json ' + \ . (!empty(l:options) ? ' ' . l:options : '') +endfunction + +function! ale_linters#rego#opacheck#Handle(buffer, lines) abort + let l:output = [] + + let l:errors = ale#util#FuzzyJSONDecode(a:lines, {'errors': []}) + let l:dir = expand('#' . a:buffer . ':p:h') + let l:file = expand('#' . a:buffer . ':p') + + for l:error in l:errors['errors'] + if has_key(l:error, 'location') + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:error['location']['file']), + \ 'lnum': l:error['location']['row'], + \ 'col': l:error['location']['col'], + \ 'text': l:error['message'], + \ 'code': l:error['code'], + \ 'type': 'E', + \}) + else + call add(l:output, { + \ 'filename': l:file, + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:error['message'], + \ 'code': l:error['code'], + \ 'type': 'E', + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('rego', { +\ 'name': 'opacheck', +\ 'output_stream': 'both', +\ 'executable': function('ale_linters#rego#opacheck#GetExecutable'), +\ 'command': function('ale_linters#rego#opacheck#GetCommand'), +\ 'callback': 'ale_linters#rego#opacheck#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/robot/rflint.vim b/sources_non_forked/ale/ale_linters/robot/rflint.vim new file mode 100644 index 00000000..8fe2d797 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/robot/rflint.vim @@ -0,0 +1,46 @@ +" Author: Samuel Branisa +" Description: rflint linting for robot framework files + +call ale#Set('robot_rflint_executable', 'rflint') + +function! ale_linters#robot#rflint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'robot_rflint_executable') +endfunction + +function! ale_linters#robot#rflint#GetCommand(buffer) abort + let l:executable = ale_linters#robot#rflint#GetExecutable(a:buffer) + let l:flags = '--format' + \ . ' "{filename}:{severity}:{linenumber}:{char}:{rulename}:{message}"' + + return l:executable + \ . ' ' + \ . l:flags + \ . ' %s' +endfunction + +function! ale_linters#robot#rflint#Handle(buffer, lines) abort + let l:pattern = '\v^([[:alnum:][:punct:]]+):(W|E):([[:digit:]]+):([[:digit:]]+):([[:alnum:]]+):(.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'filename': l:match[1], + \ 'type': l:match[2], + \ 'lnum': str2nr(l:match[3]), + \ 'col': str2nr(l:match[4]), + \ 'text': l:match[5], + \ 'detail': l:match[6], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('robot', { +\ 'name': 'rflint', +\ 'executable': function('ale_linters#robot#rflint#GetExecutable'), +\ 'command': function('ale_linters#robot#rflint#GetCommand'), +\ 'callback': 'ale_linters#robot#rflint#Handle', +\}) + diff --git a/sources_non_forked/ale/ale_linters/rst/cspell.vim b/sources_non_forked/ale/ale_linters/rst/cspell.vim new file mode 100644 index 00000000..14cfb42e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for ReStructuredText files. + +call ale#handlers#cspell#DefineLinter('rst') diff --git a/sources_non_forked/ale/ale_linters/rst/rstcheck.vim b/sources_non_forked/ale/ale_linters/rst/rstcheck.vim index 39e11d6e..e0cf0798 100644 --- a/sources_non_forked/ale/ale_linters/rst/rstcheck.vim +++ b/sources_non_forked/ale/ale_linters/rst/rstcheck.vim @@ -1,6 +1,5 @@ " Author: John Nduli https://github.com/jnduli " Description: Rstcheck for reStructuredText files -" function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort " matches: 'bad_rst.rst:1: (SEVERE/4) Title overline & underline @@ -22,17 +21,11 @@ function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#rst#rstcheck#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . 'rstcheck' - \ . ' %t' -endfunction - - call ale#linter#Define('rst', { \ 'name': 'rstcheck', \ 'executable': 'rstcheck', -\ 'command': function('ale_linters#rst#rstcheck#GetCommand'), +\ 'cwd': '%s:h', +\ 'command': 'rstcheck %t', \ 'callback': 'ale_linters#rst#rstcheck#Handle', \ 'output_stream': 'both', \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/brakeman.vim b/sources_non_forked/ale/ale_linters/ruby/brakeman.vim index a8088080..2dc48740 100644 --- a/sources_non_forked/ale/ale_linters/ruby/brakeman.vim +++ b/sources_non_forked/ale/ale_linters/ruby/brakeman.vim @@ -36,7 +36,7 @@ function! ale_linters#ruby#brakeman#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_brakeman_executable') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'brakeman') + return ale#ruby#EscapeExecutable(l:executable, 'brakeman') \ . ' -f json -q ' \ . ale#Var(a:buffer, 'ruby_brakeman_options') \ . ' -p ' . ale#Escape(l:rails_root) diff --git a/sources_non_forked/ale/ale_linters/ruby/cspell.vim b/sources_non_forked/ale/ale_linters/ruby/cspell.vim new file mode 100644 index 00000000..780356b1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Ruby files. + +call ale#handlers#cspell#DefineLinter('ruby') diff --git a/sources_non_forked/ale/ale_linters/ruby/debride.vim b/sources_non_forked/ale/ale_linters/ruby/debride.vim new file mode 100644 index 00000000..3b2cc443 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/debride.vim @@ -0,0 +1,42 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: debride, a dead method detector for Ruby files + +call ale#Set('ruby_debride_executable', 'debride') +call ale#Set('ruby_debride_options', '') + +function! ale_linters#ruby#debride#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_debride_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'debride') + \ . ale#Var(a:buffer, 'ruby_debride_options') + \ . ' %s' +endfunction + +function! ale_linters#ruby#debride#HandleOutput(buffer, lines) abort + let l:output = [] + + for l:line in a:lines + if l:line !~# '^ ' + continue + endif + + let l:elements = split(l:line) + let l:method_name = l:elements[0] + let l:lnum = split(l:elements[1], ':')[1] + + call add(l:output, { + \ 'lnum': 0 + l:lnum, + \ 'text': 'Possible unused method: ' . l:method_name, + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'debride', +\ 'executable': {b -> ale#Var(b, 'ruby_debride_executable')}, +\ 'command': function('ale_linters#ruby#debride#GetCommand'), +\ 'callback': 'ale_linters#ruby#debride#HandleOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/packwerk.vim b/sources_non_forked/ale/ale_linters/ruby/packwerk.vim new file mode 100644 index 00000000..4014b2da --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/packwerk.vim @@ -0,0 +1,55 @@ +" Author: ymap - https://github.com/ymap +" Description: Packwerk, a static analyzer used to enforce boundaries and modularize Rails applications. + +call ale#Set('ruby_packwerk_executable', 'packwerk') +call ale#Set('ruby_packwerk_options', '') + +function! ale_linters#ruby#packwerk#Handle(buffer, lines) abort + let l:pattern = '\v^[^:]+:(\d+):(\d+)$' + let l:index = 0 + let l:output = [] + + while l:index < len(a:lines) - 1 + let l:cleaned_line = substitute(a:lines[l:index], '\v\e\[[0-9;]*m', '', 'g') + let l:match = matchlist(l:cleaned_line, l:pattern) + + if len(l:match) > 0 + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': a:lines[l:index + 1], + \}) + endif + + let l:index += 1 + endwhile + + return l:output +endfunction + +function! ale_linters#ruby#packwerk#GetCommand(buffer) abort + let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) + + if l:rails_root is? '' + return '' + endif + + let l:executable = ale#Var(a:buffer, 'ruby_packwerk_executable') + let l:sep = has('win32') ? '\' : '/' + let l:abs_path = expand('#' . a:buffer . ':p') + let l:rel_path = substitute(l:abs_path, escape(l:rails_root . l:sep, '\'), '', '') + + return ale#ruby#EscapeExecutable(l:executable, 'packwerk') + \ . ' check' + \ . ale#Pad(ale#Var(a:buffer, 'ruby_packwerk_options')) + \ . ' ' + \ . ale#Escape(rel_path) +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'packwerk', +\ 'executable': {b -> ale#Var(b, 'ruby_packwerk_executable')}, +\ 'command': function('ale_linters#ruby#packwerk#GetCommand'), +\ 'callback': 'ale_linters#ruby#packwerk#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim b/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim index a94fb671..36646647 100644 --- a/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim +++ b/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim @@ -33,7 +33,7 @@ function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort let l:output_file = has('win32') ? '%t ' : '/dev/stdout ' let l:cat_file = has('win32') ? '; type %t' : '' - return ale#handlers#ruby#EscapeExecutable(l:executable, 'rails_best_practices') + return ale#ruby#EscapeExecutable(l:executable, 'rails_best_practices') \ . ' --silent -f json --output-file ' . l:output_file \ . ale#Var(a:buffer, 'ruby_rails_best_practices_options') \ . ale#Escape(l:rails_root) diff --git a/sources_non_forked/ale/ale_linters/ruby/reek.vim b/sources_non_forked/ale/ale_linters/ruby/reek.vim index e39e366f..b6fa9d76 100644 --- a/sources_non_forked/ale/ale_linters/ruby/reek.vim +++ b/sources_non_forked/ale/ale_linters/ruby/reek.vim @@ -14,11 +14,15 @@ function! ale_linters#ruby#reek#GetCommand(buffer, version) abort \ ? ' --stdin-filename %s' \ : '' - return ale#handlers#ruby#EscapeExecutable(l:executable, 'reek') + return ale#ruby#EscapeExecutable(l:executable, 'reek') \ . ' -f json --no-progress --no-color --force-exclusion' \ . l:display_name_args endfunction +function! s:GetDocumentationLink(error) abort + return get(a:error, 'documentation_link', get(a:error, 'wiki_link', '')) +endfunction + function! s:BuildText(buffer, error) abort let l:parts = [] @@ -29,7 +33,7 @@ function! s:BuildText(buffer, error) abort call add(l:parts, a:error.message) if ale#Var(a:buffer, 'ruby_reek_show_wiki_link') - call add(l:parts, '[' . a:error.wiki_link . ']') + call add(l:parts, '[' . s:GetDocumentationLink(a:error) . ']') endif return join(l:parts, ' ') diff --git a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim index 8b9e9c84..483806a6 100644 --- a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim +++ b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim @@ -7,10 +7,10 @@ call ale#Set('ruby_rubocop_options', '') function! ale_linters#ruby#rubocop#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop') + return ale#ruby#EscapeExecutable(l:executable, 'rubocop') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'ruby_rubocop_options') - \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) + \ . ' --stdin %s' endfunction function! ale_linters#ruby#rubocop#GetType(severity) abort diff --git a/sources_non_forked/ale/ale_linters/ruby/ruby.vim b/sources_non_forked/ale/ale_linters/ruby/ruby.vim index 2dc55eb0..621fcbc0 100644 --- a/sources_non_forked/ale/ale_linters/ruby/ruby.vim +++ b/sources_non_forked/ale/ale_linters/ruby/ruby.vim @@ -6,7 +6,7 @@ call ale#Set('ruby_ruby_executable', 'ruby') call ale#linter#Define('ruby', { \ 'name': 'ruby', \ 'executable': {b -> ale#Var(b, 'ruby_ruby_executable')}, -\ 'command': '%e -w -c -T1 %t', +\ 'command': '%e -w -c %t', \ 'output_stream': 'stderr', \ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/sorbet.vim b/sources_non_forked/ale/ale_linters/ruby/sorbet.vim index ee765a6e..c67e20cc 100644 --- a/sources_non_forked/ale/ale_linters/ruby/sorbet.vim +++ b/sources_non_forked/ale/ale_linters/ruby/sorbet.vim @@ -1,14 +1,17 @@ call ale#Set('ruby_sorbet_executable', 'srb') call ale#Set('ruby_sorbet_options', '') +call ale#Set('ruby_sorbet_enable_watchman', 0) function! ale_linters#ruby#sorbet#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable') let l:options = ale#Var(a:buffer, 'ruby_sorbet_options') + let l:enable_watchman = ale#Var(a:buffer, 'ruby_sorbet_enable_watchman') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'srb') + return ale#ruby#EscapeExecutable(l:executable, 'srb') \ . ' tc' \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --lsp --disable-watchman' + \ . ' --lsp' + \ . (l:enable_watchman ? '' : ' --disable-watchman') endfunction call ale#linter#Define('ruby', { diff --git a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim index f075a7d5..6ccfd2d6 100644 --- a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim +++ b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim @@ -8,10 +8,10 @@ call ale#Set('ruby_standardrb_options', '') function! ale_linters#ruby#standardrb#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_standardrb_executable') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'standardrb') + return ale#ruby#EscapeExecutable(l:executable, 'standardrb') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'ruby_standardrb_options') - \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) + \ . ' --stdin %s' endfunction " standardrb is based on RuboCop so the callback is the same 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/rust/analyzer.vim b/sources_non_forked/ale/ale_linters/rust/analyzer.vim new file mode 100644 index 00000000..e3141cd3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rust/analyzer.vim @@ -0,0 +1,37 @@ +" Author: Jon Gjengset +" Description: The next generation language server for Rust + +call ale#Set('rust_analyzer_executable', 'rust-analyzer') +call ale#Set('rust_analyzer_config', {}) + +function! ale_linters#rust#analyzer#GetCommand(buffer) abort + return '%e' +endfunction + +function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort + " Try to find nearest Cargo.toml for cargo projects + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + if !empty(l:cargo_file) + return fnamemodify(l:cargo_file, ':h') + endif + + " Try to find nearest rust-project.json for non-cargo projects + let l:rust_project = ale#path#FindNearestFile(a:buffer, 'rust-project.json') + + if !empty(l:rust_project) + return fnamemodify(l:rust_project, ':h') + endif + + return '' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'analyzer', +\ 'aliases': ['rust_analyzer'], +\ 'lsp': 'stdio', +\ 'initialization_options': {b -> ale#Var(b, 'rust_analyzer_config')}, +\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')}, +\ 'command': function('ale_linters#rust#analyzer#GetCommand'), +\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/rust/cargo.vim b/sources_non_forked/ale/ale_linters/rust/cargo.vim index 99178585..37fd10a8 100644 --- a/sources_non_forked/ale/ale_linters/rust/cargo.vim +++ b/sources_non_forked/ale/ale_linters/rust/cargo.vim @@ -11,6 +11,7 @@ call ale#Set('rust_cargo_default_feature_behavior', 'default') call ale#Set('rust_cargo_include_features', '') call ale#Set('rust_cargo_use_clippy', 0) call ale#Set('rust_cargo_clippy_options', '') +call ale#Set('rust_cargo_target_dir', '') function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') isnot# '' @@ -22,6 +23,19 @@ function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort endif endfunction +function! ale_linters#rust#cargo#GetCwd(buffer) abort + if ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace') + let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h') + + if l:nearest_cargo_dir isnot# '.' + return l:nearest_cargo_dir + endif + endif + + return '' +endfunction + function! ale_linters#rust#cargo#GetCommand(buffer, version) abort let l:use_check = ale#Var(a:buffer, 'rust_cargo_use_check') \ && ale#semver#GTE(a:version, [0, 17, 0]) @@ -31,6 +45,9 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort \ && ale#semver#GTE(a:version, [0, 22, 0]) let l:use_tests = ale#Var(a:buffer, 'rust_cargo_check_tests') \ && ale#semver#GTE(a:version, [0, 22, 0]) + let l:target_dir = ale#Var(a:buffer, 'rust_cargo_target_dir') + let l:use_target_dir = !empty(l:target_dir) + \ && ale#semver#GTE(a:version, [0, 17, 0]) let l:include_features = ale#Var(a:buffer, 'rust_cargo_include_features') @@ -38,18 +55,6 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort let l:include_features = ' --features ' . ale#Escape(l:include_features) endif - let l:avoid_whole_workspace = ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace') - let l:nearest_cargo_prefix = '' - - if l:avoid_whole_workspace - let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') - let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h') - - if l:nearest_cargo_dir isnot# '.' - let l:nearest_cargo_prefix = 'cd '. ale#Escape(l:nearest_cargo_dir) .' && ' - endif - endif - let l:default_feature_behavior = ale#Var(a:buffer, 'rust_cargo_default_feature_behavior') if l:default_feature_behavior is# 'all' @@ -77,11 +82,12 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort endif endif - return l:nearest_cargo_prefix . 'cargo ' + return 'cargo ' \ . l:subcommand \ . (l:use_all_targets ? ' --all-targets' : '') \ . (l:use_examples ? ' --examples' : '') \ . (l:use_tests ? ' --tests' : '') + \ . (l:use_target_dir ? (' --target-dir ' . ale#Escape(l:target_dir)) : '') \ . ' --frozen --message-format=json -q' \ . l:default_feature \ . l:include_features @@ -91,6 +97,7 @@ endfunction call ale#linter#Define('rust', { \ 'name': 'cargo', \ 'executable': function('ale_linters#rust#cargo#GetCargoExecutable'), +\ 'cwd': function('ale_linters#rust#cargo#GetCwd'), \ 'command': {buffer -> ale#semver#RunWithVersionCheck( \ buffer, \ ale_linters#rust#cargo#GetCargoExecutable(buffer), diff --git a/sources_non_forked/ale/ale_linters/rust/cspell.vim b/sources_non_forked/ale/ale_linters/rust/cspell.vim new file mode 100644 index 00000000..d2523c7d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rust/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Rust files. + +call ale#handlers#cspell#DefineLinter('rust') diff --git a/sources_non_forked/ale/ale_linters/rust/rustc.vim b/sources_non_forked/ale/ale_linters/rust/rustc.vim index f140b58b..bc6431ba 100644 --- a/sources_non_forked/ale/ale_linters/rust/rustc.vim +++ b/sources_non_forked/ale/ale_linters/rust/rustc.vim @@ -1,7 +1,7 @@ " Author: Daniel Schemala " Description: rustc for rust files -call ale#Set('rust_rustc_options', '-Z no-codegen') +call ale#Set('rust_rustc_options', '--emit=mir -o /dev/null') function! ale_linters#rust#rustc#RustcCommand(buffer) abort " Try to guess the library search path. If the project is managed by cargo, diff --git a/sources_non_forked/ale/ale_linters/salt/salt_lint.vim b/sources_non_forked/ale/ale_linters/salt/salt_lint.vim new file mode 100644 index 00000000..47f66d83 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/salt/salt_lint.vim @@ -0,0 +1,33 @@ +" Author: Benjamin BINIER +" Description: salt-lint, saltstack linter + +call ale#Set('salt_salt_lint_executable', 'salt-lint') +call ale#Set('salt_salt_lint_options', '') + +function! ale_linters#salt#salt_lint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'salt_salt_lint_options')) + \ . ' --json' +endfunction + +function! ale_linters#salt#salt_lint#Handle(buffer, lines) abort + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + call add(l:output, { + \ 'lnum': l:error.linenumber + 0, + \ 'code': l:error.id + 0, + \ 'text': l:error.message, + \ 'type': l:error.severity is# 'HIGH' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('salt', { +\ 'name': 'salt_lint', +\ 'aliases': ['salt-lint'], +\ 'executable': {b -> ale#Var(b, 'salt_salt_lint_executable')}, +\ 'command': function('ale_linters#salt#salt_lint#GetCommand'), +\ 'callback': 'ale_linters#salt#salt_lint#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/sass/sasslint.vim b/sources_non_forked/ale/ale_linters/sass/sasslint.vim index 17cd3667..ff396e68 100644 --- a/sources_non_forked/ale/ale_linters/sass/sasslint.vim +++ b/sources_non_forked/ale/ale_linters/sass/sasslint.vim @@ -5,7 +5,7 @@ call ale#Set('sass_sasslint_options', '') call ale#Set('sass_sasslint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#sass#sasslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'sass_sasslint', [ + return ale#path#FindExecutable(a:buffer, 'sass_sasslint', [ \ 'node_modules/sass-lint/bin/sass-lint.js', \ 'node_modules/.bin/sass-lint', \]) diff --git a/sources_non_forked/ale/ale_linters/sass/stylelint.vim b/sources_non_forked/ale/ale_linters/sass/stylelint.vim index 7b14c6b4..651d7fd5 100644 --- a/sources_non_forked/ale/ale_linters/sass/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sass/stylelint.vim @@ -5,7 +5,8 @@ call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', call ale#linter#Define('sass', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'sass_stylelint', [ +\ 'output_stream': 'both', +\ 'executable': {b -> ale#path#FindExecutable(b, 'sass_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': '%e --stdin-filename %s', diff --git a/sources_non_forked/ale/ale_linters/scala/cspell.vim b/sources_non_forked/ale/ale_linters/scala/cspell.vim new file mode 100644 index 00000000..fa09d420 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Scala files. + +call ale#handlers#cspell#DefineLinter('scala') diff --git a/sources_non_forked/ale/ale_linters/scala/metals.vim b/sources_non_forked/ale/ale_linters/scala/metals.vim new file mode 100644 index 00000000..1362e1a3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/metals.vim @@ -0,0 +1,50 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Metals Language Server for Scala https://scalameta.org/metals/ + +call ale#Set('scala_metals_executable', 'metals') +call ale#Set('scala_metals_project_root', '') + +function! ale_linters#scala#metals#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'scala_metals_project_root') + + if !empty(l:project_root) + return l:project_root + endif + + let l:potential_roots = [ + \ 'build.sc', + \ 'build.sbt', + \ '.bloop', + \ '.metals', + \] + + for l:root in l:potential_roots + let l:project_root = ale#path#ResolveLocalPath( + \ a:buffer, + \ l:root, + \ '' + \) + + if !empty(l:project_root) + return fnamemodify( + \ l:project_root, + \ ':h', + \) + endif + endfor + + return '' +endfunction + +function! ale_linters#scala#metals#GetCommand(buffer) abort + return '%e' . ale#Pad('stdio') +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'metals', +\ 'lsp': 'stdio', +\ 'language': 'scala', +\ 'executable': {b -> ale#Var(b, 'scala_metals_executable')}, +\ 'command': function('ale_linters#scala#metals#GetCommand'), +\ 'project_root': function('ale_linters#scala#metals#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/scss/sasslint.vim b/sources_non_forked/ale/ale_linters/scss/sasslint.vim index cf13546e..99027051 100644 --- a/sources_non_forked/ale/ale_linters/scss/sasslint.vim +++ b/sources_non_forked/ale/ale_linters/scss/sasslint.vim @@ -5,7 +5,7 @@ call ale#Set('scss_sasslint_options', '') call ale#Set('scss_sasslint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#scss#sasslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'scss_sasslint', [ + return ale#path#FindExecutable(a:buffer, 'scss_sasslint', [ \ 'node_modules/sass-lint/bin/sass-lint.js', \ 'node_modules/.bin/sass-lint', \]) diff --git a/sources_non_forked/ale/ale_linters/scss/stylelint.vim b/sources_non_forked/ale/ale_linters/scss/stylelint.vim index b5b21536..4f82a98a 100644 --- a/sources_non_forked/ale/ale_linters/scss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/scss/stylelint.vim @@ -11,7 +11,8 @@ endfunction call ale#linter#Define('scss', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'scss_stylelint', [ +\ 'output_stream': 'both', +\ 'executable': {b -> ale#path#FindExecutable(b, 'scss_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#scss#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/sh/bashate.vim b/sources_non_forked/ale/ale_linters/sh/bashate.vim new file mode 100644 index 00000000..3cd84245 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sh/bashate.vim @@ -0,0 +1,43 @@ +" Author: hsanson +" Description: Lints sh files using bashate +" URL: https://github.com/openstack/bashate + +call ale#Set('sh_bashate_executable', 'bashate') +call ale#Set('sh_bashate_options', '') + +function! ale_linters#sh#bashate#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'sh_bashate_executable') +endfunction + +function! ale_linters#sh#bashate#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'sh_bashate_options') + let l:executable = ale_linters#sh#bashate#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' ' . l:options . ' ' . '%t' +endfunction + +function! ale_linters#sh#bashate#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " /path/to/script/file:694:1: E003 Indent not multiple of 4 + let l:pattern = ':\(\d\+\):\(\d\+\): \(.*\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sh', { +\ 'name': 'bashate', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#sh#bashate#GetExecutable'), +\ 'command': function('ale_linters#sh#bashate#GetCommand'), +\ 'callback': 'ale_linters#sh#bashate#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/sh/cspell.vim b/sources_non_forked/ale/ale_linters/sh/cspell.vim new file mode 100644 index 00000000..e3c5a6f0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sh/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for shell scripts. + +call ale#handlers#cspell#DefineLinter('sh') diff --git a/sources_non_forked/ale/ale_linters/sh/language_server.vim b/sources_non_forked/ale/ale_linters/sh/language_server.vim index 5a3b0e9a..c6781584 100644 --- a/sources_non_forked/ale/ale_linters/sh/language_server.vim +++ b/sources_non_forked/ale/ale_linters/sh/language_server.vim @@ -6,7 +6,7 @@ call ale#Set('sh_language_server_executable', 'bash-language-server') call ale#Set('sh_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#sh#language_server#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'sh_language_server', [ + return ale#path#FindExecutable(a:buffer, 'sh_language_server', [ \ 'node_modules/.bin/bash-language-server', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/sh/shell.vim b/sources_non_forked/ale/ale_linters/sh/shell.vim index 189dc21d..0605c285 100644 --- a/sources_non_forked/ale/ale_linters/sh/shell.vim +++ b/sources_non_forked/ale/ale_linters/sh/shell.vim @@ -1,10 +1,5 @@ " Author: w0rp -" Description: Lints sh files using bash -n - -" Backwards compatibility -if exists('g:ale_linters_sh_shell_default_shell') - let g:ale_sh_shell_default_shell = g:ale_linters_sh_shell_default_shell -endif +" Description: Lints shell files by invoking the shell with -n " This option can be changed to change the default shell when the shell " cannot be taken from the hashbang line. @@ -34,8 +29,10 @@ function! ale_linters#sh#shell#Handle(buffer, lines) abort " Matches patterns line the following: " " bash: line 13: syntax error near unexpected token `d' + " bash:行0: 未预期的符号“done”附近有语法错误 + " bash: 列 90: 尋找匹配的「"」時遇到了未預期的檔案結束符 " sh: 11: Syntax error: "(" unexpected - let l:pattern = '\v(line |: ?)(\d+): (.+)$' + let l:pattern = '\v([^:]+:\D*)(\d+): (.+)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) diff --git a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim index 1d8b6096..d9945126 100644 --- a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim +++ b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim @@ -1,107 +1,4 @@ " Author: w0rp -" Description: This file adds support for using the shellcheck linter with -" shell scripts. +" Description: shellcheck linter for shell scripts. -" This global variable can be set with a string of comma-separated error -" codes to exclude from shellcheck. For example: -" -" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' -call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) -call ale#Set('sh_shellcheck_executable', 'shellcheck') -call ale#Set('sh_shellcheck_dialect', 'auto') -call ale#Set('sh_shellcheck_options', '') -call ale#Set('sh_shellcheck_change_directory', 1) - -function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort - let l:shell_type = ale#handlers#sh#GetShellType(a:buffer) - - if !empty(l:shell_type) - " Use the dash dialect for /bin/ash, etc. - if l:shell_type is# 'ash' - return 'dash' - endif - - return l:shell_type - endif - - " If there's no hashbang, try using Vim's buffer variables. - if getbufvar(a:buffer, 'is_bash', 0) - return 'bash' - elseif getbufvar(a:buffer, 'is_sh', 0) - return 'sh' - elseif getbufvar(a:buffer, 'is_kornshell', 0) - return 'ksh' - endif - - return '' -endfunction - -function! ale_linters#sh#shellcheck#GetCommand(buffer, version) abort - let l:options = ale#Var(a:buffer, 'sh_shellcheck_options') - 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:cd_string = ale#Var(a:buffer, 'sh_shellcheck_change_directory') - \ ? ale#path#BufferCdString(a:buffer) - \ : '' - - if l:dialect is# 'auto' - let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer) - endif - - return l:cd_string - \ . '%e' - \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '') - \ . l:external_option - \ . ' -f gcc -' -endfunction - -function! ale_linters#sh#shellcheck#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) - if l:match[4] is# 'error' - let l:type = 'E' - elseif l:match[4] is# 'note' - let l:type = 'I' - else - let l:type = 'W' - endif - - let l:item = { - \ 'lnum': str2nr(l:match[2]), - \ 'type': l:type, - \ 'text': l:match[5], - \ 'code': l:match[6], - \} - - if !empty(l:match[3]) - let l:item.col = str2nr(l:match[3]) - endif - - " If the filename is something like , or -, then - " this is an error for the file we checked. - if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' - let l:item['filename'] = l:match[1] - endif - - call add(l:output, l:item) - endfor - - return l:output -endfunction - -call ale#linter#Define('sh', { -\ 'name': 'shellcheck', -\ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')}, -\ 'command': {buffer -> ale#semver#RunWithVersionCheck( -\ buffer, -\ ale#Var(buffer, 'sh_shellcheck_executable'), -\ '%e --version', -\ function('ale_linters#sh#shellcheck#GetCommand'), -\ )}, -\ 'callback': 'ale_linters#sh#shellcheck#Handle', -\}) +call ale#handlers#shellcheck#DefineLinter('sh') diff --git a/sources_non_forked/ale/ale_linters/solidity/solc.vim b/sources_non_forked/ale/ale_linters/solidity/solc.vim new file mode 100644 index 00000000..28977083 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/solidity/solc.vim @@ -0,0 +1,53 @@ +" Author: Karl Bartel - http://karl.berlin/ +" Description: Report solc compiler errors in Solidity code + +call ale#Set('solidity_solc_executable', 'solc') +call ale#Set('solidity_solc_options', '') + +function! ale_linters#solidity#solc#Handle(buffer, lines) abort + " Matches patterns like the following: + " Error: Expected ';' but got '(' + " --> /path/to/file/file.sol:1:10:) + let l:pattern = '\v(Error|Warning): (.*)$' + let l:line_and_column_pattern = '\v\.sol:(\d+):(\d+):' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + let l:match = matchlist(l:line, l:line_and_column_pattern) + + if len(l:match) > 0 + let l:index = len(l:output) - 1 + let l:output[l:index]['lnum'] = l:match[1] + 0 + let l:output[l:index]['col'] = l:match[2] + 0 + endif + else + let l:isError = l:match[1] is? 'Error' + + call add(l:output, { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': l:isError ? 'E' : 'W', + \}) + endif + endfor + + return l:output +endfunction + +function! ale_linters#solidity#solc#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'solidity_solc_executable') + + return l:executable . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s' +endfunction + +call ale#linter#Define('solidity', { +\ 'name': 'solc', +\ 'executable': {b -> ale#Var(b, 'solidity_solc_executable')}, +\ 'command': function('ale_linters#solidity#solc#GetCommand'), +\ 'callback': 'ale_linters#solidity#solc#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/solidity/solhint.vim b/sources_non_forked/ale/ale_linters/solidity/solhint.vim index 8ea33e07..9dc308fe 100644 --- a/sources_non_forked/ale/ale_linters/solidity/solhint.vim +++ b/sources_non_forked/ale/ale_linters/solidity/solhint.vim @@ -1,29 +1,83 @@ -" Author: Franco Victorio - https://github.com/fvictorio +" Authors: Franco Victorio <@fvictorio>, Henrique Barcelos <@hbarcelos> " Description: Report errors in Solidity code with solhint +call ale#Set('solidity_solhint_options', '') +call ale#Set('solidity_solhint_executable', 'solhint') +call ale#Set('solidity_solhint_use_global', get(g:, 'ale_use_global_executables', 0)) + function! ale_linters#solidity#solhint#Handle(buffer, lines) abort - " Matches patterns like the following: - " /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars) - let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$' let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:isError = l:match[3] is? 'error' + " Matches lines like the following: + " contracts/Bounty.sol:14:3: Expected indentation of 4 spaces but found 2 [Error/indent] + let l:lint_pattern = '\v^[^:]+:(\d+):(\d+): %(Parse error: )@ +\ ale#node#Executable(b, ale_linters#solidity#solhint#GetExecutable(b)) +\ . ale#Pad(ale#Var(b, 'solidity_solhint_options')) +\ . ' --formatter unix %s' +\ }, \ 'callback': 'ale_linters#solidity#solhint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim index 92ef4d63..5594e3b8 100644 --- a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim +++ b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim @@ -29,11 +29,18 @@ call ale#Set('spec_rpmlint_executable', 'rpmlint') call ale#Set('spec_rpmlint_options', '') -function! ale_linters#spec#rpmlint#GetCommand(buffer) abort +function! ale_linters#spec#rpmlint#GetCommand(buffer, version) abort + if ale#semver#GTE(a:version, [2, 0, 0]) + " The -o/--option flag was removed in version 2.0.0 + let l:version_dependent_args = '' + else + let l:version_dependent_args = ' -o "NetworkEnabled False"' + endif + return '%e' \ . ale#Pad(ale#Var(a:buffer, 'spec_rpmlint_options')) - \ . ' -o "NetworkEnabled False"' \ . ' -v' + \ . l:version_dependent_args \ . ' %t' endfunction @@ -73,6 +80,11 @@ endfunction call ale#linter#Define('spec', { \ 'name': 'rpmlint', \ 'executable': {b -> ale#Var(b, 'spec_rpmlint_executable')}, -\ 'command': function('ale_linters#spec#rpmlint#GetCommand'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'spec_rpmlint_executable'), +\ '%e --version', +\ function('ale_linters#spec#rpmlint#GetCommand'), +\ )}, \ 'callback': 'ale_linters#spec#rpmlint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/sql/sqlfluff.vim b/sources_non_forked/ale/ale_linters/sql/sqlfluff.vim new file mode 100644 index 00000000..91d69c12 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sql/sqlfluff.vim @@ -0,0 +1,108 @@ +" Author: Carl Smedstad +" Description: sqlfluff for SQL files + +let g:ale_sql_sqlfluff_executable = +\ get(g:, 'ale_sql_sqlfluff_executable', 'sqlfluff') + +let g:ale_sql_sqlfluff_options = +\ get(g:, 'ale_sql_sqlfluff_options', '') + +function! ale_linters#sql#sqlfluff#Executable(buffer) abort + return ale#Var(a:buffer, 'sql_sqlfluff_executable') +endfunction + +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') + + let l:cmd = + \ ale#Escape(l:executable) + \ . ' lint' + + let l:config_file = ale#path#FindNearestFile(a:buffer, '.sqlfluff') + + if !empty(l:config_file) + let l:cmd .= ' --config ' . ale#Escape(l:config_file) + else + let l:cmd .= ' --dialect ansi' + endif + + let l:cmd .= + \ ' --format json ' + \ . l:options + \ . ' %t' + + return l:cmd +endfunction + +function! ale_linters#sql#sqlfluff#Handle(buffer, version, lines) abort + let l:output = [] + let l:json_lines = ale#util#FuzzyJSONDecode(a:lines, []) + + if empty(l:json_lines) + return l:output + endif + + let l:json = l:json_lines[0] + + " if there's no warning, 'result' is `null`. + if empty(get(l:json, 'violations')) + return l:output + endif + + if ale#semver#GTE(a:version, [3, 0, 0]) + for l:violation in get(l:json, 'violations', []) + let l:err = { + \ 'filename': l:json.filepath, + \ 'lnum': l:violation.start_line_no, + \ 'col': l:violation.start_line_pos, + \ 'text': l:violation.description, + \ 'code': l:violation.code, + \ 'type': 'W', + \} + + if has_key(l:violation, 'end_line_no') + let l:err.end_lnum = l:violation.end_line_no + endif + + if has_key(l:violation, 'end_line_pos') + let l:err.end_col = l:violation.end_line_pos + endif + + call add(l:output, l:err) + 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 + +call ale#linter#Define('sql', { +\ 'name': 'sqlfluff', +\ 'executable': function('ale_linters#sql#sqlfluff#Executable'), +\ '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/sql/sqllint.vim b/sources_non_forked/ale/ale_linters/sql/sqllint.vim new file mode 100644 index 00000000..78396fe9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sql/sqllint.vim @@ -0,0 +1,33 @@ +" ale_linters/sql/sqllint.vim +" Author: Joe Reynolds +" Description: sql-lint for SQL files. +" sql-lint can be found at +" https://www.npmjs.com/package/sql-lint +" https://github.com/joereynolds/sql-lint + +function! ale_linters#sql#sqllint#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " stdin:1 [ER_NO_DB_ERROR] No database selected + let l:pattern = '\v^[^:]+:(\d+) (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3][0], + \ 'text': l:match[0], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sql', { +\ 'name': 'sqllint', +\ 'aliases': ['sql-lint'], +\ 'executable': 'sql-lint', +\ 'command': 'sql-lint', +\ 'callback': 'ale_linters#sql#sqllint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim index ce6f9426..652e15d2 100644 --- a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim @@ -12,7 +12,8 @@ endfunction call ale#linter#Define('stylus', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'stylus_stylelint', [ +\ 'output_stream': 'both', +\ 'executable': {b -> ale#path#FindExecutable(b, 'stylus_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#stylus#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim b/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim index 6c705e46..a12191b8 100644 --- a/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim @@ -13,7 +13,8 @@ endfunction call ale#linter#Define('sugarss', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'sugarss_stylelint', [ +\ 'output_stream': 'both', +\ 'executable': {b -> ale#path#FindExecutable(b, 'sugarss_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#sugarss#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim b/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim new file mode 100644 index 00000000..2200b582 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim @@ -0,0 +1,21 @@ +" Author: Joakim Repomaa +" Description: Svelte Language Server integration for ALE + +call ale#Set('svelte_svelteserver_executable', 'svelteserver') +call ale#Set('svelte_svelteserver_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#svelte#svelteserver#GetProjectRoot(buffer) abort + let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json') + + return !empty(l:package_path) ? fnamemodify(l:package_path, ':h') : '' +endfunction + +call ale#linter#Define('svelte', { +\ 'name': 'svelteserver', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'svelte_svelteserver', [ +\ 'node_modules/.bin/svelteserver', +\ ])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#svelte#svelteserver#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim b/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim new file mode 100644 index 00000000..4c61764d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim @@ -0,0 +1,43 @@ +" Authors: Klaas Pieter Annema , bosr +" Description: Support for swift-format https://github.com/apple/swift-format + +function! ale_linters#swift#appleswiftformat#GetLinterCommand(buffer) abort + let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' lint %t' + let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer) + + if l:config_args isnot# '' + let l:command_args = l:command_args . ' ' . l:config_args + endif + + return l:command_args +endfunction + +function! ale_linters#swift#appleswiftformat#Handle(buffer, lines) abort + " Matches the typical output of swift-format, that is lines of the following pattern: + " + " Sources/main.swift:4:21: warning: [DoNotUseSemicolons] remove ';' and move the next statement to the new line + " Sources/main.swift:3:12: warning: [Spacing] remove 1 space + let l:pattern = '\v^.*:(\d+):(\d+): (\S+): \[(\S+)\] (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \ 'code': l:match[4], + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('swift', { +\ 'name': 'apple-swift-format', +\ 'executable': function('ale#swift#GetAppleSwiftFormatExecutable'), +\ 'command': function('ale_linters#swift#appleswiftformat#GetLinterCommand'), +\ 'output_stream': 'stderr', +\ 'language': 'swift', +\ 'callback': 'ale_linters#swift#appleswiftformat#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/swift/cspell.vim b/sources_non_forked/ale/ale_linters/swift/cspell.vim new file mode 100644 index 00000000..25451e9d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/swift/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Swift files. + +call ale#handlers#cspell#DefineLinter('swift') diff --git a/sources_non_forked/ale/ale_linters/swift/sourcekitlsp.vim b/sources_non_forked/ale/ale_linters/swift/sourcekitlsp.vim index 560893bf..a403dcc1 100644 --- a/sources_non_forked/ale/ale_linters/swift/sourcekitlsp.vim +++ b/sources_non_forked/ale/ale_linters/swift/sourcekitlsp.vim @@ -5,6 +5,7 @@ call ale#Set('sourcekit_lsp_executable', 'sourcekit-lsp') call ale#linter#Define('swift', { \ 'name': 'sourcekitlsp', +\ 'aliases': ['sourcekit'], \ 'lsp': 'stdio', \ 'executable': {b -> ale#Var(b, 'sourcekit_lsp_executable')}, \ 'command': '%e', diff --git a/sources_non_forked/ale/ale_linters/swift/swiftlint.vim b/sources_non_forked/ale/ale_linters/swift/swiftlint.vim index 237c45d3..d08c68f6 100644 --- a/sources_non_forked/ale/ale_linters/swift/swiftlint.vim +++ b/sources_non_forked/ale/ale_linters/swift/swiftlint.vim @@ -5,7 +5,7 @@ call ale#Set('swift_swiftlint_executable', 'swiftlint') call ale#Set('swift_swiftlint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#swift#swiftlint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'swift_swiftlint', [ + return ale#path#FindExecutable(a:buffer, 'swift_swiftlint', [ \ 'Pods/SwiftLint/swiftlint', \ 'ios/Pods/SwiftLint/swiftlint', \ 'swiftlint', diff --git a/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim b/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim new file mode 100644 index 00000000..64eef8cf --- /dev/null +++ b/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim @@ -0,0 +1,18 @@ +function! ale_linters#systemd#systemd_analyze#Handle(buffer, lines) abort + return ale#util#MapMatches(a:lines, '\v(.+):([0-9]+): (.+)', {match -> { + \ 'lnum': str2nr(match[2]), + \ 'col': 1, + \ 'type': 'W', + \ 'text': match[3], + \}}) +endfunction + +call ale#linter#Define('systemd', { +\ 'name': 'systemd_analyze', +\ 'aliases': ['systemd-analyze'], +\ 'executable': 'systemd-analyze', +\ 'command': 'SYSTEMD_LOG_COLOR=0 %e --user verify %s', +\ 'callback': 'ale_linters#systemd#systemd_analyze#Handle', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/checkov.vim b/sources_non_forked/ale/ale_linters/terraform/checkov.vim new file mode 100644 index 00000000..568b46e1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/checkov.vim @@ -0,0 +1,41 @@ +" Author: Thyme-87 +" Description: use checkov for providing warnings via ale + +call ale#Set('terraform_checkov_executable', 'checkov') +call ale#Set('terraform_checkov_options', '') + +function! ale_linters#terraform#checkov#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'terraform_checkov_executable') +endfunction + +function! ale_linters#terraform#checkov#GetCommand(buffer) abort + return '%e ' . '-f %t -o json --quiet ' . ale#Var(a:buffer, 'terraform_checkov_options') +endfunction + +function! ale_linters#terraform#checkov#Handle(buffer, lines) abort + let l:output = [] + + let l:results = get(get(ale#util#FuzzyJSONDecode(a:lines, {}), 'results', []), 'failed_checks', []) + + for l:violation in l:results + call add(l:output, { + \ 'filename': l:violation['file_path'], + \ 'lnum': l:violation['file_line_range'][0], + \ 'end_lnum': l:violation['file_line_range'][1], + \ 'text': l:violation['check_name'] . ' [' . l:violation['check_id'] . ']', + \ 'detail': l:violation['check_id'] . ': ' . l:violation['check_name'] . "\n" . + \ 'For more information, see: '. l:violation['guideline'], + \ 'type': 'W', + \ }) + endfor + + return l:output +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'checkov', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#terraform#checkov#GetExecutable'), +\ 'command': function('ale_linters#terraform#checkov#GetCommand'), +\ 'callback': 'ale_linters#terraform#checkov#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform.vim b/sources_non_forked/ale/ale_linters/terraform/terraform.vim index 0429cb7a..1beb8501 100644 --- a/sources_non_forked/ale/ale_linters/terraform/terraform.vim +++ b/sources_non_forked/ale/ale_linters/terraform/terraform.vim @@ -9,30 +9,50 @@ endfunction function! ale_linters#terraform#terraform#GetCommand(buffer) abort return ale#Escape(ale_linters#terraform#terraform#GetExecutable(a:buffer)) - \ . ' fmt -no-color --check=true -' + \ . ' validate -no-color -json ' +endfunction + +function! ale_linters#terraform#terraform#GetType(severity) abort + if a:severity is? 'warning' + return 'W' + endif + + return 'E' +endfunction + +function! ale_linters#terraform#terraform#GetDetail(error) abort + let l:detail = get(a:error, 'detail', '') + + if strlen(l:detail) > 0 + return l:detail + else + return get(a:error, 'summary', '') + endif endfunction function! ale_linters#terraform#terraform#Handle(buffer, lines) abort - let l:head = '^Error running fmt: In : ' let l:output = [] - let l:patterns = [ - \ l:head.'At \(\d\+\):\(\d\+\): \(.*\)$', - \ l:head.'\(.*\)$' - \] - for l:match in ale#util#GetMatches(a:lines, l:patterns) - if len(l:match[2]) > 0 + let l:errors = ale#util#FuzzyJSONDecode(a:lines, {'diagnostics': []}) + let l:dir = expand('#' . a:buffer . ':p:h') + let l:file = expand('#' . a:buffer . ':p') + + for l:error in l:errors['diagnostics'] + if has_key(l:error, 'range') call add(l:output, { - \ 'lnum': str2nr(l:match[1]), - \ 'col': str2nr(l:match[2]), - \ 'text': l:match[3], - \ 'type': 'E', + \ 'filename': ale#path#GetAbsPath(l:dir, l:error['range']['filename']), + \ 'lnum': l:error['range']['start']['line'], + \ 'col': l:error['range']['start']['column'], + \ 'text': ale_linters#terraform#terraform#GetDetail(l:error), + \ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']), \}) else call add(l:output, { - \ 'lnum': line('$'), - \ 'text': l:match[1], - \ 'type': 'E', + \ 'filename': l:file, + \ 'lnum': 0, + \ 'col': 0, + \ 'text': ale_linters#terraform#terraform#GetDetail(l:error), + \ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']), \}) endif endfor @@ -42,7 +62,7 @@ endfunction call ale#linter#Define('terraform', { \ 'name': 'terraform', -\ 'output_stream': 'stderr', +\ 'output_stream': 'stdout', \ 'executable': function('ale_linters#terraform#terraform#GetExecutable'), \ 'command': function('ale_linters#terraform#terraform#GetCommand'), \ 'callback': 'ale_linters#terraform#terraform#Handle', diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim b/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim new file mode 100644 index 00000000..7dc77941 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim @@ -0,0 +1,39 @@ +" Author: Horacio Sanson +" Description: terraform-ls integration for ALE (cf. https://github.com/hashicorp/terraform-ls) + +call ale#Set('terraform_terraform_executable', 'terraform') +call ale#Set('terraform_ls_executable', 'terraform-ls') +call ale#Set('terraform_ls_options', '') + +function! ale_linters#terraform#terraform_ls#GetTerraformExecutable(buffer) abort + let l:terraform_executable = ale#Var(a:buffer, 'terraform_terraform_executable') + + if(ale#path#IsAbsolute(l:terraform_executable)) + return '-tf-exec ' . l:terraform_executable + endif + + return '' +endfunction + +function! ale_linters#terraform#terraform_ls#GetCommand(buffer) abort + return '%e' + \ . ale#Pad('serve') + \ . ale#Pad(ale_linters#terraform#terraform_ls#GetTerraformExecutable(a:buffer)) + \ . ale#Pad(ale#Var(a:buffer, 'terraform_ls_options')) +endfunction + +function! ale_linters#terraform#terraform_ls#GetProjectRoot(buffer) abort + let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform') + + return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'terraform_ls', +\ 'aliases': ['terraformls'], +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'terraform_ls_executable')}, +\ 'command': function('ale_linters#terraform#terraform_ls#GetCommand'), +\ 'project_root': function('ale_linters#terraform#terraform_ls#GetProjectRoot'), +\ 'language': 'terraform', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim b/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim new file mode 100644 index 00000000..e2408c15 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim @@ -0,0 +1,25 @@ +" Author: OJFord +" Description: terraform-lsp integration for ALE (cf. https://github.com/juliosueiras/terraform-lsp) + +call ale#Set('terraform_langserver_executable', 'terraform-lsp') +call ale#Set('terraform_langserver_options', '') + +function! ale_linters#terraform#terraform_lsp#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'terraform_langserver_options')) +endfunction + +function! ale_linters#terraform#terraform_lsp#GetProjectRoot(buffer) abort + let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform') + + return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'terraform_lsp', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'terraform_langserver_executable')}, +\ 'command': function('ale_linters#terraform#terraform_lsp#GetCommand'), +\ 'project_root': function('ale_linters#terraform#terraform_lsp#GetProjectRoot'), +\ 'language': 'terraform', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/tflint.vim b/sources_non_forked/ale/ale_linters/terraform/tflint.vim index 6d54a8b1..86b5b74a 100644 --- a/sources_non_forked/ale/ale_linters/terraform/tflint.vim +++ b/sources_non_forked/ale/ale_linters/terraform/tflint.vim @@ -9,23 +9,69 @@ call ale#Set('terraform_tflint_executable', 'tflint') function! ale_linters#terraform#tflint#Handle(buffer, lines) abort let l:output = [] + let l:pattern = '\v^(.*):(\d+),(\d+)-(\d+)?,?(\d+): (.{-1,}); (.+)$' + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) - for l:error in ale#util#FuzzyJSONDecode(a:lines, []) - if l:error.type is# 'ERROR' - let l:type = 'E' - elseif l:error.type is# 'NOTICE' - let l:type = 'I' - else - let l:type = 'W' - endif + " This is a rough test for tflint's output format + " On versions prior to 0.11 it outputs all errors as a single level list + if type(l:json) is v:t_list + for l:error in l:json + if l:error.type is# 'ERROR' + let l:type = 'E' + elseif l:error.type is# 'NOTICE' + let l:type = 'I' + else + let l:type = 'W' + endif - call add(l:output, { - \ 'lnum': l:error.line, - \ 'text': l:error.message, - \ 'type': l:type, - \ 'code': l:error.detector, - \}) - endfor + call add(l:output, { + \ 'lnum': l:error.line, + \ 'text': l:error.message, + \ 'type': l:type, + \ 'code': l:error.detector, + \}) + endfor + else + for l:error in get(l:json, 'errors', []) + for l:match in ale#util#GetMatches(l:error.message, [l:pattern]) + if l:match[4] is# '' + let l:match[4] = l:match[2] + endif + + call add(l:output, { + \ 'filename': l:match[1], + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'end_lnum': str2nr(l:match[4]), + \ 'end_col': str2nr(l:match[5]), + \ 'text': l:match[7], + \ 'code': l:match[6], + \ 'type': 'E', + \}) + endfor + endfor + + for l:error in get(l:json, 'issues', []) + if l:error.rule.severity is# 'ERROR' + let l:type = 'E' + elseif l:error.rule.severity is# 'NOTICE' + let l:type = 'I' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'filename': l:error.range.filename, + \ 'lnum': l:error.range.start.line, + \ 'col': l:error.range.start.column, + \ 'end_lnum': l:error.range.end.line, + \ 'end_col': l:error.range.end.column, + \ 'text': l:error.message, + \ 'code': l:error.rule.name, + \ 'type': l:type, + \}) + endfor + endif return l:output endfunction @@ -45,7 +91,7 @@ function! ale_linters#terraform#tflint#GetCommand(buffer) abort let l:cmd .= ' ' . l:opts endif - let l:cmd .= ' -f json %t' + let l:cmd .= ' -f json' return l:cmd endfunction @@ -53,6 +99,7 @@ endfunction call ale#linter#Define('terraform', { \ 'name': 'tflint', \ 'executable': {b -> ale#Var(b, 'terraform_tflint_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#terraform#tflint#GetCommand'), \ 'callback': 'ale_linters#terraform#tflint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/terraform/tfsec.vim b/sources_non_forked/ale/ale_linters/terraform/tfsec.vim new file mode 100644 index 00000000..d29cdd13 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/tfsec.vim @@ -0,0 +1,87 @@ +" Description: tfsec for Terraform files +" +" See: https://www.terraform.io/ +" https://github.com/aquasecurity/tfsec + +call ale#Set('terraform_tfsec_options', '') +call ale#Set('terraform_tfsec_executable', 'tfsec') + +let s:separator = has('win32') ? '\' : '/' + +function! ale_linters#terraform#tfsec#Handle(buffer, lines) abort + let l:output = [] + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) + + " if there's no warning, 'result' is `null`. + if empty(get(l:json, 'results')) + return l:output + endif + + for l:result in get(l:json, 'results', []) + if l:result.severity is# 'LOW' + let l:type = 'I' + elseif l:result.severity is# 'CRITICAL' + let l:type = 'E' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'filename': l:result.location.filename, + \ 'lnum': l:result.location.start_line, + \ 'end_lnum': l:result.location.end_line, + \ 'text': l:result.description, + \ 'code': l:result.long_id, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +" Construct command arguments to tfsec with `terraform_tfsec_options`. +function! ale_linters#terraform#tfsec#GetCommand(buffer) abort + let l:cmd = '%e' + + let l:config = ale_linters#terraform#tfsec#FindConfig(a:buffer) + + if !empty(l:config) + let l:cmd .= ' --config-file ' . l:config + endif + + let l:opts = ale#Var(a:buffer, 'terraform_tfsec_options') + + if !empty(l:opts) + let l:cmd .= ' ' . l:opts + endif + + let l:cmd .= ' --format json' + + return l:cmd +endfunction + +" Find the nearest configuration file of tfsec. +function! ale_linters#terraform#tfsec#FindConfig(buffer) abort + let l:config_dir = ale#path#FindNearestDirectory(a:buffer, '.tfsec') + + if !empty(l:config_dir) + " https://aquasecurity.github.io/tfsec/v1.28.0/guides/configuration/config/ + for l:basename in ['config.yml', 'config.json'] + let l:config = ale#path#Simplify(join([l:config_dir, l:basename], s:separator)) + + if filereadable(l:config) + return ale#Escape(l:config) + endif + endfor + endif + + return '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'tfsec', +\ 'executable': {b -> ale#Var(b, 'terraform_tfsec_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#terraform#tfsec#GetCommand'), +\ 'callback': 'ale_linters#terraform#tfsec#Handle', +\}) 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 - " 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/tex/cspell.vim b/sources_non_forked/ale/ale_linters/tex/cspell.vim new file mode 100644 index 00000000..4cf2b08e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for TeX files. + +call ale#handlers#cspell#DefineLinter('tex') diff --git a/sources_non_forked/ale/ale_linters/tex/lacheck.vim b/sources_non_forked/ale/ale_linters/tex/lacheck.vim index 19d69403..35aad083 100644 --- a/sources_non_forked/ale/ale_linters/tex/lacheck.vim +++ b/sources_non_forked/ale/ale_linters/tex/lacheck.vim @@ -13,7 +13,7 @@ function! ale_linters#tex#lacheck#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) " lacheck follows `\input{}` commands. If the cwd is not the same as the - " file in the buffer then it will fail to find the inputed items. We do not + " file in the buffer then it will fail to find the inputted items. We do not " want warnings from those items anyway if !empty(matchstr(l:match[3], '^Could not open ".\+"$')) continue diff --git a/sources_non_forked/ale/ale_linters/tex/texlab.vim b/sources_non_forked/ale/ale_linters/tex/texlab.vim index 5ead74b4..8e96b80b 100644 --- a/sources_non_forked/ale/ale_linters/tex/texlab.vim +++ b/sources_non_forked/ale/ale_linters/tex/texlab.vim @@ -1,11 +1,15 @@ " Author: Ricardo Liang +" Author: ourigen " Description: Texlab language server (Rust rewrite) call ale#Set('tex_texlab_executable', 'texlab') call ale#Set('tex_texlab_options', '') +call ale#Set('tex_texlab_config', {}) function! ale_linters#tex#texlab#GetProjectRoot(buffer) abort - return '' + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' endfunction function! ale_linters#tex#texlab#GetCommand(buffer) abort @@ -18,4 +22,5 @@ call ale#linter#Define('tex', { \ 'executable': {b -> ale#Var(b, 'tex_texlab_executable')}, \ 'command': function('ale_linters#tex#texlab#GetCommand'), \ 'project_root': function('ale_linters#tex#texlab#GetProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'tex_texlab_config')}, \}) diff --git a/sources_non_forked/ale/ale_linters/texinfo/cspell.vim b/sources_non_forked/ale/ale_linters/texinfo/cspell.vim new file mode 100644 index 00000000..d691b3a7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/texinfo/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for TeXInfo files. + +call ale#handlers#cspell#DefineLinter('texinfo') diff --git a/sources_non_forked/ale/ale_linters/text/cspell.vim b/sources_non_forked/ale/ale_linters/text/cspell.vim new file mode 100644 index 00000000..813ef3b8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for general text files. + +call ale#handlers#cspell#DefineLinter('text') diff --git a/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim b/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim new file mode 100644 index 00000000..bf929d10 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim @@ -0,0 +1,46 @@ +" Author: Jon Parise + +call ale#Set('thrift_thriftcheck_executable', 'thriftcheck') +call ale#Set('thrift_thriftcheck_options', '') + +function! ale_linters#thrift#thriftcheck#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'thrift_thriftcheck_options')) + \ . ' --stdin-filename %s' + \ . ' %t' +endfunction + +function! ale_linters#thrift#thriftcheck#Handle(buffer, lines) abort + " Matches lines like the following: + " + " file.thrift:1:1: error: "py" namespace must match "^idl\\." (namespace.pattern) + " file.thrift:3:5: warning: 64-bit integer constant -2147483649 may not work in all languages (int.64bit) + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+): ?([^:]+): (.+) \(([^\)]+)\)$' + + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[3] is# 'warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'text': l:match[4], + \ 'code': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('thrift', { +\ 'name': 'thriftcheck', +\ 'executable': {b -> ale#Var(b, 'thrift_thriftcheck_executable')}, +\ 'command': function('ale_linters#thrift#thriftcheck#GetCommand'), +\ 'callback': 'ale_linters#thrift#thriftcheck#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 +" 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/typescript/cspell.vim b/sources_non_forked/ale/ale_linters/typescript/cspell.vim new file mode 100644 index 00000000..6061b75c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for TypeScript files. + +call ale#handlers#cspell#DefineLinter('typescript') diff --git a/sources_non_forked/ale/ale_linters/typescript/deno.vim b/sources_non_forked/ale/ale_linters/typescript/deno.vim new file mode 100644 index 00000000..f47fac7a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/deno.vim @@ -0,0 +1,12 @@ +" Author: Mohammed Chelouti - https://github.com/motato1 +" Arnold Chand +" Description: Deno lsp linter for TypeScript files. + +call ale#linter#Define('typescript', { +\ 'name': 'deno', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#deno#GetExecutable'), +\ 'command': '%e lsp', +\ 'project_root': function('ale#handlers#deno#GetProjectRoot'), +\ 'initialization_options': function('ale#handlers#deno#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/eslint.vim b/sources_non_forked/ale/ale_linters/typescript/eslint.vim index 33a21440..eaeac307 100644 --- a/sources_non_forked/ale/ale_linters/typescript/eslint.vim +++ b/sources_non_forked/ale/ale_linters/typescript/eslint.vim @@ -4,6 +4,7 @@ call ale#linter#Define('typescript', { \ 'name': 'eslint', \ '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/typescript/standard.vim b/sources_non_forked/ale/ale_linters/typescript/standard.vim new file mode 100644 index 00000000..1d524a10 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/standard.vim @@ -0,0 +1,31 @@ +" Author: Ahmed El Gabri <@ahmedelgabri> +" Description: standardjs for typescript files + +call ale#Set('typescript_standard_executable', 'standard') +call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typescript_standard_options', '') + +function! ale_linters#typescript#standard#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'typescript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', + \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/.bin/standard', + \]) +endfunction + +function! ale_linters#typescript#standard#GetCommand(buffer) abort + let l:executable = ale_linters#typescript#standard#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'typescript_standard_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin %s' +endfunction + +" standard uses eslint and the output format is the same +call ale#linter#Define('typescript', { +\ 'name': 'standard', +\ 'executable': function('ale_linters#typescript#standard#GetExecutable'), +\ 'command': function('ale_linters#typescript#standard#GetCommand'), +\ 'callback': 'ale#handlers#eslint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tslint.vim b/sources_non_forked/ale/ale_linters/typescript/tslint.vim index f70c2e45..886a3cd4 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tslint.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tslint.vim @@ -59,8 +59,7 @@ function! ale_linters#typescript#tslint#GetCommand(buffer) abort \ ? ' -r ' . ale#Escape(l:tslint_rules_dir) \ : '' - return ale#path#BufferCdString(a:buffer) - \ . ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer)) + return ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer)) \ . ' --format json' \ . l:tslint_config_option \ . l:tslint_rules_option @@ -70,6 +69,7 @@ endfunction call ale#linter#Define('typescript', { \ 'name': 'tslint', \ 'executable': function('ale#handlers#tslint#GetExecutable'), +\ 'cwd': '%s:h', \ 'command': function('ale_linters#typescript#tslint#GetCommand'), \ 'callback': 'ale_linters#typescript#tslint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim index 840889f3..d97becca 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim @@ -8,7 +8,8 @@ call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executabl call ale#linter#Define('typescript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable': {b -> ale#node#FindExecutable(b, 'typescript_tsserver', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'typescript_tsserver', [ +\ '.yarn/sdks/typescript/bin/tsserver', \ 'node_modules/.bin/tsserver', \ ])}, \ 'command': '%e', diff --git a/sources_non_forked/ale/ale_linters/typescript/xo.vim b/sources_non_forked/ale/ale_linters/typescript/xo.vim index 0a3a717b..6f4ee50c 100644 --- a/sources_non_forked/ale/ale_linters/typescript/xo.vim +++ b/sources_non_forked/ale/ale_linters/typescript/xo.vim @@ -1,23 +1,6 @@ -call ale#Set('typescript_xo_executable', 'xo') -call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('typescript_xo_options', '') - -function! ale_linters#typescript#xo#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'typescript_xo', [ - \ 'node_modules/.bin/xo', - \]) -endfunction - -function! ale_linters#typescript#xo#GetCommand(buffer) abort - return ale#Escape(ale_linters#typescript#xo#GetExecutable(a:buffer)) - \ . ale#Pad(ale#Var(a:buffer, 'typescript_xo_options')) - \ . ' --reporter json --stdin --stdin-filename %s' -endfunction - -" xo uses eslint and the output format is the same call ale#linter#Define('typescript', { \ 'name': 'xo', -\ 'executable': function('ale_linters#typescript#xo#GetExecutable'), -\ 'command': function('ale_linters#typescript#xo#GetCommand'), -\ 'callback': 'ale#handlers#eslint#HandleJSON', +\ 'executable': function('ale#handlers#xo#GetExecutable'), +\ 'command': function('ale#handlers#xo#GetLintCommand'), +\ 'callback': 'ale#handlers#xo#HandleJSON', \}) diff --git a/sources_non_forked/ale/ale_linters/v/v.vim b/sources_non_forked/ale/ale_linters/v/v.vim new file mode 100644 index 00000000..dfe6f562 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/v/v.vim @@ -0,0 +1,73 @@ +" Author: fiatjaf +" Description: v build for V files + +call ale#Set('v_v_executable', 'v') +call ale#Set('v_v_options', '') + +function! ale_linters#v#v#Handler(buffer, lines) abort + let l:dir = expand('#' . a:buffer . ':p:h') + let l:output = [] + + " Matches patterns like the following: + " + " ./const.v:4:3: warning: const names cannot contain uppercase letters, use snake_case instead + " 2 | + " 3 | const ( + " 4 | BUTTON_TEXT = 'OK' + " | ~~~~~~~~~~~ + " 5 | ) + " ./main.v:4:8: warning: module 'os' is imported but never used + " 2 | + " 3 | import ui + " 4 | import os + " | ~~ + " 5 | + " 6 | const ( + " ./main.v:20:10: error: undefined ident: `win_widt` + " 18 | mut app := &App{} + " 19 | app.window = ui.window({ + " 20 | width: win_widt + " | ~~~~~~~~ + " 21 | height: win_height + " 22 | title: 'Counter' + let l:current = {} + + for l:line in a:lines + " matches basic error description + let l:match = matchlist(l:line, + \ '\([^:]\+\):\([^:]\+\):\([^:]\+\): \([^:]\+\): \(.*\)') + + if !empty(l:match) + let l:current = { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[5], + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \} + call add(l:output, l:current) + continue + endif + + " try to get information about the ending column + let l:tildematch = matchstr(l:line, '\~\+') + + if !empty(l:tildematch) + let l:current['end_col'] = l:current['col'] + len(l:tildematch) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('v', { +\ 'name': 'v', +\ 'executable': {b -> ale#Var(b, 'v_v_executable')}, +\ 'command': {b -> +\ '%e' . ale#Pad(ale#Var(b, 'v_v_options')) +\ . ' . -o /tmp/vim-ale-v' +\ }, +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#v#v#Handler', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/vala/vala_lint.vim b/sources_non_forked/ale/ale_linters/vala/vala_lint.vim new file mode 100644 index 00000000..7f8a566a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vala/vala_lint.vim @@ -0,0 +1,66 @@ +" Author: Atsuya Takagi +" Description: A linter for Vala using Vala-Lint. + +call ale#Set('vala_vala_lint_config_filename', 'vala-lint.conf') +call ale#Set('vala_vala_lint_executable', 'io.elementary.vala-lint') + +function! ale_linters#vala#vala_lint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'vala_vala_lint_executable') +endfunction + +function! ale_linters#vala#vala_lint#GetCommand(buffer) abort + let l:command = ale_linters#vala#vala_lint#GetExecutable(a:buffer) + + let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename') + let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename) + + if !empty(l:config_path) + let l:command .= ' -c ' . l:config_path + endif + + return l:command . ' %s' +endfunction + +function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort + let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(error\|warn\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)' + let l:output = [] + + for l:line in a:lines + " remove color escape sequences since vala-lint doesn't support + " output without colors + let l:cleaned_line = substitute(l:line, '\e\[[0-9;]\+[mK]', '', 'g') + let l:match = matchlist(l:cleaned_line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:refined_type = l:match[3] is# 'warn' ? 'W' : 'E' + let l:cleaned_text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') + + let l:lnum = l:match[1] + 0 + let l:column = l:match[2] + 0 + let l:type = l:refined_type + let l:text = l:cleaned_text + let l:code = l:match[5] + + call add(l:output, { + \ 'lnum': l:lnum, + \ 'col': l:column, + \ 'text': l:text, + \ 'type': l:type, + \ 'code': l:code, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('vala', { +\ 'name': 'vala_lint', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#vala#vala_lint#GetExecutable'), +\ 'command': function('ale_linters#vala#vala_lint#GetCommand'), +\ 'callback': 'ale_linters#vala#vala_lint#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim b/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim new file mode 100644 index 00000000..b05d8565 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim @@ -0,0 +1,5 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#handlers#hdl_checker#DefineLinter('verilog') diff --git a/sources_non_forked/ale/ale_linters/verilog/iverilog.vim b/sources_non_forked/ale/ale_linters/verilog/iverilog.vim index e081f33f..54d55d79 100644 --- a/sources_non_forked/ale/ale_linters/verilog/iverilog.vim +++ b/sources_non_forked/ale/ale_linters/verilog/iverilog.vim @@ -5,6 +5,7 @@ call ale#Set('verilog_iverilog_options', '') function! ale_linters#verilog#iverilog#GetCommand(buffer) abort return 'iverilog -t null -Wall ' + \ . '-y%s:h ' \ . ale#Var(a:buffer, 'verilog_iverilog_options') \ . ' %t' endfunction 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 +" 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/verilog/verilator.vim b/sources_non_forked/ale/ale_linters/verilog/verilator.vim index 64bb6e41..006e310d 100644 --- a/sources_non_forked/ale/ale_linters/verilog/verilator.vim +++ b/sources_non_forked/ale/ale_linters/verilog/verilator.vim @@ -7,16 +7,11 @@ if !exists('g:ale_verilog_verilator_options') endif function! ale_linters#verilog#verilator#GetCommand(buffer) abort - let l:filename = ale#util#Tempname() . '_verilator_linted.v' - - " Create a special filename, so we can detect it in the handler. - call ale#command#ManageFile(a:buffer, l:filename) - let l:lines = getbufline(a:buffer, 1, '$') - call ale#util#Writefile(a:buffer, l:lines, l:filename) - + " the path to the current file is systematically added to the search path return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' + \ . '-I%s:h ' \ . ale#Var(a:buffer, 'verilog_verilator_options') .' ' - \ . ale#Escape(l:filename) + \ . '%t' endfunction function! ale_linters#verilog#verilator#Handle(buffer, lines) abort @@ -28,22 +23,28 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort " %Warning-UNDRIVEN: test.v:3: Signal is not driven: clk " %Warning-UNUSED: test.v:4: Signal is not used: dout " %Warning-BLKSEQ: test.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=). - let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\d\+\): \(.\+\)$' + " Since version 4.032 (04/2020) verilator linter messages also contain the column number, + " and look like: + " %Error: /tmp/test.sv:3:1: syntax error, unexpected endmodule, expecting ';' + " + " to stay compatible with old versions of the tool, the column number is + " optional in the researched pattern + let l:pattern = '^%\(Warning\|Error\)[^:]*:\s*\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:line = l:match[3] + 0 - let l:type = l:match[1] is# 'Error' ? 'E' : 'W' - let l:text = l:match[4] - let l:file = l:match[2] + let l:item = { + \ 'lnum': str2nr(l:match[3]), + \ 'text': l:match[5], + \ 'type': l:match[1] is# 'Error' ? 'E' : 'W', + \ 'filename': l:match[2], + \} - if l:file =~# '_verilator_linted.v' - call add(l:output, { - \ 'lnum': l:line, - \ 'text': l:text, - \ 'type': l:type, - \}) + if !empty(l:match[4]) + let l:item.col = str2nr(l:match[4]) endif + + call add(l:output, l:item) endfor return l:output diff --git a/sources_non_forked/ale/ale_linters/verilog/vlog.vim b/sources_non_forked/ale/ale_linters/verilog/vlog.vim index 37d21c4c..45e1977c 100644 --- a/sources_non_forked/ale/ale_linters/verilog/vlog.vim +++ b/sources_non_forked/ale/ale_linters/verilog/vlog.vim @@ -13,14 +13,30 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort "Matches patterns like the following: "** Warning: add.v(7): (vlog-2623) Undefined variable: C. "** Error: file.v(1): (vlog-13294) Identifier must be declared with a port mode: C. - let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:pattern = '^**\s\(\w*\): \([a-zA-Z0-9\-\.\_\/ ]\+\)(\(\d\+\)):\s\+\(.*\)' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': l:match[2] + 0, + \ 'lnum': l:match[3] + 0, \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', - \ 'text': l:match[3], + \ 'text': l:match[4], + \ 'filename': l:match[2], + \}) + endfor + + "Matches patterns like the following: + "** Warning: (vlog-2623) add.v(7): Undefined variable: C. + "** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C. + " let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:pattern = '^**\s\(\w*\):\s\([^)]*)\) \([a-zA-Z0-9\-\.\_\/ ]\+\)(\(\d\+\)):\s\+\(.*\)' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[4] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[2] . ' ' . l:match[5], + \ 'filename': l:match[3], \}) endfor diff --git a/sources_non_forked/ale/ale_linters/verilog/yosys.vim b/sources_non_forked/ale/ale_linters/verilog/yosys.vim new file mode 100644 index 00000000..29657755 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/yosys.vim @@ -0,0 +1,42 @@ +" Author: Nathan Sharp +" Description: Yosys for Verilog files + +call ale#Set('verilog_yosys_executable', 'yosys') +call ale#Set('verilog_yosys_options', '-Q -T -p ''read_verilog %s''') + +function! ale_linters#verilog#yosys#GetCommand(buffer) abort + return '%e ' . ale#Var(a:buffer, 'verilog_yosys_options') . ' 2>&1' +endfunction + +function! ale_linters#verilog#yosys#Handle(buffer, lines) abort + let l:output = [] + let l:path = fnamemodify(bufname(a:buffer), ':p') + + for l:match in ale#util#GetMatches(a:lines, '^\([^:]\+\):\(\d\+\): \(WARNING\|ERROR\): \(.\+\)$') + call add(l:output, { + \ 'lnum': str2nr(l:match[2]), + \ 'text': l:match[4], + \ 'type': l:match[3][0], + \ 'filename': l:match[1], + \}) + endfor + + for l:match in ale#util#GetMatches(a:lines, '^\(Warning\|ERROR\): \(.\+\)$') + call add(l:output, { + \ 'lnum': 1, + \ 'text': l:match[2], + \ 'type': l:match[1][0], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('verilog', { +\ 'name': 'yosys', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'verilog_yosys_executable')}, +\ 'command': function('ale_linters#verilog#yosys#GetCommand'), +\ 'callback': 'ale_linters#verilog#yosys#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim b/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim new file mode 100644 index 00000000..c9d306b3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim @@ -0,0 +1,5 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#handlers#hdl_checker#DefineLinter('vhdl') diff --git a/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim b/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim index 822eb30a..5ca2f149 100644 --- a/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim +++ b/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim @@ -22,16 +22,20 @@ function! s:GetALEProjectDir(buffer) abort return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable))) endfunction -function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort - let l:dir = s:GetALEProjectDir(a:buffer) +function! ale_linters#vim#ale_custom_linting_rules#GetCwd(buffer) abort + let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer) + return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable))) +endfunction + +function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort let l:temp_dir = ale#command#CreateDirectory(a:buffer) let l:temp_file = l:temp_dir . '/example.vim' let l:lines = getbufline(a:buffer, 1, '$') call ale#util#Writefile(a:buffer, l:lines, l:temp_file) - return ale#path#CdString(l:dir) . '%e ' . ale#Escape(l:temp_dir) + return '%e ' . ale#Escape(l:temp_dir) endfunction function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort @@ -59,6 +63,7 @@ endfunction call ale#linter#Define('vim', { \ 'name': 'ale_custom_linting_rules', \ 'executable': function('ale_linters#vim#ale_custom_linting_rules#GetExecutable'), +\ 'cwd': function('ale_linters#vim#ale_custom_linting_rules#GetCwd'), \ 'command': function('ale_linters#vim#ale_custom_linting_rules#GetCommand'), \ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle', \ 'read_buffer': 0, diff --git a/sources_non_forked/ale/ale_linters/vim/vimls.vim b/sources_non_forked/ale/ale_linters/vim/vimls.vim new file mode 100644 index 00000000..7003eb04 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vim/vimls.vim @@ -0,0 +1,61 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Vim Language Server integration for ALE + +call ale#Set('vim_vimls_executable', 'vim-language-server') +call ale#Set('vim_vimls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('vim_vimls_config', {}) + +function! ale_linters#vim#vimls#GetProjectRoot(buffer) abort + let l:trigger_file_candidates = [ + \ '.vimrc', + \ 'init.vim', + \] + + for l:candidate in l:trigger_file_candidates + let l:trigger_file = fnamemodify(bufname(a:buffer), ':t') + + if l:trigger_file is# l:candidate + return fnamemodify( + \ bufname(a:buffer), + \ ':h', + \) + endif + endfor + + let l:trigger_dir_candidates = [ + \ 'autoload', + \ 'plugin', + \ '.git', + \] + + let l:path_upwards = ale#path#Upwards(fnamemodify(bufname(a:buffer), ':p:h')) + + for l:path in l:path_upwards + for l:candidate in l:trigger_dir_candidates + let l:trigger_dir = ale#path#Simplify( + \ l:path . '/' . l:candidate, + \) + + if isdirectory(l:trigger_dir) + return fnamemodify( + \ l:trigger_dir, + \ ':p:h:h', + \) + endif + endfor + endfor + + return '' +endfunction + +call ale#linter#Define('vim', { +\ 'name': 'vimls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')}, +\ 'executable': {b -> ale#path#FindExecutable(b, 'vim_vimls', [ +\ 'node_modules/.bin/vim-language-server', +\ ])}, +\ 'command': '%e --stdio', +\ 'language': 'vim', +\ 'project_root': function('ale_linters#vim#vimls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/vim/vint.vim b/sources_non_forked/ale/ale_linters/vim/vint.vim index 65e19126..f7054ffb 100644 --- a/sources_non_forked/ale/ale_linters/vim/vint.vim +++ b/sources_non_forked/ale/ale_linters/vim/vint.vim @@ -5,7 +5,7 @@ call ale#Set('vim_vint_show_style_issues', 1) call ale#Set('vim_vint_executable', 'vint') let s:enable_neovim = has('nvim') ? ' --enable-neovim' : '' -let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})"' +let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {policy_name} - {description} (see {reference})"' function! ale_linters#vim#vint#GetCommand(buffer, version) abort let l:can_use_no_color_flag = empty(a:version) @@ -13,12 +13,17 @@ function! ale_linters#vim#vint#GetCommand(buffer, version) abort let l:warning_flag = ale#Var(a:buffer, 'vim_vint_show_style_issues') ? '-s' : '-w' + " Use the --stdin-display-name argument if supported, temp file otherwise. + let l:stdin_or_temp = ale#semver#GTE(a:version, [0, 4, 0]) + \ ? ' --stdin-display-name %s -' + \ : ' %t' + return '%e' \ . ' ' . l:warning_flag \ . (l:can_use_no_color_flag ? ' --no-color' : '') \ . s:enable_neovim \ . ' ' . s:format - \ . ' %t' + \ . l:stdin_or_temp endfunction let s:word_regex_list = [ diff --git a/sources_non_forked/ale/ale_linters/vue/cspell.vim b/sources_non_forked/ale/ale_linters/vue/cspell.vim new file mode 100644 index 00000000..2d8bfdc3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vue/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Vue files. + +call ale#handlers#cspell#DefineLinter('vue') diff --git a/sources_non_forked/ale/ale_linters/vue/vls.vim b/sources_non_forked/ale/ale_linters/vue/vls.vim index ac451f3c..009effd0 100644 --- a/sources_non_forked/ale/ale_linters/vue/vls.vim +++ b/sources_non_forked/ale/ale_linters/vue/vls.vim @@ -12,8 +12,9 @@ endfunction call ale#linter#Define('vue', { \ 'name': 'vls', +\ 'aliases': ['vuels'], \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'vue_vls', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_vls', [ \ 'node_modules/.bin/vls', \ ])}, \ 'command': '%e --stdio', diff --git a/sources_non_forked/ale/ale_linters/vue/volar.vim b/sources_non_forked/ale/ale_linters/vue/volar.vim new file mode 100644 index 00000000..953262b5 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vue/volar.vim @@ -0,0 +1,59 @@ +" Author: Arnold Chand +" Description: Volar Language Server integration for ALE adopted from +" nvim-lspconfig and volar/packages/shared/src/types.ts + +call ale#Set('vue_volar_executable', 'vue-language-server') +call ale#Set('vue_volar_use_global', 1) +call ale#Set('vue_volar_init_options', { +\ 'typescript': { 'tsdk': '' }, +\}) + +function! ale_linters#vue#volar#GetProjectRoot(buffer) abort + let l:project_roots = [ + \ 'package.json', + \ 'vite.config.js', + \ 'vite.config.mjs', + \ 'vite.config.cjs', + \ 'vite.config.ts', + \ '.git', + \ bufname(a:buffer) + \] + + for l:project_root in l:project_roots + let l:nearest_filepath = ale#path#FindNearestFile(a:buffer, l:project_root) + + if !empty(l:nearest_filepath) + return fnamemodify(l:nearest_filepath, ':h') + endif + endfor + + return '' +endfunction + +function! ale_linters#vue#volar#GetInitializationOptions(buffer) abort + let l:tsserver_path = ale#path#FindNearestDirectory(a:buffer, 'node_modules/typescript/lib') + + if l:tsserver_path is# '' + " no-custom-checks + echohl WarningMsg + " no-custom-checks + echom '[volar] Must have typescript installed in project, please install via `npm install -D typescript`.' + " no-custom-checks + echohl None + endif + + let l:init_options = ale#Var(a:buffer, 'vue_volar_init_options') + let l:init_options.typescript.tsdk = l:tsserver_path + + return l:init_options +endfunction + +call ale#linter#Define('vue', { +\ 'name': 'volar', +\ 'language': 'vue', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_volar', ['node_modules/.bin/vue-language-server'])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#vue#volar#GetProjectRoot'), +\ 'initialization_options': function('ale_linters#vue#volar#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/wgsl/naga.vim b/sources_non_forked/ale/ale_linters/wgsl/naga.vim new file mode 100644 index 00000000..2816751b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/wgsl/naga.vim @@ -0,0 +1,12 @@ +" Author: rhysd +" Description: naga-cli linter for WGSL syntax. + +call ale#Set('wgsl_naga_executable', 'naga') + +call ale#linter#Define('wgsl', { +\ 'name': 'naga', +\ 'executable': {b -> ale#Var(b, 'wgsl_naga_executable')}, +\ 'output_stream': 'stderr', +\ 'command': {b -> '%e --stdin-file-path %s'}, +\ 'callback': 'ale#handlers#naga#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/xhtml/cspell.vim b/sources_non_forked/ale/ale_linters/xhtml/cspell.vim new file mode 100644 index 00000000..c465b41b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/xhtml/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for XHTML files. + +call ale#handlers#cspell#DefineLinter('xhtml') diff --git a/sources_non_forked/ale/ale_linters/yaml/actionlint.vim b/sources_non_forked/ale/ale_linters/yaml/actionlint.vim new file mode 100644 index 00000000..902da729 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/actionlint.vim @@ -0,0 +1,87 @@ +" Author: Peter Benjamin +" Description: Linter for GitHub Workflows + +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' + let l:options .= ale#Pad('-no-color') + endif + + if l:options !~# '-oneline' + let l:options .= ale#Pad('-oneline') + endif + + let l:configfile = ale_linters#yaml#actionlint#GitRepoHasConfig(a:buffer) + + if !empty(l:configfile) + let l:options .= ale#Pad('-config-file ' . l:configfile) + endif + + return '%e' . ale#Pad(l:options) . ' - ' +endfunction + +" If we have a actionlint.yml or actionlint.yaml in our github directory +" use that as our config file. +function! ale_linters#yaml#actionlint#GitRepoHasConfig(buffer) abort + let l:filename = expand('#' . a:buffer . ':p') + let l:configfilebase = substitute(l:filename, '\.github/.*', '.github/actionlint.','') + + for l:ext in ['yml', 'yaml'] + let l:configfile = l:configfilebase . l:ext + + if filereadable(l:configfile) + return l:configfile + endif + endfor + + return '' +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: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:text, + \ 'code': l:code, + \ 'type': 'E', + \} + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'actionlint', +\ 'executable': {b -> ale#Var(b, 'yaml_actionlint_executable')}, +\ 'command': function('ale_linters#yaml#actionlint#GetCommand'), +\ 'callback': 'ale_linters#yaml#actionlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/circleci.vim b/sources_non_forked/ale/ale_linters/yaml/circleci.vim new file mode 100644 index 00000000..20835454 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/circleci.vim @@ -0,0 +1,35 @@ +function! ale_linters#yaml#circleci#Handle(buffer, lines) abort + let l:match_index = -1 + let l:output = [] + + for l:index in range(len(a:lines)) + let l:line = a:lines[l:index] + + if l:line =~? 'Error: ERROR IN CONFIG FILE:' + let l:match_index = l:index + 1 + break + endif + endfor + + if l:match_index > 0 + return [{ + \ 'type': 'E', + \ 'lnum': 1, + \ 'text': a:lines[l:match_index], + \ 'detail': join(a:lines[l:match_index :], "\n"), + \}] + endif + + return [] +endfunction + +" The circleci validate requires network requests, so we'll only run it when +" files are saved to prevent the server from being hammered. +call ale#linter#Define('yaml', { +\ 'name': 'circleci', +\ 'executable': {b -> expand('#' . b . ':p') =~? '\.circleci' ? 'circleci' : ''}, +\ 'command': 'circleci --skip-update-check config validate - < %s', +\ 'callback': 'ale_linters#yaml#circleci#Handle', +\ 'output_stream': 'stderr', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim b/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim new file mode 100644 index 00000000..ec48115a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim @@ -0,0 +1,49 @@ +call ale#Set('yaml_gitlablint_executable', 'gll') +call ale#Set('yaml_gitlablint_options', '') + +function! ale_linters#yaml#gitlablint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_gitlablint_options')) + \ . ' -p %t' +endfunction + +function! ale_linters#yaml#gitlablint#Handle(buffer, lines) abort + " Matches patterns line the following: + " (): mapping values are not allowed in this context at line 68 column 8 + " jobs:build:dev config contains unknown keys: ony + let l:pattern = '^\(.*\) at line \(\d\+\) column \(\d\+\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if !empty(l:match) + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[1], + \ 'type': 'E', + \} + call add(l:output, l:item) + else + if l:line isnot# 'GitLab CI configuration is invalid' + let l:item = { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:line, + \ 'type': 'E', + \} + call add(l:output, l:item) + endif + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'gitlablint', +\ 'executable': {b -> ale#Var(b, 'yaml_gitlablint_executable')}, +\ 'command': function('ale_linters#yaml#gitlablint#GetCommand'), +\ 'callback': 'ale_linters#yaml#gitlablint#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/ls.vim b/sources_non_forked/ale/ale_linters/yaml/ls.vim new file mode 100644 index 00000000..79510ffe --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/ls.vim @@ -0,0 +1,35 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: YAML Language Server https://github.com/redhat-developer/yaml-language-server + +call ale#Set('yaml_ls_executable', 'yaml-language-server') +call ale#Set('yaml_ls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('yaml_ls_config', {}) + +function! ale_linters#yaml#ls#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'yaml_ls', [ + \ 'node_modules/.bin/yaml-language-server', + \]) +endfunction + +function! ale_linters#yaml#ls#GetCommand(buffer) abort + let l:executable = ale_linters#yaml#ls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +" Just use the current file +function! ale_linters#yaml#ls#FindProjectRoot(buffer) abort + let l:project_file = expand('#' . a:buffer . ':p') + + return fnamemodify(l:project_file, ':h') +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'yaml-language-server', +\ 'aliases': ['yamlls'], +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#yaml#ls#GetExecutable'), +\ 'command': function('ale_linters#yaml#ls#GetCommand'), +\ 'project_root': function('ale_linters#yaml#ls#FindProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'yaml_ls_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/spectral.vim b/sources_non_forked/ale/ale_linters/yaml/spectral.vim new file mode 100644 index 00000000..13654f06 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/spectral.vim @@ -0,0 +1,14 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +call ale#Set('yaml_spectral_executable', 'spectral') +call ale#Set('yaml_spectral_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('yaml', { +\ 'name': 'spectral', +\ 'executable': {b -> ale#path#FindExecutable(b, 'yaml_spectral', [ +\ 'node_modules/.bin/spectral', +\ ])}, +\ 'command': '%e lint --ignore-unknown-format -q -f text %t', +\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput' +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim index 1f140e37..7fc2b430 100644 --- a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim @@ -32,7 +32,7 @@ endfunction call ale#linter#Define('yaml', { \ 'name': 'swaglint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'yaml_swaglint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'yaml_swaglint', [ \ 'node_modules/.bin/swaglint', \ ])}, \ 'command': '%e -r compact --stdin', diff --git a/sources_non_forked/ale/ale_linters/yaml/yamllint.vim b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim index bedb7bf1..39011df1 100644 --- a/sources_non_forked/ale/ale_linters/yaml/yamllint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim @@ -3,48 +3,9 @@ call ale#Set('yaml_yamllint_executable', 'yamllint') call ale#Set('yaml_yamllint_options', '') -function! ale_linters#yaml#yamllint#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options')) - \ . ' -f parsable %t' -endfunction - -function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort - " Matches patterns line the following: - " something.yaml:1:1: [warning] missing document start "---" (document-start) - " something.yml:2:1: [error] syntax error: expected the node content, but found '' - let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$' - let l:output = [] - - for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:item = { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:match[4], - \ 'type': l:match[3] is# 'error' ? 'E' : 'W', - \} - - let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$') - - if !empty(l:code_match) - if l:code_match[2] is# 'trailing-spaces' - \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') - " Skip warnings for trailing whitespace if the option is off. - continue - endif - - let l:item.text = l:code_match[1] - let l:item.code = l:code_match[2] - endif - - call add(l:output, l:item) - endfor - - return l:output -endfunction - call ale#linter#Define('yaml', { \ 'name': 'yamllint', \ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')}, -\ 'command': function('ale_linters#yaml#yamllint#GetCommand'), -\ 'callback': 'ale_linters#yaml#yamllint#Handle', +\ 'command': function('ale#handlers#yamllint#GetCommand'), +\ 'callback': 'ale#handlers#yamllint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/yaml/yq.vim b/sources_non_forked/ale/ale_linters/yaml/yq.vim new file mode 100644 index 00000000..35aef654 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/yq.vim @@ -0,0 +1,22 @@ +" Author: axhav +call ale#Set('yaml_yq_executable', 'yq') +call ale#Set('yaml_yq_options', '') +call ale#Set('yaml_yq_filters', '.') + +" Matches patterns like the following: +let s:pattern = '^Error\:.* line \(\d\+\)\: \(.\+\)$' + +function! ale_linters#yaml#yq#Handle(buffer, lines) abort + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'lnum': match[1] + 0, + \ 'text': match[2], + \}}) +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'yq', +\ 'executable': {b -> ale#Var(b, 'yaml_yq_executable')}, +\ 'output_stream': 'stderr', +\ 'command': '%e', +\ 'callback': 'ale_linters#yaml#yq#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/yara/yls.vim b/sources_non_forked/ale/ale_linters/yara/yls.vim new file mode 100644 index 00000000..d8371a25 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yara/yls.vim @@ -0,0 +1,18 @@ +" Author: TcM1911 +" Description: A language server for Yara. + +call ale#Set('yara_yls_executable', 'yls') + +function! ale_linters#yara#yls#FindProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:project_root) ? (ale#path#Upwards(l:project_root)[1]) : '' +endfunction + +call ale#linter#Define('yara', { +\ 'name': 'yls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'yara_yls_executable')}, +\ 'command': '%e -v', +\ 'project_root': function('ale_linters#yara#yls#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/zeek/zeek.vim b/sources_non_forked/ale/ale_linters/zeek/zeek.vim new file mode 100644 index 00000000..1c93094f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/zeek/zeek.vim @@ -0,0 +1,23 @@ +" Author: Benjamin Bannier +" Description: Support for checking Zeek files. +" +call ale#Set('zeek_zeek_executable', 'zeek') + +function! ale_linters#zeek#zeek#HandleErrors(buffer, lines) abort + let l:pattern = '\(error\|warning\) in \v.*, line (\d+): (.*)$' + + return map(ale#util#GetMatches(a:lines, l:pattern), "{ + \ 'lnum': str2nr(v:val[2]), + \ 'text': v:val[3], + \ 'type': (v:val[1] is# 'error') ? 'E': 'W', + \}") +endfunction + +call ale#linter#Define('zeek', { +\ 'name': 'zeek', +\ 'executable': {b -> ale#Var(b, 'zeek_zeek_executable')}, +\ 'output_stream': 'stderr', +\ 'command': {-> '%e --parse-only %s'}, +\ 'callback': 'ale_linters#zeek#zeek#HandleErrors', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/zig/zlint.vim b/sources_non_forked/ale/ale_linters/zig/zlint.vim new file mode 100644 index 00000000..b7be1e22 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/zig/zlint.vim @@ -0,0 +1,30 @@ +" Author: Don Isaac +" Description: A linter for the Zig programming language + +call ale#Set('zig_zlint_executable', 'zlint') + +function! ale_linters#zig#zlint#Handle(buffer, lines) abort + " GitHub Actions format: ::severity file=file,line=line,col=col,title=code::message + let l:pattern = '::\([a-z]\+\) file=\([^,]\+\),line=\(\d\+\),col=\(\d\+\),title=\([^:]\+\)::\(.*\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'filename': l:match[2], + \ 'lnum': str2nr(l:match[3]), + \ 'col': str2nr(l:match[4]), + \ 'text': l:match[6], + \ 'type': l:match[1] =~? 'error\|fail' ? 'E' : 'W', + \ 'code': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('zig', { +\ 'name': 'zlint', +\ 'executable': {b -> ale#Var(b, "zig_zlint_executable")}, +\ 'command': '%e %s -f gh', +\ 'callback': 'ale_linters#zig#zlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/zig/zls.vim b/sources_non_forked/ale/ale_linters/zig/zls.vim new file mode 100644 index 00000000..1390f6b1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/zig/zls.vim @@ -0,0 +1,20 @@ +" Author: CherryMan +" Description: A language server for Zig + +call ale#Set('zig_zls_executable', 'zls') +call ale#Set('zig_zls_config', {}) + +function! ale_linters#zig#zls#GetProjectRoot(buffer) abort + let l:build_rs = ale#path#FindNearestFile(a:buffer, 'build.zig') + + return !empty(l:build_rs) ? fnamemodify(l:build_rs, ':h') : '' +endfunction + +call ale#linter#Define('zig', { +\ 'name': 'zls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'zig_zls_config')}, +\ 'executable': {b -> ale#Var(b, 'zig_zls_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#zig#zls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/autoload/ale.vim b/sources_non_forked/ale/autoload/ale.vim index 3a4e79c8..2f46bce5 100644 --- a/sources_non_forked/ale/autoload/ale.vim +++ b/sources_non_forked/ale/autoload/ale.vim @@ -5,10 +5,14 @@ " Strings used for severity in the echoed message let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error') let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info') +let g:ale_echo_msg_log_str = get(g:, 'ale_echo_msg_log_str', 'Log') let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning') -" Ignoring linters, for disabling some, or ignoring LSP diagnostics. -let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {}) -let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 0) + +" LSP window/showMessage format +let g:ale_lsp_show_message_format = get(g:, 'ale_lsp_show_message_format', '%severity%:%linter%: %s') +" Valid values mimic LSP definitions (error, warning and information; log is +" never shown) +let g:ale_lsp_show_message_severity = get(g:, 'ale_lsp_show_message_severity', 'error') let s:lint_timer = -1 let s:getcmdwintype_exists = exists('*getcmdwintype') @@ -94,12 +98,23 @@ function! s:Lint(buffer, should_lint_file, timer_id) abort let l:filetype = getbufvar(a:buffer, '&filetype') let l:linters = ale#linter#Get(l:filetype) - " Apply ignore lists for linters only if needed. let l:ignore_config = ale#Var(a:buffer, 'linters_ignore') let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp') - let l:linters = !empty(l:ignore_config) || l:disable_lsp - \ ? ale#engine#ignore#Exclude(l:filetype, l:linters, l:ignore_config, l:disable_lsp) - \ : l:linters + + " Load code to ignore linters only if we need to. + if ( + \ !empty(l:ignore_config) + \ || l:disable_lsp is 1 + \ || l:disable_lsp is v:true + \ || (l:disable_lsp is# 'auto' && get(g:, 'lspconfig', 0)) + \) + let l:linters = ale#engine#ignore#Exclude( + \ l:filetype, + \ l:linters, + \ l:ignore_config, + \ l:disable_lsp, + \) + endif " Tell other sources that they can start checking the buffer now. let g:ale_want_results_buffer = a:buffer @@ -156,7 +171,7 @@ function! ale#Queue(delay, ...) abort endif endfunction -let s:current_ale_version = [2, 5, 0] +let s:current_ale_version = [4, 0, 0] " A function used to check for ALE features in files outside of the project. function! ale#Has(feature) abort @@ -207,7 +222,7 @@ endfunction " valid for cmd on Windows, or most shells on Unix. function! ale#Env(variable_name, value) abort if has('win32') - return 'set ' . a:variable_name . '=' . ale#Escape(a:value) . ' && ' + return 'set ' . ale#Escape(a:variable_name . '=' . a:value) . ' && ' endif return a:variable_name . '=' . ale#Escape(a:value) . ' ' @@ -251,11 +266,34 @@ function! ale#GetLocItemMessage(item, format_string) abort " Replace special markers with certain information. " \=l:variable is used to avoid escaping issues. - let l:msg = substitute(l:msg, '\V%severity%', '\=l:severity', 'g') - let l:msg = substitute(l:msg, '\V%linter%', '\=l:linter_name', 'g') let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g') + let l:msg = substitute(l:msg, '\V%severity%', '\=l:severity', 'g') + let l:msg = substitute(l:msg, '\V%type%', '\=l:type', 'g') + let l:msg = substitute(l:msg, '\V%linter%', '\=l:linter_name', 'g') " Replace %s with the text. let l:msg = substitute(l:msg, '\V%s', '\=a:item.text', 'g') + " Windows may insert carriage return line endings (^M), strip these characters. + let l:msg = substitute(l:msg, '\r', '', 'g') return l:msg endfunction + +" Given a buffer and a linter or fixer name, return an Array of two-item +" Arrays describing how to map filenames to and from the local to foreign file +" systems. +function! ale#GetFilenameMappings(buffer, name) abort + let l:linter_mappings = ale#Var(a:buffer, 'filename_mappings') + + if type(l:linter_mappings) is v:t_list + return l:linter_mappings + endif + + let l:name = a:name + + if !has_key(l:linter_mappings, l:name) + " Use * as a default setting for all tools. + let l:name = '*' + endif + + return get(l:linter_mappings, l:name, []) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/ant.vim b/sources_non_forked/ale/autoload/ale/ant.vim index 689b444b..b6d4217f 100644 --- a/sources_non_forked/ale/autoload/ale/ant.vim +++ b/sources_non_forked/ale/autoload/ale/ant.vim @@ -1,4 +1,4 @@ -" Author: Andrew Lee . +" Author: Andrew Lee . " Inspired by ale/gradle.vim by Michael Pardo " Description: Functions for working with Ant projects. @@ -23,19 +23,23 @@ function! ale#ant#FindExecutable(buffer) abort return '' endfunction -" Given a buffer number, build a command to print the classpath of the root -" project. Returns an empty string if cannot build the command. +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Ant is not detected. function! ale#ant#BuildClasspathCommand(buffer) abort let l:executable = ale#ant#FindExecutable(a:buffer) - let l:project_root = ale#ant#FindProjectRoot(a:buffer) - if !empty(l:executable) && !empty(l:project_root) - return ale#path#CdString(l:project_root) - \ . ale#Escape(l:executable) - \ . ' classpath' - \ . ' -S' - \ . ' -q' + if !empty(l:executable) + let l:project_root = ale#ant#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) .' classpath -S -q' + \] + endif endif - return '' + return ['', ''] endfunction diff --git a/sources_non_forked/ale/autoload/ale/assert.vim b/sources_non_forked/ale/autoload/ale/assert.vim index dac5efb7..141cd0f2 100644 --- a/sources_non_forked/ale/autoload/ale/assert.vim +++ b/sources_non_forked/ale/autoload/ale/assert.vim @@ -52,6 +52,36 @@ function! s:ProcessDeferredCommands(initial_result) abort return l:command endfunction +function! s:ProcessDeferredCwds(initial_command, initial_cwd) abort + let l:result = a:initial_command + let l:last_cwd = v:null + let l:command_index = 0 + let l:cwd_list = [] + + while ale#command#IsDeferred(l:result) + call add(l:cwd_list, l:result.cwd) + + if get(g:, 'ale_run_synchronously_emulate_commands') + " Don't run commands, but simulate the results. + let l:Callback = g:ale_run_synchronously_callbacks[0] + let l:output = get(s:command_output, l:command_index, []) + call l:Callback(0, l:output) + unlet g:ale_run_synchronously_callbacks + + let l:command_index += 1 + else + " Run the commands in the shell, synchronously. + call ale#test#FlushJobs() + endif + + let l:result = l:result.value + endwhile + + call add(l:cwd_list, a:initial_cwd is v:null ? l:last_cwd : a:initial_cwd) + + return l:cwd_list +endfunction + " Load the currently loaded linter for a test case, and check that the command " matches the given string. function! ale#assert#Linter(expected_executable, expected_command) abort @@ -85,6 +115,38 @@ function! ale#assert#Linter(expected_executable, expected_command) abort \ [l:executable, l:command] endfunction +function! ale#assert#LinterCwd(expected_cwd) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + + let l:initial_cwd = ale#linter#GetCwd(l:buffer, l:linter) + call ale#command#SetCwd(l:buffer, l:initial_cwd) + + let l:cwd = s:ProcessDeferredCwds( + \ ale#linter#GetCommand(l:buffer, l:linter), + \ l:initial_cwd, + \) + + call ale#command#ResetCwd(l:buffer) + + if type(a:expected_cwd) isnot v:t_list + let l:cwd = l:cwd[-1] + endif + + AssertEqual a:expected_cwd, l:cwd +endfunction + +function! ale#assert#FixerCwd(expected_cwd) abort + let l:buffer = bufnr('') + let l:cwd = s:ProcessDeferredCwds(s:FixerFunction(l:buffer), v:null) + + if type(a:expected_cwd) isnot v:t_list + let l:cwd = l:cwd[-1] + endif + + AssertEqual a:expected_cwd, l:cwd +endfunction + function! ale#assert#Fixer(expected_result) abort let l:buffer = bufnr('') let l:result = s:ProcessDeferredCommands(s:FixerFunction(l:buffer)) @@ -107,8 +169,21 @@ function! ale#assert#LinterNotExecuted() abort let l:buffer = bufnr('') let l:linter = s:GetLinter() let l:executable = ale#linter#GetExecutable(l:buffer, l:linter) + let l:executed = 1 - Assert empty(l:executable), "The linter will be executed when it shouldn't be" + if !empty(l:executable) + let l:command = ale#linter#GetCommand(l:buffer, l:linter) + + if type(l:command) is v:t_list + let l:command = l:command[-1] + endif + + let l:executed = !empty(l:command) + else + let l:executed = 0 + endif + + Assert !l:executed, "The linter will be executed when it shouldn't be" endfunction function! ale#assert#LSPOptions(expected_options) abort @@ -130,7 +205,7 @@ endfunction function! ale#assert#LSPLanguage(expected_language) abort let l:buffer = bufnr('') let l:linter = s:GetLinter() - let l:language = ale#util#GetFunction(l:linter.language_callback)(l:buffer) + let l:language = ale#linter#GetLanguage(l:buffer, l:linter) AssertEqual a:expected_language, l:language endfunction @@ -153,6 +228,7 @@ endfunction function! ale#assert#SetUpLinterTestCommands() abort command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput() + command! -nargs=+ AssertLinterCwd :call ale#assert#LinterCwd() command! -nargs=+ AssertLinter :call ale#assert#Linter() command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted() command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions() @@ -164,10 +240,35 @@ endfunction function! ale#assert#SetUpFixerTestCommands() abort command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput() + command! -nargs=+ AssertFixerCwd :call ale#assert#FixerCwd() command! -nargs=+ AssertFixer :call ale#assert#Fixer() command! -nargs=0 AssertFixerNotExecuted :call ale#assert#FixerNotExecuted() endfunction +function! ale#assert#ResetVariables(filetype, name, ...) abort + " If the suffix of the option names format is different, an additional + " argument can be used for that instead. + if a:0 > 1 + throw 'Too many arguments' + endif + + let l:option_suffix = get(a:000, 0, a:name) + let l:prefix = 'ale_' . a:filetype . '_' + \ . substitute(l:option_suffix, '-', '_', 'g') + let l:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' + + " Save and clear linter variables. + " We'll load the runtime file to reset them to defaults. + for l:key in filter(keys(g:), l:filter_expr) + execute 'Save g:' . l:key + unlet g:[l:key] + endfor + + for l:key in filter(keys(b:), l:filter_expr) + unlet b:[l:key] + endfor +endfunction + " A dummy function for making sure this module is loaded. function! ale#assert#SetUpLinterTest(filetype, name) abort " Set up a marker so ALE doesn't create real random temporary filenames. @@ -177,35 +278,22 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort call ale#linter#Reset() call ale#linter#PreventLoading(a:filetype) - let l:prefix = 'ale_' . a:filetype . '_' . a:name - let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' + Save g:ale_root + let g:ale_root = {} - Save g:ale_lsp_root - let g:ale_lsp_root = {} + Save b:ale_root + unlet! b:ale_root - Save b:ale_lsp_root - unlet! b:ale_lsp_root + call ale#assert#ResetVariables(a:filetype, a:name) Save g:ale_c_build_dir unlet! g:ale_c_build_dir - - " Save and clear linter variables. - " We'll load the runtime file to reset them to defaults. - for l:key in filter(keys(g:), b:filter_expr) - execute 'Save g:' . l:key - unlet g:[l:key] - endfor - unlet! b:ale_c_build_dir - for l:key in filter(keys(b:), b:filter_expr) - unlet b:[l:key] - endfor - execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim' if !exists('g:dir') - call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#test#SetDirectory('/testplugin/test/linter') endif call ale#assert#SetUpLinterTestCommands() @@ -226,6 +314,10 @@ function! ale#assert#TearDownLinterTest() abort delcommand GivenCommandOutput endif + if exists(':AssertLinterCwd') + delcommand AssertLinterCwd + endif + if exists(':AssertLinter') delcommand AssertLinter endif @@ -267,26 +359,23 @@ function! ale#assert#TearDownLinterTest() abort endif endfunction -function! ale#assert#SetUpFixerTest(filetype, name) abort +function! ale#assert#SetUpFixerTest(filetype, name, ...) abort + " If the suffix of the option names format is different, an additional + " argument can be used for that instead. + if a:0 > 1 + throw 'Too many arguments' + endif + " Set up a marker so ALE doesn't create real random temporary filenames. let g:ale_create_dummy_temporary_file = 1 let l:function_name = ale#fix#registry#GetFunc(a:name) let s:FixerFunction = function(l:function_name) - let l:prefix = 'ale_' . a:filetype . '_' . a:name - let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' + let l:option_suffix = get(a:000, 0, a:name) + call ale#assert#ResetVariables(a:filetype, a:name, l:option_suffix) - for l:key in filter(keys(g:), b:filter_expr) - execute 'Save g:' . l:key - unlet g:[l:key] - endfor - - for l:key in filter(keys(b:), b:filter_expr) - unlet b:[l:key] - endfor - - execute 'runtime autoload/ale/fixers/' . a:name . '.vim' + execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim' if !exists('g:dir') call ale#test#SetDirectory('/testplugin/test/fixers') @@ -321,6 +410,10 @@ function! ale#assert#TearDownFixerTest() abort delcommand GivenCommandOutput endif + if exists(':AssertFixerCwd') + delcommand AssertFixerCwd + endif + if exists(':AssertFixer') delcommand AssertFixer endif diff --git a/sources_non_forked/ale/autoload/ale/balloon.vim b/sources_non_forked/ale/autoload/ale/balloon.vim index 72f6b91c..8678376f 100644 --- a/sources_non_forked/ale/autoload/ale/balloon.vim +++ b/sources_non_forked/ale/autoload/ale/balloon.vim @@ -2,23 +2,39 @@ " Description: balloonexpr support for ALE. function! ale#balloon#MessageForPos(bufnr, lnum, col) abort + let l:set_balloons = ale#Var(a:bufnr, 'set_balloons') + let l:show_problems = 0 + let l:show_hover = 0 + + if l:set_balloons is 1 + let l:show_problems = 1 + let l:show_hover = 1 + elseif l:set_balloons is# 'hover' + let l:show_hover = 1 + endif + " Don't show balloons if they are disabled, or linting is disabled. - if !ale#Var(a:bufnr, 'set_balloons') + if !(l:show_problems || l:show_hover) \|| !g:ale_enabled \|| !getbufvar(a:bufnr, 'ale_enabled', 1) return '' endif - let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist - let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col) + if l:show_problems + let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist + let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col) + endif " Show the diagnostics message if found, 'Hover' output otherwise - if l:index >= 0 + if l:show_problems && l:index >= 0 return l:loclist[l:index].text - elseif exists('*balloon_show') || getbufvar( - \ a:bufnr, - \ 'ale_set_balloons_legacy_echo', - \ get(g:, 'ale_set_balloons_legacy_echo', 0) + elseif l:show_hover && ( + \ exists('*balloon_show') + \ || getbufvar( + \ a:bufnr, + \ 'ale_set_balloons_legacy_echo', + \ get(g:, 'ale_set_balloons_legacy_echo', 0) + \ ) \) " Request LSP/tsserver hover information, but only if this version of " Vim supports the balloon_show function, or if we turned a legacy diff --git a/sources_non_forked/ale/autoload/ale/c.vim b/sources_non_forked/ale/autoload/ale/c.vim index 5540ec14..4a22c6fe 100644 --- a/sources_non_forked/ale/autoload/ale/c.vim +++ b/sources_non_forked/ale/autoload/ale/c.vim @@ -2,20 +2,28 @@ " Description: Functions for integrating with C-family linters. call ale#Set('c_parse_makefile', 0) -call ale#Set('c_parse_compile_commands', 0) +call ale#Set('c_always_make', has('unix') && !has('macunix')) +call ale#Set('c_parse_compile_commands', 1) + let s:sep = has('win32') ? '\' : '/' " Set just so tests can override it. let g:__ale_c_project_filenames = ['.git/HEAD', 'configure', 'Makefile', 'CMakeLists.txt'] -function! ale#c#GetBuildDirectory(buffer) abort - " Don't include build directory for header files, as compile_commands.json - " files don't consider headers to be translation units, and provide no - " commands for compiling header files. - if expand('#' . a:buffer) =~# '\v\.(h|hpp)$' - return '' - endif +let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [ +\ 'build', +\ 'bin', +\]) +function! s:CanParseMakefile(buffer) abort + " Something somewhere seems to delete this setting in tests, so ensure we + " always have a default value. + call ale#Set('c_parse_makefile', 0) + + return ale#Var(a:buffer, 'c_parse_makefile') +endfunction + +function! ale#c#GetBuildDirectory(buffer) abort let l:build_dir = ale#Var(a:buffer, 'c_build_dir') " c_build_dir has the priority if defined @@ -68,14 +76,73 @@ function! ale#c#ShellSplit(line) abort return l:args endfunction -function! ale#c#ParseCFlags(path_prefix, cflag_line) abort - let l:cflags_list = [] +" Takes the path prefix and a list of cflags and expands @file arguments to +" the contents of the file. +" +" @file arguments are command line arguments recognised by gcc and clang. For +" instance, if @./path/to/file was given to gcc, it would load .path/to/file +" and use the contents of that file as arguments. +function! ale#c#ExpandAtArgs(path_prefix, raw_split_lines) abort + let l:out_lines = [] - let l:split_lines = ale#c#ShellSplit(a:cflag_line) + for l:option in a:raw_split_lines + if stridx(l:option, '@') == 0 + " This is an argument specifying a location of a file containing other arguments + let l:path = join(split(l:option, '\zs')[1:], '') + + " Make path absolute + if !ale#path#IsAbsolute(l:path) + let l:rel_path = substitute(l:path, '"', '', 'g') + let l:rel_path = substitute(l:rel_path, '''', '', 'g') + let l:path = ale#path#GetAbsPath(a:path_prefix, l:rel_path) + endif + + " Read the file and add all the arguments + try + let l:additional_args = readfile(l:path) + catch + continue " All we can really do is skip this argument + endtry + + let l:file_lines = [] + + for l:line in l:additional_args + let l:file_lines += ale#c#ShellSplit(l:line) + endfor + + " @file arguments can include other @file arguments, so we must + " recurse. + let l:out_lines += ale#c#ExpandAtArgs(a:path_prefix, l:file_lines) + else + " This is not an @file argument, so don't touch it. + let l:out_lines += [l:option] + endif + endfor + + return l:out_lines +endfunction + +" Quote C/C++ a compiler argument, if needed. +" +" Quoting arguments might cause issues with some systems/compilers, so we only +" quote them if we need to. +function! ale#c#QuoteArg(arg) abort + if a:arg !~# '\v[#$&*()\\|[\]{};''"<>/?! ^%]' + return a:arg + endif + + return ale#Escape(a:arg) +endfunction + +function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort + " Expand @file arguments now before parsing + let l:arguments = ale#c#ExpandAtArgs(a:path_prefix, a:raw_arguments) + " A list of [already_quoted, argument] + let l:items = [] let l:option_index = 0 - while l:option_index < len(l:split_lines) - let l:option = l:split_lines[l:option_index] + while l:option_index < len(l:arguments) + let l:option = l:arguments[l:option_index] let l:option_index = l:option_index + 1 " Include options, that may need relative path fix @@ -83,56 +150,67 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort \ || stridx(l:option, '-iquote') == 0 \ || stridx(l:option, '-isystem') == 0 \ || stridx(l:option, '-idirafter') == 0 + \ || stridx(l:option, '-iframework') == 0 if stridx(l:option, '-I') == 0 && l:option isnot# '-I' let l:arg = join(split(l:option, '\zs')[2:], '') let l:option = '-I' else - let l:arg = l:split_lines[l:option_index] + let l:arg = l:arguments[l:option_index] let l:option_index = l:option_index + 1 endif " Fix relative paths if needed - if stridx(l:arg, s:sep) != 0 && stridx(l:arg, '/') != 0 + if !ale#path#IsAbsolute(l:arg) let l:rel_path = substitute(l:arg, '"', '', 'g') let l:rel_path = substitute(l:rel_path, '''', '', 'g') - let l:arg = ale#Escape(a:path_prefix . s:sep . l:rel_path) + let l:arg = ale#path#GetAbsPath(a:path_prefix, l:rel_path) endif - call add(l:cflags_list, l:option) - call add(l:cflags_list, l:arg) + call add(l:items, [1, l:option]) + call add(l:items, [1, ale#Escape(l:arg)]) " Options with arg that can be grouped with the option or separate elseif stridx(l:option, '-D') == 0 || stridx(l:option, '-B') == 0 - call add(l:cflags_list, l:option) - if l:option is# '-D' || l:option is# '-B' - call add(l:cflags_list, l:split_lines[l:option_index]) + call add(l:items, [1, l:option]) + call add(l:items, [0, l:arguments[l:option_index]]) let l:option_index = l:option_index + 1 + else + call add(l:items, [0, l:option]) endif " Options that have an argument (always separate) elseif l:option is# '-iprefix' || stridx(l:option, '-iwithprefix') == 0 \ || l:option is# '-isysroot' || l:option is# '-imultilib' - call add(l:cflags_list, l:option) - call add(l:cflags_list, l:split_lines[l:option_index]) + \ || l:option is# '-include' || l:option is# '-imacros' + call add(l:items, [0, l:option]) + call add(l:items, [0, l:arguments[l:option_index]]) let l:option_index = l:option_index + 1 " Options without argument elseif (stridx(l:option, '-W') == 0 && stridx(l:option, '-Wa,') != 0 && stridx(l:option, '-Wl,') != 0 && stridx(l:option, '-Wp,') != 0) \ || l:option is# '-w' || stridx(l:option, '-pedantic') == 0 \ || l:option is# '-ansi' || stridx(l:option, '-std=') == 0 - \ || (stridx(l:option, '-f') == 0 && stridx(l:option, '-fdump') != 0 && stridx(l:option, '-fdiagnostics') != 0 && stridx(l:option, '-fno-show-column') != 0) + \ || stridx(l:option, '-f') == 0 && l:option !~# '\v^-f(dump|diagnostics|no-show-column|stack-usage)' \ || stridx(l:option, '-O') == 0 \ || l:option is# '-C' || l:option is# '-CC' || l:option is# '-trigraphs' \ || stridx(l:option, '-nostdinc') == 0 || stridx(l:option, '-iplugindir=') == 0 \ || stridx(l:option, '--sysroot=') == 0 || l:option is# '--no-sysroot-suffix' \ || stridx(l:option, '-m') == 0 - call add(l:cflags_list, l:option) + call add(l:items, [0, l:option]) endif endwhile - return join(l:cflags_list, ' ') + if a:should_quote + " Quote C arguments that haven't already been quoted above. + " If and only if we've been asked to quote them. + call map(l:items, 'v:val[0] ? v:val[1] : ale#c#QuoteArg(v:val[1])') + else + call map(l:items, 'v:val[1]') + endif + + return join(l:items, ' ') endfunction function! ale#c#ParseCFlagsFromMakeOutput(buffer, make_output) abort - if !g:ale_c_parse_makefile + if !s:CanParseMakefile(a:buffer) return v:null endif @@ -150,7 +228,7 @@ function! ale#c#ParseCFlagsFromMakeOutput(buffer, make_output) abort let l:makefile_path = ale#path#FindNearestFile(a:buffer, 'Makefile') let l:makefile_dir = fnamemodify(l:makefile_path, ':p:h') - return ale#c#ParseCFlags(l:makefile_dir, l:cflag_line) + return ale#c#ParseCFlags(l:makefile_dir, 0, ale#c#ShellSplit(l:cflag_line)) endfunction " Given a buffer number, find the project directory containing @@ -218,6 +296,10 @@ if !exists('s:compile_commands_cache') let s:compile_commands_cache = {} endif +function! ale#c#ResetCompileCommandsCache() abort + let s:compile_commands_cache = {} +endfunction + function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort let l:empty = [{}, {}] @@ -248,9 +330,20 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort let l:dir_lookup = {} for l:entry in (type(l:raw_data) is v:t_list ? l:raw_data : []) + let l:filename = ale#path#GetAbsPath(l:entry.directory, l:entry.file) + + " Store a key for lookups by the absolute path to the filename. + let l:file_lookup[l:filename] = get(l:file_lookup, l:filename, []) + [l:entry] + + " Store a key for fuzzy lookups by the absolute path to the directory. + let l:dirname = fnamemodify(l:filename, ':h') + let l:dir_lookup[l:dirname] = get(l:dir_lookup, l:dirname, []) + [l:entry] + + " Store a key for fuzzy lookups by just the basename of the file. let l:basename = tolower(fnamemodify(l:entry.file, ':t')) let l:file_lookup[l:basename] = get(l:file_lookup, l:basename, []) + [l:entry] + " Store a key for fuzzy lookups by just the basename of the directory. let l:dirbasename = tolower(fnamemodify(l:entry.directory, ':p:h:t')) let l:dir_lookup[l:dirbasename] = get(l:dir_lookup, l:dirbasename, []) + [l:entry] endfor @@ -265,18 +358,80 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort return l:empty endfunction +" Get [should_quote, arguments] from either 'command' or 'arguments' +" 'arguments' should be quoted later, the split 'command' strings should not. +function! s:GetArguments(json_item) abort + if has_key(a:json_item, 'arguments') + return [1, a:json_item.arguments] + elseif has_key(a:json_item, 'command') + return [0, ale#c#ShellSplit(a:json_item.command)] + endif + + return [0, []] +endfunction + function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort + let l:buffer_filename = ale#path#Simplify(expand('#' . a:buffer . ':p')) + let l:basename = tolower(fnamemodify(l:buffer_filename, ':t')) + " Look for any file in the same directory if we can't find an exact match. + let l:dir = fnamemodify(l:buffer_filename, ':h') + " Search for an exact file match first. - let l:basename = tolower(expand('#' . a:buffer . ':t')) - let l:file_list = get(a:file_lookup, l:basename, []) + let l:file_list = get(a:file_lookup, l:buffer_filename, []) + + " We may have to look for /foo/bar instead of C:\foo\bar + if empty(l:file_list) && has('win32') + let l:file_list = get( + \ a:file_lookup, + \ ale#path#RemoveDriveLetter(l:buffer_filename), + \ [] + \) + endif + + " Try the absolute path to the directory second. + let l:dir_list = get(a:dir_lookup, l:dir, []) + + if empty(l:dir_list) && has('win32') + let l:dir_list = get( + \ a:dir_lookup, + \ ale#path#RemoveDriveLetter(l:dir), + \ [] + \) + endif + + if empty(l:file_list) && empty(l:dir_list) + " If we can't find matches with the path to the file, try a + " case-insensitive match for any similarly-named file. + let l:file_list = get(a:file_lookup, l:basename, []) + + " If we can't find matches with the path to the directory, try a + " case-insensitive match for anything in similarly-named directory. + let l:dir_list = get(a:dir_lookup, tolower(fnamemodify(l:dir, ':t')), []) + endif + " A source file matching the header filename. let l:source_file = '' if empty(l:file_list) && l:basename =~? '\.h$\|\.hpp$' for l:suffix in ['.c', '.cpp'] - let l:key = fnamemodify(l:basename, ':r') . l:suffix + " Try to find a source file by an absolute path first. + let l:key = fnamemodify(l:buffer_filename, ':r') . l:suffix let l:file_list = get(a:file_lookup, l:key, []) + if empty(l:file_list) && has('win32') + let l:file_list = get( + \ a:file_lookup, + \ ale#path#RemoveDriveLetter(l:key), + \ [] + \) + endif + + if empty(l:file_list) + " Look fuzzy matches on the basename second. + let l:key = fnamemodify(l:basename, ':r') . l:suffix + let l:file_list = get(a:file_lookup, l:key, []) + endif + if !empty(l:file_list) let l:source_file = l:key break @@ -285,30 +440,31 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort endif for l:item in l:file_list + let l:filename = ale#path#GetAbsPath(l:item.directory, l:item.file) + " Load the flags for this file, or for a source file matching the " header file. - if has_key(l:item, 'command') - \&& ( - \ bufnr(l:item.file) is a:buffer + if ( + \ bufnr(l:filename) is a:buffer \ || ( \ !empty(l:source_file) - \ && l:item.file[-len(l:source_file):] is? l:source_file + \ && l:filename[-len(l:source_file):] is? l:source_file \ ) \) - return ale#c#ParseCFlags(l:item.directory, l:item.command) + let [l:should_quote, l:args] = s:GetArguments(l:item) + + return ale#c#ParseCFlags(l:item.directory, l:should_quote, l:args) endif endfor - " Look for any file in the same directory if we can't find an exact match. - let l:dir = ale#path#Simplify(expand('#' . a:buffer . ':p:h')) - - let l:dirbasename = tolower(expand('#' . a:buffer . ':p:h:t')) - let l:dir_list = get(a:dir_lookup, l:dirbasename, []) - for l:item in l:dir_list - if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir - \&& has_key(l:item, 'command') - return ale#c#ParseCFlags(l:item.directory, l:item.command) + let l:filename = ale#path#GetAbsPath(l:item.directory, l:item.file) + + if ale#path#RemoveDriveLetter(fnamemodify(l:filename, ':h')) + \ is? ale#path#RemoveDriveLetter(l:dir) + let [l:should_quote, l:args] = s:GetArguments(l:item) + + return ale#c#ParseCFlags(l:item.directory, l:should_quote, l:args) endif endfor @@ -326,10 +482,6 @@ endfunction function! ale#c#GetCFlags(buffer, output) abort let l:cflags = v:null - if ale#Var(a:buffer, 'c_parse_makefile') && !empty(a:output) - let l:cflags = ale#c#ParseCFlagsFromMakeOutput(a:buffer, a:output) - endif - if ale#Var(a:buffer, 'c_parse_compile_commands') let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) @@ -338,6 +490,10 @@ function! ale#c#GetCFlags(buffer, output) abort endif endif + if empty(l:cflags) && s:CanParseMakefile(a:buffer) && !empty(a:output) + let l:cflags = ale#c#ParseCFlagsFromMakeOutput(a:buffer, a:output) + endif + if l:cflags is v:null let l:cflags = ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)) endif @@ -346,19 +502,28 @@ function! ale#c#GetCFlags(buffer, output) abort endfunction function! ale#c#GetMakeCommand(buffer) abort - if ale#Var(a:buffer, 'c_parse_makefile') - let l:makefile_path = ale#path#FindNearestFile(a:buffer, 'Makefile') + if s:CanParseMakefile(a:buffer) + let l:path = ale#path#FindNearestFile(a:buffer, 'Makefile') - if !empty(l:makefile_path) - return 'cd '. fnamemodify(l:makefile_path, ':p:h') . ' && make -n' + if empty(l:path) + let l:path = ale#path#FindNearestFile(a:buffer, 'GNUmakefile') + endif + + if !empty(l:path) + let l:always_make = ale#Var(a:buffer, 'c_always_make') + + return [ + \ fnamemodify(l:path, ':h'), + \ 'make -n' . (l:always_make ? ' --always-make' : ''), + \] endif endif - return '' + return ['', ''] endfunction function! ale#c#RunMakeCommand(buffer, Callback) abort - let l:command = ale#c#GetMakeCommand(a:buffer) + let [l:cwd, l:command] = ale#c#GetMakeCommand(a:buffer) if empty(l:command) return a:Callback(a:buffer, []) @@ -368,6 +533,7 @@ function! ale#c#RunMakeCommand(buffer, Callback) abort \ a:buffer, \ l:command, \ {b, output -> a:Callback(a:buffer, output)}, + \ {'cwd': l:cwd}, \) endfunction @@ -420,7 +586,37 @@ function! ale#c#IncludeOptions(include_paths) abort return join(l:option_list) endfunction -let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [ -\ 'build', -\ 'bin', -\]) +" Get the language flag depending on on the executable, options and +" file extension +function! ale#c#GetLanguageFlag( +\ buffer, +\ executable, +\ use_header_lang_flag, +\ header_exts, +\ linter_lang_flag +\) abort + " Use only '-header' if the executable is 'clang' by default + if a:use_header_lang_flag == -1 + let l:use_header_lang_flag = a:executable =~# 'clang' + else + let l:use_header_lang_flag = a:use_header_lang_flag + endif + + " If we don't use the header language flag, return the default linter + " language flag + if !l:use_header_lang_flag + return a:linter_lang_flag + endif + + " Get the buffer file extension + let l:buf_ext = expand('#' . a:buffer . ':e') + + " If the buffer file is an header according to its extension, use + " the linter language flag + '-header', ex: 'c-header' + if index(a:header_exts, l:buf_ext) >= 0 + return a:linter_lang_flag . '-header' + endif + + " Else, use the default linter language flag + return a:linter_lang_flag +endfunction diff --git a/sources_non_forked/ale/autoload/ale/code_action.vim b/sources_non_forked/ale/autoload/ale/code_action.vim new file mode 100644 index 00000000..4167e907 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/code_action.vim @@ -0,0 +1,379 @@ +" Author: Jerko Steiner +" Description: Code action support for LSP / tsserver + +function! ale#code_action#ReloadBuffer() abort + let l:buffer = bufnr('') + + execute 'augroup ALECodeActionReloadGroup' . l:buffer + autocmd! + augroup END + + silent! execute 'augroup! ALECodeActionReloadGroup' . l:buffer + + call ale#util#Execute(':e!') +endfunction + +function! ale#code_action#HandleCodeAction(code_action, options) abort + let l:current_buffer = bufnr('') + let l:changes = a:code_action.changes + + for l:file_code_edit in l:changes + call ale#code_action#ApplyChanges( + \ l:file_code_edit.fileName, + \ l:file_code_edit.textChanges, + \ a:options, + \) + endfor +endfunction + +function! s:ChangeCmp(left, right) abort + if a:left.start.line < a:right.start.line + return -1 + endif + + if a:left.start.line > a:right.start.line + return 1 + endif + + if a:left.start.offset < a:right.start.offset + return -1 + endif + + if a:left.start.offset > a:right.start.offset + return 1 + endif + + if a:left.end.line < a:right.end.line + return -1 + endif + + if a:left.end.line > a:right.end.line + return 1 + endif + + if a:left.end.offset < a:right.end.offset + return -1 + endif + + if a:left.end.offset > a:right.end.offset + return 1 + endif + + return 0 +endfunction + +function! ale#code_action#ApplyChanges(filename, changes, options) abort + let l:should_save = get(a:options, 'should_save') + let l:conn_id = get(a:options, 'conn_id') + + let l:orig_buffer = bufnr('') + + " The buffer is used to determine the fileformat, if available. + let l:buffer = bufnr(a:filename) + + if l:buffer != l:orig_buffer + call ale#util#Execute('silent edit ' . a:filename) + let l:buffer = bufnr('') + endif + + let l:lines = getbufline(l:buffer, 1, '$') + + " Add empty line if there's trailing newline, like readfile() does. + if getbufvar(l:buffer, '&eol') + let l:lines += [''] + endif + + let l:pos = getpos('.')[1:2] + + " Changes have to be sorted so we apply them from bottom-to-top + for l:code_edit in reverse(sort(copy(a:changes), function('s:ChangeCmp'))) + let l:line = l:code_edit.start.line + let l:column = l:code_edit.start.offset + let l:end_line = l:code_edit.end.line + let l:end_column = l:code_edit.end.offset + let l:text = l:code_edit.newText + + let l:insertions = split(l:text, '\n', 1) + + " Fix invalid columns + let l:column = l:column > 0 ? l:column : 1 + let l:end_column = l:end_column > 0 ? l:end_column : 1 + + " Clamp start to BOF + if l:line < 1 + let [l:line, l:column] = [1, 1] + endif + + " Clamp start to EOF + if l:line > len(l:lines) || l:line == len(l:lines) && l:column > len(l:lines[-1]) + 1 + let [l:line, l:column] = [len(l:lines), len(l:lines[-1]) + 1] + " Special case when start is after EOL + elseif l:line < len(l:lines) && l:column > len(l:lines[l:line - 1]) + 1 + let [l:line, l:column] = [l:line + 1, 1] + endif + + " Adjust end: clamp if invalid and/or adjust if we moved start + if l:end_line < l:line || l:end_line == l:line && l:end_column < l:column + let [l:end_line, l:end_column] = [l:line, l:column] + endif + + " Clamp end to EOF + if l:end_line > len(l:lines) || l:end_line == len(l:lines) && l:end_column > len(l:lines[-1]) + 1 + let [l:end_line, l:end_column] = [len(l:lines), len(l:lines[-1]) + 1] + " Special case when end is after EOL + elseif l:end_line < len(l:lines) && l:end_column > len(l:lines[l:end_line - 1]) + 1 + let [l:end_line, l:end_column] = [l:end_line + 1, 1] + endif + + " Careful, [:-1] is not an empty list + let l:start = l:line is 1 ? [] : l:lines[: l:line - 2] + let l:middle = l:column is 1 ? [''] : [l:lines[l:line - 1][: l:column - 2]] + + let l:middle[-1] .= l:insertions[0] + let l:middle += l:insertions[1:] + let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :] + + let l:end_line_len = len(l:lines[l:end_line - 1]) + let l:lines_before_change = len(l:lines) + let l:lines = l:start + l:middle + l:lines[l:end_line :] + + let l:current_line_offset = len(l:lines) - l:lines_before_change + let l:column_offset = len(l:middle[-1]) - l:end_line_len + + " Keep cursor where it was (if outside of changes) or move it after + " the changed text (if inside), but don't touch it when the change + " spans the entire buffer, in which case we have no clue and it's + " better to not do anything. + if l:line isnot 1 || l:column isnot 1 + \|| l:end_line < l:lines_before_change + \|| l:end_line == l:lines_before_change && l:end_column <= l:end_line_len + let l:pos = s:UpdateCursor(l:pos, + \ [l:line, l:column], + \ [l:end_line, l:end_column], + \ [l:current_line_offset, l:column_offset]) + endif + endfor + + " Make sure to add a trailing newline if and only if it should be added. + if l:lines[-1] is# '' && getbufvar(l:buffer, '&eol') + call remove(l:lines, -1) + else + call setbufvar(l:buffer, '&eol', 0) + endif + + call ale#util#SetBufferContents(l:buffer, l:lines) + + call ale#lsp#NotifyForChanges(l:conn_id, l:buffer) + + if l:should_save + call ale#util#Execute('silent w!') + endif + + call setpos('.', [0, l:pos[0], l:pos[1], 0]) + + if l:orig_buffer != l:buffer && bufexists(l:orig_buffer) + call ale#util#Execute('silent buf ' . string(l:orig_buffer)) + endif +endfunction + +function! s:UpdateCursor(cursor, start, end, offset) abort + let l:cur_line = a:cursor[0] + let l:cur_column = a:cursor[1] + let l:line = a:start[0] + let l:column = a:start[1] + let l:end_line = a:end[0] + let l:end_column = a:end[1] + let l:line_offset = a:offset[0] + let l:column_offset = a:offset[1] + + if l:end_line < l:cur_line + " both start and end lines are before the cursor. only line offset + " needs to be updated + let l:cur_line += l:line_offset + elseif l:end_line == l:cur_line + " end line is at the same location as cursor, which means + " l:line <= l:cur_line + if l:line < l:cur_line || l:column <= l:cur_column + " updates are happening either before or around the cursor + if l:end_column < l:cur_column + " updates are happening before the cursor, update the + " column offset for cursor + let l:cur_line += l:line_offset + let l:cur_column += l:column_offset + else + " updates are happening around the cursor, move the cursor + " to the end of the changes + let l:cur_line += l:line_offset + let l:cur_column = l:end_column + l:column_offset + endif + " else is not necessary, it means modifications are happening + " after the cursor so no cursor updates need to be done + endif + else + " end line is after the cursor + if l:line < l:cur_line || l:line == l:cur_line && l:column <= l:cur_column + " changes are happening around the cursor, move the cursor + " to the end of the changes + let l:cur_line = l:end_line + l:line_offset + let l:cur_column = l:end_column + l:column_offset + " else is not necessary, it means modifications are happening + " after the cursor so no cursor updates need to be done + endif + endif + + return [l:cur_line, l:cur_column] +endfunction + +function! ale#code_action#GetChanges(workspace_edit) abort + if a:workspace_edit is v:null + return {} + endif + + let l:changes = {} + + if has_key(a:workspace_edit, 'changes') && !empty(a:workspace_edit.changes) + return a:workspace_edit.changes + elseif has_key(a:workspace_edit, 'documentChanges') + let l:document_changes = [] + + if type(a:workspace_edit.documentChanges) is v:t_dict + \ && has_key(a:workspace_edit.documentChanges, 'edits') + call add(l:document_changes, a:workspace_edit.documentChanges) + elseif type(a:workspace_edit.documentChanges) is v:t_list + let l:document_changes = a:workspace_edit.documentChanges + endif + + for l:text_document_edit in l:document_changes + let l:filename = l:text_document_edit.textDocument.uri + let l:edits = l:text_document_edit.edits + let l:changes[l:filename] = l:edits + endfor + endif + + return l:changes +endfunction + +function! ale#code_action#BuildChangesList(changes_map) abort + let l:changes = [] + + for l:file_name in keys(a:changes_map) + let l:text_edits = a:changes_map[l:file_name] + let l:text_changes = [] + + for l:edit in l:text_edits + let l:range = l:edit.range + let l:new_text = l:edit.newText + + call add(l:text_changes, { + \ 'start': { + \ 'line': l:range.start.line + 1, + \ 'offset': l:range.start.character + 1, + \ }, + \ 'end': { + \ 'line': l:range.end.line + 1, + \ 'offset': l:range.end.character + 1, + \ }, + \ 'newText': l:new_text, + \}) + endfor + + call add(l:changes, { + \ 'fileName': ale#util#ToResource(l:file_name), + \ 'textChanges': l:text_changes, + \}) + endfor + + return l:changes +endfunction + +function! s:EscapeMenuName(text) abort + return substitute(a:text, '\\\| \|\.\|&', '\\\0', 'g') +endfunction + +function! s:UpdateMenu(data, menu_items) abort + silent! aunmenu PopUp.Refactor\.\.\. + + if empty(a:data) + return + endif + + for [l:type, l:item] in a:menu_items + let l:name = l:type is# 'tsserver' ? l:item.name : l:item.title + let l:func_name = l:type is# 'tsserver' + \ ? 'ale#codefix#ApplyTSServerCodeAction' + \ : 'ale#codefix#ApplyLSPCodeAction' + + execute printf( + \ 'anoremenu PopUp.&Refactor\.\.\..%s' + \ . ' :call %s(%s, %s)', + \ s:EscapeMenuName(l:name), + \ l:func_name, + \ string(a:data), + \ string(l:item), + \) + endfor + + if empty(a:menu_items) + silent! anoremenu PopUp.Refactor\.\.\..(None) :silent + endif +endfunction + +function! s:GetCodeActions(linter, options) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + let l:column = min([l:column, len(getline(l:line))]) + + let l:location = { + \ 'buffer': l:buffer, + \ 'line': l:line, + \ 'column': l:column, + \ 'end_line': l:line, + \ 'end_column': l:column, + \} + let l:Callback = function('s:OnReady', [l:location, a:options]) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#code_action#GetCodeActions(options) abort + silent! aunmenu PopUp.Rename + silent! aunmenu PopUp.Refactor\.\.\. + + " Only display the menu items if there's an LSP server. + if len(ale#lsp_linter#GetEnabled(bufnr(''))) > 0 + if !empty(expand('')) + silent! anoremenu PopUp.Rename :ALERename + endif + + silent! anoremenu PopUp.Refactor\.\.\..(None) :silent + + call ale#codefix#Execute( + \ mode() is# 'v' || mode() is# "\", + \ function('s:UpdateMenu') + \) + endif +endfunction + +function! s:Setup(enabled) abort + augroup ALECodeActionsGroup + autocmd! + + if a:enabled + autocmd MenuPopup * :call ale#code_action#GetCodeActions({}) + endif + augroup END + + if !a:enabled + silent! augroup! ALECodeActionsGroup + + silent! aunmenu PopUp.Rename + silent! aunmenu PopUp.Refactor\.\.\. + endif +endfunction + +function! ale#code_action#EnablePopUpMenu() abort + call s:Setup(1) +endfunction + +function! ale#code_action#DisablePopUpMenu() abort + call s:Setup(0) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/codefix.vim b/sources_non_forked/ale/autoload/ale/codefix.vim new file mode 100644 index 00000000..6eaadb23 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/codefix.vim @@ -0,0 +1,491 @@ +" Author: Dalius Dobravolskas +" Description: Code Fix support for tsserver and LSP servers + +let s:codefix_map = {} + +" Used to get the codefix map in tests. +function! ale#codefix#GetMap() abort + return deepcopy(s:codefix_map) +endfunction + +" Used to set the codefix map in tests. +function! ale#codefix#SetMap(map) abort + let s:codefix_map = a:map +endfunction + +function! ale#codefix#ClearLSPData() abort + let s:codefix_map = {} +endfunction + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +function! ale#codefix#ApplyTSServerCodeAction(data, item) abort + if has_key(a:item, 'changes') + let l:changes = a:item.changes + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'codefix', + \ 'changes': l:changes, + \ }, + \ {}, + \) + else + let l:message = ale#lsp#tsserver_message#GetEditsForRefactor( + \ a:data.buffer, + \ a:data.line, + \ a:data.column, + \ a:data.end_line, + \ a:data.end_column, + \ a:item.id[0], + \ a:item.id[1], + \) + + let l:request_id = ale#lsp#Send(a:data.connection_id, l:message) + + let s:codefix_map[l:request_id] = a:data + endif +endfunction + +function! ale#codefix#HandleTSServerResponse(conn_id, response) abort + if !has_key(a:response, 'request_seq') + \ || !has_key(s:codefix_map, a:response.request_seq) + return + endif + + let l:data = remove(s:codefix_map, a:response.request_seq) + let l:MenuCallback = get(l:data, 'menu_callback', v:null) + + if get(a:response, 'command', '') is# 'getCodeFixes' + if get(a:response, 'success', v:false) is v:false + \&& l:MenuCallback is v:null + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting code fixes. Reason: ' . l:message) + + return + endif + + let l:result = get(a:response, 'body', []) + call filter(l:result, 'has_key(v:val, ''changes'')') + + if l:MenuCallback isnot v:null + call l:MenuCallback( + \ l:data, + \ map(copy(l:result), '[''tsserver'', v:val]') + \) + + return + endif + + if len(l:result) == 0 + call s:message('No code fixes available.') + + return + endif + + let l:code_fix_to_apply = 0 + + if len(l:result) == 1 + let l:code_fix_to_apply = 1 + else + let l:codefix_no = 1 + let l:codefixstring = "Code Fixes:\n" + + for l:codefix in l:result + let l:codefixstring .= l:codefix_no . ') ' + \ . l:codefix.description . "\n" + let l:codefix_no += 1 + endfor + + let l:codefixstring .= 'Type number and (empty cancels): ' + + let l:code_fix_to_apply = ale#util#Input(l:codefixstring, '') + let l:code_fix_to_apply = str2nr(l:code_fix_to_apply) + + if l:code_fix_to_apply == 0 + return + endif + endif + + call ale#codefix#ApplyTSServerCodeAction( + \ l:data, + \ l:result[l:code_fix_to_apply - 1], + \) + elseif get(a:response, 'command', '') is# 'getApplicableRefactors' + if get(a:response, 'success', v:false) is v:false + \&& l:MenuCallback is v:null + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting applicable refactors. Reason: ' . l:message) + + return + endif + + let l:result = get(a:response, 'body', []) + + if len(l:result) == 0 + call s:message('No applicable refactors available.') + + return + endif + + let l:refactors = [] + + for l:item in l:result + for l:action in l:item.actions + call add(l:refactors, { + \ 'name': l:action.description, + \ 'id': [l:item.name, l:action.name], + \}) + endfor + endfor + + if l:MenuCallback isnot v:null + call l:MenuCallback( + \ l:data, + \ map(copy(l:refactors), '[''tsserver'', v:val]') + \) + + return + endif + + let l:refactor_no = 1 + let l:refactorstring = "Applicable refactors:\n" + + for l:refactor in l:refactors + let l:refactorstring .= l:refactor_no . ') ' + \ . l:refactor.name . "\n" + let l:refactor_no += 1 + endfor + + let l:refactorstring .= 'Type number and (empty cancels): ' + + let l:refactor_to_apply = ale#util#Input(l:refactorstring, '') + let l:refactor_to_apply = str2nr(l:refactor_to_apply) + + if l:refactor_to_apply == 0 + return + endif + + let l:id = l:refactors[l:refactor_to_apply - 1].id + + call ale#codefix#ApplyTSServerCodeAction( + \ l:data, + \ l:refactors[l:refactor_to_apply - 1], + \) + elseif get(a:response, 'command', '') is# 'getEditsForRefactor' + if get(a:response, 'success', v:false) is v:false + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting edits for refactor. Reason: ' . l:message) + + return + endif + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'editsForRefactor', + \ 'changes': a:response.body.edits, + \ }, + \ {}, + \) + endif +endfunction + +function! ale#codefix#ApplyLSPCodeAction(data, item) abort + if has_key(a:item, 'command') + \&& type(a:item.command) == v:t_dict + let l:command = a:item.command + let l:message = ale#lsp#message#ExecuteCommand( + \ l:command.command, + \ l:command.arguments, + \) + + let l:request_id = ale#lsp#Send(a:data.connection_id, l:message) + elseif has_key(a:item, 'command') && has_key(a:item, 'arguments') + \&& type(a:item.command) == v:t_string + let l:message = ale#lsp#message#ExecuteCommand( + \ a:item.command, + \ a:item.arguments, + \) + + let l:request_id = ale#lsp#Send(a:data.connection_id, l:message) + elseif has_key(a:item, 'edit') || has_key(a:item, 'arguments') + if has_key(a:item, 'edit') + let l:topass = a:item.edit + else + let l:topass = a:item.arguments[0] + endif + + let l:changes_map = ale#code_action#GetChanges(l:topass) + + if empty(l:changes_map) + return + endif + + let l:changes = ale#code_action#BuildChangesList(l:changes_map) + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'codeaction', + \ 'changes': l:changes, + \ }, + \ {}, + \) + endif +endfunction + +function! ale#codefix#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'method') + \ && a:response.method is# 'workspace/applyEdit' + \ && has_key(a:response, 'params') + let l:params = a:response.params + + let l:changes_map = ale#code_action#GetChanges(l:params.edit) + + if empty(l:changes_map) + return + endif + + let l:changes = ale#code_action#BuildChangesList(l:changes_map) + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'applyEdit', + \ 'changes': l:changes, + \ }, + \ {} + \) + elseif has_key(a:response, 'id') + \&& has_key(s:codefix_map, a:response.id) + let l:data = remove(s:codefix_map, a:response.id) + let l:MenuCallback = get(l:data, 'menu_callback', v:null) + + let l:result = get(a:response, 'result') + + if type(l:result) != v:t_list + let l:result = [] + endif + + " Send the results to the menu callback, if set. + if l:MenuCallback isnot v:null + call l:MenuCallback( + \ l:data, + \ map(copy(l:result), '[''lsp'', v:val]') + \) + + return + endif + + if len(l:result) == 0 + call s:message('No code actions received from server') + + return + endif + + let l:codeaction_no = 1 + let l:codeactionstring = "Code Fixes:\n" + + for l:codeaction in l:result + let l:codeactionstring .= l:codeaction_no . ') ' + \ . l:codeaction.title . "\n" + let l:codeaction_no += 1 + endfor + + let l:codeactionstring .= 'Type number and (empty cancels): ' + + let l:codeaction_to_apply = ale#util#Input(l:codeactionstring, '') + let l:codeaction_to_apply = str2nr(l:codeaction_to_apply) + + if l:codeaction_to_apply == 0 + return + endif + + let l:item = l:result[l:codeaction_to_apply - 1] + + call ale#codefix#ApplyLSPCodeAction(l:data, l:item) + endif +endfunction + +function! s:FindError(buffer, line, column, end_line, end_column, linter_name) abort + let l:nearest_error = v:null + + if a:line == a:end_line + \&& a:column == a:end_column + \&& has_key(g:ale_buffer_info, a:buffer) + let l:nearest_error_diff = -1 + + for l:error in get(g:ale_buffer_info[a:buffer], 'loclist', []) + if has_key(l:error, 'code') + \ && (a:linter_name is v:null || l:error.linter_name is# a:linter_name) + \ && l:error.lnum == a:line + let l:diff = abs(l:error.col - a:column) + + if l:nearest_error_diff == -1 || l:diff < l:nearest_error_diff + let l:nearest_error_diff = l:diff + let l:nearest_error = l:error + endif + endif + endfor + endif + + return l:nearest_error +endfunction + +function! s:OnReady( +\ line, +\ column, +\ end_line, +\ end_column, +\ MenuCallback, +\ linter, +\ lsp_details, +\) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'code_actions') + return + endif + + let l:buffer = a:lsp_details.buffer + + if a:linter.lsp is# 'tsserver' + let l:nearest_error = + \ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column, a:linter.lsp) + + if l:nearest_error isnot v:null + let l:message = ale#lsp#tsserver_message#GetCodeFixes( + \ l:buffer, + \ a:line, + \ a:column, + \ a:line, + \ a:column, + \ [l:nearest_error.code], + \) + else + let l:message = ale#lsp#tsserver_message#GetApplicableRefactors( + \ l:buffer, + \ a:line, + \ a:column, + \ a:end_line, + \ a:end_column, + \) + endif + else + " Send a message saying the buffer has changed first, otherwise + " completions won't know what text is nearby. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:diagnostics = [] + let l:nearest_error = + \ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column, v:null) + + if l:nearest_error isnot v:null + let l:diagnostics = [ + \ { + \ 'code': l:nearest_error.code, + \ 'message': l:nearest_error.text, + \ 'range': { + \ 'start': { + \ 'line': l:nearest_error.lnum - 1, + \ 'character': l:nearest_error.col - 1, + \ }, + \ 'end': { + \ 'line': get(l:nearest_error, 'end_lnum', 1) - 1, + \ 'character': get(l:nearest_error, 'end_col', 0) + \ }, + \ }, + \ }, + \] + endif + + let l:message = ale#lsp#message#CodeAction( + \ l:buffer, + \ a:line, + \ a:column, + \ a:end_line, + \ a:end_column, + \ l:diagnostics, + \) + endif + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#codefix#HandleTSServerResponse') + \ : function('ale#codefix#HandleLSPResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:codefix_map[l:request_id] = { + \ 'connection_id': l:id, + \ 'buffer': l:buffer, + \ 'line': a:line, + \ 'column': a:column, + \ 'end_line': a:end_line, + \ 'end_column': a:end_column, + \ 'menu_callback': a:MenuCallback, + \} +endfunction + +function! s:ExecuteGetCodeFix(linter, range, MenuCallback) abort + let l:buffer = bufnr('') + + if a:range == 0 + let [l:line, l:column] = getpos('.')[1:2] + let l:end_line = l:line + let l:end_column = l:column + + " Expand the range to cover the current word, if there is one. + let l:cword = expand('') + + if !empty(l:cword) + let l:search_pos = searchpos('\V' . l:cword, 'bn', l:line) + + if l:search_pos != [0, 0] + let l:column = l:search_pos[1] + let l:end_column = l:column + len(l:cword) - 1 + endif + endif + elseif mode() is# 'v' || mode() is# "\" + " You need to get the start and end in a different way when you're in + " visual mode. + let [l:line, l:column] = getpos('v')[1:2] + let [l:end_line, l:end_column] = getpos('.')[1:2] + else + let [l:line, l:column] = getpos("'<")[1:2] + let [l:end_line, l:end_column] = getpos("'>")[1:2] + endif + + let l:column = max([min([l:column, len(getline(l:line))]), 1]) + let l:end_column = min([l:end_column, len(getline(l:end_line))]) + + let l:Callback = function( + \ 's:OnReady', [l:line, l:column, l:end_line, l:end_column, a:MenuCallback] + \) + + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#codefix#Execute(range, ...) abort + if a:0 > 1 + throw 'Too many arguments' + endif + + let l:MenuCallback = get(a:000, 0, v:null) + let l:linters = ale#lsp_linter#GetEnabled(bufnr('')) + + if empty(l:linters) + if l:MenuCallback is v:null + call s:message('No active LSPs') + else + call l:MenuCallback({}, []) + endif + + return + endif + + for l:linter in l:linters + call s:ExecuteGetCodeFix(l:linter, a:range, l:MenuCallback) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/command.vim b/sources_non_forked/ale/autoload/ale/command.vim index 1bbc4f4c..c9dc8d94 100644 --- a/sources_non_forked/ale/autoload/ale/command.vim +++ b/sources_non_forked/ale/autoload/ale/command.vim @@ -7,6 +7,9 @@ if !exists('s:buffer_data') let s:buffer_data = {} endif +" The regular expression used for formatting filenames with modifiers. +let s:path_format_regex = '\v\%s(%(:h|:t|:r|:e)*)' + " Used to get the data in tests. function! ale#command#GetData() abort return deepcopy(s:buffer_data) @@ -26,6 +29,19 @@ function! ale#command#InitData(buffer) abort endif endfunction +" Set the cwd for commands that are about to run. +" Used internally. +function! ale#command#SetCwd(buffer, cwd) abort + call ale#command#InitData(a:buffer) + let s:buffer_data[a:buffer].cwd = a:cwd +endfunction + +function! ale#command#ResetCwd(buffer) abort + if has_key(s:buffer_data, a:buffer) + let s:buffer_data[a:buffer].cwd = v:null + endif +endfunction + function! ale#command#ManageFile(buffer, file) abort call ale#command#InitData(a:buffer) call add(s:buffer_data[a:buffer].file_list, a:file) @@ -133,14 +149,62 @@ function! ale#command#EscapeCommandPart(command_part) abort return substitute(a:command_part, '%', '%%', 'g') endfunction +" Format a filename, converting it with filename mappings, if non-empty, +" and escaping it for putting into a command string. +" +" The filename can be modified. +function! s:FormatFilename(filename, mappings, modifiers) abort + let l:filename = a:filename + + if !empty(a:mappings) + let l:filename = ale#filename_mapping#Map(l:filename, a:mappings) + endif + + if !empty(a:modifiers) + let l:filename = fnamemodify(l:filename, a:modifiers) + endif + + return ale#Escape(l:filename) +endfunction + +" Produce a command prefix to check to a particular directory for a command. +" %s format markers with filename-modifiers can be used as the directory, and +" will be returned verbatim for formatting in paths relative to files. +function! ale#command#CdString(directory) abort + let l:match = matchstrpos(a:directory, s:path_format_regex) + " Do not escape the directory here if it's a valid format string. + " This allows us to use sequences like %s:h, %s:h:h, etc. + let l:directory = l:match[1:] == [0, len(a:directory)] + \ ? a:directory + \ : ale#Escape(a:directory) + + if has('win32') + return 'cd /d ' . l:directory . ' && ' + endif + + return 'cd ' . l:directory . ' && ' +endfunction + " Given a command string, replace every... " %s -> with the current filename " %t -> with the name of an unused file in a temporary directory " %% -> with a literal % -function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_needed, input) abort +function! ale#command#FormatCommand( +\ buffer, +\ executable, +\ command, +\ pipe_file_if_needed, +\ input, +\ cwd, +\ mappings, +\) abort let l:temporary_file = '' let l:command = a:command + if !empty(a:cwd) + let l:command = ale#command#CdString(a:cwd) . l:command + endif + " First replace all uses of %%, used for literal percent characters, " with an ugly string. let l:command = substitute(l:command, '%%', '<>', 'g') @@ -154,14 +218,24 @@ function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_ne " file. if l:command =~# '%s' let l:filename = fnamemodify(bufname(a:buffer), ':p') - let l:command = substitute(l:command, '%s', '\=ale#Escape(l:filename)', 'g') + let l:command = substitute( + \ l:command, + \ s:path_format_regex, + \ '\=s:FormatFilename(l:filename, a:mappings, submatch(1))', + \ 'g' + \) endif if a:input isnot v:false && l:command =~# '%t' " Create a temporary filename, / " The file itself will not be created by this function. let l:temporary_file = s:TemporaryFilename(a:buffer) - let l:command = substitute(l:command, '%t', '\=ale#Escape(l:temporary_file)', 'g') + let l:command = substitute( + \ l:command, + \ '\v\%t(%(:h|:t|:r|:e)*)', + \ '\=s:FormatFilename(l:temporary_file, a:mappings, submatch(1))', + \ 'g' + \) endif " Finish formatting so %% becomes %. @@ -244,9 +318,16 @@ function! s:ExitCallback(buffer, line_list, Callback, data) abort let l:result = a:data.result let l:result.value = l:value - if get(l:result, 'result_callback', v:null) isnot v:null - call call(l:result.result_callback, [l:value]) - endif + " Set the default cwd for this buffer in this call stack. + call ale#command#SetCwd(a:buffer, l:result.cwd) + + try + if get(l:result, 'result_callback', v:null) isnot v:null + call call(l:result.result_callback, [l:value]) + endif + finally + call ale#command#ResetCwd(a:buffer) + endtry endfunction function! ale#command#Run(buffer, command, Callback, ...) abort @@ -258,6 +339,13 @@ function! ale#command#Run(buffer, command, Callback, ...) abort let l:output_stream = get(l:options, 'output_stream', 'stdout') let l:line_list = [] + let l:cwd = get(l:options, 'cwd', v:null) + + if l:cwd is v:null + " Default the working directory to whatever it was for the last + " command run in the chain. + let l:cwd = get(get(s:buffer_data, a:buffer, {}), 'cwd', v:null) + endif let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand( \ a:buffer, @@ -265,6 +353,8 @@ function! ale#command#Run(buffer, command, Callback, ...) abort \ a:command, \ get(l:options, 'read_buffer', 0), \ get(l:options, 'input', v:null), + \ l:cwd, + \ get(l:options, 'filename_mappings', []), \) let l:command = ale#job#PrepareCommand(a:buffer, l:command) let l:job_options = { @@ -330,10 +420,14 @@ function! ale#command#Run(buffer, command, Callback, ...) abort " The `_deferred_job_id` is used for both checking the type of object, and " for checking the job ID and status. " + " The cwd is kept and used as the default value for the next command in + " the chain. + " " The original command here is used in tests. let l:result = { \ '_deferred_job_id': l:job_id, \ 'executable': get(l:options, 'executable', ''), + \ 'cwd': l:cwd, \ 'command': a:command, \} diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index ebf32909..4fd02721 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -1,10 +1,11 @@ " Author: w0rp " Description: Completion support for LSP linters +scriptencoding utf-8 " The omnicompletion menu is shown through a special Plug mapping which is " only valid in Insert mode. This way, feedkeys() won't send these keys if you " quit Insert mode quickly enough. -inoremap (ale_show_completion_menu) +inoremap (ale_show_completion_menu) " If we hit the key sequence in normal mode, then we won't show the menu, so " we should restore the old settings right away. nnoremap (ale_show_completion_menu) :call ale#completion#RestoreCompletionOptions() @@ -15,29 +16,108 @@ onoremap (ale_show_completion_menu) let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100) let g:ale_completion_excluded_words = get(g:, 'ale_completion_excluded_words', []) let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50) +let g:ale_completion_autoimport = get(g:, 'ale_completion_autoimport', 1) +let g:ale_completion_tsserver_remove_warnings = get(g:, 'ale_completion_tsserver_remove_warnings', 0) let s:timer_id = -1 let s:last_done_pos = [] " CompletionItemKind values from the LSP protocol. -let s:LSP_COMPLETION_TEXT_KIND = 1 -let s:LSP_COMPLETION_METHOD_KIND = 2 -let s:LSP_COMPLETION_FUNCTION_KIND = 3 -let s:LSP_COMPLETION_CONSTRUCTOR_KIND = 4 -let s:LSP_COMPLETION_FIELD_KIND = 5 -let s:LSP_COMPLETION_VARIABLE_KIND = 6 -let s:LSP_COMPLETION_CLASS_KIND = 7 -let s:LSP_COMPLETION_INTERFACE_KIND = 8 -let s:LSP_COMPLETION_MODULE_KIND = 9 -let s:LSP_COMPLETION_PROPERTY_KIND = 10 -let s:LSP_COMPLETION_UNIT_KIND = 11 -let s:LSP_COMPLETION_VALUE_KIND = 12 -let s:LSP_COMPLETION_ENUM_KIND = 13 -let s:LSP_COMPLETION_KEYWORD_KIND = 14 -let s:LSP_COMPLETION_SNIPPET_KIND = 15 -let s:LSP_COMPLETION_COLOR_KIND = 16 -let s:LSP_COMPLETION_FILE_KIND = 17 -let s:LSP_COMPLETION_REFERENCE_KIND = 18 +let g:ale_lsp_types = { +\ 1: 'text', +\ 2: 'method', +\ 3: 'function', +\ 4: 'constructor', +\ 5: 'field', +\ 6: 'variable', +\ 7: 'class', +\ 8: 'interface', +\ 9: 'module', +\ 10: 'property', +\ 11: 'unit', +\ 12: 'value', +\ 13: 'enum', +\ 14: 'keyword', +\ 15: 'snippet', +\ 16: 'color', +\ 17: 'file', +\ 18: 'reference', +\ 19: 'folder', +\ 20: 'enum_member', +\ 21: 'constant', +\ 22: 'struct', +\ 23: 'event', +\ 24: 'operator', +\ 25: 'type_parameter', +\ } + +" from https://github.com/microsoft/TypeScript/blob/29becf05012bfa7ba20d50b0d16813971e46b8a6/lib/protocol.d.ts#L2472 +let g:ale_tsserver_types = { +\ 'warning': 'text', +\ 'keyword': 'keyword', +\ 'script': 'file', +\ 'module': 'module', +\ 'class': 'class', +\ 'local class': 'class', +\ 'interface': 'interface', +\ 'type': 'class', +\ 'enum': 'enum', +\ 'enum member': 'enum_member', +\ 'var': 'variable', +\ 'local var': 'variable', +\ 'function': 'function', +\ 'local function': 'function', +\ 'method': 'method', +\ 'getter': 'property', +\ 'setter': 'method', +\ 'property': 'property', +\ 'constructor': 'constructor', +\ 'call': 'method', +\ 'index': 'index', +\ 'construct': 'constructor', +\ 'parameter': 'parameter', +\ 'type parameter': 'type_parameter', +\ 'primitive type': 'unit', +\ 'label': 'text', +\ 'alias': 'class', +\ 'const': 'constant', +\ 'let': 'variable', +\ 'directory': 'folder', +\ 'external module name': 'text', +\ 'JSX attribute': 'parameter', +\ 'string': 'text' +\ } + +" For compatibility reasons, we only use built in VIM completion kinds +" See :help complete-items for Vim completion kinds +let g:ale_completion_symbols = get(g:, 'ale_completion_symbols', { +\ 'text': 'v', +\ 'method': 'f', +\ 'function': 'f', +\ 'constructor': 'f', +\ 'field': 'm', +\ 'variable': 'v', +\ 'class': 't', +\ 'interface': 't', +\ 'module': 'd', +\ 'property': 'm', +\ 'unit': 'v', +\ 'value': 'v', +\ 'enum': 't', +\ 'keyword': 'v', +\ 'snippet': 'v', +\ 'color': 'v', +\ 'file': 'v', +\ 'reference': 'v', +\ 'folder': 'v', +\ 'enum_member': 'm', +\ 'constant': 'm', +\ 'struct': 't', +\ 'event': 'v', +\ 'operator': 'f', +\ 'type_parameter': 'p', +\ '': 'v' +\ }) let s:LSP_INSERT_TEXT_FORMAT_PLAIN = 1 let s:LSP_INSERT_TEXT_FORMAT_SNIPPET = 2 @@ -50,14 +130,17 @@ let s:should_complete_map = { \ '': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$', \ 'clojure': s:lisp_regex, \ 'lisp': s:lisp_regex, +\ 'racket': '\k\+$', \ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$', \ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$', \ 'cpp': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$|-\>$', +\ 'c': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|-\>$', \} " Regular expressions for finding the start column to replace with completion. let s:omni_start_map = { \ '': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$', +\ 'racket': '\k\+$', \} " A map of exact characters for triggering LSP completions. Do not forget to @@ -67,6 +150,7 @@ let s:trigger_character_map = { \ 'typescript': ['.', '''', '"'], \ 'rust': ['.', '::'], \ 'cpp': ['.', '::', '->'], +\ 'c': ['.', '->'], \} function! s:GetFiletypeValue(map, filetype) abort @@ -108,7 +192,13 @@ function! ale#completion#GetTriggerCharacter(filetype, prefix) abort return '' endfunction -function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort +function! ale#completion#Filter( +\ buffer, +\ filetype, +\ suggestions, +\ prefix, +\ exact_prefix_match, +\) abort let l:excluded_words = ale#Var(a:buffer, 'completion_excluded_words') if empty(a:prefix) @@ -135,10 +225,17 @@ function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort " Dictionaries is accepted here. let l:word = type(l:item) is v:t_string ? l:item : l:item.word - " Add suggestions if the suggestion starts with a - " case-insensitive match for the prefix. - if l:word[: len(a:prefix) - 1] is? a:prefix - call add(l:filtered_suggestions, l:item) + if a:exact_prefix_match + " Add suggestions if the word is an exact match. + if l:word is# a:prefix + call add(l:filtered_suggestions, l:item) + endif + else + " Add suggestions if the suggestion starts with a + " case-insensitive match for the prefix. + if l:word[: len(a:prefix) - 1] is? a:prefix + call add(l:filtered_suggestions, l:item) + endif endif endfor endif @@ -161,30 +258,34 @@ function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort return l:filtered_suggestions endfunction -function! s:ReplaceCompletionOptions() abort - let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') - - if l:source is# 'ale-automatic' || l:source is# 'ale-manual' - " Remember the old omnifunc value, if there is one. - " If we don't store an old one, we'll just never reset the option. - " This will stop some random exceptions from appearing. - if !exists('b:ale_old_omnifunc') && !empty(&l:omnifunc) - let b:ale_old_omnifunc = &l:omnifunc - endif - - let &l:omnifunc = 'ale#completion#AutomaticOmniFunc' +function! s:ReplaceCompletionOptions(source) abort + " Remember the old omnifunc value, if there is one. + " If we don't store an old one, we'll just never reset the option. + " This will stop some random exceptions from appearing. + if !exists('b:ale_old_omnifunc') && !empty(&l:omnifunc) + let b:ale_old_omnifunc = &l:omnifunc endif - if l:source is# 'ale-automatic' + let &l:omnifunc = 'ale#completion#AutomaticOmniFunc' + + if a:source is# 'ale-automatic' if !exists('b:ale_old_completeopt') let b:ale_old_completeopt = &l:completeopt endif - if &l:completeopt =~# 'preview' - let &l:completeopt = 'menu,menuone,preview,noselect,noinsert' - else - let &l:completeopt = 'menu,menuone,noselect,noinsert' - endif + let l:opt_list = split(&l:completeopt, ',') + " The menu and noinsert options must be set, or automatic completion + " will be annoying. + let l:new_opt_list = ['menu', 'menuone', 'noinsert'] + + " Permit some other completion options, provided users have set them. + for l:opt in ['preview', 'popup', 'noselect'] + if index(l:opt_list, l:opt) >= 0 + call add(l:new_opt_list, l:opt) + endif + endfor + + let &l:completeopt = join(l:new_opt_list, ',') endif endfunction @@ -236,59 +337,112 @@ function! ale#completion#AutomaticOmniFunc(findstart, base) abort else let l:result = ale#completion#GetCompletionResult() - call s:ReplaceCompletionOptions() + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if l:source is# 'ale-automatic' || l:source is# 'ale-manual' + call s:ReplaceCompletionOptions(l:source) + endif return l:result isnot v:null ? l:result : [] endif endfunction +function! s:OpenCompletionMenu(...) abort + if !&l:paste + call ale#util#FeedKeys("\(ale_show_completion_menu)") + endif +endfunction + function! ale#completion#Show(result) abort - if ale#util#Mode() isnot# 'i' + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if ale#util#Mode() isnot# 'i' && l:source isnot# 'ale-import' return endif - " Set the list in the buffer, temporarily replace omnifunc with our - " function, and then start omni-completion. + " Set the list in the buffer. let b:ale_completion_result = a:result " Don't try to open the completion menu if there's nothing to show. if empty(b:ale_completion_result) + if l:source is# 'ale-import' + " If we ran completion from :ALEImport, + " tell the user that nothing is going to happen. + call s:message('No possible imports found.') + endif + return endif " Replace completion options shortly before opening the menu. - call s:ReplaceCompletionOptions() - - let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') - if l:source is# 'ale-automatic' || l:source is# 'ale-manual' - call timer_start( - \ 0, - \ {-> ale#util#FeedKeys("\(ale_show_completion_menu)")} - \) + call s:ReplaceCompletionOptions(l:source) + + call timer_start(0, function('s:OpenCompletionMenu')) endif if l:source is# 'ale-callback' call b:CompleteCallback(b:ale_completion_result) endif + + if l:source is# 'ale-import' + call ale#completion#HandleUserData(b:ale_completion_result[0]) + + let l:text_changed = '' . g:ale_lint_on_text_changed + + " Check the buffer again right away, if linting is enabled. + if g:ale_enabled + \&& ( + \ l:text_changed is# '1' + \ || l:text_changed is# 'always' + \ || l:text_changed is# 'normal' + \ || l:text_changed is# 'insert' + \) + call ale#Queue(0, '') + endif + endif endfunction function! ale#completion#GetAllTriggers() abort return deepcopy(s:trigger_character_map) endfunction +function! ale#completion#GetCompletionKind(kind) abort + let l:lsp_symbol = get(g:ale_lsp_types, a:kind, '') + + if !empty(l:lsp_symbol) + return l:lsp_symbol + endif + + return get(g:ale_tsserver_types, a:kind, '') +endfunction + +function! ale#completion#GetCompletionSymbols(kind) abort + let l:kind = ale#completion#GetCompletionKind(a:kind) + let l:symbol = get(g:ale_completion_symbols, l:kind, '') + + if !empty(l:symbol) + return l:symbol + endif + + return get(g:ale_completion_symbols, '', 'v') +endfunction + function! s:CompletionStillValid(request_id) abort let [l:line, l:column] = getpos('.')[1:2] - return ale#util#Mode() is# 'i' - \&& has_key(b:, 'ale_completion_info') + return has_key(b:, 'ale_completion_info') + \&& ( + \ ale#util#Mode() is# 'i' + \ || b:ale_completion_info.source is# 'ale-import' + \) \&& b:ale_completion_info.request_id == a:request_id \&& b:ale_completion_info.line == l:line \&& ( \ b:ale_completion_info.column == l:column - \ || b:ale_completion_info.source is# 'deoplete' \ || b:ale_completion_info.source is# 'ale-omnifunc' \ || b:ale_completion_info.source is# 'ale-callback' + \ || b:ale_completion_info.source is# 'ale-import' \) endfunction @@ -296,7 +450,14 @@ function! ale#completion#ParseTSServerCompletions(response) abort let l:names = [] for l:suggestion in a:response.body - call add(l:names, l:suggestion.name) + let l:kind = get(l:suggestion, 'kind', '') + + if g:ale_completion_tsserver_remove_warnings == 0 || l:kind isnot# 'warning' + call add(l:names, { + \ 'word': l:suggestion.name, + \ 'source': get(l:suggestion, 'source', ''), + \}) + endif endfor return l:names @@ -306,11 +467,26 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort let l:buffer = bufnr('') let l:results = [] let l:names_with_details = [] + let l:info = get(b:, 'ale_completion_info', {}) for l:suggestion in a:response.body let l:displayParts = [] + let l:local_name = v:null + + for l:action in get(l:suggestion, 'codeActions', []) + call add(l:displayParts, l:action.description . ' ') + endfor for l:part in l:suggestion.displayParts + " Stop on stop on line breaks for the menu. + if get(l:part, 'kind') is# 'lineBreak' + break + endif + + if get(l:part, 'kind') is# 'localName' + let l:local_name = l:part.text + endif + call add(l:displayParts, l:part.text) endfor @@ -321,22 +497,37 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort call add(l:documentationParts, l:part.text) endfor - if l:suggestion.kind is# 'className' - let l:kind = 'f' - elseif l:suggestion.kind is# 'parameterName' - let l:kind = 'f' - else - let l:kind = 'v' - endif - " See :help complete-items - call add(l:results, { - \ 'word': l:suggestion.name, - \ 'kind': l:kind, + let l:result = { + \ 'word': ( + \ l:suggestion.name is# 'default' + \ && l:suggestion.kind is# 'alias' + \ && !empty(l:local_name) + \ ? l:local_name + \ : l:suggestion.name + \ ), + \ 'kind': ale#completion#GetCompletionSymbols(l:suggestion.kind), \ 'icase': 1, \ 'menu': join(l:displayParts, ''), + \ 'dup': get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, \ 'info': join(l:documentationParts, ''), - \}) + \} + " This flag is used to tell if this completion came from ALE or not. + let l:user_data = {'_ale_completion_item': 1} + + if has_key(l:suggestion, 'codeActions') + let l:user_data.code_actions = l:suggestion.codeActions + endif + + let l:result.user_data = json_encode(l:user_data) + + " Include this item if we'll accept any items, + " or if we only want items with additional edits, and this has them. + if !get(l:info, 'additional_edits_only', 0) + \|| has_key(l:user_data, 'code_actions') + call add(l:results, l:result) + endif endfor let l:names = getbufvar(l:buffer, 'ale_tsserver_completion_names', []) @@ -345,16 +536,17 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort let l:names_with_details = map(copy(l:results), 'v:val.word') let l:missing_names = filter( \ copy(l:names), - \ 'index(l:names_with_details, v:val) < 0', + \ 'index(l:names_with_details, v:val.word) < 0', \) for l:name in l:missing_names call add(l:results, { - \ 'word': l:name, + \ 'word': l:name.word, \ 'kind': 'v', \ 'icase': 1, \ 'menu': '', \ 'info': '', + \ 'user_data': json_encode({'_ale_completion_item': 1}), \}) endfor endif @@ -393,7 +585,7 @@ function! ale#completion#ParseLSPCompletions(response) abort continue endif - if get(l:item, 'insertTextFormat') is s:LSP_INSERT_TEXT_FORMAT_PLAIN + if get(l:item, 'insertTextFormat', s:LSP_INSERT_TEXT_FORMAT_PLAIN) is s:LSP_INSERT_TEXT_FORMAT_PLAIN \&& type(get(l:item, 'textEdit')) is v:t_dict let l:text = l:item.textEdit.newText elseif type(get(l:item, 'insertText')) is v:t_string @@ -408,21 +600,14 @@ function! ale#completion#ParseLSPCompletions(response) abort continue endif - " See :help complete-items for Vim completion kinds - if !has_key(l:item, 'kind') - let l:kind = 'v' - elseif l:item.kind is s:LSP_COMPLETION_METHOD_KIND - let l:kind = 'm' - elseif l:item.kind is s:LSP_COMPLETION_CONSTRUCTOR_KIND - let l:kind = 'm' - elseif l:item.kind is s:LSP_COMPLETION_FUNCTION_KIND - let l:kind = 'f' - elseif l:item.kind is s:LSP_COMPLETION_CLASS_KIND - let l:kind = 'f' - elseif l:item.kind is s:LSP_COMPLETION_INTERFACE_KIND - let l:kind = 'f' - else - let l:kind = 'v' + " Don't use LSP items with additional text edits when autoimport for + " completions is turned off. + if !empty(get(l:item, 'additionalTextEdits')) + \&& !( + \ get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport + \) + continue endif let l:doc = get(l:item, 'documentation', '') @@ -431,17 +616,70 @@ function! ale#completion#ParseLSPCompletions(response) abort let l:doc = l:doc.value endif - call add(l:results, { + " Collapse whitespaces and line breaks into a single space. + let l:detail = substitute(get(l:item, 'detail', ''), '\_s\+', ' ', 'g') + + let l:result = { \ 'word': l:word, - \ 'kind': l:kind, + \ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')), \ 'icase': 1, - \ 'menu': get(l:item, 'detail', ''), + \ 'menu': l:detail, + \ 'dup': get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, \ 'info': (type(l:doc) is v:t_string ? l:doc : ''), - \}) + \} + " This flag is used to tell if this completion came from ALE or not. + let l:user_data = {'_ale_completion_item': 1} + + if has_key(l:item, 'additionalTextEdits') + \ && l:item.additionalTextEdits isnot v:null + let l:text_changes = [] + + for l:edit in l:item.additionalTextEdits + call add(l:text_changes, { + \ 'start': { + \ 'line': l:edit.range.start.line + 1, + \ 'offset': l:edit.range.start.character + 1, + \ }, + \ 'end': { + \ 'line': l:edit.range.end.line + 1, + \ 'offset': l:edit.range.end.character + 1, + \ }, + \ 'newText': l:edit.newText, + \}) + endfor + + if !empty(l:text_changes) + let l:user_data.code_actions = [{ + \ 'description': 'completion', + \ 'changes': [ + \ { + \ 'fileName': expand('#' . l:buffer . ':p'), + \ 'textChanges': l:text_changes, + \ }, + \ ], + \}] + endif + endif + + let l:result.user_data = json_encode(l:user_data) + + " Include this item if we'll accept any items, + " or if we only want items with additional edits, and this has them. + if !get(l:info, 'additional_edits_only', 0) + \|| has_key(l:user_data, 'code_actions') + call add(l:results, l:result) + endif endfor if has_key(l:info, 'prefix') - let l:results = ale#completion#Filter(l:buffer, &filetype, l:results, l:info.prefix) + let l:results = ale#completion#Filter( + \ l:buffer, + \ &filetype, + \ l:results, + \ l:info.prefix, + \ get(l:info, 'additional_edits_only', 0), + \) endif return l:results[: g:ale_completion_max_suggestions - 1] @@ -465,20 +703,41 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort \ &filetype, \ ale#completion#ParseTSServerCompletions(a:response), \ b:ale_completion_info.prefix, + \ get(b:ale_completion_info, 'additional_edits_only', 0), \)[: g:ale_completion_max_suggestions - 1] " We need to remember some names for tsserver, as it doesn't send " details back for everything we send. call setbufvar(l:buffer, 'ale_tsserver_completion_names', l:names) - if !empty(l:names) + if empty(l:names) + " Response with no results now and skip making a redundant request + " for nothing. + call ale#completion#Show([]) + else + let l:identifiers = [] + + for l:name in l:names + let l:identifier = { + \ 'name': l:name.word, + \} + let l:source = get(l:name, 'source', '') + + " Empty source results in no details for the completed item + if !empty(l:source) + call extend(l:identifier, { 'source': l:source }) + endif + + call add(l:identifiers, l:identifier) + endfor + let b:ale_completion_info.request_id = ale#lsp#Send( \ b:ale_completion_info.conn_id, \ ale#lsp#tsserver_message#CompletionEntryDetails( \ l:buffer, \ b:ale_completion_info.line, \ b:ale_completion_info.column, - \ l:names, + \ l:identifiers, \ ), \) endif @@ -520,11 +779,18 @@ function! s:OnReady(linter, lsp_details) abort call ale#lsp#RegisterCallback(l:id, l:Callback) if a:linter.lsp is# 'tsserver' + if get(g:, 'ale_completion_tsserver_autoimport') is 1 + " no-custom-checks + echom '`g:ale_completion_tsserver_autoimport` is deprecated. Use `g:ale_completion_autoimport` instead.' + endif + let l:message = ale#lsp#tsserver_message#Completions( \ l:buffer, \ b:ale_completion_info.line, \ b:ale_completion_info.column, \ b:ale_completion_info.prefix, + \ get(b:ale_completion_info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, \) else " Send a message saying the buffer has changed first, otherwise @@ -558,6 +824,8 @@ endfunction " the current buffer. 1 will be returned if there's a potential source of " completion data ALE can use, and 0 will be returned otherwise. function! ale#completion#CanProvideCompletions() abort + " NOTE: We can report that ALE can provide completions to Deoplete from + " here, and we might ignore linters still below. for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) return 1 @@ -583,9 +851,19 @@ function! ale#completion#GetCompletions(...) abort let b:CompleteCallback = l:CompleteCallback endif - let [l:line, l:column] = getpos('.')[1:2] + if has_key(l:options, 'line') && has_key(l:options, 'column') + " Use a provided line and column, if given. + let l:line = l:options.line + let l:column = l:options.column + else + let [l:line, l:column] = getpos('.')[1:2] + endif - let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) + if has_key(l:options, 'prefix') + let l:prefix = l:options.prefix + else + let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) + endif if l:source is# 'ale-automatic' && empty(l:prefix) return 0 @@ -604,22 +882,57 @@ function! ale#completion#GetCompletions(...) abort \} unlet! b:ale_completion_result + if has_key(l:options, 'additional_edits_only') + let b:ale_completion_info.additional_edits_only = + \ l:options.additional_edits_only + endif + let l:buffer = bufnr('') let l:Callback = function('s:OnReady') let l:started = 0 - for l:linter in ale#linter#Get(&filetype) - if !empty(l:linter.lsp) - if ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) - let l:started = 1 - endif + for l:linter in ale#lsp_linter#GetEnabled(l:buffer) + if ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) + let l:started = 1 endif endfor return l:started endfunction +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +" This function implements the :ALEImport command. +function! ale#completion#Import() abort + let l:word = expand('') + + if empty(l:word) + call s:message('Nothing to complete at cursor!') + + return + endif + + let [l:line, l:column] = getpos('.')[1:2] + let l:column = searchpos('\V' . escape(l:word, '/\'), 'bnc', l:line)[1] + let l:column = l:column + len(l:word) - 1 + + if l:column isnot 0 + let l:started = ale#completion#GetCompletions('ale-import', { + \ 'line': l:line, + \ 'column': l:column, + \ 'prefix': l:word, + \ 'additional_edits_only': 1, + \}) + + if !l:started + call s:message('No completion providers are available.') + endif + endif +endfunction + function! ale#completion#OmniFunc(findstart, base) abort if a:findstart let l:started = ale#completion#GetCompletions('ale-omnifunc') @@ -692,6 +1005,31 @@ function! ale#completion#Queue() abort let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler')) endfunction +function! ale#completion#HandleUserData(completed_item) abort + let l:user_data_json = get(a:completed_item, 'user_data', '') + let l:user_data = type(l:user_data_json) is v:t_dict + \ ? l:user_data_json + \ : ale#util#FuzzyJSONDecode(l:user_data_json, {}) + + if !has_key(l:user_data, '_ale_completion_item') + return + endif + + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if l:source is# 'ale-automatic' + \|| l:source is# 'ale-manual' + \|| l:source is# 'ale-callback' + \|| l:source is# 'ale-import' + \|| l:source is# 'ale-omnifunc' + for l:code_action in get(l:user_data, 'code_actions', []) + call ale#code_action#HandleCodeAction(l:code_action, {}) + endfor + endif + + silent doautocmd User ALECompletePost +endfunction + function! ale#completion#Done() abort silent! pclose @@ -700,6 +1038,12 @@ function! ale#completion#Done() abort let s:last_done_pos = getpos('.')[1:2] endfunction +augroup ALECompletionActions + autocmd! + + autocmd CompleteDone * call ale#completion#HandleUserData(v:completed_item) +augroup END + function! s:Setup(enabled) abort augroup ALECompletionGroup autocmd! diff --git a/sources_non_forked/ale/autoload/ale/cursor.vim b/sources_non_forked/ale/autoload/ale/cursor.vim index 8c331c5c..da3b6922 100644 --- a/sources_non_forked/ale/autoload/ale/cursor.vim +++ b/sources_non_forked/ale/autoload/ale/cursor.vim @@ -9,7 +9,14 @@ let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10) let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s') let s:cursor_timer = -1 -let s:last_pos = [0, 0, 0] + +" A wrapper for echon so we can test messages we echo in Vader tests. +function! ale#cursor#Echom(message) abort + if mode() is# 'n' + " no-custom-checks + exec "norm! :echom a:message\n" + endif +endfunction function! ale#cursor#TruncatedEcho(original_message) abort let l:message = a:original_message @@ -17,6 +24,9 @@ function! ale#cursor#TruncatedEcho(original_message) abort let l:message = substitute(l:message, "\t", ' ', 'g') " Remove any newlines in the message. let l:message = substitute(l:message, "\n", '', 'g') + " Convert indentation groups into single spaces for better legibility when + " put on a single line + let l:message = substitute(l:message, ' \+', ' ', 'g') " We need to remember the setting for shortmess and reset it again. let l:shortmess_options = &l:shortmess @@ -28,7 +38,7 @@ function! ale#cursor#TruncatedEcho(original_message) abort silent! setlocal shortmess+=T try - exec "norm! :echomsg l:message\n" + call ale#cursor#Echom(l:message) catch /^Vim\%((\a\+)\)\=:E523/ " Fallback into manual truncate (#1987) let l:winwidth = winwidth(0) @@ -39,6 +49,8 @@ function! ale#cursor#TruncatedEcho(original_message) abort endif exec 'echomsg l:message' + catch /E481/ + " Do nothing if running from a visual selection. endtry " Reset the cursor position if we moved off the end of the line. @@ -86,7 +98,9 @@ function! ale#cursor#EchoCursorWarning(...) abort elseif get(l:info, 'echoed') " We'll only clear the echoed message when moving off errors once, " so we don't continually clear the echo line. - execute 'echo' + " + " no-custom-checks + echo let l:info.echoed = 0 endif endif @@ -116,14 +130,18 @@ function! ale#cursor#EchoCursorWarningWithDelay() abort let l:pos = getpos('.')[0:2] + if !exists('w:last_pos') + let w:last_pos = [0, 0, 0] + endif + " Check the current buffer, line, and column number against the last " recorded position. If the position has actually changed, *then* " we should echo something. Otherwise we can end up doing processing " the echo message far too frequently. - if l:pos != s:last_pos + if l:pos != w:last_pos let l:delay = ale#Var(l:buffer, 'echo_delay') - let s:last_pos = l:pos + let w:last_pos = l:pos let s:cursor_timer = timer_start( \ l:delay, \ function('ale#cursor#EchoCursorWarning') @@ -137,11 +155,17 @@ function! s:ShowCursorDetailForItem(loc, options) abort let s:last_detailed_line = line('.') let l:message = get(a:loc, 'detail', a:loc.text) let l:lines = split(l:message, "\n") - call ale#preview#Show(l:lines, {'stay_here': l:stay_here}) - " Clear the echo message if we manually displayed details. - if !l:stay_here - execute 'echo' + if g:ale_floating_preview || g:ale_detail_to_floating_preview + call ale#floating_preview#Show(l:lines) + else + call ale#preview#Show(l:lines, {'stay_here': l:stay_here}) + + " Clear the echo message if we manually displayed details. + if !l:stay_here + " no-custom-checks + echo + endif endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/debugging.vim b/sources_non_forked/ale/autoload/ale/debugging.vim index 379c0d73..fe145baf 100644 --- a/sources_non_forked/ale/autoload/ale/debugging.vim +++ b/sources_non_forked/ale/autoload/ale/debugging.vim @@ -1,6 +1,8 @@ " Author: w0rp " Description: This file implements debugging information for ALE +let g:ale_info_default_mode = get(g:, 'ale_info_default_mode', 'preview') + let s:global_variable_list = [ \ 'ale_cache_executable_check_failures', \ 'ale_change_sign_column_color', @@ -8,6 +10,7 @@ let s:global_variable_list = [ \ 'ale_completion_delay', \ 'ale_completion_enabled', \ 'ale_completion_max_suggestions', +\ 'ale_disable_lsp', \ 'ale_echo_cursor', \ 'ale_echo_msg_error_str', \ 'ale_echo_msg_format', @@ -17,6 +20,7 @@ let s:global_variable_list = [ \ 'ale_fix_on_save', \ 'ale_fixers', \ 'ale_history_enabled', +\ 'ale_info_default_mode', \ 'ale_history_log_output', \ 'ale_keep_list_window_open', \ 'ale_lint_delay', @@ -28,16 +32,17 @@ let s:global_variable_list = [ \ 'ale_linter_aliases', \ 'ale_linters', \ 'ale_linters_explicit', +\ 'ale_linters_ignore', \ 'ale_list_vertical', \ 'ale_list_window_size', \ 'ale_loclist_msg_format', -\ 'ale_lsp_root', \ 'ale_max_buffer_history_size', \ 'ale_max_signs', \ 'ale_maximum_file_size', \ 'ale_open_list', \ 'ale_pattern_options', \ 'ale_pattern_options_enabled', +\ 'ale_root', \ 'ale_set_balloons', \ 'ale_set_highlights', \ 'ale_set_loclist', @@ -50,8 +55,9 @@ let s:global_variable_list = [ \ 'ale_sign_style_error', \ 'ale_sign_style_warning', \ 'ale_sign_warning', -\ 'ale_statusline_format', +\ 'ale_sign_highlight_linenrs', \ 'ale_type_map', +\ 'ale_use_neovim_diagnostics_api', \ 'ale_use_global_executables', \ 'ale_virtualtext_cursor', \ 'ale_warn_about_trailing_blank_lines', @@ -59,7 +65,8 @@ let s:global_variable_list = [ \] function! s:Echo(message) abort - execute 'echo a:message' + " no-custom-checks + echo a:message endfunction function! s:GetLinterVariables(filetype, exclude_linter_names) abort @@ -194,10 +201,42 @@ function! s:EchoLSPErrorMessages(all_linter_names) abort endfor endfunction -function! ale#debugging#Info() abort +function! s:GetIgnoredLinters(buffer, enabled_linters) abort + let l:filetype = &filetype + let l:ignore_config = ale#Var(a:buffer, 'linters_ignore') + let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp') + + if ( + \ !empty(l:ignore_config) + \ || l:disable_lsp is 1 + \ || l:disable_lsp is v:true + \ || (l:disable_lsp is# 'auto' && get(g:, 'lspconfig', 0)) + \) + let l:non_ignored = ale#engine#ignore#Exclude( + \ l:filetype, + \ a:enabled_linters, + \ l:ignore_config, + \ l:disable_lsp, + \) + else + let l:non_ignored = copy(a:enabled_linters) + endif + + call map(l:non_ignored, 'v:val.name') + + return filter( + \ copy(a:enabled_linters), + \ 'index(l:non_ignored, v:val.name) < 0' + \) +endfunction + +function! ale#debugging#Info(...) abort + let l:options = (a:0 > 0) ? a:1 : {} + let l:show_preview_info = get(l:options, 'preview') + + let l:buffer = bufnr('') let l:filetype = &filetype - " We get the list of enabled linters for free by the above function. let l:enabled_linters = deepcopy(ale#linter#Get(l:filetype)) " But have to build the list of available linters ourselves. @@ -221,17 +260,42 @@ function! ale#debugging#Info() abort let l:fixers = uniq(sort(l:fixers[0] + l:fixers[1])) let l:fixers_string = join(map(copy(l:fixers), '"\n " . v:val'), '') + " Get the names of ignored linters. + let l:ignored_names = map( + \ s:GetIgnoredLinters(l:buffer, l:enabled_linters), + \ 'v:val.name' + \) + call s:Echo(' Current Filetype: ' . l:filetype) call s:Echo('Available Linters: ' . string(l:all_names)) call s:EchoLinterAliases(l:all_linters) call s:Echo(' Enabled Linters: ' . string(l:enabled_names)) - call s:Echo(' Suggested Fixers: ' . l:fixers_string) - call s:Echo(' Linter Variables:') - call s:Echo('') - call s:EchoLinterVariables(l:variable_list) + call s:Echo(' Ignored Linters: ' . string(l:ignored_names)) + call s:Echo(' Suggested Fixers:' . l:fixers_string) + " We use this line with only a space to know where to end highlights. + call s:Echo(' ') + + " Only show Linter Variables directive if there are any. + if !empty(l:variable_list) + call s:Echo(' Linter Variables:') + + if l:show_preview_info + call s:Echo('" Press Space to read :help for a setting') + endif + + call s:EchoLinterVariables(l:variable_list) + " We use this line with only a space to know where to end highlights. + call s:Echo(' ') + endif + call s:Echo(' Global Variables:') - call s:Echo('') + + if l:show_preview_info + call s:Echo('" Press Space to read :help for a setting') + endif + call s:EchoGlobalVariables() + call s:Echo(' ') call s:EchoLSPErrorMessages(l:all_names) call s:Echo(' Command History:') call s:Echo('') @@ -245,9 +309,7 @@ function! ale#debugging#InfoToClipboard() abort return endif - redir => l:output - silent call ale#debugging#Info() - redir END + let l:output = execute('call ale#debugging#Info()') let @+ = l:output call s:Echo('ALEInfo copied to your clipboard') @@ -256,10 +318,51 @@ endfunction function! ale#debugging#InfoToFile(filename) abort let l:expanded_filename = expand(a:filename) - redir => l:output - silent call ale#debugging#Info() - redir END + let l:output = execute('call ale#debugging#Info()') call writefile(split(l:output, "\n"), l:expanded_filename) call s:Echo('ALEInfo written to ' . l:expanded_filename) endfunction + +function! ale#debugging#InfoToPreview() abort + let l:output = execute('call ale#debugging#Info({''preview'': 1})') + + call ale#preview#Show(split(l:output, "\n"), { + \ 'filetype': 'ale-info', + \}) +endfunction + +function! ale#debugging#InfoCommand(...) abort + if len(a:000) > 1 + " no-custom-checks + echom 'Invalid ALEInfo arguments!' + + return + endif + + " Do not show info for the info window itself. + if &filetype is# 'ale-info' + return + endif + + " Get 'echo' from '-echo', if there's an argument. + let l:mode = get(a:000, '')[1:] + + if empty(l:mode) + let l:mode = ale#Var(bufnr(''), 'info_default_mode') + endif + + if l:mode is# 'echo' + call ale#debugging#Info() + elseif l:mode is# 'clip' || l:mode is# 'clipboard' + call ale#debugging#InfoToClipboard() + else + call ale#debugging#InfoToPreview() + endif +endfunction + +function! ale#debugging#InfoToClipboardDeprecatedCommand() abort + " no-custom-checks + echom 'ALEInfoToClipboard is deprecated. Use ALEInfo -clipboard instead.' + call ale#debugging#InfoToClipboard() +endfunction diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 3915cac1..210ee038 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -5,6 +5,7 @@ let s:go_to_definition_map = {} " Enable automatic updates of the tagstack let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1) +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') " Used to get the definition map in tests. function! ale#definition#GetMap() abort @@ -34,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 get(a:response, 'command', '') is# 'definition' + 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) @@ -64,15 +137,47 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort let l:result = [] endif - for l:item in l:result - let l:filename = ale#path#FromURI(l:item.uri) - let l:line = l:item.range.start.line + 1 - let l:column = l:item.range.start.character + 1 + let l:item_list = [] - call ale#definition#UpdateTagStack() - call ale#util#Open(l:filename, l:line, l:column, l:options) - break + 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 + let l:filename = ale#path#FromFileURI(l:uri) + call ale#util#Open(l:filename, l:line, l:column, l:options) + else + call l:uri_handler.OpenURILink(l:uri, l:line, l:column, l:options, a:conn_id) + endif + 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 @@ -91,11 +196,25 @@ function! s:OnReady(line, column, options, capability, linter, lsp_details) abor call ale#lsp#RegisterCallback(l:id, l:Callback) if a:linter.lsp is# 'tsserver' - let l:message = ale#lsp#tsserver_message#Definition( - \ l:buffer, - \ a:line, - \ a:column - \) + if a:capability is# 'definition' + let l:message = ale#lsp#tsserver_message#Definition( + \ l:buffer, + \ a:line, + \ a:column + \) + elseif a:capability is# 'typeDefinition' + let l:message = ale#lsp#tsserver_message#TypeDefinition( + \ l:buffer, + \ a:line, + \ a:column + \) + elseif a:capability is# 'implementation' + let l:message = ale#lsp#tsserver_message#Implementation( + \ l:buffer, + \ a:line, + \ a:column + \) + endif else " Send a message saying the buffer has changed first, or the " definition position probably won't make sense. @@ -108,6 +227,8 @@ function! s:OnReady(line, column, options, capability, linter, lsp_details) abor let l:message = ale#lsp#message#Definition(l:buffer, a:line, a:column) elseif a:capability is# 'typeDefinition' let l:message = ale#lsp#message#TypeDefinition(l:buffer, a:line, a:column) + elseif a:capability is# 'implementation' + let l:message = ale#lsp#message#Implementation(l:buffer, a:line, a:column) else " XXX: log here? return @@ -134,23 +255,51 @@ function! s:GoToLSPDefinition(linter, options, capability) abort endfunction function! ale#definition#GoTo(options) abort - for l:linter in ale#linter#Get(&filetype) - if !empty(l:linter.lsp) - call s:GoToLSPDefinition(l:linter, a:options, 'definition') - endif + for l:linter in ale#lsp_linter#GetEnabled(bufnr('')) + call s:GoToLSPDefinition(l:linter, a:options, 'definition') endfor endfunction function! ale#definition#GoToType(options) abort - for l:linter in ale#linter#Get(&filetype) - if !empty(l:linter.lsp) - " TODO: handle typeDefinition for tsserver if supported by the - " protocol - if l:linter.lsp is# 'tsserver' - continue - endif - - call s:GoToLSPDefinition(l:linter, a:options, 'typeDefinition') - endif + for l:linter in ale#lsp_linter#GetEnabled(bufnr('')) + call s:GoToLSPDefinition(l:linter, a:options, 'typeDefinition') endfor endfunction + +function! ale#definition#GoToImpl(options) abort + for l:linter in ale#lsp_linter#GetEnabled(bufnr('')) + call s:GoToLSPDefinition(l:linter, a:options, 'implementation') + endfor +endfunction + +function! ale#definition#GoToCommandHandler(command, ...) abort + let l:options = {} + + if len(a:000) > 0 + for l:option in a:000 + if l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' + endif + endfor + endif + + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + + if a:command is# 'type' + call ale#definition#GoToType(l:options) + elseif a:command is# 'implementation' + call ale#definition#GoToImpl(l:options) + else + call ale#definition#GoTo(l:options) + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/dhall.vim b/sources_non_forked/ale/autoload/ale/dhall.vim new file mode 100644 index 00000000..cc54418f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/dhall.vim @@ -0,0 +1,24 @@ +" Author: Pat Brisbin , toastal +" Description: Functions for working with Dhall’s executable + +call ale#Set('dhall_executable', 'dhall') +call ale#Set('dhall_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('dhall_options', '') + +function! ale#dhall#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'dhall_executable') + + " Dhall is written in Haskell and commonly installed with Stack + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall') +endfunction + +function! ale#dhall#GetExecutableWithOptions(buffer) abort + let l:executable = ale#dhall#GetExecutable(a:buffer) + + return l:executable + \ . ale#Pad(ale#Var(a:buffer, 'dhall_options')) +endfunction + +function! ale#dhall#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'dhall_options')) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/engine.vim b/sources_non_forked/ale/autoload/ale/engine.vim index 491d3c2e..28579056 100644 --- a/sources_non_forked/ale/autoload/ale/engine.vim +++ b/sources_non_forked/ale/autoload/ale/engine.vim @@ -4,6 +4,7 @@ " Remapping of linter problems. let g:ale_type_map = get(g:, 'ale_type_map', {}) +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) if !has_key(s:, 'executable_cache_map') let s:executable_cache_map = {} @@ -104,42 +105,6 @@ function! ale#engine#IsCheckingBuffer(buffer) abort \ || !empty(get(l:info, 'active_other_sources_list', [])) endfunction -" Register a temporary file to be managed with the ALE engine for -" a current job run. -function! ale#engine#ManageFile(buffer, filename) abort - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''ale#engine#ManageFile is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - call ale#command#ManageFile(a:buffer, a:filename) -endfunction - -" Same as the above, but manage an entire directory. -function! ale#engine#ManageDirectory(buffer, directory) abort - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''ale#engine#ManageDirectory is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - call ale#command#ManageDirectory(a:buffer, a:directory) -endfunction - -function! ale#engine#CreateFile(buffer) abort - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''ale#engine#CreateFile is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - return ale#command#CreateFile(a:buffer) -endfunction - -" Create a new temporary directory and manage it in one go. -function! ale#engine#CreateDirectory(buffer) abort - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''ale#engine#CreateDirectory is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - return ale#command#CreateDirectory(a:buffer) -endfunction - function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_source) abort let l:info = get(g:ale_buffer_info, a:buffer, {}) @@ -192,7 +157,6 @@ function! s:HandleExit(job_info, buffer, output, data) abort let l:linter = a:job_info.linter let l:executable = a:job_info.executable - let l:next_chain_index = a:job_info.next_chain_index " Remove this job from the list. call ale#engine#MarkLinterInactive(l:buffer_info, l:linter.name) @@ -207,20 +171,6 @@ function! s:HandleExit(job_info, buffer, output, data) abort call remove(a:output, -1) endif - if l:next_chain_index < len(get(l:linter, 'command_chain', [])) - let [l:command, l:options] = ale#engine#ProcessChain( - \ a:buffer, - \ l:executable, - \ l:linter, - \ l:next_chain_index, - \ a:output, - \) - - call s:RunJob(l:command, l:options) - - return - endif - try let l:loclist = ale#util#GetFunction(l:linter.callback)(a:buffer, a:output) " Handle the function being unknown, or being deleted. @@ -228,15 +178,25 @@ function! s:HandleExit(job_info, buffer, output, data) abort let l:loclist = [] endtry + if type(l:loclist) isnot# v:t_list + " we only expect the list type; don't pass anything else down to + " `ale#engine#HandleLoclist` since it won't understand it + let l:loclist = [] + endif + call ale#engine#HandleLoclist(l:linter.name, a:buffer, l:loclist, 0) endfunction function! ale#engine#SetResults(buffer, loclist) abort let l:linting_is_done = !ale#engine#IsCheckingBuffer(a:buffer) + if g:ale_use_neovim_diagnostics_api + call ale#engine#SendResultsToNeovimDiagnostics(a:buffer, a:loclist) + endif + " Set signs first. This could potentially fix some line numbers. " The List could be sorted again here by SetSigns. - if g:ale_set_signs + if !g:ale_use_neovim_diagnostics_api && g:ale_set_signs call ale#sign#SetSigns(a:buffer, a:loclist) endif @@ -249,10 +209,15 @@ function! ale#engine#SetResults(buffer, loclist) abort call ale#statusline#Update(a:buffer, a:loclist) endif - if g:ale_set_highlights + if !g:ale_use_neovim_diagnostics_api && g:ale_set_highlights call ale#highlight#SetHighlights(a:buffer, a:loclist) endif + if !g:ale_use_neovim_diagnostics_api + \&& (g:ale_virtualtext_cursor is# 'all' || g:ale_virtualtext_cursor == 2) + call ale#virtualtext#SetTexts(a:buffer, a:loclist) + endif + if l:linting_is_done if g:ale_echo_cursor " Try and echo the warning now. @@ -260,7 +225,8 @@ function! ale#engine#SetResults(buffer, loclist) abort call ale#cursor#EchoCursorWarning() endif - if g:ale_virtualtext_cursor + if !g:ale_use_neovim_diagnostics_api + \&& (g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor == 1) " Try and show the warning now. " This will only do something meaningful if we're in normal mode. call ale#virtualtext#ShowCursorWarning() @@ -284,6 +250,19 @@ function! ale#engine#SetResults(buffer, loclist) abort endif endfunction +function! ale#engine#SendResultsToNeovimDiagnostics(buffer, loclist) abort + if !has('nvim-0.6') + " We will warn the user on startup as well if they try to set + " g:ale_use_neovim_diagnostics_api outside of a Neovim context. + return + endif + + " Keep the Lua surface area really small in the VimL part of ALE, + " and just require the diagnostics.lua module on demand. + let l:SendDiagnostics = luaeval('require("ale.diagnostics").sendAleResultsToDiagnostics') + call l:SendDiagnostics(a:buffer, a:loclist) +endfunction + function! s:RemapItemTypes(type_map, loclist) abort for l:item in a:loclist let l:key = l:item.type @@ -307,6 +286,13 @@ function! s:RemapItemTypes(type_map, loclist) abort endfunction function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist) abort + let l:mappings = ale#GetFilenameMappings(a:buffer, a:linter_name) + + if !empty(l:mappings) + " We need to apply reverse filename mapping here. + let l:mappings = ale#filename_mapping#Invert(l:mappings) + endif + let l:bufnr_map = {} let l:new_loclist = [] @@ -347,13 +333,19 @@ function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist) let l:item.code = l:old_item.code endif - if has_key(l:old_item, 'filename') - \&& !ale#path#IsTempName(l:old_item.filename) + let l:old_name = get(l:old_item, 'filename', '') + + " Map parsed from output to local filesystem files. + if !empty(l:old_name) && !empty(l:mappings) + let l:old_name = ale#filename_mapping#Map(l:old_name, l:mappings) + endif + + if !empty(l:old_name) && !ale#path#IsTempName(l:old_name) " Use the filename given. " Temporary files are assumed to be for this buffer, " and the filename is not included then, because it looks bad " in the loclist window. - let l:filename = l:old_item.filename + let l:filename = l:old_name let l:item.filename = l:filename if has_key(l:old_item, 'bufnr') @@ -384,6 +376,12 @@ function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist) if has_key(l:old_item, 'end_lnum') let l:item.end_lnum = str2nr(l:old_item.end_lnum) + + " When the error ends after the end of the file, put it at the + " end. This is only done for the current buffer. + if l:item.bufnr == a:buffer && l:item.end_lnum > l:last_line_number + let l:item.end_lnum = l:last_line_number + endif endif if has_key(l:old_item, 'sub_type') @@ -450,24 +448,25 @@ function! s:RunJob(command, options) abort return 0 endif + let l:cwd = a:options.cwd let l:executable = a:options.executable let l:buffer = a:options.buffer let l:linter = a:options.linter let l:output_stream = a:options.output_stream - let l:next_chain_index = a:options.next_chain_index - let l:read_buffer = a:options.read_buffer + let l:read_buffer = a:options.read_buffer && !a:options.lint_file let l:info = g:ale_buffer_info[l:buffer] let l:Callback = function('s:HandleExit', [{ \ 'linter': l:linter, \ 'executable': l:executable, - \ 'next_chain_index': l:next_chain_index, \}]) let l:result = ale#command#Run(l:buffer, l:command, l:Callback, { + \ 'cwd': l:cwd, \ 'output_stream': l:output_stream, \ 'executable': l:executable, \ 'read_buffer': l:read_buffer, - \ 'log_output': l:next_chain_index >= len(get(l:linter, 'command_chain', [])), + \ 'log_output': 1, + \ 'filename_mappings': ale#GetFilenameMappings(l:buffer, l:linter.name), \}) " Only proceed if the job is being run. @@ -482,69 +481,7 @@ function! s:RunJob(command, options) abort return 1 endfunction -" Determine which commands to run for a link in a command chain, or -" just a regular command. -function! ale#engine#ProcessChain(buffer, executable, linter, chain_index, input) abort - let l:output_stream = get(a:linter, 'output_stream', 'stdout') - let l:read_buffer = a:linter.read_buffer - let l:chain_index = a:chain_index - let l:input = a:input - - while l:chain_index < len(a:linter.command_chain) - " Run a chain of commands, one asynchronous command after the other, - " so that many programs can be run in a sequence. - let l:chain_item = a:linter.command_chain[l:chain_index] - - if l:chain_index == 0 - " The first callback in the chain takes only a buffer number. - let l:command = ale#util#GetFunction(l:chain_item.callback)( - \ a:buffer - \) - else - " The second callback in the chain takes some input too. - let l:command = ale#util#GetFunction(l:chain_item.callback)( - \ a:buffer, - \ l:input - \) - endif - - " If we have a command to run, execute that. - if !empty(l:command) - " The chain item can override the output_stream option. - if has_key(l:chain_item, 'output_stream') - let l:output_stream = l:chain_item.output_stream - endif - - " The chain item can override the read_buffer option. - if has_key(l:chain_item, 'read_buffer') - let l:read_buffer = l:chain_item.read_buffer - elseif l:chain_index != len(a:linter.command_chain) - 1 - " Don't read the buffer for commands besides the last one - " in the chain by default. - let l:read_buffer = 0 - endif - - break - endif - - " Command chain items can return an empty string to indicate that - " a command should be skipped, so we should try the next item - " with no input. - let l:input = [] - let l:chain_index += 1 - endwhile - - return [l:command, { - \ 'executable': a:executable, - \ 'buffer': a:buffer, - \ 'linter': a:linter, - \ 'output_stream': l:output_stream, - \ 'next_chain_index': l:chain_index + 1, - \ 'read_buffer': l:read_buffer, - \}] -endfunction - -function! s:StopCurrentJobs(buffer, clear_lint_file_jobs) abort +function! s:StopCurrentJobs(buffer, clear_lint_file_jobs, linter_slots) abort let l:info = get(g:ale_buffer_info, a:buffer, {}) call ale#command#StopJobs(a:buffer, 'linter') @@ -553,11 +490,25 @@ function! s:StopCurrentJobs(buffer, clear_lint_file_jobs) abort call ale#command#StopJobs(a:buffer, 'file_linter') let l:info.active_linter_list = [] else + let l:lint_file_map = {} + + " Use a previously computed map of `lint_file` values to find + " linters that are used for linting files. + for [l:lint_file, l:linter] in a:linter_slots + if l:lint_file is 1 + let l:lint_file_map[l:linter.name] = 1 + endif + endfor + " Keep jobs for linting files when we're only linting buffers. - call filter(l:info.active_linter_list, 'get(v:val, ''lint_file'')') + call filter(l:info.active_linter_list, 'get(l:lint_file_map, v:val.name)') endif endfunction +function! ale#engine#Stop(buffer) abort + call s:StopCurrentJobs(a:buffer, 1, []) +endfunction + function! s:RemoveProblemsForDisabledLinters(buffer, linters) abort " Figure out which linters are still enabled, and remove " problems for linters which are no longer enabled. @@ -608,10 +559,15 @@ function! s:AddProblemsFromOtherBuffers(buffer, linters) abort endif endfunction -function! s:RunIfExecutable(buffer, linter, executable) abort +function! s:RunIfExecutable(buffer, linter, lint_file, executable) abort if ale#command#IsDeferred(a:executable) let a:executable.result_callback = { - \ executable -> s:RunIfExecutable(a:buffer, a:linter, executable) + \ executable -> s:RunIfExecutable( + \ a:buffer, + \ a:linter, + \ a:lint_file, + \ executable + \ ) \} return 1 @@ -619,29 +575,31 @@ function! s:RunIfExecutable(buffer, linter, executable) abort if ale#engine#IsExecutable(a:buffer, a:executable) " Use different job types for file or linter jobs. - let l:job_type = a:linter.lint_file ? 'file_linter' : 'linter' + let l:job_type = a:lint_file ? 'file_linter' : 'linter' call setbufvar(a:buffer, 'ale_job_type', l:job_type) - if has_key(a:linter, 'command_chain') - let [l:command, l:options] = ale#engine#ProcessChain( - \ a:buffer, - \ a:executable, - \ a:linter, - \ 0, - \ [] - \) + " Get the cwd for the linter and set it before we call GetCommand. + " This will ensure that ale#command#Run uses it by default. + let l:cwd = ale#linter#GetCwd(a:buffer, a:linter) - return s:RunJob(l:command, l:options) + if l:cwd isnot v:null + call ale#command#SetCwd(a:buffer, l:cwd) endif let l:command = ale#linter#GetCommand(a:buffer, a:linter) + + if l:cwd isnot v:null + call ale#command#ResetCwd(a:buffer) + endif + let l:options = { + \ 'cwd': l:cwd, \ 'executable': a:executable, \ 'buffer': a:buffer, \ 'linter': a:linter, \ 'output_stream': get(a:linter, 'output_stream', 'stdout'), - \ 'next_chain_index': 1, \ 'read_buffer': a:linter.read_buffer, + \ 'lint_file': a:lint_file, \} return s:RunJob(l:command, l:options) @@ -653,22 +611,73 @@ endfunction " Run a linter for a buffer. " " Returns 1 if the linter was successfully run. -function! s:RunLinter(buffer, linter) abort +function! s:RunLinter(buffer, linter, lint_file) abort if !empty(a:linter.lsp) return ale#lsp_linter#CheckWithLSP(a:buffer, a:linter) else let l:executable = ale#linter#GetExecutable(a:buffer, a:linter) - return s:RunIfExecutable(a:buffer, a:linter, l:executable) + return s:RunIfExecutable(a:buffer, a:linter, a:lint_file, l:executable) endif return 0 endfunction -function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort - " Initialise the buffer information if needed. - let l:new_buffer = ale#engine#InitBufferInfo(a:buffer) - call s:StopCurrentJobs(a:buffer, a:should_lint_file) +function! s:GetLintFileSlots(buffer, linters) abort + let l:linter_slots = [] + + for l:linter in a:linters + let l:LintFile = l:linter.lint_file + + if type(l:LintFile) is v:t_func + let l:LintFile = l:LintFile(a:buffer) + endif + + call add(l:linter_slots, [l:LintFile, l:linter]) + endfor + + return l:linter_slots +endfunction + +function! s:GetLintFileValues(slots, Callback) abort + let l:deferred_list = [] + let l:new_slots = [] + + for [l:lint_file, l:linter] in a:slots + while ale#command#IsDeferred(l:lint_file) && has_key(l:lint_file, 'value') + " If we've already computed the return value, use it. + let l:lint_file = l:lint_file.value + endwhile + + if ale#command#IsDeferred(l:lint_file) + " If we are going to return the result later, wait for it. + call add(l:deferred_list, l:lint_file) + else + " If we have the value now, coerce it to 0 or 1. + let l:lint_file = l:lint_file is 1 + endif + + call add(l:new_slots, [l:lint_file, l:linter]) + endfor + + if !empty(l:deferred_list) + for l:deferred in l:deferred_list + let l:deferred.result_callback = + \ {-> s:GetLintFileValues(l:new_slots, a:Callback)} + endfor + else + call a:Callback(l:new_slots) + endif +endfunction + +function! s:RunLinters( +\ buffer, +\ linters, +\ slots, +\ should_lint_file, +\ new_buffer, +\) abort + call s:StopCurrentJobs(a:buffer, a:should_lint_file, a:slots) call s:RemoveProblemsForDisabledLinters(a:buffer, a:linters) " We can only clear the results if we aren't checking the buffer. @@ -676,10 +685,10 @@ function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort silent doautocmd User ALELintPre - for l:linter in a:linters + for [l:lint_file, l:linter] in a:slots " Only run lint_file linters if we should. - if !l:linter.lint_file || a:should_lint_file - if s:RunLinter(a:buffer, l:linter) + if !l:lint_file || a:should_lint_file + if s:RunLinter(a:buffer, l:linter, l:lint_file) " If a single linter ran, we shouldn't clear everything. let l:can_clear_results = 0 endif @@ -694,11 +703,32 @@ function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort " disabled, or ALE itself is disabled. if l:can_clear_results call ale#engine#SetResults(a:buffer, []) - elseif l:new_buffer - call s:AddProblemsFromOtherBuffers(a:buffer, a:linters) + elseif a:new_buffer + call s:AddProblemsFromOtherBuffers( + \ a:buffer, + \ map(copy(a:slots), 'v:val[1]') + \) endif endfunction +function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort + " Initialise the buffer information if needed. + let l:new_buffer = ale#engine#InitBufferInfo(a:buffer) + + call s:GetLintFileValues( + \ s:GetLintFileSlots(a:buffer, a:linters), + \ { + \ slots -> s:RunLinters( + \ a:buffer, + \ a:linters, + \ slots, + \ a:should_lint_file, + \ l:new_buffer, + \ ) + \ } + \) +endfunction + " Clean up a buffer. " " This function will stop all current jobs for the buffer, diff --git a/sources_non_forked/ale/autoload/ale/engine/ignore.vim b/sources_non_forked/ale/autoload/ale/engine/ignore.vim index 80574656..8ac36eb5 100644 --- a/sources_non_forked/ale/autoload/ale/engine/ignore.vim +++ b/sources_non_forked/ale/autoload/ale/engine/ignore.vim @@ -1,6 +1,26 @@ " Author: w0rp " Description: Code for ignoring linters. Only loaded and if configured. +" A map for remapping lspconfig server names to linter names or aliases in +" ALE. We should change the names where they will conflict with names in ALE. +" +" Notes on names from nvim-lspconfig not included here. +" +" * 'rubocop' is run in a language server mode +" * 'eslint' is run via 'vscode-eslint-language-server' +let s:lspconfig_map = { +\ 'als': 'adals', +\ 'ansiblels': 'ansible-language-server', +\ 'bicep': 'bicep_language_server', +\ 'cmake': 'cmake_language_server', +\ 'denols': 'deno', +\ 'erlangls': 'erlang_ls', +\ 'html': 'vscodehtml', +\ 'ocamlls': 'ocaml-language-server', +\ 'ols': 'odin-lsp', +\ 'puppet': 'puppet_languageserver', +\} + " Given a filetype and a configuration for ignoring linters, return a List of " Strings for linter names to ignore. function! ale#engine#ignore#GetList(filetype, config) abort @@ -21,24 +41,51 @@ function! ale#engine#ignore#GetList(filetype, config) abort return [] endfunction +" This function can be mocked in tests. +function! ale#engine#ignore#GetLSPConfigNames() abort + return luaeval('require ''ale.util''.configured_lspconfig_servers()') +endfunction + +function! s:GetMappedLSPConfigNames() abort + " Check the lspconfig flag before calling luaeval. + if !get(g:, 'lspconfig', 0) + return [] + endif + + let l:lspconfig_servers = ale#engine#ignore#GetLSPConfigNames() + + return map( + \ !empty(l:lspconfig_servers) ? l:lspconfig_servers : [], + \ {_, val -> get(s:lspconfig_map, val, val) } + \) +endfunction + " Given a List of linter descriptions, exclude the linters to be ignored. function! ale#engine#ignore#Exclude(filetype, all_linters, config, disable_lsp) abort let l:names_to_remove = ale#engine#ignore#GetList(a:filetype, a:config) + + " If configured to automatically ignore otherwise configured LSP linter + " names, add them to the names to remove. This could ignore linters + " with matching names that are not marked as LSP linters. + if a:disable_lsp is# 'auto' + call extend(l:names_to_remove, s:GetMappedLSPConfigNames()) + endif + + let l:ignore_all_lsps = a:disable_lsp is 1 || a:disable_lsp is v:true let l:filtered_linters = [] for l:linter in a:all_linters - let l:name_list = [l:linter.name] + l:linter.aliases - let l:should_include = 1 + let l:should_include = index(l:names_to_remove, l:linter.name) == -1 + let l:i = 0 - for l:name in l:name_list - if index(l:names_to_remove, l:name) >= 0 - let l:should_include = 0 - break - endif - endfor + while l:should_include && l:i < len(l:linter.aliases) + let l:name = l:linter.aliases[l:i] + let l:should_include = index(l:names_to_remove, l:name) == -1 + let l:i += 1 + endwhile - if a:disable_lsp && has_key(l:linter, 'lsp') && l:linter.lsp isnot# '' - let l:should_include = 0 + if l:should_include && l:ignore_all_lsps + let l:should_include = empty(get(l:linter, 'lsp')) endif if l:should_include diff --git a/sources_non_forked/ale/autoload/ale/events.vim b/sources_non_forked/ale/autoload/ale/events.vim index da554ef9..f6aae3e9 100644 --- a/sources_non_forked/ale/autoload/ale/events.vim +++ b/sources_non_forked/ale/autoload/ale/events.vim @@ -92,6 +92,75 @@ function! ale#events#FileChangedEvent(buffer) abort endif endfunction +" A timer for emulating InsertLeave. +" +" We only need a single timer, and we'll lint the last buffer we entered +" insert mode on. +if !exists('s:insert_leave_timer') + let s:insert_leave_timer = -1 +endif + +" True if the ModeChanged event exists. +" In this case, ModeChanged will be used instead of InsertLeave emulation. +let s:mode_changed_exists = exists('##ModeChanged') + +function! ale#events#EmulateInsertLeave(buffer) abort + if mode() is# 'n' + call timer_stop(s:insert_leave_timer) + call ale#Queue(0, '', a:buffer) + endif +endfunction + +function! ale#events#InsertEnterEvent(buffer) abort + if g:ale_close_preview_on_insert && exists('*ale#preview#CloseIfTypeMatches') + call ale#preview#CloseIfTypeMatches('ale-preview') + endif + + " Start a repeating timer if the use might not trigger InsertLeave, so we + " can emulate its behavior. + " If the ModeChanged autocmd exists, it will be used instead of this + " timer; as ModeChanged will be sent regardless of how the insert mode is + " exited, including , and . + if ale#Var(a:buffer, 'lint_on_insert_leave') + \&& maparg("\", 'i') isnot# '' + \&& !s:mode_changed_exists + call timer_stop(s:insert_leave_timer) + let s:insert_leave_timer = timer_start( + \ 100, + \ {-> ale#events#EmulateInsertLeave(a:buffer) }, + \ {'repeat': -1} + \) + endif +endfunction + +function! ale#events#InsertLeaveEvent(buffer) abort + " Kill the InsertLeave emulation if the event fired. + " If the ModeChanged event is available, it will be used instead of + " a timer. + if !s:mode_changed_exists + call timer_stop(s:insert_leave_timer) + endif + + if ale#Var(a:buffer, 'lint_on_insert_leave') + call ale#Queue(0, '', a:buffer) + endif + + " Look for a warning to echo as soon as we leave Insert mode. + " The script's position variable used when moving the cursor will + " not be changed here. + " + " We don't echo this message in emulated insert leave mode, as the user + " may want less work to happen on pressing versus + if exists('*ale#engine#Cleanup') + call ale#cursor#EchoCursorWarning() + + if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor is# 1 || g:ale_virtualtext_cursor is# '1' + " Show a virtualtext message if enabled. + call ale#virtualtext#ShowCursorWarning() + endif + endif +endfunction + function! ale#events#Init() abort " This value used to be a Boolean as a Number, and is now a String. let l:text_changed = '' . g:ale_lint_on_text_changed @@ -105,11 +174,11 @@ function! ale#events#Init() abort if g:ale_enabled if l:text_changed is? 'always' || l:text_changed is# '1' - autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay) + autocmd TextChanged,TextChangedI * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) elseif l:text_changed is? 'normal' - autocmd TextChanged * call ale#Queue(g:ale_lint_delay) + autocmd TextChanged * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) elseif l:text_changed is? 'insert' - autocmd TextChangedI * call ale#Queue(g:ale_lint_delay) + autocmd TextChangedI * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) endif if g:ale_lint_on_enter @@ -127,29 +196,56 @@ function! ale#events#Init() abort \) endif - if g:ale_lint_on_insert_leave - autocmd InsertLeave * if ale#Var(str2nr(expand('')), 'lint_on_insert_leave') | call ale#Queue(0) | endif + " Add an InsertEnter event if we need to close the preview window + " on entering insert mode, or if we want to run ALE on leaving + " insert mode and is not the same as . + " + " We will emulate leaving insert mode for users that might not + " trigger InsertLeave. + " + " If the ModeChanged event is available, this timer will not + " be used. + if g:ale_close_preview_on_insert + \|| (g:ale_lint_on_insert_leave && maparg("\", 'i') isnot# '' && !s:mode_changed_exists) + autocmd InsertEnter * call ale#events#InsertEnterEvent(str2nr(expand(''))) endif + let l:add_insert_leave_event = g:ale_lint_on_insert_leave + if g:ale_echo_cursor || g:ale_cursor_detail + " We need to make the message display on InsertLeave + let l:add_insert_leave_event = 1 + autocmd CursorMoved,CursorHold * if exists('*ale#engine#Cleanup') | call ale#cursor#EchoCursorWarningWithDelay() | endif - " Look for a warning to echo as soon as we leave Insert mode. - " The script's position variable used when moving the cursor will - " not be changed here. - autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#cursor#EchoCursorWarning() | endif endif - if g:ale_virtualtext_cursor + if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor is# 1 || g:ale_virtualtext_cursor is# '1' + " We need to make the message display on InsertLeave + let l:add_insert_leave_event = 1 + autocmd CursorMoved,CursorHold * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarningWithDelay() | endif - " Look for a warning to echo as soon as we leave Insert mode. - " The script's position variable used when moving the cursor will - " not be changed here. - autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarning() | endif endif - if g:ale_close_preview_on_insert - autocmd InsertEnter * if exists('*ale#preview#CloseIfTypeMatches') | call ale#preview#CloseIfTypeMatches('ale-preview') | endif + if l:add_insert_leave_event + if s:mode_changed_exists + " If the ModeChanged event is available, handle any + " transition from the Insert mode to any other mode. + autocmd ModeChanged i*:* call ale#events#InsertLeaveEvent(str2nr(expand(''))) + else + " If ModeChanged is not available, handle InsertLeave events. + autocmd InsertLeave * call ale#events#InsertLeaveEvent(str2nr(expand(''))) + endif + endif + + if g:ale_hover_cursor + autocmd CursorHold * if exists('*ale#lsp#Send') | call ale#hover#ShowTruncatedMessageAtCursor() | endif endif endif augroup END + + augroup AleURISchemes + autocmd! + + autocmd BufNewFile,BufReadPre jdt://** call ale#uri#jdt#ReadJDTLink(expand('')) + augroup END endfunction diff --git a/sources_non_forked/ale/autoload/ale/filename_mapping.vim b/sources_non_forked/ale/autoload/ale/filename_mapping.vim new file mode 100644 index 00000000..76d47acc --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/filename_mapping.vim @@ -0,0 +1,22 @@ +" Author: w0rp +" Description: Logic for handling mappings between files + +" Invert filesystem mappings so they can be mapped in reverse. +function! ale#filename_mapping#Invert(filename_mappings) abort + return map(copy(a:filename_mappings), '[v:val[1], v:val[0]]') +endfunction + +" Given a filename and some filename_mappings, map a filename. +function! ale#filename_mapping#Map(filename, filename_mappings) abort + let l:simplified_filename = ale#path#Simplify(a:filename) + + for [l:mapping_from, l:mapping_to] in a:filename_mappings + let l:mapping_from = ale#path#Simplify(l:mapping_from) + + if l:simplified_filename[:len(l:mapping_from) - 1] is# l:mapping_from + return l:mapping_to . l:simplified_filename[len(l:mapping_from):] + endif + endfor + + return a:filename +endfunction diff --git a/sources_non_forked/ale/autoload/ale/filerename.vim b/sources_non_forked/ale/autoload/ale/filerename.vim new file mode 100644 index 00000000..93cf78e1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/filerename.vim @@ -0,0 +1,133 @@ +" Author: Dalius Dobravolskas +" Description: Rename file support for tsserver + +let s:filerename_map = {} + +" Used to get the rename map in tests. +function! ale#filerename#GetMap() abort + return deepcopy(s:filerename_map) +endfunction + +" Used to set the rename map in tests. +function! ale#filerename#SetMap(map) abort + let s:filerename_map = a:map +endfunction + +function! ale#filerename#ClearLSPData() abort + let s:filerename_map = {} +endfunction + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +function! ale#filerename#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') isnot# 'getEditsForFileRename' + return + endif + + if !has_key(s:filerename_map, a:response.request_seq) + return + endif + + let l:options = remove(s:filerename_map, a:response.request_seq) + + let l:old_name = l:options.old_name + let l:new_name = l:options.new_name + + if get(a:response, 'success', v:false) is v:false + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error renaming file "' . l:old_name . '" to "' . l:new_name + \ . '". Reason: ' . l:message) + + return + endif + + let l:changes = a:response.body + + if empty(l:changes) + call s:message('No changes while renaming "' . l:old_name . '" to "' . l:new_name . '"') + else + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'filerename', + \ 'changes': l:changes, + \ }, + \ { + \ 'should_save': 1, + \ }, + \) + endif + + silent! noautocmd execute 'saveas ' . l:new_name + call delete(l:old_name) +endfunction + +function! s:OnReady(options, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'filerename') + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = function('ale#filerename#HandleTSServerResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:message = ale#lsp#tsserver_message#GetEditsForFileRename( + \ a:options.old_name, + \ a:options.new_name, + \) + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:filerename_map[l:request_id] = a:options +endfunction + +function! s:ExecuteFileRename(linter, options) abort + let l:buffer = bufnr('') + + let l:Callback = function('s:OnReady', [a:options]) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#filerename#Execute() abort + let l:buffer = bufnr('') + let l:lsp_linters = [] + + for l:linter in ale#lsp_linter#GetEnabled(l:buffer) + if l:linter.lsp is# 'tsserver' + call add(l:lsp_linters, l:linter) + endif + endfor + + if empty(l:lsp_linters) + call s:message('No active tsserver LSPs') + + return + endif + + let l:old_name = expand('#' . l:buffer . ':p') + let l:new_name = ale#util#Input('New file name: ', l:old_name, 'file') + + if l:old_name is# l:new_name + call s:message('New file name matches old file name') + + return + endif + + if empty(l:new_name) + call s:message('New name cannot be empty!') + + return + endif + + for l:lsp_linter in l:lsp_linters + call s:ExecuteFileRename(l:lsp_linter, { + \ 'old_name': l:old_name, + \ 'new_name': l:new_name, + \}) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/filetypes.vim b/sources_non_forked/ale/autoload/ale/filetypes.vim index 6cdc9ece..340a9c4e 100644 --- a/sources_non_forked/ale/autoload/ale/filetypes.vim +++ b/sources_non_forked/ale/autoload/ale/filetypes.vim @@ -4,9 +4,7 @@ function! ale#filetypes#LoadExtensionMap() abort " Output includes: " '*.erl setf erlang' - redir => l:output - silent exec 'autocmd' - redir end + let l:output = execute('exec "autocmd"') let l:map = {} diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim index 9987fbdd..786978d1 100644 --- a/sources_non_forked/ale/autoload/ale/fix.vim +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -1,57 +1,43 @@ -call ale#Set('fix_on_save_ignore', {}) +" Author: w0rp +" Description: Functions for fixing code with programs, or other means. + +let g:ale_fix_on_save_ignore = get(g:, 'ale_fix_on_save_ignore', {}) +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) " Apply fixes queued up for buffers which may be hidden. " Vim doesn't let you modify hidden buffers. function! ale#fix#ApplyQueuedFixes(buffer) abort let l:data = get(g:ale_fix_buffer_data, a:buffer, {'done': 0}) - let l:has_bufline_api = exists('*deletebufline') && exists('*setbufline') - if !l:data.done || (!l:has_bufline_api && a:buffer isnot bufnr('')) + if !l:data.done || (!ale#util#HasBuflineApi() && a:buffer isnot bufnr('')) return endif call remove(g:ale_fix_buffer_data, a:buffer) - if l:data.changes_made - " If the file is in DOS mode, we have to remove carriage returns from - " the ends of lines before calling setline(), or we will see them - " twice. - let l:new_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' - \ ? map(copy(l:data.output), 'substitute(v:val, ''\r\+$'', '''', '''')') - \ : l:data.output - let l:first_line_to_remove = len(l:new_lines) + 1 + try + if l:data.changes_made + let l:new_lines = ale#util#SetBufferContents(a:buffer, l:data.output) - " Use a Vim API for setting lines in other buffers, if available. - if l:has_bufline_api - call setbufline(a:buffer, 1, l:new_lines) - call deletebufline(a:buffer, l:first_line_to_remove, '$') - " Fall back on setting lines the old way, for the current buffer. - else - let l:old_line_length = len(l:data.lines_before) - - if l:old_line_length >= l:first_line_to_remove - let l:save = winsaveview() - silent execute - \ l:first_line_to_remove . ',' . l:old_line_length . 'd_' - call winrestview(l:save) - endif - - call setline(1, l:new_lines) - endif - - if l:data.should_save - if a:buffer is bufnr('') - if empty(&buftype) - noautocmd :w! + if l:data.should_save + if a:buffer is bufnr('') + if empty(&buftype) + noautocmd :w! + else + set nomodified + endif else - set nomodified + call writefile(l:new_lines, expand('#' . a:buffer . ':p')) " no-custom-checks + call setbufvar(a:buffer, '&modified', 0) endif - else - call writefile(l:new_lines, expand(a:buffer . ':p')) " no-custom-checks - call setbufvar(a:buffer, '&modified', 0) endif endif - endif + catch /E21\|E5555/ + " If we cannot modify the buffer now, try again later. + let g:ale_fix_buffer_data[a:buffer] = l:data + + return + endtry if l:data.should_save let l:should_lint = ale#Var(a:buffer, 'fix_on_save') @@ -74,7 +60,7 @@ endfunction function! ale#fix#ApplyFixes(buffer, output) abort let l:data = g:ale_fix_buffer_data[a:buffer] let l:data.output = a:output - let l:data.changes_made = l:data.lines_before != l:data.output + let l:data.changes_made = l:data.lines_before !=# l:data.output " no-custom-checks let l:data.done = 1 call ale#command#RemoveManagedFiles(a:buffer) @@ -89,7 +75,11 @@ function! ale#fix#ApplyFixes(buffer, output) abort if l:data.lines_before != l:lines call remove(g:ale_fix_buffer_data, a:buffer) - execute 'echoerr ''The file was changed before fixing finished''' + + if !l:data.ignore_file_changed_errors + " no-custom-checks + echoerr 'The file was changed before fixing finished' + endif return endif @@ -115,7 +105,6 @@ function! s:HandleExit(job_info, buffer, job_output, data) abort let l:output = a:job_output endif - let l:ChainCallback = get(a:job_info, 'chain_with', v:null) let l:ProcessWith = get(a:job_info, 'process_with', v:null) " Post-process the output with a function if we have one. @@ -127,27 +116,17 @@ function! s:HandleExit(job_info, buffer, job_output, data) abort " otherwise skip this job and use the input from before. " " We'll use the input from before for chained commands. - if l:ChainCallback is v:null && !empty(split(join(l:output))) + if !empty(split(join(l:output))) let l:input = l:output else let l:input = a:job_info.input endif - if l:ChainCallback isnot v:null && !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''chain_with is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - let l:next_index = l:ChainCallback is v:null - \ ? a:job_info.callback_index + 1 - \ : a:job_info.callback_index - call s:RunFixer({ \ 'buffer': a:buffer, \ 'input': l:input, - \ 'output': l:output, \ 'callback_list': a:job_info.callback_list, - \ 'callback_index': l:next_index, - \ 'chain_callback': l:ChainCallback, + \ 'callback_index': a:job_info.callback_index + 1, \}) endfunction @@ -160,6 +139,7 @@ function! s:RunJob(result, options) abort let l:buffer = a:options.buffer let l:input = a:options.input + let l:fixer_name = a:options.fixer_name if a:result is 0 || type(a:result) is v:t_list if type(a:result) is v:t_list @@ -177,27 +157,23 @@ function! s:RunJob(result, options) abort endif let l:command = get(a:result, 'command', '') - let l:ChainWith = get(a:result, 'chain_with', v:null) if empty(l:command) - " If the command is empty, skip to the next item, or call the - " chain_with function. + " If the command is empty, skip to the next item. call s:RunFixer({ \ 'buffer': l:buffer, \ 'input': l:input, - \ 'callback_index': a:options.callback_index + (l:ChainWith is v:null), + \ 'callback_index': a:options.callback_index, \ 'callback_list': a:options.callback_list, - \ 'chain_callback': l:ChainWith, - \ 'output': [], \}) return endif let l:read_temporary_file = get(a:result, 'read_temporary_file', 0) - " Default to piping the buffer for the last fixer in the chain. - let l:read_buffer = get(a:result, 'read_buffer', l:ChainWith is v:null) + let l:read_buffer = get(a:result, 'read_buffer', 1) let l:output_stream = get(a:result, 'output_stream', 'stdout') + let l:cwd = get(a:result, 'cwd', v:null) if l:read_temporary_file let l:output_stream = 'none' @@ -205,7 +181,6 @@ function! s:RunJob(result, options) abort let l:Callback = function('s:HandleExit', [{ \ 'input': l:input, - \ 'chain_with': l:ChainWith, \ 'callback_index': a:options.callback_index, \ 'callback_list': a:options.callback_list, \ 'process_with': get(a:result, 'process_with', v:null), @@ -217,6 +192,8 @@ function! s:RunJob(result, options) abort \ 'read_buffer': l:read_buffer, \ 'input': l:input, \ 'log_output': 0, + \ 'cwd': l:cwd, + \ 'filename_mappings': ale#GetFilenameMappings(l:buffer, l:fixer_name), \}) if empty(l:run_result) @@ -240,32 +217,22 @@ function! s:RunFixer(options) abort return endif - let l:ChainCallback = get(a:options, 'chain_callback', v:null) - - let l:Function = l:ChainCallback isnot v:null - \ ? ale#util#GetFunction(l:ChainCallback) - \ : a:options.callback_list[l:index] + let [l:fixer_name, l:Function] = a:options.callback_list[l:index] " Record new jobs started as fixer jobs. call setbufvar(l:buffer, 'ale_job_type', 'fixer') - if l:ChainCallback isnot v:null - " Chained commands accept (buffer, output, [input]) - let l:result = ale#util#FunctionArgCount(l:Function) == 2 - \ ? call(l:Function, [l:buffer, a:options.output]) - \ : call(l:Function, [l:buffer, a:options.output, copy(l:input)]) - else - " Regular fixer commands accept (buffer, [input]) - let l:result = ale#util#FunctionArgCount(l:Function) == 1 - \ ? call(l:Function, [l:buffer]) - \ : call(l:Function, [l:buffer, copy(l:input)]) - endif + " Regular fixer commands accept (buffer, [input]) + let l:result = ale#util#FunctionArgCount(l:Function) == 1 + \ ? call(l:Function, [l:buffer]) + \ : call(l:Function, [l:buffer, copy(l:input)]) call s:RunJob(l:result, { \ 'buffer': l:buffer, \ 'input': l:input, \ 'callback_list': a:options.callback_list, \ 'callback_index': l:index, + \ 'fixer_name': l:fixer_name, \}) endfunction @@ -333,16 +300,24 @@ function! s:GetCallbacks(buffer, fixing_flag, fixers) abort " Variables with capital characters are needed, or Vim will complain about " funcref variables. for l:Item in l:callback_list + " Try to capture the names of registered fixer names, so we can use + " them for filename mapping or other purposes later. + let l:fixer_name = v:null + if type(l:Item) is v:t_string let l:Func = ale#fix#registry#GetFunc(l:Item) if !empty(l:Func) + let l:fixer_name = l:Item let l:Item = l:Func endif endif try - call add(l:corrected_list, ale#util#GetFunction(l:Item)) + call add(l:corrected_list, [ + \ l:fixer_name, + \ ale#util#GetFunction(l:Item) + \]) catch /E475/ " Rethrow exceptions for failing to get a function so we can print " a friendly message about it. @@ -360,6 +335,7 @@ function! ale#fix#InitBufferData(buffer, fixing_flag) abort \ 'lines_before': getbufline(a:buffer, 1, '$'), \ 'done': 0, \ 'should_save': a:fixing_flag is# 'save_file', + \ 'ignore_file_changed_errors': a:fixing_flag is# '!', \ 'temporary_directory_list': [], \} endfunction @@ -368,26 +344,32 @@ endfunction " " Returns 0 if no fixes can be applied, and 1 if fixing can be done. function! ale#fix#Fix(buffer, fixing_flag, ...) abort - if a:fixing_flag isnot# '' && a:fixing_flag isnot# 'save_file' - throw "fixing_flag must be either '' or 'save_file'" + if a:fixing_flag isnot# '' + \&& a:fixing_flag isnot# '!' + \&& a:fixing_flag isnot# 'save_file' + throw "fixing_flag must be '', '!', or 'save_file'" endif try let l:callback_list = s:GetCallbacks(a:buffer, a:fixing_flag, a:000) catch /E700\|BADNAME/ - let l:function_name = join(split(split(v:exception, ':')[3])) - let l:echo_message = printf( - \ 'There is no fixer named `%s`. Check :ALEFixSuggest', - \ l:function_name, - \) - execute 'echom l:echo_message' + if a:fixing_flag isnot# '!' + let l:function_name = join(split(split(v:exception, ':')[3])) + let l:echo_message = printf( + \ 'There is no fixer named `%s`. Check :ALEFixSuggest', + \ l:function_name, + \) + " no-custom-checks + echom l:echo_message + endif return 0 endtry if empty(l:callback_list) if a:fixing_flag is# '' - execute 'echom ''No fixers have been defined. Try :ALEFixSuggest''' + " no-custom-checks + echom 'No fixers have been defined. Try :ALEFixSuggest' endif return 0 @@ -414,3 +396,4 @@ endfunction augroup ALEBufferFixGroup autocmd! autocmd BufEnter * call ale#fix#ApplyQueuedFixes(str2nr(expand(''))) +augroup END diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index 7a553ccc..efa1fe75 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -7,11 +7,31 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Add blank lines before control statements.', \ }, +\ 'alejandra': { +\ 'function': 'ale#fixers#alejandra#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'The Uncompromising Nix Code Formatter', +\ }, \ 'align_help_tags': { \ 'function': 'ale#fixers#help#AlignTags', \ 'suggested_filetypes': ['help'], \ 'description': 'Align help tags to the right margin', \ }, +\ 'apkbuild-fixer': { +\ 'function': 'ale#fixers#apkbuild_fixer#Fix', +\ 'suggested_filetypes': ['apkbuild'], +\ 'description': 'Fix policy violations found by apkbuild-lint in APKBUILDs', +\ }, +\ 'autoimport': { +\ 'function': 'ale#fixers#autoimport#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix import issues with autoimport.', +\ }, +\ 'autoflake': { +\ 'function': 'ale#fixers#autoflake#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix flake issues with autoflake.', +\ }, \ 'autopep8': { \ 'function': 'ale#fixers#autopep8#Fix', \ 'suggested_filetypes': ['python'], @@ -22,16 +42,98 @@ 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', 'css', 'graphql'], +\ 'description': 'Fix JavaScript and TypeScript using biome.', +\ }, \ 'black': { \ 'function': 'ale#fixers#black#Fix', \ 'suggested_filetypes': ['python'], \ 'description': 'Fix PEP8 issues with black.', \ }, +\ 'buf-format': { +\ 'function': 'ale#fixers#buf_format#Fix', +\ 'suggested_filetypes': ['proto'], +\ 'description': 'Fix .proto files with buf format.', +\ }, +\ 'buildifier': { +\ 'function': 'ale#fixers#buildifier#Fix', +\ 'suggested_filetypes': ['bzl'], +\ 'description': 'Format BUILD and .bzl files with buildifier.', +\ }, +\ 'css-beautify': { +\ 'function': 'ale#fixers#css_beautify#Fix', +\ 'suggested_filetypes': ['css'], +\ 'description': 'Format CSS using css-beautify from js-beautify.', +\ }, +\ 'deno': { +\ 'function': 'ale#fixers#deno#Fix', +\ 'suggested_filetypes': ['typescript'], +\ 'description': 'Fix TypeScript using deno fmt.', +\ }, +\ 'dfmt': { +\ 'function': 'ale#fixers#dfmt#Fix', +\ 'suggested_filetypes': ['d'], +\ 'description': 'Fix D files with dfmt.', +\ }, +\ 'dhall': { +\ 'function': 'ale#fixers#dhall#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Fix Dhall files with dhall-format.', +\ }, +\ 'dhall-format': { +\ 'function': 'ale#fixers#dhall_format#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Standard code formatter for the Dhall language', +\ 'aliases': ['dhall'], +\ }, +\ 'dhall-freeze': { +\ 'function': 'ale#fixers#dhall_freeze#Freeze', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Add integrity checks to remote import statements of an expression for the Dhall language', +\ }, +\ 'dhall-lint': { +\ 'function': 'ale#fixers#dhall_lint#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Standard code formatter for the Dhall language and removing dead code', +\ }, +\ 'djlint': { +\ 'function': 'ale#fixers#djlint#Fix', +\ 'suggested_filetypes': ['html', 'htmldjango', 'htmlangular', 'jinja', 'handlebars', 'nunjucks', 'gohtmltmpl'], +\ 'description': 'Fix HTML templates with `djlint --reformat`.', +\ }, +\ 'dune': { +\ 'function': 'ale#fixers#dune#Fix', +\ 'suggested_filetypes': ['dune'], +\ 'description': 'Fix dune files with dune format', +\ }, +\ 'erlang_mode': { +\ 'function': 'ale#fixers#erlang_mode#Fix', +\ 'suggested_filetypes': ['erlang'], +\ 'description': 'Indent with the Erlang mode for Emacs', +\ 'aliases': ['erlang-mode'], +\ }, +\ 'erlfmt': { +\ 'function': 'ale#fixers#erlfmt#Fix', +\ 'suggested_filetypes': ['erlang'], +\ 'description': 'Format Erlang code with erlfmt', +\ }, \ 'fecs': { \ 'function': 'ale#fixers#fecs#Fix', \ '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.', +\ }, +\ 'kulala_fmt': { +\ 'function': 'ale#fixers#kulala_fmt#Fix', +\ 'suggested_filetypes': ['http', 'rest'], +\ 'description': 'Fix http and rest files with kulala_fmt.', +\ }, \ 'tidy': { \ 'function': 'ale#fixers#tidy#Fix', \ 'suggested_filetypes': ['html'], @@ -49,9 +151,19 @@ let s:default_registry = { \ 'description': 'Apply elm-format to a file.', \ 'aliases': ['format'], \ }, +\ 'nimpretty': { +\ 'function': 'ale#fixers#nimpretty#Fix', +\ 'suggested_filetypes': ['nim'], +\ 'description': 'Apply nimpretty to a file.', +\ }, +\ 'erblint': { +\ 'function': 'ale#fixers#erblint#Fix', +\ 'suggested_filetypes': ['eruby'], +\ 'description': 'Apply erblint --autocorrect to a file.', +\ }, \ 'eslint': { \ 'function': 'ale#fixers#eslint#Fix', -\ 'suggested_filetypes': ['javascript', 'typescript'], +\ 'suggested_filetypes': ['javascript', 'typescript', 'astro'], \ 'description': 'Apply eslint --fix to a file.', \ }, \ 'mix_format': { @@ -66,7 +178,7 @@ let s:default_registry = { \ }, \ 'prettier': { \ 'function': 'ale#fixers#prettier#Fix', -\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml'], +\ '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': { @@ -75,6 +187,11 @@ let s:default_registry = { \ 'description': 'Apply prettier-eslint to a file.', \ 'aliases': ['prettier-eslint'], \ }, +\ 'pyflyby': { +\ 'function': 'ale#fixers#pyflyby#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Tidy Python imports with pyflyby.', +\ }, \ 'importjs': { \ 'function': 'ale#fixers#importjs#Fix', \ 'suggested_filetypes': ['javascript'], @@ -95,11 +212,26 @@ let s:default_registry = { \ 'suggested_filetypes': [], \ 'description': 'Remove all trailing whitespace characters at the end of every line.', \ }, +\ 'yamlfix': { +\ 'function': 'ale#fixers#yamlfix#Fix', +\ 'suggested_filetypes': ['yaml'], +\ 'description': 'Fix YAML files with yamlfix.', +\ }, +\ 'yamlfmt': { +\ 'function': 'ale#fixers#yamlfmt#Fix', +\ 'suggested_filetypes': ['yaml'], +\ 'description': 'Format YAML files with yamlfmt.', +\ }, \ 'yapf': { \ 'function': 'ale#fixers#yapf#Fix', \ 'suggested_filetypes': ['python'], \ 'description': 'Fix Python files with yapf.', \ }, +\ 'yq': { +\ 'function': 'ale#fixers#yq#Fix', +\ 'suggested_filetypes': ['yaml'], +\ 'description': 'Fix YAML files with yq.', +\ }, \ 'rubocop': { \ 'function': 'ale#fixers#rubocop#Fix', \ 'suggested_filetypes': ['ruby'], @@ -112,7 +244,7 @@ let s:default_registry = { \ }, \ 'scalafmt': { \ 'function': 'ale#fixers#scalafmt#Fix', -\ 'suggested_filetypes': ['scala'], +\ 'suggested_filetypes': ['sbt', 'scala'], \ 'description': 'Fix Scala files using scalafmt', \ }, \ 'sorbet': { @@ -130,6 +262,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['ruby'], \ 'description': 'Fix ruby files with standardrb --fix', \ }, +\ 'statix': { +\ 'function': 'ale#fixers#statix#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'Fix common Nix antipatterns with statix fix', +\ }, \ 'stylelint': { \ 'function': 'ale#fixers#stylelint#Fix', \ 'suggested_filetypes': ['css', 'sass', 'scss', 'sugarss', 'stylus'], @@ -140,6 +277,16 @@ let s:default_registry = { \ 'suggested_filetypes': ['swift'], \ 'description': 'Apply SwiftFormat to a file.', \ }, +\ 'syntax_tree': { +\ 'function': 'ale#fixers#syntax_tree#Fix', +\ 'suggested_filetypes': ['ruby'], +\ 'description': 'Fix ruby files with stree write', +\ }, +\ 'apple-swift-format': { +\ 'function': 'ale#fixers#appleswiftformat#Fix', +\ 'suggested_filetypes': ['swift'], +\ 'description': 'Apply apple/swift-format to a file.', +\ }, \ 'phpcbf': { \ 'function': 'ale#fixers#phpcbf#Fix', \ 'suggested_filetypes': ['php'], @@ -150,6 +297,16 @@ let s:default_registry = { \ 'suggested_filetypes': ['php'], \ 'description': 'Fix PHP files with php-cs-fixer.', \ }, +\ 'pint': { +\ 'function': 'ale#fixers#pint#Fix', +\ 'suggested_filetypes': ['php'], +\ 'description': 'Fix PHP files with Laravel Pint.', +\ }, +\ 'astyle': { +\ 'function': 'ale#fixers#astyle#Fix', +\ 'suggested_filetypes': ['c', 'cpp'], +\ 'description': 'Fix C/C++ with astyle.', +\ }, \ 'clangtidy': { \ 'function': 'ale#fixers#clangtidy#Fix', \ 'suggested_filetypes': ['c', 'cpp', 'objc'], @@ -157,29 +314,64 @@ let s:default_registry = { \ }, \ 'clang-format': { \ 'function': 'ale#fixers#clangformat#Fix', -\ 'suggested_filetypes': ['c', 'cpp', 'cuda'], -\ 'description': 'Fix C/C++ and cuda files with clang-format.', +\ 'suggested_filetypes': ['c', 'cpp', 'cs', 'cuda', 'java', 'javascript', 'json', 'objc', 'proto'], +\ 'description': 'Fix C, C++, C#, CUDA, Java, JavaScript, JSON, ObjectiveC and Protobuf files with clang-format.', \ }, \ 'cmakeformat': { \ 'function': 'ale#fixers#cmakeformat#Fix', \ 'suggested_filetypes': ['cmake'], \ 'description': 'Fix CMake files with cmake-format.', \ }, +\ 'fish_indent': { +\ 'function': 'ale#fixers#fish_indent#Fix', +\ 'suggested_filetypes': ['fish'], +\ 'description': 'Format fish scripts using fish_indent.', +\ }, +\ 'forge': { +\ 'function': 'ale#fixers#forge#Fix', +\ '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'], \ 'description': 'Fix Go files with go fmt.', \ }, +\ 'gofumpt': { +\ 'function': 'ale#fixers#gofumpt#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go files with gofumpt, a stricter go fmt.', +\ }, \ 'goimports': { \ 'function': 'ale#fixers#goimports#Fix', \ 'suggested_filetypes': ['go'], \ 'description': 'Fix Go files imports with goimports.', \ }, +\ 'golangci_lint': { +\ 'function': 'ale#fixers#golangci_lint#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go files with golangci-lint.', +\ }, +\ 'golines': { +\ 'function': 'ale#fixers#golines#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go file long lines with golines', +\ }, \ 'gomod': { \ 'function': 'ale#fixers#gomod#Fix', \ 'suggested_filetypes': ['gomod'], \ 'description': 'Fix Go module files with go mod edit -fmt.', \ }, +\ 'gopls': { +\ 'function': 'ale#fixers#gopls#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go files with gopls.', +\ }, \ 'tslint': { \ 'function': 'ale#fixers#tslint#Fix', \ 'suggested_filetypes': ['typescript'], @@ -230,14 +422,24 @@ let s:default_registry = { \ 'suggested_filetypes': ['haskell'], \ 'description': 'Refactor Haskell files with stylish-haskell.', \ }, +\ 'purs-tidy': { +\ 'function': 'ale#fixers#purs_tidy#Fix', +\ 'suggested_filetypes': ['purescript'], +\ 'description': 'Format PureScript files with purs-tidy.', +\ }, +\ 'purty': { +\ 'function': 'ale#fixers#purty#Fix', +\ 'suggested_filetypes': ['purescript'], +\ 'description': 'Format PureScript files with purty.', +\ }, \ 'ocamlformat': { \ 'function': 'ale#fixers#ocamlformat#Fix', -\ 'suggested_filetypes': ['ocaml'], +\ 'suggested_filetypes': ['ocaml', 'ocamlinterface'], \ 'description': 'Fix OCaml files with ocamlformat.', \ }, \ 'ocp-indent': { \ 'function': 'ale#fixers#ocp_indent#Fix', -\ 'suggested_filetypes': ['ocaml'], +\ 'suggested_filetypes': ['ocaml', 'ocamlinterface'], \ 'description': 'Fix OCaml files with ocp-indent.', \ }, \ 'refmt': { @@ -245,16 +447,31 @@ let s:default_registry = { \ 'suggested_filetypes': ['reason'], \ 'description': 'Fix ReasonML files with refmt.', \ }, +\ 'pandoc': { +\ 'function': 'ale#fixers#pandoc#Fix', +\ 'suggested_filetypes': ['markdown'], +\ 'description': 'Fix markdown files with pandoc.', +\ }, \ 'shfmt': { \ 'function': 'ale#fixers#shfmt#Fix', \ 'suggested_filetypes': ['sh'], \ 'description': 'Fix sh files with shfmt.', \ }, +\ 'sqlfluff': { +\ 'function': 'ale#fixers#sqlfluff#Fix', +\ 'suggested_filetypes': ['sql'], +\ 'description': 'Fix SQL files with sqlfluff.', +\ }, \ 'sqlfmt': { \ 'function': 'ale#fixers#sqlfmt#Fix', \ 'suggested_filetypes': ['sql'], \ 'description': 'Fix SQL files with sqlfmt.', \ }, +\ 'sqlformat': { +\ 'function': 'ale#fixers#sqlformat#Fix', +\ 'suggested_filetypes': ['sql'], +\ 'description': 'Fix SQL files with sqlformat.', +\ }, \ 'google_java_format': { \ 'function': 'ale#fixers#google_java_format#Fix', \ 'suggested_filetypes': ['java'], @@ -270,6 +487,16 @@ let s:default_registry = { \ 'suggested_filetypes': ['json'], \ 'description': 'Fix JSON files with jq.', \ }, +\ 'json_pytool': { +\ 'function': 'ale#fixers#json_pytool#Fix', +\ 'suggested_filetypes': ['json'], +\ 'description': "Fix JSON files with python's built-in json.tool module.", +\ }, +\ 'protolint': { +\ 'function': 'ale#fixers#protolint#Fix', +\ 'suggested_filetypes': ['proto'], +\ 'description': 'Fix Protocol Buffer files with protolint.', +\ }, \ 'perltidy': { \ 'function': 'ale#fixers#perltidy#Fix', \ 'suggested_filetypes': ['perl'], @@ -290,6 +517,16 @@ let s:default_registry = { \ 'suggested_filetypes': ['dart'], \ 'description': 'Fix Dart files with dartfmt.', \ }, +\ 'dart-format': { +\ 'function': 'ale#fixers#dart_format#Fix', +\ 'suggested_filetypes': ['dart'], +\ 'description': 'Fix Dart files with dart format.', +\ }, +\ 'dotnet-format': { +\ 'function': 'ale#fixers#dotnet_format#Fix', +\ 'suggested_filetypes': ['cs'], +\ 'description': 'Fix C# files with dotnet format.', +\ }, \ 'xmllint': { \ 'function': 'ale#fixers#xmllint#Fix', \ 'suggested_filetypes': ['xml'], @@ -305,14 +542,24 @@ let s:default_registry = { \ 'suggested_filetypes': ['hcl', 'terraform'], \ 'description': 'Fix tf and hcl files with terraform fmt.', \ }, +\ 'packer': { +\ 'function': 'ale#fixers#packer#Fix', +\ 'suggested_filetypes': ['hcl', 'packer'], +\ 'description': 'Fix Packer HCL files with packer fmt.', +\ }, +\ 'crystal': { +\ 'function': 'ale#fixers#crystal#Fix', +\ 'suggested_filetypes': ['cr'], +\ 'description': 'Fix cr (crystal).', +\ }, \ 'ktlint': { \ 'function': 'ale#fixers#ktlint#Fix', -\ 'suggested_filetypes': ['kt'], +\ 'suggested_filetypes': ['kt', 'kotlin'], \ 'description': 'Fix Kotlin files with ktlint.', \ }, \ 'styler': { \ 'function': 'ale#fixers#styler#Fix', -\ 'suggested_filetypes': ['r', 'rmarkdown'], +\ 'suggested_filetypes': ['r', 'rmarkdown', 'rmd'], \ 'description': 'Fix R files with styler.', \ }, \ 'latexindent': { @@ -335,6 +582,146 @@ let s:default_registry = { \ 'suggested_filetypes': ['ada'], \ 'description': 'Format Ada files with gnatpp.', \ }, +\ 'nixfmt': { +\ 'function': 'ale#fixers#nixfmt#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'A nix formatter written in Haskell.', +\ }, +\ 'nixpkgs-fmt': { +\ 'function': 'ale#fixers#nixpkgsfmt#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'A formatter for Nix code', +\ }, +\ 'remark-lint': { +\ 'function': 'ale#fixers#remark_lint#Fix', +\ 'suggested_filetypes': ['markdown'], +\ 'description': 'Fix markdown files with remark-lint', +\ }, +\ 'html-beautify': { +\ 'function': 'ale#fixers#html_beautify#Fix', +\ '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'], +\ 'description': 'Fix Lua files with lua-format.', +\ }, +\ 'luafmt': { +\ 'function': 'ale#fixers#luafmt#Fix', +\ 'suggested_filetypes': ['lua'], +\ 'description': 'Fix Lua files with luafmt.', +\ }, +\ 'dprint': { +\ 'function': 'ale#fixers#dprint#Fix', +\ 'suggested_filetypes': ['dockerfile', 'javascript', 'json', 'markdown', 'toml', 'typescript'], +\ 'description': 'Pluggable and configurable code formatting platform', +\ }, +\ 'stylua': { +\ 'function': 'ale#fixers#stylua#Fix', +\ 'suggested_filetypes': ['lua'], +\ 'description': 'Fix Lua files with stylua.', +\ }, +\ 'ormolu': { +\ 'function': 'ale#fixers#ormolu#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'A formatter for Haskell source code.', +\ }, +\ 'fourmolu': { +\ 'function': 'ale#fixers#fourmolu#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'A formatter for Haskell source code.', +\ }, +\ 'jsonnetfmt': { +\ 'function': 'ale#fixers#jsonnetfmt#Fix', +\ 'suggested_filetypes': ['jsonnet'], +\ 'description': 'Fix jsonnet files with jsonnetfmt', +\ }, +\ 'ptop': { +\ 'function': 'ale#fixers#ptop#Fix', +\ 'suggested_filetypes': ['pascal'], +\ 'description': 'Fix Pascal files with ptop.', +\ }, +\ 'opafmt': { +\ 'function': 'ale#fixers#opafmt#Fix', +\ 'suggested_filetypes': ['rego'], +\ 'description': 'Fix rego files with opa fmt.', +\ }, +\ 'vfmt': { +\ 'function': 'ale#fixers#vfmt#Fix', +\ 'suggested_filetypes': ['v'], +\ 'description': 'A formatter for V source code.', +\ }, +\ 'zigfmt': { +\ 'function': 'ale#fixers#zigfmt#Fix', +\ 'suggested_filetypes': ['zig'], +\ 'description': 'Official formatter for Zig', +\ }, +\ 'raco_fmt': { +\ 'function': 'ale#fixers#raco_fmt#Fix', +\ 'suggested_filetypes': ['racket'], +\ 'description': 'Fix Racket files with raco fmt.', +\ }, +\ 'ruff': { +\ 'function': 'ale#fixers#ruff#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix python files with ruff.', +\ }, +\ 'ruff_format': { +\ 'function': 'ale#fixers#ruff_format#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix python files with the ruff formatter.', +\ }, +\ 'pycln': { +\ 'function': 'ale#fixers#pycln#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'remove unused python import statements', +\ }, +\ 'rustywind': { +\ 'function': 'ale#fixers#rustywind#Fix', +\ 'suggested_filetypes': ['html'], +\ 'description': 'Sort Tailwind CSS classes', +\ }, +\ 'npm-groovy-lint': { +\ 'function': 'ale#fixers#npmgroovylint#Fix', +\ 'suggested_filetypes': ['groovy'], +\ 'description': 'Fix Groovy files with npm-groovy-fix.', +\ }, +\ 'erb-formatter': { +\ 'function': 'ale#fixers#erbformatter#Fix', +\ 'suggested_filetypes': ['eruby'], +\ 'description': 'Apply erb-formatter -w to eruby/erb files.', +\ }, +\ 'nickel_format': { +\ 'function': 'ale#fixers#nickel_format#Fix', +\ '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', +\ }, +\ 'scadformat': { +\ 'function': 'ale#fixers#scadformat#Fix', +\ 'suggested_filetypes': ['openscad'], +\ 'description': 'Formatter for scad files', +\ }, +\ 'cljfmt': { +\ 'function': 'ale#fixers#cljfmt#Fix', +\ 'suggested_filetypes': ['clojure'], +\ 'description': 'formatter and linter for clojure files', +\ }, +\ 'typstyle': { +\ 'function': 'ale#fixers#typstyle#Fix', +\ 'suggested_filetypes': ['typst'], +\ 'description': 'A formatter for Typst files', +\ }, \} " Reset the function registry to the default entries. diff --git a/sources_non_forked/ale/autoload/ale/fixers/alejandra.vim b/sources_non_forked/ale/autoload/ale/fixers/alejandra.vim new file mode 100644 index 00000000..3844e8c0 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/alejandra.vim @@ -0,0 +1,13 @@ +call ale#Set('nix_alejandra_executable', 'alejandra') +call ale#Set('nix_alejandra_options', '') + +function! ale#fixers#alejandra#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_alejandra_executable') + let l:options = ale#Var(a:buffer, 'nix_alejandra_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' -- -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/apkbuild_fixer.vim b/sources_non_forked/ale/autoload/ale/fixers/apkbuild_fixer.vim new file mode 100644 index 00000000..b297fc61 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/apkbuild_fixer.vim @@ -0,0 +1,19 @@ +" Author: Leo +" Description: Fix policy violations found by apkbuild-lint + +call ale#Set('apkbuild_apkbuild_fixer_executable', 'apkbuild-fixer') +call ale#Set('apkbuild_apkbuild_fixer_lint_executable', get(g:, 'ale_apkbuild_apkbuild_lint_executable')) +call ale#Set('apkbuild_apkbuild_fixer_options', '') + +function! ale#fixers#apkbuild_fixer#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'apkbuild_apkbuild_fixer_executable') + let l:options = ale#Var(a:buffer, 'apkbuild_apkbuild_fixer_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -p ' . ale#Var(a:buffer, 'apkbuild_apkbuild_fixer_lint_executable') + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim b/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim new file mode 100644 index 00000000..ca27e82c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim @@ -0,0 +1,16 @@ +" Author: (bosr) +" Description: Integration of apple/swift-format formatter with ALE. + +function! ale#fixers#appleswiftformat#Fix(buffer) abort + let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' format --in-place %t' + let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer) + + if l:config_args isnot# '' + let l:command_args = l:command_args . ' ' . l:config_args + endif + + return { + \ 'read_temporary_file': 1, + \ 'command': l:command_args, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/astyle.vim b/sources_non_forked/ale/autoload/ale/fixers/astyle.vim new file mode 100644 index 00000000..3a5a70a1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/astyle.vim @@ -0,0 +1,59 @@ +" Author: James Kim +" Description: Fix C/C++ files with astyle. + +function! s:set_variables() abort + for l:ft in ['c', 'cpp'] + call ale#Set(l:ft . '_astyle_executable', 'astyle') + call ale#Set(l:ft . '_astyle_project_options', '') + endfor +endfunction + +call s:set_variables() + + +function! ale#fixers#astyle#Var(buffer, name) abort + let l:ft = getbufvar(str2nr(a:buffer), '&filetype') + let l:ft = l:ft =~# 'cpp' ? 'cpp' : 'c' + + return ale#Var(a:buffer, l:ft . '_astyle_' . a:name) +endfunction + +" Try to find a project options file. +function! ale#fixers#astyle#FindProjectOptions(buffer) abort + let l:proj_options = ale#fixers#astyle#Var(a:buffer, 'project_options') + + " If user has set project options variable then use it and skip any searching. + " This would allow users to use project files named differently than .astylerc. + if !empty(l:proj_options) + return l:proj_options + endif + + " Try to find nearest .astylerc file. + let l:proj_options = fnamemodify(ale#path#FindNearestFile(a:buffer, '.astylerc'), ':t') + + if !empty(l:proj_options) + return l:proj_options + endif + + " Try to find nearest _astylerc file. + let l:proj_options = fnamemodify(ale#path#FindNearestFile(a:buffer, '_astylerc'), ':t') + + if !empty(l:proj_options) + return l:proj_options + endif + + " If no project options file is found return an empty string. + return '' +endfunction + +function! ale#fixers#astyle#Fix(buffer) abort + let l:executable = ale#fixers#astyle#Var(a:buffer, 'executable') + let l:proj_options = ale#fixers#astyle#FindProjectOptions(a:buffer) + let l:command = ' --stdin=' . ale#Escape(expand('#' . a:buffer)) + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:proj_options) ? '' : ' --project=' . l:proj_options) + \ . l:command + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim b/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim new file mode 100644 index 00000000..9f8b04fc --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim @@ -0,0 +1,46 @@ +" Author: circld +" Description: Fixing files with autoflake. + +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#fixers#autoflake#GetExecutable(a:buffer) + + 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) . l:exec_args + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --in-place ' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim new file mode 100644 index 00000000..8d35419e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim @@ -0,0 +1,45 @@ +" Author: lyz-code +" Description: Fixing Python imports with autoimport. + +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') + + return { + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) . l:exec_args + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim b/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim index 5798d827..f9af46f8 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 new file mode 100644 index 00000000..63c0fdbc --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/biome.vim @@ -0,0 +1,12 @@ +function! ale#fixers#biome#Fix(buffer) abort + let l:executable = ale#handlers#biome#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'biome_options') + let l:apply = ale#Var(a:buffer, 'biome_fixer_apply_unsafe') ? '--apply-unsafe' : '--apply' + + return { + \ '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 fba6c3b4..6f263f13 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/black.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/black.vim @@ -5,6 +5,8 @@ call ale#Set('python_black_executable', 'black') 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 @@ -13,29 +15,47 @@ function! ale#fixers#black#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_black_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 function! ale#fixers#black#Fix(buffer) abort - let l:cd_string = ale#Var(a:buffer, 'python_black_change_directory') - \ ? ale#path#BufferCdString(a:buffer) - \ : '' - let l:executable = ale#fixers#black#GetExecutable(a:buffer) + let l:cmd = [ale#Escape(l:executable)] - let l:exec_args = l:executable =~? 'pipenv$' - \ ? ' run black' - \ : '' + if l:executable =~? '\(pipenv\|poetry\|uv\)$' + call extend(l:cmd, ['run', 'black']) + endif let l:options = ale#Var(a:buffer, 'python_black_options') - if expand('#' . a:buffer . ':e') is? 'pyi' - let l:options .= '--pyi' + if !empty(l:options) + call add(l:cmd, l:options) endif - return { - \ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' -', - \} + let l:fname = expand('#' . a:buffer . '...') + call add(l:cmd, '--stdin-filename '.ale#Escape(ale#path#Simplify(l:fname))) + + if expand('#' . a:buffer . ':e') is? 'pyi' + call add(l:cmd, '--pyi') + endif + + call add(l:cmd, '-') + + let l:result = {'command': join(l:cmd, ' ')} + + if ale#Var(a:buffer, 'python_black_change_directory') + let l:result.cwd = '%s:h' + endif + + return l:result endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/buf_format.vim b/sources_non_forked/ale/autoload/ale/fixers/buf_format.vim new file mode 100644 index 00000000..c2c156b7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/buf_format.vim @@ -0,0 +1,12 @@ +" Author: Alex McKinney +" Description: Run buf format. + +call ale#Set('proto_buf_format_executable', 'buf') + +function! ale#fixers#buf_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'proto_buf_format_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' format %t', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim b/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim new file mode 100644 index 00000000..48103b2e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim @@ -0,0 +1,26 @@ +" Author: Jon Parise +" Description: Format Bazel BUILD and .bzl files with buildifier. +" +call ale#Set('bazel_buildifier_executable', 'buildifier') +call ale#Set('bazel_buildifier_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('bazel_buildifier_options', '') + +function! ale#fixers#buildifier#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'bazel_buildifier', [ + \ 'buildifier', + \]) +endfunction + +function! ale#fixers#buildifier#Fix(buffer) abort + let l:executable = ale#Escape(ale#fixers#buildifier#GetExecutable(a:buffer)) + let l:options = ale#Var(a:buffer, 'bazel_buildifier_options') + let l:filename = ale#Escape(bufname(a:buffer)) + + let l:command = l:executable . ' -mode fix -lint fix -path ' . l:filename + + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return {'command': l:command . ' -'} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim b/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim index ea5743a5..81498ebd 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim @@ -5,9 +5,11 @@ scriptencoding utf-8 call ale#Set('c_clangformat_executable', 'clang-format') call ale#Set('c_clangformat_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('c_clangformat_options', '') +call ale#Set('c_clangformat_style_option', '') +call ale#Set('c_clangformat_use_local_file', 0) function! ale#fixers#clangformat#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'c_clangformat', [ + return ale#path#FindExecutable(a:buffer, 'c_clangformat', [ \ 'clang-format', \]) endfunction @@ -16,6 +18,24 @@ function! ale#fixers#clangformat#Fix(buffer) abort let l:executable = ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer)) let l:filename = ale#Escape(bufname(a:buffer)) let l:options = ale#Var(a:buffer, 'c_clangformat_options') + let l:style_option = ale#Var(a:buffer, 'c_clangformat_style_option') + let l:use_local_file = ale#Var(a:buffer, 'c_clangformat_use_local_file') + + if l:style_option isnot# '' + let l:style_option = '-style=' . "'" . l:style_option . "'" + endif + + if l:use_local_file + let l:config = ale#path#FindNearestFile(a:buffer, '.clang-format') + + if !empty(l:config) + let l:style_option = '-style=file' + endif + endif + + if l:style_option isnot# '' + let l:options .= ' ' . l:style_option + endif let l:command = l:executable . ' --assume-filename=' . l:filename diff --git a/sources_non_forked/ale/autoload/ale/fixers/cljfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/cljfmt.vim new file mode 100644 index 00000000..dbcf10d8 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/cljfmt.vim @@ -0,0 +1,14 @@ +" Author: rudolf ordoyne +" Description: Support for cljfmt https://github.com/weavejester/cljfmt + +call ale#Set('clojure_cljfmt_executable', 'cljfmt') + +function! ale#fixers#cljfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'clojure_cljfmt_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' fix %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim b/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim index f40ed6ed..dcc29cf3 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim @@ -10,9 +10,7 @@ function! ale#fixers#cmakeformat#Fix(buffer) abort return { \ 'command': ale#Escape(l:executable) - \ . ' -i ' \ . (empty(l:options) ? '' : ' ' . l:options) - \ . ' %t', - \ 'read_temporary_file': 1, + \ . ' -' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/crystal.vim b/sources_non_forked/ale/autoload/ale/fixers/crystal.vim new file mode 100644 index 00000000..4ba702ba --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/crystal.vim @@ -0,0 +1,14 @@ +call ale#Set('crystal_format_executable', 'crystal') +call ale#Set('crystal_format_options', '') + +function! ale#fixers#crystal#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'crystal_format_executable') + let l:options = ale#Var(a:buffer, 'crystal_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' tool format' + \ . ale#Pad(l:options) + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/css_beautify.vim b/sources_non_forked/ale/autoload/ale/fixers/css_beautify.vim new file mode 100644 index 00000000..14a837c4 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/css_beautify.vim @@ -0,0 +1,20 @@ +" Author: https://github.com/Spixmaster +" Description: Format CSS using css-beautify from js-beautify. + +call ale#Set('css_css_beautify_executable', 'css-beautify') +call ale#Set('css_css_beautify_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('css_css_beautify_options', '') + +function! ale#fixers#css_beautify#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'css_css_beautify', + \ ['css-beautify'] + \) + + let l:options = ale#Var(a:buffer, 'css_css_beautify_options') + + return { + \ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim b/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim new file mode 100644 index 00000000..4b8f730b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim @@ -0,0 +1,18 @@ +" Author: ghsang +" Description: Integration of dart format with ALE. + +call ale#Set('dart_format_executable', 'dart') +call ale#Set('dart_format_options', '') + +function! ale#fixers#dart_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'dart_format_executable') + let l:options = ale#Var(a:buffer, 'dart_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/deno.vim b/sources_non_forked/ale/autoload/ale/fixers/deno.vim new file mode 100644 index 00000000..7154c6ee --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/deno.vim @@ -0,0 +1,17 @@ +function! ale#fixers#deno#Fix(buffer) abort + let l:executable = ale#handlers#deno#GetExecutable(a:buffer) + + if !executable(l:executable) + return 0 + endif + + let l:options = ' fmt -' + + if ale#Var(a:buffer, 'deno_unstable') + let l:options = l:options . ' --unstable' + endif + + return { + \ 'command': ale#Escape(l:executable) . l:options + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim new file mode 100644 index 00000000..0072e045 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim @@ -0,0 +1,18 @@ +" Author: theoldmoon0602 +" Description: Integration of dfmt with ALE. + +call ale#Set('d_dfmt_executable', 'dfmt') +call ale#Set('d_dfmt_options', '') + +function! ale#fixers#dfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'd_dfmt_executable') + let l:options = ale#Var(a:buffer, 'd_dfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -i' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim new file mode 100644 index 00000000..4f12abc8 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim @@ -0,0 +1,11 @@ +" Author: toastal +" Description: Dhall’s built-in formatter +" +function! ale#fixers#dhall_format#Fix(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + + return { + \ 'command': l:executable + \ . ' format' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim new file mode 100644 index 00000000..ff54482d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim @@ -0,0 +1,14 @@ +" Author: toastal +" Description: Dhall’s package freezing + +call ale#Set('dhall_freeze_options', '') + +function! ale#fixers#dhall_freeze#Freeze(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + + return { + \ 'command': l:executable + \ . ' freeze' + \ . ale#Pad(ale#Var(a:buffer, 'dhall_freeze_options')) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim new file mode 100644 index 00000000..149a6581 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim @@ -0,0 +1,11 @@ +" Author: toastal +" Description: Dhall’s built-in linter/formatter + +function! ale#fixers#dhall_lint#Fix(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + + return { + \ 'command': l:executable + \ . ' lint' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/djlint.vim b/sources_non_forked/ale/autoload/ale/fixers/djlint.vim new file mode 100644 index 00000000..74c6c261 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/djlint.vim @@ -0,0 +1,48 @@ +" Author: Adrian Vollmer (computerfluesterer@protonmail.com) +" Description: HTML template formatter using `djlint --reformat` + +call ale#Set('html_djlint_executable', 'djlint') +call ale#Set('html_djlint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('html_djlint_options', '') + +function! ale#fixers#djlint#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'html_djlint', + \ ['djlint'] + \) + + let l:options = ale#Var(a:buffer, 'html_djlint_options') + + let l:profile = '' + let l:filetypes = split(getbufvar(a:buffer, '&filetype'), '\.') + + " Append the --profile flag depending on the current filetype (unless it's + " already set in g:html_djlint_options). + if match(l:options, '--profile') == -1 + let l:djlint_profiles = { + \ 'html': 'html', + \ 'htmldjango': 'django', + \ 'jinja': 'jinja', + \ 'nunjucks': 'nunjucks', + \ 'handlebars': 'handlebars', + \ 'gohtmltmpl': 'golang', + \ 'htmlangular': 'angular', + \} + + for l:filetype in l:filetypes + if has_key(l:djlint_profiles, l:filetype) + let l:profile = l:djlint_profiles[l:filetype] + break + endif + endfor + endif + + if !empty(l:profile) + let l:options = (!empty(l:options) ? l:options . ' ' : '') . '--profile ' . l:profile + endif + + return { + \ 'command': ale#Escape(l:executable) . ' --reformat ' . l:options . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dotnet_format.vim b/sources_non_forked/ale/autoload/ale/fixers/dotnet_format.vim new file mode 100644 index 00000000..b44a28bd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dotnet_format.vim @@ -0,0 +1,18 @@ +" Author: ghsang +" Description: Integration of dotnet format with ALE. + +call ale#Set('cs_dotnet_format_executable', 'dotnet') +call ale#Set('cs_dotnet_format_options', '') + +function! ale#fixers#dotnet_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'cs_dotnet_format_executable') + let l:options = ale#Var(a:buffer, 'cs_dotnet_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --folder --include %t "$(dirname %t)"', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dprint.vim b/sources_non_forked/ale/autoload/ale/fixers/dprint.vim new file mode 100644 index 00000000..99e590df --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dprint.vim @@ -0,0 +1,29 @@ +call ale#Set('dprint_executable', 'dprint') +call ale#Set('dprint_executable_override', 0) +call ale#Set('dprint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('dprint_options', '') +call ale#Set('dprint_config', 'dprint.json') + +function! ale#fixers#dprint#Fix(buffer) abort + let l:executable = ale#path#FindExecutable(a:buffer, 'dprint', ['dprint']) + let l:executable_override = ale#Var(a:buffer, 'dprint_executable_override') + + if !executable(l:executable) && !l:executable_override + return 0 + endif + + let l:options = ale#Var(a:buffer, 'dprint_options') + let l:config = ale#path#FindNearestFile(a:buffer, ale#Var(a:buffer, 'dprint_config')) + + if !empty(l:config) + let l:options = l:options . ' -c ' . ale#Escape(l:config) + endif + + let l:options = l:options . ' --stdin %s' + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fmt ' + \ . l:options + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dune.vim b/sources_non_forked/ale/autoload/ale/fixers/dune.vim new file mode 100644 index 00000000..6ef7ec9f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dune.vim @@ -0,0 +1,16 @@ +" Author: Albert Peschar +" Description: Fix files with dune format. + +call ale#Set('ocaml_dune_executable', 'dune') +call ale#Set('ocaml_dune_options', '') + +function! ale#fixers#dune#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'ocaml_dune_executable') + let l:options = ale#Var(a:buffer, 'ocaml_dune_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim b/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim index cd2be2c3..a4740db4 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim @@ -6,7 +6,7 @@ call ale#Set('elm_format_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('elm_format_options', '--yes') function! ale#fixers#elm_format#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'elm_format', [ + return ale#path#FindExecutable(a:buffer, 'elm_format', [ \ 'node_modules/.bin/elm-format', \]) endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/erbformatter.vim b/sources_non_forked/ale/autoload/ale/fixers/erbformatter.vim new file mode 100644 index 00000000..7bb43e0c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/erbformatter.vim @@ -0,0 +1,13 @@ +" Author: Arash Mousavi +" Description: Support for ERB::Formetter https://github.com/nebulab/erb-formatter + +call ale#Set('eruby_erbformatter_executable', 'erb-formatter') + +function! ale#fixers#erbformatter#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'eruby_erbformatter_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' -w %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/erblint.vim b/sources_non_forked/ale/autoload/ale/fixers/erblint.vim new file mode 100644 index 00000000..41aca0c8 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/erblint.vim @@ -0,0 +1,40 @@ +" Author: Roeland Moors - https://github.com/roelandmoors +" Description: ERB Lint, support for https://github.com/Shopify/erb-lint + +call ale#Set('eruby_erblint_executable', 'erblint') +call ale#Set('eruby_erblint_options', '') + + +" Erblint fixer outputs diagnostics first and then the fixed +" output. These are delimited by something like this: +" ================ /path/to/demo.html.erb ================== +" We only need the output after this +function! ale#fixers#erblint#PostProcess(buffer, output) abort + let l:line = 0 + + for l:output in a:output + let l:line = l:line + 1 + + if l:output =~# "^=\\+.*=\\+$" + break + endif + endfor + + return a:output[l:line :] +endfunction + +function! ale#fixers#erblint#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable') + let l:options = ale#Var(a:buffer, 'eruby_erblint_options') + + return ale#ruby#EscapeExecutable(l:executable, 'erblint') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --autocorrect --stdin %s' +endfunction + +function! ale#fixers#erblint#Fix(buffer) abort + return { + \ 'command': ale#fixers#erblint#GetCommand(a:buffer), + \ 'process_with': 'ale#fixers#erblint#PostProcess' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/erlang_mode.vim b/sources_non_forked/ale/autoload/ale/fixers/erlang_mode.vim new file mode 100644 index 00000000..a89784d5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/erlang_mode.vim @@ -0,0 +1,49 @@ +" Author: Dmitri Vereshchagin +" Description: Indent with the Erlang mode for Emacs + +call ale#Set('erlang_erlang_mode_emacs_executable', 'emacs') +call ale#Set('erlang_erlang_mode_indent_level', 4) +call ale#Set('erlang_erlang_mode_icr_indent', 'nil') +call ale#Set('erlang_erlang_mode_indent_guard', 2) +call ale#Set('erlang_erlang_mode_argument_indent', 2) +call ale#Set('erlang_erlang_mode_indent_tabs_mode', 'nil') + +let s:variables = { +\ 'erlang-indent-level': 'erlang_erlang_mode_indent_level', +\ 'erlang-icr-indent': 'erlang_erlang_mode_icr_indent', +\ 'erlang-indent-guard': 'erlang_erlang_mode_indent_guard', +\ 'erlang-argument-indent': 'erlang_erlang_mode_argument_indent', +\ 'indent-tabs-mode': 'erlang_erlang_mode_indent_tabs_mode', +\} + +function! ale#fixers#erlang_mode#Fix(buffer) abort + let emacs_executable = + \ ale#Var(a:buffer, 'erlang_erlang_mode_emacs_executable') + + let l:exprs = [ + \ s:SetqDefault(a:buffer, s:variables), + \ '(erlang-mode)', + \ '(font-lock-fontify-region (point-min) (point-max))', + \ '(indent-region (point-min) (point-max))', + \ '(funcall (if indent-tabs-mode ''tabify ''untabify)' + \ . ' (point-min) (point-max))', + \ '(save-buffer 0)', + \] + + let l:command = ale#Escape(l:emacs_executable) + \ . ' --batch' + \ . ' --find-file=%t' + \ . join(map(l:exprs, '" --eval=" . ale#Escape(v:val)'), '') + + return {'command': l:command, 'read_temporary_file': 1} +endfunction + +function! s:SetqDefault(buffer, variables) abort + let l:args = [] + + for [l:emacs_name, l:ale_name] in items(a:variables) + let l:args += [l:emacs_name, ale#Var(a:buffer, l:ale_name)] + endfor + + return '(setq-default ' . join(l:args) . ')' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim new file mode 100644 index 00000000..06cb1704 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim @@ -0,0 +1,19 @@ +" Author: AntoineGagne - https://github.com/AntoineGagne +" Description: Integration of erlfmt with ALE. + +call ale#Set('erlang_erlfmt_executable', 'erlfmt') +call ale#Set('erlang_erlfmt_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('erlang_erlfmt_options', '') + +function! ale#fixers#erlfmt#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'erlang_erlfmt', ['erlfmt']) +endfunction + +function! ale#fixers#erlfmt#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'erlang_erlfmt_options') + let l:executable = ale#fixers#erlfmt#GetExecutable(a:buffer) + + let l:command = ale#Escape(l:executable) . ale#Pad(l:options) . ' -' + + return {'command': l:command} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/eslint.vim b/sources_non_forked/ale/autoload/ale/fixers/eslint.vim index 62e692b1..c9535cb0 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/eslint.vim @@ -53,6 +53,7 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort " Use --fix-to-stdout with eslint_d if l:executable =~# 'eslint_d$' && ale#semver#GTE(a:version, [3, 19, 0]) return { + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), \ 'command': ale#node#Executable(a:buffer, l:executable) \ . ale#Pad(l:options) \ . ' --stdin-filename %s --stdin --fix-to-stdout', @@ -63,6 +64,7 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort " 4.9.0 is the first version with --fix-dry-run if ale#semver#GTE(a:version, [4, 9, 0]) return { + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), \ 'command': ale#node#Executable(a:buffer, l:executable) \ . ale#Pad(l:options) \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json', @@ -71,6 +73,7 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort endif return { + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), \ 'command': ale#node#Executable(a:buffer, l:executable) \ . ale#Pad(l:options) \ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '') diff --git a/sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim b/sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim new file mode 100644 index 00000000..ebf17c5a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim @@ -0,0 +1,19 @@ +" Author: Chen YuanYuan +" Description: Integration of fish_indent with ALE. + +call ale#Set('fish_fish_indent_executable', 'fish_indent') +call ale#Set('fish_fish_indent_options', '') + +function! ale#fixers#fish_indent#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'fish_fish_indent_executable') + let l:options = ale#Var(a:buffer, 'fish_fish_indent_options') + let l:filename = ale#Escape(bufname(a:buffer)) + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -w ' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim b/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim index 33ce0af3..4bad8f9b 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim @@ -6,7 +6,7 @@ call ale#Set('json_fixjson_options', '') call ale#Set('json_fixjson_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#fixjson#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'json_fixjson', [ + return ale#path#FindExecutable(a:buffer, 'json_fixjson', [ \ 'node_modules/.bin/fixjson', \]) endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/forge.vim b/sources_non_forked/ale/autoload/ale/fixers/forge.vim new file mode 100644 index 00000000..2efbb7da --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/forge.vim @@ -0,0 +1,11 @@ +call ale#Set('solidity_forge_executable', 'forge') + +function! ale#fixers#forge#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'solidity_forge_executable') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fmt %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/fourmolu.vim b/sources_non_forked/ale/autoload/ale/fixers/fourmolu.vim new file mode 100644 index 00000000..399ec0f4 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/fourmolu.vim @@ -0,0 +1,20 @@ +call ale#Set('haskell_fourmolu_executable', 'fourmolu') +call ale#Set('haskell_fourmolu_options', '') + +function! ale#fixers#fourmolu#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_fourmolu_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'fourmolu') +endfunction + +function! ale#fixers#fourmolu#Fix(buffer) abort + let l:executable = ale#fixers#fourmolu#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'haskell_fourmolu_options') + + return { + \ 'command': l:executable + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --stdin-input-file ' + \ . ale#Escape(@%), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/gleam_format.vim b/sources_non_forked/ale/autoload/ale/fixers/gleam_format.vim new file mode 100644 index 00000000..00c366f5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/gleam_format.vim @@ -0,0 +1,19 @@ +" Author: Jonathan Palardt https://github.com/jpalardy +" Description: Integration of 'gleam format' with ALE. + +call ale#Set('gleam_format_executable', 'gleam') + +function! ale#fixers#gleam_format#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'gleam_format_executable') + + return ale#Escape(l:executable) +endfunction + +function! ale#fixers#gleam_format#Fix(buffer) abort + let l:executable = ale#fixers#gleam_format#GetExecutable(a:buffer) + + return { + \ 'command': l:executable . ' format %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim b/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim index d5a539b9..b9cfbb58 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim @@ -11,9 +11,6 @@ function! ale#fixers#gofmt#Fix(buffer) abort return { \ 'command': l:env . ale#Escape(l:executable) - \ . ' -l -w' \ . (empty(l:options) ? '' : ' ' . l:options) - \ . ' %t', - \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/gofumpt.vim b/sources_non_forked/ale/autoload/ale/fixers/gofumpt.vim new file mode 100644 index 00000000..99753209 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/gofumpt.vim @@ -0,0 +1,17 @@ +" Author: David Houston +" Description: A stricter gofmt implementation. + +call ale#Set('go_gofumpt_executable', 'gofumpt') +call ale#Set('go_gofumpt_options', '') + +function! ale#fixers#gofumpt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_gofumpt_executable') + let l:options = ale#Var(a:buffer, 'go_gofumpt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ale#Pad(l:options) + \ . ' -w -- %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/golangci_lint.vim b/sources_non_forked/ale/autoload/ale/fixers/golangci_lint.vim new file mode 100644 index 00000000..596f1590 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/golangci_lint.vim @@ -0,0 +1,32 @@ +" Author: Ian Stapleton Cordasco +" Description: Run golangci-lint with the --fix flag to autofix some issues + +call ale#Set('go_golangci_lint_options', '') +call ale#Set('go_golangci_lint_executable', 'golangci-lint') +call ale#Set('go_golangci_lint_package', 1) + +function! ale#fixers#golangci_lint#GetCommand(buffer) abort + let l:filename = expand('#' . a:buffer . ':t') + let l:executable = ale#Var(a:buffer, 'go_golangci_lint_executable') + let l:options = ale#Var(a:buffer, 'go_golangci_lint_options') . ' --fix' + let l:package_mode = ale#Var(a:buffer, 'go_golangci_lint_package') + let l:env = ale#go#EnvString(a:buffer) + + + if l:package_mode + return l:env . ale#Escape(l:executable) + \ . ' run ' + \ . l:options + endif + + return l:env . ale#Escape(l:executable) + \ . ' run ' + \ . l:options + \ . ' ' . ale#Escape(l:filename) +endfunction + +function! ale#fixers#golangci_lint#Fix(buffer) abort + return { + \ 'command': ale#fixers#golangci_lint#GetCommand(a:buffer), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/golines.vim b/sources_non_forked/ale/autoload/ale/fixers/golines.vim new file mode 100644 index 00000000..9326f482 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/golines.vim @@ -0,0 +1,21 @@ +" Author Pig Frown +" Description: Fix Go files long lines with golines" + +call ale#Set('go_golines_executable', 'golines') + +call ale#Set('go_golines_options', '') + +function! ale#fixers#golines#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_golines_executable') + let l:options = ale#Var(a:buffer, 'go_golines_options') + let l:env = ale#go#EnvString(a:buffer) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': l:env . ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/gopls.vim b/sources_non_forked/ale/autoload/ale/fixers/gopls.vim new file mode 100644 index 00000000..98f553c1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/gopls.vim @@ -0,0 +1,23 @@ +" Author: Sean Enck +" Description: Integration of gopls format with ALE. + +call ale#Set('go_gopls_fix_executable', 'gopls') +call ale#Set('go_gopls_fix_options', '') + +function! ale#fixers#gopls#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_gopls_fix_executable') + let l:options = ale#Var(a:buffer, 'go_gopls_fix_options') + let l:env = ale#go#EnvString(a:buffer) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': l:env . ale#Escape(l:executable) + \ . ' format' + \ . ale#Pad(l:options) + \ . ' -l -w %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim b/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim new file mode 100644 index 00000000..9817563e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim @@ -0,0 +1,20 @@ +" Author: WhyNotHugo +" Description: Format HTML files with html-beautify. + +call ale#Set('html_beautify_executable', 'html-beautify') +call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('html_beautify_options', '') + +function! ale#fixers#html_beautify#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'html_beautify', + \ ['html-beautify'] + \) + + let l:options = ale#Var(a:buffer, 'html_beautify_options') + + return { + \ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/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 +" 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 9070fb27..45083ee8 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/isort.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/isort.vim @@ -2,24 +2,76 @@ " Description: Fixing Python imports with isort. call ale#Set('python_isort_executable', 'isort') -call ale#Set('python_isort_options', '') 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#Fix(buffer) abort - let l:options = ale#Var(a:buffer, 'python_isort_options') - - let l:executable = ale#python#FindExecutable( - \ a:buffer, - \ 'python_isort', - \ ['isort'], - \) - - if !executable(l:executable) - return 0 +function! ale#fixers#isort#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_isort_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 + +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\|uv\)$' + call extend(l:cmd, ['run', 'isort']) + endif + + return join(l:cmd, ' ') +endfunction + +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\|uv\)$' + call extend(l:cmd, ['run', 'isort']) + endif + + if ale#semver#GTE(a:version, [5, 7, 0]) + call add(l:cmd, '--filename %s') + endif + + let l:options = ale#Var(a:buffer, 'python_isort_options') + + if !empty(l:options) + call add(l:cmd, l:options) + endif + + call add(l:cmd, '-') + return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \ 'cwd': '%s:h', + \ 'command': join(l:cmd, ' '), \} endfunction + +function! ale#fixers#isort#Fix(buffer) abort + let l:executable = ale#fixers#isort#GetExecutable(a:buffer) + let l:command = ale#fixers#isort#GetCmd(a:buffer) . ale#Pad('--version') + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale#fixers#isort#FixForVersion'), + \) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/json_pytool.vim b/sources_non_forked/ale/autoload/ale/fixers/json_pytool.vim new file mode 100644 index 00000000..17aeeea1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/json_pytool.vim @@ -0,0 +1,20 @@ +" Author: idbrii +" Description: json formatter as ALE fixer using python's json.tool + +call ale#Set('json_pytool_executable', 'python') +call ale#Set('json_pytool_options', '') +call ale#Set('json_pytool_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#json_pytool#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'json_pytool', ['python']) +endfunction + +function! ale#fixers#json_pytool#Fix(buffer) abort + let l:executable = ale#Escape(ale#fixers#json_pytool#GetExecutable(a:buffer)) + let l:opts = ale#Var(a:buffer, 'json_pytool_options') + let l:command = printf('%s -m json.tool %s -', l:executable, l:opts) + + return { + \ 'command': l:command + \ } +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/jsonnetfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/jsonnetfmt.vim new file mode 100644 index 00000000..f1e41cd5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/jsonnetfmt.vim @@ -0,0 +1,18 @@ +" Authors: Trevor Whitney and Takuya Kosugiyama +" Description: Integration of jsonnetfmt with ALE. + +call ale#Set('jsonnet_jsonnetfmt_executable', 'jsonnetfmt') +call ale#Set('jsonnet_jsonnetfmt_options', '') + +function! ale#fixers#jsonnetfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'jsonnet_jsonnetfmt_executable') + let l:options = ale#Var(a:buffer, 'jsonnet_jsonnetfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -i' + \ . ale#Pad(l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim b/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim index cb975d6c..64d1340d 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim @@ -3,7 +3,6 @@ function! ale#fixers#ktlint#Fix(buffer) abort return { - \ 'command': ale#handlers#ktlint#GetCommand(a:buffer) . ' --format', - \ 'read_temporary_file': 1, + \ 'command': ale#handlers#ktlint#GetCommand(a:buffer) . ' --format' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/kulala_fmt.vim b/sources_non_forked/ale/autoload/ale/fixers/kulala_fmt.vim new file mode 100644 index 00000000..10e81450 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/kulala_fmt.vim @@ -0,0 +1,11 @@ +" Author: hsanson +" Description: kulala_fmt fixer for http and rest files. + +call ale#Set('http_kulala_fmt_executable', 'kulala-fmt') + +function! ale#fixers#kulala_fmt#Fix(buffer) abort + return { + \ 'command': ale#Escape(ale#Var(a:buffer, 'http_kulala_fmt_executable')) . ' format %t > /dev/null', + \ 'read_temporary_file': 1 + \ } +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim b/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim index b0a0884a..54f1231e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim @@ -10,9 +10,7 @@ function! ale#fixers#latexindent#Fix(buffer) abort return { \ 'command': ale#Escape(l:executable) - \ . ' -l -w' + \ . ' -l' \ . (empty(l:options) ? '' : ' ' . l:options) - \ . ' %t', - \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim b/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim new file mode 100644 index 00000000..98b155c0 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim @@ -0,0 +1,16 @@ +" Author: Mathias Jean Johansen +" Description: Integration of LuaFormatter with ALE. + +call ale#Set('lua_lua_format_executable', 'lua-format') +call ale#Set('lua_lua_format_options', '') + +function! ale#fixers#lua_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_lua_format_executable') + let l:options = ale#Var(a:buffer, 'lua_lua_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ale#Pad(l:options) + \ . ' -i', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim b/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim new file mode 100644 index 00000000..6cb9ef4a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim @@ -0,0 +1,13 @@ +call ale#Set('lua_luafmt_executable', 'luafmt') +call ale#Set('lua_luafmt_options', '') + +function! ale#fixers#luafmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_luafmt_executable') + let l:options = ale#Var(a:buffer, 'lua_luafmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --stdin', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nickel_format.vim b/sources_non_forked/ale/autoload/ale/fixers/nickel_format.vim new file mode 100644 index 00000000..07eed8f9 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nickel_format.vim @@ -0,0 +1,16 @@ +" Author: Yining +" Description: nickel format as ALE fixer for Nickel files + +call ale#Set('nickel_nickel_format_executable', 'nickel') +call ale#Set('nickel_nickel_format_options', '') + +function! ale#fixers#nickel_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nickel_nickel_format_executable') + let l:options = ale#Var(a:buffer, 'nickel_nickel_format_options') + + return { + \ 'command': ale#Escape(l:executable) . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options) + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim b/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim new file mode 100644 index 00000000..fe2e7136 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim @@ -0,0 +1,15 @@ +" Author: Nhan +" Description: Integration of nimpretty with ALE. + +call ale#Set('nim_nimpretty_executable', 'nimpretty') +call ale#Set('nim_nimpretty_options', '--maxLineLen:80') + +function! ale#fixers#nimpretty#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nim_nimpretty_executable') + let l:options = ale#Var(a:buffer, 'nim_nimpretty_options') + + return { + \ 'command': ale#Escape(l:executable) . ' %t' . ale#Pad(l:options), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim new file mode 100644 index 00000000..4a548b23 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim @@ -0,0 +1,15 @@ +scriptencoding utf-8 +" Author: houstdav000 +" Description: Fix files with nixfmt + +call ale#Set('nix_nixfmt_executable', 'nixfmt') +call ale#Set('nix_nixfmt_options', '') + +function! ale#fixers#nixfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_nixfmt_executable') + let l:options = ale#Var(a:buffer, 'nix_nixfmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ale#Pad(l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim new file mode 100644 index 00000000..403ce798 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim @@ -0,0 +1,12 @@ +call ale#Set('nix_nixpkgsfmt_executable', 'nixpkgs-fmt') +call ale#Set('nix_nixpkgsfmt_options', '') + +function! ale#fixers#nixpkgsfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_nixpkgsfmt_executable') + let l:options = ale#Var(a:buffer, 'nix_nixpkgsfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/npmgroovylint.vim b/sources_non_forked/ale/autoload/ale/fixers/npmgroovylint.vim new file mode 100644 index 00000000..39e43cf6 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/npmgroovylint.vim @@ -0,0 +1,16 @@ +" Author: lucas-str +" Description: Integration of npm-groovy-lint for Groovy files. + +call ale#Set('groovy_npmgroovylint_fix_options', '--fix') + +function! ale#fixers#npmgroovylint#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'groovy_npmgroovylint_executable') + let l:options = ale#Var(a:buffer, 'groovy_npmgroovylint_fix_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim b/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim index 9b7c3e12..b12d2eb9 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim @@ -5,14 +5,13 @@ call ale#Set('ocaml_ocamlformat_executable', 'ocamlformat') call ale#Set('ocaml_ocamlformat_options', '') function! ale#fixers#ocamlformat#Fix(buffer) abort - let l:filename = expand('#' . a:buffer . ':p') let l:executable = ale#Var(a:buffer, 'ocaml_ocamlformat_executable') let l:options = ale#Var(a:buffer, 'ocaml_ocamlformat_options') return { \ 'command': ale#Escape(l:executable) \ . (empty(l:options) ? '' : ' ' . l:options) - \ . ' --name=' . ale#Escape(l:filename) + \ . ' --name=%s' \ . ' -' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/opafmt.vim b/sources_non_forked/ale/autoload/ale/fixers/opafmt.vim new file mode 100644 index 00000000..a0999b70 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/opafmt.vim @@ -0,0 +1,15 @@ +" Description: Fixer for rego files + +call ale#Set('opa_fmt_executable', 'opa') +call ale#Set('opa_fmt_options', '') + +function! ale#fixers#opafmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'opa_fmt_executable') + let l:options = ale#Var(a:buffer, 'opa_fmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fmt' + \ . (empty(l:options) ? '' : ' ' . l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim b/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim new file mode 100644 index 00000000..69b55c1f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim @@ -0,0 +1,12 @@ +call ale#Set('haskell_ormolu_executable', 'ormolu') +call ale#Set('haskell_ormolu_options', '') + +function! ale#fixers#ormolu#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_ormolu_executable') + let l:options = ale#Var(a:buffer, 'haskell_ormolu_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/packer.vim b/sources_non_forked/ale/autoload/ale/fixers/packer.vim new file mode 100644 index 00000000..8770550d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/packer.vim @@ -0,0 +1,17 @@ +" Author: Zhuoyun Wei +" Description: Fixer for Packer HCL files + +call ale#Set('packer_fmt_executable', 'packer') +call ale#Set('packer_fmt_options', '') + +function! ale#fixers#packer#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'packer_fmt_executable') + let l:options = ale#Var(a:buffer, 'packer_fmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fmt' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim b/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim new file mode 100644 index 00000000..d704c8a2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim @@ -0,0 +1,16 @@ +scriptencoding utf-8 +" Author: Jesse Hathaway +" Description: Fix markdown files with pandoc. + +call ale#Set('markdown_pandoc_executable', 'pandoc') +call ale#Set('markdown_pandoc_options', '-f gfm -t gfm -s -') + +function! ale#fixers#pandoc#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'markdown_pandoc_executable') + let l:options = ale#Var(a:buffer, 'markdown_pandoc_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . l:options, + \} +endfunction 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 5c59e262..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,9 +4,10 @@ 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#node#FindExecutable(a:buffer, 'php_cs_fixer', [ + return ale#path#FindExecutable(a:buffer, 'php_cs_fixer', [ \ 'vendor/bin/php-cs-fixer', \ '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/phpcbf.vim b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim index f14b8406..494bf346 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim @@ -2,11 +2,12 @@ " Description: Fixing files with phpcbf. call ale#Set('php_phpcbf_standard', '') +call ale#Set('php_phpcbf_options', '') call ale#Set('php_phpcbf_executable', 'phpcbf') call ale#Set('php_phpcbf_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#phpcbf#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'php_phpcbf', [ + return ale#path#FindExecutable(a:buffer, 'php_phpcbf', [ \ 'vendor/bin/phpcbf', \ 'phpcbf' \]) @@ -20,6 +21,6 @@ function! ale#fixers#phpcbf#Fix(buffer) abort \ : '' return { - \ 'command': ale#Escape(l:executable) . ' --stdin-path=%s ' . l:standard_option . ' -' + \ 'command': ale#Escape(l:executable) . ' --stdin-path=%s ' . l:standard_option . ale#Pad(ale#Var(a:buffer, 'php_phpcbf_options')) . ' -' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/pint.vim b/sources_non_forked/ale/autoload/ale/fixers/pint.vim new file mode 100644 index 00000000..274ddd9e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pint.vim @@ -0,0 +1,25 @@ +" Author: Michael Dyrynda +" Description: Fixing files with Laravel Pint. + +call ale#Set('php_pint_executable', 'pint') +call ale#Set('php_pint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_pint_options', '') + +function! ale#fixers#pint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'php_pint', [ + \ 'vendor/bin/pint', + \ 'pint' + \]) +endfunction + +function! ale#fixers#pint#Fix(buffer) abort + let l:executable = ale#fixers#pint#GetExecutable(a:buffer) + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . ale#Var(a:buffer, 'php_pint_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 23120777..c9210e63 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim @@ -7,7 +7,7 @@ call ale#Set('javascript_prettier_use_global', get(g:, 'ale_use_global_executabl call ale#Set('javascript_prettier_options', '') function! ale#fixers#prettier#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_prettier', [ + return ale#path#FindExecutable(a:buffer, 'javascript_prettier', [ \ 'node_modules/.bin/prettier_d', \ 'node_modules/prettier-cli/index.js', \ 'node_modules/.bin/prettier', @@ -34,6 +34,13 @@ function! ale#fixers#prettier#ProcessPrettierDOutput(buffer, output) abort return a:output endfunction +function! ale#fixers#prettier#GetCwd(buffer) abort + let l:config = ale#path#FindNearestFile(a:buffer, '.prettierignore') + + " Fall back to the directory of the buffer + return !empty(l:config) ? fnamemodify(l:config, ':h') : '%s:h' +endfunction + function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort let l:executable = ale#fixers#prettier#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'javascript_prettier_options') @@ -67,8 +74,12 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort \ 'graphql': 'graphql', \ 'markdown': 'markdown', \ 'vue': 'vue', + \ 'svelte': 'svelte', \ 'yaml': 'yaml', + \ 'openapi': 'yaml', \ 'html': 'html', + \ 'ruby': 'ruby', + \ 'astro': 'astro', \} for l:filetype in l:filetypes @@ -86,8 +97,8 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort " Special error handling needed for prettier_d if l:executable =~# 'prettier_d$' return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) + \ 'cwd': '%s:h', + \ 'command':ale#Escape(l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --stdin-filepath %s --stdin', \ 'process_with': 'ale#fixers#prettier#ProcessPrettierDOutput', @@ -97,8 +108,8 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort " 1.4.0 is the first version with --stdin-filepath if ale#semver#GTE(a:version, [1, 4, 0]) return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) + \ 'cwd': ale#fixers#prettier#GetCwd(a:buffer), + \ 'command': ale#Escape(l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --stdin-filepath %s --stdin', \} diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim index 1e66f49e..0b9c88b7 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim @@ -7,7 +7,7 @@ call ale#Set('javascript_prettier_eslint_use_global', get(g:, 'ale_use_global_ex call ale#Set('javascript_prettier_eslint_options', '') function! ale#fixers#prettier_eslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_prettier_eslint', [ + return ale#path#FindExecutable(a:buffer, 'javascript_prettier_eslint', [ \ 'node_modules/prettier-eslint-cli/dist/index.js', \ 'node_modules/.bin/prettier-eslint', \]) @@ -37,8 +37,8 @@ function! ale#fixers#prettier_eslint#ApplyFixForVersion(buffer, version) abort " 4.4.0 is the first version with --stdin-filepath if ale#semver#GTE(a:version, [4, 4, 0]) return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) \ . l:eslint_config_option \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --stdin-filepath %s --stdin', diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim index b6e0a6f9..c8c09e31 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim @@ -6,7 +6,7 @@ call ale#Set('javascript_prettier_standard_use_global', get(g:, 'ale_use_global_ call ale#Set('javascript_prettier_standard_options', '') function! ale#fixers#prettier_standard#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_prettier_standard', [ + return ale#path#FindExecutable(a:buffer, 'javascript_prettier_standard', [ \ 'node_modules/prettier-standard/lib/index.js', \ 'node_modules/.bin/prettier-standard', \]) @@ -17,8 +17,8 @@ function! ale#fixers#prettier_standard#Fix(buffer) abort return { \ 'command': ale#Escape(ale#fixers#prettier_standard#GetExecutable(a:buffer)) - \ . ' %t' + \ . ' --stdin' + \ . ' --stdin-filepath=%s' \ . ' ' . l:options, - \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/protolint.vim b/sources_non_forked/ale/autoload/ale/fixers/protolint.vim new file mode 100644 index 00000000..9b8e72f1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/protolint.vim @@ -0,0 +1,26 @@ +" Author: Yohei Yoshimuta +" Description: Integration of protolint with ALE. + +call ale#Set('proto_protolint_executable', 'protolint') +call ale#Set('proto_protolint_config', '') + +function! ale#fixers#protolint#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'proto_protolint_executable') + + return ale#Escape(l:executable) +endfunction + +function! ale#fixers#protolint#Fix(buffer) abort + let l:executable = ale#fixers#protolint#GetExecutable(a:buffer) + let l:config = ale#Var(a:buffer, 'proto_protolint_config') + + return { + \ 'command': l:executable + \ . (!empty(l:config) ? ' -config_path=' . ale#Escape(l:config) : '') + \ . ' -fix' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + + diff --git a/sources_non_forked/ale/autoload/ale/fixers/ptop.vim b/sources_non_forked/ale/autoload/ale/fixers/ptop.vim new file mode 100644 index 00000000..98345226 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ptop.vim @@ -0,0 +1,17 @@ +" Author: BarrOff https://github.com/BarrOff +" Description: Integration of ptop with ALE. + +call ale#Set('pascal_ptop_executable', 'ptop') +call ale#Set('pascal_ptop_options', '') + +function! ale#fixers#ptop#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'pascal_ptop_executable') + let l:options = ale#Var(a:buffer, 'pascal_ptop_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %s %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/purs_tidy.vim b/sources_non_forked/ale/autoload/ale/fixers/purs_tidy.vim new file mode 100644 index 00000000..09fa631b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/purs_tidy.vim @@ -0,0 +1,24 @@ +" Author: toastal +" Description: Integration of purs-tidy with ALE. + +call ale#Set('purescript_tidy_executable', 'purs-tidy') +call ale#Set('purescript_tidy_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('purescript_tidy_options', '') + +function! ale#fixers#purs_tidy#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'purescript_tidy', [ + \ 'node_modules/purescript-tidy/bin/index.js', + \ 'node_modules/.bin/purs-tidy', + \]) +endfunction + +function! ale#fixers#purs_tidy#Fix(buffer) abort + let l:executable = ale#fixers#purs_tidy#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'purescript_tidy_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . ale#Pad(l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/purty.vim b/sources_non_forked/ale/autoload/ale/fixers/purty.vim new file mode 100644 index 00000000..46d2cacd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/purty.vim @@ -0,0 +1,22 @@ +" Author: iclanzan +" Description: Integration of purty with ALE. + +call ale#Set('purescript_purty_executable', 'purty') + +function! ale#fixers#purty#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'purescript_purty_executable') + + return ale#Escape(l:executable) +endfunction + +function! ale#fixers#purty#Fix(buffer) abort + let l:executable = ale#fixers#purty#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' --write' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/pycln.vim b/sources_non_forked/ale/autoload/ale/fixers/pycln.vim new file mode 100644 index 00000000..ca15cc4e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pycln.vim @@ -0,0 +1,96 @@ +" Author: Yining +" Description: pycln as ALE fixer for python files + +call ale#Set('python_pycln_executable', 'pycln') +call ale#Set('python_pycln_options', '') +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 + if ale#Var(a:buffer, 'python_pycln_change_directory') + " Run from project root if found, else from buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '%s:h' +endfunction + +function! ale#fixers#pycln#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycln_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pycln_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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\|uv\)$' + \ ? ' run pycln' + \ : '' + + return ale#Escape(l:executable) . l:exec_args +endfunction + +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\|uv\)$' + call extend(l:cmd, ['run', 'pycln']) + endif + + let l:options = ale#Var(a:buffer, 'python_pycln_options') + + if !empty(l:options) + call add(l:cmd, l:options) + endif + + let l:config_file = ale#Var(a:buffer, 'python_pycln_config_file') + let l:config_file = l:options !~# '\v(^| )--config ' && !empty(l:config_file) + \ ? ale#Escape(ale#path#Simplify(l:config_file)) + \ : '' + + if !empty(l:config_file) + call add(l:cmd, '--config ' . l:config_file) + endif + + call add(l:cmd, '--silence') + + " NOTE: pycln version `1.3.0` support reading from stdin + call add(l:cmd, ale#semver#GTE(a:version, [1, 3, 0]) ? '-' : '%s') + + return { + \ 'cwd': ale#fixers#pycln#GetCwd(a:buffer), + \ 'command': join(l:cmd, ' '), + \} +endfunction + +function! ale#fixers#pycln#Fix(buffer) abort + let l:executable = ale#fixers#pycln#GetExecutable(a:buffer) + let l:command = ale#fixers#pycln#GetCommand(a:buffer) . ale#Pad('--version') + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale#fixers#pycln#FixForVersion'), + \) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim b/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim new file mode 100644 index 00000000..d5c2d235 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim @@ -0,0 +1,47 @@ +" Author: infokiller +" Description: Tidy imports using pyflyby's tidy-import script +" https://github.com/deshaw/pyflyby + +call ale#Set('python_pyflyby_executable', 'tidy-imports') +call ale#Set('python_pyflyby_use_global', get(g:, 'ale_use_global_executables', 0)) +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')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflyby_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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 + +function! ale#fixers#pyflyby#Fix(buffer) abort + " let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer) + let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer) + let l:cmd = [ale#Escape(l:executable)] + + if l:executable =~? '\(pipenv\|poetry\|uv\)$' + call extend(l:cmd, ['run', 'tidy-imports']) + endif + + let l:options = ale#Var(a:buffer, 'python_pyflyby_options') + + if !empty(l:options) + call add(l:cmd, l:options) + endif + + return {'command': join(l:cmd, ' ')} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/raco_fmt.vim b/sources_non_forked/ale/autoload/ale/fixers/raco_fmt.vim new file mode 100644 index 00000000..16cf4468 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/raco_fmt.vim @@ -0,0 +1,15 @@ +" Author: Jeremy Cantrell +" Description: Integration of raco fmt with ALE. + +call ale#Set('racket_raco_fmt_executable', 'raco') +call ale#Set('racket_raco_fmt_options', '') + +function! ale#fixers#raco_fmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'racket_raco_fmt_executable') + let l:options = ale#Var(a:buffer, 'racket_raco_fmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ' fmt' + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim b/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim new file mode 100644 index 00000000..85593b44 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim @@ -0,0 +1,24 @@ +" Author: blyoa +" Description: Fixing files with remark-lint. + +call ale#Set('markdown_remark_lint_executable', 'remark') +call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('markdown_remark_lint_options', '') + +function! ale#fixers#remark_lint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'markdown_remark_lint', [ + \ 'node_modules/remark-cli/cli.js', + \ 'node_modules/.bin/remark', + \]) +endfunction + +function! ale#fixers#remark_lint#Fix(buffer) abort + let l:executable = ale#fixers#remark_lint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : ''), + \} +endfunction + 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..6e10c1d6 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/rubocop.vim b/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim index 33ba6887..5a1b7959 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim @@ -1,20 +1,38 @@ call ale#Set('ruby_rubocop_options', '') +call ale#Set('ruby_rubocop_auto_correct_all', 0) call ale#Set('ruby_rubocop_executable', 'rubocop') +" Rubocop fixer outputs diagnostics first and then the fixed +" output. These are delimited by a "=======" string that we +" look for to remove everything before it. +function! ale#fixers#rubocop#PostProcess(buffer, output) abort + let l:line = 0 + + for l:output in a:output + let l:line = l:line + 1 + + if l:output =~# "^=\\+$" + break + endif + endfor + + return a:output[l:line :] +endfunction + function! ale#fixers#rubocop#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') - let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml') let l:options = ale#Var(a:buffer, 'ruby_rubocop_options') + let l:auto_correct_all = ale#Var(a:buffer, 'ruby_rubocop_auto_correct_all') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop') - \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') + return ale#ruby#EscapeExecutable(l:executable, 'rubocop') \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --auto-correct --force-exclusion %t' + \ . (l:auto_correct_all ? ' --auto-correct-all' : ' --auto-correct') + \ . ' --force-exclusion --stdin %s' endfunction function! ale#fixers#rubocop#Fix(buffer) abort return { \ 'command': ale#fixers#rubocop#GetCommand(a:buffer), - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/rubyfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/rubyfmt.vim new file mode 100644 index 00000000..64b3c2c4 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/rubyfmt.vim @@ -0,0 +1,16 @@ +" Author: Yining +" Description: support rubyfmt as ALE fixer for Ruby files + +call ale#Set('ruby_rubyfmt_executable', 'rubyfmt') +call ale#Set('ruby_rubyfmt_options', '') + +function! ale#fixers#rubyfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_rubyfmt_executable') + let l:options = ale#Var(a:buffer, 'ruby_rubyfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (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 new file mode 100644 index 00000000..c0c3cd62 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ruff.vim @@ -0,0 +1,100 @@ +" Author: Yining +" Description: ruff as ALE fixer for python files + +call ale#Set('python_ruff_executable', 'ruff') +call ale#Set('python_ruff_options', '') +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') + " Run from project root if found, else from buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '%s:h' +endfunction + +function! ale#fixers#ruff#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_ruff_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_ruff_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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\|uv\)$' + \ ? ' run ruff' + \ : '' + + return ale#Escape(l:executable) . l:exec_args +endfunction + +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\|uv\)$' + call extend(l:cmd, ['run', 'ruff']) + endif + + " NOTE: ruff 0.5.0 removes `ruff ` in favor of `ruff check ` + 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) + call add(l:cmd, l:options) + endif + + " when --stdin-filename present, ruff will use it for proj root resolution + " https://github.com/charliermarsh/ruff/pull/1281 + let l:fname = expand('#' . a:buffer . '...') + call add(l:cmd, '--stdin-filename '.ale#Escape(ale#path#Simplify(l:fname))) + + call add(l:cmd, '--fix') + + " NOTE: ruff version `0.0.72` implements `--fix` with stdin + if ale#semver#GTE(a:version, [0, 0, 72]) + call add(l:cmd, '-') + else + call add(l:cmd, '%s') + endif + + return { + \ 'cwd': ale#fixers#ruff#GetCwd(a:buffer), + \ 'command': join(l:cmd, ' '), + \} +endfunction + +function! ale#fixers#ruff#Fix(buffer) abort + let l:executable = ale#fixers#ruff#GetExecutable(a:buffer) + let l:command = ale#fixers#ruff#GetCommand(a:buffer) . ale#Pad('--version') + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale#fixers#ruff#FixForVersion'), + \) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ruff_format.vim b/sources_non_forked/ale/autoload/ale/fixers/ruff_format.vim new file mode 100644 index 00000000..cfa7b76d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ruff_format.vim @@ -0,0 +1,78 @@ +" Author: Yining , Joseph Henrich +" Description: ruff formatter as ALE fixer for python files + +call ale#Set('python_ruff_format_executable', 'ruff') +call ale#Set('python_ruff_format_options', '') +call ale#Set('python_ruff_format_use_global', get(g:, 'ale_use_global_executables', 0)) +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') + " Run from project root if found, else from buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '%s:h' +endfunction + +function! ale#fixers#ruff_format#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_ruff_format_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_ruff_format_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + 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\|uv\)$' + \ ? ' run ruff' + \ : '' + + return ale#Escape(l:executable) . l:exec_args +endfunction + +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\|uv\)$' + call extend(l:cmd, ['run', 'ruff']) + endif + + let l:options = ale#Var(a:buffer, 'python_ruff_format_options') + + " when --stdin-filename present, ruff will use it for proj root resolution + " https://github.com/charliermarsh/ruff/pull/1281 + let l:fname = expand('#' . a:buffer . '...') + call add(l:cmd, 'format') + + if !empty(l:options) + call add(l:cmd, l:options) + endif + + call add(l:cmd, '--stdin-filename '.ale#Escape(ale#path#Simplify(l:fname))) + + call add(l:cmd, '-') + + return { + \ 'cwd': ale#fixers#ruff_format#GetCwd(a:buffer), + \ 'command': join(l:cmd, ' '), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/rustywind.vim b/sources_non_forked/ale/autoload/ale/fixers/rustywind.vim new file mode 100644 index 00000000..5e9bb3c5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/rustywind.vim @@ -0,0 +1,17 @@ +scriptencoding utf-8 +" Author: Guillermo Roig +" Description: Sort TailwindCSS classes with rustywind + +call ale#Set('html_rustywind_executable', 'rustywind') +call ale#Set('html_rustywind_options', '') + +function! ale#fixers#rustywind#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'html_rustywind_executable') + let l:options = ale#Var(a:buffer, 'html_rustywind_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --stdin' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/scadformat.vim b/sources_non_forked/ale/autoload/ale/fixers/scadformat.vim new file mode 100644 index 00000000..f95f2963 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/scadformat.vim @@ -0,0 +1,15 @@ +" Author: tony o'dell +" Description: Fix scad files with scadformat + +call ale#Set('openscad_scadformat_executable', 'scadformat') +call ale#Set('openscad_scadformat_options', '') + +function! ale#fixers#scadformat#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'openscad_scadformat_executable') + let l:options = ale#Var(a:buffer, 'openscad_scadformat_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/shfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/shfmt.vim index 06e8da57..0eefc985 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/shfmt.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/shfmt.vim @@ -5,27 +5,13 @@ scriptencoding utf-8 call ale#Set('sh_shfmt_executable', 'shfmt') call ale#Set('sh_shfmt_options', '') -function! s:DefaultOption(buffer) abort - if getbufvar(a:buffer, '&expandtab') == 0 - " Tab is used by default - return '' - endif - - let l:tabsize = getbufvar(a:buffer, '&shiftwidth') - - if l:tabsize == 0 - let l:tabsize = getbufvar(a:buffer, '&tabstop') - endif - - return ' -i ' . l:tabsize -endfunction - function! ale#fixers#shfmt#Fix(buffer) abort let l:executable = ale#Var(a:buffer, 'sh_shfmt_executable') let l:options = ale#Var(a:buffer, 'sh_shfmt_options') return { \ 'command': ale#Escape(l:executable) - \ . (empty(l:options) ? s:DefaultOption(a:buffer) : ' ' . l:options) + \ . ' -filename=%s' + \ . (empty(l:options) ? '' : ' ' . l:options) \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim b/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim index 182f7300..7c12fa1e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim @@ -5,7 +5,7 @@ function! ale#fixers#sorbet#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable') let l:options = ale#Var(a:buffer, 'ruby_sorbet_options') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'srb') + return ale#ruby#EscapeExecutable(l:executable, 'srb') \ . ' tc' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --autocorrect --file %t' diff --git a/sources_non_forked/ale/autoload/ale/fixers/sqlfluff.vim b/sources_non_forked/ale/autoload/ale/fixers/sqlfluff.vim new file mode 100644 index 00000000..1dc9f5c1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/sqlfluff.vim @@ -0,0 +1,25 @@ +" Author: Carl Smedstad +" Description: Fixing SQL files with sqlfluff + +call ale#Set('sql_sqlfluff_executable', 'sqlfluff') + +function! ale#fixers#sqlfluff#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'sql_sqlfluff_executable') + + let l:cmd = + \ ale#Escape(l:executable) + \ . ' fix --force' + + let l:config_file = ale#path#FindNearestFile(a:buffer, '.sqlfluff') + + if !empty(l:config_file) + let l:cmd .= ' --config ' . ale#Escape(l:config_file) + else + let l:cmd .= ' --dialect ansi' + endif + + return { + \ 'command': l:cmd . ' %t > /dev/null', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim b/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim new file mode 100644 index 00000000..6319c1ac --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim @@ -0,0 +1,16 @@ +" Author: Cluas +" Description: Fixing files with sqlformat. + +call ale#Set('sql_sqlformat_executable', 'sqlformat') +call ale#Set('sql_sqlformat_options', '') + +function! ale#fixers#sqlformat#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'sql_sqlformat_executable') + let l:options = ale#Var(a:buffer, 'sql_sqlformat_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/standard.vim b/sources_non_forked/ale/autoload/ale/fixers/standard.vim index 77712d40..b9d60ebb 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standard.vim @@ -6,7 +6,8 @@ call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executabl call ale#Set('javascript_standard_options', '') function! ale#fixers#standard#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + return ale#path#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/.bin/standard', \]) @@ -14,12 +15,19 @@ endfunction function! ale#fixers#standard#Fix(buffer) abort let l:executable = ale#fixers#standard#GetExecutable(a:buffer) - let l:options = ale#Var(a:buffer, 'javascript_standard_options') + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:options_type = 'javascript_standard_options' + + if l:filetype =~# 'typescript' + let l:options_type = 'typescript_standard_options' + endif + + let l:options = ale#Var(a:buffer, l:options_type) return { \ 'command': ale#node#Executable(a:buffer, l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --fix %t', + \ . ' --fix --stdin < %s > %t', \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim b/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim index fab1e2bc..acb310c6 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim @@ -9,15 +9,15 @@ function! ale#fixers#standardrb#GetCommand(buffer) abort let l:config = ale#path#FindNearestFile(a:buffer, '.standard.yml') let l:options = ale#Var(a:buffer, 'ruby_standardrb_options') - return ale#handlers#ruby#EscapeExecutable(l:executable, 'standardrb') + return ale#ruby#EscapeExecutable(l:executable, 'standardrb') \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --fix --force-exclusion %t' + \ . ' --fix --force-exclusion --stdin %s' endfunction function! ale#fixers#standardrb#Fix(buffer) abort return { \ 'command': ale#fixers#standardrb#GetCommand(a:buffer), - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/statix.vim b/sources_non_forked/ale/autoload/ale/fixers/statix.vim new file mode 100644 index 00000000..5991c925 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/statix.vim @@ -0,0 +1,17 @@ +" Author: David Houston +" Description: Provide statix fix as a fixer for simple Nix antipatterns. + +call ale#Set('nix_statix_fix_executable', 'statix') +call ale#Set('nix_statix_fix_options', '') + +function! ale#fixers#statix#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_statix_fix_executable') + let l:options = ale#Var(a:buffer, 'nix_statix_fix_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ale#Pad('fix') + \ . ale#Pad('--stdin') + \ . ale#Pad(l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim index 6bfb2fde..650b9c4a 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim @@ -3,9 +3,10 @@ call ale#Set('stylelint_executable', 'stylelint') call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('stylelint_options', '') function! ale#fixers#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'stylelint', [ + return ale#path#FindExecutable(a:buffer, 'stylelint', [ \ 'node_modules/stylelint/bin/stylelint.js', \ 'node_modules/.bin/stylelint', \]) @@ -13,10 +14,13 @@ endfunction function! ale#fixers#stylelint#Fix(buffer) abort let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'stylelint_options') return { + \ 'cwd': '%s:h', \ 'command': ale#node#Executable(a:buffer, l:executable) - \ . ' --fix %t', - \ 'read_temporary_file': 1, + \ . ale#Pad(l:options) + \ . ' --fix --stdin --stdin-filename %s', + \ 'read_temporary_file': 0, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/styler.vim b/sources_non_forked/ale/autoload/ale/fixers/styler.vim index 7ff3275c..1c7607bd 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/styler.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/styler.vim @@ -2,13 +2,13 @@ " Description: Fixing R files with styler. call ale#Set('r_styler_executable', 'Rscript') -call ale#Set('r_styler_options', 'tidyverse_style') +call ale#Set('r_styler_options', 'tidyverse_style()') function! ale#fixers#styler#Fix(buffer) abort return { \ 'command': 'Rscript --vanilla -e ' \ . '"suppressPackageStartupMessages(library(styler));' - \ . 'style_file(commandArgs(TRUE), style = ' + \ . 'style_file(commandArgs(TRUE), transformers = ' \ . ale#Var(a:buffer, 'r_styler_options') . ')"' \ . ' %t', \ 'read_temporary_file': 1, diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylua.vim b/sources_non_forked/ale/autoload/ale/fixers/stylua.vim new file mode 100644 index 00000000..6c3ba054 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/stylua.vim @@ -0,0 +1,27 @@ +" Author: Robert Liebowitz +" Description: https://github.com/johnnymorganz/stylua + +call ale#Set('lua_stylua_executable', 'stylua') +call ale#Set('lua_stylua_options', '') + +function! ale#fixers#stylua#GetCwd(buffer) abort + for l:possible_configfile in ['stylua.toml', '.stylua.toml'] + let l:config = ale#path#FindNearestFile(a:buffer, l:possible_configfile) + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + endfor + + return '%s:h' +endfunction + +function! ale#fixers#stylua#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_stylua_executable') + let l:options = ale#Var(a:buffer, 'lua_stylua_options') + + return { + \ 'cwd': ale#fixers#stylua#GetCwd(a:buffer), + \ 'command': ale#Escape(l:executable) . ale#Pad(l:options) . ' --stdin-filepath %s -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim b/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim index 304182b2..cc553b7d 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim @@ -6,7 +6,7 @@ call ale#Set('swift_swiftformat_use_global', get(g:, 'ale_use_global_executables call ale#Set('swift_swiftformat_options', '') function! ale#fixers#swiftformat#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'swift_swiftformat', [ + return ale#path#FindExecutable(a:buffer, 'swift_swiftformat', [ \ 'Pods/SwiftFormat/CommandLineTool/swiftformat', \ 'ios/Pods/SwiftFormat/CommandLineTool/swiftformat', \ 'swiftformat', diff --git a/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim b/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim new file mode 100644 index 00000000..08823a88 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim @@ -0,0 +1,18 @@ +call ale#Set('ruby_syntax_tree_options', '') +call ale#Set('ruby_syntax_tree_executable', 'stree') + +function! ale#fixers#syntax_tree#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_syntax_tree_executable') + let l:options = ale#Var(a:buffer, 'ruby_syntax_tree_options') + + return ale#ruby#EscapeExecutable(l:executable, 'stree') + \ . ' format' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +function! ale#fixers#syntax_tree#Fix(buffer) abort + return { + \ 'command': ale#fixers#syntax_tree#GetCommand(a:buffer), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/tidy.vim b/sources_non_forked/ale/autoload/ale/fixers/tidy.vim index 1af4120b..2c79e73a 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/tidy.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/tidy.vim @@ -5,7 +5,7 @@ call ale#Set('html_tidy_executable', 'tidy') call ale#Set('html_tidy_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#tidy#Fix(buffer) abort - let l:executable = ale#node#FindExecutable( + let l:executable = ale#path#FindExecutable( \ a:buffer, \ 'html_tidy', \ ['tidy'], diff --git a/sources_non_forked/ale/autoload/ale/fixers/tslint.vim b/sources_non_forked/ale/autoload/ale/fixers/tslint.vim index b352af3a..15768fd5 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/tslint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/tslint.vim @@ -16,7 +16,7 @@ function! ale#fixers#tslint#Fix(buffer) abort return { \ 'command': ale#node#Executable(a:buffer, l:executable) \ . l:tslint_config_option - \ . ' --fix %t', + \ . ' --outputAbsolutePaths --fix %t', \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/typstyle.vim b/sources_non_forked/ale/autoload/ale/fixers/typstyle.vim new file mode 100644 index 00000000..19c9399f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/typstyle.vim @@ -0,0 +1,20 @@ +" Author: Adrian Vollmer (computerfluesterer@protonmail.com) +" Description: Typst formatter using typstyle + +call ale#Set('typst_typstyle_executable', 'typstyle') +call ale#Set('typst_typstyle_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typst_typstyle_options', '') + +function! ale#fixers#typstyle#Fix(buffer) abort + let l:executable = ale#path#FindExecutable( + \ a:buffer, + \ 'typst_typstyle', + \ ['typstyle'] + \) + + let l:options = ale#Var(a:buffer, 'typst_typstyle_options') + + return { + \ 'command': ale#Escape(l:executable) . ' ' . l:options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/uncrustify.vim b/sources_non_forked/ale/autoload/ale/fixers/uncrustify.vim index ffec18ef..0e8271ec 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/uncrustify.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/uncrustify.vim @@ -4,13 +4,30 @@ call ale#Set('c_uncrustify_executable', 'uncrustify') call ale#Set('c_uncrustify_options', '') +let s:languages = { +\ 'c': 'C', +\ 'cpp': 'CPP', +\ 'cs': 'CS', +\ 'objc': 'OC', +\ 'objcpp': 'OC+', +\ 'd': 'D', +\ 'java': 'JAVA', +\ 'vala': 'VALA', +\ 'p': 'PAWN', +\} + +function! ale#fixers#uncrustify#Language(buffer) abort + return get(s:languages, &filetype, 'C') +endfunction + function! ale#fixers#uncrustify#Fix(buffer) abort let l:executable = ale#Var(a:buffer, 'c_uncrustify_executable') let l:options = ale#Var(a:buffer, 'c_uncrustify_options') return { \ 'command': ale#Escape(l:executable) - \ . ' --no-backup' - \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --no-backup ' + \ . '-l' . ale#Pad(ale#fixers#uncrustify#Language(a:buffer)) + \ . ale#Pad(l:options) \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim new file mode 100644 index 00000000..2e780318 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim @@ -0,0 +1,13 @@ +" Author: fiatjaf +" Description: Integration of `v fmt` with ALE. + +call ale#Set('v_vfmt_options', '') + +function! ale#fixers#vfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'v_v_executable') + let l:options = ale#Var(a:buffer, 'v_vfmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ' fmt' . ale#Pad(l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/xmllint.vim b/sources_non_forked/ale/autoload/ale/fixers/xmllint.vim index b14ffd36..4c74508b 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/xmllint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/xmllint.vim @@ -1,4 +1,4 @@ -" Author: Cyril Roelandt +" Author: Cyril Roelandt , jiz4oh " Description: Integration of xmllint with ALE. call ale#Set('xml_xmllint_executable', 'xmllint') @@ -7,8 +7,8 @@ call ale#Set('xml_xmllint_indentsize', 2) function! ale#fixers#xmllint#Fix(buffer) abort let l:executable = ale#Escape(ale#Var(a:buffer, 'xml_xmllint_executable')) - let l:filename = ale#Escape(bufname(a:buffer)) - let l:command = l:executable . ' --format ' . l:filename + + let l:command = l:executable . ' --format' let l:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize') @@ -24,6 +24,6 @@ function! ale#fixers#xmllint#Fix(buffer) abort endif return { - \ 'command': l:command + \ 'command': l:command . ' -' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/xo.vim b/sources_non_forked/ale/autoload/ale/fixers/xo.vim index 882350be..dcf4c737 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/xo.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/xo.vim @@ -1,23 +1,36 @@ " Author: Albert Marquez - https://github.com/a-marquez " Description: Fixing files with XO. -call ale#Set('javascript_xo_executable', 'xo') -call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('javascript_xo_options', '') +function! ale#fixers#xo#Fix(buffer) abort + let l:executable = ale#handlers#xo#GetExecutable(a:buffer) + let l:options = ale#handlers#xo#GetOptions(a:buffer) -function! ale#fixers#xo#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_xo', [ - \ 'node_modules/xo/cli.js', - \ 'node_modules/.bin/xo', - \]) + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ '%e --version', + \ {b, v -> ale#fixers#xo#ApplyFixForVersion(b, v, l:executable, l:options)} + \) endfunction -function! ale#fixers#xo#Fix(buffer) abort - let l:executable = ale#fixers#xo#GetExecutable(a:buffer) +function! ale#fixers#xo#ApplyFixForVersion(buffer, version, executable, options) abort + let l:executable = ale#node#Executable(a:buffer, a:executable) + let l:options = ale#Pad(a:options) + + " 0.30.0 is the first version with a working --stdin --fix + if ale#semver#GTE(a:version, [0, 30, 0]) + return { + \ 'command': l:executable + \ . ' --stdin --stdin-filename %s' + \ . ' --fix' + \ . l:options, + \} + endif return { - \ 'command': ale#node#Executable(a:buffer, l:executable) - \ . ' --fix %t', + \ 'command': l:executable + \ . ' --fix %t' + \ . l:options, \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim b/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim new file mode 100644 index 00000000..6654a25c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim @@ -0,0 +1,25 @@ +" Author: lyz-code +" Description: Fixing yaml files with yamlfix. + +call ale#Set('yaml_yamlfix_executable', 'yamlfix') +call ale#Set('yaml_yamlfix_options', '') +call ale#Set('yaml_yamlfix_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#yamlfix#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'yaml_yamlfix_options') + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'yaml_yamlfix', + \ ['yamlfix'], + \) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/yamlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/yamlfmt.vim new file mode 100644 index 00000000..e730832a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/yamlfmt.vim @@ -0,0 +1,20 @@ +" Author: https://github.com/Spixmaster +" Description: Format YAML files with yamlfmt. + +call ale#Set('yaml_yamlfmt_executable', 'yamlfmt') +call ale#Set('yaml_yamlfmt_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('yaml_yamlfmt_options', '') + +function! ale#fixers#yamlfmt#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'yaml_yamlfmt', + \ ['yamlfmt'] + \) + + let l:options = ale#Var(a:buffer, 'yaml_yamlfmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -in', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/yapf.vim b/sources_non_forked/ale/autoload/ale/fixers/yapf.vim index f04bb1f9..cbc3d46d 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/fixers/yq.vim b/sources_non_forked/ale/autoload/ale/fixers/yq.vim new file mode 100644 index 00000000..b9bf7007 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/yq.vim @@ -0,0 +1,22 @@ +call ale#Set('yaml_yq_executable', 'yq') +call ale#Set('yaml_yq_options', '') +call ale#Set('yaml_yq_filters', '.') + +function! ale#fixers#yq#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'yaml_yq_executable') +endfunction + +function! ale#fixers#yq#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'yaml_yq_options') + let l:filters = ale#Var(a:buffer, 'yaml_yq_filters') + + if empty(l:filters) + return 0 + endif + + return { + \ 'command': ale#Escape(ale#fixers#yq#GetExecutable(a:buffer)) + \ . ' ' . l:filters . ' ' + \ . l:options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/zigfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/zigfmt.vim new file mode 100644 index 00000000..b22e5b83 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/zigfmt.vim @@ -0,0 +1,14 @@ +scriptencoding utf-8 +" Author: Arash Mousavi +" Description: Official formatter for Zig. + +call ale#Set('zig_zigfmt_executable', 'zig') + +function! ale#fixers#zigfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'zig_zigfmt_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' fmt %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/floating_preview.vim b/sources_non_forked/ale/autoload/ale/floating_preview.vim new file mode 100644 index 00000000..3e1fabb8 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/floating_preview.vim @@ -0,0 +1,221 @@ +" Author: Jan-Grimo Sobez +" Author: Kevin Clark +" Author: D. Ben Knoble +" Author: Shaun Duncan +" Description: Floating preview window for showing whatever information in. + +" Precondition: exists('*nvim_open_win') || has('popupwin') + +function! ale#floating_preview#Show(lines, ...) abort + if !exists('*nvim_open_win') && !has('popupwin') + " no-custom-checks + echom 'Floating windows not supported in this vim instance.' + + return + endif + + let l:options = get(a:000, 0, {}) + + if has('nvim') + call s:NvimShow(a:lines, l:options) + else + call s:VimShow(a:lines, l:options) + endif + + return w:preview.id +endfunction + +function! s:NvimShow(lines, options) abort + " Remove the close autocmd so it doesn't happen mid update + augroup ale_floating_preview_window + autocmd! + augroup END + + " Only create a new window if we need it + if !exists('w:preview') || index(nvim_list_wins(), w:preview['id']) is# -1 + call s:NvimCreate(a:options) + else + call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:true) + endif + + " Execute commands in window context + if exists('*win_execute') + for l:command in get(a:options, 'commands', []) + call win_execute(w:preview['id'], l:command) + endfor + else + let l:parent_window = nvim_get_current_win() + + call nvim_set_current_win(w:preview['id']) + + for l:command in get(a:options, 'commands', []) + call execute(l:command) + endfor + + call nvim_set_current_win(l:parent_window) + endif + + " Return to parent context on move + augroup ale_floating_preview_window + autocmd! + + if g:ale_close_preview_on_insert + autocmd CursorMoved,TabLeave,WinLeave,BufWinLeave,WinScrolled,InsertEnter ++once call s:NvimClose() + else + autocmd CursorMoved,TabLeave,WinLeave,BufWinLeave,WinScrolled ++once call s:NvimClose() + endif + augroup END + + let [l:lines, l:width, l:height] = s:NvimPrepareWindowContent(a:lines) + + call nvim_win_set_width(w:preview['id'], l:width) + call nvim_win_set_height(w:preview['id'], l:height) + call nvim_buf_set_lines(w:preview['buffer'], 0, -1, v:false, l:lines) + call nvim_buf_set_option(w:preview['buffer'], 'modified', v:false) + call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:false) +endfunction + +function! s:VimShow(lines, options) abort + if g:ale_close_preview_on_insert + " Remove the close autocmd so it doesn't happen mid update + silent! autocmd! ale_floating_preview_window + endif + + " Only create a new window if we need it + if !exists('w:preview') || index(popup_list(), w:preview['id']) is# -1 + call s:VimCreate(a:options) + endif + + " Execute commands in window context + for l:command in get(a:options, 'commands', []) + call win_execute(w:preview['id'], l:command) + endfor + + call popup_settext(w:preview['id'], a:lines) + + if g:ale_close_preview_on_insert + augroup ale_floating_preview_window + autocmd! + autocmd InsertEnter * ++once call s:VimClose() + augroup END + endif +endfunction + +function! s:NvimPrepareWindowContent(lines) abort + let l:max_height = 10 + + let l:width = max(map(copy(a:lines), 'strdisplaywidth(v:val)')) + let l:height = min([len(a:lines), l:max_height]) + + return [a:lines[0:l:height-1], l:width, l:height] +endfunction + +function! s:NvimCreate(options) abort + let l:left = get(g:ale_floating_window_border, 0, '|') + let l:top = get(g:ale_floating_window_border, 1, '-') + + let l:popup_opts = extend({ + \ 'relative': 'cursor', + \ 'row': 1, + \ 'col': 0, + \ 'width': 42, + \ 'height': 4, + \ 'style': 'minimal', + \ 'border': empty(g:ale_floating_window_border) ? 'none' : [ + \ get(g:ale_floating_window_border, 2, '+'), + \ l:top, + \ get(g:ale_floating_window_border, 3, '+'), + \ get(g:ale_floating_window_border, 6, l:left), + \ get(g:ale_floating_window_border, 4, '+'), + \ get(g:ale_floating_window_border, 7, l:top), + \ get(g:ale_floating_window_border, 5, '+'), + \ l:left, + \ ], + \ }, s:GetPopupOpts()) + + let l:buffer = nvim_create_buf(v:false, v:false) + let l:winid = nvim_open_win(l:buffer, v:false, l:popup_opts) + + call nvim_buf_set_option(l:buffer, 'buftype', 'acwrite') + call nvim_buf_set_option(l:buffer, 'bufhidden', 'delete') + call nvim_buf_set_option(l:buffer, 'swapfile', v:false) + call nvim_buf_set_option(l:buffer, 'filetype', get(a:options, 'filetype', 'ale-preview')) + + let w:preview = {'id': l:winid, 'buffer': l:buffer} +endfunction + +function! s:VimCreate(options) abort + " default options + let l:popup_opts = extend({ + \ 'line': 'cursor+1', + \ 'col': 'cursor', + \ 'drag': v:true, + \ 'resize': v:true, + \ 'close': 'button', + \ 'padding': [0, 1, 0, 1], + \ 'border': [], + \ 'borderchars': empty(g:ale_floating_window_border) ? [' '] : [ + \ get(g:ale_floating_window_border, 1, '-'), + \ get(g:ale_floating_window_border, 6, '|'), + \ get(g:ale_floating_window_border, 7, '-'), + \ get(g:ale_floating_window_border, 0, '|'), + \ get(g:ale_floating_window_border, 2, '+'), + \ get(g:ale_floating_window_border, 3, '+'), + \ get(g:ale_floating_window_border, 4, '+'), + \ get(g:ale_floating_window_border, 5, '+'), + \ ], + \ 'moved': 'any', + \ }, s:GetPopupOpts()) + + let l:popup_id = popup_create([], l:popup_opts) + call setbufvar(winbufnr(l:popup_id), '&filetype', get(a:options, 'filetype', 'ale-preview')) + let w:preview = {'id': l:popup_id} +endfunction + +function! s:NvimClose() abort + let l:mode = mode() + let l:restore_visual = l:mode is# 'v' || l:mode is# 'V' || l:mode is# "\" + + if !exists('w:preview') + return + endif + + call setbufvar(w:preview['buffer'], '&modified', 0) + + if win_id2win(w:preview['id']) > 0 + execute win_id2win(w:preview['id']).'wincmd c' + endif + + unlet w:preview + + if l:restore_visual + normal! gv + endif +endfunction + +function! s:VimClose() abort + if !exists('w:preview') + return + endif + + call popup_close(w:preview['id']) + unlet w:preview +endfunction + +" get either the results of a function callback or dictionary for popup overrides +function! s:GetPopupOpts() abort + if exists('g:ale_floating_preview_popup_opts') + let l:ref = g:ale_floating_preview_popup_opts + + if type(l:ref) is# v:t_dict + return l:ref + elseif type(l:ref) is# v:t_string + try + return function(l:ref)() + catch /E700/ + endtry + endif + endif + + return {} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/go.vim b/sources_non_forked/ale/autoload/ale/go.vim index 4a21e596..bce85a87 100644 --- a/sources_non_forked/ale/autoload/ale/go.vim +++ b/sources_non_forked/ale/autoload/ale/go.vim @@ -42,3 +42,17 @@ function! ale#go#EnvString(buffer) abort return l:env endfunction + +function! ale#go#GetGoPathExecutable(suffix) abort + let l:prefix = $GOPATH + + if !empty($GOPATH) + let l:prefix = $GOPATH + elseif has('win32') + let l:prefix = $USERPROFILE . '/go' + else + let l:prefix = $HOME . '/go' + endif + + return ale#path#Simplify(l:prefix . '/' . a:suffix) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/gradle.vim b/sources_non_forked/ale/autoload/ale/gradle.vim index dc377fb9..ba1add4d 100644 --- a/sources_non_forked/ale/autoload/ale/gradle.vim +++ b/sources_non_forked/ale/autoload/ale/gradle.vim @@ -50,18 +50,25 @@ function! ale#gradle#FindExecutable(buffer) abort return '' endfunction -" Given a buffer number, build a command to print the classpath of the root -" project. Returns an empty string if cannot build the command. +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Gradle is not detected. function! ale#gradle#BuildClasspathCommand(buffer) abort let l:executable = ale#gradle#FindExecutable(a:buffer) - let l:project_root = ale#gradle#FindProjectRoot(a:buffer) - if !empty(l:executable) && !empty(l:project_root) - return ale#path#CdString(l:project_root) - \ . ale#Escape(l:executable) - \ . ' -I ' . ale#Escape(s:init_path) - \ . ' -q printClasspath' + if !empty(l:executable) + let l:project_root = ale#gradle#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) + \ . ' -I ' . ale#Escape(s:init_path) + \ . ' -q printClasspath' + \] + endif endif - return '' + return ['', ''] endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/alex.vim b/sources_non_forked/ale/autoload/ale/handlers/alex.vim index 190a7f86..1a92bd14 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/alex.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/alex.vim @@ -3,7 +3,7 @@ scriptencoding utf-8 " Description: Error handling for errors in alex output format function! ale#handlers#alex#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'alex', [ + return ale#path#FindExecutable(a:buffer, 'alex', [ \ 'node_modules/.bin/alex', \ 'node_modules/alex/cli.js', \]) @@ -11,8 +11,9 @@ endfunction function! ale#handlers#alex#CreateCommandCallback(flags) abort return {b -> ale#node#Executable(b, ale#handlers#alex#GetExecutable(b)) - \ . ' %s ' - \ . a:flags} + \ . ' --stdin ' + \ . a:flags + \} endfunction function! ale#handlers#alex#Handle(buffer, lines) abort @@ -38,6 +39,7 @@ endfunction " Define a linter for a specific filetype. Accept flags to adapt to the filetype. " no flags treat input as markdown " --html treat input as HTML +" --mdx treat input as MDX " --text treat input as plaintext function! ale#handlers#alex#DefineLinter(filetype, flags) abort call ale#Set('alex_executable', 'alex') @@ -49,6 +51,5 @@ function! ale#handlers#alex#DefineLinter(filetype, flags) abort \ 'command': ale#handlers#alex#CreateCommandCallback(a:flags), \ 'output_stream': 'stderr', \ 'callback': 'ale#handlers#alex#Handle', - \ 'lint_file': 1, \}) endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/atools.vim b/sources_non_forked/ale/autoload/ale/handlers/atools.vim new file mode 100644 index 00000000..c273fc40 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/atools.vim @@ -0,0 +1,41 @@ +" Author: Leo +" Description: Handlers for output expected from atools + +function! ale#handlers#atools#Handle(buffer, lines) abort + " Format: SEVERITY:[TAG]:PATH:LINENUM:MSG + " Example: MC:[AL5]:./APKBUILD:12:variable set to empty string: install= + let l:pattern = '\([^:]\+\):\([^:]\+\):\([^:]\+\):\(\d\+\):\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " We are expected to receive 2 characters, the first character + " can be 'S', 'I', 'M' 'T', which are respectively: + " Serious (Error) + " Important (Error) + " Minor (Warning) + " Style (Warning) + " + " The second character can be either 'C' or 'P', which are respectively: + " Certain (Error) + " Possible (Warning) + let l:severity = matchstr(l:match[1], '^.') + let l:certainty = matchstr(l:match[1], '.$') + + let l:type = 'E' + " If the tag returns 'Minor' or 'Style' or is 'Possible' + " then return a warning + + if l:severity is# 'M' || l:severity is# 'T' || l:certainty is# 'P' + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': l:match[4] + 0, + \ 'text': l:match[5], + \ 'type': l:type, + \ 'code': matchstr(l:match[2], 'AL[0-9]*'), + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/biome.vim b/sources_non_forked/ale/autoload/ale/handlers/biome.vim new file mode 100644 index 00000000..b22c1c46 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/biome.vim @@ -0,0 +1,58 @@ +" Author: Filip Gospodinov +" Description: Functions for working with biome, for checking or fixing files. + +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, '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', + \]) +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/c3lsp.vim b/sources_non_forked/ale/autoload/ale/handlers/c3lsp.vim new file mode 100644 index 00000000..2763f3db --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/c3lsp.vim @@ -0,0 +1,19 @@ +scriptencoding utf-8 +" Author: Koni Marti +" Description: Utilities for c3lsp + +function! ale#handlers#c3lsp#GetProjectRoot(buffer) abort + let l:config = ale#path#FindNearestFile(a:buffer, 'project.json') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + return expand('#' . a:buffer . ':p:h') +endfunction + +function! ale#handlers#c3lsp#GetInitOpts(buffer, init_options_var) abort + let l:init_options = {} + + return extend(l:init_options, ale#Var(a:buffer, a:init_options_var)) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/cairo.vim b/sources_non_forked/ale/autoload/ale/handlers/cairo.vim new file mode 100644 index 00000000..41029c8d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/cairo.vim @@ -0,0 +1,41 @@ +" Author: 0xhyoga <0xhyoga@gmx.com>, +" Description: This file implements handlers specific to Cairo +" +function! ale#handlers#cairo#HandleCairoErrors(buffer, lines) abort + " Matches patterns like the following: + " Error: Expected ';' but got '(' + " --> /path/to/file/file.cairo:1:10:) + let l:pattern = '\v(error|warning): (.*)$' + let l:line_and_column_pattern = '\v\.cairo:(\d+):(\d+)' + let l:exclude_pattern = '\vcould not compile.*' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + let l:match = matchlist(l:line, l:line_and_column_pattern) + + if len(l:match) > 0 + let l:index = len(l:output) - 1 + let l:output[l:index]['lnum'] = l:match[1] + 0 + let l:output[l:index]['col'] = l:match[2] + 0 + endif + else + let l:text = l:match[2] + + if l:text !~# l:exclude_pattern + let l:isError = l:match[1] is? 'Error' + + call add(l:output, { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:text, + \ 'type': l:isError ? 'E' : 'W', + \}) + endif + endif + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ccls.vim b/sources_non_forked/ale/autoload/ale/handlers/ccls.vim index 1e2aa318..290f5852 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/ccls.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/ccls.vim @@ -17,3 +17,10 @@ function! ale#handlers#ccls#GetProjectRoot(buffer) abort " Fall back on default project root detection. return ale#c#FindProjectRoot(a:buffer) endfunction + +function! ale#handlers#ccls#GetInitOpts(buffer, init_options_var) abort + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:init_options = empty(l:build_dir) ? {} : {'compilationDatabaseDirectory': l:build_dir} + + return extend(l:init_options, ale#Var(a:buffer, a:init_options_var)) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim index 6d8fa15d..150bb007 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim @@ -1,10 +1,9 @@ " Description: Handle errors for cppcheck. -function! ale#handlers#cppcheck#GetCdCommand(buffer) abort +function! ale#handlers#cppcheck#GetCwd(buffer) abort let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer) - let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : '' - return l:cd_command + return !empty(l:dir) ? l:dir : '' endfunction function! ale#handlers#cppcheck#GetBufferPathIncludeOptions(buffer) abort @@ -20,6 +19,18 @@ function! ale#handlers#cppcheck#GetBufferPathIncludeOptions(buffer) abort endfunction function! ale#handlers#cppcheck#GetCompileCommandsOptions(buffer) abort + " The compile_commands.json doesn't apply to headers and cppheck will + " bail out if it cannot find a file matching the filter, below. Skip out + " now, for headers. Also, suppress FPs; cppcheck is not meant to + " process lone header files. + let b:buffer_name = bufname(a:buffer) + let b:file_extension = fnamemodify(b:buffer_name, ':e') + + if b:file_extension is# 'h' || b:file_extension is# 'hpp' + return ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) + \ . ' --suppress=unusedStructMember' + endif + " If the current buffer is modified, using compile_commands.json does no " good, so include the file's directory instead. It's not quite as good as " using --project, but is at least equivalent to running cppcheck on this @@ -36,24 +47,40 @@ function! ale#handlers#cppcheck#GetCompileCommandsOptions(buffer) abort " then use the file to set up import paths, etc. let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer) + " By default, cppcheck processes every config in compile_commands.json. + " Use --file-filter to limit to just the buffer file. return !empty(l:json_path) - \ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ]) + \ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ]) . ' --file-filter=' . ale#Escape(bufname(a:buffer)) \ : '' endfunction function! ale#handlers#cppcheck#HandleCppCheckFormat(buffer, lines) abort " Look for lines like the following. " - " [test.cpp:5]: (error) Array 'a[10]' accessed at index 10, which is out of bounds - let l:pattern = '\v^\[(.+):(\d+)\]: \(([a-z]+)\) (.+)$' + "test.cpp:974:6: error:inconclusive Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\ + " n[3]=3; + " ^ + "" OR if cppcheck doesn't support {column} or {inconclusive:text}: + "test.cpp:974:{column}: error:{inconclusive:inconclusive} Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\ + " n[3]=3; + " ^ + " + "" OR if using the misra addon: + "test.c:1:16: style: misra violation (use --rule-texts= to get proper output) [misra-c2012-2.7]\' + "void test( int parm ) {} + " ^ + let l:pattern = '\v(\f+):(\d+):(\d+|\{column\}): (\w+):(\{inconclusive:inconclusive\})? ?(.*) \[(%(\w[-.]?)+)\]\' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) if ale#path#IsBufferPath(a:buffer, l:match[1]) call add(l:output, { - \ 'lnum': str2nr(l:match[2]), - \ 'type': l:match[3] is# 'error' ? 'E' : 'W', - \ 'text': l:match[4], + \ 'lnum': str2nr(l:match[2]), + \ 'col': match(l:match[3],'{column}') >= 0 ? 1 : str2nr(l:match[3]), + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'sub_type': l:match[4] is# 'style' ? 'style' : '', + \ 'text': l:match[6], + \ 'code': l:match[7] \}) endif endfor diff --git a/sources_non_forked/ale/autoload/ale/handlers/cspell.vim b/sources_non_forked/ale/autoload/ale/handlers/cspell.vim new file mode 100644 index 00000000..a59002bb --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/cspell.vim @@ -0,0 +1,78 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: Define a handler function for cspell's output + +function! ale#handlers#cspell#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, + \ 'cspell', [ + \ 'node_modules/.bin/cspell', + \ 'node_modules/cspell/bin.js', + \ ] + \) +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 + +function! ale#handlers#cspell#Handle(buffer, lines) abort + " Look for lines like the following: + " + " /home/user/repos/ale/README.md:3:128 - Unknown word (Neovim) + " match1: 3 + " match2: 128 + " match3: Unknown word (Neovim) + " match4: Neovim + let l:pattern = '\v^.*:(\d+):(\d+) - ([^\(]+\(([^\)]+)\).*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'end_col': l:match[2] + len(l:match[4]) - 1, + \ 'text': l:match[3], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +function! ale#handlers#cspell#DefineLinter(filetype) abort + call ale#Set('cspell_executable', 'cspell') + call ale#Set('cspell_options', '') + call ale#Set('cspell_use_global', get(g:, 'ale_use_global_executables', 0)) + + call ale#linter#Define(a:filetype, { + \ 'name': 'cspell', + \ 'executable': function('ale#handlers#cspell#GetExecutable'), + \ 'command': function('ale#handlers#cspell#GetCommand'), + \ 'callback': 'ale#handlers#cspell#Handle', + \}) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/deadnix.vim b/sources_non_forked/ale/autoload/ale/handlers/deadnix.vim new file mode 100644 index 00000000..8f03f38e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/deadnix.vim @@ -0,0 +1,33 @@ +function! ale#handlers#deadnix#Handle(buffer, lines) abort + let l:output = [] + + for l:line in a:lines + try + let l:file = ale#util#FuzzyJSONDecode(l:line, v:null) + catch + continue + endtry + + if type(l:file) isnot v:t_dict + continue + endif + + for l:error in l:file['results'] + try + let l:ale_error = { + \ 'lnum': l:error['line'], + \ 'col': l:error['column'], + \ 'end_col': l:error['endColumn'], + \ 'text': l:error['message'], + \ 'type': 'W', + \} + catch + continue + endtry + + call add(l:output, l:ale_error) + endfor + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/deno.vim b/sources_non_forked/ale/autoload/ale/handlers/deno.vim new file mode 100644 index 00000000..1770559d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/deno.vim @@ -0,0 +1,87 @@ +" Author: Mohammed Chelouti - https://github.com/motato1 +" Arnold Chand +" Description: Handler functions for Deno. + +call ale#Set('deno_executable', 'deno') +call ale#Set('deno_unstable', 0) +call ale#Set('deno_import_map', 'import_map.json') +call ale#Set('deno_lsp_project_root', '') + +function! ale#handlers#deno#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'deno_executable') +endfunction + +" Find project root for Deno's language server. +" +" Deno projects do not require a project or configuration file at the project root. +" This means the root directory has to be guessed, +" unless it is explicitly specified by the user. +" +" The project root is determined by ... +" 1. using a user-specified value from deno_lsp_project_root +" 2. looking for common top-level files/dirs +" 3. using the buffer's directory +function! ale#handlers#deno#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'deno_lsp_project_root') + + if !empty(l:project_root) + return l:project_root + endif + + let l:possible_project_roots = [ + \ 'deno.json', + \ 'deno.jsonc', + \ 'tsconfig.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 + +" Initialization Options for deno, for javascript and typescript +function! ale#handlers#deno#GetInitializationOptions(buffer) abort + let l:options = { + \ 'enable': v:true, + \ 'lint': v:true, + \ 'unstable': v:false, + \ 'importMap': ale#path#FindNearestFile(a:buffer, 'import_map.json'), + \ } + + if ale#Var(a:buffer, 'deno_unstable') + let l:options.unstable = v:true + endif + + " Look for a value set using the historical option name. + let l:import_map = getbufvar( + \ a:buffer, + \ 'ale_deno_importMap', + \ get(g:, 'ale_deno_importMap', '') + \) + + if empty(l:import_map) + let l:import_map = ale#Var(a:buffer, 'deno_import_map') + endif + + if !empty(l:import_map) + let l:options.importMap = ale#path#FindNearestFile(a:buffer, l:import_map) + endif + + return l:options +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/djlint.vim b/sources_non_forked/ale/autoload/ale/handlers/djlint.vim new file mode 100644 index 00000000..57015248 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/djlint.vim @@ -0,0 +1,64 @@ +" Author: Vivian De Smedt , Adrian Vollmer +" Description: Adds support for djlint +" +function! ale#handlers#djlint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'html_djlint_executable') +endfunction + +function! ale#handlers#djlint#GetCommand(buffer) abort + let l:executable = ale#handlers#djlint#GetExecutable(a:buffer) + + let l:options = ale#Var(a:buffer, 'html_djlint_options') + + let l:profile = '' + let l:filetypes = split(getbufvar(a:buffer, '&filetype'), '\.') + + " Append the --profile flag depending on the current filetype (unless it's + " already set in g:html_djlint_options). + if match(l:options, '--profile') == -1 + let l:djlint_profiles = { + \ 'html': 'html', + \ 'htmldjango': 'django', + \ 'jinja': 'jinja', + \ 'nunjucks': 'nunjucks', + \ 'handlebars': 'handlebars', + \ 'gohtmltmpl': 'golang', + \ 'htmlangular': 'angular', + \} + + for l:filetype in l:filetypes + if has_key(l:djlint_profiles, l:filetype) + let l:profile = l:djlint_profiles[l:filetype] + break + endif + endfor + endif + + if !empty(l:profile) + let l:options = (!empty(l:options) ? l:options . ' ' : '') . '--profile ' . l:profile + endif + + return ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' %s' +endfunction + +function! ale#handlers#djlint#Handle(buffer, lines) abort + let l:output = [] + let l:pattern = '\v^([A-Z]\d+) (\d+):(\d+) (.*)$' + let l:i = 0 + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:i += 1 + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'vcol': 1, + \ 'text': l:match[4], + \ 'code': l:match[1], + \ 'type': 'W', + \} + call add(l:output, l:item) + endfor + + return l:output +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 +" 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 4d533ff2..eea06f51 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim @@ -1,6 +1,12 @@ " Author: w0rp " Description: Functions for working with eslint, for checking or fixing files. +let s:executables = [ +\ '.yarn/sdks/eslint/bin/eslint.js', +\ 'node_modules/.bin/eslint_d', +\ 'node_modules/eslint/bin/eslint.js', +\ 'node_modules/.bin/eslint', +\] let s:sep = has('win32') ? '\' : '/' call ale#Set('javascript_eslint_options', '') @@ -12,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', @@ -30,11 +40,12 @@ function! ale#handlers#eslint#FindConfig(buffer) abort endfunction function! ale#handlers#eslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_eslint', [ - \ 'node_modules/.bin/eslint_d', - \ 'node_modules/eslint/bin/eslint.js', - \ 'node_modules/.bin/eslint', - \]) + return ale#path#FindExecutable(a:buffer, 'javascript_eslint', s:executables) +endfunction + +" Given a buffer, return an appropriate working directory for ESLint. +function! ale#handlers#eslint#GetCwd(buffer) abort + return ale#path#Dirname(ale#handlers#eslint#FindConfig(a:buffer)) endfunction function! ale#handlers#eslint#GetCommand(buffer) abort @@ -84,11 +95,14 @@ function! s:CheckForBadConfig(buffer, lines) abort endfunction function! s:parseJSON(buffer, lines) abort - try - let l:parsed = json_decode(a:lines[-1]) - catch - return [] - endtry + let l:parsed = [] + + for l:line in a:lines + try + let l:parsed = extend(l:parsed, json_decode(l:line)) + catch + endtry + endfor if type(l:parsed) != v:t_list || empty(l:parsed) return [] diff --git a/sources_non_forked/ale/autoload/ale/handlers/fecs.vim b/sources_non_forked/ale/autoload/ale/handlers/fecs.vim index 5362edb9..064b927e 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/fecs.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/fecs.vim @@ -9,7 +9,7 @@ function! ale#handlers#fecs#GetCommand(buffer) abort endfunction function! ale#handlers#fecs#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_fecs', [ + return ale#path#FindExecutable(a:buffer, 'javascript_fecs', [ \ 'node_modules/.bin/fecs', \ 'node_modules/fecs/bin/fecs', \]) diff --git a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim index ec16b977..0b37c98a 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim @@ -10,7 +10,7 @@ let s:pragma_error = '#pragma once in main file' " :8:5: warning: conversion lacks type at end of format [-Wformat=] " :10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’) " -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004] -let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$' +let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+)?:?(\d+)?:? ([^:]+): (.+)$' let s:inline_pattern = '\v inlined from .* at \:(\d+):(\d+):$' function! s:IsHeaderFile(filename) abort @@ -117,6 +117,23 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort if !empty(l:output) if !has_key(l:output[-1], 'detail') let l:output[-1].detail = l:output[-1].text + + " handle macro expansion errors/notes + if l:match[5] =~? '^in expansion of macro ‘\w*\w’$' + " if the macro expansion is in the file we're in, add + " the lnum and col keys to the previous error + if l:match[1] is# '' + \ && !has_key(l:output[-1], 'col') + let l:output[-1].lnum = str2nr(l:match[2]) + let l:output[-1].col = str2nr(l:match[3]) + else + " the error is not in the current file, and since + " macro expansion errors don't show the full path to + " the error from the current file, we have to just + " give out a generic error message + let l:output[-1].text = 'Error found in macro expansion. See :ALEDetail' + endif + endif endif let l:output[-1].detail = l:output[-1].detail . "\n" diff --git a/sources_non_forked/ale/autoload/ale/handlers/go.vim b/sources_non_forked/ale/autoload/ale/handlers/go.vim index f17cd862..c969669d 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/go.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/go.vim @@ -6,9 +6,12 @@ " " Author: Ben Paxton " Description: moved to generic Golang file from govet +" +" Author: mostfunkyduck +" Description: updated to work with go 1.14 function! ale#handlers#go#Handler(buffer, lines) abort - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? ?(.+)$' + let l:pattern = '\v^%(vet: )?([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? ?(.+)$' let l:output = [] let l:dir = expand('#' . a:buffer . ':p:h') diff --git a/sources_non_forked/ale/autoload/ale/handlers/haskell.vim b/sources_non_forked/ale/autoload/ale/handlers/haskell.vim index 3613b1bb..70a3a7ea 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/haskell.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/haskell.vim @@ -19,6 +19,16 @@ let s:temp_regex_prefix = \ . substitute(s:temp_dir, '\\', '\\\\', 'g') \ . '\.\{-}' +function! s:PanicOutput(lines) abort + return [{ + \ 'lnum': 1, + \ 'col': 1, + \ 'text': 'ghc panic!', + \ 'type': 'E', + \ 'detail' : join(a:lines, "\n"), + \}] +endfunction + function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort " Look for lines like the following. " @@ -34,6 +44,14 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort let l:corrected_lines = [] + " If ghc panic error, put the whole message in details and exit. + let l:panic_position = match(a:lines,'ghc: panic!') + let l:panic_end = match(a:lines,'Please report this as a GHC bug:') + + if l:panic_position >= 0 + return s:PanicOutput(a:lines[l:panic_position : l:panic_end]) + endif + " Group the lines into smaller lists. for l:line in a:lines if len(matchlist(l:line, l:pattern)) > 0 diff --git a/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim b/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim new file mode 100644 index 00000000..d45f86e1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim @@ -0,0 +1,73 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#Set('hdl_checker_executable', 'hdl_checker') +call ale#Set('hdl_checker_config_file', has('unix') ? '.hdl_checker.config' : '_hdl_checker.config') +call ale#Set('hdl_checker_options', '') + +" Use this as a function so we can mock it on testing. Need to do this because +" test files are inside /testplugin (which refers to the ale repo), which will +" always have a .git folder +function! ale#handlers#hdl_checker#IsDotGit(path) abort + return ! empty(a:path) && isdirectory(a:path) +endfunction + +" Should return (in order of preference) +" 1. Nearest config file +" 2. Nearest .git directory +" 3. The current path +function! ale#handlers#hdl_checker#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile( + \ a:buffer, + \ ale#Var(a:buffer, 'hdl_checker_config_file')) + + if !empty(l:project_root) + return fnamemodify(l:project_root, ':h') + endif + + " Search for .git to use as root + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + + if ale#handlers#hdl_checker#IsDotGit(l:project_root) + return fnamemodify(l:project_root, ':h:h') + endif + + return '' +endfunction + +function! ale#handlers#hdl_checker#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'hdl_checker_executable') +endfunction + +function! ale#handlers#hdl_checker#GetCommand(buffer) abort + let l:command = ale#Escape(ale#handlers#hdl_checker#GetExecutable(a:buffer)) . ' --lsp' + + " Add extra parameters only if config has been set + let l:options = ale#Var(a:buffer, 'hdl_checker_options') + + if ! empty(l:options) + let l:command = l:command . ' ' . l:options + endif + + return l:command +endfunction + +" To allow testing +function! ale#handlers#hdl_checker#GetInitOptions(buffer) abort + return {'project_file': ale#Var(a:buffer, 'hdl_checker_config_file')} +endfunction + +" Define the hdl_checker linter for a given filetype. +function! ale#handlers#hdl_checker#DefineLinter(filetype) abort + call ale#linter#Define(a:filetype, { + \ 'name': 'hdl_checker', + \ 'aliases': ['hdl-checker'], + \ 'lsp': 'stdio', + \ 'language': a:filetype, + \ 'executable': function('ale#handlers#hdl_checker#GetExecutable'), + \ 'command': function('ale#handlers#hdl_checker#GetCommand'), + \ 'project_root': function('ale#handlers#hdl_checker#GetProjectRoot'), + \ 'initialization_options': function('ale#handlers#hdl_checker#GetInitOptions'), + \ }) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/inko.vim b/sources_non_forked/ale/autoload/ale/handlers/inko.vim new file mode 100644 index 00000000..73f06871 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/inko.vim @@ -0,0 +1,37 @@ +" Author: Yorick Peterse +" Description: output handlers for the Inko JSON format + +function! ale#handlers#inko#GetType(severity) abort + if a:severity is? 'warning' + return 'W' + endif + + return 'E' +endfunction + +function! ale#handlers#inko#Handle(buffer, lines) abort + try + let l:errors = json_decode(join(a:lines, '')) + catch + return [] + endtry + + if empty(l:errors) + return [] + endif + + let l:output = [] + let l:dir = expand('#' . a:buffer . ':p:h') + + for l:error in l:errors + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:error['file']), + \ 'lnum': l:error['line'], + \ 'col': l:error['column'], + \ 'text': l:error['message'], + \ 'type': ale#handlers#inko#GetType(l:error['level']), + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim b/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim index ad999485..77e7ab66 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim @@ -13,7 +13,7 @@ function! ale#handlers#ktlint#GetCommand(buffer) abort return ale#Escape(l:executable) \ . (empty(l:options) ? '' : ' ' . l:options) \ . (empty(l:rulesets) ? '' : ' ' . l:rulesets) - \ . ' %t' + \ . ' --stdin' endfunction function! ale#handlers#ktlint#GetRulesets(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim b/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim index 10e049df..73974ceb 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim @@ -2,6 +2,7 @@ " Description: languagetool for markdown files " call ale#Set('languagetool_executable', 'languagetool') +call ale#Set('languagetool_options', '--autoDetect') function! ale#handlers#languagetool#GetExecutable(buffer) abort return ale#Var(a:buffer, 'languagetool_executable') @@ -9,8 +10,10 @@ endfunction function! ale#handlers#languagetool#GetCommand(buffer) abort let l:executable = ale#handlers#languagetool#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'languagetool_options') - return ale#Escape(l:executable) . ' --autoDetect %s' + return ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) . ' %s' endfunction function! ale#handlers#languagetool#HandleOutput(buffer, lines) abort diff --git a/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim b/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim index daaa1d66..6c273bd0 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim @@ -2,15 +2,22 @@ " Description: Adds support for markdownlint function! ale#handlers#markdownlint#Handle(buffer, lines) abort - let l:pattern=': \(\d*\): \(MD\d\{3}\)\(\/\)\([A-Za-z0-9-]\+\)\(.*\)$' + let l:pattern=': \?\(\d\+\)\(:\(\d\+\)\?\)\? \(MD\d\{3}/[A-Za-z0-9-/]\+\) \(.*\)$' let l:output=[] for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { + let l:result = ({ \ 'lnum': l:match[1] + 0, - \ 'text': '(' . l:match[2] . l:match[3] . l:match[4] . ')' . l:match[5], + \ 'code': l:match[4], + \ 'text': l:match[5], \ 'type': 'W', \}) + + if len(l:match[3]) > 0 + let l:result.col = (l:match[3] + 0) + endif + + call add(l:output, l:result) endfor return l:output diff --git a/sources_non_forked/ale/autoload/ale/handlers/naga.vim b/sources_non_forked/ale/autoload/ale/handlers/naga.vim new file mode 100644 index 00000000..6480aba6 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/naga.vim @@ -0,0 +1,30 @@ +" Author: rhysd +" Description: Handle errors for naga-cli. + +function! ale#handlers#naga#Handle(buffer, lines) abort + let l:errors = [] + let l:current_error = v:null + + for l:line in a:lines + if l:line =~# '^error: ' + let l:text = l:line[7:] + let l:current_error = { 'text': l:text, 'type': 'E' } + continue + endif + + if l:current_error isnot v:null + let l:matches = matchlist(l:line, '\v:(\d+):(\d+)$') + + if !empty(l:matches) + let l:current_error.lnum = str2nr(l:matches[1]) + let l:current_error.col = str2nr(l:matches[2]) + call add(l:errors, l:current_error) + let l:current_error = v:null + continue + endif + endif + endfor + + return l:errors +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim b/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim new file mode 100644 index 00000000..2738ea2b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim @@ -0,0 +1,30 @@ +" Author: Risto Stevcev +" Description: Handlers for the official OCaml language server + +let s:language_id_of_filetype = { +\ 'menhir': 'ocaml.menhir', +\ 'ocaml': 'ocaml', +\ 'ocamlinterface': 'ocaml.interface', +\ 'ocamllex': 'ocaml.lex' +\} + +function! ale#handlers#ocamllsp#GetExecutable(buffer) abort + return 'ocamllsp' +endfunction + +function! ale#handlers#ocamllsp#GetCommand(buffer) abort + let l:executable = ale#handlers#ocamllsp#GetExecutable(a:buffer) + let l:ocaml_ocamllsp_use_opam = ale#Var(a:buffer, 'ocaml_ocamllsp_use_opam') + + return l:ocaml_ocamllsp_use_opam ? 'opam config exec -- ' . l:executable : l:executable +endfunction + +function! ale#handlers#ocamllsp#GetLanguage(buffer) abort + return s:language_id_of_filetype[getbufvar(a:buffer, '&filetype')] +endfunction + +function! ale#handlers#ocamllsp#GetProjectRoot(buffer) abort + let l:dune_project_file = ale#path#FindNearestFile(a:buffer, 'dune-project') + + return !empty(l:dune_project_file) ? fnamemodify(l:dune_project_file, ':h') : '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ols.vim b/sources_non_forked/ale/autoload/ale/handlers/ols.vim index 74130a26..c292c6d9 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/ols.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/ols.vim @@ -4,7 +4,7 @@ function! ale#handlers#ols#GetExecutable(buffer) abort let l:ols_setting = ale#handlers#ols#GetLanguage(a:buffer) . '_ols' - return ale#node#FindExecutable(a:buffer, l:ols_setting, [ + return ale#path#FindExecutable(a:buffer, l:ols_setting, [ \ 'node_modules/.bin/ocaml-language-server', \]) endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/openscad.vim b/sources_non_forked/ale/autoload/ale/handlers/openscad.vim new file mode 100644 index 00000000..33eee31c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/openscad.vim @@ -0,0 +1,73 @@ +scriptencoding utf-8LE +" Description: This file defines a handler function for linting OpenSCAD files +" with SCA2D + +function! ale#handlers#openscad#SCA2D_callback(buffer, lines) abort + " Example output:: + " foo.scad:3:1: W2001: Variable `unused` overwritten within scope. + " foo.scad:1:1: F0001: Cannot read file due to syntax error: + " - No terminal matches '}' in the current parser context, at line 1 col 36 + let l:filename_re = '^\([^:]*\):' + let l:linenum_re = '\([0-9]*\):' + let l:colnum_re = '\([0-9]*\):' + let l:err_id = '\([IWEFU][0-9]\+\):' + let l:err_msg = '\(.*\)' + let l:pattern = filename_re . + \ linenum_re . + \ colnum_re . + \ ' ' . + \ err_id . + \ ' ' . + \ err_msg + + let l:result = [] + let l:idx = 0 + + for l:line in a:lines + let l:matches = matchlist(line, pattern) + + if len(matches) > 0 + " option: Info, Warning, Error, Fatal, Unknown + if index(['I', 'W'], matches[4][0]) >= 0 + let l:type = 'W' + else + let l:type = 'E' + endif + + let l:lnum = matches[2] + let l:col = matches[3] + let l:text = matches[5] + + " Better locations for some syntax errors + if matches[4][0] is# 'F' + let l:syntax_error_re = '^\(.*\), at line \([0-9]\+\) col \([0-9]\+\)$' + let l:next_line = a:lines[idx+1] + let l:syn_err_matches = matchlist(l:next_line, l:syntax_error_re) + + if len(syn_err_matches) > 0 + let l:text = l:text . l:syn_err_matches[1] + let l:lnum = l:syn_err_matches[2] + let l:col = l:syn_err_matches[3] + else + let l:text = l:next_line + endif + endif + + let l:element = { + \ 'lnum': str2nr(l:lnum), + \ 'col': str2nr(l:col), + \ 'text': l:text, + \ 'detail': l:matches[4] . ': ' . l:text, + \ 'filename': fnamemodify(matches[1], ':p'), + \ 'type': l:type + \ } + + call add(l:result, l:element) + endif + + let l:idx += 1 + endfor + + return result + +endfun diff --git a/sources_non_forked/ale/autoload/ale/handlers/ruby.vim b/sources_non_forked/ale/autoload/ale/handlers/ruby.vim index c28b8b75..7a1c5765 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/ruby.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/ruby.vim @@ -36,11 +36,3 @@ endfunction function! ale#handlers#ruby#HandleSyntaxErrors(buffer, lines) abort return s:HandleSyntaxError(a:buffer, a:lines) endfunction - -function! ale#handlers#ruby#EscapeExecutable(executable, bundle_exec) abort - let l:exec_args = a:executable =~? 'bundle' - \ ? ' exec ' . a:bundle_exec - \ : '' - - return ale#Escape(a:executable) . l:exec_args -endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/sh.vim b/sources_non_forked/ale/autoload/ale/handlers/sh.vim index 75eaf71f..6ed9fea3 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/sh.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/sh.vim @@ -1,20 +1,37 @@ " Author: w0rp -" Get the shell type for a buffer, based on the hashbang line. function! ale#handlers#sh#GetShellType(buffer) abort - let l:bang_line = get(getbufline(a:buffer, 1), 0, '') + let l:shebang = get(getbufline(a:buffer, 1), 0, '') - " Take the shell executable from the hashbang, if we can. - if l:bang_line[:1] is# '#!' + let l:command = '' + + " Take the shell executable from the shebang, if we can. + if l:shebang[:1] is# '#!' " Remove options like -e, etc. - let l:command = substitute(l:bang_line, ' --\?[a-zA-Z0-9]\+', '', 'g') - - for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] - if l:command =~# l:possible_shell . '\s*$' - return l:possible_shell - endif - endfor + let l:command = substitute(l:shebang, ' --\?[a-zA-Z0-9]\+', '', 'g') endif + " With no shebang line, attempt to use Vim's buffer-local variables. + if l:command is# '' + if getbufvar(a:buffer, 'is_bash', 0) + let l:command = 'bash' + elseif getbufvar(a:buffer, 'is_sh', 0) + let l:command = 'sh' + elseif getbufvar(a:buffer, 'is_kornshell', 0) + let l:command = 'ksh' + endif + endif + + " If we couldn't find a shebang, try the filetype + if l:command is# '' + let l:command = &filetype + endif + + for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] + if l:command =~# l:possible_shell . '\s*$' + return l:possible_shell + endif + endfor + return '' endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim new file mode 100644 index 00000000..002c4651 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim @@ -0,0 +1,198 @@ +" Author: w0rp +" Description: This file adds support for using the shellcheck linter + +" Shellcheck supports shell directives to define the shell dialect for scripts +" that do not have a shebang for some reason. +" https://github.com/koalaman/shellcheck/wiki/Directive#shell +function! ale#handlers#shellcheck#GetShellcheckDialectDirective(buffer) abort + let l:linenr = 0 + let l:pattern = '\s\{-}#\s\{-}shellcheck\s\{-}shell=\(.*\)' + let l:possible_shell = ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] + + while l:linenr < min([50, line('$')]) + let l:linenr += 1 + let l:match = matchlist(getline(l:linenr), l:pattern) + + if len(l:match) > 1 && index(l:possible_shell, l:match[1]) >= 0 + return l:match[1] + endif + endwhile + + return '' +endfunction + +function! ale#handlers#shellcheck#GetDialectArgument(buffer) abort + let l:shell_type = ale#handlers#shellcheck#GetShellcheckDialectDirective(a:buffer) + + if empty(l:shell_type) + let l:shell_type = ale#handlers#sh#GetShellType(a:buffer) + endif + + if !empty(l:shell_type) + " Use the dash dialect for /bin/ash, etc. + if l:shell_type is# 'ash' + return 'dash' + endif + + return l:shell_type + endif + + return '' +endfunction + +function! ale#handlers#shellcheck#GetCwd(buffer) abort + return ale#Var(a:buffer, 'sh_shellcheck_change_directory') ? '%s:h' : '' +endfunction + +function! ale#handlers#shellcheck#GetCommand(buffer, version) abort + let l:options = ale#Var(a:buffer, 'sh_shellcheck_options') + 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) + endif + + return '%e' + \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '') + \ . l:external_option + \ . ' -f ' . l:format . ' -' +endfunction + +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 , 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 = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[4] is# 'error' + let l:type = 'E' + elseif l:match[4] is# 'note' + let l:type = 'I' + else + let l:type = 'W' + endif + + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ '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]) + let l:item.col = str2nr(l:match[3]) + endif + + " If the filename is something like , or -, then + " this is an error for the file we checked. + if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' + let l:item['filename'] = l:match[1] + endif + + call add(l:output, l:item) + endfor + + 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: + " let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' + call ale#Set('sh_shellcheck_exclusions', '') + call ale#Set('sh_shellcheck_executable', 'shellcheck') + call ale#Set('sh_shellcheck_dialect', 'auto') + call ale#Set('sh_shellcheck_options', '') + call ale#Set('sh_shellcheck_change_directory', 1) + + call ale#linter#Define(a:filetype, { + \ 'name': 'shellcheck', + \ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')}, + \ 'cwd': function('ale#handlers#shellcheck#GetCwd'), + \ 'command': {buffer -> ale#semver#RunWithVersionCheck( + \ buffer, + \ ale#Var(buffer, 'sh_shellcheck_executable'), + \ '%e --version', + \ function('ale#handlers#shellcheck#GetCommand'), + \ )}, + \ '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/handlers/sml.vim b/sources_non_forked/ale/autoload/ale/handlers/sml.vim index 594ee4f7..403b25fa 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/sml.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/sml.vim @@ -56,33 +56,42 @@ function! ale#handlers#sml#Handle(buffer, lines) abort " Try to match basic sml errors " TODO(jez) We can get better errorfmt strings from Syntastic let l:out = [] - let l:pattern = '^.*\:\([0-9\.]\+\)\ \(\w\+\)\:\ \(.*\)' - let l:pattern2 = '^.*\:\([0-9]\+\)\.\?\([0-9]\+\).* \(\(Warning\|Error\): .*\)' + let l:pattern = '^\(.*\)\:\([0-9\.]\+\)\ \(\w\+\)\:\ \(.*\)' + let l:pattern2 = '^\(.*\)\:\([0-9]\+\)\.\?\([0-9]\+\).* \(\(Warning\|Error\): .*\)' for l:line in a:lines let l:match2 = matchlist(l:line, l:pattern2) if len(l:match2) != 0 - call add(l:out, { - \ 'bufnr': a:buffer, - \ 'lnum': l:match2[1] + 0, - \ 'col' : l:match2[2] - 1, - \ 'text': l:match2[3], - \ 'type': l:match2[3] =~# '^Warning' ? 'W' : 'E', - \}) + if l:match2[1] =~# 'stdIn$' + let l:loc = {'bufnr': a:buffer} + else + let l:loc = {'filename': l:match2[1]} + endif + call add(l:out, extend(l:loc, { + \ 'lnum': l:match2[2] + 0, + \ 'col' : l:match2[3] - 1, + \ 'text': l:match2[4], + \ 'type': l:match2[4] =~# '^Warning' ? 'W' : 'E', + \})) continue endif let l:match = matchlist(l:line, l:pattern) if len(l:match) != 0 - call add(l:out, { - \ 'bufnr': a:buffer, - \ 'lnum': l:match[1] + 0, - \ 'text': l:match[2] . ': ' . l:match[3], - \ 'type': l:match[2] is# 'error' ? 'E' : 'W', - \}) + if l:match[1] =~# 'stdIn$' + let l:loc = {'bufnr': a:buffer} + else + let l:loc = {'filename': l:match[1]} + endif + + call add(l:out, extend(l:loc, { + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[3] . ': ' . l:match[4], + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \})) continue endif endfor diff --git a/sources_non_forked/ale/autoload/ale/handlers/spectral.vim b/sources_non_forked/ale/autoload/ale/handlers/spectral.vim new file mode 100644 index 00000000..1eb4a5de --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/spectral.vim @@ -0,0 +1,31 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +function! ale#handlers#spectral#HandleSpectralOutput(buffer, lines) abort + " Matches patterns like the following: + " openapi.yml:1:1 error oas3-schema "Object should have required property `info`." + " openapi.yml:1:1 warning oas3-api-servers "OpenAPI `servers` must be present and non-empty array." + let l:pattern = '\v^.*:(\d+):(\d+) (error|warning) (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:obj = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \ 'text': l:match[4], + \} + + let l:code_match = matchlist(l:obj.text, '\v^(.+) "(.+)"$') + + if !empty(l:code_match) + let l:obj.code = l:code_match[1] + let l:obj.text = l:code_match[2] + endif + + call add(l:output, l:obj) + endfor + + return l:output +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/handlers/statix.vim b/sources_non_forked/ale/autoload/ale/handlers/statix.vim new file mode 100644 index 00000000..eeef4107 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/statix.vim @@ -0,0 +1,24 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: This file defines a handler function for statix's errorformat +" output. + +function! ale#handlers#statix#Handle(buffer, lines) abort + " Look for lines like the following. + " + " flake.nix>46:13:W:3:This assignment is better written with `inherit` + let l:pattern = '\v^.*\>(\d+):(\d+):([A-Z]):(\d+):(.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3], + \ 'code': l:match[4], + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/textlint.vim b/sources_non_forked/ale/autoload/ale/handlers/textlint.vim index 6d495b0d..7a648617 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/textlint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/textlint.vim @@ -6,7 +6,7 @@ call ale#Set('textlint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('textlint_options', '') function! ale#handlers#textlint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'textlint', [ + return ale#path#FindExecutable(a:buffer, 'textlint', [ \ 'node_modules/.bin/textlint', \ 'node_modules/textlint/bin/textlint.js', \]) diff --git a/sources_non_forked/ale/autoload/ale/handlers/tslint.vim b/sources_non_forked/ale/autoload/ale/handlers/tslint.vim index 90579344..ee091d24 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/tslint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/tslint.vim @@ -7,7 +7,7 @@ function! ale#handlers#tslint#InitVariables() abort endfunction function! ale#handlers#tslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [ + return ale#path#FindExecutable(a:buffer, 'typescript_tslint', [ \ 'node_modules/.bin/tslint', \]) endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/writegood.vim b/sources_non_forked/ale/autoload/ale/handlers/writegood.vim index 8ae61a38..b5b91b3f 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/writegood.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/writegood.vim @@ -11,7 +11,7 @@ endfunction call ale#handlers#writegood#ResetOptions() function! ale#handlers#writegood#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'writegood', [ + return ale#path#FindExecutable(a:buffer, 'writegood', [ \ 'node_modules/.bin/write-good', \ 'node_modules/write-good/bin/write-good.js', \]) diff --git a/sources_non_forked/ale/autoload/ale/handlers/xo.vim b/sources_non_forked/ale/autoload/ale/handlers/xo.vim new file mode 100644 index 00000000..a87c6d8f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/xo.vim @@ -0,0 +1,44 @@ +call ale#Set('javascript_xo_executable', 'xo') +call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_xo_options', '') + +call ale#Set('typescript_xo_executable', 'xo') +call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typescript_xo_options', '') + +function! ale#handlers#xo#GetExecutable(buffer) abort + let l:type = ale#handlers#xo#GetType(a:buffer) + + return ale#path#FindExecutable(a:buffer, l:type . '_xo', [ + \ 'node_modules/xo/cli.js', + \ 'node_modules/.bin/xo', + \]) +endfunction + +function! ale#handlers#xo#GetLintCommand(buffer) abort + return ale#Escape(ale#handlers#xo#GetExecutable(a:buffer)) + \ . ale#Pad(ale#handlers#xo#GetOptions(a:buffer)) + \ . ' --reporter json --stdin --stdin-filename %s' +endfunction + +function! ale#handlers#xo#GetOptions(buffer) abort + let l:type = ale#handlers#xo#GetType(a:buffer) + + return ale#Var(a:buffer, l:type . '_xo_options') +endfunction + +" xo uses eslint and the output format is the same +function! ale#handlers#xo#HandleJSON(buffer, lines) abort + return ale#handlers#eslint#HandleJSON(a:buffer, a:lines) +endfunction + +function! ale#handlers#xo#GetType(buffer) abort + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:type = 'javascript' + + if l:filetype =~# 'typescript' + let l:type = 'typescript' + endif + + return l:type +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim b/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim new file mode 100644 index 00000000..5e04577d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim @@ -0,0 +1,39 @@ +function! ale#handlers#yamllint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options')) + \ . ' -f parsable %t' +endfunction + +function! ale#handlers#yamllint#Handle(buffer, lines) abort + " Matches patterns line the following: + " something.yaml:1:1: [warning] missing document start "---" (document-start) + " something.yml:2:1: [error] syntax error: expected the node content, but found '' + let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \} + + let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$') + + if !empty(l:code_match) + if l:code_match[2] is# 'trailing-spaces' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + let l:item.text = l:code_match[1] + let l:item.code = l:code_match[2] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/highlight.vim b/sources_non_forked/ale/autoload/ale/highlight.vim index cb7911e1..473ad354 100644 --- a/sources_non_forked/ale/autoload/ale/highlight.vim +++ b/sources_non_forked/ale/autoload/ale/highlight.vim @@ -26,6 +26,25 @@ endif let s:MAX_POS_VALUES = 8 let s:MAX_COL_SIZE = 1073741824 " pow(2, 30) +let s:has_nvim_highlight = exists('*nvim_buf_add_highlight') && exists('*nvim_buf_clear_namespace') + +if s:has_nvim_highlight + let s:ns_id = nvim_create_namespace('ale_highlight') +endif + +" Wrappers are necessary to test this functionality by faking the calls in tests. +function! ale#highlight#nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) abort + " Ignore all errors for adding highlights. + try + call nvim_buf_add_highlight(a:buffer, a:ns_id, a:hl_group, a:line, a:col_start, a:col_end) + catch + endtry +endfunction + +function! ale#highlight#nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) abort + call nvim_buf_clear_namespace(a:buffer, a:ns_id, a:line_start, a:line_end) +endfunction + function! ale#highlight#CreatePositions(line, col, end_line, end_col) abort if a:line >= a:end_line " For single lines, just return the one position. @@ -51,15 +70,53 @@ endfunction " except these which have matching loclist item entries. function! ale#highlight#RemoveHighlights() abort - for l:match in getmatches() - if l:match.group =~? '\v^ALE(Style)?(Error|Warning|Info)(Line)?$' - call matchdelete(l:match.id) - endif - endfor + if s:has_nvim_highlight + call ale#highlight#nvim_buf_clear_namespace(bufnr(''), s:ns_id, 0, -1) + else + for l:match in getmatches() + if l:match.group =~? '\v^ALE(Style)?(Error|Warning|Info)(Line)?$' + call matchdelete(l:match.id) + endif + endfor + endif +endfunction + +" Same semantics of matchaddpos but will use nvim_buf_add_highlight if +" available. This involves iterating over the position list, switching from +" 1-based indexing to 0-based indexing, and translating the multiple ways +" that position can be specified for matchaddpos into line + col_start + +" col_end. +function! s:matchaddpos(group, pos_list) abort + if s:has_nvim_highlight + for l:pos in a:pos_list + let l:line = type(l:pos) == v:t_number + \ ? l:pos - 1 + \ : l:pos[0] - 1 + + if type(l:pos) == v:t_number || len(l:pos) == 1 + let l:col_start = 0 + let l:col_end = s:MAX_COL_SIZE + else + let l:col_start = l:pos[1] - 1 + let l:col_end = l:col_start + get(l:pos, 2, 1) + endif + + call ale#highlight#nvim_buf_add_highlight( + \ bufnr(''), + \ s:ns_id, + \ a:group, + \ l:line, + \ l:col_start, + \ l:col_end, + \) + endfor + else + call matchaddpos(a:group, a:pos_list) + endif endfunction function! s:highlight_line(bufnr, lnum, group) abort - call matchaddpos(a:group, [a:lnum]) + call s:matchaddpos(a:group, [a:lnum]) endfunction function! s:highlight_range(bufnr, range, group) abort @@ -72,7 +129,7 @@ function! s:highlight_range(bufnr, range, group) abort \ a:range.end_lnum, \ a:range.end_col \ ), - \ 'matchaddpos(a:group, v:val)' + \ 's:matchaddpos(a:group, v:val)' \) endfunction @@ -153,6 +210,12 @@ function! ale#highlight#SetHighlights(buffer, loclist) abort " Set the list in the buffer variable. call setbufvar(str2nr(a:buffer), 'ale_highlight_items', l:new_list) + let l:exclude_list = ale#Var(a:buffer, 'exclude_highlights') + + if !empty(l:exclude_list) + call filter(l:new_list, 'empty(ale#util#GetMatches(v:val.text, l:exclude_list))') + endif + " Update highlights for the current buffer, which may or may not " be the buffer we just set highlights for. call ale#highlight#UpdateHighlights() diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim index 2af35aa4..a42766eb 100644 --- a/sources_non_forked/ale/autoload/ale/hover.vim +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -24,6 +24,8 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort if get(a:response, 'success', v:false) is v:true \&& get(a:response, 'body', v:null) isnot v:null + let l:set_balloons = ale#Var(l:options.buffer, 'set_balloons') + " If we pass the show_documentation flag, we should show the full " documentation, and always in the preview window. if get(l:options, 'show_documentation', 0) @@ -40,8 +42,21 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort endif elseif get(l:options, 'hover_from_balloonexpr', 0) \&& exists('*balloon_show') - \&& ale#Var(l:options.buffer, 'set_balloons') + \&& (l:set_balloons is 1 || l:set_balloons is# 'hover') call balloon_show(a:response.body.displayString) + elseif get(l:options, 'truncated_echo', 0) + if !empty(a:response.body.displayString) + call ale#cursor#TruncatedEcho(a:response.body.displayString) + endif + elseif g:ale_hover_to_floating_preview || g:ale_floating_preview + call ale#floating_preview#Show(split(a:response.body.displayString, "\n"), { + \ 'filetype': 'ale-preview.message', + \}) + elseif g:ale_hover_to_preview + call ale#preview#Show(split(a:response.body.displayString, "\n"), { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \}) else call ale#util#ShowMessage(a:response.body.displayString) endif @@ -49,6 +64,150 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort endif endfunction +" Convert a language name to another one. +" The language name could be an empty string or v:null +function! s:ConvertLanguageName(language) abort + return a:language +endfunction + +" Cache syntax file (non-)existence to avoid calling globpath repeatedly. +let s:syntax_file_exists_cache = {} + +function! s:SyntaxFileExists(syntax_file) abort + if !has_key(s:syntax_file_exists_cache, a:syntax_file) + let s:syntax_file_exists_cache[a:syntax_file] = + \ !empty(globpath(&runtimepath, a:syntax_file)) + endif + + return s:syntax_file_exists_cache[a:syntax_file] +endfunction + +function! ale#hover#ParseLSPResult(contents) abort + let l:includes = {} + let l:highlights = [] + let l:lines = [] + let l:list = type(a:contents) is v:t_list ? a:contents : [a:contents] + let l:region_index = 0 + + for l:item in l:list + if !empty(l:lines) + call add(l:lines, '') + endif + + if type(l:item) is v:t_dict && has_key(l:item, 'kind') + if l:item.kind is# 'markdown' + " Handle markdown values as we handle strings below. + let l:item = get(l:item, 'value', '') + elseif l:item.kind is# 'plaintext' + " We shouldn't try to parse plaintext as markdown. + " Pass the lines on and skip parsing them. + call extend(l:lines, split(get(l:item, 'value', ''), "\n")) + + continue + endif + endif + + let l:marked_list = [] + + " If the item is a string, then we should parse it as Markdown text. + if type(l:item) is v:t_string + let l:fence_language = v:null + let l:fence_lines = [] + + 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, '^``` *\([^ ]\+\)\? *$') + + if !empty(l:match) + let l:fence_language = len(l:match) > 1 ? l:match[1] : 'text' + + if !empty(l:marked_list) + call add(l:fence_lines, '') + endif + else + if !empty(l:marked_list) + \&& l:marked_list[-1][0] isnot v:null + call add(l:marked_list, [v:null, ['']]) + endif + + call add(l:marked_list, [v:null, [l:line]]) + endif + elseif l:line =~# '^```$' + " When we hit the end of a code fence, pass the fenced + " lines on to the next steps below. + call add(l:marked_list, [l:fence_language, l:fence_lines]) + let l:fence_language = v:null + let l:fence_lines = [] + else + " Gather lines inside of a code fence. + call add(l:fence_lines, l:line) + endif + endfor + " If the result from the LSP server is a {language: ..., value: ...} + " Dictionary, then that should be interpreted as if it was: + " + " ```${language} + " ${value} + " ``` + elseif type(l:item) is v:t_dict + \&& has_key(l:item, 'language') + \&& type(l:item.language) is v:t_string + \&& has_key(l:item, 'value') + \&& type(l:item.value) is v:t_string + call add( + \ l:marked_list, + \ [l:item.language, split(l:item.value, "\n")], + \) + endif + + for [l:language, l:marked_lines] in l:marked_list + if l:language is v:null + " NOTE: We could handle other Markdown formatting here. + call map( + \ l:marked_lines, + \ 'substitute(v:val, ''\\_'', ''_'', ''g'')', + \) + else + let l:language = s:ConvertLanguageName(l:language) + + if !empty(l:language) + let l:syntax_file = printf('syntax/%s.vim', l:language) + + if s:SyntaxFileExists(l:syntax_file) + let l:includes[l:language] = l:syntax_file + endif + + let l:start = len(l:lines) + 1 + let l:end = l:start + len(l:marked_lines) + let l:region_index += 1 + + call add(l:highlights, 'syntax region' + \ . ' ALE_hover_' . l:region_index + \ . ' start=/\%' . l:start . 'l/' + \ . ' end=/\%' . l:end . 'l/' + \ . ' contains=@ALE_hover_' . l:language + \) + endif + endif + + call extend(l:lines, l:marked_lines) + endfor + endfor + + let l:include_commands = [] + + for [l:language, l:lang_path] in sort(items(l:includes)) + call add(l:include_commands, 'unlet! b:current_syntax') + call add( + \ l:include_commands, + \ printf('syntax include @ALE_hover_%s %s', l:language, l:lang_path), + \) + endfor + + return [l:include_commands + l:highlights, l:lines] +endfunction + function! ale#hover#HandleLSPResponse(conn_id, response) abort if has_key(a:response, 'id') \&& has_key(s:hover_map, a:response.id) @@ -75,32 +234,36 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort return endif - let l:result = l:result.contents + let [l:commands, l:lines] = ale#hover#ParseLSPResult(l:result.contents) - if type(l:result) is v:t_string - " The result can be just a string. - let l:result = [l:result] - endif + if !empty(l:lines) + let l:set_balloons = ale#Var(l:options.buffer, 'set_balloons') - if type(l:result) is v:t_dict - " If the result is an object, then it's markup content. - let l:result = [l:result.value] - endif - - if type(l:result) is v:t_list - " Replace objects with text values. - call map(l:result, 'type(v:val) is v:t_string ? v:val : v:val.value') - let l:str = join(l:result, "\n") - let l:str = substitute(l:str, '^\s*\(.\{-}\)\s*$', '\1', '') - - if !empty(l:str) - if get(l:options, 'hover_from_balloonexpr', 0) - \&& exists('*balloon_show') - \&& ale#Var(l:options.buffer, 'set_balloons') - call balloon_show(l:str) + if get(l:options, 'hover_from_balloonexpr', 0) + \&& exists('*balloon_show') + \&& (l:set_balloons is 1 || l:set_balloons is# 'hover') + call balloon_show(join(l:lines, "\n")) + elseif get(l:options, 'truncated_echo', 0) + if type(l:lines[0]) is# v:t_list + call ale#cursor#TruncatedEcho(join(l:lines[0], '\n')) else - call ale#util#ShowMessage(l:str) + call ale#cursor#TruncatedEcho(l:lines[0]) endif + elseif g:ale_hover_to_floating_preview || g:ale_floating_preview + call ale#floating_preview#Show(l:lines, { + \ 'filetype': 'ale-preview.message', + \ 'commands': l:commands, + \}) + elseif g:ale_hover_to_preview + call ale#preview#Show(l:lines, { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \ 'commands': l:commands, + \}) + else + call ale#util#ShowMessage(join(l:lines, "\n"), { + \ 'commands': l:commands, + \}) endif endif endif @@ -133,7 +296,10 @@ function! s:OnReady(line, column, opt, linter, lsp_details) abort " hover position probably won't make sense. call ale#lsp#NotifyForChanges(l:id, l:buffer) - let l:column = min([a:column, len(getbufline(l:buffer, a:line)[0])]) + let l:column = max([ + \ min([a:column, len(getbufline(l:buffer, a:line)[0])]), + \ 1, + \]) let l:message = ale#lsp#message#Hover(l:buffer, a:line, l:column) endif @@ -146,6 +312,7 @@ function! s:OnReady(line, column, opt, linter, lsp_details) abort \ 'column': l:column, \ 'hover_from_balloonexpr': get(a:opt, 'called_from_balloonexpr', 0), \ 'show_documentation': get(a:opt, 'show_documentation', 0), + \ 'truncated_echo': get(a:opt, 'truncated_echo', 0), \} endfunction @@ -162,15 +329,16 @@ function! ale#hover#Show(buffer, line, col, opt) abort let l:show_documentation = get(a:opt, 'show_documentation', 0) let l:Callback = function('s:OnReady', [a:line, a:col, a:opt]) - for l:linter in ale#linter#Get(getbufvar(a:buffer, '&filetype')) + for l:linter in ale#lsp_linter#GetEnabled(a:buffer) " Only tsserver supports documentation requests at the moment. - if !empty(l:linter.lsp) - \&& (!l:show_documentation || l:linter.lsp is# 'tsserver') + if !l:show_documentation || l:linter.lsp is# 'tsserver' call ale#lsp_linter#StartLSP(a:buffer, l:linter, l:Callback) endif endfor endfunction +let s:last_pos = [0, 0, 0] + " This function implements the :ALEHover command. function! ale#hover#ShowAtCursor() abort let l:buffer = bufnr('') @@ -179,6 +347,29 @@ function! ale#hover#ShowAtCursor() abort call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], {}) endfunction +function! ale#hover#ShowTruncatedMessageAtCursor() abort + let l:buffer = bufnr('') + let l:pos = getpos('.')[0:2] + + if !getbufvar(l:buffer, 'ale_enabled', 1) + return + endif + + if l:pos != s:last_pos + let s:last_pos = l:pos + let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) + + if empty(l:loc) + call ale#hover#Show( + \ l:buffer, + \ l:pos[1], + \ l:pos[2], + \ {'truncated_echo': 1}, + \) + endif + endif +endfunction + " This function implements the :ALEDocumentation command. function! ale#hover#ShowDocumentationAtCursor() abort let l:buffer = bufnr('') diff --git a/sources_non_forked/ale/autoload/ale/java.vim b/sources_non_forked/ale/autoload/ale/java.vim index e641ac6c..859d938d 100644 --- a/sources_non_forked/ale/autoload/ale/java.vim +++ b/sources_non_forked/ale/autoload/ale/java.vim @@ -1,7 +1,7 @@ " Author: Horacio Sanson https://github.com/hsanson " Description: Functions for integrating with Java tools -" Find the nearest dir contining a gradle or pom file and asume it +" Find the nearest dir contining a gradle or pom file and assume it " the root of a java app. function! ale#java#FindProjectRoot(buffer) abort let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer) diff --git a/sources_non_forked/ale/autoload/ale/job.vim b/sources_non_forked/ale/autoload/ale/job.vim index 14b3e484..0fc43a8c 100644 --- a/sources_non_forked/ale/autoload/ale/job.vim +++ b/sources_non_forked/ale/autoload/ale/job.vim @@ -187,10 +187,16 @@ function! ale#job#PrepareCommand(buffer, command) abort \ : a:command " If a custom shell is specified, use that. - if exists('g:ale_shell') - let l:shell_arguments = get(g:, 'ale_shell_arguments', &shellcmdflag) + if exists('b:ale_shell') + let l:ale_shell = b:ale_shell + elseif exists('g:ale_shell') + let l:ale_shell = g:ale_shell + endif - return split(g:ale_shell) + split(l:shell_arguments) + [l:command] + if exists('l:ale_shell') + let l:shell_arguments = get(b:, 'ale_shell_arguments', get(g:, 'ale_shell_arguments', &shellcmdflag)) + + return split(l:ale_shell) + split(l:shell_arguments) + [l:command] endif if has('win32') @@ -244,10 +250,16 @@ function! ale#job#Start(command, options) abort if has_key(a:options, 'out_cb') let l:job_options.out_cb = function('s:VimOutputCallback') + else + " prevent buffering of output and excessive polling in case close_cb is set + let l:job_options.out_cb = {->0} endif if has_key(a:options, 'err_cb') let l:job_options.err_cb = function('s:VimErrorCallback') + else + " prevent buffering of output and excessive polling in case close_cb is set + let l:job_options.err_cb = {->0} endif if has_key(a:options, 'exit_cb') diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim index 78dcd3a2..618557d7 100644 --- a/sources_non_forked/ale/autoload/ale/linter.vim +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -12,9 +12,14 @@ let s:linters = {} let s:default_ale_linter_aliases = { \ 'Dockerfile': 'dockerfile', \ 'csh': 'sh', +\ 'javascriptreact': ['javascript', 'jsx'], \ 'plaintex': 'tex', +\ 'ps1': 'powershell', \ 'rmarkdown': 'r', +\ 'rmd': 'r', \ 'systemverilog': 'verilog', +\ 'typescriptreact': ['typescript', 'tsx'], +\ 'vader': ['vim', 'vader'], \ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'], \ 'vimwiki': 'markdown', \ 'vue': ['vue', 'javascript'], @@ -28,25 +33,35 @@ let s:default_ale_linter_aliases = { " " No linters are used for plaintext files by default. " -" Only cargo is enabled for Rust by default. +" Only cargo and rls are enabled for Rust by default. " rpmlint is disabled by default because it can result in code execution. " hhast is disabled by default because it executes code in the project root. " " 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', 'golint', 'go vet'], +\ 'go': ['gofmt', 'golangci-lint', 'gopls', 'govet'], +\ 'groovy': ['npm-groovy-lint'], \ 'hack': ['hack'], \ 'help': [], +\ 'inko': ['inko'], +\ 'json': ['biome', 'jsonlint', 'spectral', 'vscodejson'], +\ 'json5': [], +\ 'jsonc': ['biome'], \ 'perl': ['perlcritic'], \ 'perl6': [], -\ 'python': ['flake8', 'mypy', 'pylint'], -\ 'rust': ['cargo'], +\ 'python': ['flake8', 'mypy', 'pylint', 'pyright', 'ruff'], +\ 'rust': ['analyzer', 'cargo'], \ 'spec': [], \ 'text': [], +\ 'vader': ['vimls'], \ 'vue': ['eslint', 'vls'], \ 'zsh': ['shell'], +\ 'v': ['v'], +\ 'yaml': ['actionlint', 'spectral', 'yaml-language-server', 'yamllint'], \} " Testing/debugging helper to unload all linters. @@ -73,10 +88,6 @@ function! s:IsBoolean(value) abort return type(a:value) is v:t_number && (a:value == 0 || a:value == 1) endfunction -function! s:LanguageGetter(buffer) dict abort - return l:self.language -endfunction - function! ale#linter#PreProcess(filetype, linter) abort if type(a:linter) isnot v:t_dict throw 'The linter object must be a Dictionary' @@ -110,14 +121,7 @@ function! ale#linter#PreProcess(filetype, linter) abort if !l:needs_executable if has_key(a:linter, 'executable') - \|| has_key(a:linter, 'executable_callback') - throw '`executable` and `executable_callback` cannot be used when lsp == ''socket''' - endif - elseif has_key(a:linter, 'executable_callback') - let l:obj.executable_callback = a:linter.executable_callback - - if !s:IsCallback(l:obj.executable_callback) - throw '`executable_callback` must be a callback if defined' + throw '`executable` cannot be used when lsp == ''socket''' endif elseif has_key(a:linter, 'executable') let l:obj.executable = a:linter.executable @@ -127,54 +131,12 @@ function! ale#linter#PreProcess(filetype, linter) abort throw '`executable` must be a String or Function if defined' endif else - throw 'Either `executable` or `executable_callback` must be defined' + throw '`executable` must be defined' endif if !l:needs_command if has_key(a:linter, 'command') - \|| has_key(a:linter, 'command_callback') - \|| has_key(a:linter, 'command_chain') - throw '`command` and `command_callback` and `command_chain` cannot be used when lsp == ''socket''' - endif - elseif has_key(a:linter, 'command_chain') - let l:obj.command_chain = a:linter.command_chain - - if type(l:obj.command_chain) isnot v:t_list - throw '`command_chain` must be a List' - endif - - if empty(l:obj.command_chain) - throw '`command_chain` must contain at least one item' - endif - - let l:link_index = 0 - - for l:link in l:obj.command_chain - let l:err_prefix = 'The `command_chain` item ' . l:link_index . ' ' - - if !s:IsCallback(get(l:link, 'callback')) - throw l:err_prefix . 'must define a `callback` function' - endif - - if has_key(l:link, 'output_stream') - if type(l:link.output_stream) isnot v:t_string - \|| index(['stdout', 'stderr', 'both'], l:link.output_stream) < 0 - throw l:err_prefix . '`output_stream` flag must be ' - \ . "'stdout', 'stderr', or 'both'" - endif - endif - - if has_key(l:link, 'read_buffer') && !s:IsBoolean(l:link.read_buffer) - throw l:err_prefix . 'value for `read_buffer` must be `0` or `1`' - endif - - let l:link_index += 1 - endfor - elseif has_key(a:linter, 'command_callback') - let l:obj.command_callback = a:linter.command_callback - - if !s:IsCallback(l:obj.command_callback) - throw '`command_callback` must be a callback if defined' + throw '`command` cannot be used when lsp == ''socket''' endif elseif has_key(a:linter, 'command') let l:obj.command = a:linter.command @@ -184,22 +146,12 @@ function! ale#linter#PreProcess(filetype, linter) abort throw '`command` must be a String or Function if defined' endif else - throw 'Either `command`, `executable_callback`, `command_chain` ' - \ . 'must be defined' - endif - - if ( - \ has_key(a:linter, 'command') - \ + has_key(a:linter, 'command_chain') - \ + has_key(a:linter, 'command_callback') - \) > 1 - throw 'Only one of `command`, `command_callback`, or `command_chain` ' - \ . 'should be set' + throw '`command` must be defined' endif if !l:needs_address - if has_key(a:linter, 'address') || has_key(a:linter, 'address_callback') - throw '`address` or `address_callback` cannot be used when lsp != ''socket''' + if has_key(a:linter, 'address') + throw '`address` cannot be used when lsp != ''socket''' endif elseif has_key(a:linter, 'address') if type(a:linter.address) isnot v:t_string @@ -208,41 +160,30 @@ function! ale#linter#PreProcess(filetype, linter) abort endif let l:obj.address = a:linter.address - elseif has_key(a:linter, 'address_callback') - let l:obj.address_callback = a:linter.address_callback - if !s:IsCallback(l:obj.address_callback) - throw '`address_callback` must be a callback if defined' + if has_key(a:linter, 'cwd') + throw '`cwd` makes no sense for socket LSP connections' endif else - throw '`address` or `address_callback` must be defined for getting the LSP address' + throw '`address` must be defined for getting the LSP address' + endif + + if has_key(a:linter, 'cwd') + let l:obj.cwd = a:linter.cwd + + if type(l:obj.cwd) isnot v:t_string + \&& type(l:obj.cwd) isnot v:t_func + throw '`cwd` must be a String or Function if defined' + endif endif if l:needs_lsp_details - if has_key(a:linter, 'language_callback') - if has_key(a:linter, 'language') - throw 'Only one of `language` or `language_callback` ' - \ . 'should be set' - endif + " Default to using the filetype as the language. + let l:obj.language = get(a:linter, 'language', a:filetype) - let l:obj.language_callback = get(a:linter, 'language_callback') - - if !s:IsCallback(l:obj.language_callback) - throw '`language_callback` must be a callback for LSP linters' - endif - else - " Default to using the filetype as the language. - let l:Language = get(a:linter, 'language', a:filetype) - - if type(l:Language) is v:t_string - " Make 'language_callback' return the 'language' value. - let l:obj.language = l:Language - let l:obj.language_callback = function('s:LanguageGetter') - elseif type(l:Language) is v:t_func - let l:obj.language_callback = l:Language - else - throw '`language` must be a String or Funcref' - endif + if type(l:obj.language) isnot v:t_string + \&& type(l:obj.language) isnot v:t_func + throw '`language` must be a String or Function if defined' endif if has_key(a:linter, 'project_root') @@ -250,16 +191,10 @@ function! ale#linter#PreProcess(filetype, linter) abort if type(l:obj.project_root) isnot v:t_string \&& type(l:obj.project_root) isnot v:t_func - throw '`project_root` must be a String or Function if defined' - endif - elseif has_key(a:linter, 'project_root_callback') - let l:obj.project_root_callback = a:linter.project_root_callback - - if !s:IsCallback(l:obj.project_root_callback) - throw '`project_root_callback` must be a callback if defined' + throw '`project_root` must be a String or Function' endif else - throw '`project_root` or `project_root_callback` must be defined for LSP linters' + throw '`project_root` must be defined for LSP linters' endif if has_key(a:linter, 'completion_filter') @@ -270,37 +205,16 @@ function! ale#linter#PreProcess(filetype, linter) abort endif endif - if has_key(a:linter, 'initialization_options_callback') - if has_key(a:linter, 'initialization_options') - throw 'Only one of `initialization_options` or ' - \ . '`initialization_options_callback` should be set' - endif - - let l:obj.initialization_options_callback = a:linter.initialization_options_callback - - if !s:IsCallback(l:obj.initialization_options_callback) - throw '`initialization_options_callback` must be a callback if defined' - endif - elseif has_key(a:linter, 'initialization_options') + if has_key(a:linter, 'initialization_options') let l:obj.initialization_options = a:linter.initialization_options if type(l:obj.initialization_options) isnot v:t_dict \&& type(l:obj.initialization_options) isnot v:t_func - throw '`initialization_options` must be a String or Function if defined' + throw '`initialization_options` must be a Dictionary or Function if defined' endif endif - if has_key(a:linter, 'lsp_config_callback') - if has_key(a:linter, 'lsp_config') - throw 'Only one of `lsp_config` or `lsp_config_callback` should be set' - endif - - let l:obj.lsp_config_callback = a:linter.lsp_config_callback - - if !s:IsCallback(l:obj.lsp_config_callback) - throw '`lsp_config_callback` must be a callback if defined' - endif - elseif has_key(a:linter, 'lsp_config') + if has_key(a:linter, 'lsp_config') if type(a:linter.lsp_config) isnot v:t_dict \&& type(a:linter.lsp_config) isnot v:t_func throw '`lsp_config` must be a Dictionary or Function if defined' @@ -321,21 +235,17 @@ function! ale#linter#PreProcess(filetype, linter) abort " file on disk. let l:obj.lint_file = get(a:linter, 'lint_file', 0) - if !s:IsBoolean(l:obj.lint_file) - throw '`lint_file` must be `0` or `1`' + if !s:IsBoolean(l:obj.lint_file) && type(l:obj.lint_file) isnot v:t_func + throw '`lint_file` must be `0`, `1`, or a Function' endif " An option indicating that the buffer should be read. - let l:obj.read_buffer = get(a:linter, 'read_buffer', !l:obj.lint_file) + let l:obj.read_buffer = get(a:linter, 'read_buffer', 1) if !s:IsBoolean(l:obj.read_buffer) throw '`read_buffer` must be `0` or `1`' endif - if l:obj.lint_file && l:obj.read_buffer - throw 'Only one of `lint_file` or `read_buffer` can be `1`' - endif - let l:obj.aliases = get(a:linter, 'aliases', []) if type(l:obj.aliases) isnot v:t_list @@ -343,14 +253,6 @@ function! ale#linter#PreProcess(filetype, linter) abort throw '`aliases` must be a List of String values' endif - for l:key in filter(keys(a:linter), 'v:val[-9:] is# ''_callback'' || v:val is# ''command_chain''') - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom l:key . '' is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - break - endfor - return l:obj endfunction @@ -518,34 +420,35 @@ endfunction " Given a buffer and linter, get the executable String for the linter. function! ale#linter#GetExecutable(buffer, linter) abort - let l:Executable = has_key(a:linter, 'executable_callback') - \ ? function(a:linter.executable_callback) - \ : a:linter.executable + let l:Executable = a:linter.executable return type(l:Executable) is v:t_func \ ? l:Executable(a:buffer) \ : l:Executable endfunction -" Given a buffer and linter, get the command String for the linter. -" The command_chain key is not supported. -function! ale#linter#GetCommand(buffer, linter) abort - let l:Command = has_key(a:linter, 'command_callback') - \ ? function(a:linter.command_callback) - \ : a:linter.command +function! ale#linter#GetCwd(buffer, linter) abort + let l:Cwd = get(a:linter, 'cwd', v:null) - return type(l:Command) is v:t_func - \ ? l:Command(a:buffer) - \ : l:Command + return type(l:Cwd) is v:t_func ? l:Cwd(a:buffer) : l:Cwd +endfunction + +" Given a buffer and linter, get the command String for the linter. +function! ale#linter#GetCommand(buffer, linter) abort + let l:Command = a:linter.command + + return type(l:Command) is v:t_func ? l:Command(a:buffer) : l:Command endfunction " Given a buffer and linter, get the address for connecting to the server. function! ale#linter#GetAddress(buffer, linter) abort - let l:Address = has_key(a:linter, 'address_callback') - \ ? function(a:linter.address_callback) - \ : a:linter.address + let l:Address = a:linter.address - return type(l:Address) is v:t_func - \ ? l:Address(a:buffer) - \ : l:Address + return type(l:Address) is v:t_func ? l:Address(a:buffer) : l:Address +endfunction + +function! ale#linter#GetLanguage(buffer, linter) abort + let l:Language = a:linter.language + + return type(l:Language) is v:t_func ? l:Language(a:buffer) : l:Language endfunction diff --git a/sources_non_forked/ale/autoload/ale/list.vim b/sources_non_forked/ale/autoload/ale/list.vim index 4bfe2a7b..8ce8597e 100644 --- a/sources_non_forked/ale/autoload/ale/list.vim +++ b/sources_non_forked/ale/autoload/ale/list.vim @@ -18,24 +18,49 @@ if !exists('s:timer_args') let s:timer_args = {} endif -" Return 1 if there is a buffer with buftype == 'quickfix' in bufffer list +" Return 1 if there is a buffer with buftype == 'quickfix' in buffer list function! ale#list#IsQuickfixOpen() abort - for l:buf in range(1, bufnr('$')) - if getbufvar(l:buf, '&buftype') is# 'quickfix' - return 1 - endif - endfor + let l:res = getqflist({ 'winid' : winnr() }) + + if has_key(l:res, 'winid') && l:res.winid > 0 + return 1 + endif + + let l:res = getloclist(0, { 'winid' : winnr() }) + + if has_key(l:res, 'winid') && l:res.winid > 0 + return 1 + endif return 0 endfunction " Check if we should open the list, based on the save event being fired, and -" that setting being on, or the setting just being set to `1`. -function! s:ShouldOpen(buffer) abort +" that setting being on, or that the error count is at least as high as the +" setting when set to an integer value. +function! s:ShouldOpen(buffer, loclist_len) abort let l:val = ale#Var(a:buffer, 'open_list') let l:saved = getbufvar(a:buffer, 'ale_save_event_fired', 0) - return l:val is 1 || (l:val is# 'on_save' && l:saved) + return l:val > 0 ? a:loclist_len >= l:val : l:val is# 'on_save' && l:saved +endfunction + +" Check if we should close the list, based on the save event being fired, and +" that setting being on, or the setting just being set to an integer value. +function! s:ShouldClose(buffer) abort + let l:val = ale#Var(a:buffer, 'open_list') + let l:saved = getbufvar(a:buffer, 'ale_save_event_fired', 0) + + return !((l:val >= 1) || (l:val is# 'on_save' && l:saved)) +endfunction + +function! s:Deduplicate(list) abort + let l:list = a:list + + call sort(l:list, function('ale#util#LocItemCompareWithText')) + call uniq(l:list, function('ale#util#LocItemCompareWithText')) + + return l:list endfunction function! ale#list#GetCombinedList() abort @@ -45,10 +70,7 @@ function! ale#list#GetCombinedList() abort call extend(l:list, l:info.loclist) endfor - call sort(l:list, function('ale#util#LocItemCompareWithText')) - call uniq(l:list, function('ale#util#LocItemCompareWithText')) - - return l:list + return s:Deduplicate(l:list) endfunction function! s:FixList(buffer, list) abort @@ -93,11 +115,13 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort " but it's better than nothing. let l:ids = s:WinFindBuf(a:buffer) + let l:loclist = s:Deduplicate(a:loclist) + for l:id in l:ids if has('nvim') - call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title) + call setloclist(l:id, s:FixList(a:buffer, l:loclist), ' ', l:title) else - call setloclist(l:id, s:FixList(a:buffer, a:loclist)) + call setloclist(l:id, s:FixList(a:buffer, l:loclist)) call setloclist(l:id, [], 'r', {'title': l:title}) endif endfor @@ -108,9 +132,9 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort " Open a window to show the problems if we need to. " - " We'll check if the current buffer's List is not empty here, so the - " window will only be opened if the current buffer has problems. - if s:ShouldOpen(a:buffer) && !empty(a:loclist) + " ShouldOpen() checks if the current buffer has enough problems to be + " opened. + if s:ShouldOpen(a:buffer, len(a:loclist)) let l:winnr = winnr() let l:mode = mode() @@ -166,7 +190,7 @@ function! s:RestoreViewIfNeeded(buffer) abort return endif - " Check wether the cursor has moved since linting was actually requested. If + " Check whether the cursor has moved since linting was actually requested. If " the user has indeed moved lines, do nothing let l:current_view = winsaveview() @@ -198,8 +222,25 @@ function! ale#list#SetLists(buffer, loclist) abort endif endfunction +function! ale#list#ForcePopulateErrorList(populate_quickfix) abort + let l:quickfix_bak = g:ale_set_quickfix + let g:ale_set_quickfix = a:populate_quickfix + let l:loclist_bak = g:ale_set_loclist + let g:ale_set_loclist = !a:populate_quickfix + let l:open_list_bak = g:ale_open_list + let g:ale_open_list = 1 + + let l:buffer = bufnr('') + let l:loclist = get(g:ale_buffer_info, l:buffer, {'loclist': []}).loclist + call s:SetListsImpl(-1, l:buffer, l:loclist) + + let g:ale_open_list = l:open_list_bak + let g:ale_set_loclist = l:loclist_bak + let g:ale_set_quickfix = l:quickfix_bak +endfunction + function! s:CloseWindowIfNeeded(buffer) abort - if ale#Var(a:buffer, 'keep_list_window_open') || !s:ShouldOpen(a:buffer) + if ale#Var(a:buffer, 'keep_list_window_open') || s:ShouldClose(a:buffer) return endif diff --git a/sources_non_forked/ale/autoload/ale/lsp.vim b/sources_non_forked/ale/autoload/ale/lsp.vim index 017096cd..0519c798 100644 --- a/sources_non_forked/ale/autoload/ale/lsp.vim +++ b/sources_non_forked/ale/autoload/ale/lsp.vim @@ -37,12 +37,18 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort \ 'init_queue': [], \ 'capabilities': { \ 'hover': 0, + \ 'rename': 0, + \ 'filerename': 0, \ 'references': 0, \ 'completion': 0, \ 'completion_trigger_characters': [], \ 'definition': 0, \ 'typeDefinition': 0, + \ 'implementation': 0, \ 'symbol_search': 0, + \ 'code_actions': 0, + \ 'did_save': 0, + \ 'includeText': 0, \ }, \} endif @@ -63,6 +69,9 @@ endfunction " Used only in tests. function! ale#lsp#GetConnections() abort + " This command will throw from the sandbox. + let &l:equalprg=&l:equalprg + return s:connections endfunction @@ -195,10 +204,34 @@ function! s:UpdateCapabilities(conn, capabilities) abort let a:conn.capabilities.hover = 1 endif + if type(get(a:capabilities, 'hoverProvider')) is v:t_dict + let a:conn.capabilities.hover = 1 + endif + if get(a:capabilities, 'referencesProvider') is v:true let a:conn.capabilities.references = 1 endif + if type(get(a:capabilities, 'referencesProvider')) is v:t_dict + let a:conn.capabilities.references = 1 + endif + + if get(a:capabilities, 'renameProvider') is v:true + let a:conn.capabilities.rename = 1 + endif + + if type(get(a:capabilities, 'renameProvider')) is v:t_dict + let a:conn.capabilities.rename = 1 + endif + + if get(a:capabilities, 'codeActionProvider') is v:true + let a:conn.capabilities.code_actions = 1 + endif + + if type(get(a:capabilities, 'codeActionProvider')) is v:t_dict + let a:conn.capabilities.code_actions = 1 + endif + if !empty(get(a:capabilities, 'completionProvider')) let a:conn.capabilities.completion = 1 endif @@ -215,13 +248,51 @@ function! s:UpdateCapabilities(conn, capabilities) abort let a:conn.capabilities.definition = 1 endif + if type(get(a:capabilities, 'definitionProvider')) is v:t_dict + let a:conn.capabilities.definition = 1 + endif + if get(a:capabilities, 'typeDefinitionProvider') is v:true let a:conn.capabilities.typeDefinition = 1 endif + if type(get(a:capabilities, 'typeDefinitionProvider')) is v:t_dict + let a:conn.capabilities.typeDefinition = 1 + endif + + if get(a:capabilities, 'implementationProvider') is v:true + let a:conn.capabilities.implementation = 1 + endif + + if type(get(a:capabilities, 'implementationProvider')) is v:t_dict + let a:conn.capabilities.implementation = 1 + endif + if get(a:capabilities, 'workspaceSymbolProvider') is v:true let a:conn.capabilities.symbol_search = 1 endif + + if type(get(a:capabilities, 'workspaceSymbolProvider')) is v:t_dict + let a:conn.capabilities.symbol_search = 1 + endif + + if type(get(a:capabilities, 'textDocumentSync')) is v:t_dict + let l:syncOptions = get(a:capabilities, 'textDocumentSync') + + if get(l:syncOptions, 'save') is v:true + let a:conn.capabilities.did_save = 1 + endif + + if type(get(l:syncOptions, 'save')) is v:t_dict + let a:conn.capabilities.did_save = 1 + + let l:saveOptions = get(l:syncOptions, 'save') + + if get(l:saveOptions, 'includeText') is v:true + let a:conn.capabilities.includeText = 1 + endif + endif + endif endfunction " Update a connection's configuration dictionary and notify LSP servers @@ -316,7 +387,12 @@ function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort let l:conn.capabilities.completion = 1 let l:conn.capabilities.completion_trigger_characters = ['.'] let l:conn.capabilities.definition = 1 + let l:conn.capabilities.typeDefinition = 1 + let l:conn.capabilities.implementation = 1 let l:conn.capabilities.symbol_search = 1 + let l:conn.capabilities.rename = 1 + let l:conn.capabilities.filerename = 1 + let l:conn.capabilities.code_actions = 1 endfunction function! s:SendInitMessage(conn) abort @@ -348,7 +424,7 @@ function! s:SendInitMessage(conn) abort \ 'completionItem': { \ 'snippetSupport': v:false, \ 'commitCharactersSupport': v:false, - \ 'documentationFormat': ['plaintext'], + \ 'documentationFormat': ['plaintext', 'markdown'], \ 'deprecatedSupport': v:false, \ 'preselectSupport': v:false, \ }, @@ -356,7 +432,7 @@ function! s:SendInitMessage(conn) abort \ }, \ 'hover': { \ 'dynamicRegistration': v:false, - \ 'contentFormat': ['plaintext'], + \ 'contentFormat': ['plaintext', 'markdown'], \ }, \ 'references': { \ 'dynamicRegistration': v:false, @@ -372,11 +448,20 @@ function! s:SendInitMessage(conn) abort \ 'typeDefinition': { \ 'dynamicRegistration': v:false, \ }, + \ 'implementation': { + \ 'dynamicRegistration': v:false, + \ 'linkSupport': v:false, + \ }, \ 'publishDiagnostics': { \ 'relatedInformation': v:true, \ }, \ 'codeAction': { \ 'dynamicRegistration': v:false, + \ 'codeActionLiteralSupport': { + \ 'codeActionKind': { + \ 'valueSet': [] + \ } + \ } \ }, \ 'rename': { \ 'dynamicRegistration': v:false, @@ -401,6 +486,7 @@ function! ale#lsp#StartProgram(conn_id, executable, command) abort let l:options = { \ 'mode': 'raw', \ 'out_cb': {_, message -> ale#lsp#HandleMessage(a:conn_id, message)}, + \ 'exit_cb': { -> ale#lsp#Stop(a:conn_id) }, \} if has('win32') @@ -419,6 +505,7 @@ function! ale#lsp#StartProgram(conn_id, executable, command) abort endif if l:started && !l:conn.is_tsserver + let l:conn.initialized = 0 call s:SendInitMessage(l:conn) endif diff --git a/sources_non_forked/ale/autoload/ale/lsp/message.vim b/sources_non_forked/ale/autoload/ale/lsp/message.vim index b6b14a22..9d5b6228 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/message.vim @@ -35,7 +35,7 @@ function! ale#lsp#message#Initialize(root_path, options, capabilities) abort \ 'rootPath': a:root_path, \ 'capabilities': a:capabilities, \ 'initializationOptions': a:options, - \ 'rootUri': ale#path#ToURI(a:root_path), + \ 'rootUri': ale#util#ToURI(a:root_path), \}] endfunction @@ -52,43 +52,46 @@ function! ale#lsp#message#Exit() abort endfunction function! ale#lsp#message#DidOpen(buffer, language_id) abort - let l:lines = getbufline(a:buffer, 1, '$') - return [1, 'textDocument/didOpen', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ 'languageId': a:language_id, \ 'version': ale#lsp#message#GetNextVersionID(), - \ 'text': join(l:lines, "\n") . "\n", + \ 'text': ale#util#GetBufferContents(a:buffer), \ }, \}] endfunction function! ale#lsp#message#DidChange(buffer) abort - let l:lines = getbufline(a:buffer, 1, '$') - " For changes, we simply send the full text of the document to the server. return [1, 'textDocument/didChange', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ 'version': ale#lsp#message#GetNextVersionID(), \ }, - \ 'contentChanges': [{'text': join(l:lines, "\n") . "\n"}] + \ 'contentChanges': [{'text': ale#util#GetBufferContents(a:buffer)}] \}] endfunction -function! ale#lsp#message#DidSave(buffer) abort - return [1, 'textDocument/didSave', { +function! ale#lsp#message#DidSave(buffer, include_text) abort + let l:response = [1, 'textDocument/didSave', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ }, \}] + + if a:include_text + let l:response[2].textDocument.version = ale#lsp#message#GetNextVersionID() + let l:response[2].text = ale#util#GetBufferContents(a:buffer) + endif + + return l:response endfunction function! ale#lsp#message#DidClose(buffer) abort return [1, 'textDocument/didClose', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ }, \}] endfunction @@ -99,7 +102,7 @@ let s:COMPLETION_TRIGGER_CHARACTER = 2 function! ale#lsp#message#Completion(buffer, line, column, trigger_character) abort let l:message = [0, 'textDocument/completion', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ }, \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \}] @@ -117,7 +120,7 @@ endfunction function! ale#lsp#message#Definition(buffer, line, column) abort return [0, 'textDocument/definition', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ }, \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \}] @@ -126,7 +129,16 @@ endfunction function! ale#lsp#message#TypeDefinition(buffer, line, column) abort return [0, 'textDocument/typeDefinition', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \}] +endfunction + +function! ale#lsp#message#Implementation(buffer, line, column) abort + return [0, 'textDocument/implementation', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ }, \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \}] @@ -135,7 +147,7 @@ endfunction function! ale#lsp#message#References(buffer, line, column) abort return [0, 'textDocument/references', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ }, \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \ 'context': {'includeDeclaration': v:false}, @@ -151,7 +163,7 @@ endfunction function! ale#lsp#message#Hover(buffer, line, column) abort return [0, 'textDocument/hover', { \ 'textDocument': { - \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), \ }, \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \}] @@ -162,3 +174,35 @@ function! ale#lsp#message#DidChangeConfiguration(buffer, config) abort \ 'settings': a:config, \}] endfunction + +function! ale#lsp#message#Rename(buffer, line, column, new_name) abort + return [0, 'textDocument/rename', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \ 'newName': a:new_name, + \}] +endfunction + +function! ale#lsp#message#CodeAction(buffer, line, column, end_line, end_column, diagnostics) abort + return [0, 'textDocument/codeAction', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'range': { + \ 'start': {'line': a:line - 1, 'character': a:column - 1}, + \ 'end': {'line': a:end_line - 1, 'character': a:end_column}, + \ }, + \ 'context': { + \ 'diagnostics': a:diagnostics + \ }, + \}] +endfunction + +function! ale#lsp#message#ExecuteCommand(command, arguments) abort + return [0, 'workspace/executeCommand', { + \ 'command': a:command, + \ 'arguments': a:arguments, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/reset.vim b/sources_non_forked/ale/autoload/ale/lsp/reset.vim index 2fc7f0a2..1801db01 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/reset.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/reset.vim @@ -1,9 +1,16 @@ +" Author: w0rp +" Description: Functions for resetting LSP servers. + +function! s:Message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + " Stop all LSPs and remove all of the data for them. function! ale#lsp#reset#StopAllLSPs() abort call ale#lsp#StopAll() if exists('*ale#definition#ClearLSPData') - " Clear the mapping for connections, etc. + " Clear the go to definition mapping for everything. call ale#definition#ClearLSPData() endif @@ -15,6 +22,8 @@ function! ale#lsp#reset#StopAllLSPs() abort for l:buffer_string in keys(g:ale_buffer_info) let l:buffer = str2nr(l:buffer_string) + " Non-ignored and disabled linters are included here so we can + " clear results for them after we ignore or disable them. for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype')) if !empty(l:linter.lsp) call ale#engine#HandleLoclist(l:linter.name, l:buffer, [], 0) @@ -23,3 +32,61 @@ function! ale#lsp#reset#StopAllLSPs() abort endfor endif endfunction + +function! ale#lsp#reset#Complete(arg, line, pos) abort + let l:linter_map = ale#lsp_linter#GetLSPLinterMap() + let l:candidates = map(values(l:linter_map), {_, linter -> linter.name}) + call uniq(sort(l:candidates)) + call filter(l:candidates, {_, name -> name =~? a:arg}) + + return l:candidates +endfunction + +function! ale#lsp#reset#StopLSP(name, bang) abort + let l:linter_map = ale#lsp_linter#GetLSPLinterMap() + let l:matched = filter( + \ items(l:linter_map), + \ {_, item -> item[1].name is# a:name} + \) + + if empty(l:matched) + if a:bang isnot# '!' + call s:Message('No running language server with name: ' . a:name) + endif + + return + endif + + " Stop LSP connections first. + for [l:conn_id, l:linter] in l:matched + call ale#lsp#Stop(l:conn_id) + endfor + + if exists('*ale#definition#ClearLSPData') + " Clear the go to definition mapping for everything. + call ale#definition#ClearLSPData() + endif + + " Remove connections from the lsp_linter map. + for [l:conn_id, l:linter] in l:matched + call remove(l:linter_map, l:conn_id) + endfor + + " Remove the problems for the LSP linters in every buffer. + for [l:buffer_string, l:info] in items(g:ale_buffer_info) + let l:buffer = str2nr(l:buffer_string) + let l:should_clear_buffer = 0 + + for l:item in l:info.loclist + if l:item.linter_name is# a:name + let l:should_clear_buffer = 1 + + break + endif + endfor + + if l:should_clear_buffer + call ale#engine#HandleLoclist(a:name, l:buffer, [], 0) + endif + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/response.vim b/sources_non_forked/ale/autoload/ale/lsp/response.vim index 30da77e1..498ec508 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/response.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/response.vim @@ -56,9 +56,10 @@ function! ale#lsp#response#ReadDiagnostics(response) abort endif if has_key(l:diagnostic, 'relatedInformation') + \ && l:diagnostic.relatedInformation isnot v:null let l:related = deepcopy(l:diagnostic.relatedInformation) call map(l:related, {key, val -> - \ ale#path#FromURI(val.location.uri) . + \ ale#util#ToResource(val.location.uri) . \ ':' . (val.location.range.start.line + 1) . \ ':' . (val.location.range.start.character + 1) . \ ":\n\t" . val.message diff --git a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim index d6919516..02e57899 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim @@ -36,12 +36,14 @@ function! ale#lsp#tsserver_message#Geterr(buffer) abort return [1, 'ts@geterr', {'files': [expand('#' . a:buffer . ':p')]}] endfunction -function! ale#lsp#tsserver_message#Completions(buffer, line, column, prefix) abort +function! ale#lsp#tsserver_message#Completions( +\ buffer, line, column, prefix, include_external) abort return [0, 'ts@completions', { \ 'line': a:line, \ 'offset': a:column, \ 'file': expand('#' . a:buffer . ':p'), \ 'prefix': a:prefix, + \ 'includeExternalModuleExports': a:include_external, \}] endfunction @@ -62,6 +64,22 @@ function! ale#lsp#tsserver_message#Definition(buffer, line, column) abort \}] endfunction +function! ale#lsp#tsserver_message#TypeDefinition(buffer, line, column) abort + return [0, 'ts@typeDefinition', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#Implementation(buffer, line, column) abort + return [0, 'ts@implementation', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + function! ale#lsp#tsserver_message#References(buffer, line, column) abort return [0, 'ts@references', { \ 'line': a:line, @@ -77,3 +95,71 @@ function! ale#lsp#tsserver_message#Quickinfo(buffer, line, column) abort \ 'file': expand('#' . a:buffer . ':p'), \}] endfunction + +function! ale#lsp#tsserver_message#Rename( +\ buffer, line, column, find_in_comments, find_in_strings) abort + return [0, 'ts@rename', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'arguments': { + \ 'findInComments': a:find_in_comments, + \ 'findInStrings': a:find_in_strings, + \ } + \}] +endfunction + +function! ale#lsp#tsserver_message#GetEditsForFileRename( +\ oldFilePath, newFilePath) abort + return [0, 'ts@getEditsForFileRename', { + \ 'oldFilePath': a:oldFilePath, + \ 'newFilePath': a:newFilePath, + \}] +endfunction + +function! ale#lsp#tsserver_message#OrganizeImports(buffer) abort + return [0, 'ts@organizeImports', { + \ 'scope': { + \ 'type': 'file', + \ 'args': { + \ 'file': expand('#' . a:buffer . ':p'), + \ }, + \ }, + \}] +endfunction + +function! ale#lsp#tsserver_message#GetCodeFixes(buffer, line, column, end_line, end_column, error_codes) abort + " The lines and columns are 1-based. + " The errors codes must be a list of tsserver error codes to fix. + return [0, 'ts@getCodeFixes', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'errorCodes': a:error_codes, + \}] +endfunction + +function! ale#lsp#tsserver_message#GetApplicableRefactors(buffer, line, column, end_line, end_column) abort + " The arguments for this request can also be just 'line' and 'offset' + return [0, 'ts@getApplicableRefactors', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#GetEditsForRefactor(buffer, line, column, end_line, end_column, refactor, action) abort + return [0, 'ts@getEditsForRefactor', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'refactor': a:refactor, + \ 'action': a:action, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp_linter.vim b/sources_non_forked/ale/autoload/ale/lsp_linter.vim index 190a16b4..2507e400 100644 --- a/sources_non_forked/ale/autoload/ale/lsp_linter.vim +++ b/sources_non_forked/ale/autoload/ale/lsp_linter.vim @@ -8,60 +8,124 @@ if !has_key(s:, 'lsp_linter_map') let s:lsp_linter_map = {} endif -" A Dictionary to track one-shot handlers for custom LSP requests -let s:custom_handlers_map = get(s:, 'custom_handlers_map', {}) +" Clear LSP linter data for the linting engine. +function! ale#lsp_linter#ClearLSPData() abort + let s:lsp_linter_map = {} +endfunction + +" Only for internal use. +function! ale#lsp_linter#GetLSPLinterMap() abort + return s:lsp_linter_map +endfunction + +" Just for tests. +function! ale#lsp_linter#SetLSPLinterMap(replacement_map) abort + let s:lsp_linter_map = a:replacement_map +endfunction + +" Get all enabled LSP linters. +" This list still includes linters ignored with `ale_linters_ignore`. +" +" `ale_linters_ignore` is designed to allow language servers to be used for +" their functionality while ignoring the diagnostics they return. +function! ale#lsp_linter#GetEnabled(buffer) abort + let l:filetype = getbufvar(a:buffer, '&filetype') + " Only LSP linters are included here. + let l:linters = filter(ale#linter#Get(l:filetype), '!empty(v:val.lsp)') + let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp') + + " Only load code for ignoring linters if we need it. + if ( + \ l:disable_lsp is 1 + \ || l:disable_lsp is v:true + \ || (l:disable_lsp is# 'auto' && get(g:, 'lspconfig', 0)) + \) + let l:linters = ale#engine#ignore#Exclude( + \ l:filetype, + \ l:linters, + \ [], + \ l:disable_lsp, + \) + endif + + return l:linters +endfunction " Check if diagnostics for a particular linter should be ignored. -function! s:ShouldIgnore(buffer, linter_name) abort - " Ignore all diagnostics if LSP integration is disabled. - if ale#Var(a:buffer, 'disable_lsp') - return 1 - endif - +function! s:ShouldIgnoreDiagnostics(buffer, linter) abort let l:config = ale#Var(a:buffer, 'linters_ignore') + let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp') - " Don't load code for ignoring diagnostics if there's nothing to ignore. - if empty(l:config) - return 0 + " Only load code for ignoring linters if we need it. + if ( + \ !empty(l:config) + \ || l:disable_lsp is 1 + \ || l:disable_lsp is v:true + \ || (l:disable_lsp is# 'auto' && get(g:, 'lspconfig', 0)) + \) + " Re-use the ignore implementation just for this linter. + return empty( + \ ale#engine#ignore#Exclude( + \ getbufvar(a:buffer, '&filetype'), + \ [a:linter], + \ l:config, + \ l:disable_lsp, + \ ) + \) endif - let l:filetype = getbufvar(a:buffer, '&filetype') - let l:ignore_list = ale#engine#ignore#GetList(l:filetype, l:config) - - return index(l:ignore_list, a:linter_name) >= 0 + return 0 endfunction function! s:HandleLSPDiagnostics(conn_id, response) abort - let l:linter_name = s:lsp_linter_map[a:conn_id] - let l:filename = ale#path#FromURI(a:response.params.uri) - let l:buffer = bufnr('^' . l:filename . '$') + let l:linter = get(s:lsp_linter_map, a:conn_id) + + if empty(l:linter) + return + endif + + let l:filename = ale#util#ToResource(a:response.params.uri) + let l:escaped_name = escape( + \ fnameescape(l:filename), + \ has('win32') ? '^' : '^,}]' + \) + let l:buffer = bufnr('^' . l:escaped_name . '$') let l:info = get(g:ale_buffer_info, l:buffer, {}) if empty(l:info) return endif - if s:ShouldIgnore(l:buffer, l:linter_name) + if s:ShouldIgnoreDiagnostics(l:buffer, l:linter) return endif let l:loclist = ale#lsp#response#ReadDiagnostics(a:response) - call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0) + call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist, 0) endfunction function! s:HandleTSServerDiagnostics(response, error_type) abort - let l:linter_name = 'tsserver' - let l:buffer = bufnr('^' . a:response.body.file . '$') + " Re-create a fake linter object for tsserver. + let l:linter = { + \ 'name': 'tsserver', + \ 'aliases': [], + \ 'lsp': 'tsserver', + \} + let l:escaped_name = escape( + \ fnameescape(a:response.body.file), + \ has('win32') ? '^' : '^,}]' + \) + let l:buffer = bufnr('^' . l:escaped_name . '$') let l:info = get(g:ale_buffer_info, l:buffer, {}) if empty(l:info) return endif - call ale#engine#MarkLinterInactive(l:info, l:linter_name) + call ale#engine#MarkLinterInactive(l:info, l:linter.name) - if s:ShouldIgnore(l:buffer, l:linter_name) + if s:ShouldIgnoreDiagnostics(l:buffer, l:linter) return endif @@ -77,12 +141,18 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort endif let l:info.syntax_loclist = l:thislist - else + elseif a:error_type is# 'semantic' if len(l:thislist) is 0 && len(get(l:info, 'semantic_loclist', [])) is 0 let l:no_changes = 1 endif let l:info.semantic_loclist = l:thislist + else + if len(l:thislist) is 0 && len(get(l:info, 'suggestion_loclist', [])) is 0 + let l:no_changes = 1 + endif + + let l:info.suggestion_loclist = l:thislist endif if l:no_changes @@ -90,17 +160,18 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort endif let l:loclist = get(l:info, 'semantic_loclist', []) + \ + get(l:info, 'suggestion_loclist', []) \ + get(l:info, 'syntax_loclist', []) - call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0) + call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist, 0) endfunction -function! s:HandleLSPErrorMessage(linter_name, response) abort +function! s:HandleLSPErrorMessage(linter, response) abort if !g:ale_history_enabled || !g:ale_history_log_output return endif - if empty(a:linter_name) + if empty(a:linter) return endif @@ -110,6 +181,10 @@ function! s:HandleLSPErrorMessage(linter_name, response) abort return endif + call ale#lsp_linter#AddErrorMessage(a:linter.name, l:message) +endfunction + +function! ale#lsp_linter#AddErrorMessage(linter_name, message) abort " This global variable is set here so we don't load the debugging.vim file " until someone uses :ALEInfo. let g:ale_lsp_error_messages = get(g:, 'ale_lsp_error_messages', {}) @@ -118,24 +193,34 @@ function! s:HandleLSPErrorMessage(linter_name, response) abort let g:ale_lsp_error_messages[a:linter_name] = [] endif - call add(g:ale_lsp_error_messages[a:linter_name], l:message) + call add(g:ale_lsp_error_messages[a:linter_name], a:message) endfunction function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort let l:method = get(a:response, 'method', '') if get(a:response, 'jsonrpc', '') is# '2.0' && has_key(a:response, 'error') - let l:linter_name = get(s:lsp_linter_map, a:conn_id, '') + let l:linter = get(s:lsp_linter_map, a:conn_id, {}) - call s:HandleLSPErrorMessage(l:linter_name, a:response) + call s:HandleLSPErrorMessage(l:linter, a:response) elseif l:method is# 'textDocument/publishDiagnostics' call s:HandleLSPDiagnostics(a:conn_id, a:response) + elseif l:method is# 'window/showMessage' + call ale#lsp_window#HandleShowMessage( + \ s:lsp_linter_map[a:conn_id].name, + \ g:ale_lsp_show_message_format, + \ a:response.params + \) elseif get(a:response, 'type', '') is# 'event' \&& get(a:response, 'event', '') is# 'semanticDiag' call s:HandleTSServerDiagnostics(a:response, 'semantic') elseif get(a:response, 'type', '') is# 'event' \&& get(a:response, 'event', '') is# 'syntaxDiag' call s:HandleTSServerDiagnostics(a:response, 'syntax') + elseif get(a:response, 'type', '') is# 'event' + \&& get(a:response, 'event', '') is# 'suggestionDiag' + \&& get(g:, 'ale_lsp_suggestions', '1') == 1 + call s:HandleTSServerDiagnostics(a:response, 'suggestion') endif endfunction @@ -176,7 +261,7 @@ function! ale#lsp_linter#GetConfig(buffer, linter) abort endfunction function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort - let l:buffer_ale_root = getbufvar(a:buffer, 'ale_lsp_root', {}) + let l:buffer_ale_root = getbufvar(a:buffer, 'ale_root', {}) if type(l:buffer_ale_root) is v:t_string return l:buffer_ale_root @@ -194,8 +279,8 @@ function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort endif " Try to get a global setting for the root - if has_key(g:ale_lsp_root, a:linter.name) - let l:Root = g:ale_lsp_root[a:linter.name] + if has_key(g:ale_root, a:linter.name) + let l:Root = g:ale_root[a:linter.name] if type(l:Root) is v:t_func return l:Root(a:buffer) @@ -221,7 +306,7 @@ function! ale#lsp_linter#OnInit(linter, details, Callback) abort let l:command = a:details.command let l:config = ale#lsp_linter#GetConfig(l:buffer, a:linter) - let l:language_id = ale#util#GetFunction(a:linter.language_callback)(l:buffer) + let l:language_id = ale#linter#GetLanguage(l:buffer, a:linter) call ale#lsp#UpdateConfig(l:conn_id, l:buffer, l:config) @@ -236,6 +321,30 @@ function! ale#lsp_linter#OnInit(linter, details, Callback) abort call ale#lsp#NotifyForChanges(l:conn_id, l:buffer) endif + " Tell the relevant buffer that the LSP has started via an autocmd. + if l:buffer > 0 + if l:buffer == bufnr('') + silent doautocmd User ALELSPStarted + else + execute 'augroup ALELSPStartedGroup' . l:buffer + autocmd! + + execute printf( + \ 'autocmd BufEnter ' + \ . ' doautocmd User ALELSPStarted', + \ l:buffer + \) + + " Replicate ++once behavior for backwards compatibility. + execute printf( + \ 'autocmd BufEnter ' + \ . ' autocmd! ALELSPStartedGroup%d', + \ l:buffer, l:buffer + \) + augroup END + endif + endif + call a:Callback(a:linter, a:details) endfunction @@ -259,7 +368,16 @@ function! s:StartLSP(options, address, executable, command) abort call ale#lsp#MarkConnectionAsTsserver(l:conn_id) endif - let l:command = ale#command#FormatCommand(l:buffer, a:executable, a:command, 0, v:false)[1] + let l:cwd = ale#linter#GetCwd(l:buffer, l:linter) + let l:command = ale#command#FormatCommand( + \ l:buffer, + \ a:executable, + \ a:command, + \ 0, + \ v:false, + \ l:cwd, + \ ale#GetFilenameMappings(l:buffer, l:linter.name), + \)[1] let l:command = ale#job#PrepareCommand(l:buffer, l:command) let l:ready = ale#lsp#StartProgram(l:conn_id, a:executable, l:command) endif @@ -346,6 +464,8 @@ function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort if empty(l:root) && a:linter.lsp isnot# 'tsserver' " If there's no project root, then we can't check files with LSP, " unless we are using tsserver, which doesn't use project roots. + call ale#lsp_linter#AddErrorMessage(a:linter.name, "Failed to find project root, language server won't start.") + return 0 endif @@ -382,7 +502,7 @@ function! s:CheckWithLSP(linter, details) abort call ale#lsp#RegisterCallback(l:id, l:Callback) " Remember the linter this connection is for. - let s:lsp_linter_map[l:id] = a:linter.name + let s:lsp_linter_map[l:id] = a:linter if a:linter.lsp is# 'tsserver' let l:message = ale#lsp#tsserver_message#Geterr(l:buffer) @@ -398,7 +518,9 @@ function! s:CheckWithLSP(linter, details) abort " If this was a file save event, also notify the server of that. if a:linter.lsp isnot# 'tsserver' \&& getbufvar(l:buffer, 'ale_save_event_fired', 0) - let l:save_message = ale#lsp#message#DidSave(l:buffer) + \&& ale#lsp#HasCapability(l:id, 'did_save') + let l:include_text = ale#lsp#HasCapability(l:id, 'includeText') + let l:save_message = ale#lsp#message#DidSave(l:buffer, l:include_text) let l:notified = ale#lsp#Send(l:id, l:save_message) != 0 endif endfunction @@ -407,22 +529,16 @@ function! ale#lsp_linter#CheckWithLSP(buffer, linter) abort return ale#lsp_linter#StartLSP(a:buffer, a:linter, function('s:CheckWithLSP')) endfunction -" Clear LSP linter data for the linting engine. -function! ale#lsp_linter#ClearLSPData() abort - let s:lsp_linter_map = {} - let s:custom_handlers_map = {} -endfunction - -" Just for tests. -function! ale#lsp_linter#SetLSPLinterMap(replacement_map) abort - let s:lsp_linter_map = a:replacement_map -endfunction - function! s:HandleLSPResponseToCustomRequests(conn_id, response) abort if has_key(a:response, 'id') - \&& has_key(s:custom_handlers_map, a:response.id) - let l:Handler = remove(s:custom_handlers_map, a:response.id) - call l:Handler(a:response) + " Get the custom handlers Dictionary from the linter map. + let l:linter = get(s:lsp_linter_map, a:conn_id, {}) + let l:custom_handlers = get(l:linter, 'custom_handlers', {}) + + if has_key(l:custom_handlers, a:response.id) + let l:Handler = remove(l:custom_handlers, a:response.id) + call l:Handler(a:response) + endif endif endfunction @@ -433,7 +549,17 @@ function! s:OnReadyForCustomRequests(args, linter, lsp_details) abort if l:request_id > 0 && has_key(a:args, 'handler') let l:Callback = function('s:HandleLSPResponseToCustomRequests') call ale#lsp#RegisterCallback(l:id, l:Callback) - let s:custom_handlers_map[l:request_id] = a:args.handler + + " Remember the linter this connection is for. + let s:lsp_linter_map[l:id] = a:linter + + " Add custom_handlers to the linter Dictionary. + if !has_key(a:linter, 'custom_handlers') + let a:linter.custom_handlers = {} + endif + + " Put the handler function in the map to call later. + let a:linter.custom_handlers[l:request_id] = a:args.handler endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp_window.vim b/sources_non_forked/ale/autoload/ale/lsp_window.vim new file mode 100644 index 00000000..9a27f2f1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp_window.vim @@ -0,0 +1,58 @@ +" Author: suoto +" Description: Handling of window/* LSP methods, although right now only +" handles window/showMessage + +" Constants for message type codes +let s:LSP_MESSAGE_TYPE_DISABLED = 0 +let s:LSP_MESSAGE_TYPE_ERROR = 1 +let s:LSP_MESSAGE_TYPE_WARNING = 2 +let s:LSP_MESSAGE_TYPE_INFORMATION = 3 +let s:LSP_MESSAGE_TYPE_LOG = 4 + +" Translate strings from the user config to a number so we can check +" severities +let s:CFG_TO_LSP_SEVERITY = { +\ 'disabled': s:LSP_MESSAGE_TYPE_DISABLED, +\ 'error': s:LSP_MESSAGE_TYPE_ERROR, +\ 'warning': s:LSP_MESSAGE_TYPE_WARNING, +\ 'information': s:LSP_MESSAGE_TYPE_INFORMATION, +\ 'info': s:LSP_MESSAGE_TYPE_INFORMATION, +\ 'log': s:LSP_MESSAGE_TYPE_LOG +\} + +" Handle window/showMessage response. +" - details: dict containing linter name and format (g:ale_lsp_show_message_format) +" - params: dict with the params for the call in the form of {type: number, message: string} +function! ale#lsp_window#HandleShowMessage(linter_name, format, params) abort + let l:message = a:params.message + let l:type = a:params.type + + " Get the configured severity level threshold and check if the message + " should be displayed or not + let l:configured_severity = tolower(get(g:, 'ale_lsp_show_message_severity', 'error')) + " If the user has configured with a value we can't find on the conversion + " dict, fall back to warning + let l:cfg_severity_threshold = get(s:CFG_TO_LSP_SEVERITY, l:configured_severity, s:LSP_MESSAGE_TYPE_WARNING) + + if l:type > l:cfg_severity_threshold + return + endif + + " Severity will depend on the message type + if l:type is# s:LSP_MESSAGE_TYPE_ERROR + let l:severity = g:ale_echo_msg_error_str + elseif l:type is# s:LSP_MESSAGE_TYPE_INFORMATION + let l:severity = g:ale_echo_msg_info_str + elseif l:type is# s:LSP_MESSAGE_TYPE_LOG + let l:severity = g:ale_echo_msg_log_str + else + " Default to warning just in case + let l:severity = g:ale_echo_msg_warning_str + endif + + let l:string = substitute(a:format, '\V%severity%', l:severity, 'g') + let l:string = substitute(l:string, '\V%linter%', a:linter_name, 'g') + let l:string = substitute(l:string, '\V%s\>', l:message, 'g') + + call ale#util#ShowMessage(l:string) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lua.vim b/sources_non_forked/ale/autoload/ale/lua.vim new file mode 100644 index 00000000..cda81aac --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lua.vim @@ -0,0 +1,28 @@ +" Author: w0rp +" Description: Functions for integrating with Lua linters. + +" Find project root for a Lua language server. +function! ale#lua#FindProjectRoot(buffer) abort + let l:possible_project_roots = [ + \ '.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/maven.vim b/sources_non_forked/ale/autoload/ale/maven.vim new file mode 100644 index 00000000..4f87ebb7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/maven.vim @@ -0,0 +1,57 @@ +" Description: Functions for working with Maven projects. +" +" Given a buffer number, find a Maven project root. +function! ale#maven#FindProjectRoot(buffer) abort + let l:wrapper_path = ale#path#FindNearestFile(a:buffer, 'mvnw') + + if !empty(l:wrapper_path) + return fnamemodify(l:wrapper_path, ':h') + endif + + let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') + + if !empty(l:pom_path) + return fnamemodify(l:pom_path, ':h') + endif + + return '' +endfunction + +" Given a buffer number, find the path to the executable. +" First search on the path for 'mvnw' (mvnw.cmd on Windows), if nothing is found, +" try the global command. Returns an empty string if cannot find the executable. +function! ale#maven#FindExecutable(buffer) abort + let l:wrapper_cmd = has('unix') ? 'mvnw' : 'mvnw.cmd' + let l:wrapper_path = ale#path#FindNearestFile(a:buffer, l:wrapper_cmd) + + if !empty(l:wrapper_path) && executable(l:wrapper_path) + return l:wrapper_path + endif + + if executable('mvn') + return 'mvn' + endif + + return '' +endfunction + +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Maven is not detected. +function! ale#maven#BuildClasspathCommand(buffer) abort + let l:executable = ale#maven#FindExecutable(a:buffer) + + if !empty(l:executable) + let l:project_root = ale#maven#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) . ' dependency:build-classpath' + \] + endif + endif + + return ['', ''] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/node.vim b/sources_non_forked/ale/autoload/ale/node.vim index 69060122..9e11ca7e 100644 --- a/sources_non_forked/ale/autoload/ale/node.vim +++ b/sources_non_forked/ale/autoload/ale/node.vim @@ -3,26 +3,6 @@ call ale#Set('windows_node_executable_path', 'node.exe') -" Given a buffer number, a base variable name, and a list of paths to search -" for in ancestor directories, detect the executable path for a Node program. -" -" The use_global and executable options for the relevant program will be used. -function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort - if ale#Var(a:buffer, a:base_var_name . '_use_global') - return ale#Var(a:buffer, a:base_var_name . '_executable') - endif - - for l:path in a:path_list - let l:executable = ale#path#FindNearestFile(a:buffer, l:path) - - if !empty(l:executable) - return l:executable - endif - endfor - - return ale#Var(a:buffer, a:base_var_name . '_executable') -endfunction - " Create a executable string which executes a Node.js script command with a " Node.js executable if needed. " diff --git a/sources_non_forked/ale/autoload/ale/organize_imports.vim b/sources_non_forked/ale/autoload/ale/organize_imports.vim new file mode 100644 index 00000000..fb00bc21 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/organize_imports.vim @@ -0,0 +1,63 @@ +" Author: Jerko Steiner +" Description: Organize imports support for tsserver + +function! ale#organize_imports#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') isnot# 'organizeImports' + return + endif + + if get(a:response, 'success', v:false) isnot v:true + return + endif + + let l:file_code_edits = a:response.body + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'Organize Imports', + \ 'changes': l:file_code_edits, + \ }, + \ { + \ 'conn_id': a:conn_id, + \ 'should_save': g:ale_save_hidden || !&hidden, + \ }, + \) +endfunction + +function! s:OnReady(linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if a:linter.lsp isnot# 'tsserver' + call ale#util#Execute('echom ''OrganizeImports currently only works with tsserver''') + + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = function('ale#organize_imports#HandleTSServerResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:message = ale#lsp#tsserver_message#OrganizeImports(l:buffer) + + let l:request_id = ale#lsp#Send(l:id, l:message) +endfunction + +function! s:OrganizeImports(linter) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + + if a:linter.lsp isnot# 'tsserver' + let l:column = min([l:column, len(getline(l:line))]) + endif + + let l:Callback = function('s:OnReady') + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#organize_imports#Execute() abort + for l:linter in ale#lsp_linter#GetEnabled(bufnr('')) + call s:OrganizeImports(l:linter) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/path.vim b/sources_non_forked/ale/autoload/ale/path.vim index 84c26d0a..cc5c6658 100644 --- a/sources_non_forked/ale/autoload/ale/path.vim +++ b/sources_non_forked/ale/autoload/ale/path.vim @@ -24,6 +24,14 @@ function! ale#path#Simplify(path) abort return substitute(simplify(l:win_path), '^\\\+', '\', 'g') " no-custom-checks endfunction +" Simplify a path without a Windows drive letter. +" This function can be used for checking if paths are equal. +function! ale#path#RemoveDriveLetter(path) abort + return has('win32') && a:path[1:2] is# ':\' + \ ? ale#path#Simplify(a:path[2:]) + \ : ale#path#Simplify(a:path) +endfunction + " Given a buffer and a filename, find the nearest file by searching upwards " through the paths relative to the given buffer. function! ale#path#FindNearestFile(buffer, filename) abort @@ -54,14 +62,14 @@ function! ale#path#FindNearestDirectory(buffer, directory_name) abort return '' endfunction -" Given a buffer, a string to search for, an a global fallback for when +" Given a buffer, a string to search for, and a global fallback for when " the search fails, look for a file in parent paths, and if that fails, " use the global fallback path instead. function! ale#path#ResolveLocalPath(buffer, search_string, global_fallback) abort " Search for a locally installed file first. let l:path = ale#path#FindNearestFile(a:buffer, a:search_string) - " If the serach fails, try the global executable instead. + " If the search fails, try the global executable instead. if empty(l:path) let l:path = a:global_fallback endif @@ -69,20 +77,40 @@ function! ale#path#ResolveLocalPath(buffer, search_string, global_fallback) abor return l:path endfunction -" Output 'cd && ' -" This function can be used changing the directory for a linter command. -function! ale#path#CdString(directory) abort - if has('win32') - return 'cd /d ' . ale#Escape(a:directory) . ' && ' - else - return 'cd ' . ale#Escape(a:directory) . ' && ' - endif +" Given a buffer number, a base variable name, and a list of paths to search +" for in ancestor directories, detect the executable path for a program. +function! ale#path#FindNearestExecutable(buffer, path_list) abort + for l:path in a:path_list + if ale#path#IsAbsolute(l:path) + let l:executable = filereadable(l:path) ? l:path : '' + else + let l:executable = ale#path#FindNearestFile(a:buffer, l:path) + endif + + if !empty(l:executable) + return l:executable + endif + endfor + + return '' endfunction -" Output 'cd && ' -" This function can be used changing the directory for a linter command. -function! ale#path#BufferCdString(buffer) abort - return ale#path#CdString(fnamemodify(bufname(a:buffer), ':p:h')) +" Given a buffer number, a base variable name, and a list of paths to search +" for in ancestor directories, detect the executable path for a program. +" +" The use_global and executable options for the relevant program will be used. +function! ale#path#FindExecutable(buffer, base_var_name, path_list) abort + if ale#Var(a:buffer, a:base_var_name . '_use_global') + return ale#Var(a:buffer, a:base_var_name . '_executable') + endif + + let l:nearest = ale#path#FindNearestExecutable(a:buffer, a:path_list) + + if !empty(l:nearest) + return l:nearest + endif + + return ale#Var(a:buffer, a:base_var_name . '_executable') endfunction " Return 1 if a path is an absolute path. @@ -95,7 +123,7 @@ function! ale#path#IsAbsolute(filename) abort return a:filename[:0] is# '/' || a:filename[1:2] is# ':\' endfunction -let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h')) +let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h')) " Given a filename, return 1 if the file represents some temporary file " created by Vim. @@ -124,7 +152,7 @@ function! ale#path#Dirname(path) abort endif " For /foo/bar/ we need :h:h to get /foo - if a:path[-1:] is# '/' + if a:path[-1:] is# '/' || (has('win32') && a:path[-1:] is# '\') return fnamemodify(a:path, ':h:h') endif @@ -190,7 +218,7 @@ endfunction " Convert a filesystem path to a file:// URI " relatives paths will not be prefixed with the protocol. " For Windows paths, the `:` in C:\ etc. will not be percent-encoded. -function! ale#path#ToURI(path) abort +function! ale#path#ToFileURI(path) abort let l:has_drive_letter = a:path[1:2] is# ':\' return substitute( @@ -203,7 +231,7 @@ function! ale#path#ToURI(path) abort \) endfunction -function! ale#path#FromURI(uri) abort +function! ale#path#FromFileURI(uri) abort if a:uri[:6] is? 'file://' let l:encoded_path = a:uri[7:] elseif a:uri[:4] is? 'file:' diff --git a/sources_non_forked/ale/autoload/ale/preview.vim b/sources_non_forked/ale/autoload/ale/preview.vim index 6d58aca9..1aca03ea 100644 --- a/sources_non_forked/ale/autoload/ale/preview.vim +++ b/sources_non_forked/ale/autoload/ale/preview.vim @@ -1,6 +1,22 @@ " Author: w0rp " Description: Preview windows for showing whatever information in. +if !has_key(s:, 'last_list') + let s:last_list = [] +endif + +if !has_key(s:, 'last_options') + let s:last_options = {} +endif + +function! ale#preview#SetLastSelection(item_list, options) abort + let s:last_list = a:item_list + let s:last_options = { + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), + \ 'use_relative_paths': get(a:options, 'use_relative_paths', 0), + \} +endfunction + " Open a preview window and show some lines in it. " A second argument can be passed as a Dictionary with options. They are... " @@ -23,6 +39,10 @@ function! ale#preview#Show(lines, ...) abort setlocal readonly let &l:filetype = get(l:options, 'filetype', 'ale-preview') + for l:command in get(l:options, 'commands', []) + call execute(l:command) + endfor + if get(l:options, 'stay_here') wincmd p endif @@ -67,32 +87,51 @@ function! ale#preview#ShowSelection(item_list, ...) abort call ale#preview#Show(l:lines, {'filetype': 'ale-preview-selection'}) let b:ale_preview_item_list = a:item_list + let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer') + + " Jump to an index for a previous selection, if set. + if has_key(l:options, 'jump_to_index') + let l:pos = getpos('.') + let l:pos[1] = l:options.jump_to_index + 1 + call setpos('.', l:pos) + endif + + " Remember preview state, so we can repeat it later. + call ale#preview#SetLastSelection(a:item_list, l:options) endfunction -function! s:Open(open_in_tab) abort +function! ale#preview#RepeatSelection() abort + if !empty(s:last_list) + call ale#preview#ShowSelection(s:last_list, s:last_options) + endif +endfunction + +function! s:Open(open_in) abort let l:item_list = get(b:, 'ale_preview_item_list', []) - let l:item = get(l:item_list, getpos('.')[1] - 1, {}) + let l:index = getpos('.')[1] - 1 + let l:item = get(l:item_list, l:index, {}) if empty(l:item) return endif - if !a:open_in_tab - :q! - endif + " Remember an index to jump to when repeating a selection. + let s:last_options.jump_to_index = l:index + + :q! call ale#util#Open( \ l:item.filename, \ l:item.line, \ l:item.column, - \ {'open_in_tab': a:open_in_tab}, + \ {'open_in': a:open_in}, \) endfunction -function! ale#preview#OpenSelectionInBuffer() abort - call s:Open(0) +function! ale#preview#OpenSelection() abort + call s:Open(b:ale_preview_item_open_in) endfunction function! ale#preview#OpenSelectionInTab() abort - call s:Open(1) + call s:Open('tab') endfunction diff --git a/sources_non_forked/ale/autoload/ale/python.vim b/sources_non_forked/ale/autoload/ale/python.vim index 7ed22367..148683d6 100644 --- a/sources_non_forked/ale/autoload/ale/python.vim +++ b/sources_non_forked/ale/autoload/ale/python.vim @@ -1,19 +1,24 @@ -" Author: w0rp +" Author: w0rp " Description: Functions for integrating with Python linters. 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. let s:bin_dir = has('unix') ? 'bin' : 'Scripts' +" The default virtualenv directory names are ordered from the likely most +" common names down to the least common. `.env` might be more common, but it's +" also likely to conflict with a `.env` file for environment variables, so we +" search for it last. (People really shouldn't use that name.) let g:ale_virtualenv_dir_names = get(g:, 'ale_virtualenv_dir_names', [ -\ '.env', \ '.venv', \ 'env', -\ 've-py3', \ 've', -\ 'virtualenv', \ 'venv', +\ 'virtualenv', +\ '.env', \]) function! ale#python#FindProjectRootIni(buffer) abort @@ -23,15 +28,23 @@ function! ale#python#FindProjectRootIni(buffer) abort \|| filereadable(l:path . '/setup.cfg') \|| filereadable(l:path . '/pytest.ini') \|| filereadable(l:path . '/tox.ini') + \|| filereadable(l:path . '/.pyre_configuration.local') \|| filereadable(l:path . '/mypy.ini') + \|| filereadable(l:path . '/.mypy.ini') \|| filereadable(l:path . '/pycodestyle.cfg') \|| filereadable(l:path . '/.flake8') \|| filereadable(l:path . '/.flake8rc') \|| filereadable(l:path . '/pylama.ini') \|| filereadable(l:path . '/pylintrc') \|| filereadable(l:path . '/.pylintrc') + \|| filereadable(l:path . '/pyrightconfig.json') + \|| filereadable(l:path . '/pyrightconfig.toml') \|| filereadable(l:path . '/Pipfile') \|| filereadable(l:path . '/Pipfile.lock') + \|| 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 @@ -88,6 +101,32 @@ function! ale#python#FindVirtualenv(buffer) abort return $VIRTUAL_ENV endfunction +" Automatically determine virtualenv environment variables and build +" a string of them to prefix linter commands with. +function! ale#python#AutoVirtualenvEnvString(buffer) abort + let l:venv_dir = ale#python#FindVirtualenv(a:buffer) + + if !empty(l:venv_dir) + let l:strs = [ ] + " venv/bin directory + let l:pathdir = join([l:venv_dir, s:bin_dir], s:sep) + + " expand PATH correctly inside of the appropriate shell. + " set VIRTUAL_ENV to point to venv + if has('win32') + call add(l:strs, 'set PATH=' . ale#Escape(l:pathdir) . ';%PATH% && ') + call add(l:strs, 'set VIRTUAL_ENV=' . ale#Escape(l:venv_dir) . ' && ') + else + call add(l:strs, 'PATH=' . ale#Escape(l:pathdir) . '":$PATH" ') + call add(l:strs, 'VIRTUAL_ENV=' . ale#Escape(l:venv_dir) . ' ') + endif + + return join(l:strs, '') + endif + + return '' +endfunction + " Given a buffer number and a command name, find the path to the executable. " First search on a virtualenv for Python, if nothing is found, try the global " command. Returns an empty string if cannot find the executable @@ -155,3 +194,13 @@ endfunction function! ale#python#PipenvPresent(buffer) abort return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' endfunction + +" Detects whether a poetry environment is present. +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/racket.vim b/sources_non_forked/ale/autoload/ale/racket.vim new file mode 100644 index 00000000..ff896108 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/racket.vim @@ -0,0 +1,12 @@ +function! ale#racket#FindProjectRoot(buffer) abort + let l:cwd = expand('#' . a:buffer . ':p:h') + let l:highest_init = l:cwd + + for l:path in ale#path#Upwards(l:cwd) + if filereadable(l:path.'/init.rkt') + let l:highest_init = l:path + endif + endfor + + return l:highest_init +endfunction diff --git a/sources_non_forked/ale/autoload/ale/references.vim b/sources_non_forked/ale/autoload/ale/references.vim index b9725e1e..e8cbda9e 100644 --- a/sources_non_forked/ale/autoload/ale/references.vim +++ b/sources_non_forked/ale/autoload/ale/references.vim @@ -1,3 +1,5 @@ +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') + let s:references_map = {} " Used to get the references map in tests. @@ -14,6 +16,26 @@ function! ale#references#ClearLSPData() abort let s:references_map = {} endfunction +function! ale#references#FormatTSResponseItem(response_item, options) abort + let l:match = substitute(a:response_item.lineText, '^\s*\(.\{-}\)\s*$', '\1', '') + + 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, + \ 'text': l:match, + \} + else + return { + \ 'filename': a:response_item.file, + \ 'line': a:response_item.start.line, + \ 'column': a:response_item.start.offset, + \ 'match': l:match, + \} + endif +endfunction + function! ale#references#HandleTSServerResponse(conn_id, response) abort if get(a:response, 'command', '') is# 'references' \&& has_key(s:references_map, a:response.request_seq) @@ -23,23 +45,43 @@ function! ale#references#HandleTSServerResponse(conn_id, response) abort let l:item_list = [] for l:response_item in a:response.body.refs - call add(l:item_list, { - \ 'filename': l:response_item.file, - \ 'line': l:response_item.start.line, - \ 'column': l:response_item.start.offset, - \ 'match': substitute(l:response_item.lineText, '^\s*\(.\{-}\)\s*$', '\1', ''), - \}) + call add( + \ l:item_list, + \ ale#references#FormatTSResponseItem(l:response_item, l:options) + \) endfor if empty(l:item_list) call ale#util#Execute('echom ''No references found.''') else - call ale#preview#ShowSelection(l:item_list, l:options) + 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#preview#ShowSelection(l:item_list, l:options) + endif endif endif endif endfunction +function! ale#references#FormatLSPResponseItem(response_item, options) abort + if get(a:options, 'open_in') is# 'quickfix' + return { + \ 'filename': ale#util#ToResource(a:response_item.uri), + \ 'lnum': a:response_item.range.start.line + 1, + \ 'col': a:response_item.range.start.character + 1, + \} + else + return { + \ 'filename': ale#util#ToResource(a:response_item.uri), + \ 'line': a:response_item.range.start.line + 1, + \ 'column': a:response_item.range.start.character + 1, + \} + endif +endfunction + function! ale#references#HandleLSPResponse(conn_id, response) abort if has_key(a:response, 'id') \&& has_key(s:references_map, a:response.id) @@ -51,18 +93,22 @@ function! ale#references#HandleLSPResponse(conn_id, response) abort if type(l:result) is v:t_list for l:response_item in l:result - call add(l:item_list, { - \ 'filename': ale#path#FromURI(l:response_item.uri), - \ 'line': l:response_item.range.start.line + 1, - \ 'column': l:response_item.range.start.character + 1, - \}) + call add(l:item_list, + \ ale#references#FormatLSPResponseItem(l:response_item, l:options) + \) endfor endif if empty(l:item_list) call ale#util#Execute('echom ''No references found.''') else - call ale#preview#ShowSelection(l:item_list, l:options) + 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#preview#ShowSelection(l:item_list, l:options) + endif endif endif endfunction @@ -99,7 +145,8 @@ function! s:OnReady(line, column, options, linter, lsp_details) abort let l:request_id = ale#lsp#Send(l:id, l:message) let s:references_map[l:request_id] = { - \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0 + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0, + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), \} endfunction @@ -110,18 +157,32 @@ function! ale#references#Find(...) abort for l:option in a:000 if l:option is? '-relative' let l:options.use_relative_paths = 1 + elseif l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' + elseif l:option is? '-quickfix' + let l:options.open_in = 'quickfix' endif endfor endif + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + let l:buffer = bufnr('') let [l:line, l:column] = getpos('.')[1:2] let l:column = min([l:column, len(getline(l:line))]) let l:Callback = function('s:OnReady', [l:line, l:column, l:options]) - for l:linter in ale#linter#Get(&filetype) - if !empty(l:linter.lsp) - call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) - endif + for l:linter in ale#lsp_linter#GetEnabled(l:buffer) + call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) endfor endfunction diff --git a/sources_non_forked/ale/autoload/ale/rename.vim b/sources_non_forked/ale/autoload/ale/rename.vim new file mode 100644 index 00000000..d7bc8699 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/rename.vim @@ -0,0 +1,204 @@ +" Author: Jerko Steiner +" Description: Rename symbol support for LSP / tsserver + +let s:rename_map = {} + +" Used to get the rename map in tests. +function! ale#rename#GetMap() abort + return deepcopy(s:rename_map) +endfunction + +" Used to set the rename map in tests. +function! ale#rename#SetMap(map) abort + let s:rename_map = a:map +endfunction + +function! ale#rename#ClearLSPData() abort + let s:rename_map = {} +endfunction + +let g:ale_rename_tsserver_find_in_comments = get(g:, 'ale_rename_tsserver_find_in_comments') +let g:ale_rename_tsserver_find_in_strings = get(g:, 'ale_rename_tsserver_find_in_strings') + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +function! ale#rename#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') isnot# 'rename' + return + endif + + if !has_key(s:rename_map, a:response.request_seq) + return + endif + + let l:options = remove(s:rename_map, a:response.request_seq) + + let l:old_name = l:options.old_name + let l:new_name = l:options.new_name + + if get(a:response, 'success', v:false) is v:false + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error renaming "' . l:old_name . '" to: "' . l:new_name + \ . '". Reason: ' . l:message) + + return + endif + + let l:changes = [] + + for l:response_item in a:response.body.locs + let l:filename = l:response_item.file + let l:text_changes = [] + + for l:loc in l:response_item.locs + call add(l:text_changes, { + \ 'start': { + \ 'line': l:loc.start.line, + \ 'offset': l:loc.start.offset, + \ }, + \ 'end': { + \ 'line': l:loc.end.line, + \ 'offset': l:loc.end.offset, + \ }, + \ 'newText': l:new_name, + \}) + endfor + + call add(l:changes, { + \ 'fileName': l:filename, + \ 'textChanges': l:text_changes, + \}) + endfor + + if empty(l:changes) + call s:message('Error renaming "' . l:old_name . '" to: "' . l:new_name . '"') + + return + endif + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'rename', + \ 'changes': l:changes, + \ }, + \ { + \ 'conn_id': a:conn_id, + \ 'should_save': g:ale_save_hidden || !&hidden, + \ }, + \) +endfunction + +function! ale#rename#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:rename_map, a:response.id) + let l:options = remove(s:rename_map, a:response.id) + + if !has_key(a:response, 'result') + call s:message('No rename result received from server') + + return + endif + + let l:changes_map = ale#code_action#GetChanges(a:response.result) + + if empty(l:changes_map) + call s:message('No changes received from server') + + return + endif + + let l:changes = ale#code_action#BuildChangesList(l:changes_map) + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'rename', + \ 'changes': l:changes, + \ }, + \ { + \ 'conn_id': a:conn_id, + \ 'should_save': g:ale_save_hidden || !&hidden, + \ }, + \) + endif +endfunction + +function! s:OnReady(line, column, options, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'rename') + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#rename#HandleTSServerResponse') + \ : function('ale#rename#HandleLSPResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#Rename( + \ l:buffer, + \ a:line, + \ a:column, + \ g:ale_rename_tsserver_find_in_comments, + \ g:ale_rename_tsserver_find_in_strings, + \) + else + " Send a message saying the buffer has changed first, or the + " rename position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:message = ale#lsp#message#Rename( + \ l:buffer, + \ a:line, + \ a:column, + \ a:options.new_name + \) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:rename_map[l:request_id] = a:options +endfunction + +function! s:ExecuteRename(linter, options) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + + if a:linter.lsp isnot# 'tsserver' + let l:column = min([l:column, len(getline(l:line))]) + endif + + let l:Callback = function('s:OnReady', [l:line, l:column, a:options]) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#rename#Execute() abort + let l:linters = ale#lsp_linter#GetEnabled(bufnr('')) + + if empty(l:linters) + call s:message('No active LSPs') + + return + endif + + let l:old_name = expand('') + let l:new_name = ale#util#Input('New name: ', l:old_name) + + if empty(l:new_name) + call s:message('New name cannot be empty!') + + return + endif + + for l:linter in l:linters + call s:ExecuteRename(l:linter, { + \ 'old_name': l:old_name, + \ 'new_name': l:new_name, + \}) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/ruby.vim b/sources_non_forked/ale/autoload/ale/ruby.vim index 15e835c9..d941bb2c 100644 --- a/sources_non_forked/ale/autoload/ale/ruby.vim +++ b/sources_non_forked/ale/autoload/ale/ruby.vim @@ -74,3 +74,10 @@ function! ale#ruby#HandleRubocopOutput(buffer, lines) abort return l:output endfunction +function! ale#ruby#EscapeExecutable(executable, bundle_exec) abort + let l:exec_args = a:executable =~? 'bundle' + \ ? ' exec ' . a:bundle_exec + \ : '' + + return ale#Escape(a:executable) . l:exec_args +endfunction diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim index eb0dd1cd..e78ce468 100644 --- a/sources_non_forked/ale/autoload/ale/sign.vim +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -9,17 +9,21 @@ let g:ale_max_signs = get(g:, 'ale_max_signs', -1) " there are errors. let g:ale_change_sign_column_color = get(g:, 'ale_change_sign_column_color', 0) " These variables dictate what signs are used to indicate errors and warnings. -let g:ale_sign_error = get(g:, 'ale_sign_error', '>>') +let g:ale_sign_error = get(g:, 'ale_sign_error', 'E') let g:ale_sign_style_error = get(g:, 'ale_sign_style_error', g:ale_sign_error) -let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--') +let g:ale_sign_warning = get(g:, 'ale_sign_warning', 'W') let g:ale_sign_style_warning = get(g:, 'ale_sign_style_warning', g:ale_sign_warning) -let g:ale_sign_info = get(g:, 'ale_sign_info', g:ale_sign_warning) +let g:ale_sign_info = get(g:, 'ale_sign_info', 'I') +let g:ale_sign_priority = get(g:, 'ale_sign_priority', 30) " This variable sets an offset which can be set for sign IDs. " This ID can be changed depending on what IDs are set for other plugins. " The dummy sign will use the ID exactly equal to the offset. let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) " This flag can be set to 1 to keep sign gutter always open let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) +let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0) + +let s:supports_sign_groups = has('nvim-0.4.2') || has('patch-8.1.614') if !hlexists('ALEErrorSign') highlight link ALEErrorSign error @@ -46,9 +50,10 @@ if !hlexists('ALESignColumnWithErrors') endif function! ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() abort - redir => l:output - 0verbose silent highlight SignColumn - redir end + let l:verbose = &verbose + set verbose=0 + let l:output = execute('highlight SignColumn', 'silent') + let &verbose = l:verbose let l:highlight_syntax = join(split(l:output)[2:]) let l:match = matchlist(l:highlight_syntax, '\vlinks to (.+)$') @@ -80,9 +85,9 @@ execute 'sign define ALEStyleWarningSign text=' . s:EscapeSignText(g:ale_sign_st \ . ' texthl=ALEStyleWarningSign linehl=ALEWarningLine' execute 'sign define ALEInfoSign text=' . s:EscapeSignText(g:ale_sign_info) \ . ' texthl=ALEInfoSign linehl=ALEInfoLine' -sign define ALEDummySign +sign define ALEDummySign text=\ texthl=SignColumn -if has('nvim-0.3.2') +if g:ale_sign_highlight_linenrs && (has('nvim-0.3.2') || has('patch-8.2.3874')) if !hlexists('ALEErrorSignLineNr') highlight link ALEErrorSignLineNr CursorLineNr endif @@ -146,24 +151,80 @@ function! ale#sign#GetSignName(sublist) abort return 'ALEErrorSign' endfunction +function! s:PriorityCmd() abort + if s:supports_sign_groups + return ' priority=' . g:ale_sign_priority . ' ' + else + return '' + endif +endfunction + +function! s:GroupCmd() abort + if s:supports_sign_groups + return ' group=ale_signs ' + else + return ' ' + endif +endfunction + " Read sign data for a buffer to a list of lines. function! ale#sign#ReadSigns(buffer) abort - redir => l:output - silent execute 'sign place buffer=' . a:buffer - redir end + let l:output = execute( + \ 'sign place ' . s:GroupCmd() . s:PriorityCmd() + \ . ' buffer=' . a:buffer + \ ) return split(l:output, "\n") endfunction +function! ale#sign#ParsePattern() abort + if s:supports_sign_groups + " Matches output like : + " line=4 id=1 group=ale_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 + " строка=1 id=1000001 имя=ALEErrorSign + " 行=1 識別子=1000001 名前=ALEWarningSign + " línea=12 id=1000001 nombre=ALEWarningSign + " riga=1 id=1000001 nome=ALEWarningSign + " Zeile=235 id=1000001 Name=ALEErrorSign + let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=(ALE[a-zA-Z]+Sign)' + endif + + return l:pattern +endfunction + +" Given a 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_signs' : '' })[0].signs + let l:result = [] + let l:is_dummy_sign_set = 0 + + for l:sign in l:signs + if l:sign['name'] is# 'ALEDummySign' + let l:is_dummy_sign_set = 1 + else + call add(l:result, [ + \ str2nr(l:sign['lnum']), + \ str2nr(l:sign['id']), + \ l:sign['name'], + \]) + endif + endfor + + return [l:is_dummy_sign_set, l:result] +endfunction + " Given a list of lines for sign output, return a List of [line, id, group] function! ale#sign#ParseSigns(line_list) abort - " Matches output like : - " line=4 id=1 name=ALEErrorSign - " строка=1 id=1000001 имя=ALEErrorSign - " 行=1 識別子=1000001 名前=ALEWarningSign - " línea=12 id=1000001 nombre=ALEWarningSign - " riga=1 id=1000001, nome=ALEWarningSign - let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=(ALE[a-zA-Z]+Sign)' + let l:pattern =ale#sign#ParsePattern() let l:result = [] let l:is_dummy_sign_set = 0 @@ -187,9 +248,13 @@ function! ale#sign#ParseSigns(line_list) abort endfunction function! ale#sign#FindCurrentSigns(buffer) abort - let l:line_list = ale#sign#ReadSigns(a:buffer) + if exists('*sign_getplaced') + return ale#sign#ParseSignsWithGetPlaced(a:buffer) + else + let l:line_list = ale#sign#ReadSigns(a:buffer) - return ale#sign#ParseSigns(l:line_list) + return ale#sign#ParseSigns(l:line_list) + endif endfunction " Given a loclist, group the List into with one List per line. @@ -318,8 +383,10 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort if !l:is_dummy_sign_set && (!empty(a:sign_map) || g:ale_sign_column_always) call add(l:command_list, 'sign place ' \ . g:ale_sign_offset - \ . ' line=1 name=ALEDummySign buffer=' - \ . a:buffer + \ . s:GroupCmd() + \ . s:PriorityCmd() + \ . ' line=1 name=ALEDummySign ' + \ . ' buffer=' . a:buffer \) let l:is_dummy_sign_set = 1 endif @@ -336,6 +403,8 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort if index(l:info.current_id_list, l:info.new_id) < 0 call add(l:command_list, 'sign place ' \ . (l:info.new_id) + \ . s:GroupCmd() + \ . s:PriorityCmd() \ . ' line=' . l:line_str \ . ' name=' . (l:info.new_name) \ . ' buffer=' . a:buffer @@ -350,6 +419,7 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort if l:current_id isnot l:info.new_id call add(l:command_list, 'sign unplace ' \ . l:current_id + \ . s:GroupCmd() \ . ' buffer=' . a:buffer \) endif @@ -360,6 +430,7 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort if l:is_dummy_sign_set && !g:ale_sign_column_always call add(l:command_list, 'sign unplace ' \ . g:ale_sign_offset + \ . s:GroupCmd() \ . ' buffer=' . a:buffer \) endif @@ -414,3 +485,12 @@ function! ale#sign#SetSigns(buffer, loclist) abort highlight link SignColumn ALESignColumnWithoutErrors endif endfunction + +" Remove all signs. +function! ale#sign#Clear() abort + if s:supports_sign_groups + sign unplace group=ale_signs * + else + sign unplace * + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/socket.vim b/sources_non_forked/ale/autoload/ale/socket.vim index 7e069fb5..61f11e70 100644 --- a/sources_non_forked/ale/autoload/ale/socket.vim +++ b/sources_non_forked/ale/autoload/ale/socket.vim @@ -72,9 +72,8 @@ function! ale#socket#Open(address, options) abort elseif exists('*chansend') && exists('*sockconnect') " NeoVim 0.3+ try - let l:channel_id = sockconnect('tcp', a:address, { - \ 'on_data': function('s:NeoVimOutputCallback'), - \}) + let l:channel_id = sockconnect(stridx(a:address, ':') != -1 ? 'tcp' : 'pipe', + \ a:address, {'on_data': function('s:NeoVimOutputCallback')}) let l:channel_info.last_line = '' catch /connection failed/ let l:channel_id = -1 diff --git a/sources_non_forked/ale/autoload/ale/swift.vim b/sources_non_forked/ale/autoload/ale/swift.vim index b31b8dc5..3232d42a 100644 --- a/sources_non_forked/ale/autoload/ale/swift.vim +++ b/sources_non_forked/ale/autoload/ale/swift.vim @@ -11,3 +11,60 @@ function! ale#swift#FindProjectRoot(buffer) abort return '' endfunction + +" Support Apple Swift Format {{{1 + +call ale#Set('swift_appleswiftformat_executable', 'swift-format') +call ale#Set('swift_appleswiftformat_use_swiftpm', 0) + +" Return the executable depending on whether or not to use Swift Package Manager. +" +" If not asked to use Swift Package Manager (use_swiftpm = 0), the returned +" value is the global executable, else the returned value is 'swift' because +" the final command line will be `swift run swift-format ...`. +" +" Failure is expected if use_swiftpm is `1` but no Package.swift can be located. +function! ale#swift#GetAppleSwiftFormatExecutable(buffer) abort + if !ale#Var(a:buffer, 'swift_appleswiftformat_use_swiftpm') + return ale#Var(a:buffer, 'swift_appleswiftformat_executable') + endif + + if ale#path#FindNearestFile(a:buffer, 'Package.swift') is# '' + " If there is no Package.swift file, we don't use swift-format even if it exists, + " so we return '' to indicate failure. + return '' + endif + + return 'swift' +endfunction + +" Return the command depending on whether or not to use Swift Package Manager. +" +" If asked to use Swift Package Manager (use_swiftpm = 1), the command +" arguments are prefixed with 'swift run'. +" +" In either case, the configuration file is located and added to the command. +function! ale#swift#GetAppleSwiftFormatCommand(buffer) abort + let l:executable = ale#swift#GetAppleSwiftFormatExecutable(a:buffer) + let l:command_args = '' + + if ale#Var(a:buffer, 'swift_appleswiftformat_use_swiftpm') + let l:command_args = ' ' . 'run swift-format' + endif + + return ale#Escape(l:executable) . l:command_args +endfunction + +" Locate the nearest '.swift-format' configuration file, and return the +" arguments, else return an empty string. +function! ale#swift#GetAppleSwiftFormatConfigArgs(buffer) abort + let l:config_filepath = ale#path#FindNearestFile(a:buffer, '.swift-format') + + if l:config_filepath isnot# '' + return '--configuration' . ' ' . l:config_filepath + endif + + return '' +endfunction + +" }}} diff --git a/sources_non_forked/ale/autoload/ale/symbol.vim b/sources_non_forked/ale/autoload/ale/symbol.vim index ae4151ab..ba971e74 100644 --- a/sources_non_forked/ale/autoload/ale/symbol.vim +++ b/sources_non_forked/ale/autoload/ale/symbol.vim @@ -41,7 +41,7 @@ function! ale#symbol#HandleLSPResponse(conn_id, response) abort let l:location = l:response_item.location call add(l:item_list, { - \ 'filename': ale#path#FromURI(l:location.uri), + \ 'filename': ale#util#ToResource(l:location.uri), \ 'line': l:location.range.start.line + 1, \ 'column': l:location.range.start.character + 1, \ 'match': l:response_item.name, @@ -102,8 +102,8 @@ function! ale#symbol#Search(args) abort call setbufvar(l:buffer, 'ale_symbol_request_made', 0) let l:Callback = function('s:OnReady', [l:query, l:options]) - for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype')) - if !empty(l:linter.lsp) && l:linter.lsp isnot# 'tsserver' + for l:linter in ale#lsp_linter#GetEnabled(l:buffer) + if l:linter.lsp isnot# 'tsserver' call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) endif endfor diff --git a/sources_non_forked/ale/autoload/ale/test.vim b/sources_non_forked/ale/autoload/ale/test.vim index 082d91ff..e03ecb65 100644 --- a/sources_non_forked/ale/autoload/ale/test.vim +++ b/sources_non_forked/ale/autoload/ale/test.vim @@ -34,12 +34,11 @@ function! ale#test#RestoreDirectory() abort unlet! g:dir endfunction -" Change the filename for the current buffer using a relative path to -" the script without running autocmd commands. +" Get a filename for the current buffer using a relative path to the script. " " If a g:dir variable is set, it will be used as the path to the directory " containing the test file. -function! ale#test#SetFilename(path) abort +function! ale#test#GetFilename(path) abort let l:dir = get(g:, 'dir', '') if empty(l:dir) @@ -50,28 +49,47 @@ function! ale#test#SetFilename(path) abort \ ? a:path \ : l:dir . '/' . a:path - silent! noautocmd execute 'file ' . fnameescape(ale#path#Simplify(l:full_path)) + return ale#path#Simplify(l:full_path) endfunction -function! s:RemoveModule(results) abort +" Change the filename for the current buffer using a relative path to +" the script without running autocmd commands. +" +" If a g:dir variable is set, it will be used as the path to the directory +" containing the test file. +function! ale#test#SetFilename(path) abort + let l:full_path = ale#test#GetFilename(a:path) + silent! noautocmd execute 'file ' . fnameescape(l:full_path) +endfunction + +function! RemoveNewerKeys(results) abort for l:item in a:results if has_key(l:item, 'module') call remove(l:item, 'module') endif + + if has_key(l:item, 'end_col') + call remove(l:item, 'end_col') + endif + + if has_key(l:item, 'end_lnum') + call remove(l:item, 'end_lnum') + endif endfor endfunction -" Return loclist data without the module string, only in newer Vim versions. -function! ale#test#GetLoclistWithoutModule() abort +" Return loclist data with only the keys supported by the lowest Vim versions. +function! ale#test#GetLoclistWithoutNewerKeys() abort let l:results = getloclist(0) - call s:RemoveModule(l:results) + call RemoveNewerKeys(l:results) return l:results endfunction -function! ale#test#GetQflistWithoutModule() abort +" Return quickfix data with only the keys supported by the lowest Vim versions. +function! ale#test#GetQflistWithoutNewerKeys() abort let l:results = getqflist() - call s:RemoveModule(l:results) + call RemoveNewerKeys(l:results) return l:results endfunction @@ -145,8 +163,8 @@ function! ale#test#WaitForJobs(deadline) abort " end, but before handlers are run. sleep 10ms - " We must check the buffer data again to see if new jobs started - " for command_chain linters. + " We must check the buffer data again to see if new jobs started for + " linters with chained commands. let l:has_new_jobs = 0 " Check again to see if any jobs are running. diff --git a/sources_non_forked/ale/autoload/ale/toggle.vim b/sources_non_forked/ale/autoload/ale/toggle.vim index 1311e527..8b38e5ad 100644 --- a/sources_non_forked/ale/autoload/ale/toggle.vim +++ b/sources_non_forked/ale/autoload/ale/toggle.vim @@ -14,8 +14,8 @@ function! s:DisablePostamble() abort call ale#highlight#UpdateHighlights() endif - if g:ale_virtualtext_cursor - call ale#virtualtext#Clear() + if g:ale_virtualtext_cursor isnot# 'disabled' && g:ale_virtualtext_cursor != 0 + call ale#virtualtext#Clear(bufnr('')) endif endfunction @@ -64,7 +64,8 @@ function! ale#toggle#ToggleBuffer(buffer) abort " Disabling ALE globally removes autocmd events, so we cannot enable " linting locally when linting is disabled globally if l:enabled && !g:ale_enabled - execute 'echom ''ALE cannot be enabled locally when disabled globally''' + " no-custom-checks + echom 'ALE cannot be enabled locally when disabled globally' return endif diff --git a/sources_non_forked/ale/autoload/ale/uri.vim b/sources_non_forked/ale/autoload/ale/uri.vim index 934637d9..d696f03d 100644 --- a/sources_non_forked/ale/autoload/ale/uri.vim +++ b/sources_non_forked/ale/autoload/ale/uri.vim @@ -1,9 +1,18 @@ -" This probably doesn't handle Unicode characters well. +function! s:EncodeChar(char) abort + let l:result = '' + + for l:index in range(strlen(a:char)) + let l:result .= printf('%%%02x', char2nr(a:char[l:index])) + endfor + + return l:result +endfunction + function! ale#uri#Encode(value) abort return substitute( \ a:value, \ '\([^a-zA-Z0-9\\/$\-_.!*''(),]\)', - \ '\=printf(''%%%02x'', char2nr(submatch(1)))', + \ '\=s:EncodeChar(submatch(1))', \ 'g' \) endfunction @@ -12,7 +21,23 @@ function! ale#uri#Decode(value) abort return substitute( \ a:value, \ '%\(\x\x\)', - \ '\=nr2char(''0x'' . submatch(1))', + \ '\=printf("%c", str2nr(submatch(1), 16))', \ 'g' \) endfunction + +let s:uri_handlers = { +\ 'jdt': { +\ 'OpenURILink': function('ale#uri#jdt#OpenJDTLink'), +\ } +\} + +function! ale#uri#GetURIHandler(uri) abort + for l:scheme in keys(s:uri_handlers) + if a:uri =~# '^'.l:scheme.'://' + return s:uri_handlers[scheme] + endif + endfor + + return v:null +endfunction diff --git a/sources_non_forked/ale/autoload/ale/uri/jdt.vim b/sources_non_forked/ale/autoload/ale/uri/jdt.vim new file mode 100644 index 00000000..7df10b4e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/uri/jdt.vim @@ -0,0 +1,112 @@ +" Author: yoshi1123 +" Description: Functions for working with jdt:// URIs. + +function! s:OpenJDTLink(root, uri, line, column, options, result) abort + if has_key(a:result, 'error') + " no-custom-checks + echoerr a:result.error.message + + return + endif + + let l:contents = a:result['result'] + + if type(l:contents) is# type(v:null) + " no-custom-checks + echoerr 'File content not found' + endif + + " disable autocmd when opening buffer + autocmd! AleURISchemes + call ale#util#Open(a:uri, a:line, a:column, a:options) + autocmd AleURISchemes BufNewFile,BufReadPre jdt://** call ale#uri#jdt#ReadJDTLink(expand('')) + + if !empty(getbufvar(bufnr(''), 'ale_root', '')) + return + endif + + let b:ale_root = a:root + set filetype=java + + call setline(1, split(l:contents, '\n')) + call cursor(a:line, a:column) + normal! zz + + setlocal buftype=nofile nomodified nomodifiable readonly +endfunction + +" Load new buffer with jdt:// contents and jump to line and column. +function! ale#uri#jdt#OpenJDTLink(encoded_uri, line, column, options, conn_id) abort + let l:found_eclipselsp = v:false + + " We should only arrive here from a 'go to definition' request, so we'll + " assume the eclipselsp linter is enabled. + for l:linter in ale#linter#Get('java') + if l:linter.name is# 'eclipselsp' + let l:found_eclipselsp = v:true + endif + endfor + + if !l:found_eclipselsp + throw 'eclipselsp not running' + endif + + let l:root = a:conn_id[stridx(a:conn_id, ':')+1:] + let l:uri = a:encoded_uri + call ale#lsp_linter#SendRequest( + \ bufnr(''), + \ 'eclipselsp', + \ [0, 'java/classFileContents', {'uri': ale#util#ToURI(l:uri)}], + \ function('s:OpenJDTLink', [l:root, l:uri, a:line, a:column, a:options]) + \) +endfunction + +function! s:ReadClassFileContents(uri, result) abort + if has_key(a:result, 'error') + " no-custom-checks + echoerr a:result.error.message + + return + endif + + let l:contents = a:result['result'] + + if type(l:contents) is# type(v:null) + " no-custom-checks + echoerr 'File content not found' + endif + + call setline(1, split(l:contents, '\n')) + + setlocal buftype=nofile nomodified nomodifiable readonly +endfunction + +" Read jdt:// contents, as part of current project, into current buffer. +function! ale#uri#jdt#ReadJDTLink(encoded_uri) abort + if !empty(getbufvar(bufnr(''), 'ale_root', '')) + return + endif + + let l:linter_map = ale#lsp_linter#GetLSPLinterMap() + + for [l:conn_id, l:linter] in items(l:linter_map) + if l:linter.name is# 'eclipselsp' + let l:root = l:conn_id[stridx(l:conn_id, ':')+1:] + endif + endfor + + if l:root is# v:null + throw 'eclipselsp not running' + endif + + let l:uri = a:encoded_uri + let b:ale_root = l:root + set filetype=java + + call ale#lsp_linter#SendRequest( + \ bufnr(''), + \ 'eclipselsp', + \ [0, 'java/classFileContents', {'uri': ale#util#ToURI(l:uri)}], + \ function('s:ReadClassFileContents', [l:uri]) + \) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index e7563608..98af1635 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -16,19 +16,25 @@ endfunction " Vim 8 does not support echoing long messages from asynchronous callbacks, " but NeoVim does. Small messages can be echoed in Vim 8, and larger messages " have to be shown in preview windows. -function! ale#util#ShowMessage(string) abort +function! ale#util#ShowMessage(string, ...) abort + let l:options = get(a:000, 0, {}) + if !has('nvim') call ale#preview#CloseIfTypeMatches('ale-preview.message') endif " We have to assume the user is using a monospace font. if has('nvim') || (a:string !~? "\n" && len(a:string) < &columns) - execute 'echo a:string' + " no-custom-checks + echo a:string else - call ale#preview#Show(split(a:string, "\n"), { - \ 'filetype': 'ale-preview.message', - \ 'stay_here': 1, - \}) + call ale#preview#Show(split(a:string, "\n"), extend( + \ { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \ }, + \ l:options, + \)) endif endfunction @@ -91,17 +97,17 @@ endfunction " options['open_in'] can be: " current-buffer (default) " tab -" vertical-split -" horizontal-split +" split +" vsplit function! ale#util#Open(filename, line, column, options) abort let l:open_in = get(a:options, 'open_in', 'current-buffer') let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename) if l:open_in is# 'tab' call ale#util#Execute('tabedit ' . l:args_to_open) - elseif l:open_in is# 'horizontal-split' + elseif l:open_in is# 'split' call ale#util#Execute('split ' . l:args_to_open) - elseif l:open_in is# 'vertical-split' + elseif l:open_in is# 'vsplit' call ale#util#Execute('vsplit ' . l:args_to_open) elseif bufnr(a:filename) isnot bufnr('') " Open another file only if we need to. @@ -335,16 +341,22 @@ function! ale#util#GetMatches(lines, patterns) abort return l:matches endfunction +" Given a single line, or a List of lines, and a single pattern, or a List of +" patterns, and a callback function for mapping the items matches, return the +" result of mapping all of the matches for the lines from the given patterns, +" using matchlist() +" +" Only the first pattern which matches a line will be returned. +function! ale#util#MapMatches(lines, patterns, Callback) abort + return map(ale#util#GetMatches(a:lines, a:patterns), 'a:Callback(v:val)') +endfunction + function! s:LoadArgCount(function) abort - let l:Function = a:function - - redir => l:output - silent! function Function - redir END - - if !exists('l:output') + try + let l:output = execute('function a:function') + catch /E123/ return 0 - endif + endtry let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2] let l:arg_list = filter(split(l:match, ', '), 'v:val isnot# ''...''') @@ -408,7 +420,7 @@ function! ale#util#FuzzyJSONDecode(data, default) abort endif return l:result - catch /E474/ + catch /E474\|E491/ return a:default endtry endfunction @@ -422,7 +434,10 @@ function! ale#util#Writefile(buffer, lines, filename) abort \ ? map(copy(a:lines), 'substitute(v:val, ''\r*$'', ''\r'', '''')') \ : a:lines - call writefile(l:corrected_lines, a:filename, 'S') " no-custom-checks + " Set binary flag if buffer doesn't have eol and nofixeol to avoid appending newline + let l:flags = !getbufvar(a:buffer, '&eol') && exists('+fixeol') && !&fixeol ? 'bS' : 'S' + + call writefile(l:corrected_lines, a:filename, l:flags) " no-custom-checks endfunction if !exists('s:patial_timers') @@ -477,3 +492,94 @@ function! ale#util#FindItemAtCursor(buffer) abort return [l:info, l:loc] endfunction +function! ale#util#Input(message, value, ...) abort + if a:0 > 0 + return input(a:message, a:value, a:1) + else + return input(a:message, a:value) + endif +endfunction + +function! ale#util#HasBuflineApi() abort + return exists('*deletebufline') && exists('*setbufline') +endfunction + +" Sets buffer contents to lines +function! ale#util#SetBufferContents(buffer, lines) abort + let l:has_bufline_api = ale#util#HasBuflineApi() + + if !l:has_bufline_api && a:buffer isnot bufnr('') + return + endif + + " If the file is in DOS mode, we have to remove carriage returns from + " the ends of lines before calling setline(), or we will see them + " twice. + let l:new_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' + \ ? map(copy(a:lines), 'substitute(v:val, ''\r\+$'', '''', '''')') + \ : a:lines + let l:first_line_to_remove = len(l:new_lines) + 1 + + " Use a Vim API for setting lines in other buffers, if available. + if l:has_bufline_api + if has('nvim') + " save and restore signs to avoid flickering + let signs = sign_getplaced(a:buffer, {'group': 'ale'})[0].signs + + call nvim_buf_set_lines(a:buffer, 0, l:first_line_to_remove, 0, l:new_lines) + + " restore signs (invalid line numbers will be skipped) + call sign_placelist(map(signs, {_, v -> extend(v, {'buffer': a:buffer})})) + else + call setbufline(a:buffer, 1, l:new_lines) + endif + + call deletebufline(a:buffer, l:first_line_to_remove, '$') + " Fall back on setting lines the old way, for the current buffer. + else + let l:old_line_length = line('$') + + if l:old_line_length >= l:first_line_to_remove + let l:save = winsaveview() + silent execute + \ l:first_line_to_remove . ',' . l:old_line_length . 'd_' + call winrestview(l:save) + endif + + call setline(1, l:new_lines) + endif + + return l:new_lines +endfunction + +function! ale#util#GetBufferContents(buffer) abort + return join(getbufline(a:buffer, 1, '$'), "\n") . "\n" +endfunction + +function! ale#util#ToURI(resource) abort + let l:uri_handler = ale#uri#GetURIHandler(a:resource) + + if l:uri_handler is# v:null + " resource is a filesystem path + let l:uri = ale#path#ToFileURI(a:resource) + else + " resource is a URI + let l:uri = a:resource + endif + + return l:uri +endfunction + +function! ale#util#ToResource(uri) abort + let l:uri_handler = ale#uri#GetURIHandler(a:uri) + + if l:uri_handler is# v:null + " resource is a filesystem path + let l:resource = ale#path#FromFileURI(a:uri) + else + " resource is a URI + let l:resource = a:uri + endif + + return l:resource +endfunction diff --git a/sources_non_forked/ale/autoload/ale/virtualtext.vim b/sources_non_forked/ale/autoload/ale/virtualtext.vim index d7c5360e..551211e8 100644 --- a/sources_non_forked/ale/autoload/ale/virtualtext.vim +++ b/sources_non_forked/ale/autoload/ale/virtualtext.vim @@ -3,17 +3,8 @@ scriptencoding utf-8 " Author: Luan Santos " Description: Shows lint message for the current line as virtualtext, if any -" Controls the milliseconds delay before showing a message. -let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10) -let s:cursor_timer = -1 -let s:last_pos = [0, 0, 0] - -if has('nvim-0.3.2') - let s:ns_id = nvim_create_namespace('ale') -endif - if !hlexists('ALEVirtualTextError') - highlight link ALEVirtualTextError ALEError + highlight link ALEVirtualTextError Comment endif if !hlexists('ALEVirtualTextStyleError') @@ -21,7 +12,7 @@ if !hlexists('ALEVirtualTextStyleError') endif if !hlexists('ALEVirtualTextWarning') - highlight link ALEVirtualTextWarning ALEWarning + highlight link ALEVirtualTextWarning Comment endif if !hlexists('ALEVirtualTextStyleWarning') @@ -32,27 +23,39 @@ if !hlexists('ALEVirtualTextInfo') highlight link ALEVirtualTextInfo ALEVirtualTextWarning endif -function! ale#virtualtext#Clear() abort - if !has('nvim-0.3.2') - return +let g:ale_virtualtext_prefix = +\ get(g:, 'ale_virtualtext_prefix', '%comment% %type%: ') +" Controls the milliseconds delay before showing a message. +let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10) + +" Controls the positioning of virtualtext +let g:ale_virtualtext_column = get(g:, 'ale_virtualtext_column', 0) +let g:ale_virtualtext_maxcolumn = get(g:, 'ale_virtualtext_maxcolumn', 0) +" If 1, only show the first problem with virtualtext. +let g:ale_virtualtext_single = get(g:, 'ale_virtualtext_single', 1) + +let s:cursor_timer = get(s:, 'cursor_timer', -1) +let s:last_pos = get(s:, 'last_pos', [0, 0, 0]) +let s:hl_list = get(s:, 'hl_list', []) +let s:last_message = '' + +if !has_key(s:, 'has_virt_text') + let s:has_virt_text = 0 + let s:emulate_virt = 0 + let s:last_virt = -1 + + if has('nvim-0.3.2') + let s:ns_id = nvim_create_namespace('ale') + let s:has_virt_text = 1 + elseif has('textprop') && has('popupwin') + let s:has_virt_text = 1 + let s:emulate_virt = !has('patch-9.0.0297') + + if s:emulate_virt + call prop_type_add('ale', {}) + endif endif - - let l:buffer = bufnr('') - - call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1) -endfunction - -function! ale#virtualtext#ShowMessage(message, hl_group) abort - if !has('nvim-0.3.2') - return - endif - - let l:line = line('.') - let l:buffer = bufnr('') - let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ') - - call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, a:hl_group]], {}) -endfunction +endif function! s:StopCursorTimer() abort if s:cursor_timer != -1 @@ -61,61 +64,199 @@ function! s:StopCursorTimer() abort endif endfunction +function! ale#virtualtext#ResetDataForTests() abort + let s:last_pos = [0, 0, 0] + let s:last_message = '' +endfunction + +function! ale#virtualtext#GetLastMessageForTests() abort + return s:last_message +endfunction + +function! ale#virtualtext#GetComment(buffer) abort + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:split = split(getbufvar(a:buffer, '&commentstring'), '%s') + + return !empty(l:split) ? trim(l:split[0]) : '#' +endfunction + +function! ale#virtualtext#Clear(buffer) abort + if !s:has_virt_text || !bufexists(str2nr(a:buffer)) + return + endif + + if has('nvim') + call nvim_buf_clear_namespace(a:buffer, s:ns_id, 0, -1) + else + if s:emulate_virt && s:last_virt != -1 + call prop_remove({'type': 'ale'}) + call popup_close(s:last_virt) + let s:last_virt = -1 + elseif !empty(s:hl_list) + call prop_remove({ + \ 'types': s:hl_list, + \ 'all': 1, + \ 'bufnr': a:buffer, + \}) + endif + endif +endfunction + +function! ale#virtualtext#GetGroup(item) abort + let l:type = get(a:item, 'type', 'E') + let l:sub_type = get(a:item, 'sub_type', '') + + if l:type is# 'E' + if l:sub_type is# 'style' + return 'ALEVirtualTextStyleError' + endif + + return 'ALEVirtualTextError' + endif + + if l:type is# 'W' + if l:sub_type is# 'style' + return 'ALEVirtualTextStyleWarning' + endif + + return 'ALEVirtualTextWarning' + endif + + return 'ALEVirtualTextInfo' +endfunction + +function! ale#virtualtext#GetColumnPadding(buffer, line) abort + let l:mincol = ale#Var(a:buffer, 'virtualtext_column') + let l:maxcol = ale#Var(a:buffer, 'virtualtext_maxcolumn') + let l:win = bufwinnr(a:buffer) + + if l:mincol[len(l:mincol)-1] is# '%' + let l:mincol = (winwidth(l:win) * l:mincol) / 100 + endif + + if l:maxcol[len(l:maxcol)-1] is# '%' + let l:maxcol = (winwidth(l:win) * l:maxcol) / 100 + endif + + " Calculate padding for virtualtext alignment + if l:mincol > 0 || l:maxcol > 0 + let l:line_width = strdisplaywidth(getline(a:line)) + + if l:line_width < l:mincol + return l:mincol - l:line_width + elseif l:maxcol > 0 && l:line_width >= l:maxcol + " Stop processing if virtualtext would start beyond maxcol + return -1 + endif + endif + + " no padding. + return 0 +endfunction + +function! ale#virtualtext#ShowMessage(buffer, item) abort + if !s:has_virt_text || !bufexists(str2nr(a:buffer)) + return + endif + + let l:line = max([1, a:item.lnum]) + let l:hl_group = ale#virtualtext#GetGroup(a:item) + + " Get a language-appropriate comment character, or default to '#'. + let l:comment = ale#virtualtext#GetComment(a:buffer) + let l:prefix = ale#Var(a:buffer, 'virtualtext_prefix') + let l:prefix = ale#GetLocItemMessage(a:item, l:prefix) + let l:prefix = substitute(l:prefix, '\V%comment%', '\=l:comment', 'g') + let l:msg = l:prefix . substitute(a:item.text, '\n', ' ', 'g') + let l:col_pad = ale#virtualtext#GetColumnPadding(a:buffer, l:line) + + " Store the last message we're going to set so we can read it in tests. + let s:last_message = l:msg + + " Discard virtualtext if padding is negative. + if l:col_pad < 0 + return + endif + + if has('nvim') + call nvim_buf_set_virtual_text( + \ a:buffer, + \ s:ns_id, l:line - 1, + \ [[l:msg, l:hl_group]], + \ {} + \) + elseif s:emulate_virt + let l:left_pad = col('$') + call prop_add(l:line, l:left_pad, {'type': 'ale'}) + let s:last_virt = popup_create(l:msg, { + \ 'line': -1, + \ 'padding': [0, 0, 0, 1], + \ 'mask': [[1, 1, 1, 1]], + \ 'textprop': 'ale', + \ 'highlight': l:hl_group, + \ 'fixed': 1, + \ 'wrap': 0, + \ 'zindex': 2 + \}) + else + let l:type = prop_type_get(l:hl_group) + + if l:type == {} + call prop_type_add(l:hl_group, {'highlight': l:hl_group}) + endif + + " Add highlight groups to the list so we can clear them later. + if index(s:hl_list, l:hl_group) == -1 + call add(s:hl_list, l:hl_group) + endif + + " We ignore all errors from prop_add. + silent! call prop_add(l:line, 0, { + \ 'type': l:hl_group, + \ 'text': ' ' . l:msg, + \ 'bufnr': a:buffer, + \ 'text_padding_left': l:col_pad, + \}) + endif +endfunction + function! ale#virtualtext#ShowCursorWarning(...) abort - if !g:ale_virtualtext_cursor + if g:ale_virtualtext_cursor isnot# 'current' + \&& g:ale_virtualtext_cursor != 1 return endif let l:buffer = bufnr('') if mode(1) isnot# 'n' + \|| g:ale_use_neovim_diagnostics_api + \|| ale#ShouldDoNothing(l:buffer) return endif - if ale#ShouldDoNothing(l:buffer) - return - endif + let [l:info, l:item] = ale#util#FindItemAtCursor(l:buffer) + call ale#virtualtext#Clear(l:buffer) - let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) - - call ale#virtualtext#Clear() - - if !empty(l:loc) - let l:msg = l:loc.text - let l:hl_group = 'ALEVirtualTextInfo' - let l:type = get(l:loc, 'type', 'E') - - if l:type is# 'E' - if get(l:loc, 'sub_type', '') is# 'style' - let l:hl_group = 'ALEVirtualTextStyleError' - else - let l:hl_group = 'ALEVirtualTextError' - endif - elseif l:type is# 'W' - if get(l:loc, 'sub_type', '') is# 'style' - let l:hl_group = 'ALEVirtualTextStyleWarning' - else - let l:hl_group = 'ALEVirtualTextWarning' - endif - endif - - call ale#virtualtext#ShowMessage(l:msg, l:hl_group) + if !empty(l:item) + call ale#virtualtext#ShowMessage(l:buffer, l:item) endif endfunction function! ale#virtualtext#ShowCursorWarningWithDelay() abort let l:buffer = bufnr('') - if !g:ale_virtualtext_cursor - return - endif - - if mode(1) isnot# 'n' + if g:ale_virtualtext_cursor isnot# 'current' + \&& g:ale_virtualtext_cursor != 1 return endif call s:StopCursorTimer() + if mode(1) isnot# 'n' + \|| g:ale_use_neovim_diagnostics_api + return + endif + let l:pos = getpos('.')[0:2] " Check the current buffer, line, and column number against the last @@ -133,3 +274,52 @@ function! ale#virtualtext#ShowCursorWarningWithDelay() abort endif endfunction +function! ale#virtualtext#CompareSeverityPerLine(left, right) abort + " Compare lines + if a:left.lnum < a:right.lnum + return -1 + endif + + if a:left.lnum > a:right.lnum + return 1 + endif + + let l:left_priority = ale#util#GetItemPriority(a:left) + let l:right_priority = ale#util#GetItemPriority(a:right) + + " Put highest priority items first. + if l:left_priority > l:right_priority + return -1 + endif + + if l:left_priority < l:right_priority + return 1 + endif + + " Put the first seen problem first. + return a:left.col - a:right.col +endfunction + +function! ale#virtualtext#SetTexts(buffer, loclist) abort + if !has('nvim') && s:emulate_virt + return + endif + + call ale#virtualtext#Clear(a:buffer) + + let l:buffer_list = filter(copy(a:loclist), 'v:val.bufnr == a:buffer') + + if ale#Var(a:buffer,'virtualtext_single') + " If we want a single problem per line, sort items on each line by + " highest severity and then lowest column position, then de-duplicate + " the items by line. + call uniq( + \ sort(l:buffer_list, function('ale#virtualtext#CompareSeverityPerLine')), + \ {a, b -> a.lnum - b.lnum} + \) + endif + + for l:item in l:buffer_list + call ale#virtualtext#ShowMessage(a:buffer, l:item) + endfor +endfunction diff --git a/sources_non_forked/ale/doc/ale-ada.txt b/sources_non_forked/ale/doc/ale-ada.txt index 2ac30c0a..80321dbb 100644 --- a/sources_non_forked/ale/doc/ale-ada.txt +++ b/sources_non_forked/ale/doc/ale-ada.txt @@ -2,6 +2,11 @@ ALE Ada Integration *ale-ada-options* +=============================================================================== +cspell *ale-ada-cspell* + +See |ale-cspell-options| + =============================================================================== gcc *ale-ada-gcc* @@ -32,5 +37,35 @@ g:ale_ada_gnatpp_options *g:ale_ada_gnatpp_options* This variable can be set to pass extra options to the gnatpp fixer. +=============================================================================== +ada-language-server *ale-ada-language-server* + +g:ale_ada_adals_executable *g:ale_ada_adals_executable* + *b:ale_ada_adals_executable* + Type: |String| + Default: `'ada_language_server'` + + This variable can be changed to use a different executable for Ada Language + Server. + + +g:ale_ada_adals_project *g:ale_ada_adals_project* + *b:ale_ada_adals_project* + Type: |String| + Default: `'default.gpr'` + +This variable can be changed to use a different GPR file for +Ada Language Server. + + +g:ale_ada_adals_encoding *g:ale_ada_adals_encoding* + *b:ale_ada_adals_encoding* + Type: |String| + Default: `'utf-8'` + +This variable can be changed to use a different file encoding for +Ada Language Server. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-ansible.txt b/sources_non_forked/ale/doc/ale-ansible.txt index 3a4efaa5..41442b08 100644 --- a/sources_non_forked/ale/doc/ale-ansible.txt +++ b/sources_non_forked/ale/doc/ale-ansible.txt @@ -1,6 +1,28 @@ =============================================================================== ALE Ansible Integration *ale-ansible-options* +=============================================================================== +ansible-language-server *ale-ansible-language-server* + + +g:ale_ansible_language_server_executable *g:ale_ansible_language_server* + *b:ale_ansible_language_server* + + Type: |String| + Default: 'ansible-language-server' + + Variable can be used to modify the executable used for ansible language server. + + +g:ale_ansible_language_server_config *g:ale_ansible_language_server_config* + *b:ale_ansible_language_server_config* + + Type: |Dictionary| + Default: '{}' + + Configuration parameters sent to the language server on start. Refer to the + ansible language server configuration documentation for list of available + options: https://als.readthedocs.io/en/latest/settings/ =============================================================================== ansible-lint *ale-ansible-ansible-lint* @@ -12,5 +34,6 @@ g:ale_ansible_ansible_lint_executable *g:ale_ansible_ansible_lint_executable* This variable can be changed to modify the executable used for ansible-lint. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-apkbuild.txt b/sources_non_forked/ale/doc/ale-apkbuild.txt new file mode 100644 index 00000000..f80ca290 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-apkbuild.txt @@ -0,0 +1,61 @@ +=============================================================================== +ALE APKBUILD Integration *ale-apkbuild-options* + + +=============================================================================== +apkbuild-fixer *ale-apkbuild-apkbuild-fixer* + +g:apkbuild_apkbuild_fixer_options *g:apkbuild_apkbuild_fixer_options* + *b:apkbuild_apkbuild_fixer_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the apkbuild_fixer + fixer. + + +g:apkbuild_apkbuild_fixer_executable *g:apkbuild_apkbuild_fixer_executable* + *b:apkbuild_apkbuild_fixer_executable* + Type: |String| + Default: `'apkbuild-fixer'` + + This variable can be modified to change the executable path for + `apkbuild-fixer`. + + +g:apkbuild_apkbuild_fixer_lint_executable + *g:apkbuild_apkbuild_fixer_lint_executable* + *b:apkbuild_apkbuild_fixer_lint_executable* + Type: |String| + Default: `'apkbuild-fixer'` + + This variable can be modified to change the executable path for + `apkbuild-lint`, the binary used to find violations. + + +=============================================================================== +apkbuild-lint *ale-apkbuild-apkbuild-lint* + +g:ale_apkbuild_apkbuild_lint_executable + *g:ale_apkbuild_apkbuild_lint_executable* + *b:ale_apkbuild_apkbuild_lint_executable* + + Type: |String| + Default: `'apkbuild-lint'` + + This variable can be set to change the path to apkbuild-lint + +=============================================================================== +secfixes-check *ale-apkbuild-secfixes-check* + +g:ale_apkbuild_secfixes_check_executable + *g:ale_apkbuild_secfixes_check_executable* + *b:ale_apkbuild_secfixes_check_executable* + + Type: |String| + Default: `'secfixes-check'` + + This variable can be set to change the path to secfixes-check + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-asciidoc.txt b/sources_non_forked/ale/doc/ale-asciidoc.txt index 86629fd4..dd8b12ff 100644 --- a/sources_non_forked/ale/doc/ale-asciidoc.txt +++ b/sources_non_forked/ale/doc/ale-asciidoc.txt @@ -2,6 +2,12 @@ ALE AsciiDoc Integration *ale-asciidoc-options* +=============================================================================== +cspell *ale-asciidoc-cspell* + +See |ale-cspell-options| + + =============================================================================== write-good *ale-asciidoc-write-good* diff --git a/sources_non_forked/ale/doc/ale-asm.txt b/sources_non_forked/ale/doc/ale-asm.txt index a97c6d00..c5fec7d6 100644 --- a/sources_non_forked/ale/doc/ale-asm.txt +++ b/sources_non_forked/ale/doc/ale-asm.txt @@ -21,5 +21,24 @@ g:ale_asm_gcc_options *g:ale_asm_gcc_options* This variable can be set to pass additional options to gcc. +=============================================================================== +llvm_mc *ale-asm-llvm_mc* + +g:ale_asm_clang_executable *g:ale_asm_llvm_mc_executable* + *b:ale_asm_llvm_mc_executable* + Type: |String| + Default: `'llvm-mc'` + +This variable can be changed to use a different executable for llvm-mc. + + +g:ale_asm_clang_options *g:ale_asm_llvm_mc_options* + *b:ale_asm_llvm_mc_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to llvm-mc. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: 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-avra.txt b/sources_non_forked/ale/doc/ale-avra.txt new file mode 100644 index 00000000..a61913ad --- /dev/null +++ b/sources_non_forked/ale/doc/ale-avra.txt @@ -0,0 +1,26 @@ +=============================================================================== +ALE AVRA Integration *ale-avra-options* + + +=============================================================================== +avra *ale-avra-avra* + +g:ale_avra_avra_executable *g:ale_avra_avra_executable* + *b:ale_avra_avra_executable* + + Type: |String| + Default `'avra'` + + This variable can be changed to use different executable for AVRA. + + +g:ale_avra_avra_options *g:ale_avra_avra_options* + *b:ale_avra_avra_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to AVRA. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-bats.txt b/sources_non_forked/ale/doc/ale-bats.txt new file mode 100644 index 00000000..cf2199ec --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bats.txt @@ -0,0 +1,13 @@ +=============================================================================== +ALE Bats Integration *ale-bats-options* + + +=============================================================================== +shellcheck *ale-bats-shellcheck* + +The `shellcheck` linter for Bats uses the sh options for `shellcheck`; see: +|ale-sh-shellcheck|. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-bazel.txt b/sources_non_forked/ale/doc/ale-bazel.txt new file mode 100644 index 00000000..e2922aaf --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bazel.txt @@ -0,0 +1,28 @@ +=============================================================================== +ALE Bazel Integration *ale-bazel-options* + +=============================================================================== +buildifier *ale-bazel-buildifier* + +g:ale_bazel_buildifier_executable *g:ale_bazel_buildifier_executable* + *b:ale_bazel_buildifier_executable* + Type: |String| + Default: `'buildifier'` + + See |ale-integrations-local-executables| + + +g:ale_bazel_buildifier_options *g:ale_bazel_buildifier_options* + *b:ale_bazel_buildifier_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to buildifier. + + +g:ale_bazel_buildifier_use_global *g:ale_bazel_buildifier_use_global* + *b:ale_bazel_buildifier_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-bicep.txt b/sources_non_forked/ale/doc/ale-bicep.txt new file mode 100644 index 00000000..a5ab645d --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bicep.txt @@ -0,0 +1,43 @@ +=============================================================================== +ALE Bicep Integration *ale-bicep-options* + + +=============================================================================== +bicep *ale-bicep-bicep* + +g:ale_bicep_bicep_executable *g:ale_bicep_bicep_executable* + *b:ale_bicep_bicep_executable* + Type: |String| + Default: `'bicep'` + + This variable can be set to change the path to bicep. + + +g:ale_bicep_bicep_options *g:ale_bicep_bicep_options* + *b:ale_bicep_bicep_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to bicep. + + +=============================================================================== +az_bicep *ale-bicep-az_bicep* + +g:ale_bicep_az_bicep_executable *g:ale_bicep_az_bicep_executable* + *b:ale_bicep_az_bicep_executable* + Type: |String| + Default: `'az'` + + This variable can be set to change the path to az_bicep. + + +g:ale_bicep_az_bicep_options *g:ale_bicep_az_bicep_options* + *b:ale_bicep_az_bicep_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to az_bicep. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-bitbake.txt b/sources_non_forked/ale/doc/ale-bitbake.txt new file mode 100644 index 00000000..4c480fd4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bitbake.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE BitBake Integration *ale-bitbake-options* + + +=============================================================================== +oelint-adv *ale-bitbake-oelint_adv* + +g:ale_bitbake_oelint_adv_executable *g:ale_bitbake_oelint_adv_executable* + + Type: |String| + Default: `'oelint-adv'` + + This variable can be changed to use a different executable for oelint-adv. + +g:ale_bitbake_oelint_adv_options *g:ale_bitbake_oelint_adv_options* + + Type: |String| + Default: `''` + + This variable can be set to pass additional options to oelint-adv. + + g:ale_bitbake_oelint_adv_config *g:ale_bitbake_oelint_adv_config* + + Type: |String| + Default: `'.oelint.cfg'` + + This variable can be set to use a different config file. + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-c.txt b/sources_non_forked/ale/doc/ale-c.txt index c9eb79db..b8b448fb 100644 --- a/sources_non_forked/ale/doc/ale-c.txt +++ b/sources_non_forked/ale/doc/ale-c.txt @@ -1,22 +1,36 @@ =============================================================================== ALE C Integration *ale-c-options* +For basic checking of problems with C files, ALE offers the `cc` linter, which +runs either `clang`, or `gcc`. See |ale-c-cc|. + =============================================================================== Global Options +g:ale_c_always_make *g:ale_c_always_make* + *b:ale_c_always_make* + Type: |Number| + Default: `has('unix') && !has('macunix')` + + If set to `1`, use `--always-make` for `make`, which means that output will + always be parsed from `make` dry runs with GNU make. BSD `make` does not + support this option, so you probably want to turn this option off when using + a BSD variant. + + g:ale_c_build_dir_names *g:ale_c_build_dir_names* *b:ale_c_build_dir_names* Type: |List| Default: `['build', 'bin']` - A list of directory names to be used when searching upwards from cpp - files to discover compilation databases with. For directory named `'foo'`, - ALE will search for `'foo/compile_commands.json'` in all directories on and above - the directory containing the cpp file to find path to compilation database. - This feature is useful for the clang tools wrapped around LibTooling (namely - here, clang-tidy) + A list of directory names to be used when searching upwards from C files + to discover compilation databases with. For directory named `'foo'`, ALE + will search for `'foo/compile_commands.json'` in all directories on and + above the directory containing the C file to find path to compilation + database. This feature is useful for the clang tools wrapped around + LibTooling (namely here, clang-tidy) g:ale_c_build_dir *g:ale_c_build_dir* @@ -37,7 +51,7 @@ g:ale_c_build_dir *g:ale_c_build_dir* g:ale_c_parse_compile_commands *g:ale_c_parse_compile_commands* *b:ale_c_parse_compile_commands* Type: |Number| - Default: `0` + Default: `1` If set to `1`, ALE will parse `compile_commands.json` files to automatically determine flags for C or C++ compilers. ALE will first search for the @@ -45,9 +59,6 @@ g:ale_c_parse_compile_commands *g:ale_c_parse_compile_commands* `compile_commands.json` files in the directories for |g:ale_c_build_dir_names|. - If |g:ale_c_parse_makefile| or |b:ale_c_parse_makefile| is set to `1`, the - output of `make -n` will be preferred over `compile_commands.json` files. - g:ale_c_parse_makefile *g:ale_c_parse_makefile* *b:ale_c_parse_makefile* @@ -58,24 +69,168 @@ g:ale_c_parse_makefile *g:ale_c_parse_makefile* set for C or C++ compilers. This can make it easier to determine the correct build flags to use for different files. + NOTE: When using this option on BSD, you may need to set + |g:ale_c_always_make| to `0`, and `make -n` will not provide consistent + results if binaries have already been built, so use `make clean` when + editing your files. + + WARNING: Running `make -n` automatically can execute arbitrary code, even + though it's supposed to be a dry run, so enable this option with care. You + might prefer to use the buffer-local version of the option instead with + |g:ale_pattern_options|, or you own code for checking which project you're + in. + + You might want to disable this option if `make -n` takes too long to run for + projects you work on. + + If |g:ale_c_parse_compile_commands| or |b:ale_c_parse_compile_commands| is + set to `1`, flags taken from `compile_commands.json` will be preferred over + `make -n` output. + =============================================================================== -clang *ale-c-clang* +astyle *ale-c-astyle* -g:ale_c_clang_executable *g:ale_c_clang_executable* - *b:ale_c_clang_executable* +g:ale_c_astyle_executable *g:ale_c_astyle_executable* + *b:ale_c_astyle_executable* Type: |String| - Default: `'clang'` + Default: `'astyle'` - This variable can be changed to use a different executable for clang. + This variable can be changed to use a different executable for astyle. -g:ale_c_clang_options *g:ale_c_clang_options* - *b:ale_c_clang_options* +g:ale_c_astyle_project_options *g:ale_c_astyle_project_options* + *b:ale_c_astyle_project_options* + Type: |String| + Default: `''` + + This variable can be changed to use an option file for project level + configurations. Provide only the filename of the option file that should be + present at the project's root directory. + + For example, if .astylrc is specified, the file is searched in the parent + directories of the source file's directory. + + +=============================================================================== +cc *ale-c-cc* + *ale-c-gcc* + *ale-c-clang* + +g:ale_c_cc_executable *g:ale_c_cc_executable* + *b:ale_c_cc_executable* + Type: |String| + Default: `''` + + This variable can be changed to use a different executable for a C compiler. + + ALE will try to use `clang` if Clang is available, otherwise ALE will + default to checking C code with `gcc`. + + +g:ale_c_cc_options *g:ale_c_cc_options* + *b:ale_c_cc_options* Type: |String| Default: `'-std=c11 -Wall'` - This variable can be changed to modify flags given to clang. + This variable can be changed to modify flags given to the C compiler. + + +g:ale_c_cc_use_header_lang_flag *g:ale_c_cc_use_header_lang_flag* + *b:ale_c_cc_use_header_lang_flag* + Type: |Number| + Default: `-1` + + By default, ALE will use `'-x c-header'` instead of `'-x c'` for header files + when using Clang. + + This variable can be changed to manually activate or deactivate this flag + for header files. + + - When set to `-1`, the default beviour is used, `'-x c-header'` is used with + Clang and `'-x c'` is used with other compilers. + - When set to `0`, the flag is deactivated, `'-x c'` is always used + independently of the compiler. + - When set to `1`, the flag is activated, `'-x c-header'` is always used + independently of the compiler. + + Gcc does not support `'-x c-header'` when using `'-'` as input filename, + which is what ALE does. This why, by default, ALE only uses `'-x c-header'` + with Clang. + + +g:ale_c_cc_header_exts *g:ale_c_cc_header_exts* + *b:ale_c_cc_header_exts* + Type: |List| + Default: `['h']` + + This variable can be changed to modify the list of extensions of the files + considered as header files. + + This variable is only used when `'-x c-header'` is used instead of `'-x c'`, + see |g:ale_c_cc_use_header_lang_flag|. + + +=============================================================================== +ccls *ale-c-ccls* + +g:ale_c_ccls_executable *g:ale_c_ccls_executable* + *b:ale_c_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_c_ccls_init_options *g:ale_c_ccls_init_options* + *b:ale_c_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + For all available options and explanations, visit + https://github.com/MaskRay/ccls/wiki/Customization#initialization-options. + + +=============================================================================== +clangcheck *ale-c-clangcheck* + +`clang-check` will be run only when files are saved to disk, so that +`compile_commands.json` files can be used. It is recommended to use this +linter in combination with `compile_commands.json` files. +Therefore, `clang-check` linter reads the options |g:ale_c_build_dir| and +|g:ale_c_build_dir_names|. Also, setting |g:ale_c_build_dir| actually +overrides |g:ale_c_build_dir_names|. + + +g:ale_c_clangcheck_executable *g:ale_c_clangcheck_executable* + *b:ale_c_clangcheck_executable* + Type: |String| + Default: `'clang-check'` + + This variable can be changed to use a different executable for clangcheck. + + +g:ale_c_clangcheck_options *g:ale_c_clangcheck_options* + *b:ale_c_clangcheck_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clang-check. + + This variable should not be set to point to build subdirectory with + `-p path/to/build` option, as it is handled by the |g:ale_c_build_dir| + option. =============================================================================== @@ -113,7 +268,45 @@ g:ale_c_clangformat_options *g:ale_c_clangformat_options* Type: |String| Default: `''` - This variable can be change to modify flags given to clang-format. + This variable can be changed to modify flags given to clang-format. + + +g:ale_c_clangformat_style_option *g:ale_c_clangformat_style_option* + *b:ale_c_clangformat_style_option* + Type: |String| + Default: `''` + + This variable can be changed to modify only the style flag given to + clang-format. The contents of the variable are passed directly to the -style + flag of clang-format. + + Example: > + { + \ BasedOnStyle: Microsoft, + \ ColumnLimit: 80, + \ AllowShortBlocksOnASingleLine: Always, + \ AllowShortFunctionsOnASingleLine: Inline, + \ } +< + If you set this variable, ensure you don't modify -style in + |g:ale_c_clangformat_options|, as this will cause clang-format to error. + + +g:ale_c_clangformat_use_local_file *g:ale_c_clangformat_use_local_file* + *b:ale_c_clangformat_use_local_file* + Type: |Number| + Default: `0` + + This variable can be changed to modify whether to use a local .clang-format + file. If the file is found, the flag '-style=file' is passed to clang-format + and any options configured via |g:ale_c_clangformat_style_option| are not + passed. + + If this option is enabled but no .clang-format file is found, default back to + |g:ale_c_clangformat_style_option|, if it set. + + If you set this variable, ensure you don't modify -style in + |g:ale_c_clangformat_options|, as this will cause clang-format to error. =============================================================================== @@ -216,7 +409,7 @@ g:ale_c_cquery_executable *g:ale_c_cquery_executable* This variable can be changed to use a different executable for cquery. -g:ale_cpp_cquery_cache_directory *g:ale_c_cquery_cache_directory* +g:ale_c_cquery_cache_directory *g:ale_c_cquery_cache_directory* *b:ale_c_cquery_cache_directory* Type: |String| Default: `'~/.cache/cquery'` @@ -225,6 +418,12 @@ g:ale_cpp_cquery_cache_directory *g:ale_c_cquery_cache_directory* cache. +=============================================================================== +cspell *ale-c-cspell* + +See |ale-cspell-options| + + =============================================================================== flawfinder *ale-c-flawfinder* @@ -260,25 +459,6 @@ g:ale_c_flawfinder_error_severity *g:ale_c_flawfinder_error_severity* error. This setting also applies to flawfinder for c++. -=============================================================================== -gcc *ale-c-gcc* - -g:ale_c_gcc_executable *g:ale_c_gcc_executable* - *b:ale_c_gcc_executable* - Type: |String| - Default: `'gcc'` - - This variable can be changed to use a different executable for gcc. - - -g:ale_c_gcc_options *g:ale_c_gcc_options* - *b:ale_c_gcc_options* - Type: |String| - Default: `'-std=c11 -Wall'` - - This variable can be change to modify flags given to gcc. - - =============================================================================== uncrustify *ale-c-uncrustify* @@ -298,36 +478,5 @@ g:ale_c_uncrustify_options *g:ale_c_uncrustify_options* This variable can be change to modify flags given to uncrustify. -=============================================================================== -ccls *ale-c-ccls* - -g:ale_c_ccls_executable *g:ale_c_ccls_executable* - *b:ale_c_ccls_executable* - Type: |String| - Default: `'ccls'` - - This variable can be changed to use a different executable for ccls. - - -g:ale_c_ccls_init_options *g:ale_c_ccls_init_options* - *b:ale_c_ccls_init_options* - Type: |Dictionary| - Default: `{}` - - This variable can be changed to customize ccls initialization options. - Example: > - { - \ 'cacheDirectory': '/tmp/ccls', - \ 'cacheFormat': 'binary', - \ 'diagnostics': { - \ 'onOpen': 0, - \ 'opChange': 1000, - \ }, - \ } -< - Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all - available options and explanations. - - =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-c3.txt b/sources_non_forked/ale/doc/ale-c3.txt new file mode 100644 index 00000000..acc7e013 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-c3.txt @@ -0,0 +1,35 @@ +=============================================================================== +ALE C3 Integration *ale-c3-options* + +=============================================================================== +c3lsp *ale-c3-c3lsp* + +g:ale_c3_c3lsp_executable *g:ale_c3_c3lsp_executable* + *b:ale_c3_c3lsp_executable* + Type: |String| + Default: `c3lsp` + + This variable can be changed to set the path to c3lsp executable. + + +g:ale_c3_c3lsp_options *g:ale_c3_c3lsp_options* + *b:ale_c3_c3lsp_options* + + Type: |String| + Default: `''` + + Add command line options to the c3lsp executable. This is useful to specify + the path to the C3 standard library with '-stdlib-path='. + + +g:ale_c3_c3lsp_init_options *g:ale_c3_c3lsp_init_options* + *b:ale_c3_c3lsp_init_options* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cairo.txt b/sources_non_forked/ale/doc/ale-cairo.txt new file mode 100644 index 00000000..070b76e5 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-cairo.txt @@ -0,0 +1,30 @@ +=============================================================================== +ALE Cairo Integration *ale-cairo-options* + + +=============================================================================== +scarb *ale-cairo-scarb* + +g:ale_cairo_scarb_executable *g:ale_cairo_scarb_executable* + *b:ale_cairo_scarb_executable* + + Default: `'scarb build'` + + For Cairo1 projects using Scarb + + For more information read 'https://docs.swmansion.com/scarb/' + + +=============================================================================== +starknet *ale-cairo-starknet* + +g:ale_cairo_starknet_executable *g:ale_cairo_starknet_executable* + *b:ale_cairo_starknet_executable* + + Default: `'starknet-compile'` + + Overrides the starknet-compile binary after installing the cairo-language. + + For more information read 'https://starknet.io/docs/quickstart.html' + +=============================================================================== diff --git a/sources_non_forked/ale/doc/ale-clojure.txt b/sources_non_forked/ale/doc/ale-clojure.txt index 2bf00c03..54872de7 100644 --- a/sources_non_forked/ale/doc/ale-clojure.txt +++ b/sources_non_forked/ale/doc/ale-clojure.txt @@ -9,6 +9,26 @@ A minimal and opinionated linter for code that sparks joy. https://github.com/borkdude/clj-kondo +g:ale_clojure_clj_kondo_options *g:ale_clojure_clj_kondo_options* + *b:ale_clojure_clj_kondo_options* + Type: |String| + Default: `'--cache'` + + This variable can be changed to modify options passed to clj-kondo. + +=============================================================================== +cljfmt *ale-clojure-cljfmt* + +cljfmt is a linter and fixer for Clojure code, with defaults adhering to the +Clojure Style Guide (see https://guide.clojure.style/ ) + +https://github.com/weavejester/cljfmt + +Linting options are not configurable by ale, but instead are controlled by +Leiningen, or a cljfmt file in the current or parent directories. + +see https://github.com/weavejester/cljfmt#Configuration for more information. + =============================================================================== joker *ale-clojure-joker* diff --git a/sources_non_forked/ale/doc/ale-cloudformation.txt b/sources_non_forked/ale/doc/ale-cloudformation.txt index 59c6af06..9724403b 100644 --- a/sources_non_forked/ale/doc/ale-cloudformation.txt +++ b/sources_non_forked/ale/doc/ale-cloudformation.txt @@ -7,8 +7,40 @@ cfn-python-lint *ale-cloudformation-cfn-python-lint* cfn-python-lint is a linter for AWS CloudFormation template file. -https://github.com/awslabs/cfn-python-lint +Website: https://github.com/awslabs/cfn-python-lint +Installation +------------------------------------------------------------------------------- + + +Install cfn-python-lint using either pip or brew: > + +`pip install cfn-lint`. If pip is not available, run +`python setup.py clean --all` then `python setup.py install`. + + Homebrew (macOS): + +`brew install cfn-lint` + +< +Configuration +------------------------------------------------------------------------------- + +To get cloudformation linter to work on only CloudFormation files we must set +the buffer |filetype| to yaml.cloudformation. +This causes ALE to lint the file with linters configured for cloudformation and +yaml files. + +Just put: + +> + + au BufRead,BufNewFile *.template.yaml set filetype=yaml.cloudformation + +< + +on `ftdetect/cloudformation.vim` + +This will get both cloudformation and yaml linters to work on any file with `.template.yaml` ext. =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: - diff --git a/sources_non_forked/ale/doc/ale-cmake.txt b/sources_non_forked/ale/doc/ale-cmake.txt index 602637b1..e44c328e 100644 --- a/sources_non_forked/ale/doc/ale-cmake.txt +++ b/sources_non_forked/ale/doc/ale-cmake.txt @@ -21,6 +21,25 @@ g:ale_cmake_cmakelint_options *g:ale_cmake_cmakelint_options* This variable can be set to pass additional options to cmakelint. +=============================================================================== +cmake-lint *ale-cmake-cmake-lint* + +g:ale_cmake_cmake_lint_executable *g:ale_cmake_cmake_lint_executable* + *b:ale_cmake_cmake_lint_executable* + Type: |String| + Default: `'cmake-lint'` + + This variable can be set to change the path the cmake-lint. + + +g:ale_cmake_cmake_lint_options *g:ale_cmake_cmake_lint_options* + *b:ale_cmake_cmake_lint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to cmake-lint. + + =============================================================================== cmake-format *ale-cmake-cmakeformat* diff --git a/sources_non_forked/ale/doc/ale-cpp.txt b/sources_non_forked/ale/doc/ale-cpp.txt index ead3be28..3682556d 100644 --- a/sources_non_forked/ale/doc/ale-cpp.txt +++ b/sources_non_forked/ale/doc/ale-cpp.txt @@ -1,12 +1,16 @@ =============================================================================== ALE C++ Integration *ale-cpp-options* +For basic checking of problems with C++ files, ALE offers the `cc` linter, +which runs either `clang++`, or `gcc`. See |ale-cpp-cc|. + =============================================================================== Global Options The following C options also apply to some C++ linters too. +* |g:ale_c_always_make| * |g:ale_c_build_dir_names| * |g:ale_c_build_dir| * |g:ale_c_parse_makefile| @@ -14,41 +18,117 @@ The following C options also apply to some C++ linters too. =============================================================================== -clang *ale-cpp-clang* +astyle *ale-cpp-astyle* -g:ale_cpp_clang_executable *g:ale_cpp_clang_executable* - *b:ale_cpp_clang_executable* +g:ale_cpp_astyle_executable *g:ale_cpp_astyle_executable* + *b:ale_cpp_astyle_executable* Type: |String| - Default: `'clang++'` + Default: `'astyle'` - This variable can be changed to use a different executable for clang. + This variable can be changed to use a different executable for astyle. -g:ale_cpp_clang_options *g:ale_cpp_clang_options* - *b:ale_cpp_clang_options* - Type: |String| - Default: `'-std=c++14 -Wall'` - - This variable can be changed to modify flags given to clang. - - -=============================================================================== -clangd *ale-cpp-clangd* - -g:ale_cpp_clangd_executable *g:ale_cpp_clangd_executable* - *b:ale_cpp_clangd_executable* - Type: |String| - Default: `'clangd'` - - This variable can be changed to use a different executable for clangd. - - -g:ale_cpp_clangd_options *g:ale_cpp_clangd_options* - *b:ale_cpp_clangd_options* +g:ale_cpp_astyle_project_options *g:ale_cpp_astyle_project_options* + *b:ale_cpp_astyle_project_options* Type: |String| Default: `''` - This variable can be changed to modify flags given to clangd. + This variable can be changed to use an option file for project level + configurations. Provide only the filename of the option file that should be + present at the project's root directory. + + For example, if .astylrc is specified, the file is searched in the parent + directories of the source file's directory. + + +=============================================================================== +cc *ale-cpp-cc* + *ale-cpp-gcc* + *ale-cpp-clang* + +g:ale_cpp_cc_executable *g:ale_cpp_cc_executable* + *b:ale_cpp_cc_executable* + Type: |String| + Default: `''` + + This variable can be changed to use a different executable for a C++ compiler. + + ALE will try to use `clang++` if Clang is available, otherwise ALE will + default to checking C++ code with `gcc`. + + +g:ale_cpp_cc_options *g:ale_cpp_cc_options* + *b:ale_cpp_cc_options* + Type: |String| + Default: `'-std=c++14 -Wall'` + + This variable can be changed to modify flags given to the C++ compiler. + + +g:ale_cpp_cc_use_header_lang_flag *g:ale_cpp_cc_use_header_lang_flag* + *b:ale_cpp_cc_use_header_lang_flag* + Type: |Number| + Default: `-1` + + By default, ALE will use `'-x c++-header'` instead of `'-x c++'` for header + files when using Clang. + + This variable can be changed to manually activate or deactivate this flag + for header files. + + - When set to `-1`, the default beviour is used, `'-x c++-header'` is used with + Clang and `'-x c++'` is used with other compilers. + - When set to `0`, the flag is deactivated, `'-x c++'` is always used + independently of the compiler. + - When set to `1`, the flag is activated, `'-x c++-header'` is always used + independently of the compiler. + + Gcc does not support `'-x c++-header'` when using `'-'` as input filename, + which is what ALE does. This why, by default, ALE only uses `'-x c++-header'` + with Clang. + + +g:ale_cpp_cc_header_exts *g:ale_cpp_cc_header_exts* + *b:ale_cpp_cc_header_exts* + Type: |List| + Default: `['h', 'hpp']` + + This variable can be changed to modify the list of extensions of the files + considered as header files. + + This variable is only used when `'-x c++-header'` is used instead of `'-x c++'`, + see |g:ale_cpp_cc_use_header_lang_flag|. + + +=============================================================================== +ccls *ale-cpp-ccls* + +g:ale_cpp_ccls_executable *g:ale_cpp_ccls_executable* + *b:ale_cpp_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_cpp_ccls_init_options *g:ale_cpp_ccls_init_options* + *b:ale_cpp_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. =============================================================================== @@ -82,6 +162,25 @@ g:ale_cpp_clangcheck_options *g:ale_cpp_clangcheck_options* option. +=============================================================================== +clangd *ale-cpp-clangd* + +g:ale_cpp_clangd_executable *g:ale_cpp_clangd_executable* + *b:ale_cpp_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_cpp_clangd_options *g:ale_cpp_clangd_options* + *b:ale_cpp_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + =============================================================================== clang-format *ale-cpp-clangformat* @@ -223,6 +322,21 @@ g:ale_cpp_cpplint_options *g:ale_cpp_cpplint_options* This variable can be changed to modify flags given to cpplint. +g:ale_c_cpplint_executable *g:ale_c_cpplint_executable* + *b:ale_c_cpplint_executable* + Type: |String| + Default: `'cpplint'` + + This variable can be changed to use a different executable for cpplint. + + +g:ale_c_cpplint_options *g:ale_c_cpplint_options* + *b:ale_c_cpplint_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to cpplint. + =============================================================================== cquery *ale-cpp-cquery* @@ -244,6 +358,12 @@ g:ale_cpp_cquery_cache_directory *g:ale_cpp_cquery_cache_directory* cache. +=============================================================================== +cspell *ale-cpp-cspell* + +See |ale-cspell-options| + + =============================================================================== flawfinder *ale-cpp-flawfinder* @@ -271,61 +391,11 @@ g:ale_cpp_flawfinder_options *g:ale-cpp-flawfinder* This variable can be used to pass extra options into the flawfinder command. -=============================================================================== -gcc *ale-cpp-gcc* - -g:ale_cpp_gcc_executable *g:ale_cpp_gcc_executable* - *b:ale_cpp_gcc_executable* - Type: |String| - Default: `'gcc'` - - This variable can be changed to use a different executable for gcc. - - -g:ale_cpp_gcc_options *g:ale_cpp_gcc_options* - *b:ale_cpp_gcc_options* - Type: |String| - Default: `'-std=c++14 -Wall'` - - This variable can be changed to modify flags given to gcc. - - =============================================================================== uncrustify *ale-cpp-uncrustify* See |ale-c-uncrustify| for information about the available options. -=============================================================================== -ccls *ale-cpp-ccls* - -g:ale_cpp_ccls_executable *g:ale_cpp_ccls_executable* - *b:ale_cpp_ccls_executable* - Type: |String| - Default: `'ccls'` - - This variable can be changed to use a different executable for ccls. - - -g:ale_cpp_ccls_init_options *g:ale_cpp_ccls_init_options* - *b:ale_cpp_ccls_init_options* - Type: |Dictionary| - Default: `{}` - - This variable can be changed to customize ccls initialization options. - Example: > - { - \ 'cacheDirectory': '/tmp/ccls', - \ 'cacheFormat': 'binary', - \ 'diagnostics': { - \ 'onOpen': 0, - \ 'opChange': 1000, - \ }, - \ } -< - Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all - available options and explanations. - - =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cs.txt b/sources_non_forked/ale/doc/ale-cs.txt index abcc43eb..d9a9dc00 100644 --- a/sources_non_forked/ale/doc/ale-cs.txt +++ b/sources_non_forked/ale/doc/ale-cs.txt @@ -6,27 +6,33 @@ In addition to the linters that are provided with ALE, C# code can be checked with the OmniSharp plugin. See here: https://github.com/OmniSharp/omnisharp-vim +=============================================================================== +clang-format *ale-cs-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for C#. + + =============================================================================== csc *ale-cs-csc* The |ale-cs-csc| linter checks for semantic errors when files are opened or saved. - + See |ale-lint-file-linters| for more information on linters which do not check for problems while you type. - The csc linter uses the mono csc compiler providing full c# 7 and newer - support to generate a temporary module target file (/t:module). The module - includes including all '*.cs' files contained in the directory tree rooted - at the path defined by the |g:ale_cs_csc_source| or |b:ale_cs_csc_source| - variabl and all sub directories. - + The csc linter uses the mono csc compiler, providing full C# 7 and newer + support, to generate a temporary module target file (/t:module). The module + includes all '*.cs' files contained in the directory tree rooted at the path + defined by the |g:ale_cs_csc_source| or |b:ale_cs_csc_source| variable and + all sub directories. + It will in future replace the |ale-cs-mcs| and |ale-cs-mcsc| linters as both - utilizer the mcsc compiler which according to mono porject ist further - developed and as of writint these lines only receives maintenance updates. - The down is that the csc compiler does not support the -sytax option any more - and therefore |ale-cs-csc| linter doese not offer any as you type syntax - checking like the |ale-cs-mcsc| linter doesn't. + utilize the mcsc compiler which, according to the mono project, is no longer + actively developed, and only receives maintenance updates. However, because + the csc compiler does not support the -syntax option, this linter does not + offer any as-you-type syntax checking, similar to the |ale-cs-mcsc| linter. The paths to search for additional assembly files can be specified using the |g:ale_cs_csc_assembly_path| or |b:ale_cs_csc_assembly_path| variables. @@ -91,6 +97,45 @@ g:ale_cs_csc_assemblies *g:ale_cs_csc_assemblies* \] < +=============================================================================== +cspell *ale-cs-cspell* + +See |ale-cspell-options| + + +=============================================================================== +dotnet-format *ale-cs-dotnet-format* + +Installation +------------------------------------------------------------------------------- + +Installing .NET SDK should probably ensure that `dotnet` is in your `$PATH`. +For .NET 6 the `dotnet format` tool is already included in the .NET SDK. For +.NET 5 or below you will have to manually install it using the instructions +from listed in this repository: https://github.com/dotnet/format + + +Options +------------------------------------------------------------------------------- + +g:ale_cs_dotnet_format_executable *g:ale_cs_dotnet_format_executable* + *b:ale_cs_dotnet_format_executable* + Type: |String| + Default: `'dotnet'` + + This variable can be set to specify an absolute path to the + `dotnet` executable (or to specify an alternate executable). + + +g:ale_cs_dotnet_format_options *g:ale_cs_dotnet_format_options* + *b:ale_cs_dotnet_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the `dotnet format` + fixer. + + =============================================================================== mcs *ale-cs-mcs* diff --git a/sources_non_forked/ale/doc/ale-css.txt b/sources_non_forked/ale/doc/ale-css.txt index ff74b263..74ca16dd 100644 --- a/sources_non_forked/ale/doc/ale-css.txt +++ b/sources_non_forked/ale/doc/ale-css.txt @@ -2,6 +2,39 @@ ALE CSS Integration *ale-css-options* +=============================================================================== +cspell *ale-css-cspell* + +See |ale-cspell-options| + + +=============================================================================== +css-beautify *ale-css-css-beautify* + +g:ale_css_css_beautify_executable *g:ale_css_css_beautify_executable* + *b:ale_css_css_beautify_executable* + Type: |String| + Default: `'css-beautify'` + + See |ale-integrations-local-executables| + + +g:ale_css_css_beautify_options *g:ale_css_css_beautify_options* + *b:ale_css_css_beautify_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to css-beautify. + + +g:ale_css_css_beautify_use_global *g:ale_css_css_beautify_use_global* + *b:ale_css_css_beautify_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== fecs *ale-css-fecs* @@ -43,5 +76,18 @@ g:ale_css_stylelint_use_global *g:ale_css_stylelint_use_global* See |ale-integrations-local-executables| +=============================================================================== +vscodecss *ale-css-vscode* + +Website: https://github.com/hrsh7th/vscode-langservers-extracted + +Installation +------------------------------------------------------------------------------- + +Install VSCode css language server either globally or locally: > + + npm install -g vscode-langservers-extracted +< + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cuda.txt b/sources_non_forked/ale/doc/ale-cuda.txt index 0e53f756..729d86b5 100644 --- a/sources_non_forked/ale/doc/ale-cuda.txt +++ b/sources_non_forked/ale/doc/ale-cuda.txt @@ -2,6 +2,32 @@ ALE CUDA Integration *ale-cuda-options* +=============================================================================== +clang-format *ale-cuda-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for CUDA. + + +=============================================================================== +clangd *ale-cuda-clangd* + +g:ale_cuda_clangd_executable *g:ale_cuda_clangd_executable* + *b:ale_cuda_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_cuda_clangd_options *g:ale_cuda_clangd_options* + *b:ale_cuda_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + =============================================================================== nvcc *ale-cuda-nvcc* @@ -21,12 +47,6 @@ g:ale_cuda_nvcc_options *g:ale_cuda_nvcc_options* This variable can be changed to modify flags given to nvcc. -=============================================================================== -clang-format *ale-cuda-clangformat* - -See |ale-c-clangformat| for information about the available options. -Note that the C options are also used for cuda. - =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-d.txt b/sources_non_forked/ale/doc/ale-d.txt index 55596062..72349a20 100644 --- a/sources_non_forked/ale/doc/ale-d.txt +++ b/sources_non_forked/ale/doc/ale-d.txt @@ -1,6 +1,15 @@ =============================================================================== ALE D Integration *ale-d-options* +=============================================================================== +dfmt *ale-d-dfmt* + +g:ale_d_dfmt_options *g:ale_d_dfmt_options* + *b:ale_d_dfmt_options* + Type: |String| + Default: `''` + +This variable can be set to pass additional options to the dfmt fixer. =============================================================================== dls *ale-d-dls* diff --git a/sources_non_forked/ale/doc/ale-dafny.txt b/sources_non_forked/ale/doc/ale-dafny.txt new file mode 100644 index 00000000..005170ad --- /dev/null +++ b/sources_non_forked/ale/doc/ale-dafny.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE Dafny Integration *ale-dafny-options* + + +=============================================================================== +dafny *ale-dafny-dafny* + +g:ale_dafny_dafny_timelimit *g:ale_dafny_dafny_timelimit* + *b:ale_dafny_dafny_timelimit* + Type: |Number| + Default: `10` + + This variable sets the `/timeLimit` used for dafny. + + + 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 a6d88dd8..8761515e 100644 --- a/sources_non_forked/ale/doc/ale-dart.txt +++ b/sources_non_forked/ale/doc/ale-dart.txt @@ -3,35 +3,101 @@ ALE Dart Integration *ale-dart-options* =============================================================================== -dartanalyzer *ale-dart-dartanalyzer* +analysis_server *ale-dart-analysis_server* Installation ------------------------------------------------------------------------------- -Install Dart via whatever means. `dartanalyzer` will be included in the SDK. +Install Dart via whatever means. `analysis_server` will be included in the SDK. -You can add the SDK to `$PATH`, as described here: -https://www.dartlang.org/tools/sdk - -If you have installed Dart on Linux, you can also try the following: > - " Set the executable path for dartanalyzer to the absolute path to it. - let g:ale_dart_dartanalyzer_executable = '/usr/lib/dart/bin/dartanalyzer' +In case that `dart` is not in your path, try to set the executable option to +its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_analysis_server_executable = '/usr/local/bin/dart' < -... or similarly for wherever your Dart SDK lives. This should work without -having to modify `$PATH`. - -ALE can only check for problems with `dartanalyzer` with the file on disk. -See |ale-lint-file-linters| Options ------------------------------------------------------------------------------- -g:ale_dart_dartanalyzer_executable *g:ale_dart_dartanalyzer_executable* - *b:ale_dart_dartanalyzer_executable* +g:ale_dart_analysis_server_executable *g:ale_dart_analysis_server_executable* + *b:ale_dart_analysis_server_executable* Type: |String| - Default: `'dartanalyzer'` + Default: `'dart'` - This variable can be set to change the path to dartanalyzer. + 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* + +Installation +------------------------------------------------------------------------------- + +Installing Dart should probably ensure that `dart` is in your `$PATH`. + +In case it is not, try to set the executable option to its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_format_executable = '/usr/lib/dart/bin/dart' + > + +Install Dart via whatever means. `dart analyze` will be included in the SDK. + +Options +------------------------------------------------------------------------------- + +g:ale_dart_analyze_executable *g:ale_dart_analyze_executable* + *b:ale_dart_analyze_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to specify an absolute path to the + format executable (or to specify an alternate executable). + + +=============================================================================== +dart-format *ale-dart-format* + +Installation +------------------------------------------------------------------------------- + +Installing Dart should probably ensure that `dart` is in your `$PATH`. + +In case it is not, try to set the executable option to its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_format_executable = '/usr/lib/dart/bin/dart' + > + +Options +------------------------------------------------------------------------------- + +g:ale_dart_format_executable *g:ale_dart_format_executable* + *b:ale_dart_format_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to specify an absolute path to the + format executable (or to specify an alternate executable). + + +g:ale_dart_format_options *g:ale_dart_format_options* + *b:ale_dart_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the dart format fixer. =============================================================================== diff --git a/sources_non_forked/ale/doc/ale-desktop.txt b/sources_non_forked/ale/doc/ale-desktop.txt new file mode 100644 index 00000000..62269e9c --- /dev/null +++ b/sources_non_forked/ale/doc/ale-desktop.txt @@ -0,0 +1,21 @@ +=============================================================================== +ALE desktop Integration *ale-desktop-options* + + +=============================================================================== +desktop-file-validate *ale-desktop-desktop-file-validate* + +ALE supports checking .desktop files with `desktop-file-validate.` + + +g:ale_desktop_desktop_file_validate_options + *g:ale_desktop_desktop_file_validate_options* + *b:ale_desktop_desktop_file_validate_options* + Type: |String| + Default: `''` + + This variable can be changed to set options for `desktop-file-validate`, + such as `'--warn-kde'`. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-development.txt b/sources_non_forked/ale/doc/ale-development.txt index 16b16483..412b48ca 100644 --- a/sources_non_forked/ale/doc/ale-development.txt +++ b/sources_non_forked/ale/doc/ale-development.txt @@ -13,6 +13,9 @@ CONTENTS *ale-development-contents* 4. Testing ALE..........................|ale-development-tests| 4.1. Writing Linter Tests.............|ale-development-linter-tests| 4.2. Writing Fixer Tests..............|ale-development-fixer-tests| + 4.3. Running Tests in a Windows VM....|ale-development-windows-tests| + 5. Contributing.........................|ale-development-contributing| + 5.1. Preparing a Release..............|ale-development-release| =============================================================================== 1. Introduction *ale-development-introduction* @@ -45,11 +48,11 @@ documented functions and options, until a major version is planned. Breaking changes should be preceded by a deprecation phase complete with warnings. Changes required for security may be an exception. -ALE supports Vim 8 and above, and NeoVim 0.2.0 or newer. These are the -earliest versions of Vim and NeoVim which support |job|, |timer|, |closure|, -and |lambda| features. All ALE code should be written so it is compatible with -these versions of Vim, or with version checks so particular features can -degrade or fail gracefully. +ALE supports Vim 8 and above, and Neovim 0.7.0 or newer. These are the +earliest versions of Vim and Neovim which support |+job|, |+timer|, +|+closure|, and |+lambda| features. All ALE code should be written so it is +compatible with these versions of Vim, or with version checks so particular +features can degrade or fail gracefully. Just about everything should be documented and covered with tests. @@ -96,8 +99,8 @@ should also follow some additional rules designed to prevent mistakes. Some of these are reported with ALE's `custom-linting-rules` script. See |ale-development-tests|. -* Don't leave stray `:echo` lines in code. Use `execute 'echo' ...` if you must - echo something. +* Don't leave stray `:echo` lines in code. Write `" no-custom-checks` above + the line if you must echo something. * For strings use |is#| instead of |==#|, `is?` instead of `==?`, `isnot#` instead of `!=#`, and `isnot?` instead of `!=?`. This is because `'x' ==# 0` returns 1, while `'x' is# 0` returns 0, so you will experience fewer issues @@ -147,14 +150,15 @@ Apply the following rules when writing Bash scripts. =============================================================================== 4. Testing ALE *ale-development-tests* *ale-dev-tests* *ale-tests* -ALE is tested with a suite of tests executed in Travis CI and AppVeyor. ALE -runs tests with the following versions of Vim in the following environments. +ALE is tested with a suite of tests executed via GitHub Actions and AppVeyor. +ALE runs tests with the following versions of Vim in the following +environments. -1. Vim 8.0.0027 on Linux via Travis CI. -2. Vim 8.1.0519 on Linux via Travis CI. -3. NeoVim 0.2.0 on Linux via Travis CI. -4. NeoVim 0.3.5 on Linux via Travis CI. -5. Vim 8 (stable builds) on Windows via AppVeyor. +1. Vim 8.0.0027 on Linux via GitHub Actions. +2. Vim 9.0.0297 on Linux via GitHub Actions. +3. Neovim 0.7.0 on Linux via GitHub Actions. +4. Neovim 0.8.0 on Linux via GitHub Actions. +6. Vim 8 (stable builds) on Windows via AppVeyor. If you are developing ALE code on Linux, Mac OSX, or BSD, you can run ALEs tests by installing Docker and running the `run-tests` script. Follow the @@ -170,27 +174,36 @@ will run all of the tests in Vader, Vint checks, and several Bash scripts for finding extra issues. Run `./run-tests --help` to see all of the options the script supports. Note that the script supports selecting particular test files. +Once you get used to dealing with Vim and NeoVim compatibility issues, you +probably want to use `./run-tests --fast -q` for running tests with only the +fastest available Vim version, and with success messages from tests +suppressed. + Generally write tests for any changes you make. The following types of tests are recommended for the following types of code. * New/edited error handler callbacks -> Write tests in `test/handler` -* New/edited command callbacks -> Write tests in `test/command_callback` +* New/edited linter definition -> Write tests in `test/linter` * New/edited fixer functions -> Write tests in `test/fixers` Look at existing tests in the codebase for examples of how to write tests. Refer to the Vader documentation for general information on how to write Vader tests: https://github.com/junegunn/vader.vim +If you need to add any supporting files for tests, such as empty files present +to test searching upwards through paths for configuration files, they can be +added to the `test/test-files` directory. + See |ale-development-linter-tests| for more information on how to write linter tests. -When you add new linters or fixers, make sure to add them into the table in -the README, and also into the |ale-support| list in the main help file. If you -forget to keep them both in sync, you should see an error like the following -in Travis CI. > - +When you add new linters or fixers, make sure to add them into the tables in +supported-tools.md and |ale-supported-languages-and-tools.txt|. If you forget to +keep them both in sync, you should see an error like the following in the +builds run for GitHub Actions. +> ======================================== - diff README.md and doc/ale.txt tables + diff supported-tools.md and doc/ale-supported-languages-and-tools.txt tables ======================================== Differences follow: @@ -267,8 +280,8 @@ be written like so. > \ '1:Something went wrong', \ ] < -Tests for what ALE runs should go in the `test/command_callback` directory, -and should be written like so. > +Tests for what ALE runs should go in the `test/linter` directory, and should +be written like so. > Before: " Load the linter and set up a series of commands, reset linter variables, @@ -304,6 +317,7 @@ The full list of commands that will be temporarily defined for linter tests given the above setup are as follows. `GivenCommandOutput [...]` - Define output for ale#command#Run. +`AssertLinterCwd cwd` - Check the `cwd` for the linter. `AssertLinter executable, command` - Check the executable and command. `AssertLinterNotExecuted` - Check that linters will not be executed. `AssertLSPLanguage language` - Check the language given to an LSP server. @@ -312,7 +326,6 @@ given the above setup are as follows. `AssertLSPProject project_root` - Check the root given to an LSP server. `AssertLSPAddress address` - Check the address to an LSP server. - =============================================================================== 4.2 Writing Fixer Tests *ale-development-fixer-tests* @@ -350,9 +363,174 @@ The full list of commands that will be temporarily defined for fixer tests given the above setup are as follows. `GivenCommandOutput [...]` - Define output for ale#command#Run. +`AssertFixerCwd cwd` - Check the `cwd` for the fixer. `AssertFixer results` - Check the fixer results `AssertFixerNotExecuted` - Check that fixers will not be executed. +=============================================================================== +4.3 Running Tests in a Windows VM *ale-development-windows-tests* + +Tests are run for ALE in a build of Vim 8 for Windows via AppVeyor. These +tests can frequently break due to minor differences in paths and how escaping +is done for commands on Windows. If you are a Linux or Mac user, running these +tests locally can be difficult. Here is a process that will make that easier. + +First, you want to install a Windows image with VirtualBox. Install VirtualBox +and grab a VirtualBox image for Windows such as from here: +https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ + +NOTE: If you need to enter a password for the virtual machine at any point, +the password is "Passw0rd!" without the double quotes. + +NOTE: If your trial period for Windows runs out, run the commands like the +wallpaper tells you to. + +Your virtual machine will need to have PowerShell installed. Before you go any +further, confirm that PowerShell is installed in your Windows virtual machine. + +Consult the VirtualBox documentation on how to install "Guest Additions." +You probably want to install "Guest Additions" for most things to work +properly. + +After you've loaded your virtual machine image, go into "Settings" for your +virtual machine, and "Shared Folders." Add a shared folder with the name +"ale", and set the "Folder Path" to the path to your ALE repository, for +example: "/home/w0rp/ale" + +Find out which drive letter "ale" has been mounted as in Windows. We'll use +"E:" as the drive letter, for example. Open the command prompt as an +administrator by typing in `cmd` in the start menu, right clicking on the +command prompt application, and clicking "Run as administrator." Click "Yes" +when prompted to ask if you're sure you want to run the command prompt. You +should type in the following command to mount the "ale" directory for testing, +where "E:" is replaced with your drive letter. > + + mklink /D C:\testplugin E: +< +Close the administrator Command Prompt, and try running the command +`type C:\testplugin\LICENSE` in a new Command Prompt which you are NOT running +as administrator. You should see the license for ALE in your terminal. After +you have confirmed that you have mounted ALE on your machine, search in the +Start Menu for "power shell," run PowerShell as an administrator, and issue +the following commands to install the correct Vim and Vader versions for +running tests. > + + Add-Type -A System.IO.Compression.FileSystem + + Invoke-WebRequest ftp://ftp.vim.org/pub/vim/pc/vim80-586w32.zip -OutFile C:\vim.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\vim.zip', 'C:\vim') + rm C:\vim.zip + + Invoke-WebRequest ftp://ftp.vim.org/pub/vim/pc/vim80-586rt.zip -OutFile C:\rt.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\rt.zip', 'C:\vim') + rm C:\rt.zip + + Invoke-WebRequest https://github.com/junegunn/vader.vim/archive/c6243dd81c98350df4dec608fa972df98fa2a3af.zip -OutFile C:\vader.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\vader.zip', 'C:\') + mv C:\vader.vim-c6243dd81c98350df4dec608fa972df98fa2a3af C:\vader + rm C:\vader.zip +< +After you have finished installing everything, you can run all of the tests +in Windows by opening a Command Prompt NOT as an administrator by navigating +to the directory where you've mounted the ALE code, which must be named +`C:\testplugin`, and by running the `run-tests.bat` batch file. > + + cd C:\testplugin + run-tests +< +It will probably take several minutes for all of the tests to run. Be patient. +You can run a specific test by passing the filename as an argument to the +batch file, for example: `run-tests test/test_c_flag_parsing.vader` . This will +give you results much more quickly. + +=============================================================================== +5. Contributing *ale-development-contributing* + +All integration of new code into ALE is done through GitHub pull requests. +Using that tool streamlines the process and minimizes the time and effort +required to e.g. ensure test suites are run for every change. + +As for any project hosted by GitHub, the choice of platform demands every +contributor to take care to setup an account and configure it accordingly. + +Due to details of our process, a difference to many other GitHub hosted +projects is that contributors who wish to keep the author fields for their +commits unaltered need to configure a public email address in their account +and profile settings. See: https://docs.github.com/en/account-and-profile/ + +Unless configuring GitHub to expose contact details, commits will be rewritten +to appear by `USERNAME ` . + +=============================================================================== +5.1 Preparing a Release *ale-development-release* + +ALE offers release packages through GitHub, for two reasons: + +1. Some users like to target specific release versions rather than simply + installing the plugin from `master`. This includes users who create Linux + distribution specific packages from GitHub releases. +2. The releases provide a nice way to get an overview of what has changed in + ALE over time. + +ALE has no fixed release schedule. Release versions are created whenever the +ALE developers feel the need to create one. ALE release versions follow the +typical Semantic Versioning scheme. See: https://semver.org/ + +Minor version releases for ALE should be the most common, followed by patch +releases. Every minor version release should be followed by a `vA.B.x` branch +such as `v2.0.x` for version `2.0.0` and every following patch version before +`2.1.0`. The `git` branch strategy for patches is to first merge a bug fix to +`master`, and then `git cherry-pick` a patch to a branch for a specific +version. ALE developers do not generally support anything but `master` or the +last minor version. + +Generally ALE releases hit a major version only when there are breaking +changes to a public ALE setting or function. A "public" setting or function is +defined as any setting or function documented in the `:help` |ale.txt| file. +Major ALE versions ought to be so rare that they only come once a year at +most. ALE should not typically introduce any breaking changes. + +If there are ever to be any breaking changes made for ALE, there should first +come a minor version release for ALE documenting all of the coming breaking +changes to ALE. It should be described how users can prepare for a breaking +change that is coming before it is done. + +To create a release for ALE, you will need sufficient permissions in GitHub. +Once you do, follow these steps. + +1. Create a new release draft, or edit an existing one. It helps to craft + drafts ahead of time and write the last commit ID checked for release notes + on the last update to a draft. + See the releases page: https://github.com/dense-analysis/ale/releases +2. Examine `git log` and read changes made between the last ID checked, or the + git tag of the previous release, and the current commit in `master`. +3. Write updates in separate sections (except where empty) for: + 3.a. Breaking Changes + 3.b. Deprecated Features + 3.c. New Features + 3.d. New Linters + 3.e. New Fixers + 3.f. Linter Enhancements + 3.g. Fixer Enhancements + 3.h. Bugs Fixed +4. Once you've finished writing the draft for the release, bump + `s:current_ale_version` in `autoload/ale.vim` to the current version, and + add a line to `test/test_ale_has.vader` to test for the version. See + |ale#Has()| documentation for more information. +5. Commit the changes after `./run-tests --fast -q` passes. +6. Tag the release with `git tag vA.B.C`, replacing `A`, `B`, and `C` with the + version numbers. See `git tag --list` for examples. +7. Run `git push` and `git push --tags` to push the commit and the tag. +8. Edit the release draft in GitHub, select the tag you just pushed, and + publish the draft. +9. If you're creating a new major or minor version: `git checkout -b vA.B.x`, + replacing `A` and `B` with the major and minor versions. `git push` the new + branch, and the GitHub branch protection settings should automatically + apply to the new release branch. +10. You have already completed the last step. + +Have fun creating ALE releases. Drink responsibly, or not at all, which is the +preference of w0rp. =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-dhall.txt b/sources_non_forked/ale/doc/ale-dhall.txt new file mode 100644 index 00000000..9b997b9e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-dhall.txt @@ -0,0 +1,52 @@ +=============================================================================== +ALE Dhall Integration *ale-dhall-options* + +g:ale_dhall_executable *g:ale_dhall_executable* + *b:ale_dhall_executable* + Type: |String| + Default: `'dhall'` + +g:ale_dhall_options *g:ale_dhall_options* + *b:ale_dhall_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the 'dhall` executable. + This is shared with `dhall-freeze` and `dhall-lint`. +> + let g:ale_dhall_options = '--ascii' +< + +=============================================================================== +dhall-format *ale-dhall-format* + +Dhall + (https://dhall-lang.org/) + + +=============================================================================== +dhall-freeze *ale-dhall-freeze* + +Dhall + (https://dhall-lang.org/) + +g:ale_dhall_freeze_options *g:ale_dhall_freeze_options* + *b:ale_dhall_freeze_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the 'dhall freeze` + executable. +> + let g:ale_dhall_freeze_options = '--all' +< + +=============================================================================== +dhall-lint *ale-dhall-lint* + +Dhall + (https://dhall-lang.org/) + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-dockerfile.txt b/sources_non_forked/ale/doc/ale-dockerfile.txt index 284c6a10..5d955404 100644 --- a/sources_non_forked/ale/doc/ale-dockerfile.txt +++ b/sources_non_forked/ale/doc/ale-dockerfile.txt @@ -25,12 +25,53 @@ g:ale_dockerfile_dockerfile_lint_options the dockerfile lint invocation - like custom rule file definitions. +=============================================================================== +dockerlinter *ale-dockerfile-dockerlinter* + +g:ale_dockerfile_dockerlinter_executable + *g:ale_dockerfile_dockerlinter_executable* + *b:ale_dockerfile_dockerlinter_executable* + Type: |String| + Default: `'dockerlinter'` + + This variable can be changed to specify the executable used to run + dockerlinter. + + +g:ale_dockerfile_dockerlinter_options + *g:ale_dockerfile_dockerlinter_options* + *b:ale_dockerfile_dockerlinter_options* + Type: |String| + Default: `''` + + This variable can be changed to add additional command-line arguments to + the dockerfile lint invocation - like custom rule file definitions. + + dockerlinter + + +=============================================================================== +dprint *ale-dockerfile-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/dockerfile + + =============================================================================== hadolint *ale-dockerfile-hadolint* hadolint can be found at: https://github.com/hadolint/hadolint +g:ale_dockerfile_hadolint_options *g:ale_dockerfile_hadolint_options* + *b:ale_dockerfile_hadolint_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the hadolint + invocation. These arguments will be used whether docker is being used or not + (see below). + + g:ale_dockerfile_hadolint_use_docker *g:ale_dockerfile_hadolint_use_docker* *b:ale_dockerfile_hadolint_use_docker* Type: |String| diff --git a/sources_non_forked/ale/doc/ale-elixir.txt b/sources_non_forked/ale/doc/ale-elixir.txt index 5864f728..351b442a 100644 --- a/sources_non_forked/ale/doc/ale-elixir.txt +++ b/sources_non_forked/ale/doc/ale-elixir.txt @@ -5,8 +5,7 @@ ALE Elixir Integration *ale-elixir-options* =============================================================================== mix *ale-elixir-mix* - -The `mix` linter is disabled by default, as it can bee too expensive to run. +The `mix` linter is disabled by default, as it can be too expensive to run. See `:help g:ale_linters` @@ -18,6 +17,7 @@ g:ale_elixir_mix_options *g:ale_elixir_mix_options* This variable can be changed to specify the mix executable. + =============================================================================== mix_format *ale-elixir-mix-format* @@ -30,6 +30,7 @@ g:ale_elixir_mix_format_options *g:ale_elixir_mix_format_options* This variable can be changed to specify the mix options passed to the mix_format fixer + =============================================================================== dialyxir *ale-elixir-dialyxir* @@ -45,6 +46,7 @@ configured on your project's `mix.exs`. See https://github.com/jeremyjh/dialyxir#with-explaining-stuff for more information. + =============================================================================== elixir-ls *ale-elixir-elixir-ls* @@ -72,6 +74,8 @@ g:ale_elixir_elixir_ls_config *g:ale_elixir_elixir_ls_config* \ } < Consult the ElixirLS documentation for more information about settings. + + =============================================================================== credo *ale-elixir-credo* @@ -79,11 +83,44 @@ Credo (https://github.com/rrrene/credo) g:ale_elixir_credo_strict *g:ale_elixir_credo_strict* - Type: Integer - Default: 0 + Type: |Integer| + Default: `0` Tells credo to run in strict mode or suggest mode. Set variable to 1 to enable --strict mode. + +g:ale_elixir_credo_config_file *g:ale_elixir_credo_config_file* + + Type: |String| + Default: `''` + + Tells credo to use a custom configuration file. + + +=============================================================================== +cspell *ale-elixir-cspell* + +See |ale-cspell-options| + + +=============================================================================== +lexical *ale-elixir-lexical* + +Lexical (https://github.com/lexical-lsp/lexical) + +g:ale_elixir_lexical_release *g:ale_elixir_lexical_release* + *b:ale_elixir_lexical_release* + Type: |String| + Default: `'lexical'` + + Location of the lexical release directory. This directory must contain + the language server scripts (start_lexical.sh and start_lexical.bat). + + For example, set release to: `/home/projects/lexical/_build/dev/rel/lexical` + + There are currnetly no configuration options for lexical. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-elm.txt b/sources_non_forked/ale/doc/ale-elm.txt index 823b53e1..b1510241 100644 --- a/sources_non_forked/ale/doc/ale-elm.txt +++ b/sources_non_forked/ale/doc/ale-elm.txt @@ -50,7 +50,7 @@ g:ale_elm_ls_use_global *g:ale_elm_ls_use_global* g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path* *b:ale_elm_ls_elm_path* Type: |String| - Default: `'elm'` + Default: `''` See |ale-integrations-local-executables| @@ -58,7 +58,7 @@ g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path* g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path* *b:ale_elm_ls_elm_format_path* Type: |String| - Default: `'elm-format'` + Default: `''` See |ale-integrations-local-executables| @@ -66,10 +66,18 @@ g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path* g:ale_elm_ls_elm_test_path *g:ale_elm_ls_elm_test_path* *b:ale_elm_ls_elm_test_path* Type: |String| - Default: `'elm-test'` + Default: `''` See |ale-integrations-local-executables| + +g:ale_elm_ls_elm_analyse_trigger *g:ale_elm_ls_elm_analyse_trigger* + *b:ale_elm_ls_elm_analyse_trigger* + Type: |String| + Default: `'change'` + + One of 'change', 'save' or 'never' + =============================================================================== elm-make *ale-elm-elm-make* diff --git a/sources_non_forked/ale/doc/ale-erlang.txt b/sources_non_forked/ale/doc/ale-erlang.txt index 59993a99..601410da 100644 --- a/sources_non_forked/ale/doc/ale-erlang.txt +++ b/sources_non_forked/ale/doc/ale-erlang.txt @@ -13,6 +13,14 @@ g:ale_erlang_dialyzer_executable *g:ale_erlang_dialyzer_executable* This variable can be changed to specify the dialyzer executable. +g:ale_erlang_dialyzer_options *g:ale_erlang_dialyzer_options* + *b:ale_erlang_dialyzer_options* + Type: |String| + Default: `'-Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspec'` + + This variable can be changed to specify the options to pass to the dialyzer + executable. + g:ale_erlang_dialyzer_plt_file *g:ale_erlang_dialyzer_plt_file* *b:ale_erlang_dialyzer_plt_file* Type: |String| @@ -31,9 +39,105 @@ g:ale_erlang_dialyzer_rebar3_profile *g:ale_erlang_dialyzer_rebar3_profile* This variable can be changed to specify the profile that is used to run dialyzer with rebar3. + +------------------------------------------------------------------------------- +elvis *ale-erlang-elvis* + +g:ale_erlang_elvis_executable *g:ale_erlang_elvis_executable* + *b:ale_erlang_elvis_executable* + Type: |String| + Default: `'elvis'` + + This variable can be changed to specify the elvis executable. + + +------------------------------------------------------------------------------- +erlang-mode *ale-erlang-erlang-mode* + +g:ale_erlang_erlang_mode_emacs_executable + *g:ale_erlang_erlang_mode_emacs_executable* + *b:ale_erlang_erlang_mode_emacs_executable* + Type: |String| + Default: `'emacs'` + + This variable can be changed to specify the Emacs executable. + +g:ale_erlang_erlang_mode_indent_level *g:ale_erlang_erlang_mode_indent_level* + *b:ale_erlang_erlang_mode_indent_level* + Type: |Number| + Default: `4` + + Indentation of Erlang calls/clauses within blocks. + +g:ale_erlang_erlang_mode_icr_indent *g:ale_erlang_erlang_mode_icr_indent* + *b:ale_erlang_erlang_mode_icr_indent* + Type: `'nil'` or |Number| + Default: `'nil'` + + Indentation of Erlang if/case/receive patterns. `'nil'` means keeping default + behavior. When non-`'nil'`, indent to the column of if/case/receive. + +g:ale_erlang_erlang_mode_indent_guard *g:ale_erlang_erlang_mode_indent_guard* + *b:ale_erlang_erlang_mode_indent_guard* + Type: |Number| + Default: `2` + + Indentation of Erlang guards. + +g:ale_erlang_erlang_mode_argument_indent + *g:ale_erlang_erlang_mode_argument_indent* + *b:ale_erlang_erlang_mode_argument_indent* + Type: `'nil'` or |Number| + Default: `2` + + Indentation of the first argument in a function call. When `'nil'`, indent + to the column after the `'('` of the function. + +g:ale_erlang_erlang_mode_indent_tabs_mode + *g:ale_erlang_erlang_mode_indent_tabs_mode* + *b:ale_erlang_erlang_mode_indent_tabs_mode* + Type: `'nil'` or `'t'` + Default: `'nil'` + + Indentation can insert tabs if this is non-`'nil'`. + + +------------------------------------------------------------------------------- +erlang_ls *ale-erlang-erlang_ls* + +g:ale_erlang_erlang_ls_executable *g:ale_erlang_erlang_ls_executable* + *b:ale_erlang_erlang_ls_executable* + Type: |String| + Default: `'erlang_ls'` + + This variable can be changed to specify the erlang_ls executable. + +g:ale_erlang_erlang_ls_log_dir *g:ale_erlang_erlang_ls_log_dir* + *b:ale_erlang_erlang_ls_log_dir* + Type: |String| + Default: `''` + + If set this variable overrides default directory where logs will be written. + +g:ale_erlang_erlang_ls_log_level *g:ale_erlang_erlang_ls_log_level* + *b:ale_erlang_erlang_ls_log_level* + Type: |String| + Default: `'info'` + + This variable can be changed to specify log level. + + ------------------------------------------------------------------------------- erlc *ale-erlang-erlc* +g:ale_erlang_erlc_executable *g:ale_erlang_erlc_executable* + *b:ale_erlang_erlc_executable* + Type: |String| + Default: `'erlc'` + + This variable can be changed to specify the erlc executable. + + g:ale_erlang_erlc_options *g:ale_erlang_erlc_options* *b:ale_erlang_erlc_options* Type: |String| @@ -43,6 +147,26 @@ g:ale_erlang_erlc_options *g:ale_erlang_erlc_options* or `-pa`. +------------------------------------------------------------------------------- +erlfmt *ale-erlang-erlfmt* + +g:ale_erlang_erlfmt_executable *g:ale_erlang_erlfmt_executable* + *b:ale_erlang_erlfmt_executable* + Type: |String| + Default: `'erlfmt'` + + This variable can be changed to specify the erlfmt executable. + + +g:ale_erlang_erlfmt_options *g:ale_erlang_erlfmt_options* + *b:ale_erlang_erlfmt_options* + Type: |String| + Default: `''` + + This variable controls additional parameters passed to `erlfmt`, such as + `--insert-pragma` or `--print-width`. + + ------------------------------------------------------------------------------- syntaxerl *ale-erlang-syntaxerl* diff --git a/sources_non_forked/ale/doc/ale-eruby.txt b/sources_non_forked/ale/doc/ale-eruby.txt index d75d3868..82fe685a 100644 --- a/sources_non_forked/ale/doc/ale-eruby.txt +++ b/sources_non_forked/ale/doc/ale-eruby.txt @@ -4,8 +4,10 @@ ALE Eruby Integration *ale-eruby-options* There are four linters for `eruby` files: - `erb` +- `erblint` - `erubis` - `erubi` +- `htmlbeautifier` - `ruumba` `erb` is in the Ruby standard library and is mostly universal. `erubis` is the @@ -13,13 +15,58 @@ default parser in Rails between 3.0 and 5.1. `erubi` is the default in Rails 5.1 and later. `ruumba` can extract Ruby from eruby files and run rubocop on the result. To selectively enable a subset, see |g:ale_linters|. + +=============================================================================== +erb-formatter *ale-eruby-erbformatter* + +g:ale_eruby_erbformatter_executable *g:ale_eruby_erbformatter_executable* + *b:ale_eruby_erbformatter_executable* + Type: |String| + Default: `'erb-formatter'` + + Override the invoked erb-formatter binary. This is useful for running + erb-formatter from binstubs or a bundle. + + +=============================================================================== +erblint *ale-eruby-erblint* + +g:ale_eruby_erblint_executable *g:ale_eruby_erblint_executable* + *b:ale_eruby_erblint_executable* + Type: |String| + Default: `'erblint'` + + Override the invoked erblint binary. This is useful for running erblint + from binstubs or a bundle. + + +g:ale_eruby_erblint_options *g:ale_ruby_erblint_options* + *b:ale_ruby_erblint_options* + Type: |String| + Default: `''` + + 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* g:ale_eruby_ruumba_executable *g:ale_eruby_ruumba_executable* *b:ale_eruby_ruumba_executable* - Type: String - Default: `'ruumba` + Type: |String| + Default: `'ruumba'` Override the invoked ruumba binary. This is useful for running ruumba from binstubs or a bundle. diff --git a/sources_non_forked/ale/doc/ale-fish.txt b/sources_non_forked/ale/doc/ale-fish.txt index 8450b38a..7dbbc10c 100644 --- a/sources_non_forked/ale/doc/ale-fish.txt +++ b/sources_non_forked/ale/doc/ale-fish.txt @@ -10,5 +10,22 @@ displaying errors if an error message is not found. If ALE is not showing any errors but your file does not run as expected, run `fish -n ` from the command line. +=============================================================================== +fish_indent *ale-fish-fish_indent* + +g:ale_fish_fish_indent_executable *g:ale_fish_fish_indent_executable* + *b:ale_fish_fish_indent_executable* + Type: |String| + Default: `'fish_indent'` + + This variable can be changed to use a different executable for fish_indent. + +g:ale_fish_fish_indent_options *g:ale_fish_fish_indent_options* + *b:ale_fish_fish_indent_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to fish_indent. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-gleam.txt b/sources_non_forked/ale/doc/ale-gleam.txt new file mode 100644 index 00000000..9b870a58 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-gleam.txt @@ -0,0 +1,30 @@ +=============================================================================== +ALE Gleam Integration *ale-gleam-options* + *ale-integration-gleam* + + +=============================================================================== +gleam_format *ale-gleam-gleam_format* + +g:ale_gleam_gleam_format_executable *g:ale_gleam_gleam_format_executable* + *b:ale_gleam_gleam_format_executable* + Type: |String| + Default: `'gleam'` + + This variable can be modified to change the executable path for + `gleam format`. + + +=============================================================================== +gleamlsp *ale-gleam-gleamlsp* + +g:ale_gleam_gleamlsp_executable *g:ale_gleam_gleamlsp_executable* + *b:ale_gleam_gleamlsp_executable* + Type: |String| + Default: `'gleam'` + + This variable can be modified to change the executable path for `gleamlsp`. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-go.txt b/sources_non_forked/ale/doc/ale-go.txt index be53783e..ea6311a8 100644 --- a/sources_non_forked/ale/doc/ale-go.txt +++ b/sources_non_forked/ale/doc/ale-go.txt @@ -5,23 +5,18 @@ ALE Go Integration *ale-go-options* =============================================================================== Integration Information -The `gometalinter` linter is disabled by default. ALE enables `gofmt`, -`golint` and `go vet` by default. It also supports `staticcheck`, `go -build`, `gosimple`, `golangserver`. +ALE enables `gofmt`, `gopls` and `go vet` by default. It also supports `staticcheck`, +`go build, ``gosimple`, `golangserver`, and `golangci-lint. -To enable `gometalinter`, update |g:ale_linters| as appropriate: +To enable `golangci-lint`, update |g:ale_linters| as appropriate. +A possible configuration is to enable golangci-lint and `gofmt: > " Enable all of the linters you want for Go. - let g:ale_linters = {'go': ['gometalinter', 'gofmt']} + let g:ale_linters = {'go': ['golangci-lint', 'gofmt']} < -A possible configuration is to enable `gometalinter` and `gofmt` but paired -with the `--fast` option, set by |g:ale_go_gometalinter_options|. This gets you -the benefit of running a number of linters, more than ALE would by default, -while ensuring it doesn't run any linters known to be slow or resource -intensive. -g:ale_go_go_executable *g:ale_go_go_options* - *b:ale_go_go_options* +g:ale_go_go_executable *g:ale_go_go_executable* + *b:ale_go_go_executable* Type: |String| Default: `'go'` @@ -39,7 +34,6 @@ g:ale_go_go111module *g:ale_go_go111module* golang tools. - =============================================================================== bingo *ale-go-bingo* @@ -57,6 +51,11 @@ g:ale_go_bingo_options *g:ale_go_bingo_options* Default: `''` +=============================================================================== +cspell *ale-go-cspell* + +See |ale-cspell-options| + =============================================================================== gobuild *ale-go-gobuild* @@ -80,6 +79,24 @@ g:ale_go_gofmt_options *g:ale_go_gofmt_options* This variable can be set to pass additional options to the gofmt fixer. +=============================================================================== +gofumpt *ale-go-gofumpt* + +g:ale_go_gofumpt_executable *g:ale_go_gofumpt_executable* + *b:ale_go_gofumpt_executable* + Type: |String| + Default: `'gofumpt'` + + Executable to run to use as the gofumpt fixer. + +g:ale_go_gofumpt_options *g:ale_go_gofumpt_options* + *b:ale_go_gofumpt_options* + Type: |String| + Default: `''` + + Options to pass to the gofumpt fixer. + + =============================================================================== golangci-lint *ale-go-golangci-lint* @@ -98,7 +115,7 @@ g:ale_go_golangci_lint_executable *g:ale_go_golangci_lint_executable* g:ale_go_golangci_lint_options *g:ale_go_golangci_lint_options* *b:ale_go_golangci_lint_options* Type: |String| - Default: `'--enable-all'` + Default: `''` This variable can be changed to alter the command-line arguments to the golangci-lint invocation. @@ -135,71 +152,51 @@ g:ale_go_langserver_options *g:ale_go_langserver_options* =============================================================================== -golint *ale-go-golint* +golines *ale-go-golines* -g:ale_go_golint_executable *g:ale_go_golint_executable* - *b:ale_go_golint_executable* +g:ale_go_golines_executable *g:ale_go_lines_executable* + *b:ale_go_lines_executable* Type: |String| - Default: `'golint'` + Default: `'golines'` - This variable can be set to change the golint executable path. + Location of the golines binary file - -g:ale_go_golint_options *g:ale_go_golint_options* - *b:ale_go_golint_options* +g:ale_go_golines_options *g:ale_go_golines_options* + *b:ale_go_golines_options* Type: |String| Default: `''` - This variable can be set to pass additional options to the golint linter. - - -=============================================================================== -gometalinter *ale-go-gometalinter* - -`gometalinter` is a `lint_file` linter, which only lints files that are -written to disk. This differs from the default behavior of linting the buffer. -See: |ale-lint-file| - -g:ale_go_gometalinter_executable *g:ale_go_gometalinter_executable* - *b:ale_go_gometalinter_executable* - Type: |String| - Default: `'gometalinter'` - - The executable that will be run for gometalinter. - - -g:ale_go_gometalinter_options *g:ale_go_gometalinter_options* - *b:ale_go_gometalinter_options* - Type: |String| - Default: `''` - - This variable can be changed to alter the command-line arguments to the - gometalinter invocation. - - Since `gometalinter` runs a number of linters that can consume a lot of - resources it's recommended to set this option to a value of `--fast` if you - use `gometalinter` as one of the linters in |g:ale_linters|. This disables a - number of linters known to be slow or consume a lot of resources. - - -g:ale_go_gometalinter_lint_package *g:ale_go_gometalinter_lint_package* - *b:ale_go_gometalinter_lint_package* - Type: |Number| - Default: `0` - - When set to `1`, the whole Go package will be checked instead of only the - current file. + Additional options passed to the golines command. By default golines has + --max-length=100 (lines above 100 characters will be wrapped) =============================================================================== gopls *ale-go-gopls* +gopls is the official Go language server, and is enabled for use with ALE by +default. + +To install the latest stable version of `gopls` to your `$GOPATH`, try the +following command: > + + GO111MODULE=on go get golang.org/x/tools/gopls@latest +< +If `$GOPATH` is readable by ALE, it should probably work without you having to +do anything else. See the `gopls` README file for more information: + +https://github.com/golang/tools/blob/master/gopls/README.md + + g:ale_go_gopls_executable *g:ale_go_gopls_executable* *b:ale_go_gopls_executable* Type: |String| Default: `'gopls'` - Location of the gopls binary file. + See |ale-integrations-local-executables| + + ALE will search for `gopls` in locally installed directories first by + default, and fall back on a globally installed `gopls` if it can't be found + otherwise. g:ale_go_gopls_options *g:ale_go_gopls_options* @@ -207,6 +204,51 @@ g:ale_go_gopls_options *g:ale_go_gopls_options* Type: |String| Default: `''` + Command-line options passed to the gopls executable. See `gopls -h`. + + +g:ale_go_gopls_fix_executable *g:ale_go_gopls_fix_executable* + *b:ale_go_gopls_fix_executable* + Type: |String| + Default: `'gopls'` + + Executable to run to use as the gopls fixer. + +g:ale_go_gopls_fix_options *g:ale_go_gopls_fix_options* + *b:ale_go_gopls_fix_options* + Type: |String| + Default: `''` + + Options to pass to the gopls fixer. + + +g:ale_go_gopls_init_options *g:ale_go_gopls_init_options* + *b:ale_go_gopls_init_options* + Type: |Dictionary| + Default: `{}` + + LSP initialization options passed to gopls. This can be used to configure + the behaviour of gopls. + + Example: > + let g:ale_go_gopls_init_options = {'ui.diagnostic.analyses': { + \ 'composites': v:false, + \ 'unusedparams': v:true, + \ 'unusedresult': v:true, + \ }} +< + + For a full list of supported analyzers, see: + https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md + + +g:ale_go_gopls_use_global *g:ale_go_gopls_use_global* + *b:ale_go_gopls_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + =============================================================================== govet *ale-go-govet* @@ -219,9 +261,40 @@ g:ale_go_govet_options *g:ale_go_govet_options* This variable can be set to pass additional options to the go vet linter. +=============================================================================== +revive *ale-go-revive* + +g:ale_go_revive_executable *g:ale_go_revive_executable* + *b:ale_go_revive_executable* + Type: |String| + Default: `'revive'` + + This variable can be set to change the revive executable path. + + +g:ale_go_revive_options *g:ale_go_revive_options* + *b:ale_go_revive_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the revive + + =============================================================================== staticcheck *ale-go-staticcheck* +g:ale_go_staticcheck_executable *g:ale_go_staticcheck_executable* + *b:ale_go_staticcheck_executable* + Type: |String| + Default: `'staticcheck'` + + See |ale-integrations-local-executables| + + ALE will search for `staticcheck` in locally installed directories first by + default, and fall back on a globally installed `staticcheck` if it can't be + found otherwise. + + g:ale_go_staticcheck_options *g:ale_go_staticcheck_options* *b:ale_go_staticcheck_options* Type: |String| @@ -234,11 +307,19 @@ g:ale_go_staticcheck_options *g:ale_go_staticcheck_options* g:ale_go_staticcheck_lint_package *g:ale_go_staticcheck_lint_package* *b:ale_go_staticcheck_lint_package* Type: |Number| - Default: `0` + Default: `1` When set to `1`, the whole Go package will be checked instead of only the current file. +g:ale_go_staticcheck_use_global *g:ale_go_staticcheck_use_global* + *b:ale_go_staticcheck_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-gohtmltmpl.txt b/sources_non_forked/ale/doc/ale-gohtmltmpl.txt new file mode 100644 index 00000000..8672f5d4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-gohtmltmpl.txt @@ -0,0 +1,11 @@ +=============================================================================== +ALE Go HTML Template Integration *ale-gohtmltmpl-options* + + +=============================================================================== +djlint *ale-gohtmltmpl-djlint* + +See |ale-html-djlint| + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-groovy.txt b/sources_non_forked/ale/doc/ale-groovy.txt new file mode 100644 index 00000000..cc5e8881 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-groovy.txt @@ -0,0 +1,42 @@ +=============================================================================== +ALE Groovy Integration *ale-groovy-options* + + +=============================================================================== +Integration Information + +Linting and fixing of Groovy files is enabled with the integration of +`npm-groovy-lint`. + + +=============================================================================== +npm-groovy-lint *ale-groovy-npm-groovy-lint* + +g:ale_groovy_npmgroovylint_executable *g:ale_groovy_npmgroovylint_executable* + *b:ale_groovy_npmgroovylint_executable* + Type: |String| + Default: `'npm-groovy-lint'` + + Location of the npm-groovy-lint binary file. + + +g:ale_groovy_npmgroovylint_options *g:ale_groovy_npmgroovylint_options* + *b:ale_groovy_npmgroovylint_options* + Type: |String| + Default: `'--loglevel warning'` + + Additional npm-groovy-lint linter options. + + +g:ale_groovy_npmgroovylint_fix_options *g:ale_groovy_npmgroovylint_fix_options* + *b:ale_groovy_npmgroovylint_fix_options* + Type: |String| + Default: `'--fix'` + + This variable can be used to configure fixing with npm-groovy-lint. It must + contain either `--fix` or `--format` for the fixer to work. See + `npm-groovy-lint --help` for more information on possible fix rules. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-handlebars.txt b/sources_non_forked/ale/doc/ale-handlebars.txt index 5daec5b3..8f018d34 100644 --- a/sources_non_forked/ale/doc/ale-handlebars.txt +++ b/sources_non_forked/ale/doc/ale-handlebars.txt @@ -2,6 +2,13 @@ ALE Handlebars Integration *ale-handlebars-options* +=============================================================================== +djlint *ale-handlebars-djlint* + +See |ale-html-djlint| + +=============================================================================== + =============================================================================== prettier *ale-handlebars-prettier* @@ -14,7 +21,8 @@ ember-template-lint *ale-handlebars-embertemplatelint* g:ale_handlebars_embertemplatelint_executable *g:ale_handlebars_embertemplatelint_executable* - Type: |String| *b:ale_handlebars_embertemplatelint_executable* + *b:ale_handlebars_embertemplatelint_executable* + Type: |String| Default: `'ember-template-lint'` See |ale-integrations-local-executables| @@ -22,7 +30,8 @@ g:ale_handlebars_embertemplatelint_executable g:ale_handlebars_embertemplatelint_use_global *g:ale_handlebars_embertemplatelint_use_global* - Type: |Number| *b:ale_handlebars_embertemplatelint_use_global* + *b:ale_handlebars_embertemplatelint_use_global* + Type: |Number| Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-haskell.txt b/sources_non_forked/ale/doc/ale-haskell.txt index 5dd3ec15..bcd15724 100644 --- a/sources_non_forked/ale/doc/ale-haskell.txt +++ b/sources_non_forked/ale/doc/ale-haskell.txt @@ -13,6 +13,12 @@ g:ale_haskell_brittany_executable *g:ale_haskell_brittany_executable* This variable can be changed to use a different executable for brittany. +=============================================================================== +cspell *ale-haskell-cspell* + +See |ale-cspell-options| + + =============================================================================== floskell *ale-haskell-floskell* @@ -117,13 +123,39 @@ g:ale_haskell_hlint_executable *g:ale_haskell_hlint_executable* g:ale_haskell_hlint_options g:ale_haskell_hlint_options b:ale_haskell_hlint_options - Type: String - Default: '' + Type: |String| + Default: `''` This variable can be used to pass extra options to the underlying hlint executable. +=============================================================================== +hls *ale-haskell-hls* + +g:ale_haskell_hls_executable *g:ale_haskell_hls_executable* + *b:ale_haskell_hls_executable* + Type: |String| + Default: `'haskell-language-server-wrapper'` + + This variable can be changed to use a different executable for the haskell + language server. + + +g:ale_haskell_hls_config *g:ale_haskell_hls_config* + *b:ale_haskell_hls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for HLS. For example, to see more + completions: +> + let g:ale_haskell_hls_config = {'haskell': {'maxCompletions': 250}} +< + Refer to HLS documentation for possible settings: + https://haskell-language-server.readthedocs.io/en/latest/configuration.html#language-specific-server-options + + =============================================================================== stack-build *ale-haskell-stack-build* @@ -172,5 +204,45 @@ g:ale_haskell_hie_executable *g:ale_haskell_hie_executable* ide engine. i.e. `'hie-wrapper'` +=============================================================================== +ormolu *ale-haskell-ormolu* + +g:ale_haskell_ormolu_executable *g:ale_haskell_ormolu_executable* + *b:ale_haskell_ormolu_executable* + Type: |String| + Default: `'ormolu'` + + This variable can be changed to use a different executable for ormolu. + + +g:ale_haskell_ormolu_options *g:ale_haskell_ormolu_options* + *b:ale_haskell_ormolu_options* + Type: |String| + Default: `''` + + This variable can be used to pass extra options to the underlying ormolu + executable. + + +=============================================================================== +fourmolu *ale-haskell-fourmolu* + +g:ale_haskell_fourmolu_executable *g:ale_haskell_fourmolu_executable* + *b:ale_haskell_fourmolu_executable* + Type: |String| + Default: `'fourmolu'` + + This variable can be changed to use a different executable for fourmolu. + + +g:ale_haskell_fourmolu_options *g:ale_haskell_fourmolu_options* + *b:ale_haskell_fourmolu_options* + Type: |String| + Default: `''` + + This variable can be used to pass extra options to the underlying fourmolu + executable. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-hcl.txt b/sources_non_forked/ale/doc/ale-hcl.txt index 59b0a9da..71e1114e 100644 --- a/sources_non_forked/ale/doc/ale-hcl.txt +++ b/sources_non_forked/ale/doc/ale-hcl.txt @@ -2,6 +2,11 @@ ALE HCL Integration *ale-hcl-options* +=============================================================================== +packer-fmt *ale-hcl-packer-fmt* + +See |ale-packer-fmt-fixer| for information about the available options. + =============================================================================== terraform-fmt *ale-hcl-terraform-fmt* diff --git a/sources_non_forked/ale/doc/ale-help.txt b/sources_non_forked/ale/doc/ale-help.txt new file mode 100644 index 00000000..89872545 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-help.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE Help Integration *ale-help-options* + + +=============================================================================== +cspell *ale-help-cspell* + +See |ale-cspell-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-html.txt b/sources_non_forked/ale/doc/ale-html.txt index 5d6b20e2..3db3ac85 100644 --- a/sources_non_forked/ale/doc/ale-html.txt +++ b/sources_non_forked/ale/doc/ale-html.txt @@ -2,14 +2,95 @@ ALE HTML Integration *ale-html-options* +=============================================================================== +angular *ale-html-angular* + +ALE supports language server features for Angular. You can install it via `npm`: > + + $ npm install --save-dev @angular/language-server +< +Angular 11 and up are supported. + + +g:ale_html_angular_executable *g:ale_html_angular_executable* + *b:ale_html_angular_executable* + Type: |String| + Default: `'ngserver'` + + See |ale-integrations-local-executables| + + +g:ale_html_angular_use_global *g:ale_html_angular_use_global* + *b:ale_html_angular_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +cspell *ale-html-cspell* + +See |ale-cspell-options| + +=============================================================================== +djlint *ale-html-djlint* + +`djlint` options for HTML are the same as the options for htmlangular, +htmldjango, jinja, handlebars, nunjucks and gotmplhtml. + +g:ale_html_djlint_executable *g:ale_html_djlint_executable* + *b:ale_html_djlint_executable* + Type: |String| + Default: `'djlint'` + + See |ale-integrations-local-executables| + + +g:ale_html_djlint_options *g:ale_html_djlint_options* + *b:ale_html_djlint_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to djlint. + + =============================================================================== fecs *ale-html-fecs* -`fecs` options for HTMl is the same as the options for JavaScript, -and both of them reads `./.fecsrc` as the default configuration file. +`fecs` options for HTML are the same as the options for JavaScript, and both +of them read `./.fecsrc` as the default configuration file. + See: |ale-javascript-fecs|. +=============================================================================== +html-beautify *ale-html-beautify* + +g:ale_html_beautify_executable *g:ale_html_beautify_executable* + *b:ale_html_beautify_executable* + Type: |String| + Default: `'html-beautify'` + + See |ale-integrations-local-executables| + + +g:ale_html_beautify_options *g:ale_html_beautify_options* + *b:ale_html_beautify_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to html-beautify. + + +g:ale_html_beautify_use_global *g:ale_html_beautify_use_global* + *b:ale_html_beautify_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== htmlhint *ale-html-htmlhint* @@ -37,6 +118,58 @@ g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global* See |ale-integrations-local-executables| +=============================================================================== +prettier *ale-html-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +rustywind *ale-html-rustywind* + +g:ale_html_rustywind_executable *g:ale_html_rustywind_executable* + *b:ale_html_rustywind_executable* + Type: |String| + Default: `'rustywind'` + + See |ale-integrations-local-executables| + + +g:ale_html_rustywind_options *g:ale_html_rustywind_options* + *b:ale_html_rustywind_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to rustywind. + + +=============================================================================== +stylelint *ale-html-stylelint* + +g:ale_html_stylelint_executable *g:ale_html_stylelint_executable* + *b:ale_html_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + + +g:ale_html_stylelint_options *g:ale_html_stylelint_options* + *b:ale_html_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + + +g:ale_html_stylelint_use_global *g:ale_html_stylelint_use_global* + *b:ale_html_stylelint_use_global* + Type: |String| + Default: `0` + + See |ale-integrations-local-executables| + + =============================================================================== tidy *ale-html-tidy* @@ -88,37 +221,17 @@ g:ale_html_tidy_use_global *g:html_tidy_use_global* =============================================================================== -prettier *ale-html-prettier* +vscodehtml *ale-html-vscode* -See |ale-javascript-prettier| for information about the available options. +Website: https://github.com/hrsh7th/vscode-langservers-extracted +Installation +------------------------------------------------------------------------------- -=============================================================================== -stylelint *ale-html-stylelint* - -g:ale_html_stylelint_executable *g:ale_html_stylelint_executable* - *b:ale_html_stylelint_executable* - Type: |String| - Default: `'stylelint'` - - See |ale-integrations-local-executables| - - -g:ale_html_stylelint_options *g:ale_html_stylelint_options* - *b:ale_html_stylelint_options* - Type: |String| - Default: `''` - - This variable can be set to pass additional options to stylelint. - - -g:ale_html_stylelint_use_global *g:ale_html_stylelint_use_global* - *b:ale_html_stylelint_use_global* - Type: |String| - Default: `0` - - See |ale-integrations-local-executables| +Install VSCode html language server either globally or locally: > + npm install -g vscode-langservers-extracted +< =============================================================================== write-good *ale-html-write-good* diff --git a/sources_non_forked/ale/doc/ale-htmlangular.txt b/sources_non_forked/ale/doc/ale-htmlangular.txt new file mode 100644 index 00000000..0027cfbd --- /dev/null +++ b/sources_non_forked/ale/doc/ale-htmlangular.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE HTML Angular Template Integration *ale-htmlangular-options* + + + +=============================================================================== +djlint *ale-htmlangular-djlint* + +See |ale-html-djlint| + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-htmldjango.txt b/sources_non_forked/ale/doc/ale-htmldjango.txt new file mode 100644 index 00000000..14431c8e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-htmldjango.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE HTML Django Template Integration *ale-htmldjango-options* + + + +=============================================================================== +djlint *ale-htmldjango-djlint* + +See |ale-html-djlint| + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-http.txt b/sources_non_forked/ale/doc/ale-http.txt new file mode 100644 index 00000000..aba52d34 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-http.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE HTTP Integration *ale-http-options* + + +=============================================================================== +kulala_fmt *ale-http-kulala_fmt* + +g:ale_http_kulala_fmt *g:ale_http_kulala_fmt_executable* + *b:ale_http_kulala_fmt_executable* + Type: |String| + Default: `'kulala_fmt'` + + Override the invoked kulala_fmt binary. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: 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-ink.txt b/sources_non_forked/ale/doc/ale-ink.txt new file mode 100644 index 00000000..9412a09f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-ink.txt @@ -0,0 +1,40 @@ +=============================================================================== +ALE Ink Integration *ale-ink-options* + + +=============================================================================== +ink-language-server *ale-ink-language-server* + +Ink Language Server + (https://github.com/ephraim/ink-language-server) + +g:ale_ink_ls_executable g:ale_ink_ls_executable + b:ale_ink_ls_executable + Type: |String| + Default: `'ink-language-server'` + + Ink language server executable. + +g:ale_ink_ls_initialization_options + g:ale_ink_ls_initialization_options + b:ale_ink_ls_initialization_options + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server at startup. For certain platforms and certain story + structures, the defaults will suffice. However, many projects will need to + change these settings - see the ink-language-server website for more + information. + + An example of setting non-default options: + { + \ 'ink': { + \ 'mainStoryPath': 'init.ink', + \ 'inklecateExecutablePath': '/usr/local/bin/inklecate', + \ 'runThroughMono': v:false + \ } + \} + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-inko.txt b/sources_non_forked/ale/doc/ale-inko.txt new file mode 100644 index 00000000..5ca14af6 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-inko.txt @@ -0,0 +1,22 @@ +=============================================================================== +ALE Inko Integration *ale-inko-options* + *ale-integration-inko* + +=============================================================================== +Integration Information + + Currently, the only supported linter for Inko is the Inko compiler itself. + +=============================================================================== +inko *ale-inko-inko* + +g:ale_inko_inko_executable *g:ale_inko_inko_executable* + *b:ale_inko_inko_executable* + Type: |String| + Default: `'inko'` + + This variable can be modified to change the executable path for `inko`. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-java.txt b/sources_non_forked/ale/doc/ale-java.txt index 32f0e6eb..aed3aaf8 100644 --- a/sources_non_forked/ale/doc/ale-java.txt +++ b/sources_non_forked/ale/doc/ale-java.txt @@ -24,7 +24,7 @@ g:ale_java_checkstyle_executable *g:ale_java_checkstyle_executable* *b:ale_java_checkstyle_executable* Type: |String| - Default: 'checkstyle' + Default: `'checkstyle'` This variable can be changed to modify the executable used for checkstyle. @@ -41,12 +41,25 @@ g:ale_java_checkstyle_options *g:ale_java_checkstyle_options* configuration files set with |g:ale_java_checkstyle_config|. +=============================================================================== +clang-format *ale-java-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for Java. + + +=============================================================================== +cspell *ale-java-cspell* + +See |ale-cspell-options| + + =============================================================================== javac *ale-java-javac* g:ale_java_javac_classpath *g:ale_java_javac_classpath* *b:ale_java_javac_classpath* - Type: |String| + Type: |String| or |List| Default: `''` This variable can be set to change the global classpath for Java. @@ -67,6 +80,29 @@ g:ale_java_javac_options *g:ale_java_javac_options* This variable can be set to pass additional options to javac. +g:ale_java_javac_sourcepath *g:ale_java_javac_sourcepath* + *b:ale_java_javac_sourcepath* + Type: |String| or |List| + Default: `''` + +This variable can set multiple source code paths, the source code path is a +relative path (relative to the project root directory). + +Example: + +String type: +Note that the unix system separator is a colon(`:`) window system +is a semicolon(`;`). +> + let g:ale_java_javac_sourcepath = 'build/gen/source/xx/main:build/gen/source' +< +List type: +> + let g:ale_java_javac_sourcepath = [ + \ 'build/generated/source/querydsl/main', + \ 'target/generated-sources/source/querydsl/main' + \ ] +< =============================================================================== google-java-format *ale-java-google-java-format* @@ -95,8 +131,8 @@ pmd *ale-java-pmd* g:ale_java_pmd_options *g:ale_java_pmd_options* *b:ale_java_pmd_options* - Type: String - Default: '-R category/java/bestpractices' + Type: |String| + Default: `'-R category/java/bestpractices'` This variable can be changed to modify flags given to PMD. Do not specify -f and -d. They are added automatically. @@ -107,18 +143,26 @@ javalsp *ale-java-javalsp* To enable Java LSP linter you need to download and build the vscode-javac language server from https://github.com/georgewfraser/java-language-server. -Simply download the source code and then build a distribution: - scripts/link_mac.sh +Before building the language server you need to install pre-requisites: npm, +maven, and protobuf. You also need to have Java 13 and JAVA_HOME properly +set. -or +After downloading the source code and installing all pre-requisites you can +build the language server with the included build.sh script: - scripts/link_windows.sh + scripts/build.sh -This generates a dist/mac or dist/windows directory that contains the -language server. To let ALE use this language server you need to set the +This will create launch scripts for Linux, Mac, and Windows in the dist folder +within the repo: + + - lang_server_linux.sh + - lang_server_mac.sh + - lang_server_windows.sh + +To let ALE use this language server you need to set the g:ale_java_javalsp_executable variable to the absolute path of the launcher -executable in this directory. +executable for your platform. g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* *b:ale_java_javalsp_executable* @@ -128,7 +172,7 @@ g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* This variable must be set to the absolute path of the language server launcher executable. For example: > - let g:ale_java_javalsp_executable=/java-language-server/dist/mac/bin/launcher + let g:ale_java_javalsp_executable=/java-language-server/dist/lang_server_linux.sh < g:ale_java_javalsp_config *g:ale_java_javalsp_config* @@ -136,11 +180,11 @@ g:ale_java_javalsp_config *g:ale_java_javalsp_config* Type: |Dictionary| Default: `{}` -The javalsp linter automatically detects external depenencies for Maven and +The javalsp linter automatically detects external dependencies for Maven and Gradle projects. In case the javalsp fails to detect some of them, you can specify them setting a dictionary to |g:ale_java_javalsp_config| variable. > - let g:ale_java_javalsp_executable = + let g:ale_java_javalsp_config = \ { \ 'java': { \ 'externalDependencies': [ @@ -158,16 +202,17 @@ The Java language server will look for the dependencies you specify in `externalDependencies` array in your Maven and Gradle caches ~/.m2 and ~/.gradle. + =============================================================================== eclipselsp *ale-java-eclipselsp* -To enable Eclipse LSP linter you need to clone and build the eclipse.jdt.ls +To enable Eclipse JDT LSP linter you need to clone and build the eclipse.jdt.ls language server from https://github.com/eclipse/eclipse.jdt.ls. Simply clone the source code repo and then build the plugin: ./mvnw clean verify -Note: currently, the build can only run when launched with JDK 8. JDK 9 or more +Note: currently, the build can only run when launched with JDK 11. More recent versions can be used to run the server though. After build completes the files required to run the language server will be @@ -186,8 +231,9 @@ g:ale_java_eclipselsp_path *g:ale_java_eclipselsp_path* Default: `'$HOME/eclipse.jdt.ls'` Absolute path to the location of the eclipse.jdt.ls repository folder. Or if - you have VSCode extension installed the absolute path to the VSCode extensions - folder (e.g. $HOME/.vscode/extensions/redhat.java-0.4x.0 in Linux). + you have VSCode extension installed the absolute path to the VSCode + extensions folder (e.g. $HOME/.vscode/extensions/redhat.java-0.4x.0 in + Linux). g:ale_java_eclipselsp_executable *g:ale_java_eclipse_executable* @@ -218,10 +264,22 @@ g:ale_java_eclipselsp_workspace_path *g:ale_java_eclipselsp_workspace_path* Type: |String| Default: `''` - If you have Eclipse installed is good idea to set this variable to the + If you have Eclipse installed it is a good idea to set this variable to the absolute path of the Eclipse workspace. If not set this value will be set to the parent folder of the project root. +g:ale_java_eclipselsp_javaagent *g:ale_java_eclipselsp_javaagent* + *b:ale_java_eclipselsp_javaagent* + + Type: |String| + Default: `''` + + A variable to add java agent for annotation processing such as Lombok. + If you have multiple java agent files, use space to separate them. + For example: +> + let g:ale_java_eclipselsp_javaagent='/eclipse/lombok.jar /eclipse/jacoco.jar' +< =============================================================================== uncrustify *ale-java-uncrustify* diff --git a/sources_non_forked/ale/doc/ale-javascript.txt b/sources_non_forked/ale/doc/ale-javascript.txt index ea0a7089..7e594f2a 100644 --- a/sources_non_forked/ale/doc/ale-javascript.txt +++ b/sources_non_forked/ale/doc/ale-javascript.txt @@ -17,12 +17,45 @@ You should change the structure of your project from this: > /path/foo/.eslintrc.js # root: true /path/foo/bar/.eslintrc.js # root: false < + To this: > /path/foo/.base-eslintrc.js # Base configuration here /path/foo/.eslintrc.js # extends: ["/path/foo/.base-eslintrc.js"] /path/foo/bar/.eslintrc.js # extends: ["/path/foo/.base-eslintrc.js"] < + +=============================================================================== +biome *ale-javascript-biome* + +Check the docs over at |ale-typescript-biome|. + + +=============================================================================== +clang-format *ale-javascript-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for JavaScript. + + +=============================================================================== +cspell *ale-javascript-cspell* + +See |ale-cspell-options| + + +=============================================================================== +deno *ale-javascript-deno* + +Check the docs over at |ale-typescript-deno|. + + +=============================================================================== +dprint *ale-javascript-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/typescript + + =============================================================================== eslint *ale-javascript-eslint* @@ -138,7 +171,7 @@ g:ale_javascript_flow_use_respect_pragma By default, ALE will use the `--respect-pragma` option for `flow`, so only files with the `@flow` pragma are checked by ALE. This option can be set to - `0` to disable that behaviour, so all files can be checked by `flow`. + `0` to disable that behavior, so all files can be checked by `flow`. =============================================================================== diff --git a/sources_non_forked/ale/doc/ale-jinja.txt b/sources_non_forked/ale/doc/ale-jinja.txt new file mode 100644 index 00000000..37769fe9 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-jinja.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE Jinja Integration *ale-jinja-options* + + + +=============================================================================== +djlint *ale-jinja-djlint* + +See |ale-html-djlint| + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-json.txt b/sources_non_forked/ale/doc/ale-json.txt index 96499a04..b2b5e2a6 100644 --- a/sources_non_forked/ale/doc/ale-json.txt +++ b/sources_non_forked/ale/doc/ale-json.txt @@ -2,6 +2,40 @@ ALE JSON Integration *ale-json-options* +=============================================================================== +biome *ale-json-biome* + +Check the docs over at |ale-typescript-biome|. + + +=============================================================================== +clang-format *ale-json-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for JSON. + + +=============================================================================== +cspell *ale-json-cspell* + +See |ale-cspell-options| + + +=============================================================================== +dprint *ale-json-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/json + + +=============================================================================== +eslint *ale-json-eslint* + +The `eslint` linter for JSON uses the JavaScript options for `eslint`; see: +|ale-javascript-eslint|. + +You will need a JSON ESLint plugin installed for this to work. + + =============================================================================== fixjson *ale-json-fixjson* @@ -49,6 +83,40 @@ g:ale_json_fixjson_use_global *g:ale_json_fixjson_use_global* See |ale-integrations-local-executables| +=============================================================================== +pytool *ale-json-pytool* + +Use python's json.tool module to reformat json. + +g:ale_json_pytool_executable *g:ale_json_pytool_executable* + *b:ale_json_pytool_executable* + + Type: |String| + Default: `'python'` + + The python executable that run to use its json.tool module. This fixer + requires python 3, which includes the json module. + +g:ale_json_pytool_options *g:ale_json_pytool_options* + *b:ale_json_pytool_options* + + Type: |String| + Default: `''` + + These options are passed to the json.tool module. Example: > + let g:ale_json_pytool_options = '--sort-keys --indent 2' +< See docs for all options: + https://docs.python.org/3/library/json.html#module-json.tool + +g:ale_json_pytool_use_global *g:ale_json_pytool_use_global* + *b:ale_json_pytool_use_global* + + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== jsonlint *ale-json-jsonlint* @@ -101,5 +169,49 @@ prettier *ale-json-prettier* See |ale-javascript-prettier| for information about the available options. +=============================================================================== +spectral *ale-json-spectral* + +Website: https://github.com/stoplightio/spectral + +Installation +------------------------------------------------------------------------------- + +Install spectral either globally or locally: > + + npm install @stoplight/spectral -g # global + npm install @stoplight/spectral # local +< + +Options +------------------------------------------------------------------------------- + +g:ale_json_spectral_executable *g:ale_json_spectral_executable* + *b:ale_json_spectral_executable* + Type: |String| + Default: `'spectral'` + + This variable can be set to change the path to spectral. + +g:ale_json_spectral_use_global *g:ale_json_spectral_use_global* + *b:ale_json_spectral_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + +=============================================================================== +vscodejson *ale-json-vscode* + +Website: https://github.com/hrsh7th/vscode-langservers-extracted + +Installation +------------------------------------------------------------------------------- + +Install VSCode json language server either globally or locally: > + + npm install -g vscode-langservers-extracted +< + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-json5.txt b/sources_non_forked/ale/doc/ale-json5.txt new file mode 100644 index 00000000..bafa60d1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-json5.txt @@ -0,0 +1,15 @@ +=============================================================================== +ALE JSON5 Integration *ale-json5-options* + + +=============================================================================== +eslint *ale-json5-eslint* + +The `eslint` linter for JSON uses the JavaScript options for `eslint`; see: +|ale-javascript-eslint|. + +You will need a JSON5 ESLint plugin installed for this to work. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-jsonc.txt b/sources_non_forked/ale/doc/ale-jsonc.txt new file mode 100644 index 00000000..b05fa6e6 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-jsonc.txt @@ -0,0 +1,21 @@ +=============================================================================== +ALE JSONC Integration *ale-jsonc-options* + + +=============================================================================== +biome *ale-jsonc-biome* + +Check the docs over at |ale-typescript-biome|. + + +=============================================================================== +eslint *ale-jsonc-eslint* + +The `eslint` linter for JSON uses the JavaScript options for `eslint`; see: +|ale-javascript-eslint|. + +You will need a JSONC ESLint plugin installed for this to work. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-jsonnet.txt b/sources_non_forked/ale/doc/ale-jsonnet.txt new file mode 100644 index 00000000..f99d415f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-jsonnet.txt @@ -0,0 +1,43 @@ +=============================================================================== +ALE Jsonnet Integration *ale-jsonnet-options* + + +=============================================================================== +jsonnetfmt *ale-jsonnet-jsonnetfmt* + +g:ale_jsonnet_jsonnetfmt_executable *g:ale_jsonnet_jsonnetfmt_executable* + *b:ale_jsonnet_jsonnetfmt_executable* + Type: |String| + Default: `'jsonnetfmt'` + + This option can be changed to change the path for `jsonnetfmt`. + + +g:ale_jsonnet_jsonnetfmt_options *g:ale_jsonnet_jsonnetfmt_options* + *b:ale_jsonnet_jsonnetfmt_options* + Type: |String| + Default: `''` + + This option can be changed to pass extra options to `jsonnetfmt`. + + +=============================================================================== +jsonnet-lint *ale-jsonnet-jsonnet-lint* + +g:ale_jsonnet_jsonnet_lint_executable *g:ale_jsonnet_jsonnet_lint_executable* + *b:ale_jsonnet_jsonnet_lint_executable* + Type: |String| + Default: `'jsonnet-lint'` + + This option can be changed to change the path for `jsonnet-lint`. + + +g:ale_jsonnet_jsonnet_lint_options *g:ale_jsonnet_jsonnet_lint_options* + *b:ale_jsonnet_jsonnet_lint_options* + Type: |String| + Default: `''` + + This option can be changed to pass extra options to `jsonnet-lint`. + + + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-julia.txt b/sources_non_forked/ale/doc/ale-julia.txt index 51532419..ab74ee12 100644 --- a/sources_non_forked/ale/doc/ale-julia.txt +++ b/sources_non_forked/ale/doc/ale-julia.txt @@ -11,7 +11,7 @@ g:ale_julia_executable *g:ale_julia_executable* *b:ale_julia_executable* Type: |String| - Default: 'julia' + Default: `'julia'` Path to the julia exetuable. diff --git a/sources_non_forked/ale/doc/ale-kotlin.txt b/sources_non_forked/ale/doc/ale-kotlin.txt index 4028531f..87cf56c5 100644 --- a/sources_non_forked/ale/doc/ale-kotlin.txt +++ b/sources_non_forked/ale/doc/ale-kotlin.txt @@ -79,7 +79,7 @@ g:ale_kotlin_ktlint_executable *g:ale_kotlin_ktlint_executable* g:ale_kotlin_ktlint_rulesets *g:ale_kotlin_ktlint_rulesets* Type: |List| of |String|s - Default: [] + Default: `[]` This list should contain paths to ruleset jars and/or strings of maven artifact triples. Example: diff --git a/sources_non_forked/ale/doc/ale-latex.txt b/sources_non_forked/ale/doc/ale-latex.txt index bedbabcd..b3029a5b 100644 --- a/sources_non_forked/ale/doc/ale-latex.txt +++ b/sources_non_forked/ale/doc/ale-latex.txt @@ -2,6 +2,9 @@ ALE LaTeX Integration *ale-latex-options* +=============================================================================== +cspell *ale-latex-cspell* + =============================================================================== write-good *ale-latex-write-good* @@ -9,10 +12,10 @@ See |ale-write-good-options| =============================================================================== -textlint *ale-latex-textlint* +textlint *ale-latex-textlint* See |ale-text-textlint| =============================================================================== -vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-llvm.txt b/sources_non_forked/ale/doc/ale-llvm.txt index 2f4a46bd..fff1c305 100644 --- a/sources_non_forked/ale/doc/ale-llvm.txt +++ b/sources_non_forked/ale/doc/ale-llvm.txt @@ -9,7 +9,7 @@ g:ale_llvm_llc_executable *g:ale_llvm_llc_executable* *b:ale_llvm_llc_executable* Type: |String| - Default: "llc" + Default: `"llc"` The command to use for checking. This variable is useful when llc command has suffix like "llc-5.0". diff --git a/sources_non_forked/ale/doc/ale-lua.txt b/sources_non_forked/ale/doc/ale-lua.txt index f1286f89..62d67324 100644 --- a/sources_non_forked/ale/doc/ale-lua.txt +++ b/sources_non_forked/ale/doc/ale-lua.txt @@ -1,6 +1,56 @@ =============================================================================== ALE Lua Integration *ale-lua-options* + +=============================================================================== +cspell *ale-lua-cspell* + +See |ale-cspell-options| + + +=============================================================================== +lua-format *ale-lua-lua-format* + +g:ale_lua_lua_format_executable *g:ale_lua_lua_format_executable* + *b:ale_lua_lua_format_executable* + Type: |String| + Default: `'lua-format'` + + This variable can be changed to change the path to lua-format. + + +g:ale_lua_lua_format_options *g:ale_lua_lua_format_options* + *b:ale_lua_lua_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to lua-format. + + +=============================================================================== +lua-language-server *ale-lua-lua-language-server* + *ale-lua-language-server* + +g:ale_lua_language_server_executable *g:ale_lua_language_server_executable* + *b:ale_lua_language_server_executable* + Type: |String| + Default: `'lua-language-server'` + + This variable can be changed to set the path to lua-language-server. + + If you have compiled the language server yourself in `/some/path`, the path + will be `'/some/path/bin/lua-language-server'`. + + +g:ale_lua_lua_language_server_config *g:ale_lua_lua_language_server_config* + *b:ale_lua_lua_language_server_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. + + =============================================================================== luac *ale-lua-luac* @@ -11,6 +61,7 @@ g:ale_lua_luac_executable *g:ale_lua_luac_executable* This variable can be changed to change the path to luac. + =============================================================================== luacheck *ale-lua-luacheck* @@ -30,5 +81,62 @@ g:ale_lua_luacheck_options *g:ale_lua_luacheck_options* This variable can be set to pass additional options to luacheck. +=============================================================================== +luafmt *ale-lua-luafmt* + +g:ale_lua_luafmt_executable *g:ale_lua_luafmt_executable* + *b:ale_lua_luafmt_executable* + Type: |String| + Default: `'luafmt'` + + This variable can be set to use a different executable for luafmt. + + +g:ale_lua_luafmt_options *g:ale_lua_luafmt_options* + *b:ale_lua_luafmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the luafmt fixer. + + +=============================================================================== +selene *ale-lua-selene* + +g:ale_lua_selene_executable *g:ale_lua_selene_executable* + *b:ale_lua_selene_executable* + Type: |String| + Default: `'selene'` + + This variable can be set to use a different executable for selene. + + +g:ale_lua_selene_options *g:ale_lua_selene_options* + *b:ale_lua_selene_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to selene. + + +=============================================================================== +stylua *ale-lua-stylua* + +g:ale_lua_stylua_executable *g:ale_lua_stylua_executable* + *b:ale_lua_stylua_executable* + Type: |String| + Default: `'stylua'` + + This variable can be set to use a different executable for stylua. + + +g:ale_lua_stylua_options *g:ale_lua_stylua_options* + *b:ale_lua_stylua_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the stylua fixer. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-make.txt b/sources_non_forked/ale/doc/ale-make.txt new file mode 100644 index 00000000..74de798f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-make.txt @@ -0,0 +1,18 @@ +=============================================================================== +ALE Make Integration *ale-make-options* + + +=============================================================================== +checkmake *ale-make-checkmake* + +g:ale_make_checkmake_config *g:ale_make_checkmake_config* + *b:ale_make_checkmake_config* + Type: |String| + Default: `''` + + This variable can be used to set the `--config` option of checkmake command. + if the value is empty, the checkmake command will not be invoked with the + option. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-markdown.txt b/sources_non_forked/ale/doc/ale-markdown.txt index 4e27eb91..0325c911 100644 --- a/sources_non_forked/ale/doc/ale-markdown.txt +++ b/sources_non_forked/ale/doc/ale-markdown.txt @@ -2,6 +2,49 @@ ALE Markdown Integration *ale-markdown-options* +=============================================================================== +cspell *ale-markdown-cspell* + +See |ale-cspell-options| + + +=============================================================================== +dprint *ale-markdown-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/markdown + + +=============================================================================== +markdownlint *ale-markdown-markdownlint* + +g:ale_markdown_markdownlint_executable *g:ale_markdown_markdownlint_executable* + *b:ale_markdown_markdownlint_executable* + Type: |String| + Default: `'markdownlint'` + + Override the invoked `markdownlint` binary. You can use other binaries such as + `markdownlint-cli2`. + + +g:ale_markdown_markdownlint_options *g:ale_markdown_markdownlint_options* + *b:ale_markdown_markdownlint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to markdownlint. + + +=============================================================================== +marksman *ale-markdown-marksman* + +g:ale_markdown_marksman_executable *g:ale_markdown_marksman_executable* + *b:ale_markdown_marksman_executable* + Type: |String| + Default: `'marksman'` + + Override the invoked `marksman` binary. + + =============================================================================== mdl *ale-markdown-mdl* @@ -22,12 +65,88 @@ g:ale_markdown_mdl_options *g:ale_markdown_mdl_options* This variable can be set to pass additional options to mdl. +=============================================================================== +pandoc *ale-markdown-pandoc* + +g:ale_markdown_pandoc_executable *g:ale_markdown_pandoc_executable* + *b:ale_markdown_pandoc_executable* + Type: |String| + Default: `'pandoc'` + + This variable can be set to specify where to find the pandoc executable + + +g:ale_markdown_pandoc_options *g:ale_markdown_pandoc_options* + *b:ale_markdown_pandoc_options* + Type: |String| + Default: `'-f gfm -t gfm -s -'` + + This variable can be set to change the default options passed to pandoc + =============================================================================== prettier *ale-markdown-prettier* See |ale-javascript-prettier| for information about the available options. +=============================================================================== +pymarkdown *ale-markdown-pymarkdown* + +g:ale_markdown_pymarkdown_executable *g:ale_markdown_pymarkdown_executable* + *b:ale_markdown_pymarkdown_executable* + Type: |String| + Default: `'pymarkdown'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pymarkdown'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pymarkdown'`. + + +g:ale_markdown_pymarkdown_options *g:ale_markdown_pymarkdown_options* + *b:ale_markdown_pymarkdown_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the + pymarkdown invocation. + + +g:ale_markdown_pymarkdown_use_global *g:ale_markdown_pymarkdown_use_global* + *b:ale_markdown_pymarkdown_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_markdown_pymarkdown_auto_pipenv *g:ale_markdown_pymarkdown_auto_pipenv* + *b:ale_markdown_pymarkdown_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_markdown_pymarkdown_auto_poetry *g:ale_markdown_pymarkdown_auto_poetry* + *b:ale_markdown_pymarkdown_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_markdown_pymarkdown_auto_uv *g:ale_markdown_pymarkdown_auto_uv* + *b:ale_markdown_pymarkdown_auto_uv* + Type: |Number| + Default: `0` + + Set the executable to `uv` if true. This is overridden by a manually-set + executable. + + =============================================================================== remark-lint *ale-markdown-remark-lint* @@ -68,4 +187,4 @@ See |ale-write-good-options| =============================================================================== -vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nickel.txt b/sources_non_forked/ale/doc/ale-nickel.txt new file mode 100644 index 00000000..a8dd6af8 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nickel.txt @@ -0,0 +1,25 @@ +=============================================================================== +ALE Nickel Integration *ale-nickel-options* + + +=============================================================================== +nickel_format *ale-nickel-nickel-format* + +g:ale_nickel_nickel_format_executable *g:ale_nickel_nickel_format_executable* + *b:ale_nickel_nickel_format_executable* + Type: |String| + Default: `'nickel'` + + This option can be changed to change the path for `nickel`. + + +g:ale_nickel_nickel_format_options *g:ale_nickel_nickel_format_options* + *b:ale_nickel_nickel_format_options* + Type: |String| + Default: `''` + + This option can be changed to pass extra options to `'nickel format'` + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nim.txt b/sources_non_forked/ale/doc/ale-nim.txt new file mode 100644 index 00000000..8985aeb8 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nim.txt @@ -0,0 +1,45 @@ +=============================================================================== +ALE Nim Integration *ale-nim-options* + + +=============================================================================== +nimcheck *ale-nim-nimcheck* + + ALE does not provide additional configuration options for `nimcheck` at this + point. + + +=============================================================================== +nimlsp *ale-nim-nimlsp* + +g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources* + + Type: |String| + Default: `''` + + Sets the path to Nim source repository as the first argument to `nimlsp` + command. + + +=============================================================================== +nimpretty *ale-nim-nimpretty* + + +g:ale_nim_nimpretty_executable *g:ale_nim_nimpretty_executable* + *b:ale_nim_nimpretty_executable* + Type: |String| + Default: `'nimpretty'` + + This variable can be changed to use a different executable for nimpretty. + + +g:ale_nim_nimpretty_options *g:ale_nim_nimpretty_options* + *b:ale_nim_nimpretty_options* + Type: |String| + Default: `'--maxLineLen:80'` + + This variable can be changed to modify flags given to nimpretty. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nix.txt b/sources_non_forked/ale/doc/ale-nix.txt new file mode 100644 index 00000000..5f4199ed --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nix.txt @@ -0,0 +1,115 @@ +=============================================================================== +ALE Nix Integration *ale-nix-options* + + +=============================================================================== +alejandra *ale-nix-alejandra* + +g:ale_nix_alejandra_executable *g:ale_nix_alejandra_executable* + *b:ale_nix_alejandra_executable* + Type: |String| + Default: `'alejandra'` + + This variable sets the executable used for alejandra. + +g:ale_nix_alejandra_options *g:ale_nix_alejandra_options* + *b:ale_nix_alejandra_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the alejandra fixer. + + +=============================================================================== +nixfmt *ale-nix-nixfmt* + +g:ale_nix_nixfmt_executable *g:ale_nix_nixfmt_executable* + *b:ale_nix_nixfmt_executable* + Type: |String| + Default: `'nixfmt'` + + This variable sets the executable used for nixfmt. + +g:ale_nix_nixfmt_options *g:ale_nix_nixfmt_options* + *b:ale_nix_nixfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the nixfmt fixer. + + +=============================================================================== +nixpkgs-fmt *ale-nix-nixpkgs-fmt* + +g:ale_nix_nixpkgsfmt_executable *g:ale_nix_nixpkgsfmt_executable* + *b:ale_nix_nixpkgsfmt_executable* + Type: |String| + Default: `'nixpkgs-fmt'` + + This variable sets executable used for nixpkgs-fmt. + +g:ale_nix_nixpkgsfmt_options *g:ale_nix_nixpkgsfmt_options* + *b:ale_nix_nixpkgsfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the nixpkgs-fmt + fixer. + + +=============================================================================== +statix *ale-nix-statix* + +g:ale_nix_statix_check_executable *g:ale_nix_statix_check_executable* + *b:ale_nix_statix_check_executable* + Type: |String| + Default: `'statix'` + + This variable sets the executable used for statix when running it as a + linter. + +g:ale_nix_statix_check_options *g:ale_nix_statix_check_options* + *b:ale_nix_statix_check_options* + Type: |String| + Default: `''` + + This variable can be used to pass additional options to statix when running + it as a linter. + +g:ale_nix_statix_fix_executable *g:ale_nix_fix_check_executable* + *b:ale_nix_fix_check_executable* + Type: |String| + Default: `'statix'` + + This variable sets the executable used for statix when running it as a + fixer. + +g:ale_nix_statix_fix_options *g:ale_nix_statix_fix_options* + *b:ale_nix_statix_fix_options* + Type: |String| + Default: `''` + + This variable can be used to pass additional options to statix when running + it as a fixer. + + +=============================================================================== +deadnix *ale-nix-deadnix* + +g:ale_nix_deadnix_executable *g:ale_nix_deadnix_executable* + *b:ale_nix_deadnix_executable* + Type: |String| + Default: `'deadnix'` + + This variable sets the executable used for deadnix. + +g:ale_nix_deadnix_options *g:ale_nix_deadnix_options* + *b:ale_nix_deadnix_options* + Type: |String| + Default: `''` + + This variable can be used to pass additional options to deadnix. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nunjucks.txt b/sources_non_forked/ale/doc/ale-nunjucks.txt new file mode 100644 index 00000000..d0e1db26 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nunjucks.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE Nunjucks Integration *ale-nunjucks-options* + + + +=============================================================================== +djlint *ale-nunjucks-djlint* + +See |ale-html-djlint| + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-objc.txt b/sources_non_forked/ale/doc/ale-objc.txt index 0163175a..e1a0c2a2 100644 --- a/sources_non_forked/ale/doc/ale-objc.txt +++ b/sources_non_forked/ale/doc/ale-objc.txt @@ -2,42 +2,6 @@ ALE Objective-C Integration *ale-objc-options* -=============================================================================== -clang *ale-objc-clang* - -g:ale_objc_clang_options *g:ale_objc_clang_options* - *b:ale_objc_clang_options* - Type: |String| - Default: `'-std=c11 -Wall'` - - This variable can be changed to modify flags given to clang. - - -=============================================================================== -clangd *ale-objc-clangd* - -g:ale_objc_clangd_executable *g:ale_objc_clangd_executable* - *b:ale_objc_clangd_executable* - Type: |String| - Default: `'clangd'` - - This variable can be changed to use a different executable for clangd. - - -g:ale_objc_clangd_options *g:ale_objc_clangd_options* - *b:ale_objc_clangd_options* - Type: |String| - Default: `''` - - This variable can be changed to modify flags given to clangd. - - -=============================================================================== -uncrustify *ale-objc-uncrustify* - -See |ale-c-uncrustify| for information about the available options. - - =============================================================================== ccls *ale-objc-ccls* @@ -69,5 +33,48 @@ g:ale_objc_ccls_init_options *g:ale_objc_ccls_init_options* available options and explanations. +=============================================================================== +clang *ale-objc-clang* + +g:ale_objc_clang_options *g:ale_objc_clang_options* + *b:ale_objc_clang_options* + Type: |String| + Default: `'-std=c11 -Wall'` + + This variable can be changed to modify flags given to clang. + + +=============================================================================== +clang-format *ale-objc-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for Objective-C. + + +=============================================================================== +clangd *ale-objc-clangd* + +g:ale_objc_clangd_executable *g:ale_objc_clangd_executable* + *b:ale_objc_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_objc_clangd_options *g:ale_objc_clangd_options* + *b:ale_objc_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + +=============================================================================== +uncrustify *ale-objc-uncrustify* + +See |ale-c-uncrustify| 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-ocaml.txt b/sources_non_forked/ale/doc/ale-ocaml.txt index 8b644c17..a361a7b4 100644 --- a/sources_non_forked/ale/doc/ale-ocaml.txt +++ b/sources_non_forked/ale/doc/ale-ocaml.txt @@ -2,6 +2,26 @@ ALE OCaml Integration *ale-ocaml-options* +=============================================================================== +dune *ale-ocaml-dune* + + Dune is a build system for OCaml projects. The `dune format` command is + supported for automatically formatting `dune` and `dune-project` files. + +g:ale_ocaml_dune_executable *g:ale_ocaml_dune_executable* + *b:ale_ocaml_dune_executable* + Type: |String| + Default: `'dune'` + + This variable can be set to pass the path to dune. + +g:ale_ocaml_dune_options *g:ale_ocaml_dune_options* + *b:ale_ocaml_dune_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the dune fixer. + =============================================================================== merlin *ale-ocaml-merlin* @@ -10,6 +30,21 @@ merlin *ale-ocaml-merlin* detailed instructions (https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch). +=============================================================================== +ocamllsp *ale-ocaml-ocamllsp* + + The `ocaml-lsp-server` is the official OCaml implementation of the Language + Server Protocol. See the installation instructions: + https://github.com/ocaml/ocaml-lsp#installation + +g:ale_ocaml_ocamllsp_use_opam *g:ale_ocaml_ocamllsp_use_opam* + *b:ale_ocaml_ocamllsp_use_opam* + Type: |Number| + Default: `get(g:, 'ale_ocaml_ocamllsp_use_opam', 1)` + + This variable can be set to change whether or not opam is used to execute + the language server. + =============================================================================== ols *ale-ocaml-ols* 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-openapi.txt b/sources_non_forked/ale/doc/ale-openapi.txt new file mode 100644 index 00000000..1fc41add --- /dev/null +++ b/sources_non_forked/ale/doc/ale-openapi.txt @@ -0,0 +1,74 @@ +=============================================================================== +ALE OpenApi Integration *ale-openapi-options* + +=============================================================================== +ibm_validator *ale-openapi-ibm-validator* + +Website: https://github.com/IBM/openapi-validator + + +Installation +------------------------------------------------------------------------------- + +Install ibm-openapi-validator either globally or locally: > + + npm install ibm-openapi-validator -g # global + npm install ibm-openapi-validator # local +< +Configuration +------------------------------------------------------------------------------- + +OpenAPI files can be written in YAML or JSON so in order for ALE plugins to +work with these files we must set the buffer |filetype| to either |openapi.yaml| +or |openapi.json| respectively. This causes ALE to lint the file with linters +configured for openapi and yaml files or openapi and json files respectively. + +For example setting filetype to |openapi.yaml| on a buffer and the following +|g:ale_linters| configuration will enable linting of openapi files using both +|ibm_validator| and |yamlint|: + +> + let g:ale_linters = { + \ 'yaml': ['yamllint'], + \ 'openapi': ['ibm_validator'] + \} +< + +The following plugin will detect openapi files automatically and set the +filetype to |openapi.yaml| or |openapi.json|: + + https://github.com/hsanson/vim-openapi + +Options +------------------------------------------------------------------------------- + +g:ale_openapi_ibm_validator_executable *g:ale_openapi_ibm_validator_executable* + *b:ale_openapi_ibm_validator_executable* + Type: |String| + Default: `'lint-openapi'` + + This variable can be set to change the path to lint-openapi. + + +g:ale_openapi_ibm_validator_options *g:ale_openapi_ibm_validator_options* + *b:ale_openapi_ibm_validator_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to lint-openapi. + + +=============================================================================== +prettier *ale-openapi-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +yamllint *ale-openapi-yamllint* + +See |ale-yaml-yamllint| 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-openscad.txt b/sources_non_forked/ale/doc/ale-openscad.txt new file mode 100644 index 00000000..7e580bd4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-openscad.txt @@ -0,0 +1,43 @@ +=============================================================================== +ALE OpenSCAD Integration *ale-openscad-options* + + +=============================================================================== +sca2d *ale-openscad-sca2d* + +g:ale_openscad_sca2d_executable *g:ale_openscad_sca2d_executable* + *b:ale_openscad_sca2d_executable* + Type: |String| + Default: `'sca2d'` + + See |ale-integrations-local-executables| + + +g:ale_openscad_sca2d_options *g:ale_openscad_sca2d_options* + *b:ale_openscad_sca2d_options* + Type: |String| + Default: `''` + + This variable can be set to pass options to sca2d. + + +=============================================================================== +scadformat *ale-openscad-scadformat* + +g:ale_openscad_scadformat_executable *g:ale_openscad_scadformat_executable* + *b:ale_openscad_scadformat_executable* + Type: |String| + Default: `'scadformat'` + + See |ale-integrations-local-executables| + + +g:ale_openscad_scadformat_options *g:ale_openscad_scadformat_options* + *b:ale_openscad_scadformat_options* + Type: |String| + Default: `''` + + This variable can be set to pass options to scadformat. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-packer.txt b/sources_non_forked/ale/doc/ale-packer.txt new file mode 100644 index 00000000..11b7cc22 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-packer.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Packer Integration *ale-packer-options* + + +=============================================================================== +packer-fmt-fixer *ale-packer-fmt-fixer* + +g:ale_packer_fmt_executable *g:ale_packer_fmt_executable* + *b:ale_packer_fmt_executable* + + Type: |String| + Default: `'packer'` + + This variable can be changed to use a different executable for packer. + + +g:ale_packer_fmt_options *g:ale_packer_fmt_options* + *b:ale_packer_fmt_options* + Type: |String| + Default: `''` + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pascal.txt b/sources_non_forked/ale/doc/ale-pascal.txt new file mode 100644 index 00000000..03d9a004 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-pascal.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Pascal Integration *ale-pascal-options* + +=============================================================================== +ptop *ale-pascal-ptop* + +g:ale_pascal_ptop_executable *g:ale_pascal_ptop_executable* + *b:ale_pascal_ptop_executable* + Type: |String| + Default: `'ptop'` + + This variable can be changed to specify the ptop executable. + + +g:ale_pascal_ptop_options *g:ale_pascal_ptop_options* + *b:ale_pascal_ptop_options* + Type: |String| + Default: `''` + +This variable can be set to pass additional options to the ptop fixer. + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-perl.txt b/sources_non_forked/ale/doc/ale-perl.txt index 761c2735..5eebc0e3 100644 --- a/sources_non_forked/ale/doc/ale-perl.txt +++ b/sources_non_forked/ale/doc/ale-perl.txt @@ -72,7 +72,7 @@ g:ale_perl_perlcritic_options *g:ale_perl_perlcritic_options* g:ale_perl_perlcritic_showrules *g:ale_perl_perlcritic_showrules* Type: |Number| - Default: 0 + Default: `0` Controls whether perlcritic rule names are shown after the error message. Defaults to off to reduce length of message. diff --git a/sources_non_forked/ale/doc/ale-php.txt b/sources_non_forked/ale/doc/ale-php.txt index d41fb50d..2750a319 100644 --- a/sources_non_forked/ale/doc/ale-php.txt +++ b/sources_non_forked/ale/doc/ale-php.txt @@ -1,6 +1,13 @@ =============================================================================== ALE PHP Integration *ale-php-options* + +=============================================================================== +cspell *ale-php-cspell* + +See |ale-cspell-options| + + =============================================================================== langserver *ale-php-langserver* @@ -41,6 +48,7 @@ g:ale_php_phan_minimum_severity *g:ale_php_phan_minimum_severity* This variable defines the minimum severity level. + g:ale_php_phan_executable *g:ale_php_phan_executable* *b:ale_php_phan_executable* Type: |String| @@ -48,6 +56,7 @@ g:ale_php_phan_executable *g:ale_php_phan_executable* This variable sets executable used for phan or phan_client. + g:ale_php_phan_use_client *g:ale_php_phan_use_client* *b:ale_php_phan_use_client* Type: |Number| @@ -56,6 +65,7 @@ g:ale_php_phan_use_client *g:ale_php_phan_use_client* This variable can be set to 1 to use the phan_client with phan daemon mode instead of the phan standalone. + =============================================================================== phpcbf *ale-php-phpcbf* @@ -85,6 +95,14 @@ g:ale_php_phpcbf_use_global *g:ale_php_phpcbf_use_global* See |ale-integrations-local-executables| +g:ale_php_phpcbf_options *g:ale_php_phpcbf_options* + *b:ale_php_phpcbf_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to php-cbf + + =============================================================================== phpcs *ale-php-phpcs* @@ -121,6 +139,7 @@ g:ale_php_phpcs_options *g:ale_php_phpcs_options* This variable can be set to pass additional options to php-cs + =============================================================================== phpmd *ale-php-phpmd* @@ -157,9 +176,9 @@ g:ale_php_phpstan_level *g:ale_php_phpstan_level* Type: |String| Default: `''` - This variable controls the rule levels. 0 is the loosest and 4 is the + This variable controls the rule levels. 0 is the loosest and 7 is the strictest. If this option isn't set, the rule level will be controlled by - the configuration file. If no configuration file can be detected, `'4'` will + the configuration file. If no configuration file can be detected, `'7'` will be used instead. @@ -179,6 +198,15 @@ g:ale_php_phpstan_autoload *g:ale_php_phpstan_autoload* This variable sets path to phpstan autoload file. +g:ale_php_phpstan_memory_limit *g:ale_php_phpstan_memory-limit* + *b:ale_php_phpstan_memory-limit* + Type: |String| + Default: `''` + + This variable sets the memory limit for phpstan analysis. This is a string + in the same format as `php.ini` accepts, e.g. `128M`, `1G`. + + =============================================================================== psalm *ale-php-psalm* @@ -189,39 +217,151 @@ g:ale_php_psalm_executable *g:ale_php_psalm_executable* This variable sets the executable used for psalm. -=============================================================================== -php-cs-fixer *ale-php-php-cs-fixer* -g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable* - *b:ale_php_cs_fixer_executable* +g:ale_php_psalm_options *g:ale_php_psalm_options* + *b:ale_php_psalm_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to psalm. + + +g:ale_php_psalm_use_global *g:ale_php_psalm_use_global* + *b:ale_php_psalm_use_global* + Type: |Boolean| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +php-cs-fixer *ale-php-php-cs-fixer* + +g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable* + *b:ale_php_cs_fixer_executable* Type: |String| Default: `'php-cs-fixer'` This variable sets executable used for php-cs-fixer. -g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global* - *b:ale_php_cs_fixer_use_global* - Type: |Boolean| - Default: `get(g:, 'ale_use_global_executables', 0)` - This variable force globally installed fixer. - -g:ale_php_cs_fixer_options *g:ale_php_cs_fixer_options* - *b:ale_php_cs_fixer_options* +g:ale_php_cs_fixer_options *g:ale_php_cs_fixer_options* + *b:ale_php_cs_fixer_options* Type: |String| Default: `''` This variable can be set to pass additional options to php-cs-fixer. -=============================================================================== -php *ale-php-php* -g:ale_php_php_executable *g:ale_php_php_executable* - *b:ale_php_php_executable* +g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global* + *b:ale_php_cs_fixer_use_global* + Type: |Boolean| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +php *ale-php-php* + +g:ale_php_php_executable *g:ale_php_php_executable* + *b:ale_php_php_executable* Type: |String| Default: `'php'` This variable sets the executable used for php. + +=============================================================================== +pint *ale-php-pint* + +g:ale_php_pint_executable *g:ale_php_pint_executable* + *b:ale_php_pint_executable* + Type: |String| + Default: `'pint'` + + This variable sets the executable used for pint. + + +g:ale_php_pint_options *g:ale_php_pint_options* + *b:ale_php_pint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to pint. + + +g:ale_php_pint_use_global *g:ale_php_pint_use_global* + *b:ale_php_pint_use_global* + Type: |Boolean| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +tlint *ale-php-tlint* + +g:ale_php_tlint_executable *g:ale_php_tlint_executable* + *b:ale_php_tlint_executable* + Type: |String| + Default: `'tlint'` + + See |ale-integrations-local-executables| + + +g:ale_php_tlint_use_global *g:ale_php_tlint_use_global* + *b:ale_php_tlint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_php_tlint_options *g:ale_php_tlint_options* + *b:ale_php_tlint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to tlint + + +=============================================================================== +intelephense *ale-php-intelephense* + +g:ale_php_intelephense_executable *g:ale_php_intelephense_executable* + *b:ale_php_intelephense_executable* + Type: |String| + Default: `'intelephense'` + + The variable can be set to configure the executable that will be used for + running the intelephense language server. `node_modules` directory + executable will be preferred instead of this setting if + |g:ale_php_intelephense_use_global| is `0`. + + See: |ale-integrations-local-executables| + + +g:ale_php_intelephense_use_global *g:ale_php_intelephense_use_global* + *b:ale_php_intelephense_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable can be set to `1` to force the language server to be run with + the executable set for |g:ale_php_intelephense_executable|. + + See: |ale-integrations-local-executables| + + +g:ale_php_intelephense_config *g:ale_php_intelephense_config* + *b:ale_php_intelephense_config* + Type: |Dictionary| + Default: `{}` + + The initialization options config specified by Intelephense. Refer to the + installation docs provided by intelephense (github.com/bmewburn/intelephense + -docs). + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-powershell.txt b/sources_non_forked/ale/doc/ale-powershell.txt index c28ef9ea..44a3c618 100644 --- a/sources_non_forked/ale/doc/ale-powershell.txt +++ b/sources_non_forked/ale/doc/ale-powershell.txt @@ -2,12 +2,18 @@ ALE PowerShell Integration *ale-powershell-options* +=============================================================================== +cspell *ale-powershell-cspell* + +See |ale-cspell-options| + + =============================================================================== powershell *ale-powershell-powershell* -g:ale_powershell_powershell_executable *g:ale_powershell_powershell_executable* - *b:ale_powershell_powershell_executable* - Type: String +g:ale_powershell_powershell_executable *g:ale_powershell_powershell_executable* + *b:ale_powershell_powershell_executable* + Type: |String| Default: `'pwsh'` This variable can be changed to use a different executable for powershell. @@ -25,13 +31,6 @@ Installation Install PSScriptAnalyzer by any means, so long as it can be automatically imported in PowerShell. -Some PowerShell plugins set the filetype of files to `ps1`. To continue using -these plugins, use the ale_linter_aliases global to alias `ps1` to `powershell` - -> - " Allow ps1 filetype to work with powershell linters - let g:ale_linter_aliases = {'ps1': 'powershell'} -< g:ale_powershell_psscriptanalyzer_executable *g:ale_powershell_psscriptanalyzer_executable* @@ -40,7 +39,7 @@ g:ale_powershell_psscriptanalyzer_executable Default: `'pwsh'` This variable sets executable used for powershell. - + For example, on Windows you could set powershell to be Windows Powershell: > let g:ale_powershell_psscriptanalyzer_executable = 'powershell.exe' @@ -56,7 +55,7 @@ g:ale_powershell_psscriptanalyzer_module for psscriptanalyzer invocation. -g:ale_powershell_psscriptanalyzer_exclusions +g:ale_powershell_psscriptanalyzer_exclusions *g:ale_powershell_psscriptanalyzer_exclusions* *b:ale_powershell_psscriptanalyzer_exclusions* Type: |String| @@ -72,6 +71,5 @@ g:ale_powershell_psscriptanalyzer_exclusions \ 'PSAvoidUsingWriteHost,PSAvoidGlobalVars' < - =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-proto.txt b/sources_non_forked/ale/doc/ale-proto.txt index 734e23d5..e7015dcc 100644 --- a/sources_non_forked/ale/doc/ale-proto.txt +++ b/sources_non_forked/ale/doc/ale-proto.txt @@ -5,15 +5,66 @@ ALE Proto Integration *ale-proto-options =============================================================================== Integration Information -Linting of `.proto` files requires that the `protoc` binary is installed in the -system path and that the `protoc-gen-lint` plugin for the `protoc` binary is also -installed. - To enable `.proto` file linting, update |g:ale_linters| as appropriate: > " Enable linter for .proto files - let g:ale_linters = {'proto': ['protoc-gen-lint']} + let g:ale_linters = {'proto': ['buf-lint', 'protoc-gen-lint', 'protolint']} < + +To enable `.proto` file fixing, update |g:ale_fixers| as appropriate: +> + " Enable linter for .proto files + let b:ale_fixers = {'proto': ['buf-format', 'protolint']} +< + + +=============================================================================== +buf-format *ale-proto-buf-format* + + The formatter uses `buf`, a fully-featured Protobuf compiler that doesn't depend + on `protoc`. Make sure the `buf` binary is available in the system path, or + set ale_proto_buf_format_executable. + +g:ale_proto_buf_format_executable *g:ale_proto_buf_format_executable* + + Type: |String| + Default: `'buf'` + + This variable can be changed to modify the executable used for buf. + + +=============================================================================== +buf-lint *ale-proto-buf-lint* + + The linter uses `buf`, a fully-featured Protobuf compiler that doesn't depend + on `protoc`. Make sure the `buf` binary is available in the system path, or + set ale_proto_buf_lint_executable. + +g:ale_proto_buf_lint_executable *g:ale_proto_buf_lint_executable* + + Type: |String| + Default: `'buf'` + + This variable can be changed to modify the executable used for buf. + +g:ale_proto_buf_lint_config *g:ale_proto_buf_lint_config* + + Type: |String| + Default: `''` + + A path to a buf configuration file. + + The path to the configuration file can be an absolute path or a relative + path. ALE will search for the relative path in parent directories. + + +=============================================================================== +clang-format *ale-proto-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for Proto. + + =============================================================================== protoc-gen-lint *ale-proto-protoc-gen-lint* @@ -29,5 +80,33 @@ g:ale_proto_protoc_gen_lint_options *g:ale_proto_protoc_gen_lint_options* directory of the linted file is always passed as an include path with '-I' before any user-supplied options. + +=============================================================================== +protolint *ale-proto-protolint* + + The linter is a pluggable tool that doesn't depend on the `protoc` binary. + This supports both linting and fixing. + Make sure the binary is available in the system path, or set + ale_proto_protolint_executable. + Note that the binary with v0.22.0 or above is supported. + +g:ale_proto_protolint_executable *g:ale_proto_protolint_executable* + + Type: |String| + Default: `'protolint'` + + This variable can be changed to modify the executable used for protolint. + +g:ale_proto_protolint_config *g:ale_proto_protolint_config* + + Type: |String| + Default: `''` + + A path to a protolint configuration file. + + The path to the configuration file can be an absolute path or a relative + path. ALE will search for the relative path in parent directories. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-purescript.txt b/sources_non_forked/ale/doc/ale-purescript.txt index 33fd2429..25b3dd8d 100644 --- a/sources_non_forked/ale/doc/ale-purescript.txt +++ b/sources_non_forked/ale/doc/ale-purescript.txt @@ -26,8 +26,44 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config \ 'purescript': { \ 'addSpagoSources': v:true, \ 'addNpmPath': v:true, - \ 'buildCommand': 'spago build -- --json-errors' + \ 'buildCommand': 'spago --quiet build --purs-args --json-errors' \ } \} +=============================================================================== +purs-tidy *ale-purescript-tidy* + +g:ale_purescript_tidy_executable *g:ale_purescript_tidy_executable* + *b:ale_purescript_tidy_executable* + Type: |String| + Default: `'purs-tidy'` + + This variable can be changed to use a different executable for purs-tidy. + +g:ale_purescript_tidy_use_global *g:ale_purescript_tidy_use_global* + *b:ale_purescript_tidy_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + +g:ale_purescript_tidy_options *g:ale_purescript_tidy_options* + *b:ale_purescript_tidy_options* + Type: |String| + Default: `''` + + This variable can be set to pass in additional option to the 'purs-tidy' + executable. +> + let g:ale_purescript_options = '--indent 3' +< +=============================================================================== +purty *ale-purescript-purty* + +g:ale_purescript_purty_executable *g:ale_purescript_purty_executable* + *b:ale_purescript_purty_executable* + Type: |String| + Default: `'purty'` + + This variable can be changed to use a different executable for purty. =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt index 9d5846d2..4798baaf 100644 --- a/sources_non_forked/ale/doc/ale-python.txt +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -10,6 +10,36 @@ g:ale_python_auto_pipenv *g:ale_python_auto_pipenv* 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_auto_poetry *g:ale_python_auto_poetry* + *b:ale_python_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_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| + Default: `0` + + If set to `1`, ALE will automatically set environment variables for commands + such as `PATH` to attempt to make the experience of running Python linters + via virtualenv easier, without the need for another plugin or some + specialised setup. + + =============================================================================== ALE Python Project Root Behavior *ale-python-root* @@ -27,20 +57,135 @@ ALE will look for configuration files with the following filenames. > setup.cfg pytest.ini tox.ini + .pyre_configuration.local mypy.ini + .mypy.ini pycodestyle.cfg .flake8 .flake8rc pylama.ini pylintrc .pylintrc + pyrightconfig.json + pyrightconfig.toml Pipfile Pipfile.lock + poetry.lock + pyproject.toml + .tool-versions < The first directory containing any of the files named above will be used. +=============================================================================== +autoflake *ale-python-autoflake* + +g:ale_python_autoflake_executable *g:ale_python_autoflake_executable* + *b:ale_python_autoflake_executable* + Type: |String| + Default: `'autoflake'` + + See |ale-integrations-local-executables| + + +g:ale_python_autoflake_options *g:ale_python_autoflake_options* + *b:ale_python_autoflake_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to autoflake. + + +g:ale_python_autoflake_use_global *g:ale_python_autoflake_use_global* + *b:ale_python_autoflake_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + 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* + +g:ale_python_autoimport_executable *g:ale_python_autoimport_executable* + *b:ale_python_autoimport_executable* + Type: |String| + Default: `'autoimport'` + + See |ale-integrations-local-executables| + + +g:ale_python_autoimport_options *g:ale_python_autoimport_options* + *b:ale_python_autoimport_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to autoimport. + + +g:ale_python_autoimport_use_global *g:ale_python_autoimport_use_global* + *b:ale_python_autoimport_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + 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* @@ -68,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* @@ -79,6 +251,7 @@ g:ale_python_bandit_executable *g:ale_python_bandit_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `bandit'`. + Set this to `'poetry'` to invoke `'poetry` `run` `bandit'`. g:ale_python_bandit_options *g:ale_python_bandit_options* @@ -118,6 +291,24 @@ g:ale_python_bandit_auto_pipenv *g:ale_python_bandit_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_bandit_auto_poetry *g:ale_python_bandit_auto_poetry* + *b:ale_python_bandit_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_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* @@ -145,14 +336,33 @@ g:ale_python_black_use_global *g:ale_python_black_use_global* See |ale-integrations-local-executables| -g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv* - *b:ale_python_black_auto_pipenv* +g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv* + *b:ale_python_black_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_black_auto_poetry *g:ale_python_black_auto_poetry* + *b:ale_python_black_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_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| @@ -164,18 +374,25 @@ g:ale_python_black_change_directory *g:ale_python_black_change_directory* to control the directory Python is executed from yourself. +=============================================================================== +cspell *ale-python-cspell* + +See |ale-cspell-options| + + =============================================================================== flake8 *ale-python-flake8* g:ale_python_flake8_change_directory *g:ale_python_flake8_change_directory* *b:ale_python_flake8_change_directory* - Type: |Number| - Default: `1` + Type: |String| + Default: `'project'` - If set to `1`, ALE will switch to the directory the Python file being - checked with `flake8` is in before checking it. This helps `flake8` find - configuration files more easily. This option can be turned off if you want - to control the directory Python is executed from yourself. + If set to `project`, ALE will switch to the project root before checking file. + If set to `file`, ALE will first switch to the directory containing the + Python file being checked with `flake8` before checking it. + You can turn it off with `off` option if you want to control the directory + Python is executed from yourself. g:ale_python_flake8_executable *g:ale_python_flake8_executable* @@ -184,7 +401,8 @@ g:ale_python_flake8_executable *g:ale_python_flake8_executable* Default: `'flake8'` This variable can be changed to modify the executable used for flake8. Set - this to `'pipenv'` to invoke `'pipenv` `run` `flake8'`. + this to `'pipenv'` to invoke `'pipenv` `run` `flake8'`. Set this to + `'poetry'` to invoke `'poetry` `run` `flake8'`. g:ale_python_flake8_options *g:ale_python_flake8_options* @@ -226,6 +444,98 @@ g:ale_python_flake8_auto_pipenv *g:ale_python_flake8_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_flake8_auto_poetry *g:ale_python_flake8_auto_poetry* + *b:ale_python_flake8_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_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* + +g:ale_python_flakehell_change_directory*g:ale_python_flakehell_change_directory* + *b:ale_python_flakehell_change_directory* + Type: |String| + Default: `project` + + If set to `project`, ALE will switch to the project root before checking file. + If set to `file`, ALE will switch to directory the Python file being + checked with `flakehell` is in before checking it. + You can turn it off with `off` option if you want to control the directory + Python is executed from yourself. + + +g:ale_python_flakehell_executable *g:ale_python_flakehell_executable* + *b:ale_python_flakehell_executable* + Type: |String| + Default: `'flakehell'` + + This variable can be changed to modify the executable used for flakehell. Set + this to `'pipenv'` to invoke `'pipenv` `run` `flakehell'`. Set this to + `'poetry'` to invoke `'poetry` `run` `flakehell'`. Set this to `'python'` to + invoke `'python` `-m` `flakehell'`. + + +g:ale_python_flakehell_options *g:ale_python_flakehell_options* + *b:ale_python_flakehell_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the flakehell + lint invocation. + + +g:ale_python_flakehell_use_global *g:ale_python_flakehell_use_global* + *b:ale_python_flakehell_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable controls whether or not ALE will search for flakehell in a + virtualenv directory first. If this variable is set to `1`, then ALE will + always use |g:ale_python_flakehell_executable| for the executable path. + + Both variables can be set with `b:` buffer variables instead. + + +g:ale_python_flakehell_auto_pipenv *g:ale_python_flakehell_auto_pipenv* + *b:ale_python_flakehell_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_flakehell_auto_poetry *g:ale_python_flakehell_auto_poetry* + *b:ale_python_flakehell_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_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* @@ -253,6 +563,33 @@ g:ale_python_isort_use_global *g:ale_python_isort_use_global* See |ale-integrations-local-executables| +g:ale_python_isort_auto_pipenv *g:ale_python_isort_auto_pipenv* + *b:ale_python_isort_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_isort_auto_poetry *g:ale_python_isort_auto_poetry* + *b:ale_python_isort_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_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* @@ -263,6 +600,33 @@ to check for errors while you type. `mypy` will be run from a detected project root, per |ale-python-root|. +g:ale_python_mypy_auto_pipenv *g:ale_python_mypy_auto_pipenv* + *b:ale_python_mypy_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_mypy_auto_poetry *g:ale_python_mypy_auto_poetry* + *b:ale_python_mypy_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_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| @@ -271,6 +635,8 @@ g:ale_python_mypy_executable *g:ale_python_mypy_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `mypy'`. + Set this to `'poetry'` to invoke `'poetry` `run` `mypy'`. + g:ale_python_mypy_ignore_invalid_syntax *g:ale_python_mypy_ignore_invalid_syntax* @@ -292,6 +658,14 @@ g:ale_python_mypy_options *g:ale_python_mypy_options* invocation. +g:ale_python_mypy_show_notes *g:ale_python_mypy_show_notes* + *b:ale_python_mypy_show_notes* + Type: |Number| + Default: `1` + + If enabled, notes on lines will be displayed as 'I' (info) messages. + + g:ale_python_mypy_use_global *g:ale_python_mypy_use_global* *b:ale_python_mypy_use_global* Type: |Number| @@ -300,15 +674,6 @@ g:ale_python_mypy_use_global *g:ale_python_mypy_use_global* See |ale-integrations-local-executables| -g:ale_python_mypy_auto_pipenv *g:ale_python_mypy_auto_pipenv* - *b:ale_python_mypy_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. - - =============================================================================== prospector *ale-python-prospector* @@ -320,6 +685,7 @@ g:ale_python_prospector_executable *g:ale_python_prospector_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `prospector'`. + Set this to `'poetry'` to invoke `'poetry` `run` `prospector'`. g:ale_python_prospector_options *g:ale_python_prospector_options* @@ -360,10 +726,108 @@ g:ale_python_prospector_auto_pipenv *g:ale_python_prospector_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_prospector_auto_poetry *g:ale_python_prospector_auto_poetry* + *b:ale_python_prospector_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_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* + +g:ale_python_pycln_change_directory *g:ale_python_pycln_change_directory* + *b:ale_python_pycln_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, `pycln` will be run from a detected project root, per + |ale-python-root|. if set to `0` or no project root detected, + `pycln` will be run from the buffer's directory. + + +g:ale_python_pycln_executable *g:ale_python_pycln_executable* + *b:ale_python_pycln_executable* + Type: |String| + Default: `'pycln'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pycln'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pycln'`. + + +g:ale_python_pycln_options *g:ale_python_pycln_options* + *b:ale_python_pycln_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pycln + invocation. + + For example, to select/enable and/or disable some error codes, + you may want to set > + let g:ale_python_pycln_options = '--expand-stars' + + +g:ale_python_pycln_config_file *g:ale_python_pycln_config_file* + *b:ale_python_pycln_config_file* + Type: |String| + Default: `''` + + Use this variable to set the configuration file. + If `'--config' ` is found in the |g:ale_python_pycln_options|, then that + option value will override the value in this variable. + +g:ale_python_pycln_use_global *g:ale_python_pycln_use_global* + *b:ale_python_pycln_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_pycln_auto_pipenv *g:ale_python_pycln_auto_pipenv* + *b:ale_python_pycln_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_pycln_auto_poetry *g:ale_python_pycln_auto_poetry* + *b:ale_python_pycln_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_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* - g:ale_python_pycodestyle_executable *g:ale_python_pycodestyle_executable* *b:ale_python_pycodestyle_executable* Type: |String| @@ -372,6 +836,7 @@ g:ale_python_pycodestyle_executable *g:ale_python_pycodestyle_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pycodestyle'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pycodestyle'`. g:ale_python_pycodestyle_options *g:ale_python_pycodestyle_options* @@ -400,10 +865,27 @@ g:ale_python_pycodestyle_auto_pipenv *g:ale_python_pycodestyle_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pycodestyle_auto_poetry *g:ale_python_pycodestyle_auto_poetry* + *b:ale_python_pycodestyle_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_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* - g:ale_python_pydocstyle_executable *g:ale_python_pydocstyle_executable* *b:ale_python_pydocstyle_executable* Type: |String| @@ -412,6 +894,7 @@ g:ale_python_pydocstyle_executable *g:ale_python_pydocstyle_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pydocstyle'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pydocstyle'`. g:ale_python_pydocstyle_options *g:ale_python_pydocstyle_options* @@ -440,10 +923,27 @@ g:ale_python_pydocstyle_auto_pipenv *g:ale_python_pydocstyle_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pydocstyle_auto_poetry *g:ale_python_pydocstyle_auto_poetry* + *b:ale_python_pydocstyle_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_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* - g:ale_python_pyflakes_executable *g:ale_python_pyflakes_executable* *b:ale_python_pyflakes_executable* Type: |String| @@ -452,6 +952,7 @@ g:ale_python_pyflakes_executable *g:ale_python_pyflakes_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pyflakes'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyflakes'`. g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv* @@ -463,6 +964,79 @@ g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pyflakes_auto_poetry *g:ale_python_pyflakes_auto_poetry* + *b:ale_python_pyflakes_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_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* + +g:ale_python_pyflyby_executable *g:ale_python_pyflyby_executable* + *b:ale_python_pyflyby_executable* + Type: |String| + Default: `'tidy-imports'` + + See |ale-integrations-local-executables| + + +g:ale_python_pyflyby_options *g:ale_python_pyflyby_options* + *b:ale_python_pyflyby_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pyflyby + tidy-imports invocation. + + +g:ale_python_pyflyby_use_global *g:ale_python_pyflyby_use_global* + *b:ale_python_pyflyby_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_pyflyby_auto_pipenv *g:ale_python_pyflyby_auto_pipenv* + *b:ale_python_pyflyby_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_pyflyby_auto_poetry *g:ale_python_pyflyby_auto_poetry* + *b:ale_python_pyflyby_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_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* @@ -484,7 +1058,8 @@ g:ale_python_pylama_executable *g:ale_python_pylama_executable* Default: `'pylama'` This variable can be changed to modify the executable used for pylama. Set - this to `'pipenv'` to invoke `'pipenv` `run` `pylama'`. + this to `'pipenv'` to invoke `'pipenv` `run` `pylama'`. Set this to + `'poetry'` to invoke `'poetry` `run` `pylama'`. g:ale_python_pylama_options *g:ale_python_pylama_options* @@ -517,6 +1092,23 @@ g:ale_python_pylama_auto_pipenv *g:ale_python_pylama_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pylama_auto_poetry *g:ale_python_pylama_auto_poetry* + *b:ale_python_pylama_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_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* @@ -541,6 +1133,7 @@ g:ale_python_pylint_executable *g:ale_python_pylint_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pylint'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pylint'`. g:ale_python_pylint_options *g:ale_python_pylint_options* @@ -580,6 +1173,24 @@ g:ale_python_pylint_auto_pipenv *g:ale_python_pylint_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pylint_auto_poetry *g:ale_python_pylint_auto_poetry* + *b:ale_python_pylint_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_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| @@ -588,32 +1199,34 @@ g:ale_python_pylint_use_msg_id *g:ale_python_pylint_use_msg_id* Use message for output (e.g. I0011) instead of symbolic name of the message (e.g. locally-disabled). + =============================================================================== -pyls *ale-python-pyls* +pylsp *ale-python-pylsp* -`pyls` will be run from a detected project root, per |ale-python-root|. +`pylsp` will be run from a detected project root, per |ale-python-root|. -g:ale_python_pyls_executable *g:ale_python_pyls_executable* - *b:ale_python_pyls_executable* +g:ale_python_pylsp_executable *g:ale_python_pylsp_executable* + *b:ale_python_pylsp_executable* Type: |String| - Default: `'pyls'` + Default: `'pylsp'` See |ale-integrations-local-executables| - Set this to `'pipenv'` to invoke `'pipenv` `run` `pyls'`. + Set this to `'pipenv'` to invoke `'pipenv` `run` `pylsp'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyls'`. -g:ale_python_pyls_use_global *g:ale_python_pyls_use_global* - *b:ale_python_pyls_use_global* +g:ale_python_pylsp_use_global *g:ale_python_pylsp_use_global* + *b:ale_python_pylsp_use_global* Type: |Number| Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| -g:ale_python_pyls_auto_pipenv *g:ale_python_pyls_auto_pipenv* - *b:ale_python_pyls_auto_pipenv* +g:ale_python_pylsp_auto_pipenv *g:ale_python_pylsp_auto_pipenv* + *b:ale_python_pylsp_auto_pipenv* Type: |Number| Default: `0` @@ -621,15 +1234,33 @@ g:ale_python_pyls_auto_pipenv *g:ale_python_pyls_auto_pipenv* if true. This is overridden by a manually-set executable. -g:ale_python_pyls_config *g:ale_python_pyls_config* - *b:ale_python_pyls_config* +g:ale_python_pylsp_auto_poetry *g:ale_python_pylsp_auto_poetry* + *b:ale_python_pylsp_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_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| Default: `{}` - Dictionary with configuration settings for pyls. For example, to disable + Dictionary with configuration settings for pylsp. For example, to disable the pycodestyle linter: > { - \ 'pyls': { + \ 'pylsp': { \ 'plugins': { \ 'pycodestyle': { \ 'enabled': v:false @@ -639,6 +1270,26 @@ g:ale_python_pyls_config *g:ale_python_pyls_config* \ } < +g:ale_python_pylsp_options *g:ale_python_pylsp_options* + *b:ale_python_pylsp_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pylsp + invocation. Note that this is not the same thing as ale_python_pylsp_config, + which allows configuration of how pylsp functions; this is intended to + provide flexibility in how the pylsp command is invoked. + + For example, if you had installed `pylsp` but your `pylsp` executable was not + on your `PATH` for some reason, an alternative way to run the pylsp server + would be: + let g:ale_python_pylsp_executable = 'python3' + let g:ale_python_pylsp_options = '-m pylsp' + + An example strategy for installing `pylsp`: + `python3 -m pip install --user pylsp` + + =============================================================================== pyre *ale-python-pyre* @@ -653,6 +1304,7 @@ g:ale_python_pyre_executable *g:ale_python_pyre_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pyre'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyre'`. g:ale_python_pyre_use_global *g:ale_python_pyre_use_global* @@ -672,6 +1324,180 @@ g:ale_python_pyre_auto_pipenv *g:ale_python_pyre_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pyre_auto_poetry *g:ale_python_pyre_auto_poetry* + *b:ale_python_pyre_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_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* + +The `pyright` linter requires a recent version of `pyright` which includes +the `pyright-langserver` executable. You can install `pyright` on your system +through `npm` with `sudo npm install -g pyright` or similar. + +Refer to their README for installation instructions: +https://github.com/Microsoft/pyright + +`pyright` needs to know the path to your Python executable and probably a +virtualenv to run. ALE will try to detect these automatically. +See |g:ale_python_pyright_config|. + + +g:ale_python_pyright_executable *g:ale_python_pyright_executable* + *b:ale_python_pyright_executable* + Type: |String| + Default: `'pyright-langserver'` + + The executable for running `pyright`, which is typically installed globally. + + +g:ale_python_pyright_config *g:ale_python_pyright_config* + *b:ale_python_pyright_config* + Type: |Dictionary| + Default: `{}` + + Settings for configuring the `pyright` language server. + + See pyright's documentation for a full list of options: + https://github.com/microsoft/pyright/blob/master/docs/settings.md + + ALE will automatically try to set defaults for `venvPath` and `pythonPath` + so your project can automatically be checked with the right libraries. + You can override these settings with whatever you want in your ftplugin + file like so: > + + let b:ale_python_pyright_config = { + \ 'python': { + \ 'pythonPath': '/bin/python', + \ 'venvPath': '/other/dir', + \ }, + \} +< + If `venvPath` is set, but `pythonPath` is not, + ALE will use `venvPath . '/bin/python'` or similar as `pythonPath`. + + A commonly used setting for `pyright` is disabling language services + apart from type checking and "hover" (|ale-hover|), you can set this + setting like so, or use whatever other settings you want: > + + let b:ale_python_pyright_config = { + \ 'pyright': { + \ 'disableLanguageServices': v:true, + \ }, + \} +< + +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* + +g:ale_python_refurb_change_directory *g:ale_python_refurb_change_directory* + *b:ale_python_refurb_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, `refurb` will be run from a detected project root, per + |ale-python-root|. if set to `0` or no project root detected, + `refurb` will be run from the buffer's directory. + + +g:ale_python_refurb_executable *g:ale_python_refurb_executable* + *b:ale_python_refurb_executable* + Type: |String| + Default: `'refurb'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `refurb'`. + Set this to `'poetry'` to invoke `'poetry` `run` `refurb'`. + + +g:ale_python_refurb_options *g:ale_python_refurb_options* + *b:ale_python_refurb_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the refurb + invocation. + + For example, to select/enable and/or disable some error codes, + you may want to set > + let g:ale_python_refurb_options = '--ignore 100' +g:ale_python_refurb_use_global *g:ale_python_refurb_use_global* + *b:ale_python_refurb_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_refurb_auto_pipenv *g:ale_python_refurb_auto_pipenv* + *b:ale_python_refurb_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_refurb_auto_poetry *g:ale_python_refurb_auto_poetry* + *b:ale_python_refurb_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_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* @@ -702,6 +1528,242 @@ 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* + +g:ale_python_ruff_change_directory *g:ale_python_ruff_change_directory* + *b:ale_python_ruff_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, `ruff` will be run from a detected project root, per + |ale-python-root|. if set to `0` or no project root detected, + `ruff` will be run from the buffer's directory. + + +g:ale_python_ruff_executable *g:ale_python_ruff_executable* + *b:ale_python_ruff_executable* + Type: |String| + Default: `'ruff'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `ruff'`. + Set this to `'poetry'` to invoke `'poetry` `run` `ruff'`. + + +g:ale_python_ruff_options *g:ale_python_ruff_options* + *b:ale_python_ruff_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the ruff + invocation. + + For example, to select/enable and/or disable some error codes, + you may want to set > + let g:ale_python_ruff_options = '--ignore F401' + + +g:ale_python_ruff_use_global *g:ale_python_ruff_use_global* + *b:ale_python_ruff_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_ruff_auto_pipenv *g:ale_python_ruff_auto_pipenv* + *b:ale_python_ruff_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_ruff_auto_poetry *g:ale_python_ruff_auto_poetry* + *b:ale_python_ruff_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_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* + +g:ale_python_ruff_format_change_directory + *g:ale_python_ruff_format_change_directory* + *b:ale_python_ruff_format_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, `ruff` will be run from a detected project root, per + |ale-python-root|. if set to `0` or no project root detected, + `ruff` will be run from the buffer's directory. + + +g:ale_python_ruff_format_executable *g:ale_python_ruff_format_executable* + *b:ale_python_ruff_format_executable* + Type: |String| + Default: `'ruff'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `ruff'`. + Set this to `'poetry'` to invoke `'poetry` `run` `ruff'`. + + +g:ale_python_ruff_format_options *g:ale_python_ruff_format_options* + *b:ale_python_ruff_format_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the ruff + invocation. + + For example, to select/enable and/or disable some error codes, + you may want to set > + let g:ale_python_ruff_format_options = '--ignore F401' + + +g:ale_python_ruff_format_use_global *g:ale_python_ruff_format_use_global* + *b:ale_python_ruff_format_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_ruff_format_auto_pipenv *g:ale_python_ruff_format_auto_pipenv* + *b:ale_python_ruff_format_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_ruff_format_auto_poetry *g:ale_python_ruff_format_auto_poetry* + *b:ale_python_ruff_format_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_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* + +`unimport` will be run from a detected project root, per |ale-python-root|. + + +g:ale_python_unimport_auto_pipenv *g:ale_python_unimport_auto_pipenv* + *b:ale_python_unimport_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_unimport_auto_poetry *g:ale_python_unimport_auto_poetry* + *b:ale_python_unimport_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_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| + Default: `'unimport'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `unimport'`. + Set this to `'poetry'` to invoke `'poetry` `run` `unimport'`. + + +g:ale_python_unimport_options *g:ale_python_unimport_options* + *b:ale_python_unimport_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the unimport + invocation. + + +g:ale_python_unimport_use_global *g:ale_python_unimport_use_global* + *b:ale_python_unimport_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vulture *ale-python-vulture* @@ -740,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* @@ -760,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-r.txt b/sources_non_forked/ale/doc/ale-r.txt index b5ccebe5..3fabf702 100644 --- a/sources_non_forked/ale/doc/ale-r.txt +++ b/sources_non_forked/ale/doc/ale-r.txt @@ -2,6 +2,29 @@ ALE R Integration *ale-r-options* +=============================================================================== +languageserver *ale-r-languageserver* + +g:ale_r_languageserver_cmd *g:ale_r_languageserver_cmd* + *b:ale_r_languageserver_cmd* + Type: |String| + Default: `'languageserver::run()'` + + This option can be configured to change the execution command for + languageserver. + + See the languageserver documentation for more options. + + +g:ale_r_languageserver_config *g:ale_r_languageserver_config* + *b:ale_r_languageserver_config* + Type: |Dictionary| + Default: `{}` + + This option can be configured to change settings for languageserver. See the + languageserver documentation for more information. + + =============================================================================== lintr *ale-r-lintr* @@ -22,7 +45,7 @@ g:ale_r_lintr_lint_package *g:ale_r_lintr_lint_package* Default: `0` When set to `1`, the file will be checked with `lintr::lint_package` instead - of `lintr::lint`. This prevents erroneous namespace warnings when linting + of `lintr::lint`. This prevents erroneous namespace warnings when linting package files. @@ -36,8 +59,8 @@ g:ale_r_styler_options *g:ale_r_styler_options* This option can be configured to change the options for styler. - The value of this option will be used as the `style` argument for the - `styler::style_file` options. Consult the styler documentation + The value of this option will be used as the `style` argument for the + `styler::style_file` options. Consult the styler documentation for more information. diff --git a/sources_non_forked/ale/doc/ale-racket.txt b/sources_non_forked/ale/doc/ale-racket.txt new file mode 100644 index 00000000..7e78702f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-racket.txt @@ -0,0 +1,41 @@ +=============================================================================== +ALE Racket Integration *ale-racket-options* + +=============================================================================== +racket_langserver *ale-racket-langserver* + +1. Install racket-langserver as described here: + https://github.com/jeapostrophe/racket-langserver +2. Have `racket` available in the `$PATH` environment variable, currently there + is no way to specify path to custom location of `racket`. +3. set `racket_langserver` as a linter for `racket` like: > + let g:ale_linters['racket'] += ['racket_langserver'] + +You should be able to see linter results and use LSP features of `ALE` like +`ALEGoToDefinition` with `racket-langserver`. + +=============================================================================== +raco_fmt *ale-racket-raco-fmt* + +g:ale_racket_raco_fmt_executable *g:ale_racket_raco_fmt_executable* + *b:ale_racket_raco_fmt_executable* + Type: |String| + Default: `'raco'` + + If the `raco` excutable is not in the `$PATH` environment variable, or you + prefer to use one installed in a custom location, set this option to the + path to the specific `raco` executable. + +g:ale_racket_raco_fmt_options *g:ale_racket_raco_fmt_options* + *b:ale_racket_raco_fmt_options* + Type: |String| + Default: `''` + + Use this variable to pass command-line flags/parameters to `raco_fmt` + + For example, set the page width limit to 40 > + let g:ale_racket_raco_fmt_options = '--width 40' + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-rego.txt b/sources_non_forked/ale/doc/ale-rego.txt new file mode 100644 index 00000000..9a39dbf0 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-rego.txt @@ -0,0 +1,50 @@ +=============================================================================== +ALE Rego Integration *ale-rego-options* + + +=============================================================================== +cspell *ale-rego-cspell* + +See |ale-cspell-options| + + +=============================================================================== +opacheck *ale-rego-opa-check* + +g:ale_rego_opacheck_executable *g:rego_opacheck_executable* + *b:rego_opacheck_executable* + + Type: |String| + Default: `'opa'` + + This variable can be changed to use a different executable for opa. + + +g:rego_opacheck_options *g:rego_opacheck_options* + *b:rego_opacheck_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to opa check. + + +=============================================================================== +opafmt *ale-rego-opa-fmt-fixer* + +g:ale_opa_fmt_executable *g:ale_opa_fmt_executable* + *b:ale_opa_fmt_executable* + + Type: |String| + Default: `'opa'` + + This variable can be changed to use a different executable for opa. + + +g:ale_opa_fmt_options *g:ale_opa_fmt_options* + *b:ale_opa_fmt_options* + Type: |String| + Default: `''` + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-rest.txt b/sources_non_forked/ale/doc/ale-rest.txt new file mode 100644 index 00000000..e81d319a --- /dev/null +++ b/sources_non_forked/ale/doc/ale-rest.txt @@ -0,0 +1,11 @@ +=============================================================================== +ALE REST Integration *ale-rest-options* + + +=============================================================================== +kulala_fmt *ale-rest-kulala_fmt* + +See |ale-http-kulala_fmt| + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-restructuredtext.txt b/sources_non_forked/ale/doc/ale-restructuredtext.txt index e308b072..7af62133 100644 --- a/sources_non_forked/ale/doc/ale-restructuredtext.txt +++ b/sources_non_forked/ale/doc/ale-restructuredtext.txt @@ -2,6 +2,12 @@ ALE reStructuredText Integration *ale-restructuredtext-options* +=============================================================================== +cspell *ale-restructuredtext-cspell* + +See |ale-cspell-options| + + =============================================================================== textlint *ale-restructuredtext-textlint* @@ -16,6 +22,7 @@ See: https://github.com/jimo1001/docutils-ast-writer See |ale-text-textlint| + =============================================================================== write-good *ale-restructuredtext-write-good* @@ -23,4 +30,4 @@ See |ale-write-good-options| =============================================================================== -vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-robot.txt b/sources_non_forked/ale/doc/ale-robot.txt new file mode 100644 index 00000000..405ae277 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-robot.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE Robot Integration *ale-robot-options* + + +=============================================================================== +rflint *ale-robot-rflint* + +g:ale_robot_rflint_executable *g:ale_robot_rflint_executable* + *b:ale_robot_rflint_executable* + Type: |String| + Default: `'rflint'` + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-ruby.txt b/sources_non_forked/ale/doc/ale-ruby.txt index e373ab8e..ff5a371f 100644 --- a/sources_non_forked/ale/doc/ale-ruby.txt +++ b/sources_non_forked/ale/doc/ale-ruby.txt @@ -7,7 +7,7 @@ brakeman *ale-ruby-brakeman* g:ale_ruby_brakeman_executable *g:ale_ruby_brakeman_executable* *b:ale_ruby_brakeman_executable* - Type: String + Type: |String| Default: `'brakeman'` Override the invoked brakeman binary. Set this to `'bundle'` to invoke @@ -22,13 +22,65 @@ g:ale_ruby_brakeman_options *g:ale_ruby_brakeman_options* The contents of this variable will be passed through to brakeman. +=============================================================================== +cspell *ale-ruby-cspell* + +See |ale-cspell-options| + + +=============================================================================== +debride *ale-ruby-debride* + +g:ale_ruby_debride_executable *g:ale_ruby_debride_executable* + *b:ale_ruby_debride_executable* + Type: |String| + Default: `'debride'` + + Override the invoked debride binary. Set this to `'bundle'` to invoke + `'bundle` `exec` debride'. + + +g:ale_ruby_debride_options *g:ale_ruby_debride_options* + *b:ale_ruby_debride_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to debride. + + +=============================================================================== +packwerk *ale-ruby-packwerk* + +g:ale_ruby_packwerk_executable *g:ale_ruby_packwerk_executable* + *b:ale_ruby_packwerk_executable* + Type: |String| + Default: `'packwerk'` + + Override the invoked packwerk binary. Set this to `'bundle'` to invoke + `'bundle` `exec` packwerk'. + + +g:ale_ruby_packwerk_options *g:ale_ruby_packwerk_options* + *b:ale_ruby_packwerk_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to packwerk. + + +=============================================================================== +prettier *ale-ruby-prettier* + +See |ale-javascript-prettier| for information about the available options. + + =============================================================================== rails_best_practices *ale-ruby-rails_best_practices* g:ale_ruby_rails_best_practices_executable *g:ale_ruby_rails_best_practices_executable* *b:ale_ruby_rails_best_practices_executable* - Type: String + Type: |String| Default: `'rails_best_practices'` Override the invoked rails_best_practices binary. Set this to `'bundle'` to @@ -49,7 +101,7 @@ reek *ale-ruby-reek* g:ale_ruby_reek_executable *g:ale_ruby_reek_executable* *b:ale_ruby_reek_executable* - Type: String + Type: |String| Default: `'reek'` Override the invoked reek binary. Set this to `'bundle'` to invoke @@ -59,7 +111,7 @@ g:ale_ruby_reek_executable *g:ale_ruby_reek_executable* g:ale_ruby_reek_show_context *g:ale_ruby_reek_show_context* *b:ale_ruby_reek_show_context* Type: |Number| - Default: 0 + Default: `0` Controls whether context is included in the linter message. Defaults to off because context is usually obvious while viewing a file. @@ -68,7 +120,7 @@ g:ale_ruby_reek_show_context *g:ale_ruby_reek_show_context* g:ale_ruby_reek_show_wiki_link *g:ale_ruby_reek_show_wiki_link* *b:ale_ruby_reek_show_wiki_link* Type: |Number| - Default: 0 + Default: `0` Controls whether linter messages contain a link to an explanatory wiki page for the type of code smell. Defaults to off to improve readability. @@ -79,7 +131,7 @@ rubocop *ale-ruby-rubocop* g:ale_ruby_rubocop_executable *g:ale_ruby_rubocop_executable* *b:ale_ruby_rubocop_executable* - Type: String + Type: |String| Default: `'rubocop'` Override the invoked rubocop binary. Set this to `'bundle'` to invoke @@ -91,7 +143,15 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options* Type: |String| Default: `''` - This variable can be change to modify flags given to rubocop. + This variable can be changed to modify flags given to rubocop. + + +g:ale_ruby_rubocop_auto_correct_all *g:ale_ruby_rubocop_auto_correct_all* + *b:ale_ruby_rubocop_auto_correct_all* + Type: |Number| + Default: `0` + + This variable can be changed to make rubocop to correct all offenses (unsafe). =============================================================================== @@ -99,7 +159,7 @@ ruby *ale-ruby-ruby* g:ale_ruby_ruby_executable *g:ale_ruby_ruby_executable* *b:ale_ruby_ruby_executable* - Type: String + Type: |String| Default: `'ruby'` This variable can be changed to use a different executable for ruby. @@ -110,7 +170,7 @@ rufo *ale-ruby-rufo* g:ale_ruby_rufo_executable *g:ale_ruby_rufo_executable* *b:ale_ruby_rufo_executable* - Type: String + Type: |String| Default: `'rufo'` Override the invoked rufo binary. This is useful for running rufo from @@ -122,7 +182,7 @@ solargraph *ale-ruby-solargraph* g:ale_ruby_solargraph_executable *g:ale_ruby_solargraph_executable* *b:ale_ruby_solargraph_executable* - Type: String + Type: |String| Default: `'solargraph'` Override the invoked solargraph binary. This is useful for running solargraph @@ -134,7 +194,7 @@ sorbet *ale-ruby-sorbet* g:ale_ruby_sorbet_executable *g:ale_ruby_sorbet_executable* *b:ale_ruby_sorbet_executable* - Type: String + Type: |String| Default: `'srb'` Override the invoked sorbet binary. Set this to `'bundle'` to invoke @@ -146,15 +206,25 @@ g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options* Type: |String| Default: `''` - This variable can be change to modify flags given to sorbet. + This variable can be changed to modify flags given to sorbet. + + +g:ale_ruby_sorbet_enable_watchman *g:ale_ruby_sorbet_enable_watchman* + *b:ale_ruby_sorbet_enable_watchman* + Type: |Number| + Default: `0` + + Whether or not to use watchman to let the LSP server to know about changes + to files from outside of vim. Defaults to disable watchman because it + requires watchman to be installed separately from sorbet. =============================================================================== standardrb *ale-ruby-standardrb* -g:ale_ruby_standardrb_executable *g:ale_ruby_standardrb_executable* - *b:ale_ruby_standardrb_executable* - Type: String +g:ale_ruby_standardrb_executable *g:ale_ruby_standardrb_executable* + *b:ale_ruby_standardrb_executable* + Type: |String| Default: `'standardrb'` Override the invoked standardrb binary. Set this to `'bundle'` to invoke @@ -166,10 +236,46 @@ g:ale_ruby_standardrb_options *g:ale_ruby_standardrb_options* Type: |String| Default: `''` - This variable can be change to modify flags given to standardrb. + This variable can be changed to modify flags given to standardrb. =============================================================================== +syntax_tree *ale-ruby-syntax_tree* + +g:ale_ruby_syntax_tree_executable *g:ale_ruby_syntax_tree_executable* + *b:ale_ruby_syntax_tree_executable* + Type: |String| + Default: `'stree'` + + Override the invoked SyntaxTree binary. Set this to `'bundle'` to invoke + `'bundle` `exec` stree'. + + +g:ale_ruby_syntax_tree_options *g:ale_ruby_syntax_tree_options* + *b:ale_ruby_syntax_tree_options* + Type: |String| + Default: `''` + + 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-rust.txt b/sources_non_forked/ale/doc/ale-rust.txt index 44a79b18..897fcaa1 100644 --- a/sources_non_forked/ale/doc/ale-rust.txt +++ b/sources_non_forked/ale/doc/ale-rust.txt @@ -9,7 +9,7 @@ Integration Information files for Rust distributed in Vim >=8.0.0501 or upstream: https://github.com/rust-lang/rust.vim - Note that there are three possible linters for Rust files: + Note that there are several possible linters and fixers for Rust files: 1. rustc -- The Rust compiler is used to check the currently edited file. So, if your project consists of multiple files, you will get some errors @@ -22,20 +22,60 @@ Integration Information 3. rls -- If you have `rls` installed, you might prefer using this linter over cargo. rls implements the Language Server Protocol for incremental compilation of Rust code, and can check Rust files while you type. `rls` - requires Rust files to contained in Cargo projects. - 4. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to + requires Rust files to be contained in Cargo projects. + 4. analyzer -- If you have rust-analyzer installed, you might prefer using + this linter over cargo and rls. rust-analyzer also implements the + Language Server Protocol for incremental compilation of Rust code, and is + the next iteration of rls. rust-analyzer either requires Rust files to be + contained in Cargo projects or requires the project to be described in + the rust-project.json format: + https://rust-analyzer.github.io/manual.html#non-cargo-based-projects + 5. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to consistently reformat your Rust code. - Only cargo is enabled by default. To switch to using rustc instead of cargo, - configure |g:ale_linters| appropriately: > + Only cargo and rust-analyze are enabled by default. To switch to using rustc + instead of cargo, configure |b:ale_linters| in your ftplugin file + appropriately: > " See the help text for the option for more information. - let g:ale_linters = {'rust': ['rustc']} + let b:ale_linters = ['analyzer', 'rustc'] < - Also note that rustc 1.12. or later is needed. + Also note that rustc 1.18. or later is needed. +=============================================================================== +analyzer *ale-rust-analyzer* + +g:ale_rust_analyzer_executable *g:ale_rust_analyzer_executable* + *b:ale_rust_analyzer_executable* + Type: |String| + Default: `'rust-analyzer'` + + This variable can be modified to change the executable path for + `rust-analyzer`. + + +g:ale_rust_analyzer_config *g:ale_rust_analyzer_config* + *b:ale_rust_analyzer_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for rust-analyzer. Keys of the + dictionary are components of configuration keys. For example: +> + let g:ale_rust_analyzer_config = { + \ 'server': { + \ 'extraEnv': { 'RUSTUP_TOOLCHAIN': 'stable' }, + \ } + \} +< + corresponds to `rust-analyzer.server.extraEnv = { 'RUSTUP_TOOLCHAIN': 'stable' }` + + For available configuration parameters, see the `rust-analyzer` manual: + + https://rust-analyzer.github.io/manual.html#configuration + =============================================================================== cargo *ale-rust-cargo* @@ -120,8 +160,7 @@ g:ale_rust_cargo_avoid_whole_workspace *g:ale_rust_cargo_avoid_whole_workspace* in the crate's directory. Otherwise, behave as usual. -g:ale_rust_cargo_use_clippy - *g:ale_rust_cargo_use_clippy* +g:ale_rust_cargo_use_clippy *g:ale_rust_cargo_use_clippy* *b:ale_rust_cargo_use_clippy* Type: |Number| Default: `0` @@ -138,8 +177,7 @@ g:ale_rust_cargo_use_clippy let g:ale_rust_cargo_use_clippy = executable('cargo-clippy') < -g:ale_rust_cargo_clippy_options - *g:ale_rust_cargo_clippy_options* +g:ale_rust_cargo_clippy_options *g:ale_rust_cargo_clippy_options* *b:ale_rust_cargo_clippy_options* Type: |String| @@ -150,6 +188,23 @@ g:ale_rust_cargo_clippy_options only `cargo clippy` supports (e.g. `--deny`). +g:ale_rust_cargo_target_dir *g:ale_rust_cargo_target_dir* + *b:ale_rust_cargo_target_dir* + + Type: |String| + Default: `''` + + Use a custom target directory when running the commands for ALE. This can + help to avoid "waiting for file lock on build directory" messages when + running `cargo` commands manually while ALE is performing its checks. + + +=============================================================================== +cspell *ale-rust-cspell* + +See |ale-cspell-options| + + =============================================================================== rls *ale-rust-rls* @@ -197,13 +252,13 @@ rustc *ale-rust-rustc* g:ale_rust_rustc_options *g:ale_rust_rustc_options* *b:ale_rust_rustc_options* Type: |String| - Default: `'-Z no-codegen'` + Default: `'--emit=mir -o /dev/null'` The variable can be used to change the options passed to `rustc`. - `-Z no-codegen` should only work with nightly builds of Rust. Be careful when - setting the options, as running `rustc` could execute code or generate - binary files. + Users of nightly builds of Rust might want to use `-Z no-codegen` instead. + Be careful when setting the options, as running `rustc` could execute code + or generate binary files. g:ale_rust_ignore_error_codes *g:ale_rust_ignore_error_codes* @@ -216,23 +271,25 @@ g:ale_rust_ignore_error_codes *g:ale_rust_ignore_error_codes* > let g:ale_rust_ignore_error_codes = ['E0432', 'E0433'] + g:ale_rust_ignore_secondary_spans *g:ale_rust_ignore_secondary_spans* *b:ale_rust_ignore_secondary_spans* - Type: Number - Default: 0 + Type: |Number| + Default: `0` - When set to 1, instructs the Rust error repporting to ignore secondary - spans. The problem with secondary spans is that they sometimes appear in - error messages before the main cause of the error, for example: > + When set to 1, instructs the Rust error reporting to ignore secondary spans. + The problem with secondary spans is that they sometimes appear in error + messages before the main cause of the error, for example: > 1 src/main.rs|98 col 5 error| this function takes 4 parameters but 5 - parameters were supplied: defined here + parameters were supplied: defined here 2 src/main.rs|430 col 32 error| this function takes 4 parameters but 5 - parameters were supplied: expected 4 parameters + parameters were supplied: expected 4 parameters < This is due to the sorting by line numbers. With this option set to 1, the 'defined here' span will not be presented. + =============================================================================== rustfmt *ale-rust-rustfmt* @@ -244,5 +301,13 @@ g:ale_rust_rustfmt_options *g:ale_rust_rustfmt_options* This variable can be set to pass additional options to the rustfmt fixer. +g:ale_rust_rustfmt_executable *g:ale_rust_rustfmt_executable* + *b:ale_rust_rustfmt_executable* + Type: |String| + Default: `'rustfmt'` + + This variable can be modified to change the executable path for `rustfmt`. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-salt.tmt b/sources_non_forked/ale/doc/ale-salt.tmt new file mode 100644 index 00000000..71e4c652 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-salt.tmt @@ -0,0 +1,43 @@ +=============================================================================== +ALE SALT Integration *ale-salt-options* + +=============================================================================== +salt-lint *ale-salt-salt-lint* + +Website: https://github.com/warpnet/salt-lint + + +Installation +------------------------------------------------------------------------------- + +Install salt-lint in your a virtualenv directory, locally, or globally: > + + pip install salt-lint # After activating virtualenv + pip install --user salt-lint # Install to ~/.local/bin + sudo pip install salt-lint # Install globally + +See |g:ale_virtualenv_dir_names| for configuring how ALE searches for +virtualenv directories. + + +Options +------------------------------------------------------------------------------- + +g:ale_salt_salt_lint_executable *g:ale_salt_salt_lint_executable* + *b:ale_salt_salt_lint_executable* + Type: |String| + Default: `'salt-lint'` + + This variable can be set to change the path to salt-lint. + + +g:ale_salt_salt_lint_options *g:ale_salt_salt_lint_options* + *b:ale_salt_salt_lint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to salt-lint. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-scala.txt b/sources_non_forked/ale/doc/ale-scala.txt index ff43cd6c..0b0f1a9a 100644 --- a/sources_non_forked/ale/doc/ale-scala.txt +++ b/sources_non_forked/ale/doc/ale-scala.txt @@ -2,6 +2,38 @@ ALE Scala Integration *ale-scala-options* +=============================================================================== +cspell *ale-scala-cspell* + +See |ale-cspell-options| + + +=============================================================================== +metals *ale-scala-metals* + +`metals` requires either an SBT project, a Mill project, or a running Bloop +server. + + +g:ale_scala_metals_executable *g:ale_scala_metals_executable* + *b:ale_scala_metals_executable* + Type: |String| + Default: `'metals-vim'` + + Override the invoked `metals` binary. + + +g:ale_scala_metals_project_root *g:ale_scala_metals_project_root* + *b:ale_scala_metals_project_root* + Type: |String| + Default: `''` + + By default the project root is found by searching upwards for `build.sbt`, + `build.sc`, `.bloop` or `.metals`. + If the project root is elsewhere, you can override the project root + directory. + + =============================================================================== sbtserver *ale-scala-sbtserver* diff --git a/sources_non_forked/ale/doc/ale-sh.txt b/sources_non_forked/ale/doc/ale-sh.txt index 3eac9038..9a1928c4 100644 --- a/sources_non_forked/ale/doc/ale-sh.txt +++ b/sources_non_forked/ale/doc/ale-sh.txt @@ -2,6 +2,35 @@ ALE Shell Integration *ale-sh-options* +=============================================================================== +bashate *ale-sh-bashate* + +g:ale_sh_bashate_executable *g:ale_sh_bashate_executable* + *b:ale_sh_bashate_executable* + Type: |String| + Default: `'bashate'` + + This variable sets executable used for bashate. + + +g:ale_sh_bashate_options *g:ale_sh_bashate_options* + *b:ale_sh_bashate_options* + Type: |String| + Default: `''` + + With this variable we are able to pass extra arguments for bashate. For + example to ignore the indentation rule: + +> + let g:ale_sh_bashate_options = '-i E003' +< + +=============================================================================== +cspell *ale-sh-cspell* + +See |ale-cspell-options| + + =============================================================================== sh-language-server *ale-sh-language-server* diff --git a/sources_non_forked/ale/doc/ale-solidity.txt b/sources_non_forked/ale/doc/ale-solidity.txt index 4b74a27a..6cf97344 100644 --- a/sources_non_forked/ale/doc/ale-solidity.txt +++ b/sources_non_forked/ale/doc/ale-solidity.txt @@ -2,6 +2,24 @@ ALE Solidity Integration *ale-solidity-options* +=============================================================================== +solc *ale-solidity-solc* + +g:ale_solidity_solc_executable *g:ale_solidity_solc_executable* + *b:ale_solidity_solc_executable* + Type: |String| + Default: `'solc'` + + Override the invoked solc binary. For truffle/hardhat binaries. + +g:ale_solidity_solc_options *g:ale_solidity_solc_options* + *b:ale_solidity_solc_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to solc. + + =============================================================================== solhint *ale-solidity-solhint* @@ -18,7 +36,15 @@ solium *ale-solidity-solium* See the corresponding solium usage for detailed instructions (https://github.com/duaraghav8/Solium#usage). +=============================================================================== +forge *ale-solidity-forge* + + `forge fmt` is not a linter, only a formatter. It should be used only as a + fixer. + + `forge fmt` should work out-of-the-box. You can further configure it using + `foundry.toml`. See the corresponding documentation for detailed + instructions (https://book.getfoundry.sh/reference/config/formatter). =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: - diff --git a/sources_non_forked/ale/doc/ale-sql.txt b/sources_non_forked/ale/doc/ale-sql.txt index f9bc6ac2..225ac7df 100644 --- a/sources_non_forked/ale/doc/ale-sql.txt +++ b/sources_non_forked/ale/doc/ale-sql.txt @@ -3,7 +3,14 @@ ALE SQL Integration *ale-sql-options* =============================================================================== -pgformatter *ale-sql-pgformatter* +dprint *ale-sql-dprint* + +See |ale-dprint-options| +and https://github.com/dprint/dprint-plugin-sql/releases + + +=============================================================================== +pgformatter *ale-sql-pgformatter* g:ale_sql_pgformatter_executable *g:ale_sql_pgformatter_executable* *b:ale_sql_pgformatter_executable* @@ -20,6 +27,27 @@ g:ale_sql_pgformatter_options *g:ale_sql_pgformatter_options* This variable can be set to pass additional options to the pgformatter fixer. +=============================================================================== +sqlfluff *ale-sql-sqlfluff* + +g:ale_sql_sqlfluff_executable *g:ale_sql_sqlfluff_executable* + *b:ale_sql_sqlfluff_executable* + Type: |String| + Default: `'sqlfluff'` + + This variable sets executable used for sqlfluff. + +g:ale_sql_sqlfluff_options *g:ale_sql_sqlfluff_options* + *b:ale_sql_sqlfluff_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the sqlfluff linter. + + +=============================================================================== + + =============================================================================== sqlfmt *ale-sql-sqlfmt* @@ -39,5 +67,23 @@ g:ale_sql_sqlfmt_options *g:ale_sql_sqlfmt_options* At this time only the -u flag is available to format with upper-case. +=============================================================================== +sqlformat *ale-sql-sqlformat* + +g:ale_sql_sqlformat_executable *g:ale_sql_sqlformat_executable* + *b:ale_sql_sqlformat_executable* + Type: |String| + Default: `'sqlformat'` + + This variable sets executable used for sqlformat. + +g:ale_sql_sqlformat_options *g:ale_sql_sqlformat_options* + *b:ale_sql_sqlformat_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the sqlformat fixer. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt b/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt index 37345f7b..ee225b72 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 @@ -13,14 +13,23 @@ Notes: `!!` These linters check only files on disk. See |ale-lint-file-linters| * Ada + * `ada_language_server` + * `cspell` * `gcc` * `gnatpp` * Ansible - * `ansible-lint` + * `ansible-language-server` + * `ansible-lint`!! * API Blueprint * `drafter` +* APKBUILD + * `apkbuild-fixer` + * `apkbuild-lint` + * `secfixes-check` * AsciiDoc - * `alex`!! + * `alex` + * `cspell` + * `languagetool`!! * `proselint` * `redpen` * `textlint` @@ -28,60 +37,91 @@ Notes: * `write-good` * ASM * `gcc` + * `llvm-mc` +* Astro + * `eslint` + * `prettier` +* AVRA + * `avra` * Awk * `gawk` * Bash + * `bashate` + * `cspell` * `language-server` * `shell` (-n flag) * `shellcheck` * `shfmt` +* Bats + * `shellcheck` +* Bazel + * `buildifier` * BibTeX * `bibclean` +* Bicep + * `bicep` +* BitBake + * `oelint-adv` * Bourne Shell * `shell` (-n flag) * `shellcheck` * `shfmt` * C + * `astyle` * `ccls` - * `clang` - * `clangd` + * `clang` (`cc`) * `clang-format` + * `clangcheck`!! + * `clangd` * `clangtidy`!! * `cppcheck` * `cpplint`!! * `cquery` + * `cspell` * `flawfinder` - * `gcc` + * `gcc` (`cc`) * `uncrustify` * C# + * `clang-format` * `csc`!! + * `cspell` + * `dotnet-format` * `mcs` * `mcsc`!! * `uncrustify` * C++ (filetype cpp) + * `astyle` * `ccls` - * `clang` + * `clang` (`cc`) + * `clang-format` * `clangcheck`!! * `clangd` - * `clang-format` * `clangtidy`!! * `clazy`!! * `cppcheck` * `cpplint`!! * `cquery` + * `cspell` * `flawfinder` - * `gcc` + * `gcc` (`cc`) * `uncrustify` +* C3 + * `c3lsp` +* Cairo + * `scarb`!! + * `starknet` * Chef * `cookstyle` - * `foodcritic` + * `foodcritic`!! * Clojure * `clj-kondo` + * `cljfmt` * `joker` * CloudFormation * `cfn-python-lint` * CMake * `cmake-format` + * `cmake-lint` * `cmakelint` * CoffeeScript * `coffee` @@ -90,6 +130,9 @@ Notes: * `ameba`!! * `crystal`!! * CSS + * `VSCode CSS language server` + * `cspell` + * `css-beautify` * `csslint` * `fecs` * `prettier` @@ -97,44 +140,68 @@ Notes: * Cucumber * `cucumber` * CUDA + * `clang-format` + * `clangd` * `nvcc`!! * Cypher * `cypher-lint` * Cython (pyrex filetype) * `cython` * D + * `dfmt` * `dls` * `dmd` * `uncrustify` * Dafny * `dafny`!! * Dart - * `dartanalyzer`!! + * `analysis_server` + * `dart-analyze`!! + * `dart-format`!! * `dartfmt`!! * `language_server` +* desktop + * `desktop-file-validate` +* Dhall + * `dhall-format` + * `dhall-freeze` + * `dhall-lint` * Dockerfile * `dockerfile_lint` + * `dockerlinter` + * `dprint` * `hadolint` * Elixir * `credo` + * `cspell` * `dialyxir` - * `dogma` + * `dogma`!! * `elixir-ls` + * `lexical` * `mix`!! * Elm * `elm-format` - * `elm-lsp` + * `elm-ls` * `elm-make` * Erb * `erb` + * `erb-formatter` + * `erblint` * `erubi` * `erubis` + * `htmlbeautifier` * `ruumba` * Erlang - * `erlc` * `SyntaxErl` + * `dialyzer`!! + * `elvis`!! + * `erlang-mode` (The Erlang mode for Emacs) + * `erlang_ls` + * `erlc` + * `erlfmt` * Fish * `fish` (-n flag) + * `fish_indent` * Fortran * `gcc` * `language_server` @@ -144,28 +211,37 @@ Notes: * `fusion-lint` * Git Commit Messages * `gitlint` +* Gleam + * `gleam_format` + * `gleamlsp` * GLSL - * glslang + * `glslang` * `glslls` * Go * `bingo` + * `cspell` * `go build`!! + * `go mod`!! + * `go vet`!! * `gofmt` + * `gofumpt` * `goimports` * `golangci-lint`!! * `golangserver` - * `golint` - * `gometalinter`!! - * `go mod`!! + * `golines` * `gopls` * `gosimple`!! * `gotype`!! - * `go vet`!! + * `revive`!! * `staticcheck`!! +* Go HTML Templates + * djlint * GraphQL * `eslint` * `gqlint` * `prettier` +* Groovy + * `npm-groovy-lint` * Hack * `hack` * `hackfmt` @@ -173,11 +249,14 @@ Notes: * Haml * `haml-lint` * Handlebars + * djlint * `ember-template-lint` * Haskell * `brittany` * `cabal-ghc` + * `cspell` * `floskell` + * `fourmolu` * `ghc` * `ghc-mod` * `hdevtools` @@ -185,32 +264,61 @@ Notes: * `hie` * `hindent` * `hlint` + * `hls` + * `ormolu` * `stack-build`!! * `stack-ghc` * `stylish-haskell` * HCL + * `packer-fmt` * `terraform-fmt` * HTML - * `alex`!! + * `VSCode HTML language server` + * `alex` + * `angular` + * `cspell` + * djlint + * `eslint` * `fecs` - * `HTMLHint` + * `html-beautify` + * `htmlhint` * `prettier` * `proselint` + * `rustywind` * `tidy` * `write-good` +* HTML Angular + * djlint +* HTML Django + * djlint +* HTTP + * kulala_fmt +* Hurl + * `hurlfmt` * Idris * `idris` +* Ink + * `ink-language-server` +* Inko + * `inko` !! * ISPC * `ispc`!! * Java - * `checkstyle` + * `PMD` + * `checkstyle`!! + * `clang-format` + * `cspell` * `eclipselsp` * `google-java-format` * `javac` * `javalsp` - * `PMD` * `uncrustify` * JavaScript + * `biome` + * `clang-format` + * `cspell` + * `deno` + * `dprint` * `eslint` * `fecs` * `flow` @@ -222,20 +330,39 @@ Notes: * `standard` * `tsserver` * `xo` +* Jinja + * djlint * JSON + * `VSCode JSON language server` + * `biome` + * `clang-format` + * `cspell` + * `dprint` + * `eslint` * `fixjson` * `jq` + * `json.tool` * `jsonlint` * `prettier` + * `spectral` +* JSON5 + * `eslint` +* JSONC + * `biome` + * `eslint` +* Jsonnet + * `jsonnet-lint` + * `jsonnetfmt` * Julia * `languageserver` * Kotlin * `kotlinc`!! - * `ktlint`!! + * `ktlint` * `languageserver` * LaTeX (tex) - * `alex`!! + * `alex` * `chktex` + * `cspell` * `lacheck` * `proselint` * `redpen` @@ -250,22 +377,32 @@ Notes: * LLVM * `llc` * Lua + * `cspell` + * `lua-format` + * `lua-language-server` * `luac` * `luacheck` + * `luafmt` + * `selene` + * `stylua` * Mail - * `alex`!! + * `alex` * `languagetool`!! * `proselint` * `vale` * Make * `checkmake` * Markdown - * `alex`!! + * `alex` + * `cspell` * `languagetool`!! * `markdownlint`!! + * `marksman` * `mdl` + * `pandoc` * `prettier` * `proselint` + * `pymarkdown` * `redpen` * `remark-lint` * `textlint` @@ -277,17 +414,30 @@ Notes: * `mmc`!! * NASM * `nasm`!! +* Nickel + * `nickel_format` * Nim * `nim check`!! + * `nimlsp` + * `nimpretty` * nix + * `alejandra` + * `deadnix` * `nix-instantiate` + * `nixfmt` + * `nixpkgs-fmt` + * `rnix-lsp` + * `statix` * nroff - * `alex`!! + * `alex` * `proselint` * `write-good` +* Nunjucks + * djlint * Objective-C * `ccls` * `clang` + * `clang-format` * `clangd` * `uncrustify` * Objective-C++ @@ -295,10 +445,25 @@ Notes: * `clangd` * `uncrustify` * OCaml + * `dune` * `merlin` (see |ale-ocaml-merlin|) * `ocamlformat` + * `ocamllsp` * `ocp-indent` * `ols` +* Odin + * `ols` +* OpenApi + * `ibm_validator` + * `prettier` + * `yamllint` +* OpenSCAD + * `SCA2D` + * `scadformat` +* Packer + * `packer-fmt-fixer` +* Pascal + * `ptop` * Pawn * `uncrustify` * Perl @@ -308,33 +473,43 @@ Notes: * Perl6 * `perl6 -c` * PHP + * `cspell` + * `intelephense` * `langserver` * `phan` + * `php -l` + * `php-cs-fixer` + * `phpactor` * `phpcbf` * `phpcs` - * `php-cs-fixer` - * `php -l` * `phpmd` * `phpstan` + * `pint` * `psalm`!! + * `tlint` * PO - * `alex`!! + * `alex` * `msgfmt` * `proselint` * `write-good` * Pod - * `alex`!! + * `alex` * `proselint` * `write-good` * Pony * `ponyc` * PowerShell + * `cspell` * `powershell` * `psscriptanalyzer` * Prolog * `swipl` * proto - * `protoc-gen-lint` + * `buf-format`!! + * `buf-lint`!! + * `clang-format` + * `protoc-gen-lint`!! + * `protolint`!! * Pug * `pug-lint` * Puppet @@ -343,69 +518,107 @@ Notes: * `puppet-lint` * PureScript * `purescript-language-server` + * `purs-tidy` + * `purty` * Python + * `autoflake`!! + * `autoimport` * `autopep8` * `bandit` * `black` + * `cspell` * `flake8` + * `flakehell` * `isort` * `mypy` - * `prospector` + * `prospector`!! + * `pycln` * `pycodestyle` * `pydocstyle` * `pyflakes` + * `pyflyby` * `pylama`!! * `pylint`!! - * `pyls` + * `pylsp` * `pyre` + * `pyright` + * `refurb` * `reorder-python-imports` + * ruff + * ruff-format + * `unimport` * `vulture`!! * `yapf` * QML * `qmlfmt` * `qmllint` * R + * `languageserver` * `lintr` * `styler` * Racket + * `racket-langserver` * `raco` + * `raco_fmt` +* Re:VIEW + * `redpen` * ReasonML * `merlin` * `ols` * `reason-language-server` * `refmt` +* Rego + * `cspell` + * `opacheck` + * `opafmt` +* REST + * kulala_fmt * reStructuredText - * `alex`!! + * `alex` + * `cspell` * `proselint` * `redpen` * `rstcheck` * `textlint` * `vale` * `write-good` -* Re:VIEW - * `redpen` +* Robot + * `rflint` * RPM spec * `rpmlint` * Ruby - * `brakeman` + * `brakeman`!! + * `cspell` + * `debride` + * `packwerk`!! + * `prettier` * `rails_best_practices`!! * `reek` * `rubocop` * `ruby` + * `rubyfmt` * `rufo` * `solargraph` * `sorbet` * `standardrb` + * `steep` + * `syntax_tree` * Rust * `cargo`!! + * `cspell` * `rls` + * `rust-analyzer` * `rustc` (see |ale-integration-rust|) * `rustfmt` +* Salt + * `salt-lint` * Sass * `sass-lint` * `stylelint` * Scala + * `cspell` * `fsc` + * `metals` * `sbtserver` * `scalac` * `scalafmt` @@ -420,31 +633,51 @@ Notes: * SML * `smlnj` * Solidity + * `forge` + * `solc` * `solhint` * `solium` * SQL + * `dprint` * `pgformatter` + * `sql-lint` + * `sqlfluff` * `sqlfmt` + * `sqlformat` * `sqlint` * Stylus * `stylelint` * SugarSS * `stylelint` +* Svelte + * `prettier` + * `svelteserver` * Swift + * Apple `swift-format` + * `cspell` * `sourcekit-lsp` * `swiftformat` * `swiftlint` +* systemd + * `systemd-analyze`!! * Tcl * `nagelfar`!! * Terraform - * `fmt` + * `checkov` + * `terraform` + * `terraform-fmt-fixer` + * `terraform-ls` + * `terraform-lsp` * `tflint` + * `tfsec` * Texinfo - * `alex`!! + * `alex` + * `cspell` * `proselint` * `write-good` * Text^ - * `alex`!! + * `alex` + * `cspell` * `languagetool`!! * `proselint` * `redpen` @@ -453,42 +686,84 @@ Notes: * `write-good` * Thrift * `thrift` + * `thriftcheck` +* TOML + * `dprint` * TypeScript + * `biome` + * `cspell` + * `deno` + * `dprint` * `eslint` * `fecs` * `prettier` + * `standard` * `tslint` * `tsserver` * `typecheck` +* Typst + * `typstyle` +* V + * `v`!! + * `vfmt` * VALA * `uncrustify` + * `vala_lint`!! * Verilog + * `hdl-checker` * `iverilog` + * slang * `verilator` * `vlog` * `xvlog` + * `yosys`!! * VHDL * `ghdl` * `vcom` * `xvhdl` * Vim + * `vimls` * `vint` * Vim help^ - * `alex`!! + * `alex` * `proselint` * `write-good` * Vue + * `cspell` * `prettier` * `vls` + * `volar` +* WGSL + * `naga` * XHTML - * `alex`!! + * `alex` + * `cspell` * `proselint` * `write-good` * XML * `xmllint` * YAML + * `actionlint` + * `circleci`!! + * `gitlablint` * `prettier` + * `spectral` * `swaglint` + * `yaml-language-server` + * `yamlfix` + * `yamlfmt` * `yamllint` + * `yq` * YANG * `yang-lsp` +* Yara + * `yls` +* Zeek + * `zeek`!! +* Zig + * `zigfmt` + * `zlint` + * `zls` + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-svelte.txt b/sources_non_forked/ale/doc/ale-svelte.txt new file mode 100644 index 00000000..92f109f7 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-svelte.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE Svelte Integration *ale-svelte-options* + + +=============================================================================== +prettier *ale-svelte-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +svelteserver *ale-svelte-svelteserver* + +g:ale_svelte_svelteserver_executable *g:ale_svelte_svelteserver_executable* + *b:ale_svelte_svelteserver_executable* + Type: |String| + Default: `'svelteserver'` + + See |ale-integrations-local-executables| + + +g:ale_svelte_svelteserver_use_global *g:ale_svelte_svelteserver_use_global* + *b:ale_svelte_svelteserver_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-swift.txt b/sources_non_forked/ale/doc/ale-swift.txt index 8fa0c06c..a443eab8 100644 --- a/sources_non_forked/ale/doc/ale-swift.txt +++ b/sources_non_forked/ale/doc/ale-swift.txt @@ -2,6 +2,52 @@ ALE Swift Integration *ale-swift-options* +=============================================================================== +apple-swift-format *ale-swift-apple-swift-format* + +There are 3 options to enable linting and fixing with Apple's swift-format: + +1. Install the local executable in your path, as described here: + https://github.com/apple/swift-format +2. Install the executable via your OS package manager, for instance via + Homebrew with `brew install swift-format` +3. Your Swift project has a dependency on the swift-format package, so it can + be run with `swift run swift-format lint ...` In this case, you need to set + a variable, see |g:ale_swift_appleswiftformat_use_swiftpm|. + +Additionally, ALE tries to locate and use the nearest existing `.swift-format` +configuration file. + + +g:ale_swift_appleswiftformat_executable + *g:ale_swift_appleswiftformat_executable* + *b:ale_swift_appleswiftformat_executable* + Type: |String| + Default: `'swift-format'` + + This variable can be modified to change the executable path for + `swift-format`. + + +g:ale_swift_appleswiftformat_use_swiftpm + *g:ale_swift_appleswiftformat_use_swiftpm* + *b:ale_swift_appleswiftformat_use_swiftpm* + Type: |Number| + Default: `0` + + When set to `1`, this option will cause ALE to use + `swift run swift-format lint ...` instead of the global executable. Use this + option if your Swift project has a dependency on the swift-format package. + + See |ale-integrations-local-executables| + + +=============================================================================== +cspell *ale-swift-cspell* + +See |ale-cspell-options| + + =============================================================================== sourcekitlsp *ale-swift-sourcekitlsp* @@ -16,6 +62,6 @@ g:ale_sourcekit_lsp_executable *g:ale_sourcekit_lsp_executable* See |ale-integrations-local-executables| + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: - diff --git a/sources_non_forked/ale/doc/ale-systemd.txt b/sources_non_forked/ale/doc/ale-systemd.txt new file mode 100644 index 00000000..13c7037f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-systemd.txt @@ -0,0 +1,14 @@ +=============================================================================== +ALE systemd Integration *ale-systemd-options* + + +=============================================================================== +systemd-analyze *ale-systemd-analyze* + +ALE supports checking user systemd units with `systemd-analyze --user verify` +Checks will only work with user unit files in their proper location. There +aren't any options, and checks can only run after saving the file. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-terraform.txt b/sources_non_forked/ale/doc/ale-terraform.txt index 387fd732..91a7dd16 100644 --- a/sources_non_forked/ale/doc/ale-terraform.txt +++ b/sources_non_forked/ale/doc/ale-terraform.txt @@ -2,6 +2,25 @@ ALE Terraform Integration *ale-terraform-options* +=============================================================================== +checkov *ale-terraform-checkov* + +g:ale_terraform_checkov_executable *g:ale_terraform_checkov_executable* + *b:ale_terraform_checkov_executable* + + Type: |String| + Default: `'checkov'` + + This variable can be changed to use a different executable for checkov. + + +g:ale_terraform_checkov_options *g:ale_terraform_checkov_options* + *b:ale_terraform_checkov_options* + Type: |String| + Default: `''` + + This variable can be changed to set additional options for checkov. + =============================================================================== terraform-fmt-fixer *ale-terraform-fmt-fixer* @@ -32,6 +51,47 @@ g:ale_terraform_terraform_executable *g:ale_terraform_terraform_executable* This variable can be changed to use a different executable for terraform. +=============================================================================== +terraform-ls *ale-terraform-terraform-ls* + +Official terraform language server. More stable than *terraform-lsp* but +currently has less features. + +g:ale_terraform_ls_executable *g:ale_terraform_ls_executable* + *b:ale_terraform_ls_executable* + Type: |String| + Default: `'terraform-ls'` + + This variable can be changed to use a different executable for terraform-ls. + + +g:ale_terraform_ls_options *g:ale_terraform_ls_options* + *b:ale_terraform_ls_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to terraform-ls. + + +=============================================================================== +terraform-lsp *ale-terraform-terraform-lsp* + +g:ale_terraform_langserver_executable *g:ale_terraform_langserver_executable* + *b:ale_terraform_langserver_executable* + Type: |String| + Default: `'terraform-lsp'` + + This variable can be changed to use a different executable for terraform-lsp. + + +g:ale_terraform_langserver_options *g:ale_terraform_langserver_options* + *b:ale_terraform_langserver_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to terraform-lsp. + + =============================================================================== tflint *ale-terraform-tflint* @@ -54,6 +114,25 @@ g:ale_terraform_tflint_options *g:ale_terraform_tflint_options* to include '-f json' in your new value. +=============================================================================== +tfsec *ale-terraform-tfsec* + +g:ale_terraform_tfsec_executable *g:ale_terraform_tfsec_executable* + *b:ale_terraform_tfsec_executable* + + Type: |String| + Default: `'tfsec'` + + This variable can be changed to use a different executable for tfsec. + +g:ale_terraform_tfsec_options *g:ale_terraform_tfsec_options* + *b:ale_terraform_tfsec_options* + + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to tfsec. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-tex.txt b/sources_non_forked/ale/doc/ale-tex.txt index ceb9fa81..fa0d827e 100644 --- a/sources_non_forked/ale/doc/ale-tex.txt +++ b/sources_non_forked/ale/doc/ale-tex.txt @@ -21,23 +21,28 @@ g:ale_tex_chktex_options *g:ale_tex_chktex_options* This variable can be changed to modify flags given to chktex. ------------------------------------------------------------------------------- +=============================================================================== +cspell *ale-tex-cspell* + +See |ale-cspell-options| + + +=============================================================================== lacheck *ale-tex-lacheck* g:ale_lacheck_executable *g:ale_lacheck_executable* *b:ale_lacheck_executable* Type: |String| - Default: '`lacheck`' + Default: `'lacheck'` This variable can be changed to change the path to lacheck. - =============================================================================== -latexindent *ale-tex-latexindent* +latexindent *ale-tex-latexindent* -g:ale_tex_latexindent_executable *g:ale_tex_latexindent_executable* - *b:ale_tex_latexindent_executable* +g:ale_tex_latexindent_executable *g:ale_tex_latexindent_executable* + *b:ale_tex_latexindent_executable* Type: |String| Default: `'latexindent'` @@ -52,26 +57,39 @@ g:ale_tex_latexindent_options *g:ale_tex_latexindent_options* This variable can be changed to modify flags given to latexindent. - =============================================================================== -texlab *ale-tex-texlab* +texlab *ale-tex-texlab* -g:ale_tex_texlab_executable *g:ale_tex_texlab_executable* - *b:ale_tex_texlab_executable* +g:ale_tex_texlab_executable *g:ale_tex_texlab_executable* + *b:ale_tex_texlab_executable* Type: |String| Default: `'texlab'` This variable can be changed to change the path to texlab. -g:ale_tex_texlab_options *g:ale_tex_texlab_options* - *b:ale_tex_texlab_options* +g:ale_tex_texlab_options *g:ale_tex_texlab_options* + *b:ale_tex_texlab_options* Type: |String| Default: `''` - This variable can be changed to modify flags given to texlab. + This variable can be changed to modify flags given to texlab command. +g:ale_tex_texlab_config *g:ale_tex_texlab_config* + *b:ale_tex_texlab_config* + Type: |Dictionary| + Default: `{}` + Dictionary containing LSP configuration settings used to initialize texlab + language server. Refer to texlab documentation for possible settings: + + https://github.com/latex-lsp/texlab/blob/master/docs/options.md + + For example to set build onSave initialization setting: + +> + let g:ale_tex_texlab_config = {"build":{"onSave":v:true}} +< =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-texinfo.txt b/sources_non_forked/ale/doc/ale-texinfo.txt index f8ed342d..53d42b69 100644 --- a/sources_non_forked/ale/doc/ale-texinfo.txt +++ b/sources_non_forked/ale/doc/ale-texinfo.txt @@ -2,6 +2,12 @@ ALE Texinfo Integration *ale-texinfo-options* +=============================================================================== +cspell *ale-texinfo-cspell* + +See |ale-cspell-options| + + =============================================================================== write-good *ale-texinfo-write-good* @@ -9,4 +15,4 @@ See |ale-write-good-options| =============================================================================== -vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-text.txt b/sources_non_forked/ale/doc/ale-text.txt index 913d7e61..4e4d0b2e 100644 --- a/sources_non_forked/ale/doc/ale-text.txt +++ b/sources_non_forked/ale/doc/ale-text.txt @@ -2,6 +2,12 @@ ALE Text Integration *ale-text-options* +============================================================================== +cspell *ale-text-cspell* + +See |ale-cspell-options| + + =============================================================================== textlint *ale-text-textlint* @@ -39,4 +45,4 @@ See |ale-write-good-options| =============================================================================== -vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-thrift.txt b/sources_non_forked/ale/doc/ale-thrift.txt index bb2ec058..810127b4 100644 --- a/sources_non_forked/ale/doc/ale-thrift.txt +++ b/sources_non_forked/ale/doc/ale-thrift.txt @@ -42,5 +42,24 @@ g:ale_thrift_thrift_options *g:ale_thrift_thrift_options* This variable can be changed to customize the additional command-line arguments that are passed to the thrift compiler. +=============================================================================== +thriftcheck *ale-thrift-thriftcheck* + +g:ale_thrift_thriftcheck_executable *g:ale_thrift_thriftcheck_executable* + *b:ale_thrift_thriftcheck_executable* + Type: |String| + Default: `'thriftcheck'` + + See |ale-integrations-local-executables| + + +g:ale_thrift_thriftcheck_options *g:ale_thrift_thriftcheck_options* + *b:ale_thrift_thriftcheck_options* + Type: |String| + Default: `''` + + This variable can be changed to customize the additional command-line + arguments that are passed to thriftcheck. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-toml.txt b/sources_non_forked/ale/doc/ale-toml.txt new file mode 100644 index 00000000..222a91f4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-toml.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE TOML Integration *ale-toml-options* + + +=============================================================================== +dprint *ale-toml-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/toml + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-typescript.txt b/sources_non_forked/ale/doc/ale-typescript.txt index 7dc59820..22fbe7b4 100644 --- a/sources_non_forked/ale/doc/ale-typescript.txt +++ b/sources_non_forked/ale/doc/ale-typescript.txt @@ -2,6 +2,110 @@ 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* + +See |ale-cspell-options| + + +=============================================================================== +deno *ale-typescript-deno* + +Starting from version 1.6.0, Deno comes with its own language server. Earlier +versions are not supported. + +g:ale_deno_executable *g:ale_deno_executable* + *b:ale_deno_executable* + Type: |String| + Default: `'deno'` + + +g:ale_deno_lsp_project_root *g:ale_deno_lsp_project_root* + *b:ale_deno_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 tsconfig.json. + 2. Find an ancestor directory containing a .git folder. + 3. Use the directory of the current buffer (if the buffer was opened from + a file). + + +g:ale_deno_unstable *g:ale_deno_unstable* + *b:ale_deno_unstable* + Type: |Number| + Default: `0` + + Enable or disable unstable Deno features and APIs. + + +g:ale_deno_import_map *g:ale_deno_import_map* + *b:ale_deno_import_map* + Type: |String| + Default: `'import_map.json'` + + Specify the import map filename to load url maps in a deno project. + + +=============================================================================== +dprint *ale-typescript-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/typescript + + =============================================================================== eslint *ale-typescript-eslint* @@ -16,6 +120,33 @@ prettier *ale-typescript-prettier* See |ale-javascript-prettier| for information about the available options. +=============================================================================== +standard *ale-typescript-standard* + +g:ale_typescript_standard_executable *g:ale_typescript_standard_executable* + *b:ale_typescript_standard_executable* + Type: |String| + Default: `'standard'` + + See |ale-integrations-local-executables| + + +g:ale_typescript_standard_options *g:ale_typescript_standard_options* + *b:ale_typescript_standard_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to standard. + + +g:ale_typescript_standard_use_global *g:ale_typescript_standard_use_global* + *b:ale_typescript_standard_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== tslint *ale-typescript-tslint* @@ -111,5 +242,32 @@ g:ale_typescript_tsserver_use_global *g:ale_typescript_tsserver_use_global* tsserver in node_modules. +=============================================================================== +xo *ale-typescript-xo* + +g:ale_typescript_xo_executable *g:ale_typescript_xo_executable* + *b:ale_typescript_xo_executable* + Type: |String| + Default: `'xo'` + + See |ale-integrations-local-executables| + + +g:ale_typescript_xo_options *g:ale_typescript_xo_options* + *b:ale_typescript_xo_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to xo. + + +g:ale_typescript_xo_use_global *g:ale_typescript_xo_use_global* + *b:ale_typescript_xo_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-typst.html b/sources_non_forked/ale/doc/ale-typst.html new file mode 100644 index 00000000..45a94960 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-typst.html @@ -0,0 +1,24 @@ +=============================================================================== +ALE Typst Integration *ale-typst-options* + +=============================================================================== +typstyle *ale-typst-typstyle* + +g:ale_typst_typstyle_executable *g:ale_typst_typstyle_executable* + *b:ale_typst_typstyle_executable* + Type: |String| + Default: `'typstyle'` + + See |ale-integrations-local-executables| + + +g:ale_typst_typstyle_options *g:ale_typst_typstyle_options* + *b:ale_typst_typstyle_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to typstyle. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-v.txt b/sources_non_forked/ale/doc/ale-v.txt new file mode 100644 index 00000000..8c641447 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-v.txt @@ -0,0 +1,45 @@ +=============================================================================== +ALE V Integration *ale-v-options* + + +=============================================================================== +Integration Information + +`v` is V's build tool. `vfmt` (called as `v fmt` from the same +executable that does the builds) is the autoformatter/fixer. + +g:ale_v_v_executable *g:ale_v_v_executable* + *b:ale_v_v_executable* + + Type: |String| + Default: `'v'` + + The executable that will be run for the `v` linter and the `vfmt` fixer. + + +=============================================================================== +v *ale-v-v* + +g:ale_v_v_options *g:ale_v_v_options* + *b:ale_v_v_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the v linter. + They are injected directly after "v .". + + +=============================================================================== +vfmt *ale-v-vfmt* + +g:ale_v_vfmt_options *g:ale_v_vfmt_options* + *b:ale_v_vfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the vfmt fixer. + They are injected directly after "v fmt". + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-vala.txt b/sources_non_forked/ale/doc/ale-vala.txt index ca24bcf4..d48f68bb 100644 --- a/sources_non_forked/ale/doc/ale-vala.txt +++ b/sources_non_forked/ale/doc/ale-vala.txt @@ -8,5 +8,26 @@ uncrustify *ale-vala-uncrustify* See |ale-c-uncrustify| for information about the available options. +=============================================================================== +Vala-Lint *ale-vala-vala-lint* + +g:vala_vala_lint_executable *g:vala_vala_lint_executable* + *b:vala_vala_lint_executable* + Type: |String| + Default: `'io.elementary.vala-lint'` + + This variable can be set to specify a Vala-Lint executable file. + + +g:vala_vala_lint_config_filename *g:vala_vala_lint_config_filename* + *b:vala_vala_lint_config_filename* + Type: |String| + Default: `'vala-lint.conf'` + + This variable can be set to specify a Vala-Lint config filename. When a file + with the specified name was not found or this variable was set to empty, + Vala-Lint will be executed without specifying a config filename. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-verilog.txt b/sources_non_forked/ale/doc/ale-verilog.txt index 94b820b8..83e4f31e 100644 --- a/sources_non_forked/ale/doc/ale-verilog.txt +++ b/sources_non_forked/ale/doc/ale-verilog.txt @@ -3,11 +3,17 @@ ALE Verilog/SystemVerilog Integration *ale-verilog-options* =============================================================================== -ALE can use four different linters for Verilog HDL: +ALE can use seven different linters for Verilog HDL: + + HDL Checker + Using `hdl_checker --lsp` iverilog: Using `iverilog -t null -Wall` + slang: + Using `slang -Weverything` + verilator Using `verilator --lint-only -Wall` @@ -17,6 +23,9 @@ ALE can use four different linters for Verilog HDL: Vivado Using `xvlog` + Yosys + Using `yosys -Q -T -p 'read_verilog'` + By default, both 'verilog' and 'systemverilog' filetypes are checked. You can limit 'systemverilog' files to be checked using only 'verilator' by @@ -26,6 +35,9 @@ defining 'g:ale_linters' variable: \ let g:ale_linters = {'systemverilog' : ['verilator'],} < +=============================================================================== +General notes + Linters/compilers that utilize a "work" directory for analyzing designs- such as ModelSim and Vivado- can be passed the location of these directories as part of their respective option strings listed below. This is useful for @@ -40,11 +52,30 @@ changing. This can happen in the form of hangs or crashes. To help prevent this when using these linters, it may help to run linting less frequently; for example, only when a file is saved. +HDL Checker is an alternative for some of the issues described above. It wraps +around ghdl, Vivado and ModelSim/Questa and, when using the latter, it can +handle mixed language (VHDL, Verilog, SystemVerilog) designs. + +=============================================================================== +hdl-checker *ale-verilog-hdl-checker* + +See |ale-vhdl-hdl-checker| + + =============================================================================== 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* @@ -54,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. @@ -98,5 +129,26 @@ g:ale_verilog_xvlog_options *g:ale_verilog_xvlog_options* This variable can be changed to modify the flags/options passed to 'xvlog'. +=============================================================================== +yosys *ale-verilog-yosys* + +g:ale_verilog_yosys_executable *g:ale_verilog_yosys_executable* + *b:ale_verilog_yosys_executable* + Type: |String| + Default: `'yosys'` + + This variable can be changed to the path to the 'yosys' executable. + + +g:ale_verilog_yosys_options *g:ale_verilog_yosys_options* + *b:ale_verilog_yosys_options* + Type: |String| + Default: `'-Q -T -p ''read_verilog %s'''` + + This variable can be changed to modify the flags/options passed to 'yosys'. + By default, Yosys is an interactive program. To obtain linting functionality, + the `'read_verilog'` command is used. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-vhdl.txt b/sources_non_forked/ale/doc/ale-vhdl.txt index 3fea947d..c2870240 100644 --- a/sources_non_forked/ale/doc/ale-vhdl.txt +++ b/sources_non_forked/ale/doc/ale-vhdl.txt @@ -3,10 +3,10 @@ ALE VHDL Integration *ale-vhdl-options* =============================================================================== -ALE can use three different linters for VHDL: +ALE can use four different linters for VHDL: - iverilog: - Using `iverilog -t null -Wall` + ghdl: + Using `ghdl --std=08` ModelSim/Questa Using `vcom -2008 -quiet -lint` @@ -14,8 +14,15 @@ ALE can use three different linters for VHDL: Vivado Using `xvhdl --2008` -Note all linters default to VHDL-2008 support. This, and other options, can be -changed with each linter's respective option variable. + HDL Checker + Using `hdl_checker --lsp` + +=============================================================================== +General notes + +ghdl, ModelSim/Questa and Vivado linters default to VHDL-2008 support. This, +and other options, can be changed with each linter's respective option +variable. Linters/compilers that utilize a "work" directory for analyzing designs- such as ModelSim and Vivado- can be passed the location of these directories as @@ -31,6 +38,10 @@ changing. This can happen in the form of hangs or crashes. To help prevent this when using these linters, it may help to run linting less frequently; for example, only when a file is saved. +HDL Checker is an alternative for some of the issues described above. It wraps +around ghdl, Vivado and ModelSim/Questa and, when using the latter, it can +handle mixed language (VHDL, Verilog, SystemVerilog) designs. + =============================================================================== ghdl *ale-vhdl-ghdl* @@ -50,6 +61,60 @@ g:ale_vhdl_ghdl_options *g:ale_vhdl_ghdl_options* This variable can be changed to modify the flags/options passed to 'ghdl'. +=============================================================================== +hdl-checker *ale-vhdl-hdl-checker* + +HDL Checker is a wrapper for VHDL/Verilg/SystemVerilog tools that aims to +reduce the boilerplate code needed to set things up. It can automatically +infer libraries for VHDL sources, determine the compilation order and provide +some static checks. + +You can install it using pip: +> + $ pip install hdl-checker + +`hdl-checker` will be run from a detected project root, determined by the +following methods, in order: + +1. Find the first directory containing a configuration file (see + |g:ale_hdl_checker_config_file|) +2. If no configuration file can be found, find the first directory containing + a folder named `'.git' +3. If no such folder is found, use the directory of the current buffer + + +g:ale_hdl_checker_executable + *g:ale_hdl_checker_executable* + *b:ale_hdl_checker_executable* + Type: |String| + Default: `'hdl_checker'` + + This variable can be changed to the path to the 'hdl_checker' executable. + + +g:ale_hdl_checker_options *g:ale_hdl_checker_options* + *b:ale_hdl_checker_options* + Type: |String| + Default: `''` + + This variable can be changed to modify the flags/options passed to the + 'hdl_checker' server startup command. + + +g:ale_hdl_checker_config_file *g:ale_hdl_checker_config_file* + *b:ale_hdl_checker_config_file* + Type: |String| + Default: `'.hdl_checker.config'` (Unix), + `'_hdl_checker.config'` (Windows) + + This variable can be changed to modify the config file HDL Checker will try + to look for. It will also affect how the project's root directory is + determined (see |ale-vhdl-hdl-checker|). + + More info on the configuration file format can be found at: + https://github.com/suoto/hdl_checker/wiki/Setting-up-a-project + + =============================================================================== vcom *ale-vhdl-vcom* diff --git a/sources_non_forked/ale/doc/ale-vim.txt b/sources_non_forked/ale/doc/ale-vim.txt index 772bad23..f85b43eb 100644 --- a/sources_non_forked/ale/doc/ale-vim.txt +++ b/sources_non_forked/ale/doc/ale-vim.txt @@ -2,6 +2,61 @@ ALE Vim Integration *ale-vim-options* +=============================================================================== +vimls *ale-vim-vimls* + + The `vim-language-server` is the engine that powers VimL editor support + using the Language Server Protocol. See the installation instructions: + https://github.com/iamcco/vim-language-server#install + +g:ale_vim_vimls_executable *g:ale_vim_vimls_executable* + *b:ale_vim_vimls_executable* + Type: |String| + Default: `'vim-language-server'` + + This option can be set to change the executable path for vimls. + + +g:ale_vim_vimls_config *g:ale_vim_vimls_config* + *b:ale_vim_vimls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. For example: > + { + \ 'vim': { + \ 'iskeyword': '@,48-57,_,192-255,-#', + \ 'vimruntime': '', + \ 'runtimepath': '', + \ 'diagnostic': { + \ 'enable': v:true + \ }, + \ 'indexes': { + \ 'runtimepath': v:true, + \ 'gap': 100, + \ 'count': 3, + \ 'projectRootPatterns' : ['.git', 'autoload', 'plugin'] + \ }, + \ 'suggest': { + \ 'fromVimruntime': v:true, + \ 'fromRuntimepath': v:false + \ }, + \ } + \} +< + Consult the vim-language-server documentation for more information about + settings. + + +g:ale_vim_vimls_use_global *g:ale_vim_vimls_use_global* + *b:ale_vim_vimls_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vint *ale-vim-vint* diff --git a/sources_non_forked/ale/doc/ale-vue.txt b/sources_non_forked/ale/doc/ale-vue.txt index a2c2786f..3f382e4f 100644 --- a/sources_non_forked/ale/doc/ale-vue.txt +++ b/sources_non_forked/ale/doc/ale-vue.txt @@ -2,6 +2,12 @@ ALE Vue Integration *ale-vue-options* +=============================================================================== +cspell *ale-vue-cspell* + +See |ale-cspell-options| + + =============================================================================== prettier *ale-vue-prettier* @@ -27,5 +33,36 @@ g:ale_vue_vls_use_global *g:ale_vue_vls_use_global* See |ale-integrations-local-executables| +=============================================================================== +volar *ale-vue-volar* + + It is required to have typescript installed in your project as your dev + dependency: `npm i -D typescript` + +g:ale_vue_volar_executable *g:ale_vue_volar_executable* + *b:ale_vue_volar_executable* + Type: |String| + Default: `'vue-language-server'` + + See |ale-integrations-local-executables| + + +g:ale_vue_volar_use_global *g:ale_vue_volar_use_global* + *b:ale_vue_volar_use_global* + Type: |Number| + Default: `1` + + See |ale-integrations-local-executables| + + +g:vue_volar_init_options *g:ale_vue_volar_init_options* + *b:ale_vue_volar_init_options* + Type: |Dictionary| + Default: `{ 'typescript': 'tsdk': '' }` + + Default is too long to show here, take a look at it over + `ale_linters/vue/volar.vim` + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-wgsl.txt b/sources_non_forked/ale/doc/ale-wgsl.txt new file mode 100644 index 00000000..5254f43b --- /dev/null +++ b/sources_non_forked/ale/doc/ale-wgsl.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE WGSL Integration *ale-wgsl-options* + + +=============================================================================== +naga *ale-wgsl-naga* + +g:ale_wgsl_naga_executable *g:ale_wgsl_naga_executable* + *b:ale_wgsl_naga_executable* + Type: |String| + Default: `'naga'` + + The executable that will be run for the `naga` linter. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-xhtml.txt b/sources_non_forked/ale/doc/ale-xhtml.txt index 3cc639ef..10ca5b82 100644 --- a/sources_non_forked/ale/doc/ale-xhtml.txt +++ b/sources_non_forked/ale/doc/ale-xhtml.txt @@ -2,6 +2,12 @@ ALE XHTML Integration *ale-xhtml-options* +=============================================================================== +cspell *ale-xhtml-cspell* + +See |ale-cspell-options| + + =============================================================================== write-good *ale-xhtml-write-good* @@ -9,4 +15,4 @@ See |ale-write-good-options| =============================================================================== -vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-xml.txt b/sources_non_forked/ale/doc/ale-xml.txt index e43fdefd..a7180df8 100644 --- a/sources_non_forked/ale/doc/ale-xml.txt +++ b/sources_non_forked/ale/doc/ale-xml.txt @@ -24,7 +24,7 @@ g:ale_xml_xmllint_options *g:ale_xml_xmllint_options* g:ale_xml_xmllint_indentsize *g:ale_xml_xmllint_indentsize* *b:ale_xml_xmllint_indentsize* Type: |Number| - Default: 2 + Default: `2` This variable can be sent to specify the amount of spaces used for indentation. diff --git a/sources_non_forked/ale/doc/ale-yaml.txt b/sources_non_forked/ale/doc/ale-yaml.txt index c9a12ea1..fc52dc73 100644 --- a/sources_non_forked/ale/doc/ale-yaml.txt +++ b/sources_non_forked/ale/doc/ale-yaml.txt @@ -1,6 +1,74 @@ =============================================================================== ALE YAML Integration *ale-yaml-options* + +=============================================================================== +actionlint *ale-yaml-actionlint* + +Website: https://github.com/rhysd/actionlint + + +Installation +------------------------------------------------------------------------------- + +See installation guide: https://github.com/rhysd/actionlint#quick-start + +This linter is disabled by default and must be enabled by setting `g:ale_linters`. +To enable it only for Github Action YAML files a configuration like this is +better: + +> + au BufRead,BufNewFile */.github/*/*.y{,a}ml + \ let b:ale_linters = {'yaml': ['actionlint']} +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_actionlint_executable *g:ale_yaml_actionlint_executable* + *b:ale_yaml_actionlint_executable* + Type: |String| + Default: `'actionlint'` + + This variable can be set to change the path to actionlint. + +g:ale_yaml_actionlint_options *g:ale_yaml_actionlint_options* + *b:ale_yaml_actionlint_options* + + Type: |String| + Default: `''` + + This variable can be set to add extra options to actionlint executable. + + For example, to disable running `shellcheck` and `pyflakes` external commands, + you may want to set: +> + let g:ale_yaml_actionlint_options = '-shellcheck= -pyflakes=' +< + Please note that passing `-format` as option is not supported at the moment. + + +=============================================================================== +circleci *ale-yaml-circleci* + +Website: https://circleci.com/docs/2.0/local-cli + + +Installation +------------------------------------------------------------------------------- + +Follow the instructions on the website, and make sure to test that you can +validate configuration files with: > + + circleci config validate - < .circleci/config.yml +< + +As long as the validator runs correctly, you should be able to see errors when +you save the configuration file. The validator doesn't run as you type because +it sends network requests, and running too often would overload the circleci +servers. + + =============================================================================== prettier *ale-yaml-prettier* @@ -15,7 +83,40 @@ Install prettier either globally or locally: > npm install prettier -g # global npm install prettier # local < - + +=============================================================================== +spectral *ale-yaml-spectral* + +Website: https://github.com/stoplightio/spectral + + +Installation +------------------------------------------------------------------------------- + +Install spectral either globally or locally: > + + npm install @stoplight/spectral -g # global + npm install @stoplight/spectral # local +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_spectral_executable *g:ale_yaml_spectral_executable* + *b:ale_yaml_spectral_executable* + Type: |String| + Default: `'spectral'` + + This variable can be set to change the path to spectral. + +g:ale_yaml_spectral_use_global *g:ale_yaml_spectral_use_global* + *b:ale_yaml_spectral_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== swaglint *ale-yaml-swaglint* @@ -50,6 +151,136 @@ g:ale_yaml_swaglint_use_global *g:ale_yaml_swaglint_use_global* See |ale-integrations-local-executables| +=============================================================================== +yaml-language-server *ale-yaml-language-server* + +Website: https://github.com/redhat-developer/yaml-language-server + + +Installation +------------------------------------------------------------------------------- + +Install yaml-language-server either globally or locally: > + + npm install yaml-language-server -g # global + npm install yaml-language-server # local + + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_ls_executable *g:ale_yaml_ls_executable* + *b:ale_yaml_ls_executable* + Type: |String| + Default: `'yaml-language-server'` + + This variable can be set to change the path to yaml-language-server. + + +g:ale_yaml_ls_config *g:ale_yaml_ls_config* + *b:ale_yaml_ls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. For example, to enable schema store: > + { + \ 'yaml': { + \ 'schemaStore': { + \ 'enable': v:true, + \ }, + \ }, + \ } +< + Consult the yaml-language-server documentation for more information about + settings. + + +g:ale_yaml_ls_use_global *g:ale_yaml_ls_use_global* + *b:ale_yaml_ls_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +yamlfix *ale-yaml-yamlfix* + +Website: https://lyz-code.github.io/yamlfix + + +Installation +------------------------------------------------------------------------------- + +Install yamlfix: > + + pip install yamlfix +< + +Options +------------------------------------------------------------------------------- +g:ale_yaml_yamlfix_executable *g:ale_yaml_yamlfix_executable* + *b:ale_yaml_yamlfix_executable* + Type: |String| + Default: `'yamlfix'` + + See |ale-integrations-local-executables| + + +g:ale_yaml_yamlfix_options *g:ale_yaml_yamlfix_options* + *b:ale_yaml_yamlfix_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to yamlfix. + +g:ale_yaml_yamlfix_use_global *g:ale_yaml_yamlfix_use_global* + *b:ale_yaml_yamlfix_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +yamlfmt *ale-yaml-yamlfmt* + +Website: https://github.com/google/yamlfmt + + +Installation +------------------------------------------------------------------------------- + +Install yamlfmt: + + See the website. + +Options +------------------------------------------------------------------------------- +g:ale_yaml_yamlfmt_executable *g:ale_yaml_yamlfmt_executable* + *b:ale_yaml_yamlfmt_executable* + Type: |String| + Default: `'yamlfmt'` + + See |ale-integrations-local-executables| + + +g:ale_yaml_yamlfmt_options *g:ale_yaml_yamlfmt_options* + *b:ale_yaml_yamlfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to yamlfmt. + +g:ale_yaml_yamlfmt_use_global *g:ale_yaml_yamlfmt_use_global* + *b:ale_yaml_yamlfmt_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== yamllint *ale-yaml-yamllint* @@ -88,5 +319,90 @@ g:ale_yaml_yamllint_options *g:ale_yaml_yamllint_options* This variable can be set to pass additional options to yamllint. +=============================================================================== +gitlablint *ale-yaml-gitlablint* + +Website: https://github.com/elijah-roberts/gitlab-lint + + +Installation +------------------------------------------------------------------------------- + +Install yamllint in your a virtualenv directory, locally, or globally: > + + pip3 install gitlab_lint # After activating virtualenv + pip3 install --user gitlab_lint # Install to ~/.local/bin + sudo pip3 install gitlab_lint # Install globally + +See |g:ale_virtualenv_dir_names| for configuring how ALE searches for +virtualenv directories. + +Is recommended to use |g:ale_pattern_options| to enable this linter so it only +applies to 'gitlab-ci.yml' files and not all yaml files: +> + let g:ale_pattern_options = { + \ '.gitlab-ci\.yml$': { + \ 'ale_linters': ['gitlablint'], + \ }, + \} +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_gitlablint_executable *g:ale_yaml_gitlablint_executable* + *b:ale_yaml_gitlablint_executable* + Type: |String| + Default: `'gll'` + + This variable can be set to change the path to gll. + + +g:ale_yaml_gitlablint_options *g:ale_yaml_gitlablint_options* + *b:ale_yaml_gitlablint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to gll. + + +=============================================================================== +yq *ale-yaml-yq* + +Website: https://github.com/mikefarah/yq + + +Installation +------------------------------------------------------------------------------- + +Install yq: > + + wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - | tar xz && mv ${BINARY} /usr/bin/yq + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_yq_executable *g:ale_yaml_yq_executable* + *b:ale_yaml_yq_executable* + Type: |String| + Default: `'yq'` + + This variable can be set to change the path to yq. + + +g:ale_yaml_yq_options *g:ale_yaml_yq_options* + *b:ale_yaml_yq_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to yq. + +g:ale_yaml_yq_filters *g:ale_yaml_yq_filters + *b:ale_yaml_yq_filters* + Type: |String| + Default: `'.'` + + This option can be changed to pass additional filters to yq + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-yara.txt b/sources_non_forked/ale/doc/ale-yara.txt new file mode 100644 index 00000000..6dd4abbe --- /dev/null +++ b/sources_non_forked/ale/doc/ale-yara.txt @@ -0,0 +1,22 @@ +=============================================================================== +ALE Yara Integration *ale-yara-options* + *ale-integration-yara* + +=============================================================================== +Integration Information + + Currently, the only supported linter for yara is yls. + + +=============================================================================== +yls *ale-yara-yls* + +g:ale_yara_yls_executable *g:ale_yara_yls_executable* + *b:ale_yara_yls_executable* + Type: |String| + Default: `'yls'` + + This variable can be modified to change the executable path for `yls`. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-zeek.txt b/sources_non_forked/ale/doc/ale-zeek.txt new file mode 100644 index 00000000..910bc060 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-zeek.txt @@ -0,0 +1,23 @@ +=============================================================================== +ALE Zeek Integration *ale-zeek-options* + *ale-integration-zeek* + +=============================================================================== +Integration Information + + Currently, the only supported linter for Zeek is zeek. + +=============================================================================== +zeek *ale-zeek-zeek* + +g:ale_zeek_zeek_executable *g:ale_zeek_zeek_executable* + *b:ale_zeek_zeek_executable* + Type: |String| + Default: `'zeek'` + + This variable can be modified to change the executable path for `zeek`. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-zig.txt b/sources_non_forked/ale/doc/ale-zig.txt new file mode 100644 index 00000000..9ab6cc8e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-zig.txt @@ -0,0 +1,58 @@ +=============================================================================== +ALE Zig Integration *ale-zig-options* + *ale-integration-zig* + +=============================================================================== +Integration Information + + The following linters are supported for Zig: + + * zlint (https://github.com/DonIsaac/zlint) + * zls (https://github.com/zigtools/zls) + + +=============================================================================== +zigfmt *ale-zig-zigfmt* + +g:ale_zig_zigfmt_executable *g:ale_zig_zigfmt_executable* + *b:ale_zig_zigfmt_executable* + Type: |String| + Default: `'zig'` + + The executable that will be run for the `zig fmt` fixer. + + +=============================================================================== +zlint *ale-zig-zlint* + +g:ale_zig_zlint_executable *g:ale_zig_zlint_executable* + *b:ale_zig_zlint_executable* + Type: |String| + Default: `'zlint'` + + This variable can be modified to change the executable path for `zlint`. + +=============================================================================== +zls *ale-zig-zls* + +g:ale_zig_zls_executable *g:ale_zig_zls_executable* + *b:ale_zig_zls_executable* + Type: |String| + Default: `'zls'` + + This variable can be modified to change the executable path for `zls`. + + +g:ale_zig_zls_config *g:ale_zig_zls_config* + *b:ale_zig_zls_config* + Type: |Dictionary| + Default: `{}` + + WARNING: As of writing, zls does not support receiving configuration + from the client. This variable is a PLACEHOLDER until it does. + + Dictionary with configuration settings for zls. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index beca8546..d97bbe76 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -1,4 +1,4 @@ -*ale.txt* Plugin to lint and fix files asynchronously +*ale.txt* Plugin to lint and fix files asynchronously *ale* ALE - Asynchronous Lint Engine @@ -9,22 +9,27 @@ CONTENTS *ale-contents* 1. Introduction.........................|ale-introduction| 2. Supported Languages & Tools..........|ale-support| 3. Linting..............................|ale-lint| - 3.1 Other Sources.....................|ale-lint-other-sources| + 3.1 Linting On Other Machines.........|ale-lint-other-machines| + 3.2 Adding Language Servers...........|ale-lint-language-servers| + 3.3 Other Sources.....................|ale-lint-other-sources| 4. Fixing Problems......................|ale-fix| 5. Language Server Protocol Support.....|ale-lsp| 5.1 Completion........................|ale-completion| 5.2 Go To Definition..................|ale-go-to-definition| 5.3 Go To Type Definition.............|ale-go-to-type-definition| - 5.4 Find References...................|ale-find-references| - 5.5 Hovering..........................|ale-hover| - 5.6 Symbol Search.....................|ale-symbol-search| + 5.4 Go To Implementation..............|ale-go-to-implementation| + 5.5 Find References...................|ale-find-references| + 5.6 Hovering..........................|ale-hover| + 5.7 Symbol Search.....................|ale-symbol-search| + 5.8 Refactoring: Rename, Actions......|ale-refactor| 6. Global Options.......................|ale-options| 6.1 Highlights........................|ale-highlights| 7. Linter/Fixer Options.................|ale-integration-options| 7.1 Options for alex..................|ale-alex-options| - 7.2 Options for languagetool..........|ale-languagetool-options| - 7.3 Options for write-good............|ale-write-good-options| - 7.4 Other Linter/Fixer Options........|ale-other-integration-options| + 7.2 Options for cspell................|ale-cspell-options| + 7.3 Options for languagetool..........|ale-languagetool-options| + 7.4 Options for write-good............|ale-write-good-options| + 7.5 Other Linter/Fixer Options........|ale-other-integration-options| 8. Commands/Keybinds....................|ale-commands| 9. API..................................|ale-api| 10. Special Thanks......................|ale-special-thanks| @@ -36,7 +41,7 @@ CONTENTS *ale-contents* ALE provides the means to run linters asynchronously in Vim in a variety of languages and tools. ALE sends the contents of buffers to linter programs using the |job-control| features available in Vim 8 and NeoVim. For Vim 8, -Vim must be compiled with the |job| and |channel| and |timers| features +Vim must be compiled with the |+job| and |+channel| and |+timers| features as a minimum. ALE supports the following key features for linting: @@ -44,14 +49,14 @@ ALE supports the following key features for linting: 1. Running linters when text is changed. 2. Running linters when files are opened. 3. Running linters when files are saved. (When a global flag is set.) -4. Populating the |loclist| with warning and errors. +4. Populating the |location-list| with warning and errors. 5. Setting |signs| with warnings and errors for error markers. -6. Using |echo| to show error messages when the cursor moves. +6. Using `:echo` to show error messages when the cursor moves. 7. Setting syntax highlights for errors. -ALE can fix problems with files with the |ALEFix| command, using the same job +ALE can fix problems with files with the `:ALEFix` command, using the same job control functionality used for checking for problems. Try using the -|ALEFixSuggest| command for browsing tools that can be used to fix problems +`:ALEFixSuggest` command for browsing tools that can be used to fix problems for the current buffer. If you are interested in contributing to the development of ALE, read the @@ -76,7 +81,7 @@ for |ale#linter#Define()|. Without any configuration, ALE will attempt to check all of the code for every file you open in Vim with all available tools by default. To see what ALE -is doing, and what options have been set, try using the |:ALEInfo| command. +is doing, and what options have been set, try using the `:ALEInfo` command. Most of the linters ALE runs will check the Vim buffer you are editing instead of the file on disk. This allows you to check your code for errors before you @@ -116,6 +121,7 @@ circumstances. ALE will report problems with your code in the following ways, listed with their relevant options. +* Via Neovim diagnostics (On in Neovim 0.7+) - |g:ale_use_neovim_diagnostics_api| * By updating loclist. (On by default) - |g:ale_set_loclist| * By updating quickfix. (Off by default) - |g:ale_set_quickfix| * By setting error highlights. - |g:ale_set_highlights| @@ -126,7 +132,7 @@ their relevant options. * By showing balloons for your mouse cursor - |g:ale_set_balloons| Please consult the documentation for each option, which can reveal some other -ways of tweaking the behaviour of each way of displaying problems. You can +ways of tweaking the behavior of each way of displaying problems. You can disable or enable whichever options you prefer. Most settings can be configured for each buffer. (|b:| instead of |g:|), @@ -145,9 +151,109 @@ ALE offers several options for controlling which linters are run. * Disabling only a subset of linters. - |g:ale_linters_ignore| * Disabling LSP linters and `tsserver`. - |g:ale_disable_lsp| +You can stop ALE any currently running linters with the `:ALELintStop` command. +Any existing problems will be kept. ------------------------------------------------------------------------------- -3.1 Other Sources *ale-lint-other-sources* +3.1 Linting On Other Machines *ale-lint-other-machines* + +ALE offers support for running linters or fixers on files you are editing +locally on other machines, so long as the other machine has access to the file +you are editing. This could be a linter or fixer run inside of a Docker image, +running in a virtual machine, running on a remote server, etc. + +In order to run tools on other machines, you will need to configure your tools +to run via scripts that execute commands on those machines, such as by setting +the ALE `_executable` options for those tools to a path for a script to run, +or by using |g:ale_command_wrapper| to specify a script to wrap all commands +that are run by ALE, before they are executed. For tools that ALE runs where +ALE looks for locally installed executables first, you may need to set the +`_use_global` options for those tools to `1`, or you can set +|g:ale_use_global_executables| to `1` before ALE is loaded to only use global +executables for all tools. + +In order for ALE to properly lint or fix files which are running on another +file system, you must provide ALE with |List|s of strings for mapping paths to +and from your local file system and the remote file system, such as the file +system of your Docker container. See |g:ale_filename_mappings| for all of the +different ways these filename mappings can be configured. + +For example, you might configure `pylint` to run via Docker by creating a +script like so. > + + #!/usr/bin/env bash + + exec docker run -i --rm -v "$(pwd):/data" cytopia/pylint "$@" +< + +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 change between the two file systems in your +`python.vim` |ftplugin| file, like so: > + + if expand('%:p') =~# '^/home/w0rp/git/test-pylint/' + let b:ale_linters = ['pylint'] + let b:ale_python_pylint_use_global = 1 + " This is the path to the script above. + let b:ale_python_pylint_executable = '/home/w0rp/git/test-pylint/pylint.sh' + " /data matches the path in Docker. + let b:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/w0rp/git/test-pylint', '/data'], + \ ], + \} + endif +< + +You might consider using a Vim plugin for loading Vim configuration files +specific to each project, if you have a lot of projects to manage. + + +------------------------------------------------------------------------------- +3.2 Adding Language Servers *ale-lint-language-servers* + +ALE comes with many default configurations for language servers, so they can +be detected and run automatically. ALE can connect to other language servers +by defining a new linter for a filetype. New linters can be defined in |vimrc|, +in plugin files, or `ale_linters` directories in 'runtimepath'. + +See |ale-linter-loading-behavior| for more information on loading linters. + +A minimal configuration for a language server linter might look so. > + + call ale#linter#Define('filetype_here', { + \ 'name': 'any_name_you_want', + \ 'lsp': 'stdio', + \ 'executable': '/path/to/executable', + \ 'command': '%e run', + \ 'project_root': '/path/to/root_of_project', + \}) +< +For language servers that use a TCP or named pipe socket connection, you +should define the address to connect to instead. > + + call ale#linter#Define('filetype_here', { + \ 'name': 'any_name_you_want', + \ 'lsp': 'socket', + \ 'address': 'servername:1234', + \ 'project_root': '/path/to/root_of_project', + \}) +< + Most of the options for a language server can be replaced with a |Funcref| + for a function accepting a buffer number for dynamically computing values + such as the executable path, the project path, the server address, etc, + most of which can also be determined based on executing some other + asynchronous task. See |ale#command#Run()| for computing linter options + based on asynchronous results. + + See |ale#linter#Define()| for a detailed explanation of all of the options + for configuring linters. + + +------------------------------------------------------------------------------- +3.3 Other Sources *ale-lint-other-sources* Problems for a buffer can be taken from other sources and rendered by ALE. This allows ALE to be used in combination with other plugins which also want @@ -183,6 +289,12 @@ number of the buffer that ALE wants to check. sources should perform their checks on a buffer in the background asynchronously, so they don't interrupt editing. +|ale#other_source#ShowResults()| must not be called synchronously before +ALE's engine executes its code after the |ALEWantResults| event runs. If +there are immediate results to provide to ALE, a 0 millisecond timer with +|timer_start()| can be set instead up to call |ale#other_source#ShowResults()| +after ALE has first executed its engine code for its own sources. + A plugin might integrate its own checks with ALE like so: > augroup SomeGroupName @@ -204,21 +316,21 @@ A plugin might integrate its own checks with ALE like so: > function! WorkDone(buffer, results) abort " Send results to ALE after they have been collected. - call ale#other_source#ShowResults(buffer, 'some-name', a:results) + call ale#other_source#ShowResults(a:buffer, 'some-name', a:results) endfunction < =============================================================================== 4. Fixing Problems *ale-fix* -ALE can fix problems with files with the |ALEFix| command. |ALEFix| +ALE can fix problems with files with the `:ALEFix` command. `:ALEFix` accepts names of fixers to be applied as arguments. Alternatively, when no arguments are provided, the variable |g:ale_fixers| will be read for getting a |List| of commands for filetypes, split on `.`, and the functions named in |g:ale_fixers| will be executed for fixing the errors. -The |ALEFixSuggest| command can be used to suggest tools that be used to +The `:ALEFixSuggest` command can be used to suggest tools that be used to fix problems for the current buffer. The values for `g:ale_fixers` can be a list of |String|, |Funcref|, or @@ -236,15 +348,23 @@ argument `lines`. Functions should name two arguments if the `lines` argument is desired. This is required to avoid unnecessary copying of the lines of the buffers being checked. -When a |Dictionary| is returned for an |ALEFix| callback, the following keys +When a |Dictionary| is returned for an `:ALEFix` callback, the following keys are supported for running the commands. + `cwd` An optional |String| for setting the working directory + for the command. + + If not set, or `v:null`, the `cwd` of the last command + that spawn this one will be used. + `command` A |String| for the command to run. This key is required. When `%t` is included in a command string, a temporary file will be created, containing the lines from the file after previous adjustment have been done. + See |ale-command-format-strings| for formatting options. + `read_temporary_file` When set to `1`, ALE will read the contents of the temporary file created for `%t`. This option can be used for commands which need to modify some file on disk in @@ -252,12 +372,16 @@ are supported for running the commands. `process_with` An optional callback for post-processing. - The callback must accept two arguments, - `(buffer, output)`, which can be used for converting - the output from a command into lines to replace the - buffer's contents with. + The callback must accept arguments `(bufnr, output)`: + the buffer number undergoing fixing and the fixer's + output as a |List| of |String|s. It must return a |List| + of |String|s that will be the new contents of the + buffer. + + This callback is useful to remove excess lines from the + command's output or apply additional changes to the + output. - A |List| of |String|s must be returned. `read_buffer` An optional key for disabling reading the buffer. @@ -300,7 +424,7 @@ files, a |List| may be used for configuring the fixers instead. ALEFix < -For convenience, a plug mapping is defined for |ALEFix|, so you can set up a +For convenience, a plug mapping is defined for `:ALEFix`, so you can set up a keybind easily for fixing files. > " Bind F8 to fixing problems with ALE @@ -312,7 +436,11 @@ by default. |g:ale_fix_on_save| - Fix files when they are saved. Fixers can be disabled on save with |g:ale_fix_on_save_ignore|. They will -still be run when you manually run |ALEFix|. +still be run when you manually run `:ALEFix`. + +Fixers can be run on another machines, just like linters, such as fixers run +from a Docker container, running in a virtual machine, running a remote +server, etc. See |ale-lint-other-machines|. =============================================================================== @@ -327,6 +455,11 @@ If you want to use another plugin for LSP features and tsserver, you can use the |g:ale_disable_lsp| setting to disable ALE's own LSP integrations, or ignore particular linters with |g:ale_linters_ignore|. +If for any reason you want to stop a language server ALE starts, such as when +a project configuration has significantly changed, or new files have been +added the language server isn't aware of, use either `:ALEStopLSP` or +`:ALEStopAllLSPs` to stop the server until ALE automatically starts it again. + ------------------------------------------------------------------------------- 5.1 Completion *ale-completion* @@ -345,7 +478,7 @@ integration should not be combined with ALE's own implementation. ALE additionally integrates with asyncomplete.vim for offering automatic completion data. ALE's asyncomplete source requires registration and should -use the defaults provided by the|asyncomplete#sources#ale#get_source_options| function > +use the defaults provided by the |asyncomplete#sources#ale#get_source_options| function > " Use ALE's function for asyncomplete defaults au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#ale#get_source_options({ @@ -360,22 +493,84 @@ is loaded. The delay for completion can be configured with |g:ale_completion_delay|. This setting should not be enabled if you wish to use ALE as a completion source for other plugins. +ALE automatic completion will not work when 'paste' is active. Only set +'paste' when you are copy and pasting text into your buffers. + +ALE automatic completion will interfere with default insert completion with +`CTRL-N` and so on (|compl-vim|). You can write your own keybinds and a +function in your |vimrc| file to force insert completion instead, like so: > + + function! SmartInsertCompletion() abort + " Use the default CTRL-N in completion menus + if pumvisible() + return "\" + endif + + " Exit and re-enter insert mode, and use insert completion + return "\a\" + endfunction + + inoremap =SmartInsertCompletion() +< ALE provides an 'omnifunc' function |ale#completion#OmniFunc| for triggering completion manually with CTRL-X CTRL-O. |i_CTRL-X_CTRL-O| > " Use ALE's function for omnicompletion. set omnifunc=ale#completion#OmniFunc < + *ale-completion-fallback* + +You can write your own completion function and fallback on other methods of +completion by checking if there are no results that ALE can determine. For +example, for Python code, you could fall back on the `python3complete` +function. > + + function! TestCompletionFunc(findstart, base) abort + let l:result = ale#completion#OmniFunc(a:findstart, a:base) + + " Check if ALE couldn't find anything. + if (a:findstart && l:result is -3) + \|| (!a:findstart && empty(l:result)) + " Defer to another omnifunc if ALE couldn't find anything. + return python3complete#Complete(a:findstart, a:base) + endif + + return l:result + endfunction + + set omnifunc=TestCompletionFunc +< +See |complete-functions| for documentation on how to write completion +functions. + ALE will only suggest so many possible matches for completion. The maximum number of items can be controlled with |g:ale_completion_max_suggestions|. If you don't like some of the suggestions you see, you can filter them out with |g:ale_completion_excluded_words| or |b:ale_completion_excluded_words|. -The |ALEComplete| command can be used to show completion suggestions manually, +The `:ALEComplete` command can be used to show completion suggestions manually, even when |g:ale_completion_enabled| is set to `0`. For manually requesting completion information with Deoplete, consult Deoplete's documentation. +ALE supports automatic imports from external modules. This behavior can be +disabled by setting the |g:ale_completion_autoimport| variable to `0`. +Disabling automatic imports can drop some or all completion items from +some LSP servers (e.g. eclipselsp). + +You can manually request imports for symbols at the cursor with the +`:ALEImport` command. The word at the cursor must be an exact match for some +potential completion result which includes additional text to insert into the +current buffer, which ALE will assume is code for an import line. This command +can be useful when your code already contains something you need to import. + +You can execute other commands whenever ALE inserts some completion text with +the |ALECompletePost| event. + +When working with TypeScript files, ALE can remove warnings from your +completions by setting the |g:ale_completion_tsserver_remove_warnings| +variable to 1. + *ale-completion-completeopt-bug* ALE Automatic completion implementation replaces |completeopt| before opening @@ -386,18 +581,54 @@ vimrc, and your issues should go away. > set completeopt=menu,menuone,preview,noselect,noinsert < +Or alternatively, if you want to show documentation in popups: > + set completeopt=menu,menuone,popup,noselect,noinsert +< + *ale-symbols* + +ALE provides a set of basic completion symbols. If you want to replace those +symbols with others, you can set the variable |g:ale_completion_symbols| with +a mapping of the type of completion to the symbol or other string that you +would like to use. An example here shows the available options for symbols > + + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'unit', + \ 'value': 'val', + \ 'enum': '', + \ 'keyword': 'keyword', + \ 'snippet': '', + \ 'color': 'color', + \ 'file': '', + \ 'reference': 'ref', + \ 'folder': '', + \ 'enum member': '', + \ 'constant': '', + \ 'struct': '', + \ 'event': 'event', + \ 'operator': '', + \ 'type_parameter': 'type param', + \ '': 'v' + \ } +< ------------------------------------------------------------------------------- 5.2 Go To Definition *ale-go-to-definition* ALE supports jumping to the files and locations where symbols are defined through any enabled LSP linters. The locations ALE will jump to depend on the -information returned by LSP servers. The following commands are supported: - -|ALEGoToDefinition| - Open the definition of the symbol under the cursor. -|ALEGoToDefinitionInTab| - The same, but for opening the file in a new tab. -|ALEGoToDefinitionInSplit| - The same, but in a new split. -|ALEGoToDefinitionInVSplit| - The same, but in a new vertical split. +information returned by LSP servers. The `:ALEGoToDefinition` command will jump +to the definition of symbols under the cursor. See the documentation for the +command for configuring how the location will be displayed. ALE will update Vim's |tagstack| automatically unless |g:ale_update_tagstack| is set to `0`. @@ -407,36 +638,38 @@ set to `0`. ALE supports jumping to the files and locations where symbols' types are defined through any enabled LSP linters. The locations ALE will jump to depend -on the information returned by LSP servers. The following commands are -supported: - -|ALEGoToTypeDefinition| - Open the definition of the symbol's type under - the cursor. -|ALEGoToTypeDefinitionInTab| - The same, but for opening the file in a new tab. -|ALEGoToTypeDefinitionInSplit| - The same, but in a new split. -|ALEGoToTypeDefinitionInVSplit| - The same, but in a new vertical split. - +on the information returned by LSP servers. The `:ALEGoToTypeDefinition` +command will jump to the definition of symbols under the cursor. See the +documentation for the command for configuring how the location will be +displayed. ------------------------------------------------------------------------------- -5.4 Find References *ale-find-references* +5.4 Go To Implementation *ale-go-to-implementation* -ALE supports finding references for symbols though any enabled LSP linters. -ALE will display a preview window showing the places where a symbol is -referenced in a codebase when a command is run. The following commands are -supported: - -|ALEFindReferences| - Find references for the word under the cursor. - -Options: - `-relative` Show file paths in the results relative to the working dir +ALE supports jumping to the files and locations where symbols are implemented +through any enabled LSP linters. The locations ALE will jump to depend on the +information returned by LSP servers. The `:ALEGoToImplementation` command will +jump to the implementation of symbols under the cursor. See the documentation +for the command for configuring how the location will be displayed. ------------------------------------------------------------------------------- -5.5 Hovering *ale-hover* +5.5 Find References *ale-find-references* + +ALE supports finding references for symbols though any enabled LSP linters +with the `:ALEFindReferences` command. See the documentation for the command +for a full list of options. + +------------------------------------------------------------------------------- +5.6 Hovering *ale-hover* ALE supports "hover" information for printing brief information about symbols at the cursor taken from LSP linters. The following commands are supported: -|ALEHover| - Print information about the symbol at the cursor. +`:ALEHover` - Print information about the symbol at the cursor. + +Truncated information will be displayed when the cursor rests on a symbol by +default, as long as there are no problems on the same line. You can disable +this behavior by setting |g:ale_hover_cursor| to `0`. If |g:ale_set_balloons| is set to `1` and your version of Vim supports the |balloon_show()| function, then "hover" information also show up when you move @@ -444,6 +677,14 @@ the mouse over a symbol in a buffer. Diagnostic information will take priority over hover information for balloons. If a line contains a problem, that problem will be displayed in a balloon instead of hover information. +Hover information can be displayed in the preview window instead by setting +|g:ale_hover_to_preview| to `1`. + +When using Neovim or Vim with |popupwin|, if |g:ale_hover_to_floating_preview| +or |g:ale_floating_preview| is set to 1, the hover information will show in a +floating window. The borders of the floating preview window can be customized +by setting |g:ale_floating_window_border|. + For Vim 8.1+ terminals, mouse hovering is disabled by default. Enabling |balloonexpr| commands in terminals can cause scrolling issues in terminals, so ALE will not attempt to show balloons unless |g:ale_set_balloons| is set to @@ -459,22 +700,49 @@ settings. For example: > < Documentation for symbols at the cursor can be retrieved using the -|ALEDocumentation| command. This command is only available for `tsserver`. +`:ALEDocumentation` command. This command is only available for `tsserver`. ------------------------------------------------------------------------------- -5.6 Symbol Search *ale-symbol-search* +5.7 Symbol Search *ale-symbol-search* -ALE supports searching for workspace symbols via LSP linters. The following -commands are supported: +ALE supports searching for workspace symbols via LSP linters with the +`:ALESymbolSearch` command. See the documentation for the command +for a full list of options. -|ALESymbolSearch| - Search for symbols in the workspace. +------------------------------------------------------------------------------- +5.8 Refactoring: Rename, Actions *ale-refactor* -Options: - `-relative` Show file paths in the results relative to the working dir +ALE supports renaming symbols in code such as variables or class names with +the `:ALERename` command. +`:ALEFileRename` will rename file and fix import paths (tsserver only). + +`:ALECodeAction` will execute actions on the cursor or applied to a visual +range selection, such as automatically fixing errors. + +Actions will appear in the right click mouse menu by default for GUI versions +of Vim, unless disabled by setting |g:ale_popup_menu_enabled| to `0`. + +Make sure to set your Vim to move the cursor position whenever you right +click, and enable the mouse menu: > + + set mouse=a + set mousemodel=popup_setpos +< +You may wish to remove some other menu items you don't want to see: > + + silent! aunmenu PopUp.Select\ Word + silent! aunmenu PopUp.Select\ Sentence + silent! aunmenu PopUp.Select\ Paragraph + silent! aunmenu PopUp.Select\ Line + silent! aunmenu PopUp.Select\ Block + silent! aunmenu PopUp.Select\ Blockwise + silent! aunmenu PopUp.Select\ All +< =============================================================================== 6. Global Options *ale-options* + g:airline#extensions#ale#enabled *g:airline#extensions#ale#enabled* Type: |Number| @@ -489,7 +757,7 @@ g:airline#extensions#ale#enabled *g:airline#extensions#ale#enabled* g:ale_cache_executable_check_failures *g:ale_cache_executable_check_failures* Type: |Number| - Default: undefined + Default: not set When set to `1`, ALE will cache failing executable checks for linters. By default, only executable checks which succeed will be cached. @@ -510,8 +778,8 @@ g:ale_change_sign_column_color *g:ale_change_sign_column_color* ALE uses the following highlight groups for highlighting the sign column: - `ALESignColumnWithErrors` - Links to `error` by default. - `ALESignColumnWithoutErrors` - Uses the value for `SignColumn` by default. + `:ALESignColumnWithErrors` - Links to `Error` by default. + `:ALESignColumnWithoutErrors` - Uses the value for `SignColumn` by default. The sign column color can only be changed globally in Vim. The sign column might produce unexpected results if editing different files in split @@ -545,7 +813,7 @@ g:ale_command_wrapper *g:ale_command_wrapper* " Prefix all commands with nice. let g:ale_command_wrapper = 'nice -n5' < - Use the |ALEInfo| command to view the commands that are run. All of the + Use the `:ALEInfo` command to view the commands that are run. All of the arguments for commands will be put on the end of the wrapped command by default. A `%*` marker can be used to spread the arguments in the wrapped command. > @@ -553,7 +821,6 @@ g:ale_command_wrapper *g:ale_command_wrapper* " Has the same effect as the above. let g:ale_command_wrapper = 'nice -n5 %*' < - For passing all of the arguments for a command as one argument to a wrapper, `%@` can be used instead. > @@ -577,8 +844,7 @@ g:ale_completion_delay *g:ale_completion_delay* g:ale_completion_enabled *g:ale_completion_enabled* -b:ale_completion_enabled *b:ale_completion_enabled* - + *b:ale_completion_enabled* Type: |Number| Default: `0` @@ -590,6 +856,9 @@ b:ale_completion_enabled *b:ale_completion_enabled* This setting should not be enabled if you wish to use ALE as a completion source for other completion plugins. + ALE automatic completion will not work when 'paste' is active. Only set + 'paste' when you are copy and pasting text into your buffers. + A buffer-local version of this setting `b:ale_completion_enabled` can be set to `0` to disable ALE's automatic completion support for a single buffer. ALE's completion support must be enabled globally to be enabled locally. @@ -597,6 +866,29 @@ b:ale_completion_enabled *b:ale_completion_enabled* See |ale-completion| + *g:ale_completion_tsserver_remove_warnings* +g:ale_completion_tsserver_remove_warnings + + Type: |Number| + Default: `0` + + When this option is set to `0`, ALE will return all completion items, + including those that are a warning. Warnings can be excluded from completed + items by setting it to `1`. + + +g:ale_completion_autoimport *g:ale_completion_autoimport* + + Type: |Number| + Default: `1` + + When this option is set to `1`, ALE will try to automatically import + completion results from external modules. It can be disabled by setting it + to `0`. Some LSP servers include auto imports on every completion item so + disabling automatic imports may drop some or all completion items returned + by it (e.g. eclipselsp). + + g:ale_completion_excluded_words *g:ale_completion_excluded_words* *b:ale_completion_excluded_words* Type: |List| @@ -615,6 +907,47 @@ g:ale_completion_excluded_words *g:ale_completion_excluded_words* let b:ale_completion_excluded_words = ['it', 'describe'] < +g:ale_completion_symbols *g:ale_completion_symbols* + + Type: |Dictionary| + Default: See `autoload/ale/completion.vim` + + A mapping from completion types to symbols for completions. See + |ale-symbols| for more information. + + By default, this mapping only uses built in Vim completion kinds, but it can + be updated to use any unicode character for the completion kind. For + example: > + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'v', + \ 'value': 'v', + \ 'enum': 't', + \ 'keyword': 'v', + \ 'snippet': 'v', + \ 'color': 'v', + \ 'file': 'v', + \ 'reference': 'v', + \ 'folder': 'v', + \ 'enum_member': 'm', + \ 'constant': 'm', + \ 'struct': 't', + \ 'event': 'v', + \ 'operator': 'f', + \ 'type_parameter': 'p', + \ '': 'v' + \ }) +< + g:ale_completion_max_suggestions *g:ale_completion_max_suggestions* Type: |Number| @@ -631,6 +964,7 @@ g:ale_completion_max_suggestions *g:ale_completion_max_suggestions* Adjust this option as needed, depending on the complexity of your codebase and your available processing power. + g:ale_cursor_detail *g:ale_cursor_detail* Type: |Number| @@ -653,14 +987,36 @@ g:ale_cursor_detail *g:ale_cursor_detail* loaded for messages to be displayed. See |ale-lint-settings-on-startup|. -g:ale_disable_lsp *g:ale_disable_lsp* - *b:ale_disable_lsp* +g:ale_default_navigation *g:ale_default_navigation* + *b:ale_default_navigation* + Type: |String| + Default: `'buffer'` + The default method for navigating away from the current buffer to another + buffer, such as for `:ALEFindReferences` or `:ALEGoToDefinition`. + + +g:ale_detail_to_floating_preview *g:ale_detail_to_floating_preview* + *b:ale_detail_to_floating_preview* Type: |Number| Default: `0` - When this option is set to `1`, ALE ignores all linters powered by LSP, - and also `tsserver`. + When this option is set to `1`, Neovim or Vim with |popupwin| will use a + floating window for ALEDetail output. + + +g:ale_disable_lsp *g:ale_disable_lsp* + *b:ale_disable_lsp* + Type: |Number| OR |String| + Default: `'auto'` + + When this option is set to `'auto'`, ALE will automatically disable linters + that it detects as having already been configured with the nvim-lspconfig + plugin. When this option is set to `1`, ALE ignores all linters powered by + LSP, and also `tsserver`. + + Any linters that are disabled will also not be usable for LSP functionality + other than just linting. Please see also |ale-lsp|. @@ -705,8 +1061,7 @@ g:ale_echo_msg_error_str *g:ale_echo_msg_error_str* g:ale_echo_msg_format *g:ale_echo_msg_format* -b:ale_echo_msg_format *b:ale_echo_msg_format* - + *b:ale_echo_msg_format* Type: |String| Default: `'%code: %%s'` @@ -716,7 +1071,8 @@ b:ale_echo_msg_format *b:ale_echo_msg_format* `%s` - replaced with the text for the problem `%...code...% `- replaced with the error code `%linter%` - replaced with the name of the linter - `%severity%` - replaced with the severity of the problem + `%severity%` - replaced with the severity of the problem (e.g. `Error`) + `%type%` - replaced with the type of the problem (e.g. `E`) The strings for `%severity%` can be configured with the following options. @@ -745,6 +1101,15 @@ g:ale_echo_msg_info_str *g:ale_echo_msg_info_str* The string used for `%severity%` for info. See |g:ale_echo_msg_format| +g:ale_echo_msg_log_str *g:ale_echo_msg_log_str* + + Type: |String| + Default: `'Log'` + + The string used for `%severity%` for log, used only for handling LSP show + message requests. See |g:ale_lsp_show_message_format| + + g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str* Type: |String| @@ -755,13 +1120,12 @@ g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str* g:ale_enabled *g:ale_enabled* *b:ale_enabled* - Type: |Number| Default: `1` When set to `0`, this option will completely disable ALE, such that no error checking will be performed, etc. ALE can be toggled on and off with - the |ALEToggle| command, which changes this option. + the `:ALEToggle` command, which changes this option. ALE can be disabled in each buffer by setting `let b:ale_enabled = 0` Disabling ALE based on filename patterns can be accomplished by setting @@ -770,13 +1134,27 @@ g:ale_enabled *g:ale_enabled* " Disable linting for all minified JS files. let g:ale_pattern_options = {'\.min.js$': {'ale_enabled': 0}} < - See |g:ale_pattern_options| for more information on that option. +g:ale_exclude_highlights *g:ale_exclude_highlights* + *b:ale_exclude_highlights* + Type: |List| + Default: `[]` + + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + + A list of regular expressions for matching against highlight messages to + remove. For example: > + + " Do not highlight messages matching strings like these. + let b:ale_exclude_highlights = ['line too long', 'foo.*bar'] +< + See also: |g:ale_set_highlights| + + g:ale_fixers *g:ale_fixers* *b:ale_fixers* - Type: |Dictionary| Default: `{}` @@ -797,8 +1175,7 @@ g:ale_fixers *g:ale_fixers* < g:ale_fix_on_save *g:ale_fix_on_save* -b:ale_fix_on_save *b:ale_fix_on_save* - + *b:ale_fix_on_save* Type: |Number| Default: `0` @@ -819,8 +1196,7 @@ b:ale_fix_on_save *b:ale_fix_on_save* g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore* -b:ale_fix_on_save_ignore *b:ale_fix_on_save_ignore* - + *b:ale_fix_on_save_ignore* Type: |Dictionary| or |List| Default: `{}` @@ -852,6 +1228,60 @@ b:ale_fix_on_save_ignore *b:ale_fix_on_save_ignore* let g:ale_fix_on_save_ignore = [g:AddBar] < +g:ale_floating_preview *g:ale_floating_preview* + + Type: |Number| + Default: `0` + + When set to `1`, Neovim or Vim with |popupwin| will use a floating window + for ale's preview window. + This is equivalent to setting |g:ale_hover_to_floating_preview| and + |g:ale_detail_to_floating_preview| to `1`. + + +g:ale_floating_preview_popup_opts *g:ale_floating_preview_popup_opts* + + Type: |String| or |Dictionary| + Default: `''` + + Either a dictionary of options or the string name of a function that returns + a dictionary of options. This will be used as an argument to |popup_create| + for Vim users or |nvim_open_win| for NeoVim users. In either case, the + resulting dictionary is merged with ALE defaults rather than explicitly + overriding them. This only takes effect if |g:ale_floating_preview| is + enabled. + + NOTE: for Vim users see |popup_create-arguments|, for NeoVim users see + |nvim_open_win| for argument details + + For example, to enhance popups with a title: > + + function! CustomOpts() abort + let [l:info, l:loc] = ale#util#FindItemAtCursor(bufnr('')) + return {'title': ' ALE: ' . (l:loc.linter_name) . ' '} + endfunction + + let g:ale_floating_preview_popup_opts = 'g:CustomOpts' +< + +g:ale_floating_window_border *g:ale_floating_window_border* + + Type: |List| + Default: `['|', '-', '+', '+', '+', '+', '|', '-']` + + When set to `[]`, window borders are disabled. The elements in the list set + the characters for the left side, top, top-left corner, top-right + corner, bottom-right corner, bottom-left corner, right side, and bottom of + the floating window, respectively. + + If the terminal supports Unicode, you might try setting the value to + ` ['│', '─', '╭', '╮', '╯', '╰', '│', '─']`, to make it look nicer. + + NOTE: For compatibility with previous versions, if the list does not have + elements for the right side and bottom, the left side and top will be used + instead. + + g:ale_history_enabled *g:ale_history_enabled* Type: |Number| @@ -859,7 +1289,7 @@ g:ale_history_enabled *g:ale_history_enabled* When set to `1`, ALE will remember the last few commands which were run for every buffer which is open. This information can be viewed with the - |ALEInfo| command. The size of the buffer can be controlled with the + `:ALEInfo` command. The size of the buffer can be controlled with the |g:ale_max_buffer_history_size| option. This option can be disabled if storing a command history is not desired. @@ -872,7 +1302,7 @@ g:ale_history_log_output *g:ale_history_log_output* When set to `1`, ALE will store the output of commands which have completed successfully in the command history, and the output will be displayed when - using |ALEInfo|. + using `:ALEInfo`. |g:ale_history_enabled| must be set to `1` for this output to be stored or printed. @@ -882,6 +1312,52 @@ g:ale_history_log_output *g:ale_history_log_output* if you want to save on some memory usage. +g:ale_hover_cursor *g:ale_hover_cursor* + + Type: |Number| + Default: `1` + + If set to `1`, ALE will show truncated information in the echo line about + the symbol at the cursor automatically when the |CursorHold| event is fired. + The delay before requesting hover information is based on 'updatetime', as + with all |CursorHold| events. + + If there's a problem on the line where the cursor is resting, ALE will not + show any hover information. + + See |ale-hover| for more information on hover information. + + This setting must be set to `1` before ALE is loaded for this behavior + to be enabled. See |ale-lint-settings-on-startup|. + + +g:ale_hover_to_preview *g:ale_hover_to_preview* + *b:ale_hover_to_preview* + Type: |Number| + Default: `0` + + If set to `1`, hover messages will be displayed in the preview window, + instead of in balloons or the message line. + + +g:ale_hover_to_floating_preview *g:ale_hover_to_floating_preview* + *b:ale_hover_to_floating_preview* + Type: |Number| + Default: `0` + + If set to `1`, Neovim or Vim with |popupwin| will use floating windows for + hover messages. + + +g:ale_info_default_mode *g:ale_info_default_mode* + *b:ale_info_default_mode* + Type: |String| + Default: `'preview'` + + Changes the default mode used for `:ALEInfo`. See documentation for `:ALEInfo` + for more information. + + g:ale_keep_list_window_open *g:ale_keep_list_window_open* *b:ale_keep_list_window_open* Type: |Number| @@ -909,7 +1385,7 @@ g:ale_list_window_size *g:ale_list_window_size* g:ale_lint_delay *g:ale_lint_delay* - + *b:ale_lint_delay* Type: |Number| Default: `200` @@ -917,6 +1393,9 @@ g:ale_lint_delay *g:ale_lint_delay* be run after text is changed. This option is only meaningful with the |g:ale_lint_on_text_changed| variable set to `always`, `insert`, or `normal`. + A buffer-local option, `b:ale_lint_delay`, can be set to change the delay + for different buffers, such as in |ftplugin| files. + g:ale_lint_on_enter *g:ale_lint_on_enter* @@ -990,7 +1469,6 @@ g:ale_lint_on_text_changed *g:ale_lint_on_text_changed* g:ale_lint_on_insert_leave *g:ale_lint_on_insert_leave* *b:ale_lint_on_insert_leave* - Type: |Number| Default: `1` @@ -1027,9 +1505,14 @@ g:ale_linter_aliases *g:ale_linter_aliases* { \ 'Dockerfile': 'dockerfile', \ 'csh': 'sh', + \ 'javascriptreact': ['javascript', 'jsx'], \ 'plaintex': 'tex', + \ 'ps1': 'powershell', \ 'rmarkdown': 'r', + \ 'rmd': 'r', \ 'systemverilog': 'verilog', + \ 'typescriptreact': ['typescript', 'tsx'], + \ 'vader': ['vim', 'vader'], \ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'], \ 'vimwiki': 'markdown', \ 'vue': ['vue', 'javascript'], @@ -1070,6 +1553,89 @@ g:ale_linter_aliases *g:ale_linter_aliases* < No linters will be loaded when the buffer's filetype is empty. + +g:ale_filename_mappings *g:ale_filename_mappings* + *b:ale_filename_mappings* + Type: |Dictionary| or |List| + Default: `{}` + + Either a |Dictionary| mapping a linter or fixer name, as displayed in + `:ALEInfo`, to a |List| of two-item |List|s for filename mappings, or just a + |List| of two-item |List|s. When given some paths to files, the value of + this setting will be used to convert filenames on a local file system to + filenames on some remote file system, such as paths in a Docker image, + virtual machine, or network drive. + + For example: > + + let g:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/john/proj', '/data'], + \ ], + \} +< + With the above configuration, a filename such as `/home/john/proj/foo.py` + will be provided to the linter/fixer as `/data/foo.py`, and paths parsed + from linter results such as `/data/foo.py` will be converted back to + `/home/john/proj/foo.py`. + + You can use `*` as to apply a |List| of filename mappings to all other + linters or fixers not otherwise matched. > + + " Use one List of paths for pylint. + " Use another List of paths for everything else. + let g:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/john/proj', '/data'], + \ ], + \ '*': [ + \ ['/home/john/proj', '/other-data'], + \ ], + \} +< + If you just want every single linter or fixer to use the same filename + mapping, you can just use a |List|. > + + " Same as above, but for ALL linters and fixers. + let g:ale_filename_mappings = [ + \ ['/home/john/proj', '/data'], + \] +< + You can provide many such filename paths for multiple projects. Paths are + matched by checking if the start of a file path matches the given strings, + in a case-sensitive manner. Earlier entries in the |List| will be tried + before later entries when mapping to a given file system. + + Buffer-local options can be set to the same values to override the global + options, such as in |ftplugin| files. + + NOTE: Only fixers registered with a short name can support filename mapping + by their fixer names. See |ale-fix|. Filename mappings set for all tools by + using only a |List| for the setting will also be applied to fixers not in + the registry. + + NOTE: In order for this filename mapping to work correctly, linters and + fixers must exclusively determine paths to files to lint or fix via ALE + command formatting as per |ale-command-format-strings|, and paths parsed + from linter files must be provided in `filename` keys if a linter returns + results for more than one file at a time, as per |ale-loclist-format|. If + you discover a linter or fixer which does not behave properly, please report + it as an issue. + + If you are running a linter or fixer through Docker or another remote file + system, you may have to mount your temporary directory, which you can + discover with the following command: > + + :echo fnamemodify(tempname(), ':h:h') +< + You should provide a mapping from this temporary directory to whatever you + mount this directory to in Docker, or whatever remote file system you are + working with. + + You can inspect the filename mappings ALE will use with the + |ale#GetFilenameMappings()| function. + + g:ale_linters *g:ale_linters* *b:ale_linters* Type: |Dictionary| @@ -1082,19 +1648,29 @@ g:ale_linters *g:ale_linters* following values: > { + \ 'apkbuild': ['apkbuild_lint', 'secfixes_check'], \ 'csh': ['shell'], \ 'elixir': ['credo', 'dialyxir', 'dogma'], - \ 'go': ['gofmt', 'golint', 'go vet'], + \ 'go': ['gofmt', 'golangci-lint', 'gopls', 'govet'], + \ 'groovy': ['npm-groovy-lint'], \ 'hack': ['hack'], \ 'help': [], + \ 'inko': ['inko'], + \ 'json': ['jsonlint', 'spectral'], + \ 'json': ['jsonlint', 'spectral', 'vscodejson'], + \ 'json5': [], + \ 'jsonc': [], \ 'perl': ['perlcritic'], \ 'perl6': [], - \ 'python': ['flake8', 'mypy', 'pylint'], - \ 'rust': ['cargo'], + \ 'python': ['flake8', 'mypy', 'pylint', 'pyright', 'ruff'], + \ 'rust': ['analyzer', 'cargo'], \ 'spec': [], \ 'text': [], + \ 'vader': ['vimls'], \ 'vue': ['eslint', 'vls'], \ 'zsh': ['shell'], + \ 'v': ['v'], + \ 'yaml': ['actionlint', 'spectral', 'yaml-language-server', 'yamllint'], \} < This option can be used to enable only a particular set of linters for a @@ -1147,7 +1723,6 @@ g:ale_linters_explicit *g:ale_linters_explicit* g:ale_linters_ignore *g:ale_linters_ignore* *b:ale_linters_ignore* - Type: |Dictionary| or |List| Default: `{}` @@ -1182,8 +1757,7 @@ g:ale_list_vertical *g:ale_list_vertical* g:ale_loclist_msg_format *g:ale_loclist_msg_format* -b:ale_loclist_msg_format *b:ale_loclist_msg_format* - + *b:ale_loclist_msg_format* Type: |String| Default: `g:ale_echo_msg_format` @@ -1192,22 +1766,55 @@ b:ale_loclist_msg_format *b:ale_loclist_msg_format* The strings for configuring `%severity%` are also used for this option. -g:ale_lsp_root *g:ale_lsp_root* -b:ale_lsp_root *b:ale_lsp_root* - Type: |Dictionary| or |String| - Default: {} +g:ale_lsp_show_message_format *g:ale_lsp_show_message_format* - This option is used to determine the project root for the LSP linter. If the - value is a |Dictionary|, it maps a linter to either a string containing the - project root or a |Funcref| to call to look up the root. The funcref is - provided the buffer number as its argument. + Type: |String| + Default: `'%severity%:%linter%: %s'` - The buffer-specific variable may additionally be a string containing the - project root itself. + This variable defines the format that messages received from an LSP will + have when echoed. The following sequences of characters will be replaced. + + `%s` - replaced with the message text + `%linter%` - replaced with the name of the linter + `%severity%` - replaced with the severity of the message + + The strings for `%severity%` levels "error", "info" and "warning" are shared + with |g:ale_echo_msg_format|. Severity "log" is unique to + |g:ale_lsp_show_message_format| and it can be configured via + + |g:ale_echo_msg_log_str| - Defaults to `'Log'` + + Please note that |g:ale_lsp_show_message_format| *can not* be configured + separately for each buffer like |g:ale_echo_msg_format| can. + + +g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* + + Type: |String| + Default: `'error'` + + This variable defines the minimum severity level an LSP message needs to be + displayed. Messages below this level are discarded; please note that + messages with `Log` severity level are always discarded. + + Possible values follow the LSP spec `MessageType` definition: + + `'error'` - Displays only errors. + `'warning'` - Displays errors and warnings. + `'information'` - Displays errors, warnings and infos + `'log'` - Same as `'information'` + `'disabled'` - Doesn't display any information at all. + + +g:ale_lsp_suggestions *g:ale_lsp_suggestions* + + Type: |Number| + Default: `0` + + If set to `1`, show hints/suggestions from LSP servers or tsserver, in + addition to warnings and errors. - If neither variable yields a result, a linter-specific function is invoked to - detect a project root. If this, too, yields no result, the linter is disabled. g:ale_max_buffer_history_size *g:ale_max_buffer_history_size* @@ -1215,7 +1822,7 @@ g:ale_max_buffer_history_size *g:ale_max_buffer_history_size* Default: `20` This setting controls the maximum number of commands which will be stored in - the command history used for |ALEInfo|. Command history will be rotated in + the command history used for `:ALEInfo`. Command history will be rotated in a FIFO manner. If set to a number <= 0, then the history will be continuously set to an empty |List|. @@ -1227,6 +1834,8 @@ g:ale_max_signs *g:ale_max_signs* Type: |Number| Default: `-1` + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + When set to any positive integer, ALE will not render any more than the given number of signs for any one buffer. @@ -1242,7 +1851,7 @@ g:ale_max_signs *g:ale_max_signs* g:ale_maximum_file_size *g:ale_maximum_file_size* *b:ale_maximum_file_size* Type: |Number| - Default: undefined + Default: not set A maximum file size in bytes for ALE to check. If set to any positive number, ALE will skip checking files larger than the given size. @@ -1257,6 +1866,9 @@ g:ale_open_list *g:ale_open_list* loclist (|lopen|) or for the quickfix list instead if |g:ale_set_quickfix| is `1`. (|copen|) + When set to any higher numberical value, ALE will only open the window when + the number of warnings or errors are at least that many. + When set to `'on_save'`, ALE will only open the loclist after buffers have been saved. The list will be opened some time after buffers are saved and any linter for a buffer returns results. @@ -1277,12 +1889,12 @@ g:ale_open_list *g:ale_open_list* autocmd! autocmd QuitPre * if empty(&buftype) | lclose | endif augroup END -< +< g:ale_pattern_options *g:ale_pattern_options* Type: |Dictionary| - Default: undefined + Default: not set This option maps regular expression patterns to |Dictionary| values for buffer variables. This option can be set to automatically configure @@ -1311,16 +1923,78 @@ g:ale_pattern_options *g:ale_pattern_options* g:ale_pattern_options_enabled *g:ale_pattern_options_enabled* Type: |Number| - Default: undefined + Default: not set This option can be used for disabling pattern options. If set to `0`, ALE will not set buffer variables per |g:ale_pattern_options|. -g:ale_set_balloons *g:ale_set_balloons* - *b:ale_set_balloons* +g:ale_popup_menu_enabled *g:ale_popup_menu_enabled* Type: |Number| + Default: `has('gui_running')` + + When this option is set to `1`, ALE will show code actions and rename + capabilities in the right click mouse menu when there's a LSP server or + tsserver available. See |ale-refactor|. + + This feature is only supported in GUI versions of Vim. + + This setting must be set to `1` before ALE is loaded for this behavior + to be enabled. See |ale-lint-settings-on-startup|. + + +g:ale_rename_tsserver_find_in_comments *g:ale_rename_tsserver_find_in_comments* + + Type: |Number| + Default: `0` + + If enabled, this option will tell tsserver to find and replace text in + comments when calling `:ALERename`. It can be enabled by settings the value + to `1`. + + +g:ale_rename_tsserver_find_in_strings *g:ale_rename_tsserver_find_in_strings* + + Type: |Number| + Default: `0` + + If enabled, this option will tell tsserver to find and replace text in + strings when calling `:ALERename`. It can be enabled by settings the value to + `1`. + + +g:ale_root *g:ale_root* + *b:ale_root* + Type: |Dictionary| or |String| + Default: `{}` + + This option is used to determine the project root for a linter. If the value + is a |Dictionary|, it maps a linter to either a |String| containing the + project root or a |Funcref| to call to look up the root. The |Funcref| is + provided the buffer number as its argument. + + The buffer-specific variable may additionally be a string containing the + project root itself. + + If neither variable yields a result, a linter-specific function is invoked to + detect a project root. If this, too, yields no result, and the linter is an + LSP linter, it will not run. + + +g:ale_save_hidden *g:ale_save_hidden* + + Type: |Number| + Default: `0` + + When set to `1`, save buffers when 'hidden' is set when applying code + actions or rename operations, such as through `:ALERename` or + `:ALEOrganizeImports`. + + +g:ale_set_balloons *g:ale_set_balloons* + *b:ale_set_balloons* + Type: |Number| or |String| Default: `has('balloon_eval') && has('gui_running')` When this option is set to `1`, balloon messages will be displayed for @@ -1331,6 +2005,12 @@ g:ale_set_balloons *g:ale_set_balloons* supporting "Hover" information, per |ale-hover|, then brief information about the symbol under the cursor will be displayed in a balloon. + This option can be set to `'hover'` to only enable balloons for hover + message, so diagnostics are never shown in balloons. You may wish to + configure use this setting only in GUI Vim like so: > + + let g:ale_set_balloons = has('gui_running') ? 'hover' : 0 +< Balloons can be enabled for terminal versions of Vim that support balloons, but some versions of Vim will produce strange mouse behavior when balloons are enabled. To configure balloons for your terminal, you should first @@ -1347,7 +2027,7 @@ g:ale_set_balloons *g:ale_set_balloons* g:ale_set_balloons_legacy_echo *g:ale_set_balloons_legacy_echo* *b:ale_set_balloons_legacy_echo* Type: |Number| - Default: undefined + Default: not set If set to `1`, moving your mouse over documents in Vim will make ALE ask `tsserver` or `LSP` servers for information about the symbol where the mouse @@ -1364,36 +2044,45 @@ g:ale_set_highlights *g:ale_set_highlights* Type: |Number| Default: `has('syntax')` + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + In addition, ALE's highlight groups will not be used when setting + highlights through Neovim's diagnostics API. See |diagnostic-highlights| for + how to configure Neovim diagnostic highlighting. + When this option is set to `1`, highlights will be set for problems. ALE will use the following highlight groups for problems: - |ALEError| - Items with `'type': 'E'` - |ALEWarning| - Items with `'type': 'W'` - |ALEInfo.| - Items with `'type': 'I'` - |ALEStyleError| - Items with `'type': 'E'` and `'sub_type': 'style'` - |ALEStyleWarning| - Items with `'type': 'W'` and `'sub_type': 'style'` + ALEError items with `'type': 'E'` |hl-ALEError| + ALEWarning items with `'type': 'W'` |hl-ALEWarning| + ALEInfo items with `'type': 'I'` |hl-ALEInfo| + ALEStyleError items with `'type': 'E'` and + `'sub_type': 'style'` |hl-ALEStyleError| + ALEStyleWarning items with `'type': 'W'` and + `'sub_type': 'style'` |hl-ALEStyleWarning| When |g:ale_set_signs| is set to `0`, the following highlights for entire lines will be set. - |ALEErrorLine| - All items with `'type': 'E'` - |ALEWarningLine| - All items with `'type': 'W'` - |ALEInfoLine| - All items with `'type': 'I'` + ALEErrorLine all items with `'type': 'E'` |hl-ALEErrorLine| + ALEWarningLine all items with `'type': 'W'` |hl-ALEWarningLine| + ALEInfoLine all items with `'type': 'I'` |hl-ALEInfoLine| Vim can only highlight the characters up to the last column in a buffer for match highlights, whereas the line highlights when signs are enabled will run to the edge of the screen. + Highlights can be excluded with the |g:ale_exclude_highlights| option. + g:ale_set_loclist *g:ale_set_loclist* Type: |Number| Default: `1` - When this option is set to `1`, the |loclist| will be populated with any - warnings and errors which are found by ALE. This feature can be used to - implement jumping between errors through typical use of |lnext| and |lprev|. + When this option is set to `1`, the |location-list| will be populated with + any warnings and errors which are found by ALE. This feature can be used to + implement jumping between errors through typical use of `:lnext` and `:lprev`. g:ale_set_quickfix *g:ale_set_quickfix* @@ -1402,16 +2091,16 @@ g:ale_set_quickfix *g:ale_set_quickfix* Default: `0` When this option is set to `1`, the |quickfix| list will be populated with - any problems which are found by ALE, instead of the |loclist|. The loclist - will never be populated when this option is on. + any problems which are found by ALE, instead of the |location-list|. The + loclist will never be populated when this option is on. Problems from every buffer ALE has checked will be included in the quickfix - list, which can be checked with |:copen|. Problems will be de-duplicated. + list, which can be checked with `:copen`. Problems will be de-duplicated. This feature should not be used in combination with tools for searching for - matches and commands like |:cfdo|, as ALE will replace the quickfix list + matches and commands like `:cfdo`, as ALE will replace the quickfix list pretty frequently. If you wish to use such tools, you should populate the - loclist instead. + loclist or use `:ALEPopulateQuickfix` instead. g:ale_set_signs *g:ale_set_signs* @@ -1422,29 +2111,42 @@ g:ale_set_signs *g:ale_set_signs* When this option is set to `1`, the |sign| column will be populated with signs marking where problems appear in the file. + When |g:ale_use_neovim_diagnostics_api| is `1`, the only other setting that + will be respected for signs is |g:ale_sign_priority|. ALE's highlight groups + will and other sign settings will not apply when setting signs through + Neovim's diagnostics API. See |diagnostic-signs| for how to configure signs + in Neovim. + ALE will use the following highlight groups for problems: - |ALEErrorSign| - Items with `'type': 'E'` - |ALEWarningSign| - Items with `'type': 'W'` - |ALEInfoSign| - Items with `'type': 'I'` - |ALEStyleErrorSign| - Items with `'type': 'E'` and `'sub_type': 'style'` - |ALEStyleWarningSign| - Items with `'type': 'W'` and `'sub_type': 'style'` + ALEErrorSign items with `'type': 'E'` |hl-ALEErrorSign| + ALEWarningSign items with `'type': 'W'` |hl-ALEWarningSign| + ALEInfoSign items with `'type': 'I'` |hl-ALEInfoSign| + ALEStyleErrorSign items with `'type': 'E'` and + `'sub_type': 'style'` |hl-ALEStyleErrorSign| + ALEStyleWarningSign items with `'type': 'W'` and + `'sub_type': 'style'` |hl-ALEStyleWarningSign| In addition to the style of the signs, the style of lines where signs appear can be configured with the following highlights: - |ALEErrorLine| - All items with `'type': 'E'` - |ALEWarningLine| - All items with `'type': 'W'` - |ALEInfoLine| - All items with `'type': 'I'` + ALEErrorLine all items with `'type': 'E'` |hl-ALEErrorLine| + ALEWarningLine all items with `'type': 'W'` |hl-ALEWarningLine| + ALEInfoLine all items with `'type': 'I'` |hl-ALEInfoLine| - With Neovim 0.3.2 or higher, ALE uses `numhl` option to highlight 'number' - column. It uses the following highlight groups. + With Neovim 0.3.2 or higher, ALE can use the `numhl` option to highlight the + 'number' column. It uses the following highlight groups. - |ALEErrorSignLineNr| - Items with `'type': 'E'` - |ALEWarningSignLineNr| - Items with `'type': 'W'` - |ALEInfoSignLineNr| - Items with `'type': 'I'` - |ALEStyleErrorSignLineNr| - Items with `'type': 'E'` and `'sub_type': 'style'` - |ALEStyleWarningSignLineNr| - Items with `'type': 'W'` and `'sub_type': 'style'` + ALEErrorSignLineNr items with `'type': 'E'` |hl-ALEErrorSignLineNr| + ALEWarningSignLineNr items with `'type': 'W'` |hl-ALEWarningSignLineNr| + ALEInfoSignLineNr items with `'type': 'I'` |hl-ALEInfoSignLineNr| + ALEStyleErrorSignLineNr items with `'type': 'E'` and + `'sub_type': 'style'` |hl-ALEStyleErrorSignLineNr| + ALEStyleWarningSignLineNr items with `'type': 'W'` and + `'sub_type': 'style'` |hl-ALEStyleWarningSignLineNr| + + To enable line number highlighting |g:ale_sign_highlight_linenrs| must be + set to `1` before ALE is loaded. The markers for the highlights can be customized with the following options: @@ -1460,8 +2162,18 @@ g:ale_set_signs *g:ale_set_signs* To limit the number of signs ALE will set, see |g:ale_max_signs|. -g:ale_shell *g:ale_shell* +g:ale_sign_priority *g:ale_sign_priority* + Type: |Number| + Default: `30` + + From Neovim 0.4.0 and Vim 8.1, ALE can set sign priority to all signs. The + larger this value is, the higher priority ALE signs have over other plugin + signs. See |sign-priority| for further details on how priority works. + + +g:ale_shell *g:ale_shell* + *b:ale_shell* Type: |String| Default: not set @@ -1478,7 +2190,7 @@ g:ale_shell *g:ale_shell* g:ale_shell_arguments *g:ale_shell_arguments* - + *b:ale_shell_arguments* Type: |String| Default: not set @@ -1492,6 +2204,8 @@ g:ale_sign_column_always *g:ale_sign_column_always* Type: |Number| Default: `0` + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + By default, the sign gutter will disappear when all warnings and errors have been fixed for a file. When this option is set to `1`, the sign column will remain open. This can be preferable if you don't want the text in your file @@ -1501,7 +2215,9 @@ g:ale_sign_column_always *g:ale_sign_column_always* g:ale_sign_error *g:ale_sign_error* Type: |String| - Default: `'>>'` + Default: `'E'` + + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. The sign for errors in the sign gutter. @@ -1509,7 +2225,9 @@ g:ale_sign_error *g:ale_sign_error* g:ale_sign_info *g:ale_sign_info* Type: |String| - Default: `g:ale_sign_warning` + Default: `'I'` + + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. The sign for "info" markers in the sign gutter. @@ -1519,6 +2237,8 @@ g:ale_sign_style_error *g:ale_sign_style_error* Type: |String| Default: `g:ale_sign_error` + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + The sign for style errors in the sign gutter. @@ -1527,6 +2247,8 @@ g:ale_sign_style_warning *g:ale_sign_style_warning* Type: |String| Default: `g:ale_sign_warning` + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + The sign for style warnings in the sign gutter. @@ -1535,6 +2257,8 @@ g:ale_sign_offset *g:ale_sign_offset* Type: |Number| Default: `1000000` + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + This variable controls offset from which numeric IDs will be generated for new signs. Signs cannot share the same ID values, so when two Vim plugins set signs at the same time, the IDs have to be configured such that they do @@ -1547,17 +2271,31 @@ g:ale_sign_offset *g:ale_sign_offset* g:ale_sign_warning *g:ale_sign_warning* Type: |String| - Default: `'--'` + Default: `'W'` + + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. The sign for warnings in the sign gutter. +g:ale_sign_highlight_linenrs *g:ale_sign_highlight_linenrs* + + Type: |Number| + Default: `0` + + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + + When set to `1`, this option enables highlighting problems on the 'number' + column in Vim versions that support `numhl` highlights. This option must be + configured before ALE is loaded. + + g:ale_update_tagstack *g:ale_update_tagstack* *b:ale_update_tagstack* - Type: |Number| - Default: `1` + Type: |Number| + Default: `1` - This option can be set to disable updating Vim's |tagstack| automatically. + This option can be set to disable updating Vim's |tagstack| automatically. g:ale_type_map *g:ale_type_map* @@ -1601,35 +2339,63 @@ g:ale_use_global_executables *g:ale_use_global_executables* options. +g:ale_use_neovim_diagnostics_api *g:ale_use_neovim_diagnostics_api* + + Type: |Number| + Default: `has('nvim-0.7')` + + If enabled, this option will disable ALE's standard UI, and instead send + all linter output to Neovim's diagnostics API. This allows you to collect + errors from nvim-lsp, ALE, and anything else that uses diagnostics all in + one place. Many options for configuring how problems appear on the screen + will not apply when the API is enabled. + + To enable this option, set the value to `1`. + + This option requires Neovim 0.7+, as that version introduces the diagnostics + API. + + g:ale_virtualtext_cursor *g:ale_virtualtext_cursor* Type: |Number| - Default: `0` + Default: `'all'` (if supported, otherwise `'disabled'`) - When this option is set to `1`, a message will be shown when a cursor is - near a warning or error. ALE will attempt to find the warning or error at a - column nearest to the cursor when the cursor is resting on a line which - contains a warning or error. This option can be set to `0` to disable this - behavior. + This option controls how ALE will display problems using |virtual-text|. + The following values can be used. + + `'all'`, `'2'`, or `2` - Show problems for all lines. + `'current'`, `'1'`, or `1` - Show problems for the current line. + `'disabled'`, `'0'`, or `0` - Do not show problems with virtual-text. + + When |g:ale_use_neovim_diagnostics_api| is `1`, `'current'` will behave the + same as `'all'`. Messages are only displayed after a short delay. See |g:ale_virtualtext_delay|. - Messages can be prefixed prefixed with a string. See |g:ale_virtualtext_prefix|. + Messages can be prefixed with a string if not using Neovim's diagnostics + API. See |g:ale_virtualtext_prefix|. - ALE will use the following highlight groups for problems: + If and only if not displaying problems via Neovim's diagnostics API, + highlights for configuring ALE's virtualtext messages can be configured with + custom highlight groups: - |ALEVirtualTextError| - Items with `'type': 'E'` - |ALEVirtualTextWarning| - Items with `'type': 'W'` - |ALEVirtualTextInfo| - Items with `'type': 'I'` - |ALEVirtualTextStyleError| - Items with `'type': 'E'` and `'sub_type': 'style'` - |ALEVirtualTextStyleWarning| - Items with `'type': 'W'` and `'sub_type': 'style'` + ALEVirtualTextError items with `'type': 'E'` |hl-ALEVirtualTextError| + ALEVirtualTextWarning items with `'type': 'W'` |hl-ALEVirtualTextWarning| + ALEVirtualTextInfo items with `'type': 'I'` |hl-ALEVirtualTextInfo| + ALEVirtualTextStyleError items with `'type': 'E'` and + `'sub_type': 'style'` |hl-ALEVirtualTextStyleError| + ALEVirtualTextStyleWarning items with `'type': 'W'` and + `'sub_type': 'style'` |hl-ALEVirtualTextStyleWarning| g:ale_virtualtext_delay *g:ale_virtualtext_delay* -b:ale_virtualtext_delay *b:ale_virtualtext_delay* + *b:ale_virtualtext_delay* Type: |Number| Default: `10` + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + Given any integer, this option controls the number of milliseconds before ALE will show a message for a problem near the cursor. @@ -1638,20 +2404,75 @@ b:ale_virtualtext_delay *b:ale_virtualtext_delay* g:ale_virtualtext_prefix *g:ale_virtualtext_prefix* - + *b:ale_virtualtext_prefix* Type: |String| - Default: `'> '` + Default: `'%comment% %type%: '` + + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. Prefix to be used with |g:ale_virtualtext_cursor|. -g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names* -b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* + This setting can be changed in each buffer with |b:ale_virtualtext_prefix||. + All of the same format markers used for |g:ale_echo_msg_format| can be used + for defining the prefix, including some additional sequences of characters. + + `%comment%` - replaced with comment characters in the current language + + ALE will read the comment characters from 'commentstring', reading only the + part before `%s`, with whitespace trimmed. If comment syntax cannot be + pulled from 'commentstring', ALE will default to `'#'`. + + +g:ale_virtualtext_column *g:ale_virtualtext_column* + *b:ale_virtualtext_column* +g:ale_virtualtext_maxcolumn *g:ale_virtualtext_maxcolumn* + *b:ale_virtualtext_maxcolumn* + Type: |String| or |Number| + Default: `0` + + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + + Virtualtext column range, from `column` to `maxcolumn`. If a line is + `column` or less characters long, the virtualtext message is shifted right + to `column`. + + Where the line is greater than `column` characters long, but less than + `maxcolumn`, the virtualtext message is placed at the end of the line. + + Where the line is greater than `maxcolumn` the virtualtext message is + omitted. + + A |Number| greater than `0` is used as the fixed column position, however + a |String| ending in `%` represents a percentage of the window width. + When `column` is set to zero, column positioning is disabled, when `maxcolumn` + is set to zero, no maximum line length is enforced. + + +g:ale_virtualtext_single *g:ale_virtualtext_single* + *b:ale_virtualtext_single* + Type: |Number| + Default: `1` + + This setting has no effect when |g:ale_use_neovim_diagnostics_api| is `1`. + + Enable or disable concatenation of multiple virtual text messages on a single + line. By default, if a line has multiple errors or warnings, each will be + appended in turn. + + With `single` set to a non-zero value, only the first problem on a line will + be printed with virtual text. The most severe problem on a line will be + printed. If two problems exist on a line of equal severity, the problem at + the left-most position will be printed. + + +g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names* + *b:ale_virtualenv_dir_names* Type: |List| - Default: `['.env', '.venv', 'env', 've-py3', 've', 'virtualenv', 'venv']` + Default: `['.venv', 'env', 've', 'venv', 'virtualenv', '.env']` A list of directory names to be used when searching upwards from Python - files to discover virtulenv directories with. + files to discover virtualenv directories with. For directory named `'foo'`, ALE will search for `'foo/bin/activate'` (`foo\Scripts\activate\` on Windows) in all directories on and above the @@ -1659,8 +2480,7 @@ b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* g:ale_warn_about_trailing_blank_lines *g:ale_warn_about_trailing_blank_lines* -b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines* - + *b:ale_warn_about_trailing_blank_lines* Type: |Number| Default: `1` @@ -1671,8 +2491,7 @@ b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines* g:ale_warn_about_trailing_whitespace *g:ale_warn_about_trailing_whitespace* -b:ale_warn_about_trailing_whitespace *b:ale_warn_about_trailing_whitespace* - + *b:ale_warn_about_trailing_whitespace* Type: |Number| Default: `1` @@ -1689,7 +2508,6 @@ b:ale_warn_about_trailing_whitespace *b:ale_warn_about_trailing_whitespace* g:ale_windows_node_executable_path *g:ale_windows_node_executable_path* *b:ale_windows_node_executable_path* - Type: |String| Default: `'node.exe'` @@ -1706,14 +2524,14 @@ g:ale_windows_node_executable_path *g:ale_windows_node_executable_path* ------------------------------------------------------------------------------- 6.1. Highlights *ale-highlights* -ALEError *ALEError* +ALEError *hl-ALEError* Default: `highlight link ALEError SpellBad` The highlight for highlighted errors. See |g:ale_set_highlights|. -ALEErrorLine *ALEErrorLine* +ALEErrorLine *hl-ALEErrorLine* Default: Undefined @@ -1723,14 +2541,14 @@ ALEErrorLine *ALEErrorLine* See |g:ale_set_signs| and |g:ale_set_highlights|. -ALEErrorSign *ALEErrorSign* +ALEErrorSign *hl-ALEErrorSign* Default: `highlight link ALEErrorSign error` The highlight for error signs. See |g:ale_set_signs|. -ALEErrorSignLineNr *ALEErrorSignLineNr* +ALEErrorSignLineNr *hl-ALEErrorSignLineNr* Default: `highlight link ALEErrorSignLineNr CursorLineNr` @@ -1739,21 +2557,21 @@ ALEErrorSignLineNr *ALEErrorSignLineNr* NOTE: This highlight is only available on Neovim 0.3.2 or higher. -ALEInfo *ALEInfo.* +ALEInfo *hl-ALEInfo* *ALEInfo-highlight* Default: `highlight link ALEInfo ALEWarning` The highlight for highlighted info messages. See |g:ale_set_highlights|. -ALEInfoSign *ALEInfoSign* +ALEInfoSign *hl-ALEInfoSign* Default: `highlight link ALEInfoSign ALEWarningSign` The highlight for info message signs. See |g:ale_set_signs|. -ALEInfoLine *ALEInfoLine* +ALEInfoLine *hl-ALEInfoLine* Default: Undefined @@ -1763,7 +2581,7 @@ ALEInfoLine *ALEInfoLine* See |g:ale_set_signs| and |g:ale_set_highlights|. -ALEInfoSignLineNr *ALEInfoSignLineNr* +ALEInfoSignLineNr *hl-ALEInfoSignLineNr* Default: `highlight link ALEInfoSignLineNr CursorLineNr` @@ -1772,21 +2590,21 @@ ALEInfoSignLineNr *ALEInfoSignLineNr* NOTE: This highlight is only available on Neovim 0.3.2 or higher. -ALEStyleError *ALEStyleError* +ALEStyleError *hl-ALEStyleError* Default: `highlight link ALEStyleError ALEError` The highlight for highlighted style errors. See |g:ale_set_highlights|. -ALEStyleErrorSign *ALEStyleErrorSign* +ALEStyleErrorSign *hl-ALEStyleErrorSign* Default: `highlight link ALEStyleErrorSign ALEErrorSign` The highlight for style error signs. See |g:ale_set_signs|. -ALEStyleErrorSignLineNr *ALEStyleErrorSignLineNr* +ALEStyleErrorSignLineNr *hl-ALEStyleErrorSignLineNr* Default: `highlight link ALEStyleErrorSignLineNr CursorLineNr` @@ -1795,21 +2613,21 @@ ALEStyleErrorSignLineNr *ALEStyleErrorSignLineNr* NOTE: This highlight is only available on Neovim 0.3.2 or higher. -ALEStyleWarning *ALEStyleWarning* +ALEStyleWarning *hl-ALEStyleWarning* Default: `highlight link ALEStyleWarning ALEError` The highlight for highlighted style warnings. See |g:ale_set_highlights|. -ALEStyleWarningSign *ALEStyleWarningSign* +ALEStyleWarningSign *hl-ALEStyleWarningSign* Default: `highlight link ALEStyleWarningSign ALEWarningSign` The highlight for style warning signs. See |g:ale_set_signs|. -ALEStyleWarningSignLineNr *ALEStyleWarningSignLineNr* +ALEStyleWarningSignLineNr *hl-ALEStyleWarningSignLineNr* Default: `highlight link ALEStyleWarningSignLineNr CursorLineNr` @@ -1818,49 +2636,49 @@ ALEStyleWarningSignLineNr *ALEStyleWarningSignLineNr* NOTE: This highlight is only available on Neovim 0.3.2 or higher. -ALEVirtualTextError *ALEVirtualTextError* +ALEVirtualTextError *hl-ALEVirtualTextError* - Default: `highlight link ALEVirtualTextError ALEError` + Default: `highlight link ALEVirtualTextError Comment` The highlight for virtualtext errors. See |g:ale_virtualtext_cursor|. -ALEVirtualTextInfo *ALEVirtualTextInfo* +ALEVirtualTextInfo *hl-ALEVirtualTextInfo* Default: `highlight link ALEVirtualTextInfo ALEVirtualTextWarning` The highlight for virtualtext info. See |g:ale_virtualtext_cursor|. -ALEVirtualTextStyleError *ALEVirtualTextStyleError* +ALEVirtualTextStyleError *hl-ALEVirtualTextStyleError* Default: `highlight link ALEVirtualTextStyleError ALEVirtualTextError` The highlight for virtualtext style errors. See |g:ale_virtualtext_cursor|. -ALEVirtualTextStyleWarning *ALEVirtualTextStyleWarning* +ALEVirtualTextStyleWarning *hl-ALEVirtualTextStyleWarning* Default: `highlight link ALEVirtualTextStyleWarning ALEVirtualTextWarning` The highlight for virtualtext style warnings. See |g:ale_virtualtext_cursor|. -ALEVirtualTextWarning *ALEVirtualTextWarning* +ALEVirtualTextWarning *hl-ALEVirtualTextWarning* - Default: `highlight link ALEVirtualTextWarning ALEWarning` + Default: `highlight link ALEVirtualTextWarning Comment` The highlight for virtualtext errors. See |g:ale_virtualtext_cursor|. -ALEWarning *ALEWarning* +ALEWarning *hl-ALEWarning* Default: `highlight link ALEWarning SpellCap` The highlight for highlighted warnings. See |g:ale_set_highlights|. -ALEWarningLine *ALEWarningLine* +ALEWarningLine *hl-ALEWarningLine* Default: Undefined @@ -1870,14 +2688,14 @@ ALEWarningLine *ALEWarningLine* See |g:ale_set_signs| and |g:ale_set_highlights|. -ALEWarningSign *ALEWarningSign* +ALEWarningSign *hl-ALEWarningSign* Default: `highlight link ALEWarningSign todo` The highlight for warning signs. See |g:ale_set_signs|. -ALEWarningSignLineNr *ALEWarningSignLineNr* +ALEWarningSignLineNr *hl-ALEWarningSignLineNr* Default: `highlight link ALEWarningSignLineNr CursorLineNr` @@ -1892,8 +2710,8 @@ ALEWarningSignLineNr *ALEWarningSignLineNr* Linter and fixer options are documented below and in individual help files. Every option for programs can be set globally, or individually for each -buffer. For example, `b:ale_python_flake8_executable` will override any -values set for `g:ale_python_flake8_executable`. +buffer. For example, |b:ale_python_flake8_executable| will override any +values set for |g:ale_python_flake8_executable|. *ale-integrations-local-executables* @@ -1943,7 +2761,80 @@ g:ale_alex_use_global *g:ale_alex_use_global* ------------------------------------------------------------------------------- -7.2. Options for languagetool *ale-languagetool-options* +7.2. Options for cspell *ale-cspell-options* + +The options for `cspell` are shared between all filetypes, so options can be +configured only once. + +g:ale_cspell_executable *g:ale_cspell_executable* + *b:ale_cspell_executable* + Type: |String| + Default: `'cspell'` + + See |ale-integrations-local-executables| + + +g:ale_cspell_options *g:ale_cspell_options* + *b:ale_cspell_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to `cspell`. + + +g:ale_cspell_use_global *g:ale_cspell_use_global* + *b:ale_cspell_use_global* + Type: |Number| + Default: `get(g: 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- +7.3. Options for dprint *ale-dprint-options* + +`dprint` is a fixer for many file types, including: (java|type)script, +json(c?), markdown, and more. See https://dprint.dev/plugins for an up-to-date +list of supported plugins and their configuration options. + +g:ale_dprint_executable *g:ale_dprint_executable* + *b:ale_dprint_executable* + Type: |String| + Default: `'dprint'` + + See |ale-integrations-local-executables| + + +g:ale_dprint_config *g:ale_dprint_config* + *b:ale_dprint_config* + Type: |String| + Default: `'dprint.json'` + + This variable can be changed to provide a config file to `dprint`. The + default is the nearest `dprint.json` searching upward from the current + buffer. + + See https://dprint.dev/config and https://plugins.dprint.dev + + +g:ale_dprint_options *g:ale_dprint_options* + *b:ale_dprint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to `dprint`. + + +g:ale_dprint_use_global *g:ale_dprint_use_global* + *b:ale_dprint_use_global* + Type: |Number| + Default: `get(g: 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- +7.4. Options for languagetool *ale-languagetool-options* g:ale_languagetool_executable *g:ale_languagetool_executable* *b:ale_languagetool_executable* @@ -1954,8 +2845,16 @@ g:ale_languagetool_executable *g:ale_languagetool_executable* The executable to run for languagetool. +g:ale_languagetool_options *g:ale_languagetool_options* + *b:ale_languagetool_options* + Type: |String| + Default: `'--autoDetect'` + + This variable can be set to pass additional options to languagetool. + + ------------------------------------------------------------------------------- -7.3. Options for write-good *ale-write-good-options* +7.5. Options for write-good *ale-write-good-options* The options for `write-good` are shared between all filetypes, so options can be configured once. @@ -1985,81 +2884,134 @@ g:ale_writegood_use_global *g:ale_writegood_use_global* ------------------------------------------------------------------------------- -7.4. Other Linter/Fixer Options *ale-other-integration-options* +7.6. Other Linter/Fixer Options *ale-other-integration-options* ALE supports a very wide variety of tools. Other linter or fixer options are documented in additional help files. ada.....................................|ale-ada-options| + cspell................................|ale-ada-cspell| gcc...................................|ale-ada-gcc| gnatpp................................|ale-ada-gnatpp| + ada-language-server...................|ale-ada-language-server| ansible.................................|ale-ansible-options| + ansible-language-server...............|ale-ansible-language-server| ansible-lint..........................|ale-ansible-ansible-lint| + apkbuild................................|ale-apkbuild-options| + apkbuild-fixer........................|ale-apkbuild-apkbuild-fixer| + apkbuild-lint.........................|ale-apkbuild-apkbuild-lint| + secfixes-check........................|ale-apkbuild-secfixes-check| asciidoc................................|ale-asciidoc-options| + cspell................................|ale-asciidoc-cspell| write-good............................|ale-asciidoc-write-good| textlint..............................|ale-asciidoc-textlint| 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| gawk..................................|ale-awk-gawk| + bats....................................|ale-bats-options| + shellcheck............................|ale-bats-shellcheck| + bazel...................................|ale-bazel-options| + buildifier............................|ale-bazel-buildifier| bib.....................................|ale-bib-options| bibclean..............................|ale-bib-bibclean| + bicep...................................|ale-bicep-options| + bicep.................................|ale-bicep-bicep| + az_bicep..............................|ale-bicep-az_bicep| + bitbake.................................|ale-bitbake-options| + oelint-adv............................|ale-bitbake-oelint_adv| c.......................................|ale-c-options| - clang.................................|ale-c-clang| + astyle................................|ale-c-astyle| + cc....................................|ale-c-cc| + ccls..................................|ale-c-ccls| + clangcheck............................|ale-c-clangcheck| clangd................................|ale-c-clangd| clang-format..........................|ale-c-clangformat| clangtidy.............................|ale-c-clangtidy| cppcheck..............................|ale-c-cppcheck| cquery................................|ale-c-cquery| + cspell................................|ale-c-cspell| flawfinder............................|ale-c-flawfinder| - gcc...................................|ale-c-gcc| uncrustify............................|ale-c-uncrustify| - ccls..................................|ale-c-ccls| + cairo...................................|ale-cairo-options| + scarb.................................|ale-cairo-scarb| + starknet..............................|ale-cairo-starknet| chef....................................|ale-chef-options| cookstyle.............................|ale-chef-cookstyle| foodcritic............................|ale-chef-foodcritic| clojure.................................|ale-clojure-options| clj-kondo.............................|ale-clojure-clj-kondo| + cljfmt................................|ale-clojure-cljfmt| joker.................................|ale-clojure-joker| cloudformation..........................|ale-cloudformation-options| cfn-python-lint.......................|ale-cloudformation-cfn-python-lint| cmake...................................|ale-cmake-options| cmakelint.............................|ale-cmake-cmakelint| + cmake-lint............................|ale-cmake-cmake-lint| cmake-format..........................|ale-cmake-cmakeformat| cpp.....................................|ale-cpp-options| - clang.................................|ale-cpp-clang| - clangd................................|ale-cpp-clangd| + astyle................................|ale-cpp-astyle| + cc....................................|ale-cpp-cc| + ccls..................................|ale-cpp-ccls| clangcheck............................|ale-cpp-clangcheck| + clangd................................|ale-cpp-clangd| clang-format..........................|ale-cpp-clangformat| clangtidy.............................|ale-cpp-clangtidy| clazy.................................|ale-cpp-clazy| cppcheck..............................|ale-cpp-cppcheck| cpplint...............................|ale-cpp-cpplint| cquery................................|ale-cpp-cquery| + cspell................................|ale-cpp-cspell| flawfinder............................|ale-cpp-flawfinder| - gcc...................................|ale-cpp-gcc| uncrustify............................|ale-cpp-uncrustify| - ccls..................................|ale-cpp-ccls| c#......................................|ale-cs-options| + clang-format..........................|ale-cs-clangformat| csc...................................|ale-cs-csc| + cspell................................|ale-cs-cspell| + dotnet-format.........................|ale-cs-dotnet-format| mcs...................................|ale-cs-mcs| mcsc..................................|ale-cs-mcsc| uncrustify............................|ale-cs-uncrustify| css.....................................|ale-css-options| + cspell................................|ale-css-cspell| + css-beautify..........................|ale-css-css-beautify| fecs..................................|ale-css-fecs| prettier..............................|ale-css-prettier| stylelint.............................|ale-css-stylelint| + vscodecss.............................|ale-css-vscode| cuda....................................|ale-cuda-options| - nvcc..................................|ale-cuda-nvcc| clang-format..........................|ale-cuda-clangformat| + clangd................................|ale-cuda-clangd| + nvcc..................................|ale-cuda-nvcc| + c3......................................|ale-c3-options| + c3lsp.................................|ale-c3-c3lsp| d.......................................|ale-d-options| + dfmt..................................|ale-d-dfmt| dls...................................|ale-d-dls| uncrustify............................|ale-d-uncrustify| + dafny...................................|ale-dafny-options| + dafny.................................|ale-dafny-dafny| dart....................................|ale-dart-options| - dartanalyzer..........................|ale-dart-dartanalyzer| + analysis_server.......................|ale-dart-analysis_server| + dart-analyze..........................|ale-dart-analyze| + dart-format...........................|ale-dart-format| dartfmt...............................|ale-dart-dartfmt| + desktop.................................|ale-desktop-options| + desktop-file-validate.................|ale-desktop-desktop-file-validate| + dhall...................................|ale-dhall-options| + dhall-format..........................|ale-dhall-format| + dhall-freeze..........................|ale-dhall-freeze| + dhall-lint............................|ale-dhall-lint| dockerfile..............................|ale-dockerfile-options| dockerfile_lint.......................|ale-dockerfile-dockerfile_lint| + dockerlinter..........................|ale-dockerfile-dockerlinter| + dprint................................|ale-dockerfile-dprint| hadolint..............................|ale-dockerfile-hadolint| elixir..................................|ale-elixir-options| mix...................................|ale-elixir-mix| @@ -2067,17 +3019,27 @@ documented in additional help files. dialyxir..............................|ale-elixir-dialyxir| elixir-ls.............................|ale-elixir-elixir-ls| credo.................................|ale-elixir-credo| + cspell................................|ale-elixir-cspell| + lexical...............................|ale-elixir-lexical| elm.....................................|ale-elm-options| elm-format............................|ale-elm-elm-format| elm-ls................................|ale-elm-elm-ls| elm-make..............................|ale-elm-elm-make| erlang..................................|ale-erlang-options| dialyzer..............................|ale-erlang-dialyzer| + elvis.................................|ale-erlang-elvis| + erlang-mode...........................|ale-erlang-erlang-mode| + erlang_ls.............................|ale-erlang-erlang_ls| erlc..................................|ale-erlang-erlc| + erlfmt................................|ale-erlang-erlfmt| syntaxerl.............................|ale-erlang-syntaxerl| 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| fortran.................................|ale-fortran-options| gcc...................................|ale-fortran-gcc| language_server.......................|ale-fortran-language-server| @@ -2086,33 +3048,44 @@ 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| go......................................|ale-go-options| bingo.................................|ale-go-bingo| + cspell................................|ale-go-cspell| gobuild...............................|ale-go-gobuild| gofmt.................................|ale-go-gofmt| + gofumpt...............................|ale-go-gofumpt| golangci-lint.........................|ale-go-golangci-lint| golangserver..........................|ale-go-golangserver| - golint................................|ale-go-golint| - gometalinter..........................|ale-go-gometalinter| + golines...............................|ale-go-golines| gopls.................................|ale-go-gopls| govet.................................|ale-go-govet| + revive................................|ale-go-revive| staticcheck...........................|ale-go-staticcheck| + go html template........................|ale-gohtmltmpl-options| + djlint................................|ale-gohtmltmpl-djlint| graphql.................................|ale-graphql-options| eslint................................|ale-graphql-eslint| gqlint................................|ale-graphql-gqlint| prettier..............................|ale-graphql-prettier| + groovy..................................|ale-groovy-options| + npm-groovy-lint.......................|ale-groovy-npm-groovy-lint| hack....................................|ale-hack-options| hack..................................|ale-hack-hack| hackfmt...............................|ale-hack-hackfmt| hhast.................................|ale-hack-hhast| handlebars..............................|ale-handlebars-options| + djlint................................|ale-handlebars-djlint| prettier..............................|ale-handlebars-prettier| ember-template-lint...................|ale-handlebars-embertemplatelint| haskell.................................|ale-haskell-options| brittany..............................|ale-haskell-brittany| + cspell................................|ale-haskell-cspell| floskell..............................|ale-haskell-floskell| ghc...................................|ale-haskell-ghc| ghc-mod...............................|ale-haskell-ghc-mod| @@ -2121,25 +3094,51 @@ documented in additional help files. hfmt..................................|ale-haskell-hfmt| hindent...............................|ale-haskell-hindent| hlint.................................|ale-haskell-hlint| + hls...................................|ale-haskell-hls| stack-build...........................|ale-haskell-stack-build| stack-ghc.............................|ale-haskell-stack-ghc| stylish-haskell.......................|ale-haskell-stylish-haskell| hie...................................|ale-haskell-hie| + ormolu................................|ale-haskell-ormolu| + fourmolu..............................|ale-haskell-fourmolu| hcl.....................................|ale-hcl-options| + packer-fmt............................|ale-hcl-packer-fmt| terraform-fmt.........................|ale-hcl-terraform-fmt| + help....................................|ale-help-options| + cspell................................|ale-help-cspell| html....................................|ale-html-options| + angular...............................|ale-html-angular| + cspell................................|ale-html-cspell| + djlint................................|ale-html-djlint| fecs..................................|ale-html-fecs| + html-beautify.........................|ale-html-beautify| htmlhint..............................|ale-html-htmlhint| - tidy..................................|ale-html-tidy| prettier..............................|ale-html-prettier| + rustywind.............................|ale-html-rustywind| stylelint.............................|ale-html-stylelint| + tidy..................................|ale-html-tidy| + vscodehtml............................|ale-html-vscode| write-good............................|ale-html-write-good| + html angular template...................|ale-htmlangular-options| + djlint................................|ale-htmlangular-djlint| + html django template....................|ale-htmldjango-options| + djlint................................|ale-htmldjango-djlint| + http....................................|ale-http-options| + kulala_fmt............................|ale-http-kulala_fmt| + hurl....................................|ale-hurl-options| + hurlfmt...............................|ale-hurl-hurlfmt| idris...................................|ale-idris-options| idris.................................|ale-idris-idris| + ink.....................................|ale-ink-options| + ink-language-server...................|ale-ink-language-server| + inko....................................|ale-inko-options| + inko..................................|ale-inko-inko| ispc....................................|ale-ispc-options| ispc..................................|ale-ispc-ispc| java....................................|ale-java-options| checkstyle............................|ale-java-checkstyle| + clang-format..........................|ale-java-clangformat| + cspell................................|ale-java-cspell| javac.................................|ale-java-javac| google-java-format....................|ale-java-google-java-format| pmd...................................|ale-java-pmd| @@ -2147,6 +3146,11 @@ 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| + dprint................................|ale-javascript-dprint| eslint................................|ale-javascript-eslint| fecs..................................|ale-javascript-fecs| flow..................................|ale-javascript-flow| @@ -2158,11 +3162,29 @@ documented in additional help files. prettier-standard.....................|ale-javascript-prettier-standard| standard..............................|ale-javascript-standard| xo....................................|ale-javascript-xo| + jinja...................................|ale-jinja-options| + djlint................................|ale-jinja-djlint| json....................................|ale-json-options| + biome.................................|ale-json-biome| + clang-format..........................|ale-json-clangformat| + cspell................................|ale-json-cspell| + dprint................................|ale-json-dprint| + eslint................................|ale-json-eslint| fixjson...............................|ale-json-fixjson| + pytool................................|ale-json-pytool| jsonlint..............................|ale-json-jsonlint| jq....................................|ale-json-jq| prettier..............................|ale-json-prettier| + 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| + jsonnet-lint..........................|ale-jsonnet-jsonnet-lint| + json5...................................|ale-json5-options| + eslint................................|ale-json5-eslint| julia...................................|ale-julia-options| languageserver........................|ale-julia-languageserver| kotlin..................................|ale-kotlin-options| @@ -2170,6 +3192,7 @@ documented in additional help files. ktlint................................|ale-kotlin-ktlint| languageserver........................|ale-kotlin-languageserver| latex...................................|ale-latex-options| + cspell................................|ale-latex-cspell| write-good............................|ale-latex-write-good| textlint..............................|ale-latex-textlint| less....................................|ale-less-options| @@ -2179,11 +3202,25 @@ documented in additional help files. llvm....................................|ale-llvm-options| llc...................................|ale-llvm-llc| lua.....................................|ale-lua-options| + cspell................................|ale-lua-cspell| + lua-format............................|ale-lua-lua-format| + lua-language-server...................|ale-lua-lua-language-server| luac..................................|ale-lua-luac| luacheck..............................|ale-lua-luacheck| + luafmt................................|ale-lua-luafmt| + selene................................|ale-lua-selene| + stylua................................|ale-lua-stylua| + make....................................|ale-make-options| + checkmake.............................|ale-make-checkmake| markdown................................|ale-markdown-options| + cspell................................|ale-markdown-cspell| + dprint................................|ale-markdown-dprint| + markdownlint..........................|ale-markdown-markdownlint| + marksman..............................|ale-markdown-marksman| mdl...................................|ale-markdown-mdl| + pandoc................................|ale-markdown-pandoc| prettier..............................|ale-markdown-prettier| + pymarkdown............................|ale-markdown-pymarkdown| remark-lint...........................|ale-markdown-remark-lint| textlint..............................|ale-markdown-textlint| write-good............................|ale-markdown-write-good| @@ -2191,22 +3228,52 @@ documented in additional help files. mmc...................................|ale-mercury-mmc| nasm....................................|ale-nasm-options| nasm..................................|ale-nasm-nasm| + nickel..................................|ale-nickel-options| + nickel_format.........................|ale-nickel-nickel-format| + nim.....................................|ale-nim-options| + nimcheck..............................|ale-nim-nimcheck| + nimlsp................................|ale-nim-nimlsp| + nimpretty.............................|ale-nim-nimpretty| + nix.....................................|ale-nix-options| + alejandra.............................|ale-nix-alejandra| + nixfmt................................|ale-nix-nixfmt| + nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt| + statix................................|ale-nix-statix| + deadnix...............................|ale-nix-deadnix| nroff...................................|ale-nroff-options| write-good............................|ale-nroff-write-good| + nunjucks................................|ale-nunjucks-options| + djlint................................|ale-nunjucks-djlint| objc....................................|ale-objc-options| + ccls..................................|ale-objc-ccls| clang.................................|ale-objc-clang| + clang-format..........................|ale-objc-clangformat| clangd................................|ale-objc-clangd| uncrustify............................|ale-objc-uncrustify| - ccls..................................|ale-objc-ccls| objcpp..................................|ale-objcpp-options| clang.................................|ale-objcpp-clang| clangd................................|ale-objcpp-clangd| uncrustify............................|ale-objcpp-uncrustify| ocaml...................................|ale-ocaml-options| + dune..................................|ale-ocaml-dune| merlin................................|ale-ocaml-merlin| + ocamllsp..............................|ale-ocaml-ocamllsp| 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| + yamllint..............................|ale-openapi-yamllint| + openscad................................|ale-openscad-options| + sca2d.................................|ale-openscad-sca2d| + scadformat............................|ale-openscad-scadformat| + packer..................................|ale-packer-options| + packer-fmt-fixer......................|ale-packer-fmt-fixer| + pascal..................................|ale-pascal-options| + ptop..................................|ale-pascal-ptop| pawn....................................|ale-pawn-options| uncrustify............................|ale-pawn-uncrustify| perl....................................|ale-perl-options| @@ -2216,6 +3283,7 @@ documented in additional help files. perl6...................................|ale-perl6-options| perl6.................................|ale-perl6-perl6| php.....................................|ale-php-options| + cspell................................|ale-php-cspell| langserver............................|ale-php-langserver| phan..................................|ale-php-phan| phpcbf................................|ale-php-phpcbf| @@ -2225,19 +3293,27 @@ documented in additional help files. psalm.................................|ale-php-psalm| php-cs-fixer..........................|ale-php-php-cs-fixer| php...................................|ale-php-php| + pint..................................|ale-php-pint| + tlint.................................|ale-php-tlint| + intelephense..........................|ale-php-intelephense| po......................................|ale-po-options| write-good............................|ale-po-write-good| pod.....................................|ale-pod-options| write-good............................|ale-pod-write-good| pony....................................|ale-pony-options| ponyc.................................|ale-pony-ponyc| - powershell............................|ale-powershell-options| - powershell..........................|ale-powershell-powershell| - psscriptanalyzer....................|ale-powershell-psscriptanalyzer| + powershell..............................|ale-powershell-options| + cspell................................|ale-powershell-cspell| + powershell............................|ale-powershell-powershell| + psscriptanalyzer......................|ale-powershell-psscriptanalyzer| prolog..................................|ale-prolog-options| swipl.................................|ale-prolog-swipl| proto...................................|ale-proto-options| + buf-format............................|ale-proto-buf-format| + buf-lint..............................|ale-proto-buf-lint| + clang-format..........................|ale-proto-clangformat| protoc-gen-lint.......................|ale-proto-protoc-gen-lint| + protolint.............................|ale-proto-protolint| pug.....................................|ale-pug-options| puglint...............................|ale-pug-puglint| puppet..................................|ale-puppet-options| @@ -2246,41 +3322,71 @@ documented in additional help files. puppet-languageserver.................|ale-puppet-languageserver| purescript..............................|ale-purescript-options| purescript-language-server............|ale-purescript-language-server| + purs-tidy.............................|ale-purescript-tidy| + purty.................................|ale-purescript-purty| pyrex (cython)..........................|ale-pyrex-options| cython................................|ale-pyrex-cython| python..................................|ale-python-options| + autoflake.............................|ale-python-autoflake| + autoimport............................|ale-python-autoimport| autopep8..............................|ale-python-autopep8| bandit................................|ale-python-bandit| black.................................|ale-python-black| + cspell................................|ale-python-cspell| flake8................................|ale-python-flake8| + flakehell.............................|ale-python-flakehell| isort.................................|ale-python-isort| mypy..................................|ale-python-mypy| prospector............................|ale-python-prospector| + pycln.................................|ale-python-pycln| pycodestyle...........................|ale-python-pycodestyle| pydocstyle............................|ale-python-pydocstyle| pyflakes..............................|ale-python-pyflakes| + pyflyby...............................|ale-python-pyflyby| pylama................................|ale-python-pylama| pylint................................|ale-python-pylint| - pyls..................................|ale-python-pyls| + pylsp.................................|ale-python-pylsp| pyre..................................|ale-python-pyre| + pyright...............................|ale-python-pyright| + refurb................................|ale-python-refurb| reorder-python-imports................|ale-python-reorder_python_imports| + ruff..................................|ale-python-ruff| + ruff-format...........................|ale-python-ruff-format| + unimport..............................|ale-python-unimport| vulture...............................|ale-python-vulture| yapf..................................|ale-python-yapf| qml.....................................|ale-qml-options| qmlfmt................................|ale-qml-qmlfmt| r.......................................|ale-r-options| + languageserver........................|ale-r-languageserver| lintr.................................|ale-r-lintr| styler................................|ale-r-styler| + racket..................................|ale-racket-options| + racket_langserver.....................|ale-racket-langserver| + raco_fmt..............................|ale-racket-raco-fmt| reasonml................................|ale-reasonml-options| merlin................................|ale-reasonml-merlin| ols...................................|ale-reasonml-ols| reason-language-server................|ale-reasonml-language-server| refmt.................................|ale-reasonml-refmt| + rego....................................|ale-rego-options| + cspell................................|ale-rego-cspell| + opacheck..............................|ale-rego-opa-check| + opafmt................................|ale-rego-opa-fmt-fixer| + rest....................................|ale-rest-options| + kulala_fmt............................|ale-rest-kulala_fmt| restructuredtext........................|ale-restructuredtext-options| + cspell................................|ale-restructuredtext-cspell| textlint..............................|ale-restructuredtext-textlint| write-good............................|ale-restructuredtext-write-good| + robot...................................|ale-robot-options| + rflint................................|ale-robot-rflint| ruby....................................|ale-ruby-options| brakeman..............................|ale-ruby-brakeman| + cspell................................|ale-ruby-cspell| + debride...............................|ale-ruby-debride| + packwerk..............................|ale-ruby-packwerk| + prettier..............................|ale-ruby-prettier| rails_best_practices..................|ale-ruby-rails_best_practices| reek..................................|ale-ruby-reek| rubocop...............................|ale-ruby-rubocop| @@ -2289,15 +3395,23 @@ documented in additional help files. solargraph............................|ale-ruby-solargraph| 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| + cspell................................|ale-rust-cspell| rls...................................|ale-rust-rls| rustc.................................|ale-rust-rustc| rustfmt...............................|ale-rust-rustfmt| + salt....................................|ale-salt-options| + salt-lint.............................|ale-salt-salt-lint| sass....................................|ale-sass-options| sasslint..............................|ale-sass-sasslint| stylelint.............................|ale-sass-stylelint| scala...................................|ale-scala-options| + cspell................................|ale-scala-cspell| + metals................................|ale-scala-metals| sbtserver.............................|ale-scala-sbtserver| scalafmt..............................|ale-scala-scalafmt| scalastyle............................|ale-scala-scalastyle| @@ -2306,6 +3420,8 @@ documented in additional help files. sasslint..............................|ale-scss-sasslint| stylelint.............................|ale-scss-stylelint| sh......................................|ale-sh-options| + bashate...............................|ale-sh-bashate| + cspell................................|ale-sh-cspell| sh-language-server....................|ale-sh-language-server| shell.................................|ale-sh-shell| shellcheck............................|ale-sh-shellcheck| @@ -2313,89 +3429,148 @@ documented in additional help files. sml.....................................|ale-sml-options| smlnj.................................|ale-sml-smlnj| solidity................................|ale-solidity-options| + solc..................................|ale-solidity-solc| solhint...............................|ale-solidity-solhint| solium................................|ale-solidity-solium| + forge.................................|ale-solidity-forge| spec....................................|ale-spec-options| rpmlint...............................|ale-spec-rpmlint| sql.....................................|ale-sql-options| + dprint................................|ale-sql-dprint| pgformatter...........................|ale-sql-pgformatter| + sqlfluff..............................|ale-sql-sqlfluff| sqlfmt................................|ale-sql-sqlfmt| + sqlformat.............................|ale-sql-sqlformat| stylus..................................|ale-stylus-options| stylelint.............................|ale-stylus-stylelint| sugarss.................................|ale-sugarss-options| stylelint.............................|ale-sugarss-stylelint| + svelte..................................|ale-svelte-options| + prettier..............................|ale-svelte-prettier| + svelteserver..........................|ale-svelte-svelteserver| swift...................................|ale-swift-options| + apple-swift-format....................|ale-swift-apple-swift-format| + cspell................................|ale-swift-cspell| sourcekitlsp..........................|ale-swift-sourcekitlsp| + systemd.................................|ale-systemd-options| + systemd-analyze.......................|ale-systemd-analyze| tcl.....................................|ale-tcl-options| nagelfar..............................|ale-tcl-nagelfar| terraform...............................|ale-terraform-options| + checkov...............................|ale-terraform-checkov| terraform-fmt-fixer...................|ale-terraform-fmt-fixer| terraform.............................|ale-terraform-terraform| + terraform-ls..........................|ale-terraform-terraform-ls| + terraform-lsp.........................|ale-terraform-terraform-lsp| tflint................................|ale-terraform-tflint| + tfsec.................................|ale-terraform-tfsec| tex.....................................|ale-tex-options| chktex................................|ale-tex-chktex| + cspell................................|ale-tex-cspell| lacheck...............................|ale-tex-lacheck| latexindent...........................|ale-tex-latexindent| texlab................................|ale-tex-texlab| texinfo.................................|ale-texinfo-options| + cspell................................|ale-texinfo-cspell| write-good............................|ale-texinfo-write-good| text....................................|ale-text-options| + cspell................................|ale-text-cspell| textlint..............................|ale-text-textlint| write-good............................|ale-text-write-good| thrift..................................|ale-thrift-options| thrift................................|ale-thrift-thrift| + thriftcheck...........................|ale-thrift-thriftcheck| + 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| eslint................................|ale-typescript-eslint| prettier..............................|ale-typescript-prettier| + standard..............................|ale-typescript-standard| tslint................................|ale-typescript-tslint| tsserver..............................|ale-typescript-tsserver| + xo....................................|ale-typescript-xo| + typst...................................|ale-typst-options| + typstyle..............................|ale-typst-typstyle| + v.......................................|ale-v-options| + v.....................................|ale-v-v| + vfmt..................................|ale-v-vfmt| vala....................................|ale-vala-options| uncrustify............................|ale-vala-uncrustify| 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| + yosys.................................|ale-verilog-yosys| vhdl....................................|ale-vhdl-options| ghdl..................................|ale-vhdl-ghdl| + hdl-checker...........................|ale-vhdl-hdl-checker| vcom..................................|ale-vhdl-vcom| xvhdl.................................|ale-vhdl-xvhdl| - vim.....................................|ale-vim-options| - vint..................................|ale-vim-vint| vim help................................|ale-vim-help-options| write-good............................|ale-vim-help-write-good| + vim.....................................|ale-vim-options| + vimls.................................|ale-vim-vimls| + vint..................................|ale-vim-vint| vue.....................................|ale-vue-options| + cspell................................|ale-vue-cspell| prettier..............................|ale-vue-prettier| vls...................................|ale-vue-vls| + volar.................................|ale-vue-volar| + wgsl....................................|ale-wgsl-options| + naga..................................|ale-wgsl-naga| xhtml...................................|ale-xhtml-options| + cspell................................|ale-xhtml-cspell| write-good............................|ale-xhtml-write-good| xml.....................................|ale-xml-options| xmllint...............................|ale-xml-xmllint| yaml....................................|ale-yaml-options| + actionlint............................|ale-yaml-actionlint| + circleci..............................|ale-yaml-circleci| prettier..............................|ale-yaml-prettier| + spectral..............................|ale-yaml-spectral| swaglint..............................|ale-yaml-swaglint| + yaml-language-server..................|ale-yaml-language-server| + yamlfix...............................|ale-yaml-yamlfix| + yamlfmt...............................|ale-yaml-yamlfmt| yamllint..............................|ale-yaml-yamllint| + gitlablint............................|ale-yaml-gitlablint| + yq....................................|ale-yaml-yq| yang....................................|ale-yang-options| yang-lsp..............................|ale-yang-lsp| + yara....................................|ale-yara-options| + yls...................................|ale-yara-yls| + zeek....................................|ale-zeek-options| + zeek..................................|ale-zeek-zeek| + zig.....................................|ale-zig-options| + zigfmt................................|ale-zig-zigfmt| + zlint.................................|ale-zig-zlint| + zls...................................|ale-zig-zls| =============================================================================== 8. Commands/Keybinds *ale-commands* -ALEComplete *ALEComplete* +:ALEComplete *:ALEComplete* Manually trigger LSP autocomplete and show the menu. Works only when called from insert mode. > - inoremap :AleComplete + inoremap :ALEComplete < A plug mapping `(ale_complete)` is defined for this command. > imap (ale_complete) < -ALEDocumentation *ALEDocumentation* +:ALEDocumentation *:ALEDocumentation* - Similar to the |ALEHover| command, retrieve documentation information for + Similar to the `:ALEHover` command, retrieve documentation information for the symbol at the cursor. Documentation data will always be shown in a preview window, no matter how small the documentation content is. @@ -2404,111 +3579,146 @@ ALEDocumentation *ALEDocumentation* A plug mapping `(ale_documentation)` is defined for this command. -ALEFindReferences *ALEFindReferences* +:ALEFindReferences *:ALEFindReferences* Find references in the codebase for the symbol under the cursor using the enabled LSP linters for the buffer. ALE will display a preview window containing the results if some references are found. The window can be navigated using the usual Vim navigation commands. The - Enter key (``) can be used to jump to a referencing location, or the `t` + Enter key () can be used to jump to a referencing location, or the `t` key can be used to jump to the location in a new tab. + The locations opened in different ways using the following variations. + + `:ALEFindReferences -tab` - Open the location in a new tab. + `:ALEFindReferences -split` - Open the location in a horizontal split. + `:ALEFindReferences -vsplit` - Open the location in a vertical split. + `:ALEFindReferences -quickfix` - Put the locations into quickfix list. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + You can add `-relative` to the command to view results with relatives paths, + instead of absolute paths. This option has no effect if `-quickfix` is used. + + The selection can be opened again with the `:ALERepeatSelection` command. + You can jump back to the position you were at before going to a reference of something with jump motions like CTRL-O. See |jump-motions|. A plug mapping `(ale_find_references)` is defined for this command. + You can define additional plug mapping with any additional options you want + like so: > -ALEFix *ALEFix* + nnoremap (my_mapping) :ALEFindReferences -relative +< + +:ALEFix [linter] *:ALEFix* Fix problems with the current buffer. See |ale-fix| for more information. + If the command is run with a bang (`:ALEFix!`), all warnings will be + suppressed, including warnings about no fixers being defined, and warnings + about not being able to apply fixes to a file because it has been changed. + A plug mapping `(ale_fix)` is defined for this command. -ALEFixSuggest *ALEFixSuggest* +:ALEFixSuggest *:ALEFixSuggest* Suggest tools that can be used to fix problems in the current buffer. See |ale-fix| for more information. -ALEGoToDefinition *ALEGoToDefinition* +:ALEGoToDefinition [options] *:ALEGoToDefinition* Jump to the definition of a symbol under the cursor using the enabled LSP linters for the buffer. ALE will jump to a definition if an LSP server provides a location to jump to. Otherwise, ALE will do nothing. + The locations opened in different ways using the following variations. + + `:ALEGoToDefinition -tab` - Open the location in a new tab. + `:ALEGoToDefinition -split` - Open the location in a horizontal split. + `:ALEGoToDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + You can jump back to the position you were at before going to the definition of something with jump motions like CTRL-O. See |jump-motions|. - A plug mapping `(ale_go_to_definition)` is defined for this command. + You should consider using the 'hidden' option in combination with this + command. Otherwise, Vim will refuse to leave the buffer you're jumping from + unless you have saved your edits. + + The following Plug mappings are defined for this command, which correspond + to the following commands. + + `(ale_go_to_definition)` - `:ALEGoToDefinition` + `(ale_go_to_definition_in_tab)` - `:ALEGoToDefinition -tab` + `(ale_go_to_definition_in_split)` - `:ALEGoToDefinition -split` + `(ale_go_to_definition_in_vsplit)` - `:ALEGoToDefinition -vsplit` -ALEGoToDefinitionInTab *ALEGoToDefinitionInTab* +:ALEGoToTypeDefinition [options] *:ALEGoToTypeDefinition* - The same as |ALEGoToDefinition|, but opens results in a new tab. - - A plug mapping `(ale_go_to_definition_in_tab)` is defined for this - command. - - -ALEGoToDefinitionInSplit *ALEGoToDefinitionInSplit* - - The same as |ALEGoToDefinition|, but opens results in a new split. - - A plug mapping `(ale_go_to_definition_in_split)` is defined for this - command. - - -ALEGoToDefinitionInVSplit *ALEGoToDefinitionInVSplit* - - The same as |ALEGoToDefinition|, but opens results in a new vertical split. - - A plug mapping `(ale_go_to_definition_in_vsplit)` is defined for this - command. - - -ALEGoToTypeDefinition *ALEGoToTypeDefinition* - - This works similar to |ALEGoToDefinition| but instead jumps to the + This works similar to `:ALEGoToDefinition` but instead jumps to the definition of a type of a symbol under the cursor. ALE will jump to a definition if an LSP server provides a location to jump to. Otherwise, ALE will do nothing. + The locations opened in different ways using the following variations. + + `:ALEGoToTypeDefinition -tab` - Open the location in a new tab. + `:ALEGoToTypeDefinition -split` - Open the location in a horizontal split. + `:ALEGoToTypeDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + You can jump back to the position you were at before going to the definition of something with jump motions like CTRL-O. See |jump-motions|. - A plug mapping `(ale_go_to_type_definition)` is defined for this - command. + The following Plug mappings are defined for this command, which correspond + to the following commands. + + `(ale_go_to_type_definition)` - `:ALEGoToTypeDefinition` + `(ale_go_to_type_definition_in_tab)` - `:ALEGoToTypeDefinition -tab` + `(ale_go_to_type_definition_in_split)` - `:ALEGoToTypeDefinition -split` + `(ale_go_to_type_definition_in_vsplit)` - `:ALEGoToTypeDefinition -vsplit` -ALEGoToTypeDefinitionInTab *ALEGoToTypeDefinitionInTab* +:ALEGoToImplementation [options] *:ALEGoToImplementation* - The same as |ALEGoToTypeDefinition|, but opens results in a new tab. + This works similar to `:ALEGoToDefinition` but instead jumps to the + implementation of symbol under the cursor. ALE will jump to a definition if + an LSP server provides a location to jump to. Otherwise, ALE will do nothing. - A plug mapping `(ale_go_to_type_definition_in_tab)` is defined for - this command. + The locations opened in different ways using the following variations. + + `:ALEGoToImplementation -tab` - Open the location in a new tab. + `:ALEGoToImplementation -split` - Open the location in a horizontal split. + `:ALEGoToImplementation -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + You can jump back to the position you were at before going to the definition + of something with jump motions like CTRL-O. See |jump-motions|. + + The following Plug mappings are defined for this command, which correspond + to the following commands. + + `(ale_go_to_implementation)` - `:ALEGoToImplementation` + `(ale_go_to_implementation_in_tab)` - `:ALEGoToImplementation -tab` + `(ale_go_to_implementation_in_split)` - `:ALEGoToImplementation -split` + `(ale_go_to_implementation_in_vsplit)` - `:ALEGoToImplementation -vsplit` -ALEGoToTypeDefinitionInSplit *ALEGoToTypeDefinitionInSplit* - - The same as |ALEGoToTypeDefinition|, but opens results in a new split. - - A plug mapping `(ale_go_to_type_definition_in_split)` is defined for - this command. - - -ALEGoToTypeDefinitionInVSplit *ALEGoToTypeDefinitionInVSplit* - - The same as |ALEGoToTypeDefinition|, but opens results in a new vertical - split. - - A plug mapping `(ale_go_to_type_definition_in_vsplit)` is defined for - this command. - - -ALEHover *ALEHover* +:ALEHover *:ALEHover* Print brief information about the symbol under the cursor, taken from any available LSP linters. There may be a small non-blocking delay before @@ -2521,43 +3731,122 @@ ALEHover *ALEHover* A plug mapping `(ale_hover)` is defined for this command. -ALESymbolSearch `` *ALESymbolSearch* +:ALEImport *:ALEImport* + + Try to import a symbol using `tsserver` or a Language Server. + + ALE will look for completions for the word at the cursor which contain + additional text edits that possible insert lines to import the symbol. The + first match with additional text edits will be used, and may add other code + to the current buffer other than import lines. + + If linting is enabled, and |g:ale_lint_on_text_changed| is set to ever check + buffers when text is changed, the buffer will be checked again after changes + are made. + + A Plug mapping `(ale_import)` is defined for this command. This + mapping should only be bound for normal mode. + + +:ALEOrganizeImports *:ALEOrganizeImports* + + Organize imports using tsserver. Currently not implemented for LSPs. + + +:ALERename *:ALERename* + + Rename a symbol using `tsserver` or a Language Server. + + The symbol where the cursor is resting will be the symbol renamed, and a + prompt will open to request a new name. + + The rename operation will not save modified buffers when 'hidden' is on + unless |g:ale_save_hidden| is 1. + + +:ALEFileRename *:ALEFileRename* + + Rename a file and fix imports using `tsserver`. + + +:ALECodeAction *:ALECodeAction* + + Apply a code action via LSP servers or `tsserver`. + + If there is an error present on a line that can be fixed, ALE will + automatically fix a line, unless there are multiple possible code fixes to + apply. + + This command can be run in visual mode apply actions, such as applicable + refactors. A menu will be shown to select code action to apply. + + +:ALERepeatSelection *:ALERepeatSelection* + + Repeat the last selection displayed in the preview window. + + +:ALESymbolSearch [query] *:ALESymbolSearch* Search for symbols in the workspace, taken from any available LSP linters. The arguments provided to this command will be used as a search query for finding symbols in the workspace, such as functions, types, etc. - *:ALELint* -ALELint *ALELint* + You can add `-relative` to the command to view results with relatives paths, + instead of absolute paths. + + +:ALELint *:ALELint* Run ALE once for the current buffer. This command can be used to run ALE manually, instead of automatically, if desired. - This command will also run linters where `lint_file` is set to `1`, or in - other words linters which check the file instead of the Vim buffer. + This command will also run linters where `lint_file` is evaluates to `1`, + meaning linters which check the file instead of the Vim buffer. A plug mapping `(ale_lint)` is defined for this command. -ALEPrevious *ALEPrevious* -ALEPreviousWrap *ALEPreviousWrap* -ALENext *ALENext* -ALENextWrap *ALENextWrap* -ALEFirst *ALEFirst* -ALELast *ALELast* +:ALELintStop *:ALELintStop* + + Stop any currently running jobs for checking the current buffer. + + Any problems from previous linter results will continue to be shown. + + +:ALEPopulateQuickfix *:ALEPopulateQuickfix* +:ALEPopulateLocList *:ALEPopulateLocList* + + Manually populate the |quickfix| or |location-list| and show the + corresponding list. Useful when you have other uses for both the |quickfix| + and |location-list| and don't want them automatically populated. Be sure to + disable auto populating: > + + let g:ale_set_quickfix = 0 + let g:ale_set_loclist = 0 +< + With these settings, ALE will still run checking and display it with signs, + highlighting, and other output described in |ale-lint-file-linters|. + +:ALEPrevious *:ALEPrevious* +:ALEPreviousWrap *:ALEPreviousWrap* +:ALENext *:ALENext* +:ALENextWrap *:ALENextWrap* +:ALEFirst *:ALEFirst* +:ALELast *:ALELast* *ale-navigation-commands* Move between warnings or errors in a buffer. ALE will only navigate between the errors or warnings it generated, even if both |g:ale_set_quickfix| and |g:ale_set_loclist| are set to `0`. - `ALEPrevious` and `ALENext` will stop at the top and bottom of a file, while - `ALEPreviousWrap` and `ALENextWrap` will wrap around the file to find + `:ALEPrevious` and `:ALENext` will stop at the top and bottom of a file, while + `:ALEPreviousWrap` and `:ALENextWrap` will wrap around the file to find the last or first warning or error in the file, respectively. - `ALEPrevious` and `ALENext` take optional flags arguments to custom their - behaviour : + `:ALEPrevious` and `:ALENext` take optional flags arguments to custom their + behavior : `-wrap` enable wrapping around the file `-error`, `-warning` and `-info` enable jumping to errors, warnings or infos respectively, ignoring anything else. They are mutually exclusive and if @@ -2570,7 +3859,7 @@ ALELast *ALELast* ":ALENext -wrap -error -nosyle" to jump to the next error which is not a style error while going back to the beginning of the file if needed. - `ALEFirst` goes to the first error or warning in the buffer, while `ALELast` + `:ALEFirst` goes to the first error or warning in the buffer, while `:ALELast` goes to the last one. The following || mappings are defined for the commands: > @@ -2589,8 +3878,8 @@ ALELast *ALELast* (ale_first) - ALEFirst (ale_last) - ALELast < - For example, these commands could be bound to the keys Ctrl + j - and Ctrl + k: > + For example, these commands could be bound to the keys CTRL-j + and CTRL-k: > " Map movement through errors without wrapping. nmap (ale_previous) @@ -2600,23 +3889,23 @@ ALELast *ALELast* nmap (ale_next_wrap) < -ALEToggle *ALEToggle* -ALEEnable *ALEEnable* -ALEDisable *ALEDisable* -ALEToggleBuffer *ALEToggleBuffer* -ALEEnableBuffer *ALEEnableBuffer* -ALEDisableBuffer *ALEDisableBuffer* +:ALEToggle *:ALEToggle* +:ALEEnable *:ALEEnable* +:ALEDisable *:ALEDisable* +:ALEToggleBuffer *:ALEToggleBuffer* +:ALEEnableBuffer *:ALEEnableBuffer* +:ALEDisableBuffer *:ALEDisableBuffer* - `ALEToggle`, `ALEEnable`, and `ALEDisable` enable or disable ALE linting, + `:ALEToggle`, `:ALEEnable`, and `:ALEDisable` enable or disable ALE linting, including all of its autocmd events, loclist items, quickfix items, signs, current jobs, etc., globally. Executing any of these commands will change the |g:ale_enabled| variable. ALE can be disabled or enabled for only a single buffer with - `ALEToggleBuffer`, `ALEEnableBuffer`, and `ALEDisableBuffer`. Disabling ALE + `:ALEToggleBuffer`, `:ALEEnableBuffer`, and `:ALEDisableBuffer`. Disabling ALE for a buffer will not remove autocmd events, but will prevent ALE from checking for problems and reporting problems for whatever buffer the - `ALEDisableBuffer` or `ALEToggleBuffer` command is executed from. These + `:ALEDisableBuffer` or `:ALEToggleBuffer` command is executed from. These commands can be used for temporarily disabling ALE for a buffer. These commands will modify the |b:ale_enabled| variable. @@ -2626,18 +3915,18 @@ ALEDisableBuffer *ALEDisableBuffer* The following plug mappings are defined, for conveniently defining keybinds: - |ALEToggle| - `(ale_toggle)` - |ALEEnable| - `(ale_enable)` - |ALEDisable| - `(ale_disable)` - |ALEToggleBuffer| - `(ale_toggle_buffer)` - |ALEEnableBuffer| - `(ale_enable_buffer)` - |ALEDisableBuffer| - `(ale_disable_buffer)` + `:ALEToggle` - `(ale_toggle)` + `:ALEEnable` - `(ale_enable)` + `:ALEDisable` - `(ale_disable)` + `:ALEToggleBuffer` - `(ale_toggle_buffer)` + `:ALEEnableBuffer` - `(ale_enable_buffer)` + `:ALEDisableBuffer` - `(ale_disable_buffer)` For removing problems reported by ALE, but leaving ALE enabled, see - |ALEReset| and |ALEResetBuffer|. + `:ALEReset` and `:ALEResetBuffer`. - *:ALEDetail* -ALEDetail *ALEDetail* + +:ALEDetail *:ALEDetail* Show the full linter message for the problem nearest to the cursor on the given line in the preview window. The preview window can be easily closed @@ -2650,9 +3939,8 @@ ALEDetail *ALEDetail* A plug mapping `(ale_detail)` is defined for this command. - *:ALEInfo* -ALEInfo *ALEInfo* -ALEInfoToClipboard *ALEInfoToClipboard* +:ALEInfo *:ALEInfo* + *:ALEInfoToFile* Print runtime information about ALE, including the values of global and buffer-local settings for ALE, the linters that are enabled, the commands @@ -2664,40 +3952,60 @@ ALEInfoToClipboard *ALEInfoToClipboard* |g:ale_history_log_output| to `1` to enable logging of output for commands. ALE will only log the output captured for parsing problems, etc. - The command `:ALEInfoToClipboard` can be used to output ALEInfo directly to - your clipboard. This might not work on every machine. + You can pass options to the command to control how ALE displays the + information, such as `:ALEInfo -echo`, etc. > + + -preview Show the info in a preview window. + -clip OR -clipboard Copy the information to your clipboard. + -echo echo all of the information with :echo +< + The default mode can be configured with |g:ale_info_default_mode|. + + When shown in a preview window, syntax highlights can be defined for the + `ale-info` filetype. `:ALEInfoToFile` will write the ALE runtime information to a given filename. - The filename works just like |:w|. + The filename works just like `:write`. -ALEReset *ALEReset* -ALEResetBuffer *ALEResetBuffer* +:ALEReset *:ALEReset* +:ALEResetBuffer *:ALEResetBuffer* - `ALEReset` will remove all problems reported by ALE for all buffers. - `ALEResetBuffer` will remove all problems reported for a single buffer. + `:ALEReset` will remove all problems reported by ALE for all buffers. + `:ALEResetBuffer` will remove all problems reported for a single buffer. Either command will leave ALE linting enabled, so ALE will report problems when linting is performed again. See |ale-lint| for more information. The following plug mappings are defined, for conveniently defining keybinds: - |ALEReset| - `(ale_reset)` - |ALEResetBuffer| - `(ale_reset_buffer)` + `:ALEReset` - `(ale_reset)` + `:ALEResetBuffer` - `(ale_reset_buffer)` - ALE can be disabled globally or for a buffer with |ALEDisable| or - |ALEDisableBuffer|. + ALE can be disabled globally or for a buffer with `:ALEDisable` or + `:ALEDisableBuffer`. -ALEStopAllLSPs *ALEStopAllLSPs* +:ALEStopAllLSPs *:ALEStopAllLSPs* - `ALEStopAllLSPs` will close and stop all channels and jobs for all LSP-like + `:ALEStopAllLSPs` will close and stop all channels and jobs for all LSP-like clients, including tsserver, remove all of the data stored for them, and delete all of the problems found for them, updating every linted buffer. This command can be used when LSP clients mess up and need to be restarted. +:ALEStopLSP [linter] *:ALEStopLSP* + + `:ALEStopLSP` will stop a specific language server with a given linter name. + Completion is supported for currently running language servers. All language + servers with the given name will be stopped across all buffers for all + projects. + + If the command is run with a bang (`:ALEStopLSP!`), all warnings will be + suppressed. + + =============================================================================== 9. API *ale-api* @@ -2717,6 +4025,15 @@ ale#Env(variable_name, value) *ale#Env()* 'set VAR="some value" && command' # On Windows +ale#GetFilenameMappings(buffer, name) *ale#GetFilenameMappings()* + + Given a `buffer` and the `name` of either a linter for fixer, return a + |List| of two-item |List|s that describe mapping to and from the local and + foreign file systems for running a particular linter or fixer. + + See |g:ale_filename_mappings| for details on filename mapping. + + ale#Has(feature) *ale#Has()* Return `1` if ALE supports a given feature, like |has()| for Vim features. @@ -2739,9 +4056,9 @@ ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()* The linters will always be run in the background. Calling this function again from the same buffer - An optional `linting_flag` argument can be given. If `linting_flag` - is `'lint_file'`, then linters where the `lint_file` option is set to `1` will be - run. Linters with `lint_file` set to `1` are not run by default. + An optional `linting_flag` argument can be given. If `linting_flag` is + `'lint_file'`, then linters where the `lint_file` option evaluates to `1` + will be run. Otherwise, those linters will not be run. An optional `buffer_number` argument can be given for specifying the buffer to check. The active buffer (`bufnr('')`) will be checked by default. @@ -2829,26 +4146,44 @@ ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()* 'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))} < - The following `options` can be provided. - `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for - selecting which output streams to read lines from. + `cwd` - An optional |String| for setting the working directory + for the command, just as per |ale#linter#Define|. - The default is `'stdout'` + If not set, or `v:null`, the `cwd` of the last command + that spawned this one will be used. - `executable` - An executable for formatting into `%e` in the command. - If this option is not provided, formatting commands with - `%e` will not work. + `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or + `'none`' for selecting which output streams to read + lines from. - `read_buffer` - If set to `1`, the buffer will be piped into the - command. + The default is `'stdout'` - The default is `0`. + `executable` - An executable for formatting into `%e` in the + command. If this option is not provided, formatting + commands with `%e` will not work. + + `read_buffer` - If set to `1`, the buffer will be piped into the + command. + + The default is `0`. + + `input` - When creating temporary files with `%t` or piping + text into a command `input` can be set to a |List| of + text to use instead of the buffer's text. + + `filename_mappings` - A |List| of two-item |List|s describing filename + mappings to apply for formatted filenames in the + command string, as per |g:ale_filename_mappings|. + + If the call to this function is being used for a + linter or fixer, the mappings should be provided with + this option, and can be retrieved easily with + |ale#GetFilenameMappings()|. + + The default is `[]`. - `input` - When creating temporary files with `%t` or piping text - into a command `input` can be set to a |List| of text to - use instead of the buffer's text. ale#command#EscapeCommandPart(command_part) *ale#command#EscapeCommandPart()* @@ -2928,6 +4263,21 @@ ale#fix#registry#Add(name, func, filetypes, desc, [aliases]) ALE will search for fixers in the registry first by `name`, then by their `aliases`. + For example to register a custom fixer for `luafmt`: > + + function! FormatLua(buffer) abort + return { + \ 'command': 'luafmt --stdin' + \} + endfunction + + execute ale#fix#registry#Add('luafmt', 'FormatLua', ['lua'], 'luafmt for lua') + + " You can now use it in g:ale_fixers + let g:ale_fixers = { + \ 'lua': ['luafmt'] + } +< ale#linter#Define(filetype, linter) *ale#linter#Define()* @@ -2951,7 +4301,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* |setqflist()|. The |List| will be sorted by line and then column order so it can be searched with a binary search by in future before being passed on to the - |loclist|, etc. + |location-list|, etc. This argument is required, unless the linter is an LSP linter. In which case, this argument must not be @@ -2967,17 +4317,17 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* *ale-loclist-format* `text` - This error message is required. `detail` - An optional, more descriptive message. - This message can be displayed with the |ALEDetail| + This message can be displayed with the `:ALEDetail` command instead of the message for `text`, if set. `lnum` - The line number is required. Any strings will be automatically converted to numbers by - using `str2nr()`. + using |str2nr()|. Line 0 will be moved to line 1, and lines beyond the end of the file will be moved to the end. `col` - The column number is optional and will default to `0`. Any strings will be automatically - converted to number using `str2nr()`. + converted to number using |str2nr()|. `end_col` - An optional end column number. This key can be set to specify the column problems end on, for improved highlighting. @@ -3001,7 +4351,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* and have been checked at least once. Temporary files in directories used for Vim - temporary files with `tempname()` will be assumed + temporary files with |tempname()| will be assumed to be the buffer being checked, unless the `bufnr` key is also set with a valid number for some other buffer. @@ -3044,10 +4394,33 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* The result can be computed with |ale#command#Run()|. + The command string can be formatted with format + markers. See |ale-command-format-strings|. + This command will be fed the lines from the buffer to check, and will produce the lines of output given to the `callback`. + `cwd` An optional |String| for setting the working + directory for the command, or a |Funcref| for a + function to call for computing the command, accepting + a buffer number. The working directory can be + specified as a format string for determining the path + dynamically. See |ale-command-format-strings|. + + To set the working directory to the directory + containing the file you're checking, you should + probably use `'%s:h'` as the option value. + + If this option is absent or the string is empty, the + `command` will be run with no determined working + directory in particular. + + The directory specified with this option will be used + as the default working directory for all commands run + in a chain with |ale#command#Run()|, unless otherwise + specified. + `output_stream` A |String| for the output stream the lines of output should be read from for the command which is run. The accepted values are `'stdout'`, `'stderr'`, and @@ -3063,24 +4436,30 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* if a command manually reads from a temporary file instead, etc. + This option behaves as if it was set to `0` when the + `lint_file` option evaluates to `1`. + *ale-lint-file* - `lint_file` A |Number| (`0` or `1`) indicating whether a command - should read the file instead of the Vim buffer. This - option can be used for linters which must check the - file on disk, and which cannot check a Vim buffer - instead. + `lint_file` A |Number| (`0` or `1`), or a |Funcref| for a function + accepting a buffer number for computing either `0` or + `1`, indicating whether a command should read the file + instead of the Vim buffer. This option can be used + for linters which must check the file on disk, and + which cannot check a Vim buffer instead. - Linters set with this option will not be run as a - user types, per |g:ale_lint_on_text_changed|. Linters - will instead be run only when events occur against - the file on disk, including |g:ale_lint_on_enter| - and |g:ale_lint_on_save|. Linters with this option - set to `1` will also be run when linters are run - manually, per |ALELintPost-autocmd|. + The result can be computed with |ale#command#Run()|. - When this option is set to `1`, `read_buffer` will - be set automatically to `0`. The two options cannot - be used together. + Linters where the eventual value of this option + evaluates to `1` will not be run as a user types, per + |g:ale_lint_on_text_changed|. Linters will instead be + run only when events occur against the file on disk, + including |g:ale_lint_on_enter| and + |g:ale_lint_on_save|. Linters where this option + evaluates to `1` will also be run when the `:ALELint` + command is run. + + When this option is evaluates to `1`, ALE will behave + as if `read_buffer` was set to `0`. *ale-lsp-linters* `lsp` A |String| for defining LSP (Language Server Protocol) @@ -3097,7 +4476,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* When this argument is set to `'socket'`, then the linter will be defined as an LSP linter via a TCP - socket connection. `address` must be set. + or named pipe socket connection. `address` must be set. ALE will not start a server automatically. @@ -3122,7 +4501,10 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* `address` A |String| representing an address to connect to, or a |Funcref| accepting a buffer number and - returning the |String|. + returning the |String|. If the value contains a + colon, it is interpreted as referring to a TCP + socket; otherwise it is interpreted as the path of a + named pipe. The result can be computed with |ale#command#Run()|. @@ -3200,7 +4582,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* contents of the buffer being checked. All occurrences of `%t` in command strings will reference the one temporary file. The temporary file will be created inside a temporary directory, and the entire temporary directory - will be automatically deleted, following the behaviour of + will be automatically deleted, following the behavior of |ale#command#ManageDirectory|. This option can be used for some linters which do not support reading from stdin. @@ -3219,20 +4601,29 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* command, so literal character sequences `%s` and `%t` can be escaped by using `%%s` and `%%t` instead, etc. + Some |filename-modifiers| can be applied to `%s` and `%t`. Only `:h`, `:t`, + `:r`, and `:e` may be applied, other modifiers will be ignored. Filename + modifiers can be applied to the format markers by placing them after them. + + For example: > + 'command': '%s:h %s:e %s:h:t', +< + Given a path `/foo/baz/bar.txt`, the above command string will generate + something akin to `'/foo/baz' 'txt' 'baz'` + If a callback for a command generates part of a command string which might possibly contain `%%`, `%s`, `%t`, or `%e`, where the special formatting behavior is not desired, the |ale#command#EscapeCommandPart()| function can be used to replace those characters to avoid formatting issues. *ale-linter-loading-behavior* - *ale-linter-loading-behaviour* Linters for ALE will be loaded by searching |runtimepath| in the following format: > ale_linters//.vim < - Any linters which exist anywhere in |runtimepath| with that directory + Any linters which exist anywhere in 'runtimepath' with that directory structure will be automatically loaded for the matching |filetype|. Filetypes containing `.` characters will be split into individual parts, and files will be loaded for each filetype between the `.` characters. @@ -3369,6 +4760,23 @@ g:ale_want_results_buffer *g:ale_want_results_buffer* figure out which buffer other sources should lint. +ALECompletePost *ALECompletePost-autocmd* + *ALECompletePost* + + This |User| autocmd is triggered after ALE inserts an item on + |CompleteDone|. This event can be used to run commands after a buffer + is changed by ALE as the result of completion. For example, `:ALEFix` can + be configured to run automatically when completion is done: > + + augroup FixAfterComplete + autocmd! + " Run ALEFix when completion items are added. + autocmd User ALECompletePost ALEFix! + " If ALE starts fixing a file, stop linters running for now. + autocmd User ALEFixPre ALELintStop + augroup END +< + ALELintPre *ALELintPre-autocmd* *ALELintPre* ALELintPost *ALELintPost-autocmd* @@ -3381,7 +4789,7 @@ ALEFixPost *ALEFixPost-autocmd* These |User| autocommands are triggered before and after every lint or fix cycle. They can be used to update statuslines, send notifications, etc. The autocmd commands are run with |:silent|, so |:unsilent| is required for - echoing messges. + echoing messages. For example to change the color of the statusline while the linter is running: @@ -3411,6 +4819,13 @@ ALEJobStarted *ALEJobStarted-autocmd* |ale#engine#IsCheckingBuffer()| over |ALELintPre-autocmd|, which is actually triggered before any linters are executed. +ALELSPStarted *ALELSPStarted-autocmd* + *ALELSPStarted* + + This |User| autocommand is triggered immediately after an LSP connection is + successfully initialized. This provides a way to perform any additional + initialization work, such as setting up buffer-level mappings. + ALEWantResults *ALEWantResults-autocmd* *ALEWantResults* diff --git a/sources_non_forked/ale/ftplugin/ale-fix-suggest.vim b/sources_non_forked/ale/ftplugin/ale-fix-suggest.vim index 189a4dc2..42ade0fd 100644 --- a/sources_non_forked/ale/ftplugin/ale-fix-suggest.vim +++ b/sources_non_forked/ale/ftplugin/ale-fix-suggest.vim @@ -1,2 +1,5 @@ " Close the ALEFixSuggest window with the q key. noremap q :q! + +let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'execute') +let b:undo_ftplugin .= ' | execute "silent! unmap q"' diff --git a/sources_non_forked/ale/ftplugin/ale-info.vim b/sources_non_forked/ale/ftplugin/ale-info.vim new file mode 100644 index 00000000..a982a1b6 --- /dev/null +++ b/sources_non_forked/ale/ftplugin/ale-info.vim @@ -0,0 +1,22 @@ +" Close the ALEInfo preview window with the q key. +noremap q :q! + +" Explicitly use the default synmaxcol for ale-info. +setlocal synmaxcol=3000 + +function! ALEInfoOpenHelp() abort + let l:variable = matchstr(getline('.'), '\v[gb]:ale_[a-z0-9_]+') + + if !empty(l:variable) + execute('help ' . l:variable) + endif +endfunction + +" Press space to open :help for an ALE Variable +nnoremap :call ALEInfoOpenHelp() + +let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'execute') +let b:undo_ftplugin .= ' | setlocal synmaxcol<' +let b:undo_ftplugin .= ' | execute "silent! unmap q"' +let b:undo_ftplugin .= ' | execute "silent! nunmap "' +let b:undo_ftplugin .= ' | if exists(''*ALEInfoOpenHelp'') | delfunction ALEInfoOpenHelp | endif' diff --git a/sources_non_forked/ale/ftplugin/ale-preview-selection.vim b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim index d77b4f98..1ddd0abf 100644 --- a/sources_non_forked/ale/ftplugin/ale-preview-selection.vim +++ b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim @@ -12,5 +12,20 @@ noremap A noremap o noremap O " Keybinds for opening selection items. -noremap :call ale#preview#OpenSelectionInBuffer() +noremap :call ale#preview#OpenSelection() noremap t :call ale#preview#OpenSelectionInTab() + +let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'execute') +let b:undo_ftplugin .= ' | execute "silent! unmap q"' +let b:undo_ftplugin .= ' | execute "silent! unmap v"' +let b:undo_ftplugin .= ' | execute "silent! unmap i"' +let b:undo_ftplugin .= ' | execute "silent! unmap I"' +let b:undo_ftplugin .= ' | execute "silent! unmap "' +let b:undo_ftplugin .= ' | execute "silent! unmap "' +let b:undo_ftplugin .= ' | execute "silent! unmap "' +let b:undo_ftplugin .= ' | execute "silent! unmap a"' +let b:undo_ftplugin .= ' | execute "silent! unmap A"' +let b:undo_ftplugin .= ' | execute "silent! unmap o"' +let b:undo_ftplugin .= ' | execute "silent! unmap O"' +let b:undo_ftplugin .= ' | execute "silent! unmap "' +let b:undo_ftplugin .= ' | execute "silent! unmap t"' diff --git a/sources_non_forked/ale/ftplugin/ale-preview.vim b/sources_non_forked/ale/ftplugin/ale-preview.vim index ffbffbd5..75f3bb50 100644 --- a/sources_non_forked/ale/ftplugin/ale-preview.vim +++ b/sources_non_forked/ale/ftplugin/ale-preview.vim @@ -1,2 +1,5 @@ " Close the ALEPreviewWindow window with the q key. noremap q :q! + +let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'execute') +let b:undo_ftplugin .= ' | execute "silent! unmap q"' diff --git a/sources_non_forked/ale/lspconfig.vim b/sources_non_forked/ale/lspconfig.vim new file mode 100644 index 00000000..0e25fdc2 --- /dev/null +++ b/sources_non_forked/ale/lspconfig.vim @@ -0,0 +1,3 @@ +if get(g:, 'lspconfig', 0) + " lspconfig is installed. +endif diff --git a/sources_non_forked/ale/lua/ale/diagnostics.lua b/sources_non_forked/ale/lua/ale/diagnostics.lua new file mode 100644 index 00000000..93f94859 --- /dev/null +++ b/sources_non_forked/ale/lua/ale/diagnostics.lua @@ -0,0 +1,96 @@ +local module = {} + +local ale_type_to_diagnostic_severity = { + E = vim.diagnostic.severity.ERROR, + W = vim.diagnostic.severity.WARN, + I = vim.diagnostic.severity.INFO +} + +-- Equivalent to ale#Var, only we can't error on missing global keys. +module.aleVar = function(buffer, key) + key = "ale_" .. key + local exists, value = pcall(vim.api.nvim_buf_get_var, buffer, key) + + if exists then + return value + end + + return vim.g[key] +end + +module.sendAleResultsToDiagnostics = function(buffer, loclist) + local diagnostics = {} + + -- Convert all the ALE loclist items to the shape that Neovim's diagnostic + -- API is expecting. + for _, location in ipairs(loclist) do + if location.bufnr == buffer then + table.insert( + diagnostics, + -- All line numbers from ALE are 1-indexed, but all line numbers + -- in the diagnostics API are 0-indexed, so we have to subtract 1 + -- to make this work. + { + lnum = location.lnum - 1, + -- Ending line number, or if we don't have one, just make it the same + -- as the starting line number + end_lnum = (location.end_lnum or location.lnum) - 1, + -- Which column does the error start on? + col = math.max((location.col or 1) - 1, 0), + -- end_col does *not* appear to need 1 subtracted, so we don't. + end_col = location.end_col, + -- Which severity: error, warning, or info? + severity = ale_type_to_diagnostic_severity[location.type] or "E", + -- An error code + code = location.code, + -- The error message + message = location.text, + -- e.g. "rubocop" + source = location.linter_name, + } + ) + end + end + + local virtualtext_enabled_set = { + ['all'] = true, + ['2'] = true, + [2] = true, + ['current'] = true, + ['1'] = true, + [1] = true, + } + + local set_signs = module.aleVar(buffer, 'set_signs') + local sign_priority = module.aleVar(buffer, 'sign_priority') + local signs + + if set_signs == 1 and sign_priority then + -- If signs are enabled, set the priority for them. + local local_cfg = { priority = sign_priority } + local global_cfg = vim.diagnostic.config().signs + + if type(global_cfg) == 'boolean' then + signs = local_cfg + elseif type(global_cfg) == 'table' then + signs = vim.tbl_extend('force', global_cfg, local_cfg) + else + signs = function(...) + local calculated = global_cfg(...) + return vim.tbl_extend('force', calculated, local_cfg) + end + end + end + + vim.diagnostic.set( + vim.api.nvim_create_namespace('ale'), + buffer, + diagnostics, + { + virtual_text = virtualtext_enabled_set[vim.g.ale_virtualtext_cursor] ~= nil, + signs = signs, + } + ) +end + +return module diff --git a/sources_non_forked/ale/lua/ale/util.lua b/sources_non_forked/ale/lua/ale/util.lua new file mode 100644 index 00000000..98b3bbd9 --- /dev/null +++ b/sources_non_forked/ale/lua/ale/util.lua @@ -0,0 +1,14 @@ +local M = {} + +function M.configured_lspconfig_servers() + local configs = require 'lspconfig.configs' + local keys = {} + + for key, _ in pairs(configs) do + table.insert(keys, key) + end + + return keys +end + +return M diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 6262a7c4..40ff84ca 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -14,6 +14,7 @@ let g:loaded_ale_dont_use_this_in_other_plugins_please = 1 " A flag for detecting if the required features are set. if has('nvim') + " We check for Neovim 0.2.0+, but we only officially support NeoVim 0.7.0 let s:has_features = has('timers') && has('nvim-0.2.0') else " Check if Job and Channel functions are available, instead of the @@ -24,8 +25,10 @@ endif if !s:has_features " Only output a warning if editing some special files. if index(['', 'gitcommit'], &filetype) == -1 - execute 'echoerr ''ALE requires NeoVim >= 0.2.0 or Vim 8 with +timers +job +channel''' - execute 'echoerr ''Please update your editor appropriately.''' + " no-custom-checks + echoerr 'ALE requires NeoVim >= 0.7.0 or Vim 8 with +timers +job +channel' + " no-custom-checks + echoerr 'Please update your editor appropriately.' endif " Stop here, as it won't work. @@ -57,6 +60,10 @@ let g:ale_filetype_blacklist = [ let g:ale_linters = get(g:, 'ale_linters', {}) " This option can be changed to only enable explicitly selected linters. let g:ale_linters_explicit = get(g:, 'ale_linters_explicit', 0) +" Ignoring linters, for disabling some, or ignoring LSP diagnostics. +let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {}) +" Disabling all language server functionality. +let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 'auto') " This Dictionary configures which functions will be used for fixing problems. let g:ale_fixers = get(g:, 'ale_fixers', {}) @@ -87,8 +94,8 @@ let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 1) " This flag can be set to 1 to enable linting when the filetype is changed. let g:ale_lint_on_filetype_changed = get(g:, 'ale_lint_on_filetype_changed', 1) -" This Dictionary configures the default LSP roots for various linters. -let g:ale_lsp_root = get(g:, 'ale_lsp_root', {}) +" If set to 1, hints and suggestion from LSP servers and tsserver will be shown. +let g:ale_lsp_suggestions = get(g:, 'ale_lsp_suggestions', 0) " This flag can be set to 1 to enable automatically fixing files on save. let g:ale_fix_on_save = get(g:, 'ale_fix_on_save', 0) @@ -97,6 +104,13 @@ let g:ale_fix_on_save = get(g:, 'ale_fix_on_save', 0) " should be used instead. let g:ale_enabled = get(g:, 'ale_enabled', 1) +" A Dictionary mapping linter or fixer names to Arrays of two-item Arrays +" mapping filename paths from one system to another. +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) + +" This Dictionary configures the default project roots for various linters. +let g:ale_root = get(g:, 'ale_root', {}) + " These flags dictates if ale uses the quickfix or the loclist (loclist is the " default, quickfix overrides loclist). let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1) @@ -109,14 +123,20 @@ let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs')) " This flag can be set to 0 to disable setting error highlights. let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax')) +" This List can be configured to exclude particular highlights. +let g:ale_exclude_highlights = get(g:, 'ale_exclude_highlights', []) + " This flag can be set to 0 to disable echoing when the cursor moves. let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1) " This flag can be set to 1 to automatically show errors in the preview window. let g:ale_cursor_detail = get(g:, 'ale_cursor_detail', 0) -" This flag can be set to 1 to enable virtual text when the cursor moves. -let g:ale_virtualtext_cursor = get(g:, 'ale_virtualtext_cursor', 0) +" This flag can be changed to disable/enable virtual text. +let g:ale_virtualtext_cursor = get(g:, 'ale_virtualtext_cursor', (has('nvim-0.3.2') || has('patch-9.0.0297') && has('textprop') && has('popupwin')) ? 'all' : 'disabled') + +" This flag can be set to 1 to enable LSP hover messages at the cursor. +let g:ale_hover_cursor = get(g:, 'ale_hover_cursor', 1) " This flag can be set to 1 to automatically close the preview window upon " entering Insert Mode. @@ -125,6 +145,24 @@ let g:ale_close_preview_on_insert = get(g:, 'ale_close_preview_on_insert', 0) " This flag can be set to 0 to disable balloon support. let g:ale_set_balloons = get(g:, 'ale_set_balloons', has('balloon_eval') && has('gui_running')) +" Use preview window for hover messages. +let g:ale_hover_to_preview = get(g:, 'ale_hover_to_preview', 0) + +" Float preview windows in Neovim +let g:ale_floating_preview = get(g:, 'ale_floating_preview', 0) + +" Hovers use floating windows in Neovim +let g:ale_hover_to_floating_preview = get(g:, 'ale_hover_to_floating_preview', 0) + +" Detail uses floating windows in Neovim +let g:ale_detail_to_floating_preview = get(g:, 'ale_detail_to_floating_preview', 0) + +" Border setting for floating preview windows +" The elements in the list set the characters for the left, top, top-left, +" top-right, bottom-right, bottom-left, right, and bottom of the border +" respectively +let g:ale_floating_window_border = get(g:, 'ale_floating_window_border', ['|', '-', '+', '+', '+', '+', '|', '-']) + " This flag can be set to 0 to disable warnings for trailing whitespace let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whitespace', 1) " This flag can be set to 0 to disable warnings for trailing blank lines @@ -142,10 +180,38 @@ let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0) " Enable automatic detection of pipenv for Python linters. 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) + " This variable can be overridden to set the GO111MODULE environment variable. let g:ale_go_go111module = get(g:, 'ale_go_go111module', '') -if g:ale_set_balloons +" Default executable for deno, needed set before plugin start +let g:ale_deno_executable = get(g:, 'ale_deno_executable', 'deno') + +" If 1, enable a popup menu for commands. +let g:ale_popup_menu_enabled = get(g:, 'ale_popup_menu_enabled', has('gui_running')) + +" If 0, save hidden files when code actions are applied. +let g:ale_save_hidden = get(g:, 'ale_save_hidden', 0) + +" If 1, disables ALE's built in error display. Instead, all errors are piped +" to the diagnostics API. +let g:ale_use_neovim_diagnostics_api = get(g:, 'ale_use_neovim_diagnostics_api', has('nvim-0.7')) + +if g:ale_use_neovim_diagnostics_api && !has('nvim-0.7') + " no-custom-checks + echoerr('Setting g:ale_use_neovim_diagnostics_api to 1 requires Neovim 0.7+.') +endif + +if g:ale_set_balloons is 1 || g:ale_set_balloons is# 'hover' call ale#balloon#Enable() endif @@ -153,6 +219,10 @@ if g:ale_completion_enabled call ale#completion#Enable() endif +if g:ale_popup_menu_enabled + call ale#code_action#EnablePopUpMenu() +endif + " Define commands for moving through warnings and errors. command! -bar -nargs=* ALEPrevious \ :call ale#loclist_jumping#WrapJump('before', ) @@ -179,33 +249,41 @@ command! -bar ALEDisableBuffer :call ale#toggle#DisableBuffer(bufnr('')) command! -bar ALEResetBuffer :call ale#toggle#ResetBuffer(bufnr('')) " A command to stop all LSP-like clients, including tsserver. command! -bar ALEStopAllLSPs :call ale#lsp#reset#StopAllLSPs() +" A command to stop a specific language server, or tsseserver. +command! -bar -bang -nargs=1 -complete=customlist,ale#lsp#reset#Complete ALEStopLSP :call ale#lsp#reset#StopLSP(, '') " A command for linting manually. command! -bar ALELint :call ale#Queue(0, 'lint_file') +" Stop current jobs when linting. +command! -bar ALELintStop :call ale#engine#Stop(bufnr('')) + +" Commands to manually populate the quickfixes. +command! -bar ALEPopulateQuickfix :call ale#list#ForcePopulateErrorList(1) +command! -bar ALEPopulateLocList :call ale#list#ForcePopulateErrorList(0) " Define a command to get information about current filetype. -command! -bar ALEInfo :call ale#debugging#Info() -" The same, but copy output to your clipboard. -command! -bar ALEInfoToClipboard :call ale#debugging#InfoToClipboard() +command! -bar -nargs=* ALEInfo :call ale#debugging#InfoCommand() +" Deprecated and scheduled for removal in 4.0.0. +command! -bar ALEInfoToClipboard :call ale#debugging#InfoToClipboardDeprecatedCommand() " Copy ALE information to a file. command! -bar -nargs=1 ALEInfoToFile :call ale#debugging#InfoToFile() " Fix problems in files. -command! -bar -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEFix :call ale#fix#Fix(bufnr(''), '', ) +command! -bar -bang -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEFix :call ale#fix#Fix(bufnr(''), '', ) " Suggest registered functions to use for fixing problems. command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype) " Go to definition for tsserver and LSP -command! -bar ALEGoToDefinition :call ale#definition#GoTo({}) -command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab'}) -command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'horizontal-split'}) -command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vertical-split'}) +command! -bar -nargs=* ALEGoToDefinition :call ale#definition#GoToCommandHandler('', ) " Go to type definition for tsserver and LSP -command! -bar ALEGoToTypeDefinition :call ale#definition#GoToType({}) -command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab'}) -command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'horizontal-split'}) -command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vertical-split'}) +command! -bar -nargs=* ALEGoToTypeDefinition :call ale#definition#GoToCommandHandler('type', ) + +" Go to implementation for tsserver and LSP +command! -bar -nargs=* ALEGoToImplementation :call ale#definition#GoToCommandHandler('implementation', ) + +" Repeat a previous selection in the preview window +command! -bar ALERepeatSelection :call ale#preview#RepeatSelection() " Find references for tsserver and LSP command! -bar -nargs=* ALEFindReferences :call ale#references#Find() @@ -219,8 +297,24 @@ command! -bar ALEDocumentation :call ale#hover#ShowDocumentationAtCursor() " Search for appearances of a symbol, such as a type name or function name. command! -nargs=1 ALESymbolSearch :call ale#symbol#Search() +" Complete text with tsserver and LSP command! -bar ALEComplete :call ale#completion#GetCompletions('ale-manual') +" Try to find completions for the current symbol that add additional text. +command! -bar ALEImport :call ale#completion#Import() + +" Rename symbols using tsserver and LSP +command! -bar -bang ALERename :call ale#rename#Execute() + +" Rename file using tsserver +command! -bar -bang ALEFileRename :call ale#filerename#Execute() + +" Apply code actions to a range. +command! -bar -range ALECodeAction :call ale#codefix#Execute() + +" Organize import statements using tsserver +command! -bar ALEOrganizeImports :call ale#organize_imports#Execute() + " mappings for commands nnoremap (ale_previous) :ALEPrevious nnoremap (ale_previous_wrap) :ALEPreviousWrap @@ -248,17 +342,30 @@ nnoremap (ale_lint) :ALELint nnoremap (ale_detail) :ALEDetail nnoremap (ale_fix) :ALEFix nnoremap (ale_go_to_definition) :ALEGoToDefinition -nnoremap (ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab -nnoremap (ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit -nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit +nnoremap (ale_go_to_definition_in_tab) :ALEGoToDefinition -tab +nnoremap (ale_go_to_definition_in_split) :ALEGoToDefinition -split +nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinition -vsplit nnoremap (ale_go_to_type_definition) :ALEGoToTypeDefinition -nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab -nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit -nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit +nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinition -tab +nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinition -split +nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinition -vsplit +nnoremap (ale_go_to_implementation) :ALEGoToImplementation +nnoremap (ale_go_to_implementation_in_tab) :ALEGoToImplementation -tab +nnoremap (ale_go_to_implementation_in_split) :ALEGoToImplementation -split +nnoremap (ale_go_to_implementation_in_vsplit) :ALEGoToImplementation -vsplit nnoremap (ale_find_references) :ALEFindReferences nnoremap (ale_hover) :ALEHover nnoremap (ale_documentation) :ALEDocumentation inoremap (ale_complete) :ALEComplete +nnoremap (ale_import) :ALEImport +nnoremap (ale_rename) :ALERename +nnoremap (ale_filerename) :ALEFileRename +nnoremap (ale_code_action) :ALECodeAction +nnoremap (ale_repeat_selection) :ALERepeatSelection +nnoremap (ale_info) :ALEInfo +nnoremap (ale_info_echo) :ALEInfo -echo +nnoremap (ale_info_clipboard) :ALEInfo -clipboard +nnoremap (ale_info_preview) :ALEInfo -preview " Set up autocmd groups now. call ale#events#Init() diff --git a/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py b/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py index 3955ed2d..a692dc31 100644 --- a/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py +++ b/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py @@ -24,6 +24,7 @@ class Source(Base): self.rank = 1000 self.is_bytepos = True self.min_pattern_length = 1 + self.is_volatile = True # Do not forget to update s:trigger_character_map in completion.vim in # updating entries in this map. self.input_patterns = { @@ -31,6 +32,7 @@ class Source(Base): 'rust': r'(\.|::)\w*$', 'typescript': r'(\.|\'|")\w*$', 'cpp': r'(\.|::|->)\w*$', + 'c': r'(\.|->)\w*$', } # Returns an integer for the start position, as with omnifunc. @@ -44,21 +46,17 @@ class Source(Base): if not self.vim.call('ale#completion#CanProvideCompletions'): return None - if context.get('is_refresh'): - context['is_async'] = False + event = context.get('event') - if context['is_async']: - # Result is the same as for omnifunc, or None. + if event == 'Async': result = self.vim.call('ale#completion#GetCompletionResult') - if result is not None: - context['is_async'] = False + return result or [] - return result - else: - context['is_async'] = True - - # Request some completion results. - self.vim.call('ale#completion#GetCompletions', 'deoplete') + if context.get('is_refresh'): + self.vim.command( + "call ale#completion#GetCompletions('ale-callback', " + + "{'callback': {completions -> deoplete#auto_complete() }})" + ) return [] diff --git a/sources_non_forked/ale/supported-tools.md b/sources_non_forked/ale/supported-tools.md index c933f510..fa3200ea 100644 --- a/sources_non_forked/ale/supported-tools.md +++ b/sources_non_forked/ale/supported-tools.md @@ -14,22 +14,31 @@ formatting. **Legend** -| Key | Definition | -| ------------- | -------------------------------- | -| :floppy_disk: | Only checked when saved to disk | -| :warning: | Disabled by default | +| Key | Definition | +| ------------- | ----------------------------------------------------------------- | +| :floppy_disk: | May only run on files on disk (see: `help ale-lint-file-linters` | +| :warning: | Disabled by default | --- * Ada + * [ada_language_server](https://github.com/AdaCore/ada_language_server) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [gcc](https://gcc.gnu.org) * [gnatpp](https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/gnat_utility_programs.html#the-gnat-pretty-printer-gnatpp) :floppy_disk: * Ansible - * [ansible-lint](https://github.com/willthames/ansible-lint) + * [ansible-language-server](https://github.com/ansible/ansible-language-server/) + * [ansible-lint](https://github.com/willthames/ansible-lint) :floppy_disk: * API Blueprint * [drafter](https://github.com/apiaryio/drafter) +* APKBUILD + * [apkbuild-fixer](https://gitlab.alpinelinux.org/Leo/atools) + * [apkbuild-lint](https://gitlab.alpinelinux.org/Leo/atools) + * [secfixes-check](https://gitlab.alpinelinux.org/Leo/atools) * AsciiDoc - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [languagetool](https://languagetool.org/) :floppy_disk: * [proselint](http://proselint.com/) * [redpen](http://redpen.cc/) * [textlint](https://textlint.github.io/) @@ -37,61 +46,92 @@ formatting. * [write-good](https://github.com/btford/write-good) * 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 * [gawk](https://www.gnu.org/software/gawk/) * Bash + * [bashate](https://github.com/openstack/bashate) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [language-server](https://github.com/mads-hartmann/bash-language-server) * shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set) * [shellcheck](https://www.shellcheck.net/) * [shfmt](https://github.com/mvdan/sh) +* Bats + * [shellcheck](https://www.shellcheck.net/) +* Bazel + * [buildifier](https://github.com/bazelbuild/buildtools) * BibTeX * [bibclean](http://ftp.math.utah.edu/pub/bibclean/) +* Bicep + * [bicep](https://github.com/Azure/bicep) :floppy_disk: +* BitBake + * [oelint-adv](https://github.com/priv-kweihmann/oelint-adv) * Bourne Shell * shell [-n flag](http://linux.die.net/man/1/sh) * [shellcheck](https://www.shellcheck.net/) * [shfmt](https://github.com/mvdan/sh) * C + * [astyle](http://astyle.sourceforge.net/) * [ccls](https://github.com/MaskRay/ccls) * [clang](http://clang.llvm.org/) - * [clangd](https://clang.llvm.org/extra/clangd.html) * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) + * [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) :floppy_disk: + * [clangd](https://clang.llvm.org/extra/clangd.html) * [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk: * [cppcheck](http://cppcheck.sourceforge.net) - * [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) + * [cpplint](https://github.com/cpplint/cpplint) * [cquery](https://github.com/cquery-project/cquery) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [flawfinder](https://www.dwheeler.com/flawfinder/) * [gcc](https://gcc.gnu.org/) * [uncrustify](https://github.com/uncrustify/uncrustify) * C# + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [csc](http://www.mono-project.com/docs/about-mono/languages/csharp/) :floppy_disk: see:`help ale-cs-csc` for details and configuration + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [dotnet-format](https://github.com/dotnet/format) * [mcs](http://www.mono-project.com/docs/about-mono/languages/csharp/) see:`help ale-cs-mcs` for details * [mcsc](http://www.mono-project.com/docs/about-mono/languages/csharp/) :floppy_disk: see:`help ale-cs-mcsc` for details and configuration * [uncrustify](https://github.com/uncrustify/uncrustify) * C++ (filetype cpp) + * [astyle](http://astyle.sourceforge.net/) * [ccls](https://github.com/MaskRay/ccls) * [clang](http://clang.llvm.org/) + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) :floppy_disk: * [clangd](https://clang.llvm.org/extra/clangd.html) - * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk: * [clazy](https://github.com/KDE/clazy) :floppy_disk: * [cppcheck](http://cppcheck.sourceforge.net) * [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) :floppy_disk: * [cquery](https://github.com/cquery-project/cquery) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [flawfinder](https://www.dwheeler.com/flawfinder/) * [gcc](https://gcc.gnu.org/) * [uncrustify](https://github.com/uncrustify/uncrustify) +* C3 + * [c3lsp](https://github.com/pherrymason/c3-lsp) +* Cairo + * [scarb](https://docs.swmansion.com/scarb/) :floppy_disk: + * [starknet](https://starknet.io/docs) * Chef * [cookstyle](https://docs.chef.io/cookstyle.html) - * [foodcritic](http://www.foodcritic.io/) + * [foodcritic](http://www.foodcritic.io/) :floppy_disk: * Clojure * [clj-kondo](https://github.com/borkdude/clj-kondo) + * [cljfmt](https://github.com/weavejester/cljfmt) * [joker](https://github.com/candid82/joker) * CloudFormation * [cfn-python-lint](https://github.com/awslabs/cfn-python-lint) * CMake * [cmake-format](https://github.com/cheshirekow/cmake_format) - * [cmakelint](https://github.com/richq/cmake-lint) + * [cmake-lint](https://github.com/cheshirekow/cmake_format) + * [cmakelint](https://github.com/cmake-lint/cmake-lint) * CoffeeScript * [coffee](http://coffeescript.org/) * [coffeelint](https://www.npmjs.com/package/coffeelint) @@ -99,6 +139,9 @@ formatting. * [ameba](https://github.com/veelenga/ameba) :floppy_disk: * [crystal](https://crystal-lang.org/) :floppy_disk: * CSS + * [VSCode CSS language server](https://github.com/hrsh7th/vscode-langservers-extracted) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [css-beautify](https://github.com/beautify-web/js-beautify) * [csslint](http://csslint.net/) * [fecs](http://fecs.baidu.com/) * [prettier](https://github.com/prettier/prettier) @@ -106,44 +149,68 @@ formatting. * Cucumber * [cucumber](https://cucumber.io/) * CUDA - * [nvcc](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) + * [clangd](https://clang.llvm.org/extra/clangd.html) + * [nvcc](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) :floppy_disk: * Cypher * [cypher-lint](https://github.com/cleishm/libcypher-parser) * Cython (pyrex filetype) * [cython](http://cython.org/) * D + * [dfmt](https://github.com/dlang-community/dfmt) * [dls](https://github.com/d-language-server/dls) * [dmd](https://dlang.org/dmd-linux.html) * [uncrustify](https://github.com/uncrustify/uncrustify) * Dafny * [dafny](https://rise4fun.com/Dafny) :floppy_disk: * Dart - * [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk: + * [analysis_server](https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server) + * [dart-analyze](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk: + * [dart-format](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt) * [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt) * [language_server](https://github.com/natebosch/dart_language_server) +* desktop + * [desktop-file-validate](https://www.freedesktop.org/wiki/Software/desktop-file-utils/) +* Dhall + * [dhall-format](https://github.com/dhall-lang/dhall-lang) + * [dhall-freeze](https://github.com/dhall-lang/dhall-lang) + * [dhall-lint](https://github.com/dhall-lang/dhall-lang) * Dockerfile * [dockerfile_lint](https://github.com/projectatomic/dockerfile_lint) + * [dockerlinter](https://github.com/buddy-works/dockerfile-linter) + * [dprint](https://dprint.dev) * [hadolint](https://github.com/hadolint/hadolint) * Elixir * [credo](https://github.com/rrrene/credo) - * [dialyxir](https://github.com/jeremyjh/dialyxir) :floppy_disk: + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning: + * [dialyxir](https://github.com/jeremyjh/dialyxir) * [dogma](https://github.com/lpil/dogma) :floppy_disk: - * [elixir-ls](https://github.com/JakeBecker/elixir-ls) :warning: + * [elixir-ls](https://github.com/elixir-lsp/elixir-ls) :warning: + * [lexical](https://github.com/lexical-lsp/lexical) :warning: * [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk: * Elm * [elm-format](https://github.com/avh4/elm-format) - * [elm-lsp](https://github.com/antew/elm-lsp) + * [elm-ls](https://github.com/elm-tooling/elm-language-server) * [elm-make](https://github.com/elm/compiler) * Erb * [erb](https://apidock.com/ruby/ERB) + * [erb-formatter](https://github.com/nebulab/erb-formatter) + * [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 - * [erlc](http://erlang.org/doc/man/erlc.html) * [SyntaxErl](https://github.com/ten0s/syntaxerl) + * [dialyzer](http://erlang.org/doc/man/dialyzer.html) :floppy_disk: + * [elvis](https://github.com/inaka/elvis) :floppy_disk: + * [erlang-mode](https://www.erlang.org/doc/apps/tools/erlang_mode_chapter.html) (The Erlang mode for Emacs) + * [erlang_ls](https://github.com/erlang-ls/erlang_ls) + * [erlc](http://erlang.org/doc/man/erlc.html) + * [erlfmt](https://github.com/WhatsApp/erlfmt) * Fish * fish [-n flag](https://linux.die.net/man/1/fish) + * [fish_indent](https://fishshell.com/docs/current/cmds/fish_indent.html) * Fortran * [gcc](https://gcc.gnu.org/) * [language_server](https://github.com/hansec/fortran-language-server) @@ -153,28 +220,37 @@ 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) * Go * [bingo](https://github.com/saibing/bingo) :warning: + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning: * [go build](https://golang.org/cmd/go/) :warning: :floppy_disk: + * [go mod](https://golang.org/cmd/go/) :warning: :floppy_disk: + * [go vet](https://golang.org/cmd/vet/) :floppy_disk: * [gofmt](https://golang.org/cmd/gofmt/) + * [gofumpt](https://github.com/mvdan/gofumpt) * [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) :warning: * [golangci-lint](https://github.com/golangci/golangci-lint) :warning: :floppy_disk: * [golangserver](https://github.com/sourcegraph/go-langserver) :warning: - * [golint](https://godoc.org/github.com/golang/lint) - * [gometalinter](https://github.com/alecthomas/gometalinter) :warning: :floppy_disk: - * [go mod](https://golang.org/cmd/go/) :warning: :floppy_disk: - * [gopls](https://github.com/golang/go/wiki/gopls) :warning: + * [golines](https://github.com/segmentio/golines) + * [gopls](https://github.com/golang/go/wiki/gopls) * [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) :warning: :floppy_disk: * [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk: - * [go vet](https://golang.org/cmd/vet/) :floppy_disk: + * [revive](https://github.com/mgechev/revive) :warning: :floppy_disk: * [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) :warning: :floppy_disk: +* Go HTML Templates + * [djlint](https://djlint.com/) * GraphQL * [eslint](http://eslint.org/) * [gqlint](https://github.com/happylinks/gqlint) * [prettier](https://github.com/prettier/prettier) +* Groovy + * [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) * Hack * [hack](http://hacklang.org/) * [hackfmt](https://github.com/facebook/hhvm/tree/master/hphp/hack/hackfmt) @@ -182,11 +258,14 @@ formatting. * Haml * [haml-lint](https://github.com/brigade/haml-lint) * Handlebars + * [djlint](https://djlint.com/) * [ember-template-lint](https://github.com/rwjblue/ember-template-lint) * Haskell * [brittany](https://github.com/lspitzner/brittany) * [cabal-ghc](https://www.haskell.org/cabal/) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [floskell](https://github.com/ennocramer/floskell) + * [fourmolu](https://github.com/fourmolu/fourmolu) * [ghc](https://www.haskell.org/ghc/) * [ghc-mod](https://github.com/DanielG/ghc-mod) * [hdevtools](https://hackage.haskell.org/package/hdevtools) @@ -194,36 +273,65 @@ formatting. * [hie](https://github.com/haskell/haskell-ide-engine) * [hindent](https://hackage.haskell.org/package/hindent) * [hlint](https://hackage.haskell.org/package/hlint) + * [hls](https://github.com/haskell/haskell-language-server) + * [ormolu](https://github.com/tweag/ormolu) * [stack-build](https://haskellstack.org/) :floppy_disk: * [stack-ghc](https://haskellstack.org/) * [stylish-haskell](https://github.com/jaspervdj/stylish-haskell) * HCL + * [packer-fmt](https://github.com/hashicorp/packer) * [terraform-fmt](https://github.com/hashicorp/terraform) * HTML - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [VSCode HTML language server](https://github.com/hrsh7th/vscode-langservers-extracted) + * [alex](https://github.com/get-alex/alex) + * [angular](https://www.npmjs.com/package/@angular/language-server) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [djlint](https://www.djlint.com/) + * [eslint](https://github.com/BenoitZugmeyer/eslint-plugin-html) * [fecs](http://fecs.baidu.com/) - * [HTMLHint](http://htmlhint.com/) + * [html-beautify](https://beautifier.io/) + * [htmlhint](http://htmlhint.com/) * [prettier](https://github.com/prettier/prettier) * [proselint](http://proselint.com/) + * [rustywind](https://github.com/avencera/rustywind) * [tidy](http://www.html-tidy.org/) * [write-good](https://github.com/btford/write-good) +* HTML Angular + * [djlint](https://djlint.com/) +* HTML Django + * [djlint](https://djlint.com/) +* HTTP + * [kulala_fmt](https://github.com/mistweaverco/kulala-fmt) +* Hurl + * [hurlfmt](https://hurl.dev) * Idris * [idris](http://www.idris-lang.org/) +* Ink + * [ink-language-server](https://github.com/ephread/ink-language-server) +* Inko + * [inko](https://inko-lang.org/) :floppy_disk: * ISPC * [ispc](https://ispc.github.io/) :floppy_disk: * Java - * [checkstyle](http://checkstyle.sourceforge.net) + * [PMD](https://pmd.github.io/) + * [checkstyle](http://checkstyle.sourceforge.net) :floppy_disk: + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [eclipselsp](https://github.com/eclipse/eclipse.jdt.ls) * [google-java-format](https://github.com/google/google-java-format) * [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) * [javalsp](https://github.com/georgewfraser/vscode-javac) - * [PMD](https://pmd.github.io/) * [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/) + * [dprint](https://dprint.dev/) * [eslint](http://eslint.org/) * [fecs](http://fecs.baidu.com/) * [flow](https://flowtype.org/) - * [jscs](http://jscs.info/) + * [jscs](https://jscs-dev.github.io/) * [jshint](http://jshint.com/) * [prettier](https://github.com/prettier/prettier) * [prettier-eslint](https://github.com/prettier/prettier-eslint-cli) @@ -231,24 +339,43 @@ formatting. * [standard](http://standardjs.com/) * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) * [xo](https://github.com/sindresorhus/xo) +* Jinja + * [djlint](https://djlint.com/) * 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) + * [eslint](http://eslint.org/) :warning: * [fixjson](https://github.com/rhysd/fixjson) - * [jq](https://stedolan.github.io/jq/) - * [jsonlint](http://zaa.ch/jsonlint/) + * [jq](https://stedolan.github.io/jq/) :warning: + * [json.tool](https://docs.python.org/3/library/json.html#module-json.tool) :warning: + * [jsonlint](https://github.com/zaach/jsonlint) * [prettier](https://github.com/prettier/prettier) + * [spectral](https://github.com/stoplightio/spectral) +* 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) + * [jsonnetfmt](https://jsonnet.org/learning/tools.html) * Julia * [languageserver](https://github.com/JuliaEditorSupport/LanguageServer.jl) * Kotlin * [kotlinc](https://kotlinlang.org) :floppy_disk: - * [ktlint](https://ktlint.github.io) :floppy_disk: + * [ktlint](https://ktlint.github.io) * [languageserver](https://github.com/fwcd/KotlinLanguageServer) see `:help ale-integration-kotlin` for configuration instructions * LaTeX - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) * [chktex](http://www.nongnu.org/chktex/) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [lacheck](https://www.ctan.org/pkg/lacheck) * [proselint](http://proselint.com/) * [redpen](http://redpen.cc/) - * [texlab](https://texlab.netlify.com) ([Rust rewrite](https://github.com/latex-lsp/texlab/tree/rust)) + * [texlab](https://texlab.netlify.com) * [textlint](https://textlint.github.io/) * [vale](https://github.com/ValeLint/vale) * [write-good](https://github.com/btford/write-good) @@ -259,22 +386,32 @@ formatting. * LLVM * [llc](https://llvm.org/docs/CommandGuide/llc.html) * Lua + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [lua-format](https://github.com/Koihik/LuaFormatter) + * [lua-language-server](https://github.com/LuaLS/lua-language-server) * [luac](https://www.lua.org/manual/5.1/luac.html) * [luacheck](https://github.com/mpeterv/luacheck) + * [luafmt](https://github.com/trixnz/lua-fmt) + * [selene](https://github.com/Kampfkarren/selene) + * [stylua](https://github.com/johnnymorganz/stylua) * Mail - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) * [languagetool](https://languagetool.org/) :floppy_disk: * [proselint](http://proselint.com/) * [vale](https://github.com/ValeLint/vale) * Make * [checkmake](https://github.com/mrtazz/checkmake) * Markdown - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [languagetool](https://languagetool.org/) :floppy_disk: * [markdownlint](https://github.com/DavidAnson/markdownlint) :floppy_disk: + * [marksman](https://github.com/artempyanykh/marksman) * [mdl](https://github.com/mivok/markdownlint) + * [pandoc](https://pandoc.org) * [prettier](https://github.com/prettier/prettier) * [proselint](http://proselint.com/) + * [pymarkdown](https://github.com/jackdewinter/pymarkdown) * [redpen](http://redpen.cc/) * [remark-lint](https://github.com/wooorm/remark-lint) * [textlint](https://textlint.github.io/) @@ -286,17 +423,30 @@ formatting. * [mmc](http://mercurylang.org) :floppy_disk: * NASM * [nasm](https://www.nasm.us/) :floppy_disk: +* Nickel + * [nickel_format](https://github.com/tweag/nickel#formatting) * Nim * [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk: + * [nimlsp](https://github.com/PMunch/nimlsp) + * nimpretty * nix + * [alejandra](https://github.com/kamadorueda/alejandra) + * [deadnix](https://github.com/astro/deadnix) * [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) + * [nixfmt](https://github.com/serokell/nixfmt) + * [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) + * [rnix-lsp](https://github.com/nix-community/rnix-lsp) + * [statix](https://github.com/nerdypepper/statix) * nroff - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) * [proselint](http://proselint.com/) * [write-good](https://github.com/btford/write-good) +* Nunjucks + * [djlint](https://djlint.com/) * Objective-C * [ccls](https://github.com/MaskRay/ccls) * [clang](http://clang.llvm.org/) + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [clangd](https://clang.llvm.org/extra/clangd.html) * [uncrustify](https://github.com/uncrustify/uncrustify) * Objective-C++ @@ -304,10 +454,25 @@ formatting. * [clangd](https://clang.llvm.org/extra/clangd.html) * [uncrustify](https://github.com/uncrustify/uncrustify) * OCaml + * [dune](https://dune.build/) * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions * [ocamlformat](https://github.com/ocaml-ppx/ocamlformat) + * [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) + * [yamllint](https://yamllint.readthedocs.io/) +* OpenSCAD + * [SCA2D](https://gitlab.com/bath_open_instrumentation_group/sca2d) :floppy_disk: + * [scadformat](https://github.com/hugheaves/scadformat) +* Packer (HCL) + * [packer-fmt-fixer](https://github.com/hashicorp/packer) +* Pascal + * [ptop](https://www.freepascal.org/tools/ptop.var) * Pawn * [uncrustify](https://github.com/uncrustify/uncrustify) * Perl @@ -317,33 +482,43 @@ formatting. * Perl6 * [perl6 -c](https://perl6.org) :warning: * PHP + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [intelephense](https://github.com/bmewburn/intelephense-docs) * [langserver](https://github.com/felixfbecker/php-language-server) * [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions + * [php -l](https://secure.php.net/) + * [php-cs-fixer](https://cs.symfony.com) + * [phpactor](https://github.com/phpactor/phpactor) * [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) * [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) - * [php-cs-fixer](http://cs.sensiolabs.org/) - * [php -l](https://secure.php.net/) * [phpmd](https://phpmd.org) * [phpstan](https://github.com/phpstan/phpstan) + * [pint](https://github.com/laravel/pint) :beer: * [psalm](https://getpsalm.org) :floppy_disk: + * [tlint](https://github.com/tightenco/tlint) * PO - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) * [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html) * [proselint](http://proselint.com/) * [write-good](https://github.com/btford/write-good) * Pod - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) * [proselint](http://proselint.com/) * [write-good](https://github.com/btford/write-good) * Pony * [ponyc](https://github.com/ponylang/ponyc) * PowerShell - * [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk - * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [powershell](https://github.com/PowerShell/PowerShell) + * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) * Prolog * [swipl](https://github.com/SWI-Prolog/swipl-devel) * proto - * [protoc-gen-lint](https://github.com/ckaznocha/protoc-gen-lint) + * [buf-format](https://github.com/bufbuild/buf) :floppy_disk: + * [buf-lint](https://github.com/bufbuild/buf) :floppy_disk: + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) + * [protoc-gen-lint](https://github.com/ckaznocha/protoc-gen-lint) :floppy_disk: + * [protolint](https://github.com/yoheimuta/protolint) :floppy_disk: * Pug * [pug-lint](https://github.com/pugjs/pug-lint) * Puppet @@ -352,69 +527,107 @@ formatting. * [puppet-lint](https://puppet-lint.com) * PureScript * [purescript-language-server](https://github.com/nwolverson/purescript-language-server) + * [purs-tidy](https://github.com/natefaubion/purescript-tidy) + * [purty](https://gitlab.com/joneshf/purty) * Python + * [autoflake](https://github.com/myint/autoflake) :floppy_disk: + * [autoimport](https://lyz-code.github.io/autoimport/) * [autopep8](https://github.com/hhatto/autopep8) * [bandit](https://github.com/PyCQA/bandit) :warning: - * [black](https://github.com/ambv/black) + * [black](https://github.com/psf/black) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [flake8](http://flake8.pycqa.org/en/latest/) + * [flakehell](https://github.com/flakehell/flakehell) * [isort](https://github.com/timothycrosley/isort) * [mypy](http://mypy-lang.org/) - * [prospector](https://github.com/PyCQA/prospector) :warning: + * [prospector](https://github.com/PyCQA/prospector) :warning: :floppy_disk: + * [pycln](https://github.com/hadialqattan/pycln) * [pycodestyle](https://github.com/PyCQA/pycodestyle) :warning: * [pydocstyle](https://www.pydocstyle.org/) :warning: * [pyflakes](https://github.com/PyCQA/pyflakes) + * [pyflyby](https://github.com/deshaw/pyflyby) :warning: * [pylama](https://github.com/klen/pylama) :floppy_disk: * [pylint](https://www.pylint.org/) :floppy_disk: - * [pyls](https://github.com/palantir/python-language-server) :warning: + * [pylsp](https://github.com/python-lsp/python-lsp-server) :warning: * [pyre](https://github.com/facebook/pyre-check) :warning: + * [pyright](https://github.com/microsoft/pyright) + * [refurb](https://github.com/dosisod/refurb) :floppy_disk: * [reorder-python-imports](https://github.com/asottile/reorder_python_imports) + * [ruff](https://github.com/charliermarsh/ruff) + * [ruff-format](https://docs.astral.sh/ruff/formatter/) + * [unimport](https://github.com/hakancelik96/unimport) * [vulture](https://github.com/jendrikseipp/vulture) :warning: :floppy_disk: * [yapf](https://github.com/google/yapf) * QML * [qmlfmt](https://github.com/jesperhh/qmlfmt) * [qmllint](https://github.com/qt/qtdeclarative/tree/5.11/tools/qmllint) * R + * [languageserver](https://github.com/REditorSupport/languageserver) * [lintr](https://github.com/jimhester/lintr) * [styler](https://github.com/r-lib/styler) * Racket + * [racket-langserver](https://github.com/jeapostrophe/racket-langserver/tree/master) * [raco](https://docs.racket-lang.org/raco/) + * [raco_fmt](https://docs.racket-lang.org/fmt/) +* Re:VIEW + * [redpen](http://redpen.cc/) * ReasonML * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions * [ols](https://github.com/freebroccolo/ocaml-language-server) * [reason-language-server](https://github.com/jaredly/reason-language-server) * [refmt](https://github.com/reasonml/reason-cli) +* Rego + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [opacheck](https://www.openpolicyagent.org/docs/latest/cli/#opa-check) + * [opafmt](https://www.openpolicyagent.org/docs/latest/cli/#opa-fmt) +* REST + * [kulala_fmt](https://github.com/mistweaverco/kulala-fmt) * reStructuredText - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [proselint](http://proselint.com/) * [redpen](http://redpen.cc/) * [rstcheck](https://github.com/myint/rstcheck) * [textlint](https://textlint.github.io/) * [vale](https://github.com/ValeLint/vale) * [write-good](https://github.com/btford/write-good) -* Re:VIEW - * [redpen](http://redpen.cc/) +* Robot + * [rflint](https://github.com/boakley/robotframework-lint) * RPM spec * [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`) * Ruby * [brakeman](http://brakemanscanner.org/) :floppy_disk: + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [debride](https://github.com/seattlerb/debride) + * [packwerk](https://github.com/Shopify/packwerk) :floppy_disk: + * [prettier](https://github.com/prettier/plugin-ruby) * [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) :floppy_disk: * [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) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [rls](https://github.com/rust-lang-nursery/rls) :warning: + * [rust-analyzer](https://github.com/rust-analyzer/rust-analyzer) :warning: * [rustc](https://www.rust-lang.org/) :warning: * [rustfmt](https://github.com/rust-lang-nursery/rustfmt) +* Salt + * [salt-lint](https://github.com/warpnet/salt-lint) * Sass * [sass-lint](https://www.npmjs.com/package/sass-lint) * [stylelint](https://github.com/stylelint/stylelint) * Scala + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [fsc](https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html) + * [metals](https://scalameta.org/metals/) * [sbtserver](https://www.scala-sbt.org/1.x/docs/sbt-server.html) * [scalac](http://scala-lang.org) * [scalafmt](https://scalameta.org/scalafmt/) @@ -429,31 +642,51 @@ formatting. * SML * [smlnj](http://www.smlnj.org/) * Solidity + * [forge](https://github.com/foundry-rs/forge) + * [solc](https://solidity.readthedocs.io/) * [solhint](https://github.com/protofire/solhint) * [solium](https://github.com/duaraghav8/Solium) * SQL + * [dprint](https://dprint.dev) * [pgformatter](https://github.com/darold/pgFormatter) + * [sql-lint](https://github.com/joereynolds/sql-lint) + * [sqlfluff](https://github.com/sqlfluff/sqlfluff) * [sqlfmt](https://github.com/jackc/sqlfmt) + * [sqlformat](https://github.com/andialbrecht/sqlparse) * [sqlint](https://github.com/purcell/sqlint) * Stylus * [stylelint](https://github.com/stylelint/stylelint) * SugarSS * [stylelint](https://github.com/stylelint/stylelint) +* Svelte + * [prettier](https://github.com/prettier/prettier) + * [svelteserver](https://github.com/sveltejs/language-tools/tree/master/packages/language-server) * Swift + * [Apple swift-format](https://github.com/apple/swift-format) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [sourcekit-lsp](https://github.com/apple/sourcekit-lsp) * [swiftformat](https://github.com/nicklockwood/SwiftFormat) * [swiftlint](https://github.com/realm/SwiftLint) +* systemd + * [systemd-analyze](https://www.freedesktop.org/software/systemd/man/systemd-analyze.html) :floppy_disk: * Tcl * [nagelfar](http://nagelfar.sourceforge.net) :floppy_disk: * Terraform - * [fmt](https://github.com/hashicorp/terraform) + * [checkov](https://github.com/bridgecrewio/checkov) + * [terraform](https://github.com/hashicorp/terraform) + * [terraform-fmt-fixer](https://github.com/hashicorp/terraform) + * [terraform-ls](https://github.com/hashicorp/terraform-ls) + * [terraform-lsp](https://github.com/juliosueiras/terraform-lsp) * [tflint](https://github.com/wata727/tflint) + * [tfsec](https://github.com/aquasecurity/tfsec) * Texinfo - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [proselint](http://proselint.com/) * [write-good](https://github.com/btford/write-good) * Text - * [alex](https://github.com/wooorm/alex) :warning: :floppy_disk: + * [alex](https://github.com/get-alex/alex) :warning: + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [languagetool](https://languagetool.org/) :floppy_disk: * [proselint](http://proselint.com/) :warning: * [redpen](http://redpen.cc/) :warning: @@ -462,42 +695,81 @@ formatting. * [write-good](https://github.com/btford/write-good) :warning: * Thrift * [thrift](http://thrift.apache.org/) + * [thriftcheck](https://github.com/pinterest/thriftcheck) +* 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/) * [eslint](http://eslint.org/) * [fecs](http://fecs.baidu.com/) * [prettier](https://github.com/prettier/prettier) + * [standard](http://standardjs.com/) * [tslint](https://github.com/palantir/tslint) * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) * typecheck +* Typst + * [typstyle](https://github.com/Enter-tainer/typstyle) +* V + * [v](https://github.com/vlang/v/) :floppy_disk: + * [vfmt](https://github.com/vlang/v/) * VALA * [uncrustify](https://github.com/uncrustify/uncrustify) + * [vala_lint](https://github.com/vala-lang/vala-lint) :floppy_disk: * 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) + * [yosys](http://www.clifford.at/yosys/) :floppy_disk: * VHDL * [ghdl](https://github.com/ghdl/ghdl) * [vcom](https://www.mentor.com/products/fv/questa/) * [xvhdl](https://www.xilinx.com/products/design-tools/vivado.html) * Vim + * [vimls](https://github.com/iamcco/vim-language-server) * [vint](https://github.com/Kuniwak/vint) * Vim help - * [alex](https://github.com/wooorm/alex) :warning: :floppy_disk: + * [alex](https://github.com/get-alex/alex) :warning: * [proselint](http://proselint.com/) :warning: * [write-good](https://github.com/btford/write-good) :warning: * Vue + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [prettier](https://github.com/prettier/prettier) * [vls](https://github.com/vuejs/vetur/tree/master/server) + * [volar](https://github.com/johnsoncodehk/volar) +* WGSL + * [naga](https://github.com/gfx-rs/naga) * XHTML - * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [proselint](http://proselint.com/) * [write-good](https://github.com/btford/write-good) * XML * [xmllint](http://xmlsoft.org/xmllint.html) * YAML + * [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) - * [swaglint](https://github.com/byCedric/swaglint) + * [spectral](https://github.com/stoplightio/spectral) + * [swaglint](https://github.com/byCedric/swaglint) :warning: + * [yaml-language-server](https://github.com/redhat-developer/yaml-language-server) + * [yamlfix](https://lyz-code.github.io/yamlfix) + * [yamlfmt](https://github.com/google/yamlfmt) * [yamllint](https://yamllint.readthedocs.io/) + * [yq](https://github.com/mikefarah/yq) * YANG * [yang-lsp](https://github.com/theia-ide/yang-lsp) +* Yara + * [yls](https://github.com/avast/yls) +* Zeek + * [zeek](http://zeek.org) :floppy_disk: +* Zig + * [zigfmt](https://github.com/ziglang/zig) + * [zlint](https://github.com/DonIsaac/zlint) + * [zls](https://github.com/zigtools/zls) diff --git a/sources_non_forked/ale/syntax/ale-fix-suggest.vim b/sources_non_forked/ale/syntax/ale-fix-suggest.vim index b112f5b5..19734f4c 100644 --- a/sources_non_forked/ale/syntax/ale-fix-suggest.vim +++ b/sources_non_forked/ale/syntax/ale-fix-suggest.vim @@ -3,7 +3,7 @@ if exists('b:current_syntax') endif syn match aleFixerComment /^.*$/ -syn match aleFixerName /\(^\|, \)'[^']*'/ +syn match aleFixerName /\(^ *\|, \)'[^']*'/ syn match aleFixerHelp /^See :help ale-fix-configuration/ hi def link aleFixerComment Comment diff --git a/sources_non_forked/ale/syntax/ale-info.vim b/sources_non_forked/ale/syntax/ale-info.vim new file mode 100644 index 00000000..d47b58b8 --- /dev/null +++ b/sources_non_forked/ale/syntax/ale-info.vim @@ -0,0 +1,30 @@ +if exists('b:current_syntax') + finish +endif + +" Exhaustively list different ALE Info directives to match here. +" This should hopefully avoid matching too eagerly. +syn match aleInfoDirective /^ *Current Filetype:/ +syn match aleInfoDirective /^ *Available Linters:/ +syn match aleInfoDirective /^ *Enabled Linters:/ +syn match aleInfoDirective /^ *Ignored Linters:/ +syn match aleInfoDirective /^ *Suggested Fixers:/ +syn match aleInfoDirective /^ *Command History:/ + +syn match aleCommandNoOutput /^<<>>$/ + +hi def link aleInfoDirective Title +hi def link aleInfoDirective Title +hi def link aleCommandNoOutput Comment + +" Use Vim syntax highlighting for Vim options. +unlet! b:current_syntax +syntax include @srcVim syntax/vim.vim +syntax region aleInfoVimRegionLinter matchgroup=aleInfoDirective start="^ *Linter Variables:$" end="^ $" contains=@srcVim +syntax region aleInfoVimRegionGlobal matchgroup=aleInfoDirective start="^ *Global Variables:$" end="^ $" contains=@srcVim + +unlet! b:current_syntax +syntax include @srcAleFixSuggest syntax/ale-fix-suggest.vim +syntax region aleInfoFixSuggestRegion matchgroup=aleInfoDirective start="^ *Suggested Fixers:$" end="^ $" contains=@srcAleFixSuggest + +let b:current_syntax = 'ale-info' 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/ctrlp.vim/.github/FUNDING.yml b/sources_non_forked/ctrlp.vim/.github/FUNDING.yml new file mode 100644 index 00000000..d8c27bb8 --- /dev/null +++ b/sources_non_forked/ctrlp.vim/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: ctrlpvim # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim index 9d92cf1a..80dc9e4f 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim @@ -95,7 +95,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'brief_prompt': ['s:brfprt', 0], \ 'match_current_file': ['s:matchcrfile', 0], \ 'match_natural_name': ['s:matchnatural', 0], - \ 'compare_lim': ['s:compare_lim', 3000], + \ 'compare_lim': ['s:compare_lim', 0], \ 'bufname_mod': ['s:bufname_mod', ':t'], \ 'bufpath_mod': ['s:bufpath_mod', ':~:.:h'], \ 'formatline_func': ['s:flfunc', 's:formatline(v:val)'], @@ -330,6 +330,11 @@ fu! s:Open() endf fu! s:Close() + if has('patch-9.0.0115') && exists('s:cmdheight') + let &cmdheight = s:cmdheight + unlet s:cmdheight + en + cal s:async_glob_abort(0) cal s:buffunc(0) if winnr('$') == 1 bw! @@ -395,7 +400,7 @@ fu! ctrlp#files() en " Remove base directory cal ctrlp#rmbasedir(g:ctrlp_allfiles) - if len(g:ctrlp_allfiles) <= s:compare_lim + if !s:compare_lim || len(g:ctrlp_allfiles) <= s:compare_lim cal sort(g:ctrlp_allfiles, 'ctrlp#complen') en cal s:writecache(cafile) @@ -413,30 +418,107 @@ fu! ctrlp#files() endf fu! s:InitCustomFuncs() - if s:igntype == 4 && has_key(s:usrign, 'func-init') && s:usrign['func-init'] != '' + if s:igntype == 4 && get(s:usrign, 'func-init', '') != '' exe call(s:usrign['func-init'], []) en endf fu! s:CloseCustomFuncs() - if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != '' + if s:igntype == 4 && get(s:usrign, 'func-close', '') != '' exe call(s:usrign['func-close'], []) en endf -fu! s:GlobPath(dirs, depth) - let entries = split(globpath(a:dirs, s:glob), "\n") - let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] - cal extend(g:ctrlp_allfiles, dnf[1]) - if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth - sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1) - cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth) +if has('patch-8.2-0995') && get(g:, 'ctrlp_use_readdir', 1) + fu! s:GlobPath(dirs, depth) + let entries = [] + let dirs = substitute(a:dirs, '\\\([%# ]\)', '\1', 'g') + for e in split(dirs, ',') + try + let files = readdir(e, '1', {'sort': 'none'}) + if !s:showhidden | cal filter(files, 'v:val[0] != "."') | en + let entries += map(files, 'e.s:lash.v:val') + cat + endt + endfo + let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] + if &wig != '' | cal filter(dnf[1], 'glob(v:val) != ""') | en + let g:ctrlp_allfiles += dnf[1] + if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth + sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1) + cal s:GlobPath(join(dnf[0], ','), depth) + en + endf +el + fu! s:GlobPath(dirs, depth) + let entries = split(globpath(a:dirs, s:glob), "\n") + let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] + let g:ctrlp_allfiles += dnf[1] + if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth + sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1) + cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth) + en + endf +en + +fu! s:async_glob_update_progress(timer) + let s:must_wait = 0 + if exists('s:focus') && get(s:, 'setlines_post_ended', 0) + cal s:ForceUpdate() + en + if exists('s:timer') + sil! cal ctrlp#statusline() + en + + if !exists('s:job') + call s:stop_timer_if_exists() en endf -fu! ctrlp#addfile(ch, file) - call add(g:ctrlp_allfiles, a:file) - cal s:BuildPrompt(1) +fu! s:async_glob_on_stdout(job, data, ...) + if type(a:data) ==# type([]) + let g:ctrlp_allfiles += filter(a:data, 'v:val !=# ""') + el + let g:ctrlp_allfiles += [a:data] + en +endf + +fu! s:async_glob_on_exit(...) + let s:must_wait = 0 + if exists('s:job') + unl s:job + en + cal s:stop_timer_if_exists() + if exists('s:focus') && get(s:, 'setlines_post_ended', 0) + sil! cal ctrlp#statusline() + cal s:ForceUpdate() + en +endf + +fu! s:async_glob_abort(upd) + cal s:stop_job_if_exists() + cal s:stop_timer_if_exists() + if a:upd + cal s:ForceUpdate() + en +endf + +fu! s:stop_timer_if_exists() + if exists('s:timer') + cal timer_stop(s:timer) + unl s:timer + en +endf + +fu! s:stop_job_if_exists() + if exists('s:job') + if !has('nvim') + cal job_stop(s:job) + el + cal jobstop(s:job) + en + unl s:job + en endf fu! s:safe_printf(format, ...) @@ -450,7 +532,7 @@ endf fu! s:UserCmd(lscmd) let [path, lscmd] = [s:dyncwd, a:lscmd] let do_ign = - \ type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore'] + \ type(s:usrcmd) == 4 && get(s:usrcmd, 'ignore', 0) if do_ign && ctrlp#igncwd(s:cwd) | retu | en if exists('+ssl') && &ssl && &shell !~ 'sh' let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')] @@ -462,12 +544,26 @@ fu! s:UserCmd(lscmd) if (has('win32') || has('win64')) && match(&shell, 'sh') != -1 let path = tr(path, '\', '/') en - if s:usrcmdasync && v:version >= 800 && exists('*job_start') - if exists('s:job') - call job_stop(s:job) - en + if s:usrcmdasync && (v:version >= 800 || has('nvim')) && (exists('*job_start') || exists('*jobstart')) + cal s:stop_job_if_exists() let g:ctrlp_allfiles = [] - let s:job = job_start([&shell, &shellcmdflag, printf(lscmd, path)], {'callback': 'ctrlp#addfile'}) + let s:must_wait = 1 + let argv = [&shell, &shellcmdflag, printf(lscmd, path)] + if !has('nvim') + let s:job = job_start(argv, { + \ 'out_cb': function('s:async_glob_on_stdout'), + \ 'exit_cb': function('s:async_glob_on_exit') + \ }) + el + let s:job = jobstart(argv, { + \ 'on_stdout': function('s:async_glob_on_stdout'), + \ 'on_exit': function('s:async_glob_on_exit') + \ }) + en + let s:timer = timer_start(250, function('s:async_glob_update_progress'), {'repeat': -1}) + while s:must_wait + sleep 50m + endwhile elsei has('patch-7.4-597') && !(has('win32') || has('win64')) let g:ctrlp_allfiles = systemlist(s:safe_printf(lscmd, path)) el @@ -502,7 +598,7 @@ fu! s:lsCmd() retu cmd[1] elsei type(cmd) == 4 && ( has_key(cmd, 'types') || has_key(cmd, 'fallback') ) let fndroot = [] - if has_key(cmd, 'types') && cmd['types'] != {} + if get(cmd, 'types', {}) != {} let [markrs, cmdtypes] = [[], values(cmd['types'])] for pair in cmdtypes cal add(markrs, pair[0]) @@ -510,7 +606,7 @@ fu! s:lsCmd() let fndroot = s:findroot(s:dyncwd, markrs, 0, 1) en if fndroot == [] - retu has_key(cmd, 'fallback') ? cmd['fallback'] : '' + retu get(cmd, 'fallback', '') en for pair in cmdtypes if pair[0] == fndroot[0] | brea | en @@ -545,6 +641,9 @@ fu! ctrlp#buffers(...) retu ids el let bufs = [[], []] + if s:matcher != {} && !s:matchcrfile + call filter(ids, 'v:val != s:crbufnr') + en for id in ids let bname = bufname(id) let ebname = bname == '' @@ -565,7 +664,7 @@ fu! s:MatchIt(items, pat, limit, exc) try if (s:matchcrfile || !( s:ispath && item ==# a:exc )) && \call(s:mfunc, [item, pat]) >= 0 - cal add(lines, item) + let lines += [item] en cat | brea | endt if a:limit > 0 && len(lines) >= a:limit | brea | en @@ -579,12 +678,12 @@ fu! s:MatchedItems(items, pat, limit) let items = s:narrowable() ? s:matched + s:mdata[3] : a:items let matcher = s:getextvar('matcher') if empty(matcher) || type(matcher) != 4 || !has_key(matcher, 'match') - unlet matcher + unl matcher let matcher = s:matcher en if matcher != {} let argms = - \ has_key(matcher, 'arg_type') && matcher['arg_type'] == 'dict' ? [{ + \ get(matcher, 'arg_type', '') == 'dict' ? [{ \ 'items': items, \ 'str': a:pat, \ 'limit': a:limit, @@ -655,12 +754,23 @@ fu! s:Render(lines, pat) " Sorting if !s:nosort() let s:compat = s:martcs.pat - cal sort(lines, 's:mixedsort') + if has('patch-8.1-0') + cal sort(lines, function('s:mixedsort2', [s:curtype()])) + el + cal sort(lines, 's:mixedsort') + en unl s:compat en if s:mw_order == 'btt' | cal reverse(lines) | en let s:lines = copy(lines) - cal map(lines, s:flfunc) + if s:nolim == 0 && len(lines) > height + let lines = lines[:height-1] + en + if has('patch-8.1-0') && s:flfunc ==# 's:formatline(v:val)' + cal map(lines, function('s:formatline2', [s:curtype()])) + el + cal map(lines, s:flfunc) + en cal setline(1, s:offset(lines, height)) cal s:unmarksigns() cal s:remarksigns() @@ -687,7 +797,7 @@ fu! s:Update(str) \ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res) if empty(str) | cal clearmatches() | en cal s:Render(lines, pat) - return lines + retu lines endf fu! s:ForceUpdate() @@ -722,6 +832,9 @@ fu! s:BuildPrompt(upd) if empty(prt[1]) && s:focus exe 'echoh' hibase '| echon "_" | echoh None' en + if a:upd + cal s:NotifySearch() + en endf " - SetDefTxt() {{{1 fu! s:SetDefTxt() @@ -997,7 +1110,7 @@ fu! s:MapSpecs() if !( exists('s:smapped') && s:smapped == s:bufnr ) " Correct arrow keys in terminal if ( has('termresponse') && v:termresponse =~ "\" ) - \ || &term =~? '\vxterm|','\B ','\C ','\D '] exe s:lcmap.' ['.each endfo @@ -1054,6 +1167,7 @@ fu! s:ToggleByFname() endf fu! s:ToggleType(dir) + cal s:async_glob_abort(1) let max = len(g:ctrlp_ext_vars) + len(s:coretypes) - 1 let next = s:walker(max, s:itemtype, a:dir) cal ctrlp#setlines(next) @@ -1090,10 +1204,10 @@ fu! s:SetWD(args) \ && exists('s:dyncwd') cal ctrlp#setdir(s:dyncwd) | retu en - if has_key(a:args, 'dir') && a:args['dir'] != '' + if get(a:args, 'dir', '') != '' cal ctrlp#setdir(a:args['dir']) | retu en - let pmodes = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode + let pmodes = get(a:args, 'mode', s:pathmode) let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()] if (!type(pmodes)) let pmodes = @@ -1112,7 +1226,7 @@ fu! ctrlp#acceptfile(...) let useb = 0 if a:0 == 1 && type(a:1) == 4 let [md, line] = [a:1['action'], a:1['line']] - let atl = has_key(a:1, 'tail') ? a:1['tail'] : '' + let atl = get(a:1, 'tail', '') el let [md, line] = [a:1, a:2] let atl = a:0 > 2 ? a:3 : '' @@ -1204,7 +1318,7 @@ fu! s:AcceptSelection(action) " Do something with it if s:openfunc != {} && has_key(s:openfunc, s:ctype) let actfunc = s:openfunc[s:ctype] - let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list' + let type = get(s:openfunc, 'arg_type', 'list') el if s:itemtype < len(s:coretypes) let [actfunc, type] = ['ctrlp#acceptfile', 'dict'] @@ -1279,7 +1393,7 @@ fu! s:MarkToOpen() if exists('s:marked') let vac = s:vacantdict(s:marked) let key = empty(vac) ? len(s:marked) + 1 : vac[0] - let s:marked = extend(s:marked, { key : filpath }) + cal extend(s:marked, { key : filpath }) el let [key, s:marked] = [1, { 1 : filpath }] en @@ -1288,6 +1402,7 @@ fu! s:MarkToOpen() en en sil! cal ctrlp#statusline() + redr endf fu! s:OpenMulti(...) @@ -1388,13 +1503,13 @@ fu! s:OpenNoMarks(md, line) if a:md == 'a' let [s:marked, key] = [{}, 1] for line in s:lines - let s:marked = extend(s:marked, { key : fnamemodify(line, ':p') }) + cal extend(s:marked, { key : fnamemodify(line, ':p') }) let key += 1 endfo cal s:remarksigns() cal s:BuildPrompt(0) elsei a:md == 'x' - let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'dict' + let type = get(s:openfunc, 'arg_type', 'dict') let argms = type == 'dict' ? [{ 'action': a:md, 'line': a:line }] \ : [a:md, a:line] cal call(s:openfunc[s:ctype], argms, s:openfunc) @@ -1433,15 +1548,15 @@ fu! s:compmreb(...) " By last entered time (bufnr) let [id1, id2] = [index(s:mrbs, a:1), index(s:mrbs, a:2)] if id1 == id2 - return 0 - endif + retu 0 + en if id1 < 0 - return 1 - endif + retu 1 + en if id2 < 0 - return -1 - endif - return id1 > id2 ? 1 : -1 + retu -1 + en + retu id1 > id2 ? 1 : -1 endf fu! s:compmref(...) @@ -1477,7 +1592,7 @@ fu! s:matchlens(str, pat, ...) if nr > 20 | retu {} | en if match(a:str, a:pat, st) >= 0 let [mst, mnd] = [matchstr(a:str, a:pat, st), matchend(a:str, a:pat, st)] - let lens = extend(lens, { nr : [strlen(mst), mst] }) + cal extend(lens, { nr : [strlen(mst), mst] }) let lens = s:matchlens(a:str, a:pat, mnd, lens, nr + 1) en retu lens @@ -1487,6 +1602,32 @@ fu! s:shortest(lens) retu min(map(values(a:lens), 'v:val[0]')) endf +fu! s:mixedsort2(ct, ...) + if a:ct == 'buf' + let pat = '[\/]\?\[\d\+\*No Name\]$' + if a:1 =~# pat && a:2 =~# pat | retu 0 + elsei a:1 =~# pat | retu 1 + elsei a:2 =~# pat | retu -1 | en + en + let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)] + if s:ispath + let ms = [] + if s:res_count < 21 + let ms += [s:compfnlen(a:1, a:2)] + if a:ct !~ '^\(buf\|mru\)$' | let ms += [s:comptime(a:1, a:2)] | en + if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en + en + if a:ct =~ '^\(buf\|mru\)$' + let ms += [s:compmref(a:1, a:2)] + let cln = cml ? cln : 0 + en + let ms += [cml, 0, 0, 0] + let mp = call('s:multipliers', ms[:3]) + retu cln + ms[0] * mp[0] + ms[1] * mp[1] + ms[2] * mp[2] + ms[3] * mp[3] + en + retu cln + cml * 2 +endf + fu! s:mixedsort(...) let ct = s:curtype() if ct == 'buf' @@ -1545,7 +1686,7 @@ fu! ctrlp#statusline() \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : '' if s:status != {} let argms = - \ has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' ? [{ + \ get(s:status, 'arg_type', '') == 'dict' ? [{ \ 'focus': focus, \ 'byfname': byfname, \ 'regex': s:regexp, @@ -1563,6 +1704,9 @@ fu! ctrlp#statusline() let slider = ' <'.prv.'>={'.item.'}=<'.nxt.'>' let dir = ' %=%<%#CtrlPMode2# %{getcwd()} %*' let &l:stl = focus.byfname.regex.slider.marked.dir + if exists('s:timer') + let &l:stl = '%#CtrlPStats# '.len(g:ctrlp_allfiles).' '.&l:stl + en en endf @@ -1575,7 +1719,7 @@ fu! ctrlp#progress(enum, ...) if has('macunix') || has('mac') | sl 1m | en let txt = a:0 ? '(press ctrl-c to abort)' : '' if s:status != {} - let argms = has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' + let argms = get(s:status, 'arg_type', '') == 'dict' \ ? [{ 'str': a:enum }] : [a:enum] let &l:stl = call(s:status['prog'], argms, s:status) el @@ -1612,11 +1756,44 @@ fu! s:formatline(str) retu s:lineprefix.( cond ? s:pathshorten(str) : str ) endf -fu! s:pathshorten(str) - retu matchstr(a:str, '^.\{9}').'...' - \ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$') +fu! s:formatline2(ct, key, str) + let str = a:str + if a:ct == 'buf' + let bufnr = s:bufnrfilpath(str)[0] + let parts = s:bufparts(bufnr) + let str = printf('%'.s:bufnr_width.'s', bufnr) + if s:has_conceal && has('syntax_items') + let str .= printf(' %-13s %s%-36s', + \ ''.parts[0].'', + \ ''.parts[1], '{'.parts[2].'}') + if (!empty(s:bufpath_mod)) + let str .= printf(' %s', ''.parts[3].'') + en + el + let str .= printf(' %-5s %-30s', + \ parts[0], + \ parts[2]) + if (!empty(s:bufpath_mod)) + let str .= printf(' %s', parts[3]) + en + en + retu s:lineprefix.str + en + let cond = s:ispath && ( s:winw - 4 ) < strchars(str) + retu s:lineprefix.( cond ? s:pathshorten(str) : str ) endf +if exists('*strchars') && exists('*strcharpart') + fu! s:pathshorten(str) + retu strcharpart(a:str, 0, 9).'...'.strcharpart(a:str, strchars(a:str) - s:winw + 16) + endf +el + fu! s:pathshorten(str) + retu matchstr(a:str, '^.\{9}').'...' + \ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$') + endf +en + fu! s:offset(lines, height) let s:offset = s:mw_order == 'btt' ? ( a:height - s:res_count ) : 0 retu s:offset > 0 ? ( repeat([''], s:offset) + a:lines ) : a:lines @@ -1678,19 +1855,19 @@ fu! ctrlp#dirnfile(entries) if s:igntype >= 0 && s:usrign(each, etype) | con | en if etype == 'dir' if s:showhidden | if each !~ '[\/]\.\{1,2}$' - cal add(items[0], each) + let items[0] += [each] en | el - cal add(items[0], each) + let items[0] += [each] en elsei etype == 'link' if s:folsym let isfile = !isdirectory(each) if s:folsym == 2 || !s:samerootsyml(each, isfile, cwd) - cal add(items[isfile], each) + let items[isfile] += [each] en en elsei etype == 'file' - cal add(items[1], each) + let items[1] += [each] en endfo retu items @@ -1698,17 +1875,12 @@ endf fu! s:usrign(item, type) if s:igntype == 1 | retu a:item =~ s:usrign | en - if s:igntype == 2 - if call(s:usrign, [a:item, a:type]) - retu 1 - en - elsei s:igntype == 4 - if has_key(s:usrign, a:type) && s:usrign[a:type] != '' - \ && a:item =~ s:usrign[a:type] - retu 1 - elsei has_key(s:usrign, 'func') && s:usrign['func'] != '' - \ && call(s:usrign['func'], [a:item, a:type]) - retu 1 + if s:igntype == 2 | retu call(s:usrign, [a:item, a:type]) | en + if s:igntype == 4 + if get(s:usrign, a:type, '') != '' + retu a:item =~ s:usrign[a:type] + elsei get(s:usrign, 'func', '') != '' + retu call(s:usrign['func'], [a:item, a:type]) en en retu 0 @@ -1949,7 +2121,7 @@ fu! s:ifilter(list, str) for each in a:list try if eval(estr) - cal add(rlist, each) + let rlist += [each] en cat | con | endt endfo @@ -1974,7 +2146,7 @@ endf fu! s:sublist7071(l, s, e) let [newlist, id, ae] = [[], a:s, a:e == -1 ? len(a:l) - 1 : a:e] wh id <= ae - cal add(newlist, get(a:l, id)) + let newlist += [get(a:l, id)] let id += 1 endw retu newlist @@ -2003,14 +2175,14 @@ endf fu! s:isabs(path) if (has('win32') || has('win64')) - return a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]' + retu a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]' el - return a:path =~ '^[/\\]' + retu a:path =~ '^[/\\]' en endf fu! s:bufnrfilpath(line) - if s:isabs(a:line) || a:line =~ '^\~[/\\]' || a:line =~ '^\w\+:\/\/' + if s:isabs(a:line) || a:line =~ '^\~[/\\]' || a:line =~ '^\w\+:\/\/' let filpath = a:line el let filpath = s:dyncwd.s:lash().a:line @@ -2217,14 +2389,14 @@ endf fu! s:getinput(...) let [prt, spi] = [s:prompt, ( a:0 ? a:1 : '' )] if s:abbrev != {} - let gmd = has_key(s:abbrev, 'gmode') ? s:abbrev['gmode'] : '' + let gmd = get(s:abbrev, 'gmode', '') let str = ( gmd =~ 't' && !a:0 ) || spi == 'c' ? prt[0] : join(prt, '') if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k' retu join(prt, '') en let [pf, rz] = [( s:byfname() ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )] for dict in s:abbrev['abbrevs'] - let dmd = has_key(dict, 'mode') ? dict['mode'] : '' + let dmd = get(dict, 'mode', '') let pat = escape(dict['pattern'], '~') if ( dmd == '' || ( dmd =~ pf && dmd =~ rz && !a:0 ) \ || dmd =~ '['.spi.']' ) && str =~ pat @@ -2240,9 +2412,15 @@ fu! s:getinput(...) retu spi == 'c' ? prt[0] : join(prt, '') endf -fu! s:strwidth(str) - retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str) -endf +if exists('*strdisplaywidth') + fu! s:strwidth(str) + retu strdisplaywidth(a:str) + endf +el + fu! s:strwidth(str) + retu strlen(a:str) + endf +en fu! ctrlp#j2l(nr) exe 'norm!' a:nr.'G' @@ -2435,7 +2613,7 @@ fu! s:buildpat(lst) endf fu! s:curtype() - return s:CurTypeName()[1] + retu s:CurTypeName()[1] endf fu! s:mfunc() @@ -2537,6 +2715,10 @@ fu! ctrlp#clearmarkedlist() let s:marked = {} endf +fu! ctrlp#input() + retu s:getinput() +endf + fu! ctrlp#exit() cal s:PrtExit() endf @@ -2553,6 +2735,15 @@ fu! ctrlp#nosy() retu !( has('syntax') && exists('g:syntax_on') ) endf +fu! s:hiupdate() + for [ke, va] in items(s:hlgrps) + let ke = 'CtrlP' . ke + if hlexists(ke) + exe 'hi link' ke va + en + endfo +endf + fu! ctrlp#hicheck(grp, defgrp) if !hlexists(a:grp) exe 'hi link' a:grp a:defgrp @@ -2571,6 +2762,7 @@ endf fu! s:setlines_pre(...) if a:0 | let s:itemtype = a:1 | en cal s:modevar() + let s:setlines_post_ended = 0 let g:ctrlp_lines = [] endf @@ -2581,6 +2773,7 @@ fu! s:setlines_post() cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])') en let g:ctrlp_lines = eval(types[s:itemtype]) + let s:setlines_post_ended = 1 endf fu! ctrlp#setlines(...) @@ -2591,9 +2784,9 @@ endf " Returns [lname, sname] fu! s:CurTypeName() if s:itemtype < len(s:coretypes) - return filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0] + retu filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0] el - return [s:getextvar("lname"), s:getextvar('sname')] + retu [s:getextvar("lname"), s:getextvar('sname')] en endfu @@ -2601,15 +2794,15 @@ fu! s:ExitIfSingleCandidate() if len(s:Update(s:prompt[0])) == 1 call s:AcceptSelection('e') call ctrlp#exit() - return 1 + retu 1 en - return 0 + retu 0 endfu fu! s:IsBuiltin() let builtins = ['tag', 'dir', 'bft', 'rts', 'bkd', 'lns', 'chs', 'mix', 'udo', 'qfx'] let curtype = s:getextvar('sname') - return s:itemtype < len(s:coretypes) || index(builtins, curtype) > -1 + retu s:itemtype < len(s:coretypes) || index(builtins, curtype) > -1 endfu fu! s:DetectFileType(type, ft) @@ -2657,12 +2850,31 @@ fu! ctrlp#init(type, ...) let curName = s:CurTypeName() let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0 if shouldExitSingle && s:ExitIfSingleCandidate() - return 0 + retu 0 + en + + if has('patch-9.0.0115') && &cmdheight == 0 + let s:cmdheight = &cmdheight + set cmdheight=1 en cal s:BuildPrompt(1) if s:keyloop | cal s:KeyLoop() | en - return 1 + retu 1 endf + +" - Events {{{1 +fu! s:NotifySearch() + let l:cb = s:getextvar('search') + if l:cb != -1 + cal eval(l:cb) + en +endf + +fu! ctrlp#update(...) + cal s:ForceUpdate() + if a:0 | cal s:BuildPrompt(a:1) | en +endf + " - Autocmds {{{1 if has('autocmd') aug CtrlPAug @@ -2670,6 +2882,7 @@ if has('autocmd') au BufEnter ControlP cal s:checkbuf() au BufLeave ControlP noa cal s:Close() au VimLeavePre * cal s:leavepre() + au ColorScheme * cal s:hiupdate() aug END en diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/buffertag.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/buffertag.vim index f36a5cfc..4f75e6d3 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp/buffertag.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/buffertag.vim @@ -203,10 +203,14 @@ endf fu! s:parseline(line) let vals = matchlist(a:line, - \ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)') + \ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)\t?([^\t]*)') if vals == [] | retu '' | en let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')] - retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3] + if len(vals) > 7 && vals[7] != '' + retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'|'.vals[7].'| '.vals[3] + else + retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3] + en endf fu! s:syntax() @@ -249,7 +253,7 @@ endf fu! ctrlp#buffertag#accept(mode, str) let vals = matchlist(a:str, - \ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$') + \ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)%(\|[^\t|]+)?\|\s(.+)$') let bufnr = str2nr(get(vals, 1)) if bufnr cal ctrlp#acceptfile(a:mode, bufnr) diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/tag.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/tag.vim index c2294805..383f64a1 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp/tag.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/tag.vim @@ -116,10 +116,14 @@ fu! ctrlp#tag#accept(mode, str) if cmd != '' exe cmd en - let save_cst = &cst - set cst& + if exists('&cst') + let save_cst = &cst + set cst& + en cal feedkeys(":".( utg ? fdcnt[2] : "" )."ta ".tg."\r", 'nt') - let &cst = save_cst + if exists('&cst') + let &cst = save_cst + en el let ext = "" if fdcnt[1] < 2 && fdcnt[2] diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/utils.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/utils.vim index 91b9f24e..cfc9e6c8 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp/utils.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/utils.vim @@ -75,9 +75,9 @@ fu! ctrlp#utils#globpath(...) retu call('globpath', s:wig_cond ? a:000 : a:000[:1]) endf -fu! ctrlp#utils#fnesc(path, type, ...) - if exists('*fnameescape') - if exists('+ssl') +if exists('*fnameescape') + if exists('+ssl') + fu! ctrlp#utils#fnesc(path, type, ...) if a:type == 'c' let path = escape(a:path, '%#') elsei a:type == 'f' @@ -86,11 +86,17 @@ fu! ctrlp#utils#fnesc(path, type, ...) let path = escape(a:path, '?*') en let path = substitute(path, '[', '[[]', 'g') - el - let path = fnameescape(a:path) - en + retu a:0 ? escape(path, a:1) : path + endf el - if exists('+ssl') + fu! ctrlp#utils#fnesc(path, type, ...) + let path = fnameescape(a:path) + retu a:0 ? escape(path, a:1) : path + endf + en +el + if exists('+ssl') + fu! ctrlp#utils#fnesc(path, type, ...) if a:type == 'c' let path = escape(a:path, '%#') elsei a:type == 'f' @@ -99,12 +105,15 @@ fu! ctrlp#utils#fnesc(path, type, ...) let path = escape(a:path, '?*') en let path = substitute(path, '[', '[[]', 'g') - el + retu a:0 ? escape(path, a:1) : path + endf + el + fu! ctrlp#utils#fnesc(path, type, ...) let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<") - en + retu a:0 ? escape(path, a:1) : path + endf en - retu a:0 ? escape(path, a:1) : path -endf +en "}}} " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx index d99c4c6c..74379d48 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx @@ -203,7 +203,7 @@ OPTIONS *ctrlp-options* w - 用来修饰r:使用当前工作目录而不是当前文件所在目录进行查找 0 或者 - 禁用这项功能。 -注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者 +注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者 "c" 的行为(作为备选)。 注意 #2: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。 @@ -241,22 +241,8 @@ OPTIONS *ctrlp-options* < 注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 - *'ctrlp-wildignore'* -你可以使用Vim的 |'wildignore'| 来从结果集中排序文件或目录。 -例子: > - " 排除版本控制文件 - set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX - set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash') -< -注意 #1: 每个目录设置前的字符 `*/` 是必须的。 - -注意 #2: |wildignore| 影响 |expand()| , |globpath()| 和 |glob()| 的结果,这些函数被很 -多插件用来在系统中执行查找。(例如和版本控制系统有关的插件在查找.git/、.hg/等, -一些其他插件用来在Windows上查找外部的*.exe工具),所以要修改 |wildignore| 时请先 -考虑清楚。 - *'g:ctrlp_custom_ignore'* -作为对 |'wildignore'| 和 |g:ctrlp_show_hidden| 的补充,用来设置你只是想在CtrlP中隐藏的文件和目录。使用正 +除了 |g:ctrlp_show_hidden|,你可以用这个选项设置你想在CtrlP中隐藏的文件和目录。使用正 则表达式来指定匹配模式: > let g:ctrlp_custom_ignore = '' < @@ -274,9 +260,7 @@ OPTIONS *ctrlp-options* \ 'func': 'some#custom#match_function' \ } < -注意 #1: 默认情况下, |wildignore| 和 |g:ctrlp_custom_ignore| 只在 |globpath()| 被用 -来扫描文件的情况下使用,这样这些选项在那些使用 |g:ctrlp_user_command| 定义的命 -令中不会生效。 +注意 #1: |g:ctrlp_custom_ignore| 在已经使用 |g:ctrlp_user_command| 的时候不会生效。 注意 #2: 当改变选项的变量类型时,记得先 |:unlet| ,或者重启Vim来避免这个错误: "E706: Variable type mismatch" 。 @@ -285,6 +269,9 @@ OPTIONS *ctrlp-options* 自动加载的函数。函数必须接受两个参数,要匹配的条目和接受的类型,类型可以是目 录、文件和链接。如果条目被忽略,函数需要返回1,反之,返回0。 +注意 #4: 如果设置 |g:ctrlp_use_readdir| 为0,你可以使用 Vim 的 |'wildignore'| +来将文件和目录排除出搜索结果。 + *'g:ctrlp_max_files'* 扫描文件的最大数量,设置为0时不进行限制: > let g:ctrlp_max_files = 10000 @@ -425,10 +412,12 @@ OPTIONS *ctrlp-options* 注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 *'g:ctrlp_lazy_update'* -设置为1将开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口: > +设置为1将或更大可开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口: +> let g:ctrlp_lazy_update = 0 < -如果设置为1,在250毫秒后更新。如果大于1,数字会被作为延迟时间使用。 +如果设置为1,在250毫秒后更新該值作為默認值。如果大于1,数字会被作为延迟时间使 +用。 *'g:ctrlp_default_input'* 设置为1将为提示符面板提供当前文件的相对路径作为种子: > @@ -1045,7 +1034,7 @@ b) 在正则表达式模式,输入字符串被按照Vim的正则表达式模 例如: 'abc\d*efg' 会被解读为 'abc\d*efg'。 - 如何启用正则表达式模式参见 |ctrlp-fullregexp| (按键绑定)和 + 如何启用正则表达式模式参见 |ctrlp-fullregexp| (按键绑定)和 |g:ctrlp_regexp_search| (选项)。 c) 字符串末尾使用一个冒号':'跟随一个Vim命令来在打开那个文件后执行该命令。如果 @@ -1255,7 +1244,7 @@ h) 使用?打开帮助文件。 这样只会忽略包含 "build" 的目录和包含 "foo.txt" 的文件。不会忽略带 有 "build" 的文件或者反过来。 - 注意: 如果为了忽略名为 "build" 的目录,而不是『任何』包含 "build" + 注意: 如果为了忽略名为 "build" 的目录,而不是『任何』包含 "build" 的目录,你可以使用下面的正则: ^build$ - 常见问题: @@ -1439,7 +1428,7 @@ Before 2016/11/28~ + 新命令: |YankLine()| 来复制整个文件。 + 新选项: |g:ctrlp_types| 来选择內建类型。 + 新特性: 异步在新线程中调用 |g:ctrlp_user_command| 。 设置 - |g:user_command_async| 为1来启用。 + |g:ctrlp_user_command_async| 为1来启用。 + 为 delphi, rust 和 golang提供buffertag支持。 + 新选项: |g:ctrlp_brief_prompt|, |g:match_current_file|, diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt index 6c1335f2..571d91c5 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt @@ -240,23 +240,8 @@ Set this to 1 if you want CtrlP to scan for dotfiles and dotdirs: > Note: does not apply when a command defined with |g:ctrlp_user_command| is being used. - *'ctrlp-wildignore'* -You can use Vim's |'wildignore'| to exclude files and directories from the -results. -Examples: > - " Excluding version control directories - set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX - set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash') -< -Note #1: the `*/` in front of each directory glob is required. - -Note #2: |wildignore| influences the result of |expand()|, |globpath()| and -|glob()| which many plugins use to find stuff on the system (e.g. VCS related -plugins look for .git/, .hg/,... some other plugins look for external *.exe -tools on Windows). So be a little mindful of what you put in your |wildignore|. - *'g:ctrlp_custom_ignore'* -In addition to |'wildignore'| and |g:ctrlp_show_hidden|, use this for files +In addition to |g:ctrlp_show_hidden|, use this for files and directories you want only CtrlP to not show. Use regexp to specify the patterns: > let g:ctrlp_custom_ignore = '' @@ -275,8 +260,7 @@ Examples: > \ 'func': 'some#custom#match_function' \ } < -Note #1: by default, |wildignore| and |g:ctrlp_custom_ignore| only apply when -|globpath()| is used to scan for files, thus these options do not apply when a +Note #1: |g:ctrlp_custom_ignore| does not apply when a command defined with |g:ctrlp_user_command| is being used. Note #2: when changing the option's variable type, remember to |:unlet| it @@ -288,6 +272,9 @@ recommended here. The function must take 2 parameters, the item to match and its type. The type will be "dir", "file", or "link". The function must return 1 if the item should be ignored, 0 otherwise. +Note #4: when |g:ctrlp_use_readdir| is set to 0, you can also use Vim's |'wildignore'| +to exclude files and directories. + *'g:ctrlp_max_files'* The maximum number of files to scan, set to 0 for no limit: > let g:ctrlp_max_files = 10000 @@ -437,12 +424,12 @@ Note: does not apply when a command defined with |g:ctrlp_user_command| is being used. *'g:ctrlp_lazy_update'* -Set this to 1 to enable the lazy-update feature: only update the match window -after typing's been stopped for a certain amount of time: > +Set this to 1 or bigger to enable the lazy-update feature: only update the +match window after typing's been stopped for a certain amount of time: > let g:ctrlp_lazy_update = 0 < -If is 1, update after 250ms. If bigger than 1, the number will be used as the -delay time in milliseconds. +If is 1, update after 250ms that value as default tuned. If bigger than 1, the +number will be used as the delay time in milliseconds. *'g:ctrlp_default_input'* Set this to 1 to enable seeding the prompt with the current file's relative @@ -462,14 +449,15 @@ Includes the current file in the match entries: > By default, the current file is excluded from the list. -Note: does not apply when |g:ctrlp_match_func| is used. +Note: With the exception of |:CtrlPMRU|, does not apply when +|g:ctrlp_match_func| is used. *'g:ctrlp_types'* Set this to list of names to customize core types: > let g:ctrlp_types = ['mru', 'fil'] By default, the types are: > - let g:ctrlp_types = ['fil', 'buf', 'mru']. + let g:ctrlp_types = ['fil', 'buf', 'mru'] *'g:ctrlp_abbrev'* Define input abbreviations that can be expanded (either internally or visibly) @@ -846,6 +834,13 @@ Example: > *'g:ctrlp_brief_prompt'* When this is set to 1, the on empty prompt exit CtrlP. + *'g:ctrlp_use_readdir'* +Unlike kien/ctrlp.vim, ctrlpvim/ctrlp.vim uses readdir() instead of globpath() +for speed. Set this option to 0 if you want to revert to the original +behavior. +Example: > + let g:ctrlp_use_readdir = 0 +< *ctrlp-default-value* Otherwise, you can use below to change default value. Example: > @@ -853,6 +848,17 @@ Example: > This is possible to change no-limit mode for match type "path". + *ctrlp_compare_lim* +If your search directory has more number of files than this limit, no sorting +will be performed for the first readout. You can improve CtrlP performance by +setting this to a proper value, but no sorting on the first readout can reduce +the quality of fuzzy finding results. +Example: + let g:ctrlp_compare_lim = 100 + +Set the value to 0 for unlimited sorting. Default is 0. + + =============================================================================== COMMANDS *ctrlp-commands* @@ -1107,13 +1113,13 @@ c) End the string with a colon ':' followed by a Vim command to execute that See also: Vim's |++opt| and |+cmd|. -d) Submit two dots '..' to go upward the directory tree by 1 level. To go up +d) Input two dots '..' and then hit the key to go upward the directory tree by 1 level. To go up multiple levels, use one extra dot for each extra level: > Raw input Interpreted as - .. ../ - ... ../../ - .... ../../../ + .. ../ + ... ../../ + .... ../../../ < Note: if the parent directories are large and uncached, this can be slow. @@ -1505,7 +1511,7 @@ Before 2016/11/28~ + New command: |YankLine()| to yank current line. + New option: |g:ctrlp_types| to select builtin modes. + New feature: asynchronized spawn of |g:ctrlp_user_command|. This enable - with set |g:user_command_async| to 1. + with set |g:ctrlp_user_command_async| to 1. + Support buffertag for delphi, rust and golang. + New option: |g:ctrlp_brief_prompt|, |g:match_current_file|, diff --git a/sources_non_forked/ctrlp.vim/readme.md b/sources_non_forked/ctrlp.vim/readme.md index 2f4c6aed..9c9ef0ec 100644 --- a/sources_non_forked/ctrlp.vim/readme.md +++ b/sources_non_forked/ctrlp.vim/readme.md @@ -11,6 +11,17 @@ Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim. ![ctrlp][1] +## Install + +vim 8+ manages packages all on its own. Installing `ctrlp` is this simple: + +```bash +mkdir -p ~/.vim/pack/plugins/start +git clone --depth=1 https://github.com/ctrlpvim/ctrlp.vim.git ~/.vim/pack/plugins/start/ctrlp +``` + +Of course you can use your favorite plugin manager or check the [quick installation guide][3] for a primitive installation method. + ## Basic Usage * Run `:CtrlP` or `:CtrlP [starting-directory]` to invoke CtrlP in find file mode. * Run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in find buffer or find MRU file mode. @@ -97,13 +108,10 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi Check `:help ctrlp-options` for other options. -## Installation -Use your favorite method or check the homepage for a [quick installation guide][3]. - ## License CtrlP is distributed under Vim's [license][4]. -[1]: http://i.imgur.com/aOcwHwt.png +[1]: https://i.imgur.com/aOcwHwt.png [2]: https://github.com/ctrlpvim/ctrlp.vim/tree/extensions -[3]: http://ctrlpvim.github.com/ctrlp.vim#installation +[3]: https://ctrlpvim.github.io/ctrlp.vim#installation [4]: http://vimdoc.sourceforge.net/htmldoc/uganda.html diff --git a/sources_non_forked/goyo.vim/.github/FUNDING.yml b/sources_non_forked/goyo.vim/.github/FUNDING.yml new file mode 100644 index 00000000..f2848951 --- /dev/null +++ b/sources_non_forked/goyo.vim/.github/FUNDING.yml @@ -0,0 +1 @@ +github: junegunn diff --git a/sources_non_forked/goyo.vim/LICENSE b/sources_non_forked/goyo.vim/LICENSE new file mode 100644 index 00000000..50aa5d92 --- /dev/null +++ b/sources_non_forked/goyo.vim/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2021 Junegunn Choi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/sources_non_forked/goyo.vim/autoload/goyo.vim b/sources_non_forked/goyo.vim/autoload/goyo.vim index 6667620e..5d7de0e0 100644 --- a/sources_non_forked/goyo.vim/autoload/goyo.vim +++ b/sources_non_forked/goyo.vim/autoload/goyo.vim @@ -37,12 +37,14 @@ function! s:set_color(group, attr, color) execute printf('hi %s %s%s=%s', a:group, gui ? 'gui' : 'cterm', a:attr, a:color) endfunction +nnoremap (goyo-off) :call goyo_off() + function! s:blank(repel) if bufwinnr(t:goyo_pads.r) <= bufwinnr(t:goyo_pads.l) + 1 \ || bufwinnr(t:goyo_pads.b) <= bufwinnr(t:goyo_pads.t) + 3 - call s:goyo_off() + call feedkeys("\(goyo-off)") endif - execute 'wincmd' a:repel + execute 'noautocmd wincmd' a:repel endfunction function! s:init_pad(command) @@ -203,7 +205,7 @@ function! s:goyo_on(dim) endif " vim-signify - let t:goyo_disabled_signify = exists('b:sy') && b:sy.active + let t:goyo_disabled_signify = !empty(getbufvar(bufnr(''), 'sy')) if t:goyo_disabled_signify SignifyToggle endif diff --git a/sources_non_forked/goyo.vim/doc/goyo.txt b/sources_non_forked/goyo.vim/doc/goyo.txt index b8050226..0dc57b2a 100644 --- a/sources_non_forked/goyo.vim/doc/goyo.txt +++ b/sources_non_forked/goyo.vim/doc/goyo.txt @@ -32,8 +32,6 @@ INSTALLATION *goyo-installation* Use your favorite plugin manager. - *:PlugInstall* - - {vim-plug}{3} 1. Add `Plug 'junegunn/goyo.vim'` to .vimrc 2. Run `:PlugInstall` diff --git a/sources_non_forked/gruvbox/README.md b/sources_non_forked/gruvbox/README.md index 4269786c..7398ce71 100644 --- a/sources_non_forked/gruvbox/README.md +++ b/sources_non_forked/gruvbox/README.md @@ -1,4 +1,4 @@ -

+

gruvbox is heavily inspired by [badwolf][], [jellybeans][] and [solarized][]. @@ -13,7 +13,7 @@ Attention 1. [Read this first](https://github.com/morhetz/gruvbox/wiki/Terminal-specific) 2. Typeface from gallery is [Fantasque Sans Mono](https://github.com/belluzj/fantasque-sans) -3. Typeface from screenshots below is [Fira Mono](http://www.carrois.com/fira-4-1/) +3. Typeface from screenshots below is [Fira Mono](https://mozilla.github.io/Fira/) Screenshots ----------- diff --git a/sources_non_forked/gruvbox/colors/gruvbox.vim b/sources_non_forked/gruvbox/colors/gruvbox.vim index a0c2c0ba..66246fba 100644 --- a/sources_non_forked/gruvbox/colors/gruvbox.vim +++ b/sources_non_forked/gruvbox/colors/gruvbox.vim @@ -454,6 +454,7 @@ call s:HL('GruvboxYellowSign', s:yellow, s:sign_column, s:invert_signs) call s:HL('GruvboxBlueSign', s:blue, s:sign_column, s:invert_signs) call s:HL('GruvboxPurpleSign', s:purple, s:sign_column, s:invert_signs) call s:HL('GruvboxAquaSign', s:aqua, s:sign_column, s:invert_signs) +call s:HL('GruvboxOrangeSign', s:orange, s:sign_column, s:invert_signs) " }}} @@ -888,6 +889,30 @@ hi! link NERDTreeToggleOff GruvboxRed call s:HL('multiple_cursors_cursor', s:none, s:none, s:inverse) call s:HL('multiple_cursors_visual', s:none, s:bg2) +" }}} +" coc.nvim: {{{ + +hi! link CocErrorSign GruvboxRedSign +hi! link CocWarningSign GruvboxOrangeSign +hi! link CocInfoSign GruvboxYellowSign +hi! link CocHintSign GruvboxBlueSign +hi! link CocErrorFloat GruvboxRed +hi! link CocWarningFloat GruvboxOrange +hi! link CocInfoFloat GruvboxYellow +hi! link CocHintFloat GruvboxBlue +hi! link CocDiagnosticsError GruvboxRed +hi! link CocDiagnosticsWarning GruvboxOrange +hi! link CocDiagnosticsInfo GruvboxYellow +hi! link CocDiagnosticsHint GruvboxBlue + +hi! link CocSelectedText GruvboxRed +hi! link CocCodeLens GruvboxGray + +call s:HL('CocErrorHighlight', s:none, s:none, s:undercurl, s:red) +call s:HL('CocWarningHighlight', s:none, s:none, s:undercurl, s:orange) +call s:HL('CocInfoHighlight', s:none, s:none, s:undercurl, s:yellow) +call s:HL('CocHintHighlight', s:none, s:none, s:undercurl, s:blue) + " }}} " Filetype specific ----------------------------------------------------------- diff --git a/sources_non_forked/lightline-ale/LICENSE b/sources_non_forked/lightline-ale/LICENSE index a69d8868..ef1d8a84 100644 --- a/sources_non_forked/lightline-ale/LICENSE +++ b/sources_non_forked/lightline-ale/LICENSE @@ -1,21 +1,15 @@ -MIT License +ISC License -Copyright (c) 2017 Maxim Baz +Copyright (c) 2017-2021, Maxim Baz -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/sources_non_forked/lightline-ale/README.md b/sources_non_forked/lightline-ale/README.md index a2e345b0..78a1e853 100644 --- a/sources_non_forked/lightline-ale/README.md +++ b/sources_non_forked/lightline-ale/README.md @@ -6,17 +6,17 @@ This plugin provides [ALE](https://github.com/w0rp/ale) indicator for the [light ## Table Of Contents -* [Installation](#installation) -* [Integration](#integration) -* [Configuration](#configuration) -* [License](#license) +- [Installation](#installation) +- [Integration](#integration) +- [Configuration](#configuration) +- [License](#license) ## Installation Install using a plugin manager of your choice, for example: ```viml -call dein#add('w0rp/ale') " Dependency: linter +call dein#add('dense-analysis/ale') " Dependency: linter call dein#add('itchyny/lightline.vim') " Dependency: status line call dein#add('maximbaz/lightline-ale') ``` @@ -30,6 +30,7 @@ let g:lightline = {} let g:lightline.component_expand = { \ 'linter_checking': 'lightline#ale#checking', + \ 'linter_infos': 'lightline#ale#infos', \ 'linter_warnings': 'lightline#ale#warnings', \ 'linter_errors': 'lightline#ale#errors', \ 'linter_ok': 'lightline#ale#ok', @@ -40,25 +41,41 @@ let g:lightline.component_expand = { ```viml let g:lightline.component_type = { - \ 'linter_checking': 'left', + \ 'linter_checking': 'right', + \ 'linter_infos': 'right', \ 'linter_warnings': 'warning', \ 'linter_errors': 'error', - \ 'linter_ok': 'left', + \ 'linter_ok': 'right', \ } ``` 3. Add the components to the lightline, for example to the right side: ```viml -let g:lightline.active = { 'right': [[ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok' ]] } +let g:lightline.active = { 'right': [[ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ]] } ``` +3.1. Lineinfo, fileformat, etc. have to be added additionaly. Final example: + +```viml +let g:lightline.active = { + \ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ], + \ [ 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype'] ] } + +``` + ## Configuration ##### `g:lightline#ale#indicator_checking` The indicator to use when ALE is in progress. Default is `Linting...`. +##### `g:lightline#ale#indicator_infos` + +The indicator to use when there are infos. Default is `I:`. + ##### `g:lightline#ale#indicator_warnings` The indicator to use when there are warnings. Default is `W:`. @@ -77,22 +94,24 @@ If you would like to replace the default indicators with symbols like on the scr The following icons from the Font Awesome font are used in the screenshot: -* Checking: [f110](https://fontawesome.com/icons/spinner) -* Warnings: [f071](https://fontawesome.com/icons/exclamation-triangle) -* Errors: [f05e](https://fontawesome.com/icons/ban) -* OK: [f00c](https://fontawesome.com/icons/check) (although I prefer to disable this component) +- Checking: [f110](https://fontawesome.com/icons/spinner) +- Infos: [f129](https://fontawesome.com/icons/info) +- Warnings: [f071](https://fontawesome.com/icons/exclamation-triangle) +- Errors: [f05e](https://fontawesome.com/icons/ban) +- OK: [f00c](https://fontawesome.com/icons/check) (although I prefer to disable this component) To specify icons in the configuration, use their unicode codes as `"\uXXXX"` (make sure to wrap them in double quotes). Alternatively copy the icons from a font website, or type \u\<4-digit-unicode\> or \U\<8-digit-unicode\> to insert the literal characters. See the code points here: -* Font Awesome: https://fontawesome.com/icons -* Nerd Fonts: https://github.com/ryanoasis/nerd-fonts#glyph-sets +- Font Awesome: https://fontawesome.com/icons +- Nerd Fonts: https://github.com/ryanoasis/nerd-fonts#glyph-sets Here's the configuration snippet used in the screenshot: ```viml let g:lightline#ale#indicator_checking = "\uf110" +let g:lightline#ale#indicator_infos = "\uf129" let g:lightline#ale#indicator_warnings = "\uf071" let g:lightline#ale#indicator_errors = "\uf05e" let g:lightline#ale#indicator_ok = "\uf00c" @@ -100,4 +119,4 @@ let g:lightline#ale#indicator_ok = "\uf00c" ## License -Released under the [MIT License](LICENSE) +Released under the [ISC License](LICENSE) diff --git a/sources_non_forked/lightline-ale/autoload/lightline/ale.vim b/sources_non_forked/lightline-ale/autoload/lightline/ale.vim index 06aa90c1..c04f5ab7 100644 --- a/sources_non_forked/lightline-ale/autoload/lightline/ale.vim +++ b/sources_non_forked/lightline-ale/autoload/lightline/ale.vim @@ -1,3 +1,4 @@ +let s:indicator_infos = get(g:, 'lightline#ale#indicator_infos', 'I: ') let s:indicator_warnings = get(g:, 'lightline#ale#indicator_warnings', 'W: ') let s:indicator_errors = get(g:, 'lightline#ale#indicator_errors', 'E: ') let s:indicator_ok = get(g:, 'lightline#ale#indicator_ok', 'OK') @@ -7,14 +8,21 @@ let s:indicator_checking = get(g:, 'lightline#ale#indicator_checking', 'Linting. """""""""""""""""""""" " Lightline components +function! lightline#ale#infos() abort + if !lightline#ale#linted() + return '' + endif + let l:counts = ale#statusline#Count(bufnr('')) + return l:counts.info == 0 ? '' : printf(s:indicator_infos . '%d', l:counts.info) +endfunction + function! lightline#ale#warnings() abort if !lightline#ale#linted() return '' endif let l:counts = ale#statusline#Count(bufnr('')) - let l:all_errors = l:counts.error + l:counts.style_error - let l:all_non_errors = l:counts.total - l:all_errors - return l:all_non_errors == 0 ? '' : printf(s:indicator_warnings . '%d', all_non_errors) + let l:all_warnings = l:counts.warning + l:counts.style_warning + return l:all_warnings == 0 ? '' : printf(s:indicator_warnings . '%d', all_warnings) endfunction function! lightline#ale#errors() abort @@ -44,6 +52,7 @@ endfunction function! lightline#ale#linted() abort return get(g:, 'ale_enabled', 0) == 1 + \ && getbufvar(bufnr(''), 'ale_enabled', 1) \ && getbufvar(bufnr(''), 'ale_linted', 0) > 0 \ && ale#engine#IsCheckingBuffer(bufnr('')) == 0 endfunction diff --git a/sources_non_forked/lightline.vim/.github/workflows/ci.yaml b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml new file mode 100644 index 00000000..1531fc94 --- /dev/null +++ b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml @@ -0,0 +1,44 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + vim: + - 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@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/.travis.yml b/sources_non_forked/lightline.vim/.travis.yml deleted file mode 100644 index 9c8184a2..00000000 --- a/sources_non_forked/lightline.vim/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: generic - -install: - - git clone --depth=1 https://github.com/thinca/vim-themis /tmp/themis - - (if ! test -d $HOME/vim-$VIM_VERSION/bin; then - git clone https://github.com/vim/vim $HOME/vim && - cd $HOME/vim && - git checkout v$VIM_VERSION && - ./configure --prefix=$HOME/vim-$VIM_VERSION && - make && - make install; - fi) - -cache: - directories: - - $HOME/vim-$VIM_VERSION - -env: - - VIM_VERSION=8.1.1775 - - VIM_VERSION=8.1.1700 - - VIM_VERSION=8.1.0000 - - VIM_VERSION=8.0.0000 - - VIM_VERSION=7.4 - - VIM_VERSION=7.3 - -script: - - export PATH=$HOME/vim-$VIM_VERSION/bin:$PATH - - vim --version - - /tmp/themis/bin/themis --reporter spec diff --git a/sources_non_forked/lightline.vim/LICENSE b/sources_non_forked/lightline.vim/LICENSE index 56144fc6..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-2019 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/lightline.vim/README.md b/sources_non_forked/lightline.vim/README.md index 656fe90c..c2975e05 100644 --- a/sources_non_forked/lightline.vim/README.md +++ b/sources_non_forked/lightline.vim/README.md @@ -11,40 +11,36 @@ https://github.com/itchyny/lightline.vim ![lightline.vim - wombat](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/wombat.png) -### jellybeans - -![lightline.vim - jellybeans](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/jellybeans.png) - -### solarized dark +### solarized (`background=dark`) ![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) -### solarized light +### solarized (`background=light`) ![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) -### PaperColor light +### PaperColor (`background=dark`) -![lightline.vim - PaperColor](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor.png) +![lightline.vim - PaperColor_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) -### seoul256 +### PaperColor (`background=light`) -![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256.png) +![lightline.vim - PaperColor_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) -### one +### one (`background=dark`) -![lightline.vim - one](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one.png) +![lightline.vim - one_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) -### landscape +### one (`background=light`) -![lightline.vim - landscape](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape.png) +![lightline.vim - one_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) -landscape is my colorscheme, which is a high-contrast cterm-supported colorscheme, available at https://github.com/itchyny/landscape.vim +For screenshots of all available colorshemes, see [this file](colorscheme.md). ## Why yet another clone of powerline? + [vim-powerline](https://github.com/Lokaltog/vim-powerline) is a nice plugin, but deprecated. + [powerline](https://github.com/powerline/powerline) is a nice plugin, but difficult to configure. -+ [vim-airline](https://github.com/vim-airline/vim-airline) is a nice plugin, but it uses too much functions of other plugins, which should be done by users in `.vimrc`. ++ [vim-airline](https://github.com/vim-airline/vim-airline) is a nice plugin, but it uses too many functions of other plugins, which should be done by users in `.vimrc`. ## Spirit of this plugin + Minimalism. The core script is very small to achieve enough functions as a statusline plugin. @@ -52,7 +48,8 @@ landscape is my colorscheme, which is a high-contrast cterm-supported colorschem + Orthogonality. The plugin does not rely on the implementation of other plugins. Such plugin crossing settings should be configured by users. ## Installation -### [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528) +### [Vim packages](https://vimhelp.org/repeat.txt.html#packages) (since Vim 7.4.1528) +1. Clone the plugin with the following command. git clone https://github.com/itchyny/lightline.vim ~/.vim/pack/plugins/start/lightline @@ -84,6 +81,13 @@ landscape is my colorscheme, which is a high-contrast cterm-supported colorschem 2. Install with `:PlugInstall`. +### [dein.vim](https://github.com/Shougo/dein.vim) +1. Add the following configuration to your `.vimrc`. + + call dein#add('itchyny/lightline.vim') + +2. Install with `:call dein#install()` + ## Introduction After installing this plugin, you restart the editor and will get a cool statusline. ![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/1.png) @@ -105,7 +109,7 @@ then modify `TERM` in your shell configuration (`.zshrc` for example) ```sh export TERM=xterm-256color ``` -and then add the following configure to your `.vimrc`. +and then add the following configuration to your `.vimrc`. ```vim if !has('gui_running') set t_Co=256 @@ -154,7 +158,7 @@ Instead, lightline.vim provides a simple API that user can easily integrate with Once you understand how to configure and how it will be displayed in the statusline, you can also tell how to integrate with your favorite plugins. Let's start to configure the appearance. -The statusline is composed by multiple components. +The statusline is composed of multiple components. It shows the current mode, filename, modified status on the left, and file format, encoding, filetype and cursor positions on the right. So in order to add something in the statusline, you firstly create a new component and specify the place. @@ -225,7 +229,7 @@ Now let's add some integrations with other plugin. The name of the git branch is important these days. But lightline.vim does not provide this information by default because it is also one of plugin crossing configurations, and not all people want the integration. -In order to show the branch name in the statusline, install some plugins which provides the branch information. +In order to show the branch name in the statusline, install some plugins which provide the branch information. The [vim-fugitive](https://github.com/tpope/vim-fugitive) plugin is a famous plugin so let's integrate lightline.vim with it. If you don't like to install full git integration but just want to display the branch name in the statusline, you can use the [vim-gitbranch](https://github.com/itchyny/vim-gitbranch) plugin which provides `gitbranch#name` function. ```vim @@ -236,7 +240,7 @@ let g:lightline = { \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] \ }, \ 'component_function': { - \ 'gitbranch': 'fugitive#head' + \ 'gitbranch': 'FugitiveHead' \ }, \ } ``` @@ -320,7 +324,7 @@ let g:lightline = { \ } function! LightlineMode() - return expand('%:t') ==# '__Tagbar__' ? 'Tagbar': + return expand('%:t') =~# '^__Tagbar__' ? 'Tagbar': \ expand('%:t') ==# 'ControlP' ? 'CtrlP' : \ &filetype ==# 'unite' ? 'Unite' : \ &filetype ==# 'vimfiler' ? 'VimFiler' : @@ -374,6 +378,40 @@ endfunction You can control the visibility and contents by writing simple functions. Now you notice how much function component is important for the configurability of lightline.vim. +### more tips +#### Mode names are too long. Can I use shorter mode names? +Yes, configure `g:lightline.mode_map`. +```vim +let g:lightline = { + \ 'mode_map': { + \ 'n' : 'N', + \ 'i' : 'I', + \ 'R' : 'R', + \ 'v' : 'V', + \ 'V' : 'VL', + \ "\": 'VB', + \ 'c' : 'C', + \ 's' : 'S', + \ 'S' : 'SL', + \ "\": 'SB', + \ 't': 'T', + \ }, + \ } +``` + +#### How can I truncate the components from the right in narrow windows? +Please include `%<` to one of the right components. +```vim +let g:lightline = { + \ 'component': { + \ 'lineinfo': '%3l:%-2v%<', + \ }, + \ } +``` + +#### Where can I find the default components? +See `:h g:lightline.component`. + ## Note for developers of other plugins Appearance consistency matters. diff --git a/sources_non_forked/lightline.vim/autoload/lightline.vim b/sources_non_forked/lightline.vim/autoload/lightline.vim index 127622c0..ab736ca9 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline.vim " Author: itchyny " License: MIT License -" Last Change: 2019/08/20 14:00:00. +" Last Change: 2024/12/30 21:33:02. " ============================================================================= let s:save_cpo = &cpo @@ -11,34 +11,39 @@ set cpo&vim let s:_ = 1 " 1: uninitialized, 2: disabled function! lightline#update() abort - if &buftype ==# 'popup' | return | endif + if s:skip() | return | endif if s:_ if s:_ == 2 | return | endif call lightline#init() call lightline#colorscheme() endif - if !s:lightline.enable.statusline - return + if s:lightline.enable.statusline + let w = winnr() + let s = winnr('$') == 1 && w > 0 ? [lightline#statusline(0)] : [lightline#statusline(0), lightline#statusline(1)] + for n in range(1, winnr('$')) + call setwinvar(n, '&statusline', s[n!=w]) + endfor endif - let w = winnr() - let s = winnr('$') == 1 && w > 0 ? [lightline#statusline(0)] : [lightline#statusline(0), lightline#statusline(1)] - for n in range(1, winnr('$')) - call setwinvar(n, '&statusline', s[n!=w]) - call setwinvar(n, 'lightline', n!=w) - endfor endfunction -function! lightline#update_once() abort - if !exists('w:lightline') || w:lightline - call lightline#update() - endif -endfunction +if exists('*nvim_win_get_config') + function! s:skip() abort + return !nvim_win_get_config(0).focusable + endfunction +elseif exists('*win_gettype') + function! s:skip() abort " Vim 8.2.0257 (00f3b4e007), 8.2.0991 (0fe937fd86), 8.2.0996 (40a019f157) + return win_gettype() ==# 'popup' || win_gettype() ==# 'autocmd' + endfunction +else + function! s:skip() abort + return &buftype ==# 'popup' + endfunction +endif function! lightline#update_disable() abort - if !s:lightline.enable.statusline - return + if s:lightline.enable.statusline + call setwinvar(0, '&statusline', '') endif - call setwinvar(0, '&statusline', '') endfunction function! lightline#enable() abort @@ -46,14 +51,13 @@ function! lightline#enable() abort call lightline#update() augroup lightline autocmd! - autocmd WinEnter,BufEnter,SessionLoadPost * call lightline#update() + autocmd WinEnter,BufEnter,SessionLoadPost,FileChangedShellPost * call lightline#update() if !has('patch-8.1.1715') autocmd FileType qf call lightline#update() endif autocmd SessionLoadPost * call lightline#highlight() autocmd ColorScheme * if !has('vim_starting') || expand('') !=# 'macvim' \ | call lightline#update() | call lightline#highlight() | endif - autocmd CursorMoved,BufUnload * call lightline#update_once() augroup END augroup lightline-disable autocmd! @@ -110,7 +114,7 @@ let s:_lightline = { \ 'paste': '%{&paste?"PASTE":""}', 'readonly': '%R', 'charvalue': '%b', 'charvaluehex': '%B', \ 'spell': '%{&spell?&spelllang:""}', 'fileencoding': '%{&fenc!=#""?&fenc:&enc}', 'fileformat': '%{&ff}', \ 'filetype': '%{&ft!=#""?&ft:"no ft"}', 'percent': '%3p%%', 'percentwin': '%P', - \ 'lineinfo': '%3l:%-2v', 'line': '%l', 'column': '%c', 'close': '%999X X ', 'winnr': '%{winnr()}' + \ 'lineinfo': '%3l:%-2c', 'line': '%l', 'column': '%c', 'close': '%999X X ', 'winnr': '%{winnr()}' \ }, \ 'component_visible_condition': { \ 'modified': '&modified||!&modifiable', 'readonly': '&readonly', 'paste': '&paste', 'spell': '&spell' @@ -145,7 +149,6 @@ let s:_lightline = { \ }, \ 'mode_fallback': { 'replace': 'insert', 'terminal': 'insert', 'select': 'visual' }, \ 'palette': {}, - \ 'winwidth': winwidth(0), \ } function! lightline#init() abort let s:lightline = deepcopy(get(g:, 'lightline', {})) @@ -198,13 +201,7 @@ function! lightline#colorscheme() abort let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette finally if has('win32') && !has('gui_running') && &t_Co < 256 - for u in values(s:lightline.palette) - for v in values(u) - for _ in v - let [_[2], _[3]] = [lightline#colortable#gui2cui(_[0], _[2]), lightline#colortable#gui2cui(_[1], _[3])] - endfor - endfor - endfor + call lightline#colortable#gui2cui_palette(s:lightline.palette) endif let s:highlight = {} call lightline#highlight('normal') @@ -224,7 +221,7 @@ endfunction let s:mode = '' function! lightline#link(...) abort let mode = get(s:lightline._mode_, a:0 ? a:1 : mode(), 'normal') - if s:mode == mode + if s:mode ==# mode return '' endif let s:mode = mode @@ -297,6 +294,7 @@ function! lightline#highlight(...) abort endfor exec printf('hi LightlineMiddle_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', mode, ms[0], ms[1], ms[2], ms[3], s:term(ms)) endfor + if !a:0 | let s:mode = '' | endif endfunction function! s:subseparator(components, subseparator, expanded) abort @@ -319,68 +317,35 @@ function! lightline#statusline(inactive) abort return s:line(0, a:inactive) endfunction -function! s:normalize(result) abort - if type(a:result) == 3 - return map(a:result, 'type(v:val) == 1 ? v:val : string(v:val)') - elseif type(a:result) == 1 - return [a:result] - else - return [string(a:result)] - endif -endfunction - function! s:evaluate_expand(component) abort - try - let result = eval(a:component . '()') - if type(result) == 1 && result ==# '' - return [] - endif - catch - return [] - endtry - return map(type(result) == 3 ? (result + [[], [], []])[:2] : [[], [result], []], 'filter(s:normalize(v:val), "v:val !=# ''''")') + try | let value = eval(a:component . '()') | catch | return [] | endtry + return value is '' ? [] : + \ map(type(value) == 3 ? value : [[], [value], []], + \ 'filter(map(type(v:val) == 3 ? v:val : [v:val], + \ "type(v:val) == 1 ? v:val : string(v:val)"), + \ "v:val !=# ''''")') endfunction function! s:convert(name, index) abort - if has_key(s:lightline.component_expand, a:name) + if !has_key(s:lightline.component_expand, a:name) + return [[[a:name], 0, a:index, a:index]] + else let type = get(s:lightline.component_type, a:name, a:index) let is_raw = get(s:lightline.component_raw, a:name) || type ==# 'raw' - return filter(s:map(s:evaluate_expand(s:lightline.component_expand[a:name]), - \ '[v:val, 1 + ' . is_raw . ', v:key == 1 && ' . (type !=# 'raw') . ' ? "' . type . '" : "' . a:index . '", "' . a:index . '"]'), 'v:val[0] != []') - else - return [[[a:name], 0, a:index, a:index]] + return filter(map(s:evaluate_expand(s:lightline.component_expand[a:name]), + \ '[v:val, 1 + ' . is_raw . ', v:key == 1 && ' . (type !=# 'raw') . + \ ' ? "' . type . '" : "' . a:index . '", "' . a:index . '"]'), 'v:val[0] != []') endif endfunction -function! s:flatten_twice(xss) abort - let ys = [] - for xs in a:xss - for x in xs - let ys += x - endfor - endfor - return ys -endfunction - -if v:version > 702 || v:version == 702 && has('patch295') - let s:map = function('map') -else - function! s:map(xs, f) abort - let ys = [] - for i in range(len(a:xs)) - call extend(ys, map(a:xs[(i):(i)], substitute(a:f, 'v:key', i, 'g'))) - endfor - return ys - endfunction -endif - function! s:expand(components) abort let components = [] let expanded = [] let indices = [] let prevtype = '' let previndex = -1 - let xs = s:flatten_twice(s:map(deepcopy(a:components), 'map(v:val, "s:convert(v:val, ''" . v:key . "'')")')) + let xs = [] + call map(deepcopy(a:components), 'map(v:val, "extend(xs, s:convert(v:val, ''" . v:key . "''))")') for [component, expand, type, index] in xs if prevtype !=# type for i in range(previndex + 1, max([previndex, index - 1])) @@ -406,6 +371,10 @@ function! s:expand(components) abort return [components, expanded, indices] endfunction +function! s:func(name) abort + return exists('*' . a:name) ? '%{' . a:name . '()}' : '%{exists("*' . a:name . '")?' . a:name . '():""}' +endfunction + function! s:line(tabline, inactive) abort let _ = a:tabline ? '' : '%{lightline#link()}' if s:lightline.palette == {} @@ -415,32 +384,32 @@ function! s:line(tabline, inactive) abort let [p, s] = a:tabline ? [s:lightline.tabline_separator, s:lightline.tabline_subseparator] : [s:lightline.separator, s:lightline.subseparator] let [c, f, t, w] = [s:lightline.component, s:lightline.component_function, s:lightline.component_type, s:lightline.component_raw] let mode = a:tabline ? 'tabline' : a:inactive ? 'inactive' : 'active' - let l_ = has_key(s:lightline, mode) ? s:lightline[mode].left : s:lightline.active.left - let [lt, lc, ll] = s:expand(copy(l_)) - let r_ = has_key(s:lightline, mode) ? s:lightline[mode].right : s:lightline.active.right - let [rt, rc, rl] = s:expand(copy(r_)) - for i in range(len(lt)) - let _ .= '%#LightlineLeft_' . mode . '_' . ll[i] . '#' - for j in range(len(lt[i])) - let x = lc[i][j] ? lt[i][j] : has_key(f, lt[i][j]) ? (exists('*' . f[lt[i][j]]) ? '%{' . f[lt[i][j]] . '()}' : '%{exists("*' . f[lt[i][j]] . '")?' . f[lt[i][j]] . '():""}') : get(c, lt[i][j], '') - let _ .= has_key(t, lt[i][j]) && t[lt[i][j]] ==# 'raw' || get(w, lt[i][j]) || lc[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' - if j < len(lt[i]) - 1 && s.left !=# '' - let _ .= s:subseparator(lt[i][(j):], s.left, lc[i][(j):]) + let ls = has_key(s:lightline, mode) ? s:lightline[mode].left : s:lightline.active.left + let [lc, le, li] = s:expand(ls) + let rs = has_key(s:lightline, mode) ? s:lightline[mode].right : s:lightline.active.right + let [rc, re, ri] = s:expand(rs) + for i in range(len(lc)) + let _ .= '%#LightlineLeft_' . mode . '_' . li[i] . '#' + for j in range(len(lc[i])) + let x = le[i][j] ? lc[i][j] : has_key(f, lc[i][j]) ? s:func(f[lc[i][j]]) : get(c, lc[i][j], '') + let _ .= has_key(t, lc[i][j]) && t[lc[i][j]] ==# 'raw' || get(w, lc[i][j]) || le[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' + if j < len(lc[i]) - 1 && s.left !=# '' + let _ .= s:subseparator(lc[i][(j):], s.left, le[i][(j):]) endif endfor - let _ .= '%#LightlineLeft_' . mode . '_' . ll[i] . '_' . ll[i + 1] . '#' - let _ .= i < l + len(lt) - len(l_) && ll[i] < l || ll[i] != ll[i + 1] ? p.left : len(lt[i]) ? s.left : '' + let _ .= '%#LightlineLeft_' . mode . '_' . li[i] . '_' . li[i + 1] . '#' + let _ .= i < l + len(lc) - len(ls) && li[i] < l || li[i] != li[i + 1] ? p.left : len(lc[i]) ? s.left : '' endfor let _ .= '%#LightlineMiddle_' . mode . '#%=' - for i in reverse(range(len(rt))) - let _ .= '%#LightlineRight_' . mode . '_' . rl[i] . '_' . rl[i + 1] . '#' - let _ .= i < r + len(rt) - len(r_) && rl[i] < r || rl[i] != rl[i + 1] ? p.right : len(rt[i]) ? s.right : '' - let _ .= '%#LightlineRight_' . mode . '_' . rl[i] . '#' - for j in range(len(rt[i])) - let x = rc[i][j] ? rt[i][j] : has_key(f, rt[i][j]) ? (exists('*' . f[rt[i][j]]) ? '%{' . f[rt[i][j]] . '()}' : '%{exists("*' . f[rt[i][j]] . '")?' . f[rt[i][j]] . '():""}') : get(c, rt[i][j], '') - let _ .= has_key(t, rt[i][j]) && t[rt[i][j]] ==# 'raw' || get(w, rt[i][j]) || rc[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' - if j < len(rt[i]) - 1 && s.right !=# '' - let _ .= s:subseparator(rt[i][(j):], s.right, rc[i][(j):]) + for i in range(len(rc) - 1, 0, -1) + let _ .= '%#LightlineRight_' . mode . '_' . ri[i] . '_' . ri[i + 1] . '#' + let _ .= i < r + len(rc) - len(rs) && ri[i] < r || ri[i] != ri[i + 1] ? p.right : len(rc[i]) ? s.right : '' + let _ .= '%#LightlineRight_' . mode . '_' . ri[i] . '#' + for j in range(len(rc[i])) + let x = re[i][j] ? rc[i][j] : has_key(f, rc[i][j]) ? s:func(f[rc[i][j]]) : get(c, rc[i][j], '') + let _ .= has_key(t, rc[i][j]) && t[rc[i][j]] ==# 'raw' || get(w, rc[i][j]) || re[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' + if j < len(rc[i]) - 1 && s.right !=# '' + let _ .= s:subseparator(rc[i][(j):], s.right, re[i][(j):]) endif endfor endfor @@ -449,14 +418,16 @@ endfunction let s:tabnr = -1 let s:tabcnt = -1 +let s:columns = -1 let s:tabline = '' function! lightline#tabline() abort if !has_key(s:highlight, 'tabline') call lightline#highlight('tabline') endif - if s:lightline.tabline_configured || s:tabnr != tabpagenr() || s:tabcnt != tabpagenr('$') + if s:lightline.tabline_configured || s:tabnr != tabpagenr() || s:tabcnt != tabpagenr('$') || s:columns != &columns let s:tabnr = tabpagenr() let s:tabcnt = tabpagenr('$') + let s:columns = &columns let s:tabline = s:line(1, 0) endif return s:tabline @@ -467,10 +438,10 @@ function! lightline#tabs() abort let nr = tabpagenr() let cnt = tabpagenr('$') for i in range(1, cnt) - call add(i < nr ? x : i == nr ? y : z, (i > nr + 3 ? '%<' : '') . '%'. i . 'T%{lightline#onetab(' . i . ',' . (i == nr) . ')}' . (i == cnt ? '%T' : '')) + call add(i < nr ? x : i == nr ? y : z, (i > nr + 3 ? '%<' : '') . '%' . i . 'T%{lightline#onetab(' . i . ',' . (i == nr) . ')}' . (i == cnt ? '%T' : '')) endfor let abbr = '...' - let n = min([max([s:lightline.winwidth / 40, 2]), 8]) + let n = min([max([&columns / 40, 2]), 8]) if len(x) > n && len(z) > n let x = extend(add(x[:n/2-1], abbr), x[-(n+1)/2:]) let z = extend(add(z[:(n+1)/2-1], abbr), z[-n/2:]) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim index 79013ff2..9cd7fa4d 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme.vim " Author: itchyny " License: MIT License -" Last Change: 2018/09/01 22:48:24. +" Last Change: 2019/09/07 11:20:37. " ============================================================================= let s:save_cpo = &cpo @@ -243,7 +243,7 @@ else endif let fg_color = synIDattr(synIDtrans(hlID('Normal')), 'fg', 'cterm') if fg_color !=# '' - if fg_color < 8 || 232 <= fg_color && fg_color < 244 + if fg_color < 7 || 232 <= fg_color && fg_color < 244 return 'light' elseif 8 <= fg_color && fg_color < 16 || 244 <= fg_color return 'dark' diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim index 41e64970..19591024 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim @@ -1,49 +1,53 @@ " ============================================================================= " Filename: autoload/lightline/colorscheme/16color.vim -" Author: itchyny +" Author: itchyny, jackno " License: MIT License -" Last Change: 2017/11/25 11:14:04. " ============================================================================= -let s:base03 = [ '#808080', 8 ] -let s:base02 = [ '#000000', 0 ] -let s:base01 = [ '#00ff00', 10 ] -let s:base00 = [ '#ffff00', 11 ] -let s:base0 = [ '#0000ff', 12 ] -let s:base1 = [ '#00ffff', 14 ] -let s:base2 = [ '#c0c0c0', 7 ] -let s:base3 = [ '#ffffff', 15 ] -let s:yellow = [ '#808000', 3 ] -let s:orange = [ '#ff0000', 9 ] -let s:red = [ '#800000', 1 ] -let s:magenta = [ '#800080', 5 ] -let s:violet = [ '#ff00ff', 13 ] -let s:blue = [ '#000080', 4 ] -let s:cyan = [ '#008080', 6 ] +let s:black = [ '#000000', 0 ] +let s:maroon = [ '#800000', 1 ] let s:green = [ '#008000', 2 ] +let s:olive = [ '#808000', 3 ] +let s:navy = [ '#000080', 4 ] +let s:purple = [ '#800080', 5 ] +let s:teal = [ '#008080', 6 ] +let s:silver = [ '#c0c0c0', 7 ] +let s:gray = [ '#808080', 8] +let s:red = [ '#ff0000', 9 ] +let s:lime = [ '#00ff00', 10 ] +let s:yellow = [ '#ffff00', 11 ] +let s:blue = [ '#0000ff', 12 ] +let s:fuchsia = [ '#ff00ff', 13 ] +let s:aqua = [ '#00ffff', 14 ] +let s:white = [ '#ffffff', 15 ] if lightline#colorscheme#background() ==# 'light' - let [s:base03, s:base3] = [s:base3, s:base03] - let [s:base02, s:base2] = [s:base2, s:base02] - let [s:base01, s:base1] = [s:base1, s:base01] - let [s:base00, s:base0] = [s:base0, s:base00] + let [s:black, s:white] = [s:white, s:black] + let [s:silver, s:gray] = [s:gray, s:silver] + let [s:blue, s:aqua] = [s:aqua, s:blue] + let [s:purple, s:fuchsia] = [s:fuchsia, s:purple] + let [s:green, s:lime] = [s:lime, s:green] + let [s:red, s:yellow] = [s:yellow, s:red] endif let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -let s:p.normal.left = [ [ s:base3, s:blue ], [ s:base3, s:base01 ] ] -let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] -let s:p.inactive.right = [ [ s:base02, s:base01 ], [ s:base00, s:base02 ] ] -let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ] -let s:p.insert.left = [ [ s:base3, s:green ], [ s:base3, s:base01 ] ] -let s:p.replace.left = [ [ s:base3, s:red ], [ s:base3, s:base01 ] ] -let s:p.visual.left = [ [ s:base3, s:magenta ], [ s:base3, s:base01 ] ] -let s:p.normal.middle = [ [ s:base1, s:base02 ] ] -let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] -let s:p.tabline.left = [ [ s:base2, s:base01 ] ] -let s:p.tabline.tabsel = [ [ s:base2, s:base02 ] ] -let s:p.tabline.middle = [ [ s:base01, s:base2 ] ] +let s:p.normal.left = [ [ s:white, s:blue ], [ s:white, s:gray ] ] +let s:p.normal.middle = [ [ s:silver, s:black ] ] +let s:p.normal.right = [ [ s:white, s:blue ], [ s:white, s:gray ] ] +let s:p.normal.error = [ [ s:black, s:red ] ] +let s:p.normal.warning = [ [ s:black, s:yellow ] ] +let s:p.inactive.left = [ [ s:silver, s:gray ], [ s:gray, s:black ] ] +let s:p.inactive.middle = [ [ s:silver, s:black ] ] +let s:p.inactive.right = [ [ s:silver, s:gray ], [ s:gray, s:black ] ] +let s:p.insert.left = [ [ s:white, s:green ], [ s:white, s:gray ] ] +let s:p.insert.right = copy(s:p.insert.left) +let s:p.replace.left = [ [ s:white, s:red ], [ s:white, s:gray ] ] +let s:p.replace.right = copy(s:p.replace.left) +let s:p.visual.left = [ [ s:white, s:purple ], [ s:white, s:gray ] ] +let s:p.visual.right = copy(s:p.visual.left) +let s:p.tabline.left = [ [ s:silver, s:black ] ] +let s:p.tabline.tabsel = copy(s:p.normal.right) +let s:p.tabline.middle = [ [ s:silver, s:black ] ] let s:p.tabline.right = copy(s:p.normal.right) -let s:p.normal.error = [ [ s:base2, s:red ] ] -let s:p.normal.warning = [ [ s:base02, s:yellow ] ] let g:lightline#colorscheme#16color#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim index 82559669..87b9ff04 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim @@ -2,8 +2,9 @@ " Filename: autoload/lightline/colorscheme/Tomorrow.vim " Author: itchyny " License: MIT License -" Last Change: 2013/09/07 12:22:37. +" Last Change: 2022/03/15 23:57:37. " ============================================================================= + let s:base03 = '#fafafa' let s:base023 = '#dfdfdf' let s:base02 = '#c8c8c8' diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim index 89031802..568dc51a 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim @@ -2,8 +2,9 @@ " Filename: autoload/lightline/colorscheme/Tomorrow_Night.vim " Author: itchyny " License: MIT License -" Last Change: 2013/09/07 12:23:38. +" Last Change: 2022/03/15 23:57:43. " ============================================================================= + let s:base3 = '#c5c8c6' let s:base2 = '#bababa' let s:base1 = '#a0a0a0' diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim index 31c27f35..016bbd41 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim @@ -2,8 +2,9 @@ " Filename: autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim " Author: itchyny " License: MIT License -" Last Change: 2013/09/07 14:13:21. +" Last Change: 2022/03/15 23:57:49. " ============================================================================= + let s:base3 = '#ffffff' let s:base23 = '#ffffff' let s:base2 = '#ffffff' @@ -22,7 +23,6 @@ let s:cyan = '#99ffff' let s:blue = '#bbdaff' let s:magenta = '#ebbbff' - let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} let s:p.normal.left = [ [ s:base023, s:blue ], [ s:base3, s:base01 ] ] let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim index 5b81a316..d59517b9 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim @@ -2,8 +2,9 @@ " Filename: autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim " Author: itchyny " License: MIT License -" Last Change: 2013/09/07 14:13:26. +" Last Change: 2022/03/15 23:57:52. " ============================================================================= + let s:base3 = '#eaeaea' let s:base23 = '#d0d0d0' let s:base2 = '#c6c6c6' diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim index 5124eccb..993d16a3 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim @@ -2,8 +2,9 @@ " Filename: autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim " Author: itchyny " License: MIT License -" Last Change: 2013/09/07 14:14:14. +" Last Change: 2022/03/15 23:57:56. " ============================================================================= + let s:base3 = '#cccccc' let s:base23 = '#bbbbbb' let s:base2 = '#aaaaaa' diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim new file mode 100644 index 00000000..77d40bad --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim @@ -0,0 +1,46 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/apprentice.vim +" Author: pt307 (based on work by romainl) +" License: MIT License +" Last Change: 2021/03/02 18:25:22. +" ============================================================================= + +" For the Apprentice colorscheme + +let s:almost_black = [ '#1c1c1c', 234 ] +let s:darker_grey = [ '#262626', 235 ] +let s:medium_grey = [ '#585858', 240 ] +let s:lighter_grey = [ '#bcbcbc', 250 ] +let s:green = [ '#5f875f', 65 ] +let s:red = [ '#af5f5f', 131 ] +let s:orange = [ '#ff8700', 208 ] +let s:ocre = [ '#87875f', 101 ] +let s:yellow = [ '#ffffaf', 229 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.left = [ [ s:darker_grey, s:ocre ], [ s:darker_grey, s:medium_grey ] ] +let s:p.normal.middle = [ [ s:lighter_grey, s:darker_grey ] ] +let s:p.normal.right = [ [ s:darker_grey, s:ocre ], [ s:darker_grey, s:medium_grey ] ] +let s:p.normal.warning = [ [ s:almost_black, s:orange ] ] +let s:p.normal.error = [ [ s:almost_black, s:red ] ] + +let s:p.inactive.left = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.inactive.middle = [ [ s:medium_grey, s:darker_grey ] ] +let s:p.inactive.right = [ [ s:darker_grey, s:medium_grey ] ] + +let s:p.insert.left = [ [ s:darker_grey, s:green ], [ s:darker_grey, s:medium_grey ] ] +let s:p.insert.right = [ [ s:darker_grey, s:green ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.replace.left = [ [ s:darker_grey, s:red ], [ s:darker_grey, s:medium_grey ] ] +let s:p.replace.right = [ [ s:darker_grey, s:red ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.visual.left = [ [ s:darker_grey, s:yellow ], [ s:darker_grey, s:medium_grey ] ] +let s:p.visual.right = [ [ s:darker_grey, s:yellow ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.tabline.left = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.tabline.middle = [ [ s:lighter_grey, s:darker_grey ] ] +let s:p.tabline.right = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.tabline.tabsel = [ [ s:darker_grey, s:ocre ] ] + +let g:lightline#colorscheme#apprentice#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim new file mode 100644 index 00000000..cb10a258 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/ayu_dark.vim +" Author: danielpeng2 +" License: MIT License +" Last Change: 2020/05/01 19:37:33. +" ============================================================================= + +let s:base0 = '#e6e1cf' +let s:base1 = '#e6e1cf' +let s:base2 = '#3e4b59' +let s:base3 = '#e6e1cf' +let s:base00 = '#14191f' +let s:base01 = '#14191f' +let s:base02 = '#0f1419' +let s:base023 = '#0f1419' +let s:base03 = '#e6b673' +let s:yellow = '#e6b673' +let s:orange = '#ff7733' +let s:red = '#f07178' +let s:magenta = '#ffee99' +let s:blue = '#36a3d9' +let s:cyan = s:blue +let s:green = '#b8cc52' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base1, s:base01 ], [ s:base3, s:base01 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.inactive.right = [ [ s:base1, s:base01 ], [ s:base2, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base02, s:base03 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#ayu_dark#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim new file mode 100644 index 00000000..d1f781aa --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/ayu_light.vim +" Author: christalib +" License: MIT License +" Last Change: 2020/05/01 19:38:21. +" ============================================================================= + +let s:base0 = '#5C6773' +let s:base1 = '#5C6773' +let s:base2 = '#828C99' +let s:base3 = '#5C6773' +let s:base00 = '#FFFFFF' +let s:base01 = '#FFFFFF' +let s:base02 = '#FAFAFA' +let s:base023 = '#FAFAFA' +let s:base03 = '#E6B673' +let s:yellow = '#E6B673' +let s:orange = '#FF7733' +let s:red = '#f07178' +let s:magenta = '#A37ACC' +let s:blue = '#59c2ff' +let s:cyan = s:blue +let s:green = '#86B300' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base1, s:base01 ], [ s:base3, s:base01 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.inactive.right = [ [ s:base1, s:base01 ], [ s:base2, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base02, s:base03 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#ayu_light#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim index 85da9025..fe7506fb 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim @@ -2,24 +2,26 @@ " Filename: autoload/lightline/colorscheme/ayu_mirage.vim " Author: impulse " License: MIT License -" Last Change: 2019/08/11 11:52:20. +" Last Change: 2020/05/01 19:37:21. " ============================================================================= -let s:base0 = [ '#d9d7ce', 244 ] -let s:base1 = [ '#d9d7ce', 247 ] -let s:base2 = [ '#607080', 248 ] -let s:base3 = [ '#d9d7ce', 252 ] -let s:base00 = [ '#272d38', 242 ] -let s:base01 = [ '#272d38', 240 ] -let s:base02 = [ '#212733', 238 ] -let s:base023 = [ '#212733', 236 ] -let s:base03 = [ '#ffc44c', 235 ] -let s:yellow = [ '#ffc44c', 180 ] -let s:orange = [ '#ffae57', 173 ] -let s:red = [ '#f07178', 203 ] -let s:magenta = [ '#d4bfff', 216 ] -let s:blue = [ '#59c2ff', 117 ] + +let s:base0 = '#d9d7ce' +let s:base1 = '#d9d7ce' +let s:base2 = '#607080' +let s:base3 = '#d9d7ce' +let s:base00 = '#272d38' +let s:base01 = '#272d38' +let s:base02 = '#212733' +let s:base023 = '#212733' +let s:base03 = '#ffc44c' +let s:yellow = '#ffc44c' +let s:orange = '#ffae57' +let s:red = '#f07178' +let s:magenta = '#d4bfff' +let s:blue = '#59c2ff' let s:cyan = s:blue -let s:green = [ '#bbe67e', 119 ] +let s:green = '#bbe67e' + let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] let s:p.normal.middle = [ [ s:base2, s:base02 ] ] @@ -36,4 +38,5 @@ let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] let s:p.tabline.right = [ [ s:base2, s:base00 ] ] let s:p.normal.error = [ [ s:base03, s:red ] ] let s:p.normal.warning = [ [ s:base023, s:yellow ] ] -let g:lightline#colorscheme#ayu_mirage#palette = lightline#colorscheme#flatten(s:p) + +let g:lightline#colorscheme#ayu_mirage#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim index 0a7da609..3f9f2265 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/deus.vim " Author: nikersify " License: MIT License -" Last Change: 2018/01/24 13:26:00 +" Last Change: 2020/02/15 20:56:45. " ============================================================================= let s:term_red = 204 @@ -20,13 +20,12 @@ let s:p.normal.left = [ [ '#292c33', '#98c379', s:term_black, s:term_green, 'bol let s:p.normal.right = [ [ '#292c33', '#98c379', s:term_black, s:term_green ], [ '#abb2bf', '#3e4452', s:term_white, s:term_grey ], [ '#98c379', '#292c33', s:term_green, s:term_black ] ] let s:p.inactive.right = [ [ '#292c33', '#61afef', s:term_black, s:term_blue], [ '#abb2bf', '#3e4452', s:term_white, s:term_grey ] ] let s:p.inactive.left = s:p.inactive.right[1:] -" her let s:p.insert.left = [ [ '#292c33', '#61afef', s:term_black, s:term_blue, 'bold' ], [ '#61afef', '#292c33', s:term_blue, s:term_black ] ] let s:p.insert.right = [ [ '#292c33', '#61afef', s:term_black, s:term_blue ], [ '#ABB2BF', '#3E4452', s:term_white, s:term_grey ], [ '#61afef', '#292c33', s:term_blue, s:term_black ] ] let s:p.replace.left = [ [ '#292c33', '#e06c75', s:term_black, s:term_red, 'bold' ], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] -let s:p.replace.right = [ [ '#292c33', '#e06c75', s:term_black, s:term_red, 'bold' ], s:p.normal.right[1], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] +let s:p.replace.right = [ [ '#292c33', '#e06c75', s:term_black, s:term_red ], s:p.normal.right[1], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] let s:p.visual.left = [ [ '#292c33', '#c678dd', s:term_black, s:term_purple, 'bold' ], [ '#c678dd', '#292c33', s:term_purple, s:term_black ] ] -let s:p.visual.right = [ [ '#292c33', '#c678dd', s:term_black, s:term_purple, 'bold' ], s:p.normal.right[1], [ '#c678dd', '#292c33', s:term_purple, s:term_black ] ] +let s:p.visual.right = [ [ '#292c33', '#c678dd', s:term_black, s:term_purple ], s:p.normal.right[1], [ '#c678dd', '#292c33', s:term_purple, s:term_black ] ] let s:p.normal.middle = [ [ '#abb2bf', '#292c33', s:term_white, s:term_black ] ] let s:p.insert.middle = s:p.normal.middle let s:p.replace.middle = s:p.normal.middle diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim index 15b2b35b..b70711d1 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim @@ -2,10 +2,11 @@ " Filename: autoload/lightline/colorscheme/jellybeans.vim " Author: itchyny " License: MIT License -" Last Change: 2013/09/07 12:21:04. +" Last Change: 2022/03/15 23:59:15. " ============================================================================= + let s:base03 = [ '#151513', 233 ] -let s:base02 = [ '#30302c ', 236 ] +let s:base02 = [ '#30302c', 236 ] let s:base01 = [ '#4e4e43', 239 ] let s:base00 = [ '#666656', 242 ] let s:base0 = [ '#808070', 244 ] @@ -30,10 +31,10 @@ let s:p.replace.left = [ [ s:base02, s:red ], [ s:base3, s:base01 ] ] let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] let s:p.normal.middle = [ [ s:base0, s:base02 ] ] let s:p.inactive.middle = [ [ s:base00, s:base02 ] ] -let s:p.tabline.left = [ [ s:base3, s:base00 ] ] -let s:p.tabline.tabsel = [ [ s:base3, s:base02 ] ] -let s:p.tabline.middle = [ [ s:base01, s:base1 ] ] -let s:p.tabline.right = copy(s:p.normal.right) +let s:p.tabline.left = copy(s:p.normal.middle) +let s:p.tabline.tabsel = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = copy(s:p.normal.middle) +let s:p.tabline.right = copy(s:p.tabline.middle) let s:p.normal.error = [ [ s:red, s:base02 ] ] let s:p.normal.warning = [ [ s:yellow, s:base01 ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim index 9d066a1b..ed67adb9 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim @@ -2,9 +2,9 @@ " Filename: autoload/lightline/colorscheme/molokai.vim " Author: challsted " License: MIT License -" Last Change: 2016/11/17 00:27:58. +" Last Change: 2022/03/15 23:58:40. " ============================================================================= -" + let s:black = [ '#232526', 233 ] let s:gray = [ '#808080', 244 ] let s:white = [ '#f8f8f2', 234 ] @@ -16,7 +16,6 @@ let s:red = [ '#ff0000', 160 ] let s:yellow = [ '#e6db74', 229 ] let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} - let s:p.normal.left = [ [ s:black, s:cyan ], [ s:orange, s:black ] ] let s:p.normal.middle = [ [ s:orange, s:black ] ] let s:p.normal.right = [ [ s:pink, s:black ], [ s:black, s:pink ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim index 9d0fba69..b986acf6 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim @@ -2,11 +2,10 @@ " Filename: autoload/lightline/colorscheme/one.vim " Author: Zoltan Dalmadi " License: MIT License -" Last Change: 2019/05/12 20:30:51. +" Last Change: 2019/09/09 22:42:48. " ============================================================================= " Common colors -let s:fg = [ '#abb2bf', 145 ] let s:blue = [ '#61afef', 75 ] let s:green = [ '#98c379', 76 ] let s:purple = [ '#c678dd', 176 ] @@ -18,44 +17,41 @@ let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': if lightline#colorscheme#background() ==# 'light' " Light variant - let s:bg = [ '#fafafa', 255 ] - let s:gray1 = [ '#494b53', 238 ] - let s:gray2 = [ '#f0f0f0', 255 ] - let s:gray3 = [ '#d0d0d0', 250 ] - let s:green = [ '#98c379', 35 ] + let s:fg = [ '#494b53', 238 ] + let s:bg = [ '#fafafa', 255 ] + let s:gray1 = [ '#494b53', 238 ] + let s:gray2 = [ '#f0f0f0', 255 ] + let s:gray3 = [ '#d0d0d0', 250 ] + let s:green = [ '#98c379', 35 ] - let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:gray1, s:gray3 ] ] - let s:p.normal.middle = [ [ s:gray1, s:gray2 ] ] let s:p.inactive.left = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ] let s:p.inactive.middle = [ [ s:gray3, s:gray2 ] ] let s:p.inactive.right = [ [ s:bg, s:gray3 ] ] - let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:gray1, s:gray3 ] ] - let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:gray1, s:gray3 ] ] - let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:gray1, s:gray3 ] ] else " Dark variant - let s:bg = [ '#282c34', 235 ] - let s:gray1 = [ '#5c6370', 241 ] - let s:gray2 = [ '#2c323d', 235 ] - let s:gray3 = [ '#3e4452', 240 ] + let s:fg = [ '#abb2bf', 145 ] + let s:bg = [ '#282c34', 235 ] + let s:gray1 = [ '#5c6370', 241 ] + let s:gray2 = [ '#2c323d', 235 ] + let s:gray3 = [ '#3e4452', 240 ] - let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] - let s:p.normal.middle = [ [ s:fg, s:gray2 ] ] let s:p.inactive.left = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ] let s:p.inactive.middle = [ [ s:gray1, s:gray2 ] ] let s:p.inactive.right = [ [ s:gray1, s:bg ] ] - let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] - let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] - let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] endif " Common +let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.normal.middle = [ [ s:fg, s:gray2 ] ] let s:p.normal.right = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] -let s:p.normal.error = [ [ s:red2, s:bg ] ] +let s:p.normal.error = [ [ s:red2, s:bg ] ] let s:p.normal.warning = [ [ s:yellow, s:bg ] ] let s:p.insert.right = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] let s:p.replace.right = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] let s:p.visual.right = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] let s:p.tabline.left = [ [ s:fg, s:gray3 ] ] let s:p.tabline.tabsel = [ [ s:bg, s:purple, 'bold' ] ] let s:p.tabline.middle = [ [ s:gray3, s:gray2 ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine.vim new file mode 100644 index 00000000..fcea1e53 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine.vim @@ -0,0 +1,58 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/rosepine.vim +" Author: sheruost +" License: MIT License +" Last Change: 2022/05/09 23:27:50. +" ============================================================================= + +" Reference: https://rosepinetheme.com/palette +if lightline#colorscheme#background() ==# 'light' + " Rosé Pine Dawn + let s:base = [ '#faf4ed', 255 ] + let s:surface = [ '#fffaf3', 255 ] + + let s:overlay = [ '#f2e9e1', 254 ] + let s:highlight_m = [ '#dfdad9', 145 ] + let s:muted = [ '#9893a5', 103 ] + let s:subtle = [ '#797593', 102 ] + + let s:iris = [ '#907aa9', 139 ] + let s:pine = [ '#286983', 24 ] + let s:foam = [ '#56949f', 67 ] + let s:rose = [ '#d7827e', 174 ] + let s:love = [ '#b4637a', 132 ] +else + " Rosé Pine + let s:base = [ '#191724', 233 ] + let s:surface = [ '#1f1d2e', 234 ] + + let s:overlay = [ '#26233a', 235 ] + let s:highlight_m = [ '#403d52', 59 ] + let s:muted = [ '#6e6a86', 60 ] + let s:subtle = [ '#908caa', 103 ] + + let s:iris = [ '#c4a7e7', 182 ] + let s:pine = [ '#31748f', 30 ] + let s:foam = [ '#9ccfd8', 152 ] + let s:rose = [ '#ebbcba', 217 ] + let s:love = [ '#eb6f92', 204 ] +endif + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base, s:pine ], [ s:subtle, s:surface ] ] +let s:p.normal.right = [ [ s:overlay, s:subtle ], [ s:muted, s:overlay ], [ s:highlight_m, s:surface ] ] +let s:p.inactive.right = [ [ s:base, s:surface ], [ s:overlay, s:base ] ] +let s:p.inactive.left = [ [ s:overlay, s:base ], [ s:surface, s:base ] ] +let s:p.insert.left = [ [ s:base, s:foam ], [ s:subtle, s:surface ] ] +let s:p.replace.left = [ [ s:base, s:love ], [ s:subtle, s:surface ] ] +let s:p.visual.left = [ [ s:base, s:iris ], [ s:subtle, s:surface ] ] +let s:p.normal.middle = [ [ s:overlay, s:base ] ] +let s:p.inactive.middle = [ [ s:surface, s:base ] ] +let s:p.tabline.left = [ [ s:subtle, s:base ] ] +let s:p.tabline.tabsel = [ [ s:pine, s:base ] ] +let s:p.tabline.middle = [ [ s:surface, s:base ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:love, s:base ] ] +let s:p.normal.warning = [ [ s:rose, s:surface ] ] + +let g:lightline#colorscheme#rosepine#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine_moon.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine_moon.vim new file mode 100644 index 00000000..08bfc56e --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine_moon.vim @@ -0,0 +1,41 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/rosepine_moon.vim +" Author: lsculv (based on work by sheruost) +" License: MIT License +" Last Change: 2022/11/18 11:30:19. +" ============================================================================= + +" Reference: https://rosepinetheme.com/palette +" Rosé Pine Moon +let s:base = [ '#232136', 233 ] +let s:surface = [ '#2a273f', 234 ] + +let s:overlay = [ '#393552', 235 ] +let s:highlight_m = [ '#44415a', 59 ] +let s:muted = [ '#6e6a86', 60 ] +let s:subtle = [ '#908caa', 103 ] + +let s:iris = [ '#c4a7e7', 182 ] +let s:pine = [ '#3e8fb0', 30 ] +let s:foam = [ '#9ccfd8', 152 ] +let s:rose = [ '#ea9a97', 217 ] +let s:love = [ '#eb6f92', 204 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base, s:pine ], [ s:subtle, s:surface ] ] +let s:p.normal.right = [ [ s:overlay, s:subtle ], [ s:muted, s:overlay ], [ s:highlight_m, s:surface ] ] +let s:p.inactive.right = [ [ s:base, s:surface ], [ s:overlay, s:base ] ] +let s:p.inactive.left = [ [ s:overlay, s:base ], [ s:surface, s:base ] ] +let s:p.insert.left = [ [ s:base, s:foam ], [ s:subtle, s:surface ] ] +let s:p.replace.left = [ [ s:base, s:love ], [ s:subtle, s:surface ] ] +let s:p.visual.left = [ [ s:base, s:iris ], [ s:subtle, s:surface ] ] +let s:p.normal.middle = [ [ s:overlay, s:base ] ] +let s:p.inactive.middle = [ [ s:surface, s:base ] ] +let s:p.tabline.left = [ [ s:subtle, s:base ] ] +let s:p.tabline.tabsel = [ [ s:pine, s:base ] ] +let s:p.tabline.middle = [ [ s:surface, s:base ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:love, s:base ] ] +let s:p.normal.warning = [ [ s:rose, s:surface ] ] + +let g:lightline#colorscheme#rosepine_moon#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim new file mode 100644 index 00000000..dc95139b --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/selenized_black.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/02 16:56:50. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-black +let s:bg_1 = ['#252525', 0] +let s:bg_2 = ['#3b3b3b', 8] +let s:dim_0 = ['#777777', 7] +let s:red = ['#ed4a46', 1] +let s:green = ['#70b433', 2] +let s:yellow = ['#dbb32d', 3] +let s:blue = ['#368aeb', 4] +let s:magenta = ['#eb6eb7', 5] +let s:cyan = ['#3fc5b7', 6] +let s:brred = ['#ff5e56', 9] +let s:brgreen = ['#83c746', 10] +let s:bryellow = ['#efc541', 11] +let s:brblue = ['#4f9cfe', 12] +let s:brmagenta = ['#ff81ca', 13] +let s:brcyan = ['#56d8c9', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_black#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim index 585b948b..c3238384 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim @@ -2,49 +2,48 @@ " Filename: autoload/lightline/colorscheme/selenized_dark.vim " Author: Charles Hall " License: MIT License -" Last Change: 2019/07/22 11:05:34. +" Last Change: 2020/05/02 16:53:17. " ============================================================================= " https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-dark -let s:black = [ "#184956", 0 ] -let s:red = [ "#fa5750", 1 ] -let s:green = [ "#75b938", 2 ] -let s:yellow = [ "#dbb32d", 3 ] -let s:blue = [ "#4695f7", 4 ] -let s:magenta = [ "#f275be", 5 ] -let s:cyan = [ "#41c7b9", 6 ] -let s:white = [ "#72898f", 7 ] -let s:brblack = [ "#2d5b69", 8 ] -let s:brred = [ "#ff665c", 9 ] -let s:brgreen = [ "#84c747", 10 ] -let s:bryellow = [ "#ebc13d", 11 ] -let s:brblue = [ "#58a3ff", 12 ] -let s:brmagenta = [ "#ff84cd", 13 ] -let s:brcyan = [ "#53d6c7", 14 ] -let s:brwhite = [ "#cad8d9", 15 ] +let s:bg_1 = ['#184956', 0] +let s:bg_2 = ['#2d5b69', 8] +let s:dim_0 = ['#72898f', 7] +let s:red = ['#fa5750', 1] +let s:green = ['#75b938', 2] +let s:yellow = ['#dbb32d', 3] +let s:blue = ['#4695f7', 4] +let s:magenta = ['#f275be', 5] +let s:cyan = ['#41c7b9', 6] +let s:brred = ['#ff665c', 9] +let s:brgreen = ['#84c747', 10] +let s:bryellow = ['#ebc13d', 11] +let s:brblue = ['#58a3ff', 12] +let s:brmagenta = ['#ff84cd', 13] +let s:brcyan = ['#53d6c7', 14] let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -let s:p.normal.right = [[ s:black, s:blue ],[ s:cyan, s:brblack ],[ s:white, s:black ]] -let s:p.normal.left = [[ s:black, s:blue ],[ s:cyan, s:brblack ]] -let s:p.normal.middle = [[ s:black, s:black ]] -let s:p.normal.error = [[ s:black, s:red ]] -let s:p.normal.warning = [[ s:black, s:yellow ]] +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] -let s:p.insert.right = [[ s:black, s:green ],[ s:cyan, s:brblack ],[ s:white, s:black ]] -let s:p.insert.left = [[ s:black, s:green ],[ s:cyan, s:brblack ]] +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] -let s:p.visual.right = [[ s:black, s:magenta ],[ s:cyan, s:brblack ],[ s:white, s:black ]] -let s:p.visual.left = [[ s:black, s:magenta ],[ s:cyan, s:brblack ]] +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] -let s:p.inactive.left = [[ s:brblue, s:brblack ],[ s:cyan, s:brblack ]] -let s:p.inactive.right = [[ s:brblue, s:brblack ],[ s:cyan, s:brblack ]] +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] -let s:p.replace.right = [[ s:black, s:red ],[ s:cyan, s:brblack ],[ s:white, s:black ]] -let s:p.replace.left = [[ s:black, s:red ],[ s:cyan, s:brblack ]] +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] -let s:p.tabline.right = [[ s:black, s:red ]] -let s:p.tabline.left = [[ s:cyan, s:brblack ]] -let s:p.tabline.tabsel = [[ s:black, s:blue ]] +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] let g:lightline#colorscheme#selenized_dark#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim new file mode 100644 index 00000000..979149d2 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/selenized_light.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/02 16:58:00. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-light +let s:bg_1 = ['#ece3cc', 0] +let s:bg_2 = ['#d5cdb6', 8] +let s:dim_0 = ['#909995', 7] +let s:red = ['#d2212d', 1] +let s:green = ['#489100', 2] +let s:yellow = ['#ad8900', 3] +let s:blue = ['#0072d4', 4] +let s:magenta = ['#ca4898', 5] +let s:cyan = ['#009c8f', 6] +let s:brred = ['#cc1729', 9] +let s:brgreen = ['#428b00', 10] +let s:bryellow = ['#a78300', 11] +let s:brblue = ['#006dce', 12] +let s:brmagenta = ['#c44392', 13] +let s:brcyan = ['#00978a', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_light#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim new file mode 100644 index 00000000..9da3a4e3 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/whiteline/colorscheme/selenized_white.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/03 19:34:07. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-white +let s:bg_1 = ['#ebebeb', 0] +let s:bg_2 = ['#cdcdcd', 8] +let s:dim_0 = ['#878787', 7] +let s:red = ['#d6000c', 1] +let s:green = ['#1d9700', 2] +let s:yellow = ['#c49700', 3] +let s:blue = ['#0064e4', 4] +let s:magenta = ['#dd0f9d', 5] +let s:cyan = ['#00ad9c', 6] +let s:brred = ['#bf0000', 9] +let s:brgreen = ['#008400', 10] +let s:bryellow = ['#af8500', 11] +let s:brblue = ['#0054cf', 12] +let s:brmagenta = ['#c7008b', 13] +let s:brcyan = ['#009a8a', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_white#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim index ca2d5a09..fc2f84d9 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim @@ -2,10 +2,11 @@ " Filename: autoload/lightline/colorscheme/seoul256.vim " Author: atweiden " License: MIT License -" Last Change: 2015/11/02 08:23:27. +" Last Change: 2022/03/15 23:58:59. " ============================================================================= + let s:base03 = [ '#151513', 233 ] -let s:base02 = [ '#30302c ', 236 ] +let s:base02 = [ '#30302c', 236 ] let s:base01 = [ '#4e4e43', 239 ] let s:base00 = [ '#666656', 242 ] let s:base0 = [ '#808070', 244 ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim new file mode 100644 index 00000000..db2d3758 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim @@ -0,0 +1,43 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/simpleblack.vim +" Author: lucasprag +" License: MIT License +" Last Change: 2022/03/15 23:58:35. +" ============================================================================= + +let s:black = [ '#000000', '0' ] +let s:black2 = [ '#121212', '233' ] + +let s:gray = [ '#262626', '235' ] +let s:gray2 = [ '#3a3a3a', '237' ] +let s:gray3 = [ '#4e4e4e', '239' ] +let s:gray4 = [ '#626262', '241' ] + +let s:violet = [ '#cf73e6', '170' ] + +let s:blue = [ '#5f87af', '67' ] +let s:blue2 = [ '#91aadf', '110' ] + +let s:green = [ '#57ba37', '71' ] +let s:gold = [ '#f0d50c', '220' ] +let s:red = [ '#d70000', '160' ] +let s:none = [ 'NONE', 'NONE' ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:black, s:blue ], [ s:gray4, s:black2 ] ] +let s:p.normal.right = [ [ s:gray, s:gray4 ], [ s:gray3, s:gray ], [ s:gray2, s:black2 ] ] +let s:p.inactive.right = [ [ s:black, s:black2 ], [ s:gray, s:black ] ] +let s:p.inactive.left = [ [ s:gray, s:black ], [ s:black2, s:black ] ] +let s:p.insert.left = [ [ s:black, s:green ], [ s:gray4, s:black2 ] ] +let s:p.replace.left = [ [ s:black, s:red ], [ s:gray4, s:black2 ] ] +let s:p.visual.left = [ [ s:black, s:violet ], [ s:gray4, s:black2 ] ] +let s:p.normal.middle = [ [ s:gray, s:black ] ] +let s:p.inactive.middle = [ [ s:black2, s:black ] ] +let s:p.tabline.left = [ [ s:gray4, s:black ] ] +let s:p.tabline.tabsel = [ [ s:blue, s:black ] ] +let s:p.tabline.middle = [ [ s:black2, s:black ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:red, s:black ] ] +let s:p.normal.warning = [ [ s:gold, s:black2 ] ] + +let g:lightline#colorscheme#simpleblack#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim index d6ee9c6b..53788311 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/solarized.vim " Author: itchyny " License: MIT License -" Last Change: 2017/11/25 11:13:46. +" Last Change: 2020/04/06 19:22:53. " ============================================================================= let s:cuicolors = { @@ -73,7 +73,7 @@ let s:p.inactive.middle = [ [ s:base01, s:base02 ] ] let s:p.tabline.left = [ [ s:base03, s:base00 ] ] let s:p.tabline.tabsel = [ [ s:base03, s:base1 ] ] let s:p.tabline.middle = [ [ s:base0, s:base02 ] ] -let s:p.tabline.right = copy(s:p.normal.right) +let s:p.tabline.right = copy(s:p.tabline.left) let s:p.normal.error = [ [ s:base03, s:red ] ] let s:p.normal.warning = [ [ s:base03, s:yellow ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim index f1c7e1dd..49eadc22 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim @@ -4,8 +4,9 @@ " License: MIT License " Last Change: 2018/05/19 " ============================================================================= + let s:base03 = [ '#151513', 233 ] -let s:base02 = [ '#30302c ', 236 ] +let s:base02 = [ '#30302c', 236 ] let s:base01 = [ '#4e4e43', 239 ] let s:base00 = [ '#666656', 242 ] let s:base0 = [ '#808070', 244 ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim index 96192476..9d0bdd59 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim @@ -2,11 +2,12 @@ " Filename: autoload/lightline/colorscheme/wombat.vim " Author: itchyny " License: MIT License -" Last Change: 2015/11/30 08:37:43. +" Last Change: 2022/03/15 23:59:09. " ============================================================================= + let s:base03 = [ '#242424', 235 ] -let s:base023 = [ '#353535 ', 236 ] -let s:base02 = [ '#444444 ', 238 ] +let s:base023 = [ '#353535', 236 ] +let s:base02 = [ '#444444', 238 ] let s:base01 = [ '#585858', 240 ] let s:base00 = [ '#666666', 242 ] let s:base0 = [ '#808080', 244 ] @@ -20,6 +21,7 @@ let s:magenta = [ '#f2c68a', 216 ] let s:blue = [ '#8ac6f2', 117 ] let s:cyan = s:blue let s:green = [ '#95e454', 119 ] + let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim b/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim index 82617b20..6cdddd8d 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colortable.vim " Author: itchyny " License: MIT License -" Last Change: 2015/03/29 06:21:39. +" Last Change: 2020/06/19 11:07:13. " ============================================================================= let s:save_cpo = &cpo @@ -38,5 +38,15 @@ function! lightline#colortable#gui2cui(rgb, fallback) abort return rgb[0] + rgb[1] + rgb[2] endfunction +function! lightline#colortable#gui2cui_palette(palette) abort + for u in values(a:palette) + for v in values(u) + for w in v + let [w[2], w[3]] = [lightline#colortable#gui2cui(w[0], w[2]), lightline#colortable#gui2cui(w[1], w[3])] + endfor + endfor + endfor +endfunction + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/sources_non_forked/lightline.vim/colorscheme.md b/sources_non_forked/lightline.vim/colorscheme.md new file mode 100644 index 00000000..0e7df04d --- /dev/null +++ b/sources_non_forked/lightline.vim/colorscheme.md @@ -0,0 +1,157 @@ +# Available Colorschemes + +### powerline (default) + +![lightline.vim - powerline](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/powerline.png) + +### powerlineish + +![lightline.vim - powerlineish](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/powerlineish.png) + +### wombat + +![lightline.vim - wombat](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/wombat.png) + +### OldHope + +![lightline.vim - OldHope](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/OldHope.png) + +### PaperColor (`background=dark`) + +![lightline.vim - PaperColor_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) + +### PaperColor (`background=light`) + +![lightline.vim - PaperColor_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) + +### Tomorrow + +![lightline.vim - Tomorrow](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow.png) + +### Tomorrow_Night + +![lightline.vim - Tomorrow_Night](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night.png) + +### Tomorrow_Night_Blue + +![lightline.vim_- Tomorrow_Night_Blue](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Blue.png) + +### Tomorrow_Night_Bright + +![lightline.vim - Tomorrow_Night_Bright](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Bright.png) + +### Tomorrow_Night_Eighties + +![lightline.vim - Tomorrow_Night_Eighties](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Eighties.png) + +### ayu_mirage + +![lightline.vim - ayu_mirage](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_mirage.png) + +### ayu_light + +![lightline.vim - ayu_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_light.png) + +### ayu_dark + +![lightline.vim - ayu_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_dark.png) + +### darcula + +![lightline.vim - darcula](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/darcula.png) + +### deus + +![lightline.vim - deus](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/deus.png) + +### jellybeans + +![lightline.vim - jellybeans](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/jellybeans.png) + +### selenized_dark + +![lightline.vim - selenized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_dark.png) + +### selenized_black + +![lightline.vim - selenized_black](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_black.png) + +### selenized_light + +![lightline.vim - selenized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_light.png) + +### selenized_white + +![lightline.vim - selenized_white](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_white.png) + +### solarized (`background=dark`) + +![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) + +### solarized (`background=light`) + +![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) + +### materia + +![lightline.vim - materia](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/materia.png) + +### material + +![lightline.vim - material](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/material.png) + +### molokai + +![lightline.vim - molokai](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/molokai.png) + +### nord + +![lightline.vim - nord](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/nord.png) + +### seoul256 + +![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256.png) + +### one (`background=dark`) + +![lightline.vim - one_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) + +### one (`background=light`) + +![lightline.vim - one_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) + +### rosepine (`background=dark`) + +![lightline.vim - rosepine_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/rosepine_dark.png) + +### rosepine (`background=light`) + +![lightline.vim - rosepine_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/rosepine_light.png) + +### rosepine_moon + +![lightline.vim - rosepine_moon](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/rosepine_moon.png) + +### srcery_drk + +![lightline.vim - srcery_drk](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/srcery_drk.png) + +### simpleblack + +![lightline.vim - simpleblack](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/simpleblack.png) + +### apprentice + +![lightline.vim - apprentice](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/apprentice.png) + +### landscape + +![lightline.vim - landscape](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape.png) + +### 16color (`background=dark`) + +![lightline.vim - 16color_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_dark.png) + +### 16color (`background=light`) + +![lightline.vim - 16color_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_light.png) diff --git a/sources_non_forked/lightline.vim/doc/lightline.txt b/sources_non_forked/lightline.vim/doc/lightline.txt index cf64523b..c081cae9 100644 --- a/sources_non_forked/lightline.vim/doc/lightline.txt +++ b/sources_non_forked/lightline.vim/doc/lightline.txt @@ -1,23 +1,19 @@ *lightline.txt* A light and configurable statusline/tabline for Vim -Version: 0.1 Author: itchyny (https://github.com/itchyny) License: MIT License Repository: https://github.com/itchyny/lightline.vim -Last Change: 2019/08/14 10:46:55. +Last Change: 2023/11/21 08:10:00. CONTENTS *lightline-contents* Introduction |lightline-introduction| Spirit |lightline-spirit| Option |lightline-option| -Font |lightline-font| Function |lightline-function| Component Expansion |lightline-component-expansion| Colorscheme |lightline-colorscheme| Examples |lightline-examples| -Nice Examples |lightline-nice-examples| -Powerful Example |lightline-powerful-example| Troubleshooting |lightline-troubleshooting| ============================================================================== @@ -107,7 +103,7 @@ OPTIONS *lightline-option* \ 'percent': '%3p%%', \ 'percentwin': '%P', \ 'spell': '%{&spell?&spelllang:""}', - \ 'lineinfo': '%3l:%-2v', + \ 'lineinfo': '%3l:%-2c', \ 'line': '%l', \ 'column': '%c', \ 'close': '%999X X ', @@ -148,10 +144,14 @@ OPTIONS *lightline-option* \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] \ }, \ 'component_function': { - \ 'gitbranch': 'fugitive#head' + \ 'gitbranch': 'FugitiveHead' \ }, \ } < + If you simply want to display the branch name instead of + installing a plugin for full git integration, you can use + vim-gitbranch (https://github.com/itchyny/vim-gitbranch). + g:lightline.component_function_visible_condition *g:lightline.component_function_visible_condition* A dictionary to store the visible conditions of the function @@ -227,11 +227,13 @@ OPTIONS *lightline-option* g:lightline.colorscheme *g:lightline.colorscheme* The colorscheme for lightline.vim. Currently, wombat, solarized, powerline, powerlineish, - jellybeans, molokai, seoul256, darcula, selenized_dark, + jellybeans, molokai, seoul256, darcula, + selenized_dark, selenized_black, selenized_light, selenized_white, Tomorrow, Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Bright, Tomorrow_Night_Eighties, PaperColor, landscape, one, materia, material, OldHope, nord, deus, - srcery_drk, ayu_mirage and 16color are available. + simpleblack, srcery_drk, ayu_mirage, ayu_light, ayu_dark, + apprentice, rosepine, rosepine_moon, and 16color are available. The default value is: > let g:lightline.colorscheme = 'default' @@ -289,78 +291,6 @@ OPTIONS *lightline-option* \ } < ============================================================================== -FONT *lightline-font* -You can use the patched font you used for |vim-powerline| and |powerline|. - -The patched fonts for |powerline| are available at -https://github.com/Lokaltog/powerline-fonts - -A tutorial to create a patched font for |vim-powerline| is available at -https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher - -If you have installed the patched font for |powerline|, following settings look -nice. -> - let g:lightline = { - \ 'component': { - \ 'lineinfo': ' %3l:%-2v', - \ }, - \ 'component_function': { - \ 'readonly': 'LightlineReadonly', - \ 'fugitive': 'LightlineFugitive' - \ }, - \ 'separator': { 'left': '', 'right': '' }, - \ 'subseparator': { 'left': '', 'right': '' } - \ } - function! LightlineReadonly() - return &readonly ? '' : '' - endfunction - function! LightlineFugitive() - if exists('*fugitive#head') - let branch = fugitive#head() - return branch !=# '' ? ''.branch : '' - endif - return '' - endfunction -< -If you have installed the patched font for |vim-powerline|, following settings -look nice. -> - let g:lightline = { - \ 'component': { - \ 'lineinfo': '⭡ %3l:%-2v', - \ }, - \ 'component_function': { - \ 'readonly': 'LightlineReadonly', - \ 'fugitive': 'LightlineFugitive' - \ }, - \ 'separator': { 'left': '⮀', 'right': '⮂' }, - \ 'subseparator': { 'left': '⮁', 'right': '⮃' } - \ } - function! LightlineReadonly() - return &readonly ? '⭤' : '' - endfunction - function! LightlineFugitive() - if exists('*fugitive#head') - let branch = fugitive#head() - return branch !=# '' ? '⭠ '.branch : '' - endif - return '' - endfunction -< -If the statusline does not correctly show the special characters, use the -unicode numbers. For |powerline| font users: -> - \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, - \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" } -< -For |vim-powerline| font users: -> - \ 'separator': { 'left': "\u2b80", 'right': "\u2b82" }, - \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" } -< -See |lightline-problem-9| for more detail. -============================================================================== FUNCTION *lightline-function* Exposed functions for lightline.vim. @@ -376,9 +306,6 @@ Exposed functions for lightline.vim. lightline#update() *lightline#update()* Updates all the statuslines of existing windows. - lightline#update_once() *lightline#update_once()* - Updates the statuslines only once. - lightline#enable() *lightline#enable()* Enables |lightline|. @@ -660,34 +587,27 @@ In order to change the colorscheme: \ 'colorscheme': 'wombat', \ } < - In order to define your own component: > let g:lightline = { - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'myfilename' ] ] - \ }, \ 'component_function': { - \ 'myfilename': 'LightlineFilename', - \ 'myreadonly': 'LightlineReadonly', - \ 'mymodified': 'LightlineModified', + \ 'filename': 'LightlineFilename', + \ 'readonly': 'LightlineReadonly', + \ 'modified': 'LightlineModified', \ } \ } function! LightlineFilename() - return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') . - \ (&ft == 'vimfiler' ? vimfiler#get_status_string() : - \ &ft == 'unite' ? unite#get_status_string() : - \ '' != expand('%:t') ? expand('%:t') : '[No Name]') . - \ ('' != LightlineModified() ? ' ' . LightlineModified() : '') + return &ft ==# 'vimfiler' ? vimfiler#get_status_string() : + \ &ft ==# 'unite' ? unite#get_status_string() : + \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]' endfunction function! LightlineReadonly() - return &ft !~? 'help' && &readonly ? 'RO' : '' + return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : '' endfunction function! LightlineModified() return &modifiable && &modified ? '+' : '' endfunction < - Separators settings: > let g:lightline = { @@ -695,30 +615,9 @@ Separators settings: \ 'subseparator': { 'left': '|', 'right': '|' } \ } < - -For |powerline| font users: +An example for fugitive, vimfiler and unite users. > let g:lightline = { - \ 'separator': { 'left': '', 'right': '' }, - \ 'subseparator': { 'left': '', 'right': '' } - \ } -< - -For |vim-powerline| font users: -> - let g:lightline = { - \ 'separator': { 'left': '⮀', 'right': '⮂' }, - \ 'subseparator': { 'left': '⮁', 'right': '⮃' } - \ } -< - ------------------------------------------------------------------------------- -NICE EXAMPLES *lightline-nice-examples* - -A nice example for non-patched font users. -> - let g:lightline = { - \ 'colorscheme': 'wombat', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] \ }, @@ -728,70 +627,28 @@ A nice example for non-patched font users. \ } \ } function! LightlineModified() - return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-' + return &ft =~# 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-' endfunction function! LightlineReadonly() return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : '' endfunction function! LightlineFilename() - return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') . - \ (&ft == 'vimfiler' ? vimfiler#get_status_string() : - \ &ft == 'unite' ? unite#get_status_string() : - \ &ft == 'vimshell' ? vimshell#get_status_string() : - \ '' != expand('%:t') ? expand('%:t') : '[No Name]') . - \ ('' != LightlineModified() ? ' ' . LightlineModified() : '') + return (LightlineReadonly() !=# '' ? LightlineReadonly() . ' ' : '') . + \ (&ft ==# 'vimfiler' ? vimfiler#get_status_string() : + \ &ft ==# 'unite' ? unite#get_status_string() : + \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]') . + \ (LightlineModified() !=# '' ? ' ' . LightlineModified() : '') endfunction function! LightlineFugitive() - if &ft !~? 'vimfiler' && exists('*fugitive#head') - return fugitive#head() + if exists('*FugitiveHead') + return FugitiveHead() endif return '' endfunction < -A nice example for |vim-powerline| font users: +For users of lots of plugins: > let g:lightline = { - \ 'colorscheme': 'wombat', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] - \ }, - \ 'component_function': { - \ 'fugitive': 'LightlineFugitive', - \ 'filename': 'LightlineFilename' - \ }, - \ 'separator': { 'left': '⮀', 'right': '⮂' }, - \ 'subseparator': { 'left': '⮁', 'right': '⮃' } - \ } - function! LightlineModified() - return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-' - endfunction - function! LightlineReadonly() - return &ft !~? 'help\|vimfiler' && &readonly ? '⭤' : '' - endfunction - function! LightlineFilename() - return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') . - \ (&ft == 'vimfiler' ? vimfiler#get_status_string() : - \ &ft == 'unite' ? unite#get_status_string() : - \ &ft == 'vimshell' ? vimshell#get_status_string() : - \ '' != expand('%:t') ? expand('%:t') : '[No Name]') . - \ ('' != LightlineModified() ? ' ' . LightlineModified() : '') - endfunction - function! LightlineFugitive() - if &ft !~? 'vimfiler' && exists('*fugitive#head') - let branch = fugitive#head() - return branch !=# '' ? '⭠ '.branch : '' - endif - return '' - endfunction -< - ------------------------------------------------------------------------------- -POWERFUL EXAMPLE *lightline-powerful-example* - -For users who uses lots of plugins: -> - let g:lightline = { - \ 'colorscheme': 'wombat', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark'] ], \ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ] @@ -815,7 +672,7 @@ For users who uses lots of plugins: \ } function! LightlineModified() - return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-' + return &ft ==# 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-' endfunction function! LightlineReadonly() @@ -824,22 +681,21 @@ For users who uses lots of plugins: function! LightlineFilename() let fname = expand('%:t') - return fname == 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item : - \ fname == '__Tagbar__' ? g:lightline.fname : - \ fname =~ '__Gundo\|NERD_tree' ? '' : - \ &ft == 'vimfiler' ? vimfiler#get_status_string() : - \ &ft == 'unite' ? unite#get_status_string() : - \ &ft == 'vimshell' ? vimshell#get_status_string() : - \ ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') . - \ ('' != fname ? fname : '[No Name]') . - \ ('' != LightlineModified() ? ' ' . LightlineModified() : '') + return fname ==# 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item : + \ fname =~# '^__Tagbar__\|__Gundo\|NERD_tree' ? '' : + \ &ft ==# 'vimfiler' ? vimfiler#get_status_string() : + \ &ft ==# 'unite' ? unite#get_status_string() : + \ &ft ==# 'vimshell' ? vimshell#get_status_string() : + \ (LightlineReadonly() !=# '' ? LightlineReadonly() . ' ' : '') . + \ (fname !=# '' ? fname : '[No Name]') . + \ (LightlineModified() !=# '' ? ' ' . LightlineModified() : '') endfunction function! LightlineFugitive() try - if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head') + if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*FugitiveHead') let mark = '' " edit here for cool mark - let branch = fugitive#head() + let branch = FugitiveHead() return branch !=# '' ? mark.branch : '' endif catch @@ -861,19 +717,19 @@ For users who uses lots of plugins: function! LightlineMode() let fname = expand('%:t') - return fname == '__Tagbar__' ? 'Tagbar' : - \ fname == 'ControlP' ? 'CtrlP' : - \ fname == '__Gundo__' ? 'Gundo' : - \ fname == '__Gundo_Preview__' ? 'Gundo Preview' : - \ fname =~ 'NERD_tree' ? 'NERDTree' : - \ &ft == 'unite' ? 'Unite' : - \ &ft == 'vimfiler' ? 'VimFiler' : - \ &ft == 'vimshell' ? 'VimShell' : + return fname =~# '^__Tagbar__' ? 'Tagbar' : + \ fname ==# 'ControlP' ? 'CtrlP' : + \ fname ==# '__Gundo__' ? 'Gundo' : + \ fname ==# '__Gundo_Preview__' ? 'Gundo Preview' : + \ fname =~# 'NERD_tree' ? 'NERDTree' : + \ &ft ==# 'unite' ? 'Unite' : + \ &ft ==# 'vimfiler' ? 'VimFiler' : + \ &ft ==# 'vimshell' ? 'VimShell' : \ winwidth(0) > 60 ? lightline#mode() : '' endfunction function! CtrlPMark() - if expand('%:t') =~ 'ControlP' && has_key(g:lightline, 'ctrlp_item') + if expand('%:t') ==# 'ControlP' && has_key(g:lightline, 'ctrlp_item') call lightline#link('iR'[g:lightline.ctrlp_regex]) return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item \ , g:lightline.ctrlp_next], 0) @@ -902,7 +758,6 @@ For users who uses lots of plugins: let g:tagbar_status_func = 'TagbarStatusFunc' function! TagbarStatusFunc(current, sort, fname, ...) abort - let g:lightline.fname = a:fname return lightline#statusline(0) endfunction @@ -935,17 +790,7 @@ Problem 5: |lightline-problem-5| The statusline does not seem to be correctly colored. Problem 6: |lightline-problem-6| - How to install a patched font. - -Problem 7: |lightline-problem-7| - Right triangles do not stick to the right components with the - patched font. - -Problem 8: |lightline-problem-8| - Triangles do not appear. Triangles look weird. - -Problem 9: |lightline-problem-9| - Where can I find the list of all the cool characters for patched fonts? + How to use a powerline font and the triangles for separators. Problem 10: |lightline-problem-10| Cool statusline disappears in |unite|, |vimfiler| and |vimshell| @@ -984,20 +829,17 @@ Problem 17: |lightline-problem-17| Problem 1: *lightline-problem-1* How to install this plugin. - If you are to install this plugin manually: - - 1. Put all the files under $VIM. - - If you are to install this plugin using |vim-pathogen|: - - 1. Install this plugin with the following command. + If you install this plugin using Vim packages: +> + git clone https://github.com/itchyny/lightline.vim \ + ~/.vim/pack/plugins/start/lightline +< + If you install this plugin using |vim-pathogen|: > git clone https://github.com/itchyny/lightline.vim \ ~/.vim/bundle/lightline.vim < - 2. Generate help tags with |:Helptags|. - - If you are to install this plugin using |Vundle|: + If you install this plugin using |Vundle|: 1. Add the following configuration to your .vimrc(_vimrc). @@ -1006,7 +848,7 @@ Problem 1: *lightline-problem-1* < 2. Install with |:PluginInstall|. - If you are to install this plugin using |NeoBundle|: + If you install this plugin using |NeoBundle|: 1. Add the following configuration to your .vimrc(_vimrc). @@ -1015,7 +857,7 @@ Problem 1: *lightline-problem-1* < 2. Install with |:NeoBundleInstall|. - If you are to install this plugin using |vim-plug|: + If you install this plugin using |vim-plug|: 1. Add the following configuration to your .vimrc(_vimrc). @@ -1024,51 +866,76 @@ Problem 1: *lightline-problem-1* < 2. Install with |:PlugInstall|. + If you install this plugin using |dein|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + call dein#add('itchyny/lightline.vim') +< + 2. Install with :call |dein#install()|. + Problem 2: *lightline-problem-2* How to update this plugin. - If you have installed this plugin manually: + If you installed this plugin using Vim packages: +> + git -C ~/.vim/pack/plugins/start/lightline pull +< + If you installed this plugin using |vim-pathogen|: +> + git -C ~/.vim/bundle/lightline.vim pull +< + If you installed this plugin using |Vundle|: - 1. Access https://github.com/itchyny/lightline.vim . - 2. Download the latest scripts. - 3. Place the scripts as written in Problem 1. + Execute |:PluginUpdate|. - If you have installed this plugin using Vundle: + If you installed this plugin using |NeoBundle|: - 1. Execute |:PluginUpdate|. + Execute |:NeoBundleUpdate|. - If you have installed this plugin using NeoBundle: + If you installed this plugin using |vim-plug|: - 1. Execute |:NeoBundleUpdate|. + Execute |:PlugUpdate|. - If you have installed this plugin using vim-plug: + If you installed this plugin using |dein|: - 1. Execute |:PlugUpdate|. + Execute :call |dein#update()|. Problem 3: *lightline-problem-3* How to uninstall this plugin. - If you have installed this plugin manually: + If you installed this plugin using Vim packages: +> + rm -rf ~/.vim/pack/plugins/start/lightline +< + If you installed this plugin using |vim-pathogen|: +> + rm -rf ~/.vim/bundle/lightline.vim +< + If you have installed this plugin using |Vundle|: - 1. Remove all the lightline.*s under $VIM. + 1. Remove `Plugin 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Execute |:PluginClean|. - If you have installed this plugin using Vundle: + If you installed this plugin using |NeoBundle|: - 1. Remove the :Plugin 'itchyny/lightline.vim' - configuration from your .vimrc(_vimrc). - 2. Update with |:PluginClean|. + 1. Remove `NeoBundle 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Remove the plugin directory. - If you have installed this plugin using NeoBundle: + If you installed this plugin using |vim-plug|: - 1. Remove the :NeoBundle 'itchyny/lightline.vim' - configuration from your .vimrc(_vimrc). - 2. Update with |:NeoBundleClean|. + 1. Remove `Plug 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Execute |:PlugClean|. - If you have installed this plugin using vim-plug: + If you installed this plugin using |dein|: - 1. Remove the :Plug 'itchyny/lightline.vim' - configuration from your .vimrc(_vimrc). - 2. Update with |:PlugClean|. + 1. Remove `call dein#add('itchyny/lightline.vim')` + from your .vimrc(_vimrc). + 2. Remove the plugin directory. Problem 4: *lightline-problem-4* Cool statuslines appear only on |:vsp|. @@ -1093,74 +960,25 @@ Problem 5: *lightline-problem-5* to your .vimrc(_vimrc). Problem 6: *lightline-problem-6* - How to install a patched font. + How to use a powerline font and the triangles for separators. - There are two kinds of patched fonts: + Using a patched font is not recommended due to less + portability. Also the original powerline fonts project is + not actively maintained (https://github.com/powerline/fonts). + However, there are alternatives which offer both patching of + local fonts as well as downloads of already patched fonts, + e.g. Nerd Fonts (https://github.com/ryanoasis/nerd-fonts). - + The patched fonts for |vim-powerline| - (https://github.com/Lokaltog/vim-powerline): - follow the guide https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher - + The patched fonts for |powerline| - (https://github.com/Lokaltog/powerline): - download from https://github.com/Lokaltog/powerline-fonts - -Problem 7: *lightline-problem-7* - Right triangles do not stick to the right components with patched - font. - - Remove the following setting from your .vimrc(_vimrc). -> - set ambiwidth=double -< - If you want to keep this setting, try the patched font for - |vim-powerline|. - -Problem 8: *lightline-problem-8* - Triangles do not appear. Triangles look weird. - - If the triangles do not appear (but you get some spaces or - weird characters like or ¿), firstly try adding -> - scriptencoding utf-8 - set encoding=utf-8 -< - to the head of your .vimrc(_vimrc). Still you have weird - characters, use the unicode numbers. For |powerline| font - users: + If you still want to use a patched font, you can configure > \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, - \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" } + \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }, < - For |vim-powerline| font users: + or > \ 'separator': { 'left': "\u2b80", 'right': "\u2b82" }, - \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" } + \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" }, < - The full list of unicode numbers for fancy characters is shown - in |lightline-problem-9|. - - If the triangles are shown in appropriate characters but the - colors do not look correctly, see the following. - If you are using iTerm2, change the following settings. - - + set Profiles>Colors>Minimum contrast to the Lowest. - + set Profiles>Window>Transparency to the Opaquest. - - For other terminals, this weird-triangle problem will be - resolved by disabling transparency or contrast adjustment. - -Problem 9: *lightline-problem-9* - Where can I find the list of all the cool characters for patched fonts? - - Default powerline vim-powerline - separator.left '' '' (\ue0b0) '⮀' (\u2b80) - separator.right '' '' (\ue0b2) '⮂' (\u2b82) - subseparator.left '|' '' (\ue0b1) '⮁' (\u2b81) - subseparator.right '|' '' (\ue0b3) '⮃' (\u2b83) - branch symbol -- '' (\ue0a0) '⭠' (\u2b60) - readonly symbol -- '' (\ue0a2) '⭤' (\u2b64) - linecolumn symbol -- '' (\ue0a1) '⭡' (\u2b61) - Problem 10: *lightline-problem-10* Cool statusline disappears on |unite|, |vimfiler| and |vimshell| buffers. @@ -1192,7 +1010,7 @@ Problem 11: *lightline-problem-11* return lightline#statusline(0) endfunction < - See |lightline-powerful-example| for more cool settings for + See |lightline-example| for more cool settings for these plugins. Problem 12: *lightline-problem-12* @@ -1287,8 +1105,8 @@ Problem 15: *lightline-problem-15* If you don't like the separators in the tabline, use: > let g:lightline = { - \ 'tabline_separator': { 'left': "", 'right': "" }, - \ 'tabline_subseparator': { 'left': "", 'right': "" }, + \ 'tabline_separator': { 'left': '', 'right': '' }, + \ 'tabline_subseparator': { 'left': '', 'right': '' }, \ } < Problem 16: *lightline-problem-16* diff --git a/sources_non_forked/lightline.vim/plugin/lightline.vim b/sources_non_forked/lightline.vim/plugin/lightline.vim index d08517d7..1f5f998e 100644 --- a/sources_non_forked/lightline.vim/plugin/lightline.vim +++ b/sources_non_forked/lightline.vim/plugin/lightline.vim @@ -2,10 +2,10 @@ " Filename: plugin/lightline.vim " Author: itchyny " License: MIT License -" Last Change: 2019/07/30 12:00:00. +" Last Change: 2021/11/21 22:54:41. " ============================================================================= -if exists('g:loaded_lightline') || v:version < 700 +if exists('g:loaded_lightline') || v:version < 703 finish endif let g:loaded_lightline = 1 @@ -15,14 +15,13 @@ set cpo&vim augroup lightline autocmd! - autocmd WinEnter,BufEnter,SessionLoadPost * call lightline#update() + autocmd WinEnter,BufEnter,SessionLoadPost,FileChangedShellPost * call lightline#update() if !has('patch-8.1.1715') autocmd FileType qf call lightline#update() endif autocmd SessionLoadPost * call lightline#highlight() autocmd ColorScheme * if !has('vim_starting') || expand('') !=# 'macvim' \ | call lightline#update() | call lightline#highlight() | endif - autocmd CursorMoved,BufUnload * call lightline#update_once() augroup END " This quickfix option was introduced at Vim 85850f3a5ef9, which is the commit diff --git a/sources_non_forked/lightline.vim/test/.themisrc b/sources_non_forked/lightline.vim/test/.themisrc index 6e0121ce..5c7018a1 100644 --- a/sources_non_forked/lightline.vim/test/.themisrc +++ b/sources_non_forked/lightline.vim/test/.themisrc @@ -20,3 +20,5 @@ function! SID(name) abort endfunction filetype plugin on + +call lightline#init() diff --git a/sources_non_forked/lightline.vim/test/autocmd.vim b/sources_non_forked/lightline.vim/test/autocmd.vim new file mode 100644 index 00000000..934509b8 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/autocmd.vim @@ -0,0 +1,23 @@ +if !has("patch-8.2.0996") + finish +endif + +let s:suite = themis#suite('autocmd') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = {} + call lightline#init() + tabnew + tabonly +endfunction + +function! s:suite.doautoall() + tabnew + tabnew + tabprevious + doautoall WinEnter + let statusline = getwinvar(1, '&statusline') + call s:assert.match(statusline, 'lightline') + call s:assert.match(statusline, '_active_') +endfunction diff --git a/sources_non_forked/lightline.vim/test/highlight.vim b/sources_non_forked/lightline.vim/test/highlight.vim index 0e9e6566..590536c6 100644 --- a/sources_non_forked/lightline.vim/test/highlight.vim +++ b/sources_non_forked/lightline.vim/test/highlight.vim @@ -25,11 +25,11 @@ function! s:suite.highlight() let palette = lightline#palette() call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0])) call s:assert.match(s:hi('LightlineLeft_normal_1'), s:pattern(palette.normal.left[1])) - call s:assert.match(s:hi('LightlineLeft_normal_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_normal_2'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) call s:assert.match(s:hi('LightlineRight_normal_1'), s:pattern(palette.normal.right[1])) call s:assert.match(s:hi('LightlineRight_normal_2'), s:pattern(palette.normal.right[2])) - call s:assert.match(s:hi('LightlineRight_normal_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_3'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) endfunction @@ -41,11 +41,11 @@ function! s:suite.insert() let palette = lightline#palette() call s:assert.match(s:hi('LightlineLeft_insert_0'), s:pattern(palette.insert.left[0])) call s:assert.match(s:hi('LightlineLeft_insert_1'), s:pattern(palette.insert.left[1])) - call s:assert.match(s:hi('LightlineLeft_insert_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_insert_2'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_insert_0'), s:pattern(palette.insert.right[0])) call s:assert.match(s:hi('LightlineRight_insert_1'), s:pattern(palette.insert.right[1])) call s:assert.match(s:hi('LightlineRight_insert_2'), s:pattern(palette.insert.right[2])) - call s:assert.match(s:hi('LightlineRight_insert_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_insert_3'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_insert'), s:pattern(palette.insert.middle[0])) endfunction @@ -58,11 +58,11 @@ function! s:suite.visual() let palette = lightline#palette() call s:assert.match(s:hi('LightlineLeft_visual_0'), s:pattern(palette.visual.left[0])) call s:assert.match(s:hi('LightlineLeft_visual_1'), s:pattern(palette.visual.left[1])) - call s:assert.match(s:hi('LightlineLeft_visual_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_visual_2'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_visual_0'), s:pattern(palette.normal.right[0])) call s:assert.match(s:hi('LightlineRight_visual_1'), s:pattern(palette.normal.right[1])) call s:assert.match(s:hi('LightlineRight_visual_2'), s:pattern(palette.normal.right[2])) - call s:assert.match(s:hi('LightlineRight_visual_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_visual_3'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) endfunction @@ -74,11 +74,11 @@ function! s:suite.replace() let palette = lightline#palette() call s:assert.match(s:hi('LightlineLeft_replace_0'), s:pattern(palette.replace.left[0])) call s:assert.match(s:hi('LightlineLeft_replace_1'), s:pattern(palette.replace.left[1])) - call s:assert.match(s:hi('LightlineLeft_replace_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_replace_2'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_replace_0'), s:pattern(palette.replace.right[0])) call s:assert.match(s:hi('LightlineRight_replace_1'), s:pattern(palette.replace.right[1])) call s:assert.match(s:hi('LightlineRight_replace_2'), s:pattern(palette.replace.right[2])) - call s:assert.match(s:hi('LightlineRight_replace_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_replace_3'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_replace'), s:pattern(palette.replace.middle[0])) endfunction @@ -96,13 +96,13 @@ function! s:suite.left_right() call s:assert.match(s:hi('LightlineLeft_normal_1'), s:pattern(palette.normal.left[1])) call s:assert.match(s:hi('LightlineLeft_normal_2'), s:pattern(palette.normal.middle[0])) call s:assert.match(s:hi('LightlineLeft_normal_3'), s:pattern(palette.normal.middle[0])) - call s:assert.match(s:hi('LightlineLeft_normal_4'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_normal_4'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) call s:assert.match(s:hi('LightlineRight_normal_1'), s:pattern(palette.normal.right[1])) call s:assert.match(s:hi('LightlineRight_normal_2'), s:pattern(palette.normal.right[2])) call s:assert.match(s:hi('LightlineRight_normal_3'), s:pattern(palette.normal.middle[0])) call s:assert.match(s:hi('LightlineRight_normal_4'), s:pattern(palette.normal.middle[0])) - call s:assert.match(s:hi('LightlineRight_normal_5'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_5'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) endfunction @@ -121,9 +121,9 @@ function! s:suite.no_components() call lightline#colorscheme() let palette = lightline#palette() call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0])) - call s:assert.match(s:hi('LightlineLeft_normal_1'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_normal_1'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) - call s:assert.match(s:hi('LightlineRight_normal_1'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_1'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) endfunction @@ -142,7 +142,7 @@ function! s:suite.subseparator() if i + 1 == j call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), s:pattern(get(palette.normal.left, i, palette.normal.middle[0]), get(palette.normal.left, j, palette.normal.middle[0]))) else - call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), 'E411: [hH]ighlight group not found\|cleared') endif endfor endfor @@ -157,11 +157,11 @@ function! s:suite.component_type() call s:assert.match(s:hi(printf('LightlineLeft_normal_%s', type)), s:pattern(palette.normal[type][0])) call s:assert.match(s:hi(printf('LightlineLeft_normal_0_%s', type)), s:pattern(palette.normal.left[0], palette.normal[type][0])) call s:assert.match(s:hi(printf('LightlineLeft_normal_1_%s', type)), s:pattern(palette.normal.left[1], palette.normal[type][0])) - call s:assert.match(s:hi(printf('LightlineLeft_normal_2_%s', type)), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi(printf('LightlineLeft_normal_2_%s', type)), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_0', type)), s:pattern(palette.normal[type][0], palette.normal.left[0])) call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_1', type)), s:pattern(palette.normal[type][0], palette.normal.left[1])) call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_2', type)), s:pattern(palette.normal[type][0], palette.normal.middle[0])) - call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_3', type)), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_3', type)), 'E411: [hH]ighlight group not found\|cleared') endfor for type1 in ['error', 'warning'] for type2 in ['error', 'warning'] diff --git a/sources_non_forked/lightline.vim/test/link.vim b/sources_non_forked/lightline.vim/test/link.vim index 98e409e6..3235f548 100644 --- a/sources_non_forked/lightline.vim/test/link.vim +++ b/sources_non_forked/lightline.vim/test/link.vim @@ -31,11 +31,11 @@ function! s:suite.link() call lightline#link() call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0') call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') - call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') - call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') endfunction @@ -43,11 +43,11 @@ function! s:suite.insert() call lightline#link('i') call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_insert_0') call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_insert_1') - call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_insert_0') call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_insert_1') call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_insert_2') - call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_insert') endfunction @@ -55,11 +55,11 @@ function! s:suite.visual() call lightline#link('v') call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_visual_0') call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_visual_1') - call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_visual_0') call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_visual_1') call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_visual_2') - call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_visual') endfunction @@ -67,11 +67,11 @@ function! s:suite.replace() call lightline#link('R') call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_replace_0') call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_replace_1') - call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_replace_0') call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_replace_1') call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_replace_2') - call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_replace') endfunction @@ -89,13 +89,13 @@ function! s:suite.left_right() call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') call s:assert.match(s:hi('LightlineLeft_active_2'), 'LightlineLeft_normal_2') call s:assert.match(s:hi('LightlineLeft_active_3'), 'LightlineLeft_normal_3') - call s:assert.match(s:hi('LightlineLeft_active_4'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineLeft_active_4'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') call s:assert.match(s:hi('LightlineRight_active_3'), 'LightlineRight_normal_3') call s:assert.match(s:hi('LightlineRight_active_4'), 'LightlineRight_normal_4') - call s:assert.match(s:hi('LightlineRight_active_5'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineRight_active_5'), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') endfunction @@ -114,7 +114,7 @@ function! s:suite.subseparator() if i + 1 == j call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), printf('LightlineLeft_normal_%s_%s', i, j)) else - call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), 'E411: highlight group not found') + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), 'E411: [hH]ighlight group not found\|cleared') endif endfor endfor @@ -129,11 +129,11 @@ function! s:suite.component_type() call s:assert.match(s:hi(printf('LightlineLeft_active_%s', type)), printf('LightlineLeft_normal_%s', type)) call s:assert.match(s:hi(printf('LightlineLeft_active_0_%s', type)), printf('LightlineLeft_normal_0_%s', type)) call s:assert.match(s:hi(printf('LightlineLeft_active_1_%s', type)), printf('LightlineLeft_normal_1_%s', type)) - call s:assert.match(s:hi(printf('LightlineLeft_active_2_%s', type)), 'E411: highlight group not found') + call s:assert.match(s:hi(printf('LightlineLeft_active_2_%s', type)), 'E411: [hH]ighlight group not found\|cleared') call s:assert.match(s:hi(printf('LightlineLeft_active_%s_0', type)), printf('LightlineLeft_normal_%s_0', type)) call s:assert.match(s:hi(printf('LightlineLeft_active_%s_1', type)), printf('LightlineLeft_normal_%s_1', type)) call s:assert.match(s:hi(printf('LightlineLeft_active_%s_2', type)), printf('LightlineLeft_normal_%s_2', type)) - call s:assert.match(s:hi(printf('LightlineLeft_active_%s_3', type)), 'E411: highlight group not found') + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_3', type)), 'E411: [hH]ighlight group not found\|cleared') endfor for type1 in ['error', 'warning'] for type2 in ['error', 'warning'] @@ -141,3 +141,17 @@ function! s:suite.component_type() endfor endfor endfunction + +function! s:suite.hi_clear() + call lightline#link() + colorscheme default + call lightline#link() + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') +endfunction diff --git a/sources_non_forked/lightline.vim/test/tabs.vim b/sources_non_forked/lightline.vim/test/tabs.vim index 7851e705..863dd7fa 100644 --- a/sources_non_forked/lightline.vim/test/tabs.vim +++ b/sources_non_forked/lightline.vim/test/tabs.vim @@ -2,7 +2,7 @@ let s:suite = themis#suite('tabs') let s:assert = themis#helper('assert') function! s:suite.before_each() - let g:lightline = { 'winwidth': 180 } + set columns=180 call lightline#init() tabnew tabonly diff --git a/sources_non_forked/lightline.vim/test/toggle.vim b/sources_non_forked/lightline.vim/test/toggle.vim index 7df270f8..6f7eb5bd 100644 --- a/sources_non_forked/lightline.vim/test/toggle.vim +++ b/sources_non_forked/lightline.vim/test/toggle.vim @@ -29,6 +29,12 @@ function! s:suite.disable_enable() call s:assert.equals(exists('#lightline-disable'), 0) call s:assert.not_equals(&statusline, '') call s:assert.not_equals(&tabline, '') + call lightline#disable() + call lightline#disable() + call lightline#enable() + call lightline#enable() + call s:assert.equals(exists('#lightline'), 1) + call s:assert.equals(exists('#lightline-disable'), 0) endfunction function! s:suite.toggle() diff --git a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md index dd351350..e2ce07b9 100644 --- a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md +++ b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md @@ -5,41 +5,42 @@ labels: bug --- +Keep in mind that others may have the same question in the future. The better your information, +the more likely they'll be able to help themselves. +--> #### Self-Diagnosis - -- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. -- [ ] I have reviewed the NERDTree documentation. `:h NERDTree` -- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). -- [ ] I have searched the web for an answer to my question. +Before creating an issue, take some time to search these resources for an answer. It's possible that someone else has already seen and solved your issue. +- [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) +- NERDTree documentation - `:h NERDTree` +- [NERDTree Wiki](https://github.com/preservim/nerdtree/wiki) +- Other resources: , , etc. -#### Environment (for bug reports) -- [ ] Operating System: -- [ ] Vim/Neovim version `:echo v:version`: -- [ ] NERDTree version, found on 1st line in NERDTree quickhelp `?`: -- [ ] vimrc settings - - [ ] NERDTree variables - ```vim - ``` - - Other NERDTree-dependent Plugins - - [ ] jistr/vim-nerdtree-tabs - - [ ] ryanoasis/vim-devicons - - [ ] tiagofumo/vim-nerdtree-syntax-highlight - - [ ] Xuyuanp/nerdtree-git-plugin - - [ ] Others (specify): - - [ ] I've verified the issue occurs with only NERDTree installed. +#### Environment +- Operating System: +- Vim/Neovim version `:version`: +- NERDTree version, found on first line of quickhelp `?`: +- Are you using any of these NERDTree-dependent plugins? + - [ ] [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin) + - [ ] [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons) + - [ ] [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight) + - [ ] [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin) + - [ ] [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops) + - [ ] [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection) + - [ ] [jistr/vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) + - [ ] Others (specify): +- Provide a minimal **.vimrc** file that will reproduce the issue. +```vim +``` #### Steps to Reproduce the Issue 1. -#### Current Result (Include screenshots where appropriate.) +#### Current Behavior (Include screenshots where appropriate.) #### Expected Result diff --git a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md index 25f15b02..7e13b7ac 100644 --- a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md +++ b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md @@ -3,22 +3,11 @@ name: "General Question" about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here." labels: "general question" --- - - -#### Self-Diagnosis - -- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. -- [ ] I have reviewed the NERDTree documentation. `:h NERDTree` -- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). -- [ ] I have searched the web for an answer to my question. +Before creating an issue, take some time to search these resources. It's possible that someone else has already asked your question and gotten an answer. +- [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) +- NERDTree documentation - `:h NERDTree` +- [NERDTree Wiki](https://github.com/preservim/nerdtree/wiki) +- Other resource: , , etc. #### State Your Question diff --git a/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md b/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md index ccd5bf8d..911f4598 100644 --- a/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md +++ b/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md @@ -1,13 +1,7 @@ ### Description of Changes -Closes # +Closes # --- ### New Version Info -- [ ] Derive a new version number. Increment the: - - [ ] `MAJOR` version when you make incompatible API changes - - [ ] `MINOR` version when you add functionality in a backwards-compatible manner - - [ ] `PATCH` version when you make backwards-compatible bug fixes -- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. -- [ ] Tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` diff --git a/sources_non_forked/nerdtree/.github/workflows/vint.yml b/sources_non_forked/nerdtree/.github/workflows/vint.yml new file mode 100644 index 00000000..68351b1c --- /dev/null +++ b/sources_non_forked/nerdtree/.github/workflows/vint.yml @@ -0,0 +1,15 @@ +name: Vint +on: [push, pull_request] +jobs: + vint: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Run vint with reviewdog + uses: reviewdog/action-vint@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review diff --git a/sources_non_forked/nerdtree/.vintrc.yaml b/sources_non_forked/nerdtree/.vintrc.yaml new file mode 100644 index 00000000..c44b6aba --- /dev/null +++ b/sources_non_forked/nerdtree/.vintrc.yaml @@ -0,0 +1,5 @@ +cmdargs: + severity: style_problem + color: true + env: + neovim: false diff --git a/sources_non_forked/nerdtree/CHANGELOG.md b/sources_non_forked/nerdtree/CHANGELOG.md index 9e494175..ba25bf16 100644 --- a/sources_non_forked/nerdtree/CHANGELOG.md +++ b/sources_non_forked/nerdtree/CHANGELOG.md @@ -1,132 +1,257 @@ -# Change Log - -#### 5.3... -- **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) -#### 5.2... -- **.9**: Suppress events for intermediate window/tab/buffer changes [#1026](https://github.com/scrooloose/nerdtree/pull/1026) -- **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021) -- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! [#1019](https://github.com/scrooloose/nerdtree/pull/1019) -- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017) -- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016) -- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015) -- **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014) -- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/scrooloose/nerdtree/pull/1013) +# NERDTree Change Log + +#### 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) + - fix: mapping description in NERDTree.txt. (roccomao) [#1393](https://github.com/preservim/nerdtree/pull/1393) +#### 7.0 +- **.1**: + - Fix NERDTreeFind to handle directory case sensitivity. (dangibson) [#1387](https://github.com/preservim/nerdtree/pull/1387) + - New Show file lines toggle. (hsnks100) [#1384](https://github.com/preservim/nerdtree/pull/1384) + - Add case sensitivity for refreshing nodes. (rzvxa) [#1382](https://github.com/preservim/nerdtree/pull/1382) + - Clarified the NERDTreeChangePermissions prompt. (rzvxa) [#1381](https://github.com/preservim/nerdtree/pull/1381) + - New reveal functionality for Windows. (rzvxa) [#1366](https://github.com/preservim/nerdtree/pull/1366) + - Fix bracket escaping in path names. (kai-patel) [#1359](https://github.com/preservim/nerdtree/pull/1359) + - Fix Case Sensitive Move Operation. (rzvxa) [#1375](https://github.com/preservim/nerdtree/pull/1375) + - New menu command for changing selected node permissions. (mjkloeckner) [#1348](https://github.com/preservim/nerdtree/pull/1348) + - Fix documentation errors. (BubuDavid) [#1372](https://github.com/preservim/nerdtree/pull/1372) + - Fix typo in nerdtree.vim file. (SandeshPyakurel) [#1380](https://github.com/preservim/nerdtree/pull/1380) +- **.0**: + - Now we warn about invalid files instead of ignoring them silently. (rmonico) [#1365](https://github.com/preservim/nerdtree/pull/1365) + - New g:NERDTreeWinPos options for top and bottom. (rzvxa) [#1363](https://github.com/preservim/nerdtree/pull/1363) + - Fix error in README. (nickspoons) [#1330](https://github.com/preservim/nerdtree/pull/1330) + - Fix typo in the documentation. (chapeupreto) [#1306](https://github.com/preservim/nerdtree/pull/1306) +#### 6.10 +- **.16**: Fix documentation errors. (lifecrisis) [#1269](https://github.com/preservim/nerdtree/pull/1269) +- **.15**: Ensure backward compatible testing of types. (lifecrisis) [#1266](https://github.com/preservim/nerdtree/pull/1266) +- **.14**: Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265) +- **.13**: Change highlighting of bookmarks in the tree. (PhilRunninger) [#1261](https://github.com/preservim/nerdtree/pull/1261) +- **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259) +- **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243) +- **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249) +- **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236) +- **.8**: Put `Callback` function variables in local scope. (PhilRunninger) [#1230](https://github.com/preservim/nerdtree/pull/1230) +- **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225) +- **.6**: Restore the default behavior of the `` key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) +- **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) +- **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219) +- **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215) +- **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214) +- **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213) +- **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207) +#### 6.9 +- **.12**: Respect NERDTreeCustomOpenArgs when opening bookmark (przepompownia) [#1200](https://github.com/preservim/nerdtree/pull/1200) +- **.11**: Revamp the README. (buncis, PhilRunninger) [#1192](https://github.com/preservim/nerdtree/pull/1192), [#1193](https://github.com/preservim/nerdtree/pull/1193) +- **.10**: Open a mirrored NERDTree with correct width (PhilRunninger) [#1177](https://github.com/preservim/nerdtree/pull/1177) +- **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167) +- **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166) +- **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165) +- **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164) +- **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157) +- **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156) +- **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153) +- **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151) +- **.1**: Respect user's `&shellslash` setting in CopyNode and RemoveNode functions (PhilRunninger) [#1150](https://github.com/preservim/nerdtree/pull/1150) +- **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144) +#### 6.8 +- **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138) +#### 6.7 +- **.15**: Add curly braces to the list of characters to be escaped. (PhilRunninger) [#1128](https://github.com/preservim/nerdtree/pull/1128) +- **.14**: Use backward-compatible `nerdtree#and()` in one place that was missed. (PhilRunninger) [#1134](https://github.com/preservim/nerdtree/pull/1134) +- **.13**: `cmd.exe /c start "" ` for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) +- **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. (Eugenij-W) [#1126](https://github.com/preservim/nerdtree/pull/1126) +- **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) (Eugenij-W) [#1122](https://github.com/preservim/nerdtree/pull/1122) +- **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) +- **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118) +- **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) +- **.7**: Put `'%'` argument in `bufname()` for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) +- **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103) +- **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] ` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) +- **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) +- **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098) +- **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) +- **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094) +- **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090) +#### 6.6 +- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087) +- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) +#### 6.5 +- **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083) +#### 6.4 +- **.6**: NERDTreeFind shows expected message if file doesn't exist e.g. with vim-startify (andys8). [#1081](https://github.com/preservim/nerdtree/pull/1081) +- **.5**: Ensure events are (or aren't) being ignored correctly. (PhilRunninger) [#1080](https://github.com/preservim/nerdtree/pull/1080) +- **.4**: Prevent overwriting existing files/dirs on node move. (PhilRunninger) [#1079](https://github.com/preservim/nerdtree/pull/1079) +- **.3**: Fix regex that finds keyword for minimal menu. (PhilRunninger) [#1075](https://github.com/preservim/nerdtree/pull/1075) +- **.2**: Lint vimscript, fix errors and warnings, add CI job to review PRs (Caleb Maclennan) [#1071](https://github.com/preservim/nerdtree/pull/1071) +- **.1**: Ensure backward compatibility. v:t_func is not available before Vim 8.0 (Phil Runninger) +- **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/preservim/nerdtree/pull/1067) +#### 6.3 +- **.0**: Add new command that behaves like NERDTreeToggle but defaults to the root of a VCS repository. (willfindlay) [#1060](https://github.com/preservim/nerdtree/pull/1060) +#### 6.2 +- **.1**: Menu option, 'copy path to clipboard' is aware of VIM clipboard option (jhzn) [#1056](https://github.com/preservim/nerdtree/pull/1056) +- **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/preservim/nerdtree/pull/1032) +#### 6.1 +- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/preservim/nerdtree/pull/1049) +- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/preservim/nerdtree/pull/1048) +- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/preservim/nerdtree/pull/1047) +- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/preservim/nerdtree/pull/1045) +- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/preservim/nerdtree/pull/1043) +#### 6.0 +- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/preservim/nerdtree/pull/1040) +- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/preservim/nerdtree/pull/1035) +#### 5.3 +- **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/preservim/nerdtree/pull/1038) +- **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/preservim/nerdtree/pull/1037) +- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/preservim/nerdtree/pull/1031) +- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/preservim/nerdtree/pull/1029) +#### 5.2 +- **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/preservim/nerdtree/pull/1026) +- **.8**: Revert [#1019](https://github.com/preservim/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/preservim/nerdtree/pull/1021) +- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/preservim/nerdtree/pull/1019) +- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. (PhilRunninger) [#1017](https://github.com/preservim/nerdtree/pull/1017) +- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/preservim/nerdtree/pull/1016) +- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/preservim/nerdtree/pull/1015) +- **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/preservim/nerdtree/pull/1014) +- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/preservim/nerdtree/pull/1013) - **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) -- **.0**: Expand functionality of `` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011) -#### 5.1... -- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/scrooloose/nerdtree/pull/1009) -- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/scrooloose/nerdtree/pull/1008) -- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007) +- **.0**: Expand functionality of `` mapping. (PhilRunninger) [#1011](https://github.com/preservim/nerdtree/pull/1011) +#### 5.1 +- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/preservim/nerdtree/pull/1009) +- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/preservim/nerdtree/pull/1008) +- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/preservim/nerdtree/pull/1007) - **.0**: Too many changes for one patch... - - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) [#1005](https://github.com/scrooloose/nerdtree/pull/1005) - - Add a "copy path to clipboard" menu option (PhilRunninger) [#1002](https://github.com/scrooloose/nerdtree/pull/1002) - - Enable root refresh on "vim ." a different way than [#999](https://github.com/scrooloose/nerdtree/pull/999). (PhilRunninger) [#1001](https://github.com/scrooloose/nerdtree/pull/1001) - - Fix refreshroot (PhilRunninger) [#999](https://github.com/scrooloose/nerdtree/pull/999) - - Change version check to look for 703 not 730 (vhalis) [#994](https://github.com/scrooloose/nerdtree/pull/994) - - Change minimum vim (PhilRunninger) [#991](https://github.com/scrooloose/nerdtree/pull/991) - - Allow multi-character DirArrows (PhilRunninger) [#985](https://github.com/scrooloose/nerdtree/pull/985) - - Remove redraw! while still clearing last message empty string. (PhilRunninger) [#979](https://github.com/scrooloose/nerdtree/pull/979) - - fix `_initChildren` function value set to numChildrenCached error (terryding77) [#969](https://github.com/scrooloose/nerdtree/pull/969) - - On Windows, do a case-insensitive comparison of paths. (PhilRunninger) [#967](https://github.com/scrooloose/nerdtree/pull/967) - - Remove the **Please wait... DONE** messages. (PhilRunninger) [#966](https://github.com/scrooloose/nerdtree/pull/966) - - Smarter delimiter default (PhilRunninger) [#963](https://github.com/scrooloose/nerdtree/pull/963) - - Update directory .vimdc readme example (spencerdcarlson) [#961](https://github.com/scrooloose/nerdtree/pull/961) - - Preview bookmarks (PhilRunninger) [#956](https://github.com/scrooloose/nerdtree/pull/956) - - Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) [#955](https://github.com/scrooloose/nerdtree/pull/955) - - Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) [#954](https://github.com/scrooloose/nerdtree/pull/954) - - Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) [#952](https://github.com/scrooloose/nerdtree/pull/952) - - Set a maximum window size when zooming. (PhilRunninger) [#950](https://github.com/scrooloose/nerdtree/pull/950) - - Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) [#949](https://github.com/scrooloose/nerdtree/pull/949) - - Escape a backslash so it can be used in a key mapping. (PhilRunninger) [#948](https://github.com/scrooloose/nerdtree/pull/948) - - Add a NERDTreeMinimalMenu feature (tuzz) [#938](https://github.com/scrooloose/nerdtree/pull/938) - - fixed root path error for windows (zcodes) [#935](https://github.com/scrooloose/nerdtree/pull/935) - - Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) [#929](https://github.com/scrooloose/nerdtree/pull/929) - - Document NERDTreeNodeDelimiter [#912](https://github.com/scrooloose/nerdtree/pull/912) (PhilRunninger) [#926](https://github.com/scrooloose/nerdtree/pull/926) - - Allow modification of menu keybindings (Leandros) [#923](https://github.com/scrooloose/nerdtree/pull/923) - - Add two more disqualifications for isCascadable(). (PhilRunninger) [#914](https://github.com/scrooloose/nerdtree/pull/914) - - Allow highlighting more than one flag. (kristijanhusak) [#908](https://github.com/scrooloose/nerdtree/pull/908) - - Support sorting files and directories by modification time. (PhilRunninger) [#901](https://github.com/scrooloose/nerdtree/pull/901) - - Parse . and .. from path string with trailing slash. (PhilRunninger) [#899](https://github.com/scrooloose/nerdtree/pull/899) - - Force sort to recalculate the cached sortKey. (PhilRunninger) [#898](https://github.com/scrooloose/nerdtree/pull/898) - - Add NERDTreeRefreshRoot command (wgfm) [#897](https://github.com/scrooloose/nerdtree/pull/897) - - Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) [#896](https://github.com/scrooloose/nerdtree/pull/896) - - Catch all errors, not just NERDTree errors. (PhilRunninger) [#894](https://github.com/scrooloose/nerdtree/pull/894) - - Fix typo in help file (lvoisin) [#892](https://github.com/scrooloose/nerdtree/pull/892) - - Make NERDTreeCreator set the `'nolist'` option (lifecrisis) [#889](https://github.com/scrooloose/nerdtree/pull/889) - - Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) [#888](https://github.com/scrooloose/nerdtree/pull/888) - - Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) [#887](https://github.com/scrooloose/nerdtree/pull/887) - - Fix the / motions, which currently fail with cascades (lifecrisis) [#886](https://github.com/scrooloose/nerdtree/pull/886) - - Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) [#882](https://github.com/scrooloose/nerdtree/pull/882) - - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) [#878](https://github.com/scrooloose/nerdtree/pull/878) - - Use tabnext instead of gt to allow users to remap gt. (PhilRunninger) [#877](https://github.com/scrooloose/nerdtree/pull/877) - - Do a case sensitive comparison of new/existing buffers. (PhilRunninger) [#875](https://github.com/scrooloose/nerdtree/pull/875) - - Fix opening sub-directories that have commas in their name. (PhilRunninger) [#873](https://github.com/scrooloose/nerdtree/pull/873) - - Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) [#872](https://github.com/scrooloose/nerdtree/pull/872) - - Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) [#871](https://github.com/scrooloose/nerdtree/pull/871) - - Unzoom NERDTree when opening a file (PhilRunninger) [#870](https://github.com/scrooloose/nerdtree/pull/870) - - Support unusual characters in file and directory names (PhilRunninger) [#868](https://github.com/scrooloose/nerdtree/pull/868) - - Reword renamed-buffer prompt to be more clear (aflock) [#867](https://github.com/scrooloose/nerdtree/pull/867) - - Default to placing cursor on root when closing bookmark table (lifecrisis) [#866](https://github.com/scrooloose/nerdtree/pull/866) - - Fix issues with sorting of nodes (PhilRunninger) [#856](https://github.com/scrooloose/nerdtree/pull/856) - - Better OSX detection (bubba-h57) [#853](https://github.com/scrooloose/nerdtree/pull/853) - - Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) [#852](https://github.com/scrooloose/nerdtree/pull/852) - - Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) [#851](https://github.com/scrooloose/nerdtree/pull/851) - - Add code to sort mappings in quickhelp (lifecrisis) [#849](https://github.com/scrooloose/nerdtree/pull/849) - - Use ":clearjumps" in new NERDTree windows (lifecrisis) [#844](https://github.com/scrooloose/nerdtree/pull/844) - - Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) [#840](https://github.com/scrooloose/nerdtree/pull/840) - - BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) [#838](https://github.com/scrooloose/nerdtree/pull/838) - - Make the NERDTree buffer writable when rendering it. (PhilRunninger) [#837](https://github.com/scrooloose/nerdtree/pull/837) - - Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) [#835](https://github.com/scrooloose/nerdtree/pull/835) - - Replace strcharpart() with substitute() for backward compatibility (bravestarr) [#834](https://github.com/scrooloose/nerdtree/pull/834) - - Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) [#833](https://github.com/scrooloose/nerdtree/pull/833) - - Clear output when NERDTree menu is aborted (lifecrisis) [#832](https://github.com/scrooloose/nerdtree/pull/832) - - Display a path with multi-byte characters correctly when it is truncated (bravestarr) [#830](https://github.com/scrooloose/nerdtree/pull/830) - - Support revealing file and executing file with xdg-open for Linux (ngnmhieu) [#824](https://github.com/scrooloose/nerdtree/pull/824) - - If node isn't open, count children on disk before deleting. (PhilRunninger) [#822](https://github.com/scrooloose/nerdtree/pull/822) - - Add new variable g:NERDTreeRemoveFileCmd (kutsan) [#816](https://github.com/scrooloose/nerdtree/pull/816) - - Use a better check for existence of the NERDTree buffer. (PhilRunninger) [#814](https://github.com/scrooloose/nerdtree/pull/814) - - Fix focussing previous buffer when closing NERDTree (mrubli) [#801](https://github.com/scrooloose/nerdtree/pull/801) - - Update the docs for "NERDTreeStatusline" (lifecrisis) [#796](https://github.com/scrooloose/nerdtree/pull/796) - - BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) [#795](https://github.com/scrooloose/nerdtree/pull/795) - - Revert the bugfix from pull request [#785](https://github.com/scrooloose/nerdtree/pull/785) (lifecrisis) [#794](https://github.com/scrooloose/nerdtree/pull/794) - - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) [#786](https://github.com/scrooloose/nerdtree/pull/786) - - BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) [#785](https://github.com/scrooloose/nerdtree/pull/785) - - Add modelines (lifecrisis) [#782](https://github.com/scrooloose/nerdtree/pull/782) - - Change the type of completion used by NERDTreeFind (lifecrisis) [#781](https://github.com/scrooloose/nerdtree/pull/781) - - change NERDTreeFind with args (zhenyangze) [#778](https://github.com/scrooloose/nerdtree/pull/778) - - Style Choice: Using confirm() when deleting a bookmark (lifecrisis) [#777](https://github.com/scrooloose/nerdtree/pull/777) - - remove useless substitute when `file =~# "/$"` (skyblueee) [#773](https://github.com/scrooloose/nerdtree/pull/773) - - remove useless removeLeadingSpaces in _stripMarkup (skyblueee) [#772](https://github.com/scrooloose/nerdtree/pull/772) - - Make the "o" mapping consistent with "x" (lifecrisis) [#769](https://github.com/scrooloose/nerdtree/pull/769) - - Fix a problem with the "x" handler (lifecrisis) [#768](https://github.com/scrooloose/nerdtree/pull/768) - - Clean up the handler for the "x" mapping (lifecrisis) [#767](https://github.com/scrooloose/nerdtree/pull/767) - - Revert change to tab opening method (lifecrisis) [#766](https://github.com/scrooloose/nerdtree/pull/766) - - BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) [#765](https://github.com/scrooloose/nerdtree/pull/765) - - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) [#759](https://github.com/scrooloose/nerdtree/pull/759) - - Update doc with already existing mapping variables (asnr) [#699](https://github.com/scrooloose/nerdtree/pull/699) - - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) [#696](https://github.com/scrooloose/nerdtree/pull/696) - - Correct NERDTreeIgnore pattern in doc (cntoplolicon) [#648](https://github.com/scrooloose/nerdtree/pull/648) - - Remove empty segments when splitting path (sooth-sayer) [#574](https://github.com/scrooloose/nerdtree/pull/574) - - Suppress autocmds less agressively (wincent) [#578](https://github.com/scrooloose/nerdtree/pull/578) [#691](https://github.com/scrooloose/nerdtree/pull/691) + - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) [#1005](https://github.com/preservim/nerdtree/pull/1005) + - Add a "copy path to clipboard" menu option (PhilRunninger) [#1002](https://github.com/preservim/nerdtree/pull/1002) + - Enable root refresh on "vim ." a different way than [#999](https://github.com/preservim/nerdtree/pull/999). (PhilRunninger) [#1001](https://github.com/preservim/nerdtree/pull/1001) + - Fix refreshroot (PhilRunninger) [#999](https://github.com/preservim/nerdtree/pull/999) + - Change version check to look for 703 not 730 (vhalis) [#994](https://github.com/preservim/nerdtree/pull/994) + - Change minimum vim (PhilRunninger) [#991](https://github.com/preservim/nerdtree/pull/991) + - Allow multi-character DirArrows (PhilRunninger) [#985](https://github.com/preservim/nerdtree/pull/985) + - Remove redraw! while still clearing last message empty string. (PhilRunninger) [#979](https://github.com/preservim/nerdtree/pull/979) + - fix `_initChildren` function value set to numChildrenCached error (terryding77) [#969](https://github.com/preservim/nerdtree/pull/969) + - On Windows, do a case-insensitive comparison of paths. (PhilRunninger) [#967](https://github.com/preservim/nerdtree/pull/967) + - Remove the **Please wait... DONE** messages. (PhilRunninger) [#966](https://github.com/preservim/nerdtree/pull/966) + - Smarter delimiter default (PhilRunninger) [#963](https://github.com/preservim/nerdtree/pull/963) + - Update directory .vimdc readme example (spencerdcarlson) [#961](https://github.com/preservim/nerdtree/pull/961) + - Preview bookmarks (PhilRunninger) [#956](https://github.com/preservim/nerdtree/pull/956) + - Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) [#955](https://github.com/preservim/nerdtree/pull/955) + - Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) [#954](https://github.com/preservim/nerdtree/pull/954) + - Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) [#952](https://github.com/preservim/nerdtree/pull/952) + - Set a maximum window size when zooming. (PhilRunninger) [#950](https://github.com/preservim/nerdtree/pull/950) + - Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) [#949](https://github.com/preservim/nerdtree/pull/949) + - Escape a backslash so it can be used in a key mapping. (PhilRunninger) [#948](https://github.com/preservim/nerdtree/pull/948) + - Add a NERDTreeMinimalMenu feature (tuzz) [#938](https://github.com/preservim/nerdtree/pull/938) + - fixed root path error for windows (zcodes) [#935](https://github.com/preservim/nerdtree/pull/935) + - Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) [#929](https://github.com/preservim/nerdtree/pull/929) + - Document NERDTreeNodeDelimiter [#912](https://github.com/preservim/nerdtree/pull/912) (PhilRunninger) [#926](https://github.com/preservim/nerdtree/pull/926) + - Allow modification of menu keybindings (Leandros) [#923](https://github.com/preservim/nerdtree/pull/923) + - Add two more disqualifications for isCascadable(). (PhilRunninger) [#914](https://github.com/preservim/nerdtree/pull/914) + - Allow highlighting more than one flag. (kristijanhusak) [#908](https://github.com/preservim/nerdtree/pull/908) + - Support sorting files and directories by modification time. (PhilRunninger) [#901](https://github.com/preservim/nerdtree/pull/901) + - Parse . and .. from path string with trailing slash. (PhilRunninger) [#899](https://github.com/preservim/nerdtree/pull/899) + - Force sort to recalculate the cached sortKey. (PhilRunninger) [#898](https://github.com/preservim/nerdtree/pull/898) + - Add NERDTreeRefreshRoot command (wgfm) [#897](https://github.com/preservim/nerdtree/pull/897) + - Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) [#896](https://github.com/preservim/nerdtree/pull/896) + - Catch all errors, not just NERDTree errors. (PhilRunninger) [#894](https://github.com/preservim/nerdtree/pull/894) + - Fix typo in help file (lvoisin) [#892](https://github.com/preservim/nerdtree/pull/892) + - Make NERDTreeCreator set the `'nolist'` option (lifecrisis) [#889](https://github.com/preservim/nerdtree/pull/889) + - Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) [#888](https://github.com/preservim/nerdtree/pull/888) + - Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) [#887](https://github.com/preservim/nerdtree/pull/887) + - Fix the / motions, which currently fail with cascades (lifecrisis) [#886](https://github.com/preservim/nerdtree/pull/886) + - Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) [#882](https://github.com/preservim/nerdtree/pull/882) + - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) [#878](https://github.com/preservim/nerdtree/pull/878) + - Use tabnext instead of gt to allow users to remap gt. (PhilRunninger) [#877](https://github.com/preservim/nerdtree/pull/877) + - Do a case sensitive comparison of new/existing buffers. (PhilRunninger) [#875](https://github.com/preservim/nerdtree/pull/875) + - Fix opening sub-directories that have commas in their name. (PhilRunninger) [#873](https://github.com/preservim/nerdtree/pull/873) + - Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) [#872](https://github.com/preservim/nerdtree/pull/872) + - Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) [#871](https://github.com/preservim/nerdtree/pull/871) + - Unzoom NERDTree when opening a file (PhilRunninger) [#870](https://github.com/preservim/nerdtree/pull/870) + - Support unusual characters in file and directory names (PhilRunninger) [#868](https://github.com/preservim/nerdtree/pull/868) + - Reword renamed-buffer prompt to be more clear (aflock) [#867](https://github.com/preservim/nerdtree/pull/867) + - Default to placing cursor on root when closing bookmark table (lifecrisis) [#866](https://github.com/preservim/nerdtree/pull/866) + - Fix issues with sorting of nodes (PhilRunninger) [#856](https://github.com/preservim/nerdtree/pull/856) + - Better OSX detection (bubba-h57) [#853](https://github.com/preservim/nerdtree/pull/853) + - Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) [#852](https://github.com/preservim/nerdtree/pull/852) + - Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) [#851](https://github.com/preservim/nerdtree/pull/851) + - Add code to sort mappings in quickhelp (lifecrisis) [#849](https://github.com/preservim/nerdtree/pull/849) + - Use ":clearjumps" in new NERDTree windows (lifecrisis) [#844](https://github.com/preservim/nerdtree/pull/844) + - Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) [#840](https://github.com/preservim/nerdtree/pull/840) + - BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) [#838](https://github.com/preservim/nerdtree/pull/838) + - Make the NERDTree buffer writable when rendering it. (PhilRunninger) [#837](https://github.com/preservim/nerdtree/pull/837) + - Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) [#835](https://github.com/preservim/nerdtree/pull/835) + - Replace strcharpart() with substitute() for backward compatibility (bravestarr) [#834](https://github.com/preservim/nerdtree/pull/834) + - Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) [#833](https://github.com/preservim/nerdtree/pull/833) + - Clear output when NERDTree menu is aborted (lifecrisis) [#832](https://github.com/preservim/nerdtree/pull/832) + - Display a path with multi-byte characters correctly when it is truncated (bravestarr) [#830](https://github.com/preservim/nerdtree/pull/830) + - Support revealing file and executing file with xdg-open for Linux (ngnmhieu) [#824](https://github.com/preservim/nerdtree/pull/824) + - If node isn't open, count children on disk before deleting. (PhilRunninger) [#822](https://github.com/preservim/nerdtree/pull/822) + - Add new variable g:NERDTreeRemoveFileCmd (kutsan) [#816](https://github.com/preservim/nerdtree/pull/816) + - Use a better check for existence of the NERDTree buffer. (PhilRunninger) [#814](https://github.com/preservim/nerdtree/pull/814) + - Fix focussing previous buffer when closing NERDTree (mrubli) [#801](https://github.com/preservim/nerdtree/pull/801) + - Update the docs for "NERDTreeStatusline" (lifecrisis) [#796](https://github.com/preservim/nerdtree/pull/796) + - BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) [#795](https://github.com/preservim/nerdtree/pull/795) + - Revert the bugfix from pull request [#785](https://github.com/preservim/nerdtree/pull/785) (lifecrisis) [#794](https://github.com/preservim/nerdtree/pull/794) + - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) [#786](https://github.com/preservim/nerdtree/pull/786) + - BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) [#785](https://github.com/preservim/nerdtree/pull/785) + - Add modelines (lifecrisis) [#782](https://github.com/preservim/nerdtree/pull/782) + - Change the type of completion used by NERDTreeFind (lifecrisis) [#781](https://github.com/preservim/nerdtree/pull/781) + - change NERDTreeFind with args (zhenyangze) [#778](https://github.com/preservim/nerdtree/pull/778) + - Style Choice: Using confirm() when deleting a bookmark (lifecrisis) [#777](https://github.com/preservim/nerdtree/pull/777) + - remove useless substitute when `file =~# "/$"` (skyblueee) [#773](https://github.com/preservim/nerdtree/pull/773) + - remove useless removeLeadingSpaces in _stripMarkup (skyblueee) [#772](https://github.com/preservim/nerdtree/pull/772) + - Make the "o" mapping consistent with "x" (lifecrisis) [#769](https://github.com/preservim/nerdtree/pull/769) + - Fix a problem with the "x" handler (lifecrisis) [#768](https://github.com/preservim/nerdtree/pull/768) + - Clean up the handler for the "x" mapping (lifecrisis) [#767](https://github.com/preservim/nerdtree/pull/767) + - Revert change to tab opening method (lifecrisis) [#766](https://github.com/preservim/nerdtree/pull/766) + - BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) [#765](https://github.com/preservim/nerdtree/pull/765) + - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) [#759](https://github.com/preservim/nerdtree/pull/759) + - Update doc with already existing mapping variables (asnr) [#699](https://github.com/preservim/nerdtree/pull/699) + - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) [#696](https://github.com/preservim/nerdtree/pull/696) + - Correct NERDTreeIgnore pattern in doc (cntoplolicon) [#648](https://github.com/preservim/nerdtree/pull/648) + - Remove empty segments when splitting path (sooth-sayer) [#574](https://github.com/preservim/nerdtree/pull/574) + - Suppress autocmds less agressively (wincent) [#578](https://github.com/preservim/nerdtree/pull/578) [#691](https://github.com/preservim/nerdtree/pull/691) - Add an Issues template to ask for more info initially. - - Fix markdown headers in readme (josephfrazier) [#676](https://github.com/scrooloose/nerdtree/pull/676) + - Fix markdown headers in readme (josephfrazier) [#676](https://github.com/preservim/nerdtree/pull/676) - Don't touch `@o` and `@h` registers when rendering - - Fix bug with files and directories with dollar signs (alegen) [#649](https://github.com/scrooloose/nerdtree/pull/649) - - Reuse/reopen existing window trees where possible [#244](https://github.com/scrooloose/nerdtree/pull/244) + - Fix bug with files and directories with dollar signs (alegen) [#649](https://github.com/preservim/nerdtree/pull/649) + - Reuse/reopen existing window trees where possible [#244](https://github.com/preservim/nerdtree/pull/244) - Remove NERDTree.previousBuf() - - Change color of arrow (Leeiio) [#630](https://github.com/scrooloose/nerdtree/pull/630) - - Improved a tip in README.markdown (ggicci) [#628](https://github.com/scrooloose/nerdtree/pull/628) - - Shorten delete confimration of empty directory to `y` (mikeperri) [#530](https://github.com/scrooloose/nerdtree/pull/530) - - Fix API call to open directory tree in window (devm33) [#533](https://github.com/scrooloose/nerdtree/pull/533) - - Change default arrows on non-Windows platforms (gwilk) [#546](https://github.com/scrooloose/nerdtree/pull/546) - - Update to README - combine cd and git clone (zwhitchcox) [#584](https://github.com/scrooloose/nerdtree/pull/584) - - Update to README - Tip: start NERDTree when vim starts (therealplato) [#593](https://github.com/scrooloose/nerdtree/pull/593) - - Escape filename when moving an open buffer (zacharyvoase) [#595](https://github.com/scrooloose/nerdtree/pull/595) - - Fixed incorrect :helptags command in README (curran) [#619](https://github.com/scrooloose/nerdtree/pull/619) - - Fixed incomplete escaping of folder arrows (adityanatraj) [#548](https://github.com/scrooloose/nerdtree/pull/548) - - Added NERDTreeCascadeSingleChildDir option (juanibiapina) [#558](https://github.com/scrooloose/nerdtree/pull/558) + - Change color of arrow (Leeiio) [#630](https://github.com/preservim/nerdtree/pull/630) + - Improved a tip in README.markdown (ggicci) [#628](https://github.com/preservim/nerdtree/pull/628) + - Shorten delete confimration of empty directory to `y` (mikeperri) [#530](https://github.com/preservim/nerdtree/pull/530) + - Fix API call to open directory tree in window (devm33) [#533](https://github.com/preservim/nerdtree/pull/533) + - Change default arrows on non-Windows platforms (gwilk) [#546](https://github.com/preservim/nerdtree/pull/546) + - Update to README - combine cd and git clone (zwhitchcox) [#584](https://github.com/preservim/nerdtree/pull/584) + - Update to README - Tip: start NERDTree when vim starts (therealplato) [#593](https://github.com/preservim/nerdtree/pull/593) + - Escape filename when moving an open buffer (zacharyvoase) [#595](https://github.com/preservim/nerdtree/pull/595) + - Fixed incorrect :helptags command in README (curran) [#619](https://github.com/preservim/nerdtree/pull/619) + - Fixed incomplete escaping of folder arrows (adityanatraj) [#548](https://github.com/preservim/nerdtree/pull/548) + - Added NERDTreeCascadeSingleChildDir option (juanibiapina) [#558](https://github.com/preservim/nerdtree/pull/558) - Replace strchars() with backward compatible workaround. - - Add support for copy command in Windows (SkylerLipthay) [#231](https://github.com/scrooloose/nerdtree/pull/231) + - Add support for copy command in Windows (SkylerLipthay) [#231](https://github.com/preservim/nerdtree/pull/231) - Fixed typo in README.markdown - :Helptags -> :helptags - Rename "primary" and "secondary" trees to "tab" and "window" trees. - Move a bunch of buffer level variables into the NERDTree and UI classes. diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown index 75b311a6..93a844a5 100644 --- a/sources_non_forked/nerdtree/README.markdown +++ b/sources_non_forked/nerdtree/README.markdown @@ -1,98 +1,261 @@ -The NERDTree -============= +# The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) -Introduction ------------- +## Introduction -The NERDTree is a file system explorer for the Vim editor. Using this plugin, -users can visually browse complex directory hierarchies, quickly open files for -reading or editing, and perform basic file system operations. +The NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations. -This plugin can also be extended with custom mappings using a special API. The -details of this API and of other NERDTree features are described in the -included documentation. +![NERDTree Screenshot](https://github.com/preservim/nerdtree/raw/master/screenshot.png) -![NERDTree Screenshot](https://github.com/scrooloose/nerdtree/raw/master/screenshot.png) +## Installation -Installation ------------- +Use your favorite plugin manager to install this plugin. [tpope/vim-pathogen](https://github.com/tpope/vim-pathogen), [VundleVim/Vundle.vim](https://github.com/VundleVim/Vundle.vim), [junegunn/vim-plug](https://github.com/junegunn/vim-plug), and [Shougo/dein.vim](https://github.com/Shougo/dein.vim) are some of the more popular ones. A lengthy discussion of these and other managers can be found on [vi.stackexchange.com](https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers). Basic instructions are provided below, but please **be sure to read, understand, and follow all the safety rules that come with your ~~power tools~~ plugin manager.** -#### [pathogen.vim](https://github.com/tpope/vim-pathogen) +If you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: [Vim screencast #75: Plugin managers](https://www.youtube.com/watch?v=X2_R3uxDN6g). - git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree - -Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`, and check out `:help NERDTree.txt`. +
+Pathogen +Pathogen is more of a runtime path manager than a plugin manager. You must clone the plugins' repositories yourself to a specific location, and Pathogen makes sure they are available in Vim. -#### [apt-vim](https://github.com/egalpin/apt-vim) +1. In the terminal, + ```bash + git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree + ``` +1. In your `vimrc`, + ```vim + call pathogen#infect() + syntax on + filetype plugin indent on + ``` +1. Restart Vim, and run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. +
- apt-vim install -y https://github.com/scrooloose/nerdtree.git +
+ Vundle -F.A.Q. ------- +1. Install Vundle, according to its instructions. +1. Add the following text to your `vimrc`. + ```vim + call vundle#begin() + Plugin 'preservim/nerdtree' + call vundle#end() + ``` +1. Restart Vim, and run the `:PluginInstall` statement to install your plugins. +
-> Is there any support for `git` flags? +
+ Vim-Plug -Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin). +1. Install Vim-Plug, according to its instructions. +1. Add the following text to your `vimrc`. +```vim +call plug#begin() + Plug 'preservim/nerdtree' +call plug#end() +``` +1. Restart Vim, and run the `:PlugInstall` statement to install your plugins. +
+
+ Dein + +1. Install Dein, according to its instructions. +1. Add the following text to your `vimrc`. + ```vim + call dein#begin() + call dein#add('preservim/nerdtree') + call dein#end() + ``` +1. Restart Vim, and run the `:call dein#install()` statement to install your plugins. +
+ +
+Vim 8+ packages + +If you are using Vim version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: + +```bash +git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree +vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q +``` +
+ +## Getting Started +After installing NERDTree, the best way to learn it is to turn on the Quick Help. Open NERDTree with the `:NERDTree` command, and press `?` to turn on the Quick Help, which will show you all the mappings and commands available in the NERDTree. Of course, your most complete source of information is the documentation: `:help NERDTree`. + +## NERDTree Plugins +NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible. + +* [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree. +* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders, +* [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight): Adds syntax highlighting to NERDTree based on filetype. +* [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin): Saves and restores the state of the NERDTree between sessions. +* [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops): 1) Highlights open files in a different color. 2) Closes a buffer directly from NERDTree. +* [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection): Enables NERDTree to open, delete, move, or copy multiple Visually-selected files at once. + +If any others should be listed, mention them in an issue or pull request. + + +## Frequently Asked Questions + +In the answers to these questions, you will see code blocks that you can put in your `vimrc` file. + +### How can I map a specific key or shortcut to open NERDTree? + +NERDTree doesn't create any shortcuts outside of the NERDTree window, so as not to overwrite any of your other shortcuts. Use the `nnoremap` command in your `vimrc`. You, of course, have many keys and NERDTree commands to choose from. Here are but a few examples. +```vim +nnoremap n :NERDTreeFocus +nnoremap :NERDTree +nnoremap :NERDTreeToggle +nnoremap :NERDTreeFind +``` + +### How do I open NERDTree automatically when Vim starts? +Each code block below is slightly different, as described in the `" Comment lines`. + +```vim +" Start NERDTree and leave the cursor in it. +autocmd VimEnter * NERDTree +``` --- - -> Can I have the nerdtree on every tab automatically? - -Nope. If this is something you want then chances are you aren't using tabs and -buffers as they were intended to be used. Read this -http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers - -If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) - +```vim +" Start NERDTree and put the cursor back in the other window. +autocmd VimEnter * NERDTree | wincmd p +``` --- -> How can I open a NERDTree automatically when vim starts up? - -Stick this in your vimrc: `autocmd vimenter * NERDTree` - +```vim +" Start NERDTree when Vim is started without file arguments. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif +``` --- -> How can I open a NERDTree automatically when vim starts up if no files were specified? - -Stick this in your vimrc: - - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif - -Note: Now start vim with plain `vim`, not `vim .` - +```vim +" Start NERDTree. If a file is specified, move the cursor to its window. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif +``` --- -> How can I open NERDTree automatically when vim starts up on opening a directory? - - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif - -This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. - -Note: Executing `vim ~/some-directory` will open NERDTree and a new edit window. `exe 'cd '.argv()[0]` sets the `pwd` of the new edit window to `~/some-directory` - +```vim +" Start NERDTree, unless a file or session is specified, eg. vim -S session_file.vim. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') && v:this_session == '' | NERDTree | endif +``` --- -> How can I map a specific key or shortcut to open NERDTree? +```vim +" Start NERDTree when Vim starts with a directory argument. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif +``` -Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): +### How can I close Vim or a tab automatically when NERDTree is the last window? - map :NERDTreeToggle +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\:\") | endif +``` --- -> How can I close vim if the only window left open is a NERDTree? +```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\:\") | endif +``` -Stick this in your vimrc: - - autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | 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 +``` --- -> Can I have different highlighting for different file extensions? +```vim +" Close the tab if NERDTree is the only window remaining in it. +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif +``` -See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 +### How can I prevent other buffers replacing NERDTree in its window? ---- -> How can I change default arrows? +```vim +" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. +autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif +``` -Use these variables in your vimrc. Note that below are default arrow symbols +### Can I have the same NERDTree on every tab automatically? - let g:NERDTreeDirArrowExpandable = '▸' - let g:NERDTreeDirArrowCollapsible = '▾' +```vim +" Open the existing NERDTree on each new tab. +autocmd BufWinEnter * if &buftype != 'quickfix' && getcmdwintype() == '' | silent NERDTreeMirror | endif +``` +or change your NERDTree-launching shortcut key like so: +```vim +" Mirror the NERDTree before showing it. This makes it the same on all tabs. +nnoremap :NERDTreeMirror:NERDTreeFocus +``` + +### How can I change the default arrows? + +```vim +let g:NERDTreeDirArrowExpandable = '?' +let g:NERDTreeDirArrowCollapsible = '?' +``` +The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details. + +### How can I show lines of files? + +```vim +let g:NERDTreeFileLines = 1 +``` + +Lines in the file are displayed as shown below. +``` +OpenFileOrExplorer(argv()[0]) | wincmd p | enew | wincmd p | endif | endif + +" Command to call the OpenFileOrExplorer function. +command! -n=? -complete=file -bar Edit :call OpenFileOrExplorer('') + +" Command-mode abbreviation to replace the :edit Vim command. +cnoreabbrev e Edit +``` diff --git a/sources_non_forked/nerdtree/_config.yml b/sources_non_forked/nerdtree/_config.yml new file mode 100644 index 00000000..c4192631 --- /dev/null +++ b/sources_non_forked/nerdtree/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim index 4391565e..d7246dc5 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -1,29 +1,50 @@ -if exists("g:loaded_nerdtree_autoload") +if exists('g:loaded_nerdtree_autoload') finish endif let g:loaded_nerdtree_autoload = 1 -let s:rootNERDTreePath = resolve(expand(":p:h:h")) -function! nerdtree#version(...) - let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash())) +let s:rootNERDTreePath = resolve(expand(':p:h:h')) + +"FUNCTION: nerdtree#version(...) {{{1 +" If any value is given as an argument, the entire line of text from the +" change log is shown for the current version; otherwise, only the version +" number is shown. +function! nerdtree#version(...) abort let l:text = 'Unknown' - let l:line = 0 - while l:line <= len(l:changelog) - if l:changelog[l:line] =~ '\d\+\.\d\+' - let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') - let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') - break - endif - let l:line += 1 - endwhile + try + let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash())) + let l:line = 0 + while l:line <= len(l:changelog) + if l:changelog[l:line] =~# '\d\+\.\d\+' + let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') + let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') + break + endif + let l:line += 1 + endwhile + catch + endtry return l:text endfunction " SECTION: General Functions {{{1 "============================================================ -function! nerdtree#slash() +" FUNCTION: nerdtree#closeTreeOnOpen() {{{2 +function! nerdtree#closeTreeOnOpen() abort + return g:NERDTreeQuitOnOpen == 1 || g:NERDTreeQuitOnOpen == 3 +endfunction +" FUNCTION: nerdtree#closeBookmarksOnOpen() {{{2 +function! nerdtree#closeBookmarksOnOpen() abort + return g:NERDTreeQuitOnOpen == 2 || g:NERDTreeQuitOnOpen == 3 +endfunction + +" FUNCTION: nerdtree#slash() {{{2 +" Return the path separator used by the underlying file system. Special +" consideration is taken for the use of the 'shellslash' option on Windows +" systems. +function! nerdtree#slash() abort if nerdtree#runningWindows() if exists('+shellslash') && &shellslash return '/' @@ -35,32 +56,9 @@ function! nerdtree#slash() return '/' endfunction -"FUNCTION: nerdtree#and(x,y) {{{2 -" Implements and() function for Vim <= 7.2 -function! nerdtree#and(x,y) - if exists("*and") - return and(a:x, a:y) - else - let l:x = a:x - let l:y = a:y - let l:n = 0 - let l:result = 0 - while l:x > 0 && l:y > 0 - if (l:x % 2) && (l:y % 2) - let l:result += float2nr(pow(2, l:n)) - endif - echomsg l:x . ", " . l:y . " => " l:result - let l:x = float2nr(l:x / 2) - let l:y = float2nr(l:y / 2) - let l:n += 1 - endwhile - return l:result - endif -endfunction - "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "inits a window tree in the current buffer if appropriate -function! nerdtree#checkForBrowse(dir) +function! nerdtree#checkForBrowse(dir) abort if !isdirectory(a:dir) return endif @@ -75,18 +73,18 @@ endfunction "FUNCTION: s:reuseWin(dir) {{{2 "finds a NERDTree buffer with root of dir, and opens it. function! s:reuseWin(dir) abort - let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p")) + let path = g:NERDTreePath.New(fnamemodify(a:dir, ':p')) - for i in range(1, bufnr("$")) + for i in range(1, bufnr('$')) unlet! nt - let nt = getbufvar(i, "NERDTree") + let nt = getbufvar(i, 'NERDTree') if empty(nt) continue endif if nt.isWinTree() && nt.root.path.equals(path) - call nt.setPreviousBuf(bufnr("#")) - exec "buffer " . i + call nt.setPreviousBuf(bufnr('#')) + exec 'buffer ' . i return 1 endif endfor @@ -96,19 +94,19 @@ endfunction " FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2 " completion function for the bookmark commands -function! nerdtree#completeBookmarks(A,L,P) +function! nerdtree#completeBookmarks(A,L,P) abort return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') endfunction -"FUNCTION: nerdtree#compareNodes(dir) {{{2 -function! nerdtree#compareNodes(n1, n2) - return a:n1.path.compareTo(a:n2.path) +"FUNCTION: nerdtree#compareNodes(n1, n2) {{{2 +function! nerdtree#compareNodes(n1, n2) abort + return nerdtree#compareNodePaths(a:n1.path, a:n2.path) endfunction -"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 -function! nerdtree#compareNodesBySortKey(n1, n2) - let sortKey1 = a:n1.path.getSortKey() - let sortKey2 = a:n2.path.getSortKey() +"FUNCTION: nerdtree#compareNodePaths(p1, p2) {{{2 +function! nerdtree#compareNodePaths(p1, p2) abort + let sortKey1 = a:p1.getSortKey() + let sortKey2 = a:p2.getSortKey() let i = 0 while i < min([len(sortKey1), len(sortKey2)]) " Compare chunks upto common length. @@ -120,12 +118,12 @@ function! nerdtree#compareNodesBySortKey(n1, n2) elseif sortKey1[i] ># sortKey2[i] return 1 endif - elseif type(sortKey1[i]) == v:t_number + elseif type(sortKey1[i]) == type(0) return -1 - elseif type(sortKey2[i]) == v:t_number + elseif type(sortKey2[i]) == type(0) return 1 endif - let i = i + 1 + let i += 1 endwhile " Keys are identical upto common length. @@ -142,7 +140,7 @@ endfunction " FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 " Issue a deprecation warning for a:func. If a second arg is given, use this " as the deprecation message -function! nerdtree#deprecated(func, ...) +function! nerdtree#deprecated(func, ...) abort let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated' if !exists('s:deprecationWarnings') @@ -156,22 +154,25 @@ endfunction " FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2 " Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration -function! nerdtree#exec(cmd, ignoreAll) - let old_ei = &ei +function! nerdtree#exec(cmd, ignoreAll) abort + let old_ei = &eventignore if a:ignoreAll - set ei=all + set eventignore=all endif - exec a:cmd - let &ei = old_ei + try + exec a:cmd + finally + let &eventignore = old_ei + endtry endfunction " FUNCTION: nerdtree#has_opt(options, name) {{{2 -function! nerdtree#has_opt(options, name) - return has_key(a:options, a:name) && a:options[a:name] == 1 +function! nerdtree#has_opt(options, name) abort + return has_key(a:options, a:name) && a:options[a:name] ==# 1 endfunction " FUNCTION: nerdtree#loadClassFiles() {{{2 -function! nerdtree#loadClassFiles() +function! nerdtree#loadClassFiles() abort runtime lib/nerdtree/path.vim runtime lib/nerdtree/menu_controller.vim runtime lib/nerdtree/menu_item.vim @@ -189,7 +190,7 @@ function! nerdtree#loadClassFiles() endfunction " FUNCTION: nerdtree#postSourceActions() {{{2 -function! nerdtree#postSourceActions() +function! nerdtree#postSourceActions() abort call g:NERDTreeBookmark.CacheBookmarks(1) call nerdtree#ui_glue#createDefaultBindings() @@ -197,14 +198,72 @@ function! nerdtree#postSourceActions() runtime! nerdtree_plugin/**/*.vim endfunction -"FUNCTION: nerdtree#runningWindows(dir) {{{2 -function! nerdtree#runningWindows() - return has("win16") || has("win32") || has("win64") +"FUNCTION: nerdtree#runningWindows() {{{2 +function! nerdtree#runningWindows() abort + return has('win16') || has('win32') || has('win64') endfunction -"FUNCTION: nerdtree#runningCygwin(dir) {{{2 -function! nerdtree#runningCygwin() - return has("win32unix") +"FUNCTION: nerdtree#runningCygwin() {{{2 +function! nerdtree#runningCygwin() abort + return has('win32unix') +endfunction + +"FUNCTION: nerdtree#runningMac() {{{2 +function! nerdtree#runningMac() abort + return has('gui_mac') || has('gui_macvim') || has('mac') || has('osx') +endfunction + +" FUNCTION: nerdtree#osDefaultCaseSensitiveFS() {{{2 +function! nerdtree#osDefaultCaseSensitiveFS() abort + return s:osDefaultCaseSensitiveFS +endfunction + +" FUNCTION: nerdtree#caseSensitiveFS() {{{2 +function! nerdtree#caseSensitiveFS() abort + return g:NERDTreeCaseSensitiveFS == 1 || + \((g:NERDTreeCaseSensitiveFS == 2 || g:NERDTreeCaseSensitiveFS == 3) && + \nerdtree#osDefaultCaseSensitiveFS()) +endfunction + +"FUNCTION: nerdtree#pathEquals(lhs, rhs) {{{2 +function! nerdtree#pathEquals(lhs, rhs) abort + if nerdtree#caseSensitiveFS() + return a:lhs ==# a:rhs + else + return a:lhs ==? a:rhs + 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 @@ -215,16 +274,16 @@ endfunction " "Args: "msg: the message to echo -function! nerdtree#echo(msg) +function! nerdtree#echo(msg) abort redraw - echomsg empty(a:msg) ? "" : ("NERDTree: " . a:msg) + echomsg empty(a:msg) ? '' : ('NERDTree: ' . a:msg) endfunction "FUNCTION: nerdtree#echoError {{{2 "Wrapper for nerdtree#echo, sets the message type to errormsg for this message "Args: "msg: the message to echo -function! nerdtree#echoError(msg) +function! nerdtree#echoError(msg) abort echohl errormsg call nerdtree#echo(a:msg) echohl normal @@ -234,15 +293,23 @@ endfunction "Wrapper for nerdtree#echo, sets the message type to warningmsg for this message "Args: "msg: the message to echo -function! nerdtree#echoWarning(msg) +function! nerdtree#echoWarning(msg) abort echohl warningmsg call nerdtree#echo(a:msg) echohl normal endfunction "FUNCTION: nerdtree#renderView {{{2 -function! nerdtree#renderView() +function! nerdtree#renderView() abort call b:NERDTree.render() endfunction +if nerdtree#runningWindows() + let s:osDefaultCaseSensitiveFS = 0 +elseif nerdtree#runningMac() + let s:osDefaultCaseSensitiveFS = 0 +else + let s:osDefaultCaseSensitiveFS = 1 +endif + " vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim index f0458680..c5c96181 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim @@ -1,79 +1,86 @@ -if exists("g:loaded_nerdtree_ui_glue_autoload") +if exists('g:loaded_nerdtree_ui_glue_autoload') finish endif let g:loaded_nerdtree_ui_glue_autoload = 1 " FUNCTION: nerdtree#ui_glue#createDefaultBindings() {{{1 -function! nerdtree#ui_glue#createDefaultBindings() +function! nerdtree#ui_glue#createDefaultBindings() abort let s = '' . s:SID() . '_' call NERDTreeAddKeyMap({ 'key': '', 'scope': 'all', 'callback': s . 'handleMiddleMouse' }) - call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': 'all', 'callback': s.'handleLeftClick' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'DirNode', 'callback': s.'activateDirNode' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'FileNode', 'callback': s.'activateFileNode' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'Bookmark', 'callback': s.'activateBookmark' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'all', 'callback': s.'activateAll' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s."customOpenFile"}) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s."customOpenDir"}) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s."customOpenBookmark"}) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'all', 'callback': s."activateAll" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s.'customOpenFile'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s.'customOpenDir'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s.'customOpenBookmark'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'all', 'callback': s.'activateAll' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewBookmark" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'DirNode', 'callback': s.'activateDirNode' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'FileNode', 'callback': s.'activateFileNode' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'Bookmark', 'callback': s.'activateBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Bookmark', 'callback': s.'previewBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'all', 'callback': s.'activateAll' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'FileNode', 'callback': s.'openHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Bookmark', 'callback': s.'openHSplitBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'FileNode', 'callback': s.'openVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Bookmark', 'callback': s.'openVSplitBookmark' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'FileNode', 'callback': s.'previewNodeCurrent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'FileNode', 'callback': s.'previewNodeHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeHSplitBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'FileNode', 'callback': s.'previewNodeVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeVSplitBookmark' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': 'DirNode', 'callback': s.'openNodeRecursively' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': 'all', 'callback': s . 'upDirCurrentRootClosed' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': 'all', 'callback': s . 'upDirCurrentRootOpen' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': 'Node', 'callback': s . 'chRoot' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': 'Node', 'callback': s.'chCwd' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': 'all', 'callback': s.'closeTreeWindow' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': "nerdtree#ui_glue#chRootCwd" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': 'all', 'callback': 'nerdtree#ui_glue#chRootCwd' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': 'all', 'callback': s.'refreshRoot' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': 'Node', 'callback': s.'refreshCurrent' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': 'all', 'callback': s.'displayHelp' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': 'all', 'callback': s.'toggleZoom' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': 'all', 'callback': s.'toggleShowHidden' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': 'all', 'callback': s.'toggleIgnoreFilter' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': 'all', 'callback': s.'toggleShowFiles' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': 'all', 'callback': s.'toggleShowBookmarks' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFileLines, 'scope': 'all', 'callback': s.'toggleShowFileLines' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': 'Node', 'callback': s.'closeCurrentDir' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': 'DirNode', 'callback': s.'closeChildren' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': 'Node', 'callback': s.'showMenu' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) - 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:NERDTreeMapJumpParent, 'scope': 'Node', 'callback': s.'jumpToParent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': 'Node', 'callback': s.'jumpToFirstChild' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': 'Node', 'callback': s.'jumpToLastChild' }) + 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' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Bookmark', 'callback': s . 'openInNewTab' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': 'DirNode', 'callback': s.'openExplorer' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': 'FileNode', 'callback': s.'openExplorer' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': 'Bookmark', 'callback': s.'deleteBookmark' }) endfunction @@ -81,20 +88,20 @@ endfunction "============================================================ "FUNCTION: s:customOpenFile() {{{1 -" Open file node with the "custom" key, initially . -function! s:customOpenFile(node) +" Open file node with the 'custom' key, initially . +function! s:customOpenFile(node) abort call a:node.activate(s:initCustomOpenArgs().file) endfunction "FUNCTION: s:customOpenDir() {{{1 -" Open directory node with the "custom" key, initially . -function! s:customOpenDir(node) +" Open directory node with the 'custom' key, initially . +function! s:customOpenDir(node) abort call s:activateDirNode(a:node, s:initCustomOpenArgs().dir) endfunction "FUNCTION: s:customOpenBookmark() {{{1 -" Open bookmark node with the "custom" key, initially . -function! s:customOpenBookmark(node) +" Open bookmark node with the 'custom' key, initially . +function! s:customOpenBookmark(node) abort if a:node.path.isDirectory call a:node.activate(b:NERDTree, s:initCustomOpenArgs().dir) else @@ -103,23 +110,30 @@ function! s:customOpenBookmark(node) endfunction "FUNCTION: s:initCustomOpenArgs() {{{1 -" Make sure NERDTreeCustomOpenArgs has needed keys -function! s:initCustomOpenArgs() - let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) - return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep') +function! s:initCustomOpenArgs() abort + let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}, 'dir': {}} + try + let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) + call extend(g:NERDTreeCustomOpenArgs, l:defaultOpenArgs, 'keep') + catch /^Vim(\a\+):E712:/ + call nerdtree#echoWarning('g:NERDTreeCustomOpenArgs is not set properly. Using default value.') + let g:NERDTreeCustomOpenArgs = l:defaultOpenArgs + finally + return g:NERDTreeCustomOpenArgs + endtry endfunction "FUNCTION: s:activateAll() {{{1 "handle the user activating the updir line -function! s:activateAll() - if getline(".") ==# g:NERDTreeUI.UpDirLine() +function! s:activateAll() abort + if getline('.') ==# g:NERDTreeUI.UpDirLine() return nerdtree#ui_glue#upDir(0) endif endfunction " FUNCTION: s:activateDirNode(directoryNode, options) {{{1 " Open a directory with optional options -function! s:activateDirNode(directoryNode, ...) +function! s:activateDirNode(directoryNode, ...) abort if a:directoryNode.isRoot() && a:directoryNode.isOpen call nerdtree#echo('cannot close tree root') @@ -131,21 +145,21 @@ endfunction "FUNCTION: s:activateFileNode() {{{1 "handle the user activating a tree node -function! s:activateFileNode(node) - call a:node.activate({'reuse': 'all', 'where': 'p'}) +function! s:activateFileNode(node) abort + call a:node.activate({'reuse': 'all', 'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()}) endfunction "FUNCTION: s:activateBookmark(bookmark) {{{1 "handle the user activating a bookmark -function! s:activateBookmark(bm) - call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {}) +function! s:activateBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) endfunction " FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 " Associate the current node with the given name -function! nerdtree#ui_glue#bookmarkNode(...) +function! nerdtree#ui_glue#bookmarkNode(...) abort let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} let name = a:1 if empty(name) let name = currentNode.path.getLastPathComponent(0) @@ -154,39 +168,39 @@ function! nerdtree#ui_glue#bookmarkNode(...) call currentNode.bookmark(name) call b:NERDTree.render() catch /^NERDTree.IllegalBookmarkNameError/ - call nerdtree#echo("bookmark names must not contain spaces") + call nerdtree#echo('bookmark names must not contain spaces') endtry else - call nerdtree#echo("select a node first") + call nerdtree#echo('select a node first') endif endfunction " FUNCTION: s:chCwd(node) {{{1 -function! s:chCwd(node) +function! s:chCwd(node) abort try call a:node.path.changeToDir() catch /^NERDTree.PathChangeError/ - call nerdtree#echoWarning("could not change cwd") + call nerdtree#echoWarning('could not change cwd') endtry endfunction " FUNCTION: s:chRoot(node) {{{1 " changes the current root to the selected one -function! s:chRoot(node) +function! s:chRoot(node) abort call b:NERDTree.changeRoot(a:node) endfunction " FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1 " Change the NERDTree root to match the current working directory. -function! nerdtree#ui_glue#chRootCwd() +function! nerdtree#ui_glue#chRootCwd() abort NERDTreeCWD endfunction " FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1 -function! nerdtree#ui_glue#clearBookmarks(bookmarks) +function! nerdtree#ui_glue#clearBookmarks(bookmarks) abort if a:bookmarks ==# '' let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} call currentNode.clearBookmarks() endif else @@ -201,7 +215,7 @@ endfunction " FUNCTION: s:closeChildren(node) {{{1 " closes all childnodes of the current node -function! s:closeChildren(node) +function! s:closeChildren(node) abort call a:node.closeChildren() call b:NERDTree.render() call a:node.putCursorHere(0, 0) @@ -209,7 +223,7 @@ endfunction " FUNCTION: s:closeCurrentDir(node) {{{1 " Close the parent directory of the current node. -function! s:closeCurrentDir(node) +function! s:closeCurrentDir(node) abort if a:node.isRoot() call nerdtree#echo('cannot close parent of tree root') @@ -234,30 +248,30 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window -function! s:closeTreeWindow() - if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 - exec "buffer " . b:NERDTree.previousBuf() +function! s:closeTreeWindow() abort + if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() !=# -1 + exec 'buffer ' . b:NERDTree.previousBuf() else - if winnr("$") > 1 + if winnr('$') > 1 call g:NERDTree.Close() else - call nerdtree#echo("Cannot close last window") + call nerdtree#echo('Cannot close last window') endif endif endfunction " FUNCTION: s:deleteBookmark(bookmark) {{{1 " Prompt the user to confirm the deletion of the selected bookmark. -function! s:deleteBookmark(bookmark) - let l:message = "Delete the bookmark \"" . a:bookmark.name - \ . "\" from the bookmark list?" +function! s:deleteBookmark(bookmark) abort + let l:message = 'Delete the bookmark "' . a:bookmark.name + \ . '" from the bookmark list?' let l:choices = "&Yes\n&No" echo | redraw let l:selection = confirm(l:message, l:choices, 1, 'Warning') - if l:selection != 1 + if l:selection !=# 1 call nerdtree#echo('bookmark not deleted') return endif @@ -274,21 +288,27 @@ endfunction " FUNCTION: s:displayHelp() {{{1 " toggles the help display -function! s:displayHelp() +function! s:displayHelp() abort call b:NERDTree.ui.toggleHelp() call b:NERDTree.render() call b:NERDTree.ui.centerView() endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 -function! s:findAndRevealPath(pathStr) +function! s:findAndRevealPath(pathStr) abort let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') + let l:revealOpts = {} if empty(l:pathStr) call nerdtree#echoWarning('no file for the current buffer') return endif + if !filereadable(l:pathStr) + let l:pathStr = fnamemodify(l:pathStr, ':h') + let l:revealOpts['open'] = 1 + endif + try let l:pathStr = g:NERDTreePath.Resolve(l:pathStr) let l:pathObj = g:NERDTreePath.New(l:pathStr) @@ -322,22 +342,22 @@ function! s:findAndRevealPath(pathStr) call b:NERDTree.ui.setShowHidden(1) endif - let l:node = b:NERDTree.root.reveal(l:pathObj) + let l:node = b:NERDTree.root.reveal(l:pathObj, l:revealOpts) call b:NERDTree.render() call l:node.putCursorHere(1, 0) endfunction "FUNCTION: s:handleLeftClick() {{{1 "Checks if the click should open the current node -function! s:handleLeftClick() +function! s:handleLeftClick() abort let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} "the dir arrows are multibyte chars, and vim's string functions only "deal with single bytes - so split the line up with the hack below and "take the line substring manually - let line = split(getline(line(".")), '\zs') - let startToCur = "" + let line = split(getline(line('.')), '\zs') + let startToCur = '' for i in range(0,len(line)-1) let startToCur .= line[i] endfor @@ -355,7 +375,7 @@ function! s:handleLeftClick() if currentNode.path.isDirectory call currentNode.activate() else - call currentNode.activate({'reuse': 'all', 'where': 'p'}) + call currentNode.activate({'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}) endif return endif @@ -364,7 +384,7 @@ function! s:handleLeftClick() endfunction " FUNCTION: s:handleMiddleMouse() {{{1 -function! s:handleMiddleMouse() +function! s:handleMiddleMouse() abort " A middle mouse click does not automatically position the cursor as one " would expect. Forcing the execution of a regular left mouse click here @@ -387,17 +407,17 @@ endfunction " FUNCTION: nerdtree#ui_glue#invokeKeyMap(key) {{{1 "this is needed since I cant figure out how to invoke dict functions from a "key map -function! nerdtree#ui_glue#invokeKeyMap(key) +function! nerdtree#ui_glue#invokeKeyMap(key) abort call g:NERDTreeKeyMap.Invoke(a:key) endfunction " FUNCTION: s:jumpToFirstChild(node) {{{1 -function! s:jumpToFirstChild(node) +function! s:jumpToFirstChild(node) abort call s:jumpToChild(a:node, 0) endfunction " FUNCTION: s:jumpToLastChild(node) {{{1 -function! s:jumpToLastChild(node) +function! s:jumpToLastChild(node) abort call s:jumpToChild(a:node, 1) endfunction @@ -407,7 +427,7 @@ endfunction " Args: " node: the node on which the cursor currently sits " last: 1 (true) if jumping to last child, 0 (false) if jumping to first -function! s:jumpToChild(node, last) +function! s:jumpToChild(node, last) abort let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node if l:node.isRoot() @@ -426,7 +446,7 @@ endfunction " FUNCTION: s:jumpToParent(node) {{{1 " Move the cursor to the parent of the specified node. For a cascade, move to " the parent of the cascade's first node. At the root node, do nothing. -function! s:jumpToParent(node) +function! s:jumpToParent(node) abort let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node if l:node.isRoot() @@ -444,18 +464,18 @@ endfunction " FUNCTION: s:jumpToRoot() {{{1 " moves the cursor to the root node -function! s:jumpToRoot() +function! s:jumpToRoot() abort call b:NERDTree.root.putCursorHere(1, 0) call b:NERDTree.ui.centerView() endfunction " FUNCTION: s:jumpToNextSibling(node) {{{1 -function! s:jumpToNextSibling(node) +function! s:jumpToNextSibling(node) abort call s:jumpToSibling(a:node, 1) endfunction " FUNCTION: s:jumpToPrevSibling(node) {{{1 -function! s:jumpToPrevSibling(node) +function! s:jumpToPrevSibling(node) abort call s:jumpToSibling(a:node, 0) endfunction @@ -465,7 +485,7 @@ endfunction " Args: " node: the node on which the cursor currently sits " forward: 0 to jump to previous sibling, 1 to jump to next sibling -function! s:jumpToSibling(node, forward) +function! s:jumpToSibling(node, forward) abort let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node let l:sibling = l:node.findSibling(a:forward) @@ -477,10 +497,25 @@ function! s:jumpToSibling(node, forward) 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. -function! nerdtree#ui_glue#openBookmark(name) +" implementation for the :OpenBookmark command. +function! nerdtree#ui_glue#openBookmark(name) abort try let l:bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) catch /^NERDTree.BookmarkNotFoundError/ @@ -489,48 +524,71 @@ function! nerdtree#ui_glue#openBookmark(name) endtry if l:bookmark.path.isDirectory call l:bookmark.open(b:NERDTree) - else - call l:bookmark.open(b:NERDTree, {'where': 'p'}) + return endif + + call l:bookmark.open(b:NERDTree, s:initCustomOpenArgs().file) endfunction " FUNCTION: s:openHSplit(target) {{{1 -function! s:openHSplit(target) - call a:target.activate({'where': 'h'}) +function! s:openHSplit(target) abort + call a:target.activate({'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()}) endfunction " FUNCTION: s:openVSplit(target) {{{1 -function! s:openVSplit(target) - call a:target.activate({'where': 'v'}) +function! s:openVSplit(target) abort + call a:target.activate({'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()}) +endfunction + +"FUNCTION: s:openHSplitBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:openHSplitBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) +endfunction + +"FUNCTION: s:openVSplitBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:openVSplitBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) +endfunction + +" FUNCTION: s:previewHSplitBookmark(bookmark) {{{1 +function! s:previewNodeHSplitBookmark(bookmark) abort + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {}) +endfunction + +" FUNCTION: s:previewVSplitBookmark(bookmark) {{{1 +function! s:previewNodeVSplitBookmark(bookmark) abort + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'v', 'keepopen': 1} : {}) endfunction " FUNCTION: s:openExplorer(node) {{{1 -function! s:openExplorer(node) +function! s:openExplorer(node) abort call a:node.openExplorer() endfunction " FUNCTION: s:openInNewTab(target) {{{1 -function! s:openInNewTab(target) - let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't'}) +function! s:openInNewTab(target) abort + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen()}) call l:opener.open(a:target) endfunction " FUNCTION: s:openInNewTabSilent(target) {{{1 -function! s:openInNewTabSilent(target) - let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'stay': 1}) +function! s:openInNewTabSilent(target) abort + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen(), 'stay': 1}) call l:opener.open(a:target) endfunction " FUNCTION: s:openNodeRecursively(node) {{{1 -function! s:openNodeRecursively(node) - call nerdtree#echo("Recursively opening node. Please wait...") +function! s:openNodeRecursively(node) abort + call nerdtree#echo('Recursively opening node. Please wait...') call a:node.openRecursively() call b:NERDTree.render() - call nerdtree#echo("") + call nerdtree#echo('') endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 -function! s:previewBookmark(bookmark) +function! s:previewBookmark(bookmark) abort if a:bookmark.path.isDirectory execute 'NERDTreeFind '.a:bookmark.path.str() else @@ -539,67 +597,68 @@ function! s:previewBookmark(bookmark) endfunction "FUNCTION: s:previewNodeCurrent(node) {{{1 -function! s:previewNodeCurrent(node) +function! s:previewNodeCurrent(node) abort call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) endfunction "FUNCTION: s:previewNodeHSplit(node) {{{1 -function! s:previewNodeHSplit(node) +function! s:previewNodeHSplit(node) abort call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) endfunction "FUNCTION: s:previewNodeVSplit(node) {{{1 -function! s:previewNodeVSplit(node) +function! s:previewNodeVSplit(node) abort call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) endfunction " FUNCTION: nerdtree#ui_glue#revealBookmark(name) {{{1 " put the cursor on the node associate with the given name -function! nerdtree#ui_glue#revealBookmark(name) +function! nerdtree#ui_glue#revealBookmark(name) abort try let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) call targetNode.putCursorHere(0, 1) catch /^NERDTree.BookmarkNotFoundError/ - call nerdtree#echo("Bookmark isnt cached under the current root") + call nerdtree#echo('Bookmark isn''t cached under the current root') endtry endfunction " FUNCTION: s:refreshRoot() {{{1 " Reloads the current root. All nodes below this will be lost and the root dir " will be reloaded. -function! s:refreshRoot() +function! s:refreshRoot() abort if !g:NERDTree.IsOpen() return endif - call nerdtree#echo("Refreshing the root node. This could take a while...") + call nerdtree#echo('Refreshing the root node. This could take a while...') let l:curWin = winnr() - call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1) + call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', 1) call b:NERDTree.root.refresh() call b:NERDTree.render() redraw - call nerdtree#exec(l:curWin . "wincmd w", 1) - call nerdtree#echo("") + call nerdtree#exec(l:curWin . 'wincmd w', 1) + call nerdtree#echo('') endfunction " FUNCTION: s:refreshCurrent(node) {{{1 " refreshes the root for the current node -function! s:refreshCurrent(node) +function! s:refreshCurrent(node) abort let node = a:node if !node.path.isDirectory let node = node.parent endif - call nerdtree#echo("Refreshing node. This could take a while...") + call nerdtree#echo('Refreshing node. This could take a while...') call node.refresh() call b:NERDTree.render() - call nerdtree#echo("") + call nerdtree#echo('') endfunction " FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 -function! nerdtree#ui_glue#setupCommands() +function! nerdtree#ui_glue#setupCommands() abort command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('') command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('') + command! -n=? -complete=dir -bar NERDTreeExplore :call g:NERDTreeCreator.CreateExploreTree('') command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() @@ -610,42 +669,48 @@ function! nerdtree#ui_glue#setupCommands() endfunction " Function: s:SID() {{{1 -function s:SID() - if !exists("s:sid") +function! s:SID() abort + if !exists('s:sid') let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') endif return s:sid endfun " FUNCTION: s:showMenu(node) {{{1 -function! s:showMenu(node) +function! s:showMenu(node) abort let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled()) call mc.showMenu() endfunction " FUNCTION: s:toggleIgnoreFilter() {{{1 -function! s:toggleIgnoreFilter() +function! s:toggleIgnoreFilter() abort call b:NERDTree.ui.toggleIgnoreFilter() endfunction " FUNCTION: s:toggleShowBookmarks() {{{1 -function! s:toggleShowBookmarks() +function! s:toggleShowBookmarks() abort call b:NERDTree.ui.toggleShowBookmarks() endfunction " FUNCTION: s:toggleShowFiles() {{{1 -function! s:toggleShowFiles() +function! s:toggleShowFiles() abort call b:NERDTree.ui.toggleShowFiles() endfunction " FUNCTION: s:toggleShowHidden() {{{1 " toggles the display of hidden files -function! s:toggleShowHidden() +function! s:toggleShowHidden() abort call b:NERDTree.ui.toggleShowHidden() endfunction +" FUNCTION: s:toggleShowFileLines() {{{1 +" toggles the display of hidden files +function! s:toggleShowFileLines() abort + call b:NERDTree.ui.toggleShowFileLines() +endfunction + " FUNCTION: s:toggleZoom() {{{1 -function! s:toggleZoom() +function! s:toggleZoom() abort call b:NERDTree.ui.toggleZoom() endfunction @@ -655,7 +720,7 @@ endfunction " Args: " preserveState: if 1, the current root is left open when the new tree is " rendered; if 0, the current root node is closed -function! nerdtree#ui_glue#upDir(preserveState) +function! nerdtree#ui_glue#upDir(preserveState) abort try call b:NERDTree.root.cacheParent() @@ -679,12 +744,12 @@ function! nerdtree#ui_glue#upDir(preserveState) endfunction " FUNCTION: s:upDirCurrentRootOpen() {{{1 -function! s:upDirCurrentRootOpen() +function! s:upDirCurrentRootOpen() abort call nerdtree#ui_glue#upDir(1) endfunction " FUNCTION: s:upDirCurrentRootClosed() {{{1 -function! s:upDirCurrentRootClosed() +function! s:upDirCurrentRootClosed() abort call nerdtree#ui_glue#upDir(0) endfunction diff --git a/sources_non_forked/nerdtree/doc/NERDTree.txt b/sources_non_forked/nerdtree/doc/NERDTree.txt index 14f70782..f8a1fdc1 100644 --- a/sources_non_forked/nerdtree/doc/NERDTree.txt +++ b/sources_non_forked/nerdtree/doc/NERDTree.txt @@ -116,14 +116,23 @@ The following features and functionality are provided by the NERDTree: :NERDTreeVCS (opens root of repository containing CWD) < :NERDTreeFromBookmark *:NERDTreeFromBookmark* - Opens a fresh NERDTree with the root initialized to the dir for + Opens a fresh NERDTree with the root initialized to the directory for . The only reason to use this command over :NERDTree is for the completion (which is for bookmarks rather than directories). :NERDTreeToggle [ | ] *:NERDTreeToggle* If a NERDTree already exists for this tab, it is reopened and rendered - again. If no NERDTree exists for this tab then this command acts the - same as the |:NERDTree| command. + again. If or is given, the root of NERDTree + is set to that path. If no NERDTree exists for this tab then this command + acts the same as the |:NERDTree| command. + +:NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* + Like |:NERDTreeToggle|, but searches up the directory tree to find the top of + the version control system repository, and roots the NERDTree there. It + works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A + couple of examples: > + :NERDTreeToggleVCS /home/marty/nerdtree/doc (opens /home/marty/nerdtree) + :NERDTreeToggleVCS (opens root of repository containing CWD) :NERDTreeFocus *:NERDTreeFocus* Opens (or reopens) the NERDTree if it is not currently visible; @@ -240,7 +249,7 @@ Key Description help-tag~ o........Open files, directories and bookmarks......................|NERDTree-o| go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go| - Open selected bookmark dir in current NERDTree + Find selected bookmark directory in current NERDTree t........Open selected node/bookmark in a new tab...................|NERDTree-t| T........Same as 't' but keep the focus on the current tab..........|NERDTree-T| i........Open selected file in a split window.......................|NERDTree-i| @@ -251,10 +260,10 @@ gs.......Same as s, but leave the cursor on the NERDTree...........|NERDTree-gs| O........Recursively open the selected directory....................|NERDTree-O| x........Close the current nodes parent.............................|NERDTree-x| X........Recursively close all children of the current node.........|NERDTree-X| -e........Edit the current dir.......................................|NERDTree-e| +e........Edit the current directory.................................|NERDTree-e| double-click....same as |NERDTree-o|. -middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for dirs. +middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for directories. D........Delete the current bookmark ...............................|NERDTree-D| @@ -265,19 +274,20 @@ J........Jump down inside directories at the current tree depth.....|NERDTree-J| ....Jump down to next sibling of the current directory.......|NERDTree-C-J| ....Jump up to previous sibling of the current directory.....|NERDTree-C-K| -C........Change the tree root to the selected dir...................|NERDTree-C| +C........Change the tree root to the selected directory.............|NERDTree-C| u........Move the tree root up one directory........................|NERDTree-u| U........Same as 'u' except the old root node is left open..........|NERDTree-U| r........Recursively refresh the current directory..................|NERDTree-r| R........Recursively refresh the current root.......................|NERDTree-R| m........Display the NERDTree menu..................................|NERDTree-m| -cd.......Change the CWD to the dir of the selected node............|NERDTree-cd| +cd.......Change the CWD to the directory of the selected node......|NERDTree-cd| CD.......Change tree root to the CWD...............................|NERDTree-CD| 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-FL| q........Close the NERDTree window..................................|NERDTree-q| A........Zoom (maximize/minimize) the NERDTree window...............|NERDTree-A| @@ -309,9 +319,8 @@ Applies to: files. If a file node or a bookmark that links to a file is selected, it is opened in the previous window, but the cursor does not move. -If a bookmark that links to a directory is selected, that directory is found -in the current NERDTree. If the directory couldn't be found, a new NERDTree is -created. +If a bookmark that links to a directory is selected then that directory +becomes the new root. The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see |NERDTree-o|). @@ -341,7 +350,7 @@ The same as |NERDTree-t| except that the focus is kept in the current tab. *NERDTree-i* Default key: i Map setting: *NERDTreeMapOpenSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. Opens the selected file in a new split window and puts the cursor in the new window. @@ -350,7 +359,7 @@ window. *NERDTree-gi* Default key: gi Map setting: *NERDTreeMapPreviewSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. The same as |NERDTree-i| except that the cursor is not moved. @@ -361,7 +370,7 @@ The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see *NERDTree-s* Default key: s Map setting: *NERDTreeMapOpenVSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. Opens the selected file in a new vertically split window and puts the cursor in the new window. @@ -370,7 +379,7 @@ in the new window. *NERDTree-gs* Default key: gs Map setting: *NERDTreeMapPreviewVSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. The same as |NERDTree-s| except that the cursor is not moved. @@ -461,7 +470,7 @@ Jump to the first child of the current nodes parent. If the cursor is already on the first node then do the following: * loop back thru the siblings of the current nodes parent until we find an - open dir with children + open directory with children * go to the first child of that node ------------------------------------------------------------------------------ @@ -474,7 +483,7 @@ Jump to the last child of the current nodes parent. If the cursor is already on the last node then do the following: * loop forward thru the siblings of the current nodes parent until we find - an open dir with children + an open directory with children * go to the last child of that node ------------------------------------------------------------------------------ @@ -508,7 +517,7 @@ Default key: u Map setting: *NERDTreeMapUpdir* Applies to: no restrictions. -Move the tree root up a dir (like doing a "cd .."). +Move the tree root up a directory (like doing a "cd .."). ------------------------------------------------------------------------------ *NERDTree-U* @@ -524,8 +533,8 @@ Default key: r Map setting: *NERDTreeMapRefresh* Applies to: files and directories. -If a dir is selected, recursively refresh that dir, i.e. scan the filesystem -for changes and represent them in the tree. +If a directory is selected, recursively refresh that directory, i.e. scan the +filesystem for changes and represent them in the tree. If a file node is selected then the above is done on it's parent. @@ -593,6 +602,14 @@ Applies to: no restrictions. Toggles whether the bookmarks table is displayed. +------------------------------------------------------------------------------ + *NERDTree-FL* +Default key: FL +Map setting: *NERDTreeMapToggleFileLines* +Applies to: no restrictions. + +Toggles whether the number of lines in files is displayed. + ------------------------------------------------------------------------------ *NERDTree-q* Default key: q @@ -626,8 +643,8 @@ file explorers have. The script comes with two default menu plugins: exec_menuitem.vim and fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for -creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a -menu item to execute executable files. +creating/deleting/moving/copying files and directories. exec_menuitem.vim +provides a menu item to execute executable files. Related tags: |NERDTree-m| |NERDTreeApi| @@ -665,6 +682,9 @@ the NERDTree. These settings should be set in your vimrc, using `:let`. |NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering. +|NERDTreeCaseSensitiveFS| Tells the NERDTree whether or not it is + running in on a case sensitive file system. + |NERDTreeCaseSensitiveSort| Tells the NERDTree whether to be case sensitive or not when sorting nodes. @@ -800,6 +820,26 @@ Default: 3 This setting controls the "sensitivity" of the NERDTree auto centering. See |NERDTreeAutoCenter| for details. +------------------------------------------------------------------------------ + *NERDTreeCaseSensitiveFS* +Values: 0, 1, 2 or 3. +Default: 2. + +If set to 0, the NERDTree will interact with the file system without case +sensitivity. + +If set to 1, the NERDTree will interact with the file system in a case-sensitive +manner. + +If set to 2, the NERDTree assumes its case sensitivity from the OS it is +running on. It Will default to case-insensitive on Windows and macOS +machines and case-sensitive on everything else. Since it's not a foolproof +way of detection, NERDTree won't proceed with any write actions when +the destination is ambiguous. + +Setting it to 3 will perform just like 2, but without suppressing write +actions. + ------------------------------------------------------------------------------ *NERDTreeCaseSensitiveSort* Values: 0 or 1. @@ -849,9 +889,17 @@ above nodes would then be sorted like this: > z110.txt < ------------------------------------------------------------------------------ - *NERDTreeChDirMode* + *NERDTreeUseTCD* +Values: 0 or 1. +Default: 0. -Values: 0, 1 or 2. +By default, NERDTree will use the `:cd` command to change the current working +directory. If this setting is turned on, and the `:tcd` command is available, it +will be used instead. + +------------------------------------------------------------------------------ + *NERDTreeChDirMode* +Values: 0, 1, 2, or 3. Default: 0. Use this setting to tell the script when (if at all) to change the current @@ -871,6 +919,9 @@ the CWD is changed whenever the tree root is changed. For example, if the CWD is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new root then the CWD will become /home/marty/foobar/baz. +If the set to 3, then it behaves the same as if set to 2, and the CWD is +changed whenever changing tabs to whatever the tree root is on that tab. + ------------------------------------------------------------------------------ *NERDTreeHighlightCursorline* Values: 0 or 1. @@ -902,7 +953,7 @@ Default: ['\~$']. This setting is used to specify which files the NERDTree should ignore. It must be a list of regular expressions. When the NERDTree is rendered, any -files/dirs that match any of the regex's in NERDTreeIgnore won't be +files/directories that match any of the regex's in NERDTreeIgnore won't be displayed. For example if you put the following line in your vimrc: > @@ -910,13 +961,18 @@ For example if you put the following line in your vimrc: > < then all files ending in .vim or ~ will be ignored. -There are 2 magic flags that can be appended to the end of each regular -expression to specify that the regex should match only files or only dirs. -These flags are "[[dir]]" and "[[file]]". Example: > - let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]'] +There are 3 magic flags that can be appended to the end of each regular +expression to specify that the regex should match only filenames, only lowest +level directories, or a full path. These flags are "[[dir]]", "[[file]]", and +"[[path]]". Example: > + let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]', 'tmp/cache$[[path]]'] < -This will cause all dirs ending in ".d" to be ignored and all files ending in -".o" to be ignored. +This will cause all directories ending in ".d" to be ignored, all files ending +in ".o" to be ignored, and the "cache" subdirectory of any "tmp" directory to +be ignored. All other "cache" directories will be displayed. + +When using the "[[path]]" tag on Windows, make sure you use escaped +backslashes for the separators in the regex, eg. 'Temp\\cache$[[path]]' Note: to tell the NERDTree not to ignore any files you must use the following line: > @@ -980,7 +1036,6 @@ then (to single click activate it) you must click somewhere in ------------------------------------------------------------------------------ *NERDTreeQuitOnOpen* - Values: 0,1,2 or 3. Default: 0 @@ -1017,6 +1072,20 @@ This setting can be toggled dynamically, per tree, with the |NERDTree-F| mapping and is useful for drastically shrinking the tree when you are navigating to a different part of the tree. +------------------------------------------------------------------------------ + *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-FL| +mapping. +Use one of the follow lines for this setting: > + let NERDTreeFileLines=0 + let NERDTreeFileLines=1 +< ------------------------------------------------------------------------------ *NERDTreeShowHidden* Values: 0 or 1. @@ -1081,8 +1150,8 @@ Examples: > < 1. Directories will appear last, everything else will appear above. 2. Everything will simply appear in alphabetical order. -3. Dirs will appear first, then ruby and php. Swap files, bak files and vim - backup files will appear last with everything else preceding them. +3. Directories will appear first, then ruby and php. Swap files, bak files + and vim backup files will appear last with everything else preceding them. 4. Everything is sorted by size, largest to smallest, with directories considered to have size 0 bytes. 5. Directories will appear first alphabetically, followed by files, sorted by @@ -1105,7 +1174,7 @@ setting is used. ------------------------------------------------------------------------------ *NERDTreeWinPos* -Values: "left" or "right" +Values: "left", "right", "top" or "bottom" Default: "left". This setting is used to determine where NERDTree window is placed on the @@ -1115,6 +1184,13 @@ This setting makes it possible to use two different explorer plugins simultaneously. For example, you could have the taglist plugin on the left of the window and the NERDTree on the right. +When setting this variable to "top" or "bottom" make sure to also change the +|NERDTreeWinSize| to a more reasonable size. + +For example: +> + let g:NERDTreeWinSize = 15 +< ------------------------------------------------------------------------------ *NERDTreeWinSize* Values: a positive integer. @@ -1156,8 +1232,9 @@ Use one of the following lines for this setting: > Values: 0 or 1 Default: 1. -When displaying dir nodes, this setting tells NERDTree to collapse dirs that -have only one child. Use one of the following lines for this setting: > +When displaying directory nodes, this setting tells NERDTree to collapse +directories that have only one child. Use one of the following lines for this +setting: > let NERDTreeCascadeSingleChildDir=0 let NERDTreeCascadeSingleChildDir=1 < @@ -1166,11 +1243,12 @@ have only one child. Use one of the following lines for this setting: > Values: 0 or 1 Default: 1. -When opening dir nodes, this setting tells NERDTree to recursively open dirs -that have only one child which is also a dir. NERDTree will stop when it finds -a dir that contains anything but another single dir. This setting also causes -the |NERDTree-x| mapping to close dirs in the same manner. This setting may be -useful for Java projects. Use one of the following lines for this setting: > +When opening directory nodes, this setting tells NERDTree to recursively open +directories that have only one child which is also a directory. NERDTree will +stop when it finds a directory that contains anything but another single +directory. This setting also causes the |NERDTree-x| mapping to close +directories in the same manner. This setting may be useful for Java projects. +Use one of the following lines for this setting: > let NERDTreeCascadeOpenSingleChildDir=0 let NERDTreeCascadeOpenSingleChildDir=1 < @@ -1204,13 +1282,19 @@ Values: Any single character. Defaults: Windows: ~ and + Others: ▾ and ▸ These characters indicate whether a directory is collapsible or expandable. - -They can be set to "\u00a0" to hide the arrows, but if you do this you may -need to change the node delimiter. See |NERDTreeNodeDelimiter|. You cannot use -the same character for both the arrows and the delimiter. Example: > +Example: > let NERDTreeDirArrowExpandable=">" let NERDTreeDirArrowCollapsible="v" < +They can be set to "\u00a0" to replace the arrows with a non-breaking space. +If you do this you may need to change the node delimiter. See +|NERDTreeNodeDelimiter|. You cannot use the same character for both the arrows +and the delimiter. + +Alternatively, they can be set to '' (an empty string). This removes the +arrows and the single space that follows them, shifting the entire tree two +character positions to the left. + ------------------------------------------------------------------------------ *NERDTreeNodeDelimiter* Values: Any single character. @@ -1220,15 +1304,15 @@ This character is used to separate the file or directory name from the rest of the characters in the line of text. It allows filenames to contain special characters that are otherwise used in the NERDTree, such as square brackets, braces, trailing asterisk, and leading space. For more details, see the -responsible pull request: https://github.com/scrooloose/nerdtree/pull/868. +responsible pull request: https://github.com/preservim/nerdtree/pull/868. The default value of this variable depends on the features compiled into your vim and the values of |NERDTreeDirArrowCollapsible| and |NERDTreeDirArrowExpandable|. - * If your vim is compiled with the +conceal feature, it is the "\x07" (BELL) - character, and it is hidden by setting 'conceallevel' to 3. If you use - autocommands, make sure none of them change that setting in the NERDTree_* - buffers. + * If your vim is compiled with the +conceal feature, it is the "\x07" + (BEL) character, and it is hidden by setting 'conceallevel' to 2. If you + use autocommands, make sure none of them change that setting in the + NERD_Tree_* buffers. * If your vim does NOT have the +conceal feature and you're using "\u00a0" (non-breaking space) to hide the directory arrows, "\u00b7" (middle dot) is used as the default delimiter. @@ -1297,6 +1381,10 @@ following code conventions are used: See this blog post for more details: http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html +A number of API functions take a callback argument to call. The callback can +be either a string with the name of a function to call, or a |Funcref| object +which will be called directly. + ------------------------------------------------------------------------------ 4.1. Key map API *NERDTreeKeymapAPI* @@ -1324,18 +1412,18 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* Example: > call NERDTreeAddKeyMap({ \ 'key': 'foo', - \ 'callback': 'NERDTreeCDHandler', + \ 'callback': 'NERDTreeEchoPathHandler', \ 'quickhelpText': 'echo full path of current node', \ 'scope': 'DirNode' }) - function! NERDTreeCDHandler(dirnode) - call a:dirnode.changeToDir() + function! NERDTreeEchoPathHandler(dirnode) + echo a:dirnode.path.str() endfunction < This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of - the current dir node. Note this mapping will only fire when the cursor is - on a directory node. + the current directory node. Note this mapping will only fire when the + cursor is on a directory node. ------------------------------------------------------------------------------ 4.2. Menu API *NERDTreeMenuAPI* @@ -1476,11 +1564,11 @@ in the fridge for later ;) Martyzilla recruited two other unwitting accomplices to become his minions in his quest to conquer the Vim plugin world. While he may still love to receive your emails, the best way to send suggestions, bug reports, and questions is -to submit an issue at http://github.com/scrooloose/nerdtree/issues. +to submit an issue at http://github.com/preservim/nerdtree/issues. The latest stable and development versions are on Github. - Stable: http://github.com/scrooloose/nerdtree (master branch) - Development: http://github.com/scrooloose/nerdtree/branches + Stable: http://github.com/preservim/nerdtree (master branch) + Development: http://github.com/preservim/nerdtree/branches Title Credit: * http://ascii.co.uk/art/tree diff --git a/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim b/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim index b206e7a4..37be451c 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim @@ -33,7 +33,7 @@ endfunction " Class method to get all bookmarks. Lazily initializes the bookmarks global " variable function! s:Bookmark.Bookmarks() - if !exists("g:NERDTreeBookmarks") + if !exists('g:NERDTreeBookmarks') let g:NERDTreeBookmarks = [] endif return g:NERDTreeBookmarks @@ -53,7 +53,7 @@ endfunction " FUNCTION: Bookmark.BookmarkFor(name) {{{1 " Class method that returns the Bookmark object having the specified name. -" Throws "NERDTree.BookmarkNotFoundError" if no Bookmark is found. +" Throws NERDTree.BookmarkNotFoundError if no Bookmark is found. function! s:Bookmark.BookmarkFor(name) let l:result = {} for l:bookmark in s:Bookmark.Bookmarks() @@ -93,7 +93,7 @@ function! s:Bookmark.CacheBookmarks(silent) for i in bookmarkStrings "ignore blank lines - if i != '' + if i !=# '' let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') @@ -111,7 +111,7 @@ function! s:Bookmark.CacheBookmarks(silent) if invalidBookmarksFound call s:Bookmark.Write() if !a:silent - call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") + call nerdtree#echo(invalidBookmarksFound . ' invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.') endif endif endif @@ -120,16 +120,16 @@ endfunction " FUNCTION: Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) {{{1 " Class method that indicates the relative position of two bookmarks when " placed in alphabetical order by name. Case-sensitivity is determined by an -" option. Supports the "s:Bookmark.SortBookmarksList()" method. +" option. Supports the s:Bookmark.SortBookmarksList() method. function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) let l:result = 0 - if g:NERDTreeBookmarksSort == 1 + if g:NERDTreeBookmarksSort ==# 1 if a:firstBookmark.name ? a:secondBookmark.name let l:result = 1 endif - elseif g:NERDTreeBookmarksSort == 2 + elseif g:NERDTreeBookmarksSort ==# 2 if a:firstBookmark.name <# a:secondBookmark.name let l:result = -1 elseif a:firstBookmark.name ># a:secondBookmark.name @@ -159,13 +159,13 @@ endfunction " FUNCTION: s:Edit() {{{1 " opens the NERDTreeBookmarks file for manual editing function! s:Bookmark.Edit() - call nerdtree#exec("wincmd w", 1) - call nerdtree#exec("edit ".g:NERDTreeBookmarksFile, 1) + call nerdtree#exec('wincmd w', 1) + call nerdtree#exec('edit '.g:NERDTreeBookmarksFile, 1) endfunction " FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 " Returns the tree node object associated with this Bookmark. -" Throws "NERDTree.BookmarkedNodeNotFoundError" if the node is not found. +" Throws NERDTree.BookmarkedNodeNotFoundError if the node is not found. " " Args: " searchFromAbsoluteRoot: boolean flag, search from the highest cached node @@ -185,8 +185,8 @@ endfunction " FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1 " Class method that returns the tree node object for the Bookmark with the -" given name. Throws "NERDTree.BookmarkNotFoundError" if a Bookmark with the -" name does not exist. Throws "NERDTree.BookmarkedNodeNotFoundError" if a +" given name. Throws NERDTree.BookmarkNotFoundError if a Bookmark with the +" name does not exist. Throws NERDTree.BookmarkedNodeNotFoundError if a " tree node for the named Bookmark could not be found. function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) let l:bookmark = s:Bookmark.BookmarkFor(a:name) @@ -196,9 +196,9 @@ endfunction " FUNCTION: Bookmark.GetSelected() {{{1 " returns the Bookmark the cursor is over, or {} function! s:Bookmark.GetSelected() - let line = getline(".") + let line = getline('.') let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') - if name != line + if name !=# line try return s:Bookmark.BookmarkFor(name) catch /^NERDTree.BookmarkNotFoundError/ @@ -212,7 +212,7 @@ endfunction " Class method to get all invalid bookmark strings read from the bookmarks " file function! s:Bookmark.InvalidBookmarks() - if !exists("g:NERDTreeInvalidBookmarks") + if !exists('g:NERDTreeInvalidBookmarks') let g:NERDTreeInvalidBookmarks = [] endif return g:NERDTreeInvalidBookmarks @@ -222,8 +222,8 @@ endfunction function! s:Bookmark.mustExist() if !self.path.exists() call s:Bookmark.CacheBookmarks(1) - throw "NERDTree.BookmarkPointsToInvalidLocationError: the bookmark \"". - \ self.name ."\" points to a non existing location: \"". self.path.str() + throw 'NERDTree.BookmarkPointsToInvalidLocationError: the bookmark "'. + \ self.name .'" points to a non existing location: "'. self.path.str() endif endfunction @@ -231,7 +231,7 @@ endfunction " Create a new bookmark object with the given name and path object function! s:Bookmark.New(name, path) if a:name =~# ' ' - throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name + throw 'NERDTree.IllegalBookmarkNameError: illegal name:' . a:name endif let newBookmark = copy(self) @@ -256,7 +256,7 @@ endfunction function! s:Bookmark.open(nerdtree, ...) let opts = a:0 ? a:1 : {} - if nerdtree#and(g:NERDTreeQuitOnOpen,2) + if nerdtree#closeBookmarksOnOpen() call a:nerdtree.ui.toggleShowBookmarks() endif @@ -292,7 +292,7 @@ endfunction " Get the string that should be rendered in the view for this bookmark function! s:Bookmark.str() let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - strdisplaywidth(self.name) - if &nu + if &number let pathStrMaxLen = pathStrMaxLen - &numberwidth endif @@ -335,7 +335,7 @@ function! s:Bookmark.validate() return 1 else call s:Bookmark.CacheBookmarks(1) - call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") + call nerdtree#echo(self.name . 'now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.') return 0 endif endfunction @@ -349,7 +349,7 @@ function! s:Bookmark.Write() endfor "add a blank line before the invalid ones - call add(bookmarkStrings, "") + call add(bookmarkStrings, '') for j in s:Bookmark.InvalidBookmarks() call add(bookmarkStrings, j) @@ -358,7 +358,7 @@ function! s:Bookmark.Write() try call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) catch - call nerdtree#echoError("Failed to write bookmarks file. Make sure g:NERDTreeBookmarksFile points to a valid location.") + call nerdtree#echoError('Failed to write bookmarks file. Make sure g:NERDTreeBookmarksFile points to a valid location.') endtry endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim index efd3cc81..e794e0d9 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim @@ -28,7 +28,9 @@ endfunction " FUNCTION: s:Creator._broadcastInitEvent() {{{1 function! s:Creator._broadcastInitEvent() - silent doautocmd User NERDTreeInit + if exists('#User#NERDTreeInit') + doautocmd User NERDTreeInit + endif endfunction " FUNCTION: s:Creator.BufNamePrefix() {{{1 @@ -36,6 +38,29 @@ function! s:Creator.BufNamePrefix() return 'NERD_tree_' endfunction +" FUNCTION: s:Creator.CreateExploreTree(dir) {{{1 +function! s:Creator.CreateExploreTree(dir) + try + let path = g:NERDTreePath.New(a:dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo('Invalid directory name:' . a:dir) + return + endtry + + let creator = s:Creator.New() + if getbufinfo('%')[0].changed && !&hidden && !&autowriteall + let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright ' + let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : '' + silent! execute l:splitLocation . l:splitDirection . ' new' + else + silent! execute 'enew' + endif + + call creator.createWindowTree(a:dir) + "we want windowTree buffer to disappear after moving to any other buffer + setlocal bufhidden=wipe +endfunction + " FUNCTION: s:Creator.CreateTabTree(a:name) {{{1 function! s:Creator.CreateTabTree(name) let creator = s:Creator.New() @@ -82,20 +107,20 @@ function! s:Creator.createWindowTree(dir) try let path = g:NERDTreePath.New(a:dir) catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("Invalid directory name:" . a:name) + call nerdtree#echo('Invalid directory name:' . a:dir) return endtry "we want the directory buffer to disappear when we do the :edit below setlocal bufhidden=wipe - let previousBuf = expand("#") + let previousBuf = expand('#') "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") + call self._createNERDTree(path, 'window') let b:NERDTree._previousBuf = bufnr(previousBuf) call self._setCommonBufOptions() @@ -109,7 +134,7 @@ function! s:Creator._createNERDTree(path, type) let b:NERDTree = g:NERDTree.New(a:path, a:type) " TODO: This assignment is kept for compatibility reasons. Many other - " plugins use "b:NERDTreeRoot" instead of "b:NERDTree.root". Remove this + " plugins use b:NERDTreeRoot instead of b:NERDTree.root. Remove this " assignment in the future. let b:NERDTreeRoot = b:NERDTree.root @@ -126,9 +151,9 @@ endfunction function! s:Creator.createMirror() "get the names off all the nerd tree buffers let treeBufNames = [] - for i in range(1, tabpagenr("$")) + for i in range(1, tabpagenr('$')) let nextName = self._tabpagevar(i, 'NERDTreeBufName') - if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) + if nextName != -1 && (!exists('t:NERDTreeBufName') || nextName != t:NERDTreeBufName) call add(treeBufNames, nextName) endif endfor @@ -140,7 +165,7 @@ function! s:Creator.createMirror() let i = 0 while i < len(treeBufNames) let bufName = treeBufNames[i] - let treeRoot = getbufvar(bufName, "NERDTree").root + let treeRoot = getbufvar(bufName, 'NERDTree').root let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName let i = i + 1 endwhile @@ -148,7 +173,7 @@ function! s:Creator.createMirror() "work out which tree to mirror, if there is more than 1 then ask the user let bufferName = '' if len(keys(options)) > 1 - let choices = ["Choose a tree to mirror"] + let choices = ['Choose a tree to mirror'] let choices = extend(choices, sort(keys(options))) let choice = inputlist(choices) if choice < 1 || choice > len(options) || choice ==# '' @@ -159,7 +184,7 @@ function! s:Creator.createMirror() elseif len(keys(options)) ==# 1 let bufferName = values(options)[0] else - call nerdtree#echo("No trees to mirror") + call nerdtree#echo('No trees to mirror') return endif @@ -170,6 +195,7 @@ function! s:Creator.createMirror() let t:NERDTreeBufName = bufferName call self._createTreeWin() exec 'buffer ' . bufferName + call b:NERDTree.ui.restoreScreenState() if !&hidden call b:NERDTree.render() endif @@ -179,16 +205,17 @@ endfunction " Initialize the NERDTree window. Open the window, size it properly, set all " local options, etc. function! s:Creator._createTreeWin() - let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright ' + let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright ' + let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : '' let l:splitSize = g:NERDTreeWinSize if !g:NERDTree.ExistsForTab() - let t:NERDTreeBufName = self._nextBufferName() - silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new' + let t:NERDTreeBufName = self._nextBufferName('tab') + silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new' silent! execute 'edit ' . t:NERDTreeBufName - silent! execute 'vertical resize '. l:splitSize + silent! execute l:splitDirection . ' resize '. l:splitSize else - silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split' + silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' split' silent! execute 'buffer ' . t:NERDTreeBufName endif @@ -217,17 +244,29 @@ 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 " FUNCTION: s:Creator._nextBufferNumber() {{{1 " the number to add to the nerd tree buffer name to make the buf name unique function! s:Creator._nextBufferNumber() - if !exists("s:Creator._NextBufNum") + if !exists('s:Creator._NextBufNum') let s:Creator._NextBufNum = 1 else let s:Creator._NextBufNum += 1 @@ -247,14 +286,18 @@ function! s:Creator._pathForString(str) "hack to get an absolute path if a relative path is given if dir =~# '^\.' - let dir = getcwd() . g:NERDTreePath.Slash() . dir + let dir = getcwd() . nerdtree#slash() . dir + endif + + "hack to prevent removing slash if dir is the root of the file system. + if dir !=# '/' + let dir = g:NERDTreePath.Resolve(dir) endif - let dir = g:NERDTreePath.Resolve(dir) try let path = g:NERDTreePath.New(dir) catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("No bookmark or directory found for: " . a:str) + call nerdtree#echo('No bookmark or directory found for: ' . a:str) return {} endtry endif @@ -274,7 +317,7 @@ function! s:Creator._removeTreeBufForTab() "nerdtree buf may be mirrored/displayed elsewhere if self._isBufHidden(buf) - exec "bwipeout " . buf + exec 'bwipeout ' . buf endif endif @@ -300,11 +343,11 @@ function! s:Creator._setCommonBufOptions() setlocal nowrap if g:NERDTreeShowLineNumbers - setlocal nu + setlocal number else - setlocal nonu + setlocal nonumber if v:version >= 703 - setlocal nornu + setlocal norelativenumber endif endif @@ -330,17 +373,20 @@ endfunction " FUNCTION: s:Creator._tabpagevar(tabnr, var) {{{1 function! s:Creator._tabpagevar(tabnr, var) let currentTab = tabpagenr() - let old_ei = &ei - set ei=all + let old_ei = &eventignore + set eventignore=all - exec "tabnext " . a:tabnr - let v = -1 - if exists('t:' . a:var) - exec 'let v = t:' . a:var - endif - exec "tabnext " . currentTab + try + exec 'tabnext ' . a:tabnr + let v = -1 + if exists('t:' . a:var) + exec 'let v = t:' . a:var + endif + exec 'tabnext ' . currentTab - let &ei = old_ei + finally + let &eventignore = old_ei + endtry return v endfunction @@ -352,17 +398,20 @@ function! s:Creator.ToggleTabTree(dir) endfunction " FUNCTION: s:Creator.toggleTabTree(dir) {{{1 -" Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is -" closed it is restored or initialized (if it doesnt exist) +" Toggles the NERD tree. I.e if the NERD tree is open, it is closed. If it is +" closed, it is restored or initialized. If dir is not empty, it will be set +" as the new root. " " Args: -" dir: the full path for the root node (is only used if the NERD tree is being -" initialized. +" dir: the full path for the root node (is used if the NERD tree is being +" initialized, or to change the root to a new dir.) function! s:Creator.toggleTabTree(dir) if g:NERDTree.ExistsForTab() if !g:NERDTree.IsOpen() call self._createTreeWin() - if !&hidden + if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str() + call self.createTabTree(a:dir) + elseif !&hidden call b:NERDTree.render() endif call b:NERDTree.ui.restoreScreenState() diff --git a/sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim b/sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim index bc6e8879..75528674 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim @@ -43,13 +43,13 @@ endfunction "FUNCTION: FlagSet.renderToString() {{{1 function! s:FlagSet.renderToString() - let flagstring = "" + let flagstring = '' for i in values(self._flags) let flagstring .= join(i) endfor if len(flagstring) == 0 - return "" + return '' endif return '[' . flagstring . ']' diff --git a/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim b/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim index 584da1f1..ed791677 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim @@ -51,9 +51,9 @@ function! s:KeyMap.bind() else let keymapInvokeString = self.key endif - let keymapInvokeString = escape(keymapInvokeString, '\') + let keymapInvokeString = escape(keymapInvokeString, '\"') - let premap = self.key == "" ? " " : " " + let premap = self.key ==# '' ? ' ' : ' ' exec 'nnoremap '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")' endfunction @@ -66,11 +66,11 @@ endfunction "FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) - let Callback = function(self.callback) + let l:Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) if a:0 - call Callback(a:1) + call l:Callback(a:1) else - call Callback() + call l:Callback() endif endfunction @@ -78,11 +78,11 @@ endfunction "Find a keymapping for a:key and the current scope invoke it. " "Scope is determined as follows: -" * if the cursor is on a dir node then "DirNode" -" * if the cursor is on a file node then "FileNode" -" * if the cursor is on a bookmark then "Bookmark" +" * if the cursor is on a dir node then DirNode +" * if the cursor is on a file node then FileNode +" * if the cursor is on a bookmark then Bookmark " -"If a keymap has the scope of "all" then it will be called if no other keymap +"If a keymap has the scope of 'all' then it will be called if no other keymap "is found for a:key and the scope. function! s:KeyMap.Invoke(key) @@ -100,7 +100,7 @@ function! s:KeyMap.Invoke(key) "try file node if !node.path.isDirectory - let km = s:KeyMap.FindFor(a:key, "FileNode") + let km = s:KeyMap.FindFor(a:key, 'FileNode') if !empty(km) return km.invoke(node) endif @@ -108,14 +108,14 @@ function! s:KeyMap.Invoke(key) "try dir node if node.path.isDirectory - let km = s:KeyMap.FindFor(a:key, "DirNode") + let km = s:KeyMap.FindFor(a:key, 'DirNode') if !empty(km) return km.invoke(node) endif endif "try generic node - let km = s:KeyMap.FindFor(a:key, "Node") + let km = s:KeyMap.FindFor(a:key, 'Node') if !empty(km) return km.invoke(node) endif @@ -125,14 +125,14 @@ function! s:KeyMap.Invoke(key) "try bookmark let bm = g:NERDTreeBookmark.GetSelected() if !empty(bm) - let km = s:KeyMap.FindFor(a:key, "Bookmark") + let km = s:KeyMap.FindFor(a:key, 'Bookmark') if !empty(km) return km.invoke(bm) endif endif "try all - let km = s:KeyMap.FindFor(a:key, "all") + let km = s:KeyMap.FindFor(a:key, 'all') if !empty(km) return km.invoke() endif @@ -143,7 +143,7 @@ function! s:KeyMap.Create(options) let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) "dont override other mappings unless the 'override' option is given - if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) + if get(opts, 'override', 0) ==# 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) return end diff --git a/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim b/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim index 05e82d97..952c67bd 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim @@ -44,13 +44,13 @@ function! s:MenuController.showMenu() finally call self._restoreOptions() - " Redraw when "Ctrl-C" or "Esc" is received. - if !l:done || self.selection == -1 + " Redraw when Ctrl-C or Esc is received. + if !l:done || self.selection ==# -1 redraw! endif endtry - if self.selection != -1 + if self.selection !=# -1 let l:m = self._current() call l:m.execute() endif @@ -58,24 +58,25 @@ endfunction "FUNCTION: MenuController._echoPrompt() {{{1 function! s:MenuController._echoPrompt() - let navHelp = "Use " . g:NERDTreeMenuDown . "/" . g:NERDTreeMenuUp . "/enter" + let navHelp = 'Use ' . g:NERDTreeMenuDown . '/' . g:NERDTreeMenuUp . '/enter' if self.isMinimal() let selection = self.menuItems[self.selection].text + let keyword = matchstr(selection, '[^ ]*([^ ]*') let shortcuts = map(copy(self.menuItems), "v:val['shortcut']") - let shortcuts[self.selection] = " " . split(selection)[0] . " " + let shortcuts[self.selection] = ' ' . keyword . ' ' - echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): " + echo 'Menu: [' . join(shortcuts, ',') . '] (' . navHelp . ' or shortcut): ' else - echo "NERDTree Menu. " . navHelp . ", or the shortcuts indicated" - echo "=========================================================" + echo 'NERDTree Menu. ' . navHelp . ', or the shortcuts indicated' + echo '=========================================================' for i in range(0, len(self.menuItems)-1) - if self.selection == i - echo "> " . self.menuItems[i].text + if self.selection ==# i + echo '> ' . self.menuItems[i].text else - echo " " . self.menuItems[i].text + echo ' ' . self.menuItems[i].text endif endfor endif @@ -91,20 +92,20 @@ endfunction "change the selection (if appropriate) and return 1 if the user has made "their choice, 0 otherwise function! s:MenuController._handleKeypress(key) - if a:key == g:NERDTreeMenuDown + if a:key ==# g:NERDTreeMenuDown call self._cursorDown() - elseif a:key == g:NERDTreeMenuUp + elseif a:key ==# g:NERDTreeMenuUp call self._cursorUp() - elseif a:key == nr2char(27) "escape + elseif a:key ==# nr2char(27) "escape let self.selection = -1 return 1 - elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j + elseif a:key ==# "\r" || a:key ==# "\n" "enter and ctrl-j return 1 else let index = self._nextIndexFor(a:key) - if index != -1 + if index !=# -1 let self.selection = index - if len(self._allIndexesFor(a:key)) == 1 + if len(self._allIndexesFor(a:key)) ==# 1 return 1 endif endif @@ -119,7 +120,7 @@ function! s:MenuController._allIndexesFor(shortcut) let toReturn = [] for i in range(0, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut call add(toReturn, i) endif endfor @@ -132,13 +133,13 @@ endfunction "current cursor location and wraps around to the top again if need be function! s:MenuController._nextIndexFor(shortcut) for i in range(self.selection+1, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut return i endif endfor for i in range(0, self.selection) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut return i endif endfor diff --git a/sources_non_forked/nerdtree/lib/nerdtree/menu_item.vim b/sources_non_forked/nerdtree/lib/nerdtree/menu_item.vim index 92c1bbbf..7f259171 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/menu_item.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/menu_item.vim @@ -6,7 +6,7 @@ let g:NERDTreeMenuItem = s:MenuItem "FUNCTION: MenuItem.All() {{{1 "get all top level menu items function! s:MenuItem.All() - if !exists("s:menuItems") + if !exists('s:menuItems') let s:menuItems = [] endif return s:menuItems @@ -58,7 +58,7 @@ function! s:MenuItem.CreateSeparator(options) let standard_options = { 'text': '--------------------', \ 'shortcut': -1, \ 'callback': -1 } - let options = extend(a:options, standard_options, "force") + let options = extend(a:options, standard_options, 'force') return s:MenuItem.Create(options) endfunction @@ -67,7 +67,7 @@ endfunction "make a new submenu and add it to global list function! s:MenuItem.CreateSubmenu(options) let standard_options = { 'callback': -1 } - let options = extend(a:options, standard_options, "force") + let options = extend(a:options, standard_options, 'force') return s:MenuItem.Create(options) endfunction @@ -79,7 +79,7 @@ endfunction "specified function! s:MenuItem.enabled() if self.isActiveCallback != -1 - return {self.isActiveCallback}() + return type(self.isActiveCallback) == type(function('tr')) ? self.isActiveCallback() : {self.isActiveCallback}() endif return 1 endfunction @@ -94,7 +94,11 @@ function! s:MenuItem.execute() call mc.showMenu() else if self.callback != -1 - call {self.callback}() + if type(self.callback) == type(function('tr')) + call self.callback() + else + call {self.callback}() + endif endif endif endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim index 705d4f9b..1af5346a 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim @@ -20,14 +20,16 @@ function! s:NERDTree.changeRoot(node) call self.root.open() "change dir to the dir of the new root if instructed to - if g:NERDTreeChDirMode ==# 2 + if g:NERDTreeChDirMode >= 2 call self.root.path.changeToDir() endif call self.render() call self.root.putCursorHere(0, 0) - silent doautocmd User NERDTreeNewRoot + if exists('#User#NERDTreeNewRoot') + doautocmd User NERDTreeNewRoot + endif endfunction "FUNCTION: s:NERDTree.Close() {{{1 @@ -37,45 +39,37 @@ function! s:NERDTree.Close() return endif - if winnr("$") != 1 + if winnr('$') !=# 1 " Use the window ID to identify the currently active window or fall " back on the buffer ID if win_getid/win_gotoid are not available, in " which case we'll focus an arbitrary window showing the buffer. let l:useWinId = exists('*win_getid') && exists('*win_gotoid') - if winnr() == s:NERDTree.GetWinNum() - call nerdtree#exec("wincmd p", 1) - let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") - call nerdtree#exec("wincmd p", 1) + if winnr() ==# s:NERDTree.GetWinNum() + call nerdtree#exec('wincmd p', 1) + let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') + call nerdtree#exec('wincmd p', 1) else - let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") + let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') endif - call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1) - call nerdtree#exec("close", 1) + call nerdtree#exec(s:NERDTree.GetWinNum() . ' wincmd w', 1) + call nerdtree#exec('close', 0) if l:useWinId - call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0) + call nerdtree#exec('call win_gotoid(' . l:activeBufOrWin . ')', 0) else - call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w", 0) + call nerdtree#exec(bufwinnr(l:activeBufOrWin) . ' wincmd w', 0) endif else close endif endfunction -"FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1 -"Closes the NERD tree window if the close on open option is set -function! s:NERDTree.CloseIfQuitOnOpen() - if nerdtree#and(g:NERDTreeQuitOnOpen,1) && s:NERDTree.IsOpen() - call s:NERDTree.Close() - endif -endfunction - "FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 "Places the cursor at the top of the bookmarks table function! s:NERDTree.CursorToBookmarkTable() if !b:NERDTree.ui.getShowBookmarks() - throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" + throw 'NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active' endif if g:NERDTreeMinimalUI @@ -88,7 +82,7 @@ function! s:NERDTree.CursorToBookmarkTable() while getline(line) !~# '^>-\+Bookmarks-\+$' let line = line + 1 if line >= rootNodeLine - throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table" + throw 'NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table' endif endwhile call cursor(line, 2) @@ -96,21 +90,21 @@ endfunction "FUNCTION: s:NERDTree.CursorToTreeWin(){{{1 "Places the cursor in the nerd tree window -function! s:NERDTree.CursorToTreeWin() +function! s:NERDTree.CursorToTreeWin(...) call g:NERDTree.MustBeOpen() - call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1) + call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', a:0 >0 ? a:1 : 1) endfunction " Function: s:NERDTree.ExistsForBuffer() {{{1 " Returns 1 if a nerd tree root exists in the current buffer function! s:NERDTree.ExistsForBuf() - return exists("b:NERDTree") + return exists('b:NERDTree') endfunction " Function: s:NERDTree.ExistsForTab() {{{1 " Returns 1 if a nerd tree root exists in the current tab function! s:NERDTree.ExistsForTab() - if !exists("t:NERDTreeBufName") + if !exists('t:NERDTreeBufName') return end @@ -133,7 +127,7 @@ function! s:NERDTree.ForCurrentTab() endif let bufnr = bufnr(t:NERDTreeBufName) - return getbufvar(bufnr, "NERDTree") + return getbufvar(bufnr, 'NERDTree') endfunction "FUNCTION: s:NERDTree.getRoot() {{{1 @@ -144,32 +138,39 @@ endfunction "FUNCTION: s:NERDTree.GetWinNum() {{{1 "gets the nerd tree window number for this tab function! s:NERDTree.GetWinNum() - if exists("t:NERDTreeBufName") + if exists('t:NERDTreeBufName') return bufwinnr(t:NERDTreeBufName) endif + " If WindowTree, there is no t:NERDTreeBufName variable. Search all windows. + for w in range(1,winnr('$')) + if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'win_\d\+$' + return w + endif + endfor + return -1 endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 function! s:NERDTree.IsOpen() - return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' + return s:NERDTree.GetWinNum() !=# -1 endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1 function! s:NERDTree.isTabTree() - return self._type == "tab" + return self._type ==# 'tab' endfunction "FUNCTION: s:NERDTree.isWinTree() {{{1 function! s:NERDTree.isWinTree() - return self._type == "window" + return self._type ==# 'window' endfunction "FUNCTION: s:NERDTree.MustBeOpen() {{{1 function! s:NERDTree.MustBeOpen() if !s:NERDTree.IsOpen() - throw "NERDTree.TreeNotOpen" + throw 'NERDTree.TreeNotOpen' endif endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim b/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim index d24fc8f8..ffa2853a 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim @@ -14,13 +14,14 @@ endfunction function! s:Notifier.NotifyListeners(event, path, nerdtree, params) let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) - for listener in s:Notifier.GetListenersForEvent(a:event) - call {listener}(event) + for Listener in s:Notifier.GetListenersForEvent(a:event) + let l:Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) + call l:Callback(event) endfor endfunction function! s:Notifier.GetListenersMap() - if !exists("s:refreshListenersMap") + if !exists('s:refreshListenersMap') let s:refreshListenersMap = {} endif return s:refreshListenersMap diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim index 5953eea2..27993ac7 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -1,7 +1,7 @@ " ============================================================================ " CLASS: Opener " -" The Opener class defines an API for "opening" operations. +" The Opener class defines an API for 'opening' operations. " ============================================================================ @@ -33,8 +33,7 @@ function! s:Opener._bufInWindows(bnum) endfunction " FUNCTION: Opener._checkToCloseTree(newtab) {{{1 -" Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see -" if the tree should be closed now. +" Check the class options to see if the tree should be closed now. " " Args: " a:newtab - boolean. If set, only close the tree now if we are opening the @@ -45,8 +44,8 @@ function! s:Opener._checkToCloseTree(newtab) return endif - if (a:newtab && self._where == 't') || !a:newtab - call g:NERDTree.CloseIfQuitOnOpen() + if (a:newtab && self._where ==# 't') || !a:newtab + call g:NERDTree.Close() endif endfunction @@ -54,9 +53,9 @@ endfunction " find the window number of the first normal window function! s:Opener._firstUsableWindow() let i = 1 - while i <= winnr("$") + while i <= winnr('$') let bnum = winbufnr(i) - if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' + if bnum !=# -1 && getbufvar(bnum, '&buftype') ==# '' \ && !getwinvar(i, '&previewwindow') \ && (!getbufvar(bnum, '&modified') || &hidden) return i @@ -70,23 +69,23 @@ endfunction " FUNCTION: Opener._gotoTargetWin() {{{1 function! s:Opener._gotoTargetWin() if b:NERDTree.isWinTree() - if self._where == 'v' - vsplit - elseif self._where == 'h' - split - elseif self._where == 't' + if self._where ==# 'v' + call self._newVSplit() + elseif self._where ==# 'h' + call self._newSplit() + elseif self._where ==# 't' tabnew endif else call self._checkToCloseTree(1) - if self._where == 'v' + if self._where ==# 'v' call self._newVSplit() - elseif self._where == 'h' + elseif self._where ==# 'h' call self._newSplit() - elseif self._where == 't' + elseif self._where ==# 't' tabnew - elseif self._where == 'p' + elseif self._where ==# 'p' call self._previousWindow() endif @@ -102,15 +101,15 @@ endfunction " winnumber: the number of the window in question function! s:Opener._isWindowUsable(winnumber) "gotta split if theres only one window (i.e. the NERD tree) - if winnr("$") ==# 1 + if winnr('$') ==# 1 return 0 endif let oldwinnr = winnr() - call nerdtree#exec(a:winnumber . "wincmd p", 1) - let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') + call nerdtree#exec(a:winnumber . 'wincmd p', 1) + let specialWindow = getbufvar('%', '&buftype') !=# '' || getwinvar('%', '&previewwindow') let modified = &modified - call nerdtree#exec(oldwinnr . "wincmd p", 1) + call nerdtree#exec(oldwinnr . 'wincmd p', 1) "if its a special window e.g. quickfix or another explorer plugin then we "have to split @@ -131,9 +130,9 @@ endfunction " a:path: the path object that is to be opened " a:opts: a dictionary containing the following optional keys... " 'where': specifies whether the node should be opened in new split, in -" a new tab or, in the last window; takes values "v", "h", or "t" +" a new tab or, in the last window; takes values 'v', 'h', or 't' " 'reuse': if file is already shown in a window, jump there; takes values -" "all", "currenttab", or empty +" 'all', 'currenttab', or empty " 'keepopen': boolean (0 or 1); if true, the tree window will not be closed " 'stay': boolean (0 or 1); if true, remain in tree window after opening function! s:Opener.New(path, opts) @@ -153,61 +152,32 @@ endfunction " FUNCTION: Opener._newSplit() {{{1 function! s:Opener._newSplit() - " Save the user's settings for splitbelow and splitright - let savesplitbelow=&splitbelow - let savesplitright=&splitright - - " 'there' will be set to a command to move from the split window - " back to the explorer window - " - " 'back' will be set to a command to move from the explorer window - " back to the newly split window - " - " 'right' and 'below' will be set to the settings needed for - " splitbelow and splitright IF the explorer is the only window. - " - let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" - let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" - let right= g:NERDTreeWinPos ==# "left" - let below=0 - - " Attempt to go to adjacent window - call nerdtree#exec(back, 1) - - let onlyOneWin = (winnr("$") ==# 1) - - " If no adjacent window, set splitright and splitbelow appropriately + let onlyOneWin = (winnr('$') ==# 1) + let savesplitright = &splitright if onlyOneWin - let &splitright=right - let &splitbelow=below - else - " found adjacent window - invert split direction - let &splitright=!right - let &splitbelow=!below + let &splitright = (g:NERDTreeWinPos ==# 'left') endif - - let splitMode = onlyOneWin ? "vertical" : "" + " If only one window (ie. NERDTree), split vertically instead. + let splitMode = onlyOneWin ? 'vertical' : '' " Open the new window try - exec(splitMode." sp ") + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec(splitMode . ' split',1) catch /^Vim\%((\a\+)\)\=:E37/ call g:NERDTree.CursorToTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + throw 'NERDTree.FileAlreadyOpenAndModifiedError: '. self._path.str() .' is already open and modified.' catch /^Vim\%((\a\+)\)\=:/ "do nothing endtry "resize the tree window if no other window was open before if onlyOneWin - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call nerdtree#exec(there, 1) - exec("silent ". splitMode ." resize ". size) + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec('silent '. splitMode .' resize '. g:NERDTreeWinSize, 1) call nerdtree#exec('wincmd p', 0) endif - " Restore splitmode settings - let &splitbelow=savesplitbelow let &splitright=savesplitright endfunction @@ -215,12 +185,15 @@ endfunction function! s:Opener._newVSplit() let l:winwidth = winwidth('.') - if winnr('$') == 1 + let onlyOneWin = (winnr('$') ==# 1) + let savesplitright = &splitright + if onlyOneWin + let &splitright = (g:NERDTreeWinPos ==# 'left') let l:winwidth = g:NERDTreeWinSize endif call nerdtree#exec('wincmd p', 1) - call nerdtree#exec('vnew', 1) + call nerdtree#exec('vsplit', 1) let l:currentWindowNumber = winnr() @@ -229,6 +202,7 @@ function! s:Opener._newVSplit() execute 'silent vertical resize ' . l:winwidth call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0) + let &splitright=savesplitright endfunction " FUNCTION: Opener.open(target) {{{1 @@ -243,7 +217,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed + if !self._stay && self._keepopen && get(b:, 'NERDTreeZoomed', 0) call b:NERDTree.ui.toggleZoom() endif @@ -271,7 +245,7 @@ function! s:Opener._openDirectory(node) else if empty(self._where) call b:NERDTree.changeRoot(a:node) - elseif self._where == 't' + elseif self._where ==# 't' call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) else call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) @@ -285,18 +259,18 @@ endfunction " FUNCTION: Opener._previousWindow() {{{1 function! s:Opener._previousWindow() - if !self._isWindowUsable(winnr("#")) && self._firstUsableWindow() ==# -1 + if !self._isWindowUsable(winnr('#')) && self._firstUsableWindow() ==# -1 call self._newSplit() else try - if !self._isWindowUsable(winnr("#")) - call nerdtree#exec(self._firstUsableWindow() . "wincmd w", 1) + if !self._isWindowUsable(winnr('#')) + call nerdtree#exec(self._firstUsableWindow() . 'wincmd w', 1) else call nerdtree#exec('wincmd p', 1) endif catch /^Vim\%((\a\+)\)\=:E37/ call g:NERDTree.CursorToTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + throw 'NERDTree.FileAlreadyOpenAndModifiedError: '. self._path.str() .' is already open and modified.' catch /^Vim\%((\a\+)\)\=:/ echo v:exception endtry @@ -320,13 +294,13 @@ function! s:Opener._reuseWindow() "check the current tab for the window let winnr = bufwinnr('^' . self._path.str() . '$') - if winnr != -1 - call nerdtree#exec(winnr . "wincmd w", 0) + if winnr !=# -1 + call nerdtree#exec(winnr . 'wincmd w', 0) call self._checkToCloseTree(0) return 1 endif - if self._reuse == 'currenttab' + if self._reuse ==# 'currenttab' return 0 endif @@ -336,7 +310,7 @@ function! s:Opener._reuseWindow() call self._checkToCloseTree(1) call nerdtree#exec(tabnr . 'tabnext', 1) let winnr = bufwinnr('^' . self._path.str() . '$') - call nerdtree#exec(winnr . "wincmd w", 0) + call nerdtree#exec(winnr . 'wincmd w', 0) return 1 endif @@ -345,7 +319,7 @@ endfunction " FUNCTION: Opener._saveCursorPos() {{{1 function! s:Opener._saveCursorPos() - let self._bufnr = bufnr("") + let self._bufnr = bufnr('') let self._tabnr = tabpagenr() endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/path.vim b/sources_non_forked/nerdtree/lib/nerdtree/path.vim index d00bb898..e0c1d954 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/path.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -25,10 +25,10 @@ function! s:Path.AbsolutePathFor(pathStr) if l:prependWorkingDir let l:result = getcwd() - if l:result[-1:] == s:Path.Slash() + if l:result[-1:] == nerdtree#slash() let l:result = l:result . a:pathStr else - let l:result = l:result . s:Path.Slash() . a:pathStr + let l:result = l:result . nerdtree#slash() . a:pathStr endif endif @@ -37,7 +37,7 @@ endfunction " FUNCTION: Path.bookmarkNames() {{{1 function! s:Path.bookmarkNames() - if !exists("self._bookmarkNames") + if !exists('self._bookmarkNames') call self.cacheDisplayString() endif return self._bookmarkNames @@ -57,7 +57,7 @@ function! s:Path.cacheDisplayString() abort call add(self._bookmarkNames, i.name) endif endfor - if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 + if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks ==# 1 let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}' endif @@ -65,6 +65,25 @@ function! s:Path.cacheDisplayString() abort let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest endif + if !self.isDirectory && b:NERDTree.ui.getShowFileLines() != 0 + let l:bufname = self.str({'format': 'Edit'}) + let l:lines = 0 + if executable('wc') + let l:lines = split(system('wc -l "'.l:bufname.'"'))[0] + elseif nerdtree#runningWindows() + let l:lines = substitute(system('type "'.l:bufname.'" | find /c /v ""'), '\n', '', 'g') + else + let s:lines = readfile(l:bufname) + let l:lines = 0 + for s:line in s:lines + let l:lines += 1 + if l:lines >= 20000 + break + endif + endfor + endif + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ('.l:lines.')' + endif if self.isReadOnly let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ['.g:NERDTreeGlyphReadOnly.']' endif @@ -87,55 +106,16 @@ function! s:Path.changeToDir() endif try - execute "cd " . dir - call nerdtree#echo("CWD is now: " . getcwd()) - catch - throw "NERDTree.PathChangeError: cannot change CWD to " . dir - endtry -endfunction - -" FUNCTION: Path.compareTo() {{{1 -" -" Compares this Path to the given path and returns 0 if they are equal, -1 if -" this Path is "less than" the given path, or 1 if it is "greater". -" -" Args: -" path: the path object to compare this to -" -" Return: -" 1, -1 or 0 -function! s:Path.compareTo(path) - let thisPath = self.getLastPathComponent(1) - let thatPath = a:path.getLastPathComponent(1) - - "if the paths are the same then clearly we return 0 - if thisPath ==# thatPath - return 0 - endif - - let thisSS = self.getSortOrderIndex() - let thatSS = a:path.getSortOrderIndex() - - "compare the sort sequences, if they are different then the return - "value is easy - if thisSS < thatSS - return -1 - elseif thisSS > thatSS - return 1 - else - if !g:NERDTreeSortHiddenFirst - let thisPath = substitute(thisPath, '^[._]', '', '') - let thatPath = substitute(thatPath, '^[._]', '', '') - endif - "if the sort sequences are the same then compare the paths - "alphabetically - let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath $" endif - return " \\`\|\"#%&,?()\*^<>[]$" + return " \\`\|\"#%&,?()\*^<>[]{}$" endfunction " FUNCTION: Path.getDir() {{{1 @@ -397,7 +380,7 @@ function! s:Path._splitChunks(path) let i = 0 while i < len(chunks) "convert number literals to numbers - if match(chunks[i], '^\d\+$') == 0 + if match(chunks[i], '^\d\+$') ==# 0 let chunks[i] = str2nr(chunks[i]) endif let i = i + 1 @@ -408,21 +391,21 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder + if !exists('self._sortKey') || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder " Look for file metadata tags: [[timestamp]], [[extension]], [[size]] let metadata = [] for tag in g:NERDTreeSortOrder if tag =~? '\[\[-\?timestamp\]\]' - let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~ '-' ? -1 : 1)] + let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~# '-' ? -1 : 1)] elseif tag =~? '\[\[-\?size\]\]' - let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~ '-' ? -1 : 1)] + let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~# '-' ? -1 : 1)] elseif tag =~? '\[\[extension\]\]' let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$') - let metadata += [self.isDirectory ? '' : (extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension)] + let metadata += [self.isDirectory ? '' : (extension ==# '' ? nr2char(str2nr('0x10ffff',16)) : extension)] endif endfor - if g:NERDTreeSortOrder[0] =~ '\[\[.*\]\]' + if g:NERDTreeSortOrder[0] =~# '\[\[.*\]\]' " Apply tags' sorting first if specified first. let self._sortKey = metadata + [self.getSortOrderIndex()] else @@ -430,7 +413,7 @@ function! s:Path.getSortKey() let self._sortKey = [self.getSortOrderIndex()] + metadata endif - let path = self.getLastPathComponent(1) + let path = self.getLastPathComponent(0) if !g:NERDTreeSortHiddenFirst let path = substitute(path, '^[._]', '', '') endif @@ -495,9 +478,10 @@ function! s:Path.ignore(nerdtree) endif endfor - for callback in g:NERDTree.PathFilters() - if {callback}({'path': self, 'nerdtree': a:nerdtree}) - return 1 + for l:Callback in g:NERDTree.PathFilters() + let l:Callback = type(l:Callback) ==# type(function('tr')) ? l:Callback : function(l:Callback) + if l:Callback({'path': self, 'nerdtree': a:nerdtree}) + return 1 endif endfor endif @@ -518,12 +502,15 @@ endfunction " returns true if this path matches the given ignore pattern function! s:Path._ignorePatternMatches(pattern) let pat = a:pattern - if strpart(pat,len(pat)-7) == '[[dir]]' + if strpart(pat,len(pat)-8) ==# '[[path]]' + let pat = strpart(pat,0, len(pat)-8) + return self.str() =~# pat + elseif strpart(pat,len(pat)-7) ==# '[[dir]]' if !self.isDirectory return 0 endif let pat = strpart(pat,0, len(pat)-7) - elseif strpart(pat,len(pat)-8) == '[[file]]' + elseif strpart(pat,len(pat)-8) ==# '[[file]]' if self.isDirectory return 0 endif @@ -537,26 +524,36 @@ endfunction " return 1 if this path is somewhere above the given path in the filesystem. " " a:path should be a dir -function! s:Path.isAncestor(path) - if !self.isDirectory - return 0 - endif - - let this = self.str() - let that = a:path.str() - return stridx(that, this) == 0 +function! s:Path.isAncestor(child) + return a:child.isUnder(self) endfunction " FUNCTION: Path.isUnder(path) {{{1 " return 1 if this path is somewhere under the given path in the filesystem. -function! s:Path.isUnder(path) - if a:path.isDirectory == 0 +function! s:Path.isUnder(parent) + if a:parent.isDirectory ==# 0 return 0 endif - - let this = self.str() - let that = a:path.str() - return stridx(this, that . s:Path.Slash()) == 0 + if nerdtree#runningWindows() && a:parent.drive !=# self.drive + return 0 + endif + let l:this_count = len(self.pathSegments) + if l:this_count ==# 0 + return 0 + endif + let l:that_count = len(a:parent.pathSegments) + if l:that_count ==# 0 + return 1 + endif + if l:that_count >= l:this_count + return 0 + endif + for i in range(0, l:that_count-1) + if !nerdtree#pathEquals(self.pathSegments[i], a:parent.pathSegments[i]) + return 0 + endif + endfor + return 1 endfunction " FUNCTION: Path.JoinPathStrings(...) {{{1 @@ -576,11 +573,7 @@ endfunction " Args: " path: the other path obj to compare this with function! s:Path.equals(path) - if nerdtree#runningWindows() - return self.str() ==? a:path.str() - else - return self.str() ==# a:path.str() - endif + return nerdtree#pathEquals(self.str(), a:path.str()) endfunction " FUNCTION: Path.New(pathStr) {{{1 @@ -595,23 +588,6 @@ function! s:Path.New(pathStr) return l:newPath endfunction -" FUNCTION: Path.Slash() {{{1 -" Return the path separator used by the underlying file system. Special -" consideration is taken for the use of the 'shellslash' option on Windows -" systems. -function! s:Path.Slash() - - if nerdtree#runningWindows() - if exists('+shellslash') && &shellslash - return '/' - endif - - return '\' - endif - - return '/' -endfunction - " FUNCTION: Path.Resolve() {{{1 " Invoke the vim resolve() function and return the result " This is necessary because in some versions of vim resolve() removes trailing @@ -631,8 +607,8 @@ function! s:Path.readInfoFromDisk(fullpath) let fullpath = s:Path.WinToUnixPath(a:fullpath) - if getftype(fullpath) ==# "fifo" - throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath + if getftype(fullpath) ==# 'fifo' + throw 'NERDTree.InvalidFiletypeError: Cant handle FIFO files: ' . a:fullpath endif let self.pathSegments = filter(split(fullpath, '/'), '!empty(v:val)') @@ -644,7 +620,7 @@ function! s:Path.readInfoFromDisk(fullpath) let self.isDirectory = 0 let self.isReadOnly = filewritable(a:fullpath) ==# 0 else - throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath + throw 'NERDTree.InvalidArgumentsError: Invalid path = ' . a:fullpath endif let self.isExecutable = 0 @@ -659,7 +635,7 @@ function! s:Path.readInfoFromDisk(fullpath) let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent "if the last part of the path is a symlink then flag it as such - let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath) + let self.isSymLink = (s:Path.Resolve(hardPath) !=# hardPath) if self.isSymLink let self.symLinkDest = s:Path.Resolve(fullpath) @@ -694,13 +670,13 @@ endfunction " Renames this node on the filesystem function! s:Path.rename(newPath) if a:newPath ==# '' - throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath + throw 'NERDTree.InvalidArgumentsError: Invalid newPath for renaming = '. a:newPath endif call s:Path.createParentDirectories(a:newPath) let success = rename(self.str(), a:newPath) - if success != 0 + if success !=# 0 throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath endif call self.readInfoFromDisk(a:newPath) @@ -736,7 +712,7 @@ endfunction " value associated with 'truncateTo'. A '<' is prepended. function! s:Path.str(...) let options = a:0 ? a:1 : {} - let toReturn = "" + let toReturn = '' if has_key(options, 'format') let format = options['format'] @@ -773,7 +749,7 @@ endfunction " FUNCTION: Path._strForUI() {{{1 function! s:Path._strForUI() let toReturn = '/' . join(self.pathSegments, '/') - if self.isDirectory && toReturn != '/' + if self.isDirectory && toReturn !=# '/' let toReturn = toReturn . '/' endif return toReturn @@ -796,7 +772,7 @@ function! s:Path._strForEdit() " On Windows, the drive letter may be removed by "fnamemodify()". Add it " back, if necessary. - if nerdtree#runningWindows() && l:result[0] == s:Path.Slash() + if nerdtree#runningWindows() && l:result[0] == nerdtree#slash() let l:result = self.drive . l:result endif @@ -811,14 +787,14 @@ endfunction " FUNCTION: Path._strForGlob() {{{1 function! s:Path._strForGlob() - let lead = s:Path.Slash() + let lead = nerdtree#slash() "if we are running windows then slap a drive letter on the front if nerdtree#runningWindows() let lead = self.drive . '\' endif - let toReturn = lead . join(self.pathSegments, s:Path.Slash()) + let toReturn = lead . join(self.pathSegments, nerdtree#slash()) if !nerdtree#runningWindows() let toReturn = escape(toReturn, self._escChars()) @@ -830,7 +806,7 @@ endfunction " Return the absolute pathname associated with this Path object. The pathname " returned is appropriate for the underlying file system. function! s:Path._str() - let l:separator = s:Path.Slash() + let l:separator = nerdtree#slash() let l:leader = l:separator if nerdtree#runningWindows() @@ -877,13 +853,13 @@ function! s:Path.WinToUnixPath(pathstr) let toReturn = a:pathstr "remove the x:\ of the front - let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "") + let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', '') "remove the \\ network share from the front - let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "") + let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', '') "convert all \ chars to / - let toReturn = substitute(toReturn, '\', '/', "g") + let toReturn = substitute(toReturn, '\', '/', 'g') return toReturn endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim index aa9dea6a..3fb38331 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim @@ -14,7 +14,7 @@ let g:NERDTreeDirNode = s:TreeDirNode " Class method that returns the highest cached ancestor of the current root. function! s:TreeDirNode.AbsoluteTreeRoot() let currentNode = b:NERDTree.root - while currentNode.parent != {} + while currentNode.parent !=# {} let currentNode = currentNode.parent endwhile return currentNode @@ -100,20 +100,15 @@ function! s:TreeDirNode.displayString() let l:cascade = self.getCascade() for l:dirNode in l:cascade let l:next = l:dirNode.path.displayString() - let l:label .= l:label == '' ? l:next : substitute(l:next,'^.','','') + let l:label .= l:label ==# '' ? l:next : substitute(l:next,'^.','','') endfor " Select the appropriate open/closed status indicator symbol. - if l:cascade[-1].isOpen - let l:symbol = g:NERDTreeDirArrowCollapsible - else - let l:symbol = g:NERDTreeDirArrowExpandable - endif - + let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable ) + let l:symbol .= (g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') let l:flags = l:cascade[-1].path.flagSet.renderToString() - let l:result = l:symbol . ' ' . l:flags . l:label - return l:result + return l:symbol . l:flags . l:label endfunction " FUNCTION: TreeDirNode.findNode(path) {{{1 @@ -126,14 +121,20 @@ function! s:TreeDirNode.findNode(path) if a:path.equals(self.path) return self endif - if stridx(a:path.str(), self.path.str(), 0) ==# -1 - return {} + if nerdtree#caseSensitiveFS() + if stridx(a:path.str(), self.path.str(), 0) ==# -1 + return {} + endif + else + if stridx(tolower(a:path.str()), tolower(self.path.str()), 0) ==# -1 + return {} + endif endif if self.path.isDirectory for i in self.children let retVal = i.findNode(a:path) - if retVal != {} + if retVal !=# {} return retVal endif endfor @@ -169,7 +170,7 @@ function! s:TreeDirNode.getCascadeRoot() while !empty(l:parent) && !l:parent.isRoot() - if index(l:parent.getCascade(), self) == -1 + if index(l:parent.getCascade(), self) ==# -1 break endif @@ -218,7 +219,7 @@ endfunction function! s:TreeDirNode.getChildByIndex(indx, visible) let array_to_search = a:visible? self.getVisibleChildren() : self.children if a:indx > len(array_to_search) - throw "NERDTree.InvalidArgumentsError: Index is out of bounds." + throw 'NERDTree.InvalidArgumentsError: Index is out of bounds.' endif return array_to_search[a:indx] endfunction @@ -241,7 +242,7 @@ function! s:TreeDirNode.getChildIndex(path) let z = self.getChildCount() while a < z let mid = (a+z)/2 - let diff = a:path.compareTo(self.children[mid].path) + let diff = nerdtree#compareNodePaths(a:path, self.children[mid].path) if diff ==# -1 let z = mid @@ -255,10 +256,10 @@ function! s:TreeDirNode.getChildIndex(path) endfunction " FUNCTION: TreeDirNode.getDirChildren() {{{1 -" Return a list of all child nodes from "self.children" that are of type +" Return a list of all child nodes from 'self.children' that are of type " TreeDirNode. This function supports http://github.com/scrooloose/nerdtree-project-plugin.git. function! s:TreeDirNode.getDirChildren() - return filter(copy(self.children), 'v:val.path.isDirectory == 1') + return filter(copy(self.children), 'v:val.path.isDirectory ==# 1') endfunction " FUNCTION: TreeDirNode._glob(pattern, all) {{{1 @@ -267,7 +268,7 @@ endfunction " " Args: " pattern: (string) the glob pattern to apply -" all: (0 or 1) if 1, include "." and ".." if they match "pattern"; if 0, +" all: (0 or 1) if 1, include '.' and '..' if they match 'pattern'; if 0, " always exclude them " " Note: If the pathnames in the result list are below the working directory, @@ -276,28 +277,32 @@ endfunction " relative paths. function! s:TreeDirNode._glob(pattern, all) - " Construct a path specification such that "globpath()" will return + " Construct a path specification such that globpath() will return " relative pathnames, if possible. - if self.path.str() == getcwd() + if self.path.str() ==# getcwd() let l:pathSpec = ',' else let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') + if nerdtree#runningWindows() + let l:pathSpec = substitute(l:pathSpec, "\\[\\(.*\\]\\)", "[[]\\1", "g") + endif + " On Windows, the drive letter may be removed by "fnamemodify()". - if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash() + if nerdtree#runningWindows() && l:pathSpec[0] == nerdtree#slash() let l:pathSpec = self.path.drive . l:pathSpec endif endif let l:globList = [] - " See ":h version7.txt" and ":h version8.txt" for details on the - " development of the "glob()" and "globpath()" functions. - if v:version > 704 || (v:version == 704 && has('patch654')) + " See ':h version7.txt' and ':h version8.txt' for details on the + " development of the glob() and globpath() functions. + if v:version > 704 || (v:version ==# 704 && has('patch654')) let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0) - elseif v:version == 704 && has('patch279') + elseif v:version ==# 704 && has('patch279') let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1) - elseif v:version > 702 || (v:version == 702 && has('patch051')) + elseif v:version > 702 || (v:version ==# 702 && has('patch051')) let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore) let l:globList = split(l:globString, "\n") else @@ -305,7 +310,7 @@ function! s:TreeDirNode._glob(pattern, all) let l:globList = split(l:globString, "\n") endif - " If "a:all" is false, filter "." and ".." from the output. + " If a:all is false, filter '.' and '..' from the output. if !a:all let l:toRemove = [] @@ -315,13 +320,13 @@ function! s:TreeDirNode._glob(pattern, all) " If l:file has a trailing slash, then its :tail will be ''. Use " :h to drop the slash and the empty string after it; then use :t " to get the directory name. - if l:tail == '' + if l:tail ==# '' let l:tail = fnamemodify(l:file, ':h:t') endif - if l:tail == '.' || l:tail == '..' + if l:tail ==# '.' || l:tail ==# '..' call add(l:toRemove, l:file) - if len(l:toRemove) == 2 + if len(l:toRemove) ==# 2 break endif endif @@ -341,7 +346,7 @@ endfunction unlet s:TreeDirNode.GetSelected function! s:TreeDirNode.GetSelected() let currentDir = g:NERDTreeFileNode.GetSelected() - if currentDir != {} && !currentDir.isRoot() + if currentDir !=# {} && !currentDir.isRoot() if currentDir.path.isDirectory ==# 0 let currentDir = currentDir.parent endif @@ -373,7 +378,7 @@ endfunction " FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 " returns 1 if this node has any childre, 0 otherwise.. function! s:TreeDirNode.hasVisibleChildren() - return self.getVisibleChildCount() != 0 + return self.getVisibleChildCount() !=# 0 endfunction " FUNCTION: TreeDirNode.isCascadable() {{{1 @@ -382,8 +387,14 @@ endfunction " 1. If cascaded, we don't know which dir is bookmarked or is a symlink. " 2. If the parent is a symlink or is bookmarked, you end up with unparsable " text, and NERDTree cannot get the path of any child node. +" Also, return false if this directory is the tree root, which should never be +" part of a cascade. function! s:TreeDirNode.isCascadable() - if g:NERDTreeCascadeSingleChildDir == 0 + if g:NERDTreeCascadeSingleChildDir ==# 0 + return 0 + endif + + if self.isRoot() return 0 endif @@ -398,14 +409,14 @@ function! s:TreeDirNode.isCascadable() endfor let c = self.getVisibleChildren() - return len(c) == 1 && c[0].path.isDirectory + return len(c) ==# 1 && c[0].path.isDirectory endfunction " FUNCTION: TreeDirNode._initChildren() {{{1 " Removes all childen from this node and re-reads them " " Args: -" silent: 1 if the function should not echo any "please wait" messages for +" silent: 1 if the function should not echo any 'please wait' messages for " large directories " " Return: the number of child nodes read @@ -416,10 +427,11 @@ function! s:TreeDirNode._initChildren(silent) let files = self._glob('*', 1) + self._glob('.*', 0) if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call nerdtree#echo("Please wait, caching a large dir ...") + call nerdtree#echo('Please wait, caching a large dir ...') endif let invalidFilesFound = 0 + let invalidFiles = [] for i in files try let path = g:NERDTreePath.New(i) @@ -427,15 +439,17 @@ function! s:TreeDirNode._initChildren(silent) call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {}) catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ let invalidFilesFound += 1 + let invalidFiles += [i] endtry endfor + let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder call self.sortChildren() - call nerdtree#echo("") + call nerdtree#echo('') if invalidFilesFound - call nerdtree#echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree") + call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', ')) endif return self.getChildCount() endfunction @@ -447,8 +461,8 @@ endfunction " path: dir that the node represents " nerdtree: the tree the node belongs to function! s:TreeDirNode.New(path, nerdtree) - if a:path.isDirectory != 1 - throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object." + if a:path.isDirectory !=# 1 + throw 'NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object.' endif let newTreeNode = copy(self) @@ -510,7 +524,7 @@ function! s:TreeDirNode.openAlong(...) while node.path.isDirectory call node.open(opts) let level += 1 - if node.getVisibleChildCount() == 1 + if node.getVisibleChildCount() ==# 1 let node = node.getChildByIndex(0, 1) else break @@ -523,7 +537,8 @@ endfunction " Open an explorer window for this node in the previous window. The explorer " can be a NERDTree window or a netrw window. function! s:TreeDirNode.openExplorer() - call self.open({'where': 'p'}) + execute 'wincmd p' + execute 'edit '.self.path.str({'format':'Edit'}) endfunction " FUNCTION: TreeDirNode.openInNewTab(options) {{{1 @@ -561,12 +576,13 @@ function! s:TreeDirNode.refresh() let files = self._glob('*', 1) + self._glob('.*', 0) let newChildNodes = [] let invalidFilesFound = 0 + let invalidFiles = [] for i in files try "create a new path and see if it exists in this nodes children let path = g:NERDTreePath.New(i) let newNode = self.getChild(path) - if newNode != {} + if newNode !=# {} && path.str() ==# newNode.path.str() call newNode.refresh() call add(newChildNodes, newNode) @@ -577,7 +593,8 @@ function! s:TreeDirNode.refresh() call add(newChildNodes, newNode) endif catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ - let invalidFilesFound = 1 + let invalidFilesFound += 1 + let invalidFiles += [i] endtry endfor @@ -586,7 +603,7 @@ function! s:TreeDirNode.refresh() call self.sortChildren() if invalidFilesFound - call nerdtree#echoWarning("some files could not be loaded into the NERD tree") + call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', ')) endif endif endfunction @@ -613,7 +630,7 @@ function! s:TreeDirNode.reveal(path, ...) let opts = a:0 ? a:1 : {} if !a:path.isUnder(self.path) - throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() + throw 'NERDTree.InvalidArgumentsError: ' . a:path.str() . ' should be under ' . self.path.str() endif call self.open() @@ -621,11 +638,11 @@ function! s:TreeDirNode.reveal(path, ...) if self.path.equals(a:path.getParent()) let n = self.findNode(a:path) " We may be looking for a newly-saved file that isn't in the tree yet. - if n == {} + if n ==# {} call self.refresh() let n = self.findNode(a:path) endif - if has_key(opts, "open") + if has_key(opts, 'open') call n.open() endif return n @@ -641,8 +658,8 @@ function! s:TreeDirNode.reveal(path, ...) endfunction " FUNCTION: TreeDirNode.removeChild(treenode) {{{1 -" Remove the given treenode from "self.children". -" Throws "NERDTree.ChildNotFoundError" if the node is not found. +" Remove the given treenode from self.children. +" Throws NERDTree.ChildNotFoundError if the node is not found. " " Args: " treenode: the node object to remove @@ -654,16 +671,16 @@ function! s:TreeDirNode.removeChild(treenode) endif endfor - throw "NERDTree.ChildNotFoundError: child node was not found" + throw 'NERDTree.ChildNotFoundError: child node was not found' endfunction " FUNCTION: TreeDirNode.sortChildren() {{{1 -" Sort "self.children" by alphabetical order and directory priority. +" Sort self.children by alphabetical order and directory priority. function! s:TreeDirNode.sortChildren() if count(g:NERDTreeSortOrder, '*') < 1 call add(g:NERDTreeSortOrder, '*') endif - let CompareFunc = function("nerdtree#compareNodesBySortKey") + let CompareFunc = function('nerdtree#compareNodes') call sort(self.children, CompareFunc) let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder endfunction @@ -675,7 +692,7 @@ function! s:TreeDirNode.toggleOpen(...) if self.isOpen ==# 1 call self.close() else - if g:NERDTreeCascadeOpenSingleChildDir == 0 + if g:NERDTreeCascadeOpenSingleChildDir ==# 0 call self.open(opts) else call self.openAlong(opts) diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim index d4c060fc..957b98ac 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim @@ -1,7 +1,7 @@ " ============================================================================ " CLASS: TreeFileNode " -" This class is the parent of the "TreeDirNode" class and is the "Component" +" This class is the parent of the TreeDirNode class and is the 'Component' " part of the composite design pattern between the NERDTree node classes. " ============================================================================ @@ -42,7 +42,7 @@ function! s:TreeFileNode.cacheParent() if empty(self.parent) let parentPath = self.path.getParent() if parentPath.equals(self.path) - throw "NERDTree.CannotCacheParentError: already at root" + throw 'NERDTree.CannotCacheParentError: already at root' endif let self.parent = s:TreeFileNode.New(parentPath, self.getNerdtree()) endif @@ -195,7 +195,7 @@ endfunction " FUNCTION: TreeFileNode.isRoot() {{{1 function! s:TreeFileNode.isRoot() if !g:NERDTree.ExistsForBuf() - throw "NERDTree.NoTreeError: No tree exists for the current buffer" + throw 'NERDTree.NoTreeError: No tree exists for the current buffer' endif return self.equals(self.getNerdtree().root) @@ -246,6 +246,12 @@ function! s:TreeFileNode.openInNewTab(options) call self.open(extend({'where': 't'}, a:options)) endfunction +" FUNCTION: TreeFileNode.openExplorer() +function! s:TreeFileNode.openExplorer() + execute 'wincmd p' + execute 'edit '.self.path.getParent().str({'format':'Edit'}) +endfunction + " FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 " Places the cursor on the line number this node is rendered on " @@ -259,7 +265,7 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) if a:isJump mark ' endif - call cursor(ln, col(".")) + call cursor(ln, col('.')) else if a:recurseUpward let node = self @@ -311,17 +317,13 @@ endfunction " child nodes are rendered only) " for each depth in the tree function! s:TreeFileNode._renderToString(depth, drawText) - let output = "" + let output = '' if a:drawText ==# 1 let treeParts = repeat(' ', a:depth - 1) - - if !self.path.isDirectory - let treeParts = treeParts . ' ' - endif + let treeParts .= (self.path.isDirectory || g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') let line = treeParts . self.displayString() - let output = output . line . "\n" endif diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim index d384071d..867e04b1 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -27,94 +27,100 @@ function! s:UI._dumpHelp() let help = "\" NERDTree (" . nerdtree#version() . ") quickhelp~\n" let help .= "\" ============================\n" let help .= "\" File node mappings~\n" - let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" + let help .= '" '. (g:NERDTreeMouseMode ==# 3 ? 'single' : 'double') ."-click,\n" if self.nerdtree.isTabTree() - let help .= "\" ". g:NERDTreeMapActivateNode .": open in prev window\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open in prev window\n" else - let help .= "\" ". g:NERDTreeMapActivateNode .": open in current window\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open in current window\n" endif if self.nerdtree.isTabTree() - let help .= "\" ". g:NERDTreeMapPreview .": preview\n" + let help .= '" '. g:NERDTreeMapPreview .": preview\n" endif - let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" let help .= "\" middle-click,\n" - let help .= "\" ". g:NERDTreeMapOpenSplit .": open split\n" - let help .= "\" ". g:NERDTreeMapPreviewSplit .": preview split\n" - let help .= "\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" - let help .= "\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" - let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" + let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n" + let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Directory node mappings~\n" - let help .= "\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" - let help .= "\" ". g:NERDTreeMapActivateNode .": open & close node\n" - let help .= "\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" - let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" - let help .= "\" ". g:NERDTreeMapCloseDir .": close parent of node\n" - let help .= "\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" + let help .= '" '. (g:NERDTreeMouseMode ==# 1 ? 'double' : 'single') ."-click,\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open & close node\n" + let help .= '" '. g:NERDTreeMapOpenRecursively .": recursively open node\n" + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" + let help .= '" '. g:NERDTreeMapCloseDir .": close parent of node\n" + let help .= '" '. g:NERDTreeMapCloseChildren .": close all child nodes of\n" let help .= "\" current node recursively\n" let help .= "\" middle-click,\n" - let help .= "\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" + let help .= '" '. g:NERDTreeMapOpenExpl.": explore selected dir\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Bookmark table mappings~\n" let help .= "\" double-click,\n" - let help .= "\" ". g:NERDTreeMapActivateNode .": open bookmark\n" - let help .= "\" ". g:NERDTreeMapPreview .": preview file\n" - let help .= "\" ". g:NERDTreeMapPreview .": find dir in tree\n" - let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" - let help .= "\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\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" + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n" + let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" + let help .= '" '. g:NERDTreeMapDeleteBookmark .": delete bookmark\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Tree navigation mappings~\n" - let help .= "\" ". g:NERDTreeMapJumpRoot .": go to root\n" - let help .= "\" ". g:NERDTreeMapJumpParent .": go to parent\n" - let help .= "\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" - let help .= "\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" - let help .= "\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" - let help .= "\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" + let help .= '" '. g:NERDTreeMapJumpRoot .": go to root\n" + let help .= '" '. g:NERDTreeMapJumpParent .": go to parent\n" + let help .= '" '. g:NERDTreeMapJumpFirstChild .": go to first child\n" + let help .= '" '. g:NERDTreeMapJumpLastChild .": go to last child\n" + let help .= '" '. g:NERDTreeMapJumpNextSibling .": go to next sibling\n" + let help .= '" '. g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Filesystem mappings~\n" - let help .= "\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" + let help .= '" '. g:NERDTreeMapChangeRoot .": change tree root to the\n" let help .= "\" selected dir\n" - let help .= "\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" - let help .= "\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" + let help .= '" '. g:NERDTreeMapUpdir .": move tree root up a dir\n" + let help .= '" '. g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" let help .= "\" but leave old root open\n" - let help .= "\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" - let help .= "\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" - let help .= "\" ". g:NERDTreeMapMenu .": Show menu\n" - let help .= "\" ". g:NERDTreeMapChdir .":change the CWD to the\n" + let help .= '" '. g:NERDTreeMapRefresh .": refresh cursor dir\n" + let help .= '" '. g:NERDTreeMapRefreshRoot .": refresh current root\n" + let help .= '" '. g:NERDTreeMapMenu .": Show menu\n" + let help .= '" '. g:NERDTreeMapChdir .":change the CWD to the\n" let help .= "\" selected dir\n" - let help .= "\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" + let help .= '" '. g:NERDTreeMapCWD .":change tree root to CWD\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Tree filtering mappings~\n" - let help .= "\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n" - let help .= "\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n" - let help .= "\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n" - let help .= "\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n" + let help .= '" '. g:NERDTreeMapToggleHidden .': hidden files (' . (self.getShowHidden() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleFilters .': file filters (' . (self.isIgnoreFilterEnabled() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleFiles .': files (' . (self.getShowFiles() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleBookmarks .': bookmarks (' . (self.getShowBookmarks() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleFileLines .': files lines (' . (self.getShowFileLines() ? 'on' : 'off') . ")\n" " add quickhelp entries for each custom key map let help .= "\"\n\" ----------------------------\n" let help .= "\" Custom mappings~\n" for i in g:NERDTreeKeyMap.All() if !empty(i.quickhelpText) - let help .= "\" ". i.key .": ". i.quickhelpText ."\n" + let help .= '" '. i.key .': '. i.quickhelpText ."\n" endif endfor let help .= "\"\n\" ----------------------------\n" let help .= "\" Other mappings~\n" - let help .= "\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n" - let help .= "\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" + let help .= '" '. g:NERDTreeMapQuit .": Close the NERDTree window\n" + let help .= '" '. g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" let help .= "\" the NERDTree window\n" - let help .= "\" ". g:NERDTreeMapHelp .": toggle help\n" + let help .= '" '. g:NERDTreeMapHelp .": toggle help\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Bookmark commands~\n" let help .= "\" :Bookmark []\n" @@ -128,7 +134,7 @@ function! s:UI._dumpHelp() let help .= "\" :EditBookmarks\n" silent! put =help elseif !self.isMinimal() - let help ="\" Press ". g:NERDTreeMapHelp ." for help\n" + let help ='" Press '. g:NERDTreeMapHelp ." for help\n" silent! put =help endif endfunction @@ -143,13 +149,14 @@ function! s:UI.New(nerdtree) let newObj._showFiles = g:NERDTreeShowFiles let newObj._showHidden = g:NERDTreeShowHidden let newObj._showBookmarks = g:NERDTreeShowBookmarks + let newObj._showFileLines = g:NERDTreeFileLines return newObj endfunction " FUNCTION: s:UI.getPath(ln) {{{1 -" Return the "Path" object for the node that is rendered on the given line -" number. If the "up a dir" line is selected, return the "Path" object for +" Return the Path object for the node that is rendered on the given line +" number. If the 'up a dir' line is selected, return the Path object for " the parent of the root. Return the empty dictionary if the given line " does not reference a tree node. function! s:UI.getPath(ln) @@ -157,7 +164,7 @@ function! s:UI.getPath(ln) let rootLine = self.getRootLineNum() - if a:ln == rootLine + if a:ln ==# rootLine return self.nerdtree.root.path endif @@ -174,7 +181,7 @@ function! s:UI.getPath(ln) " remove the tree parts and the leading space let curFile = self._stripMarkup(line) - let dir = "" + let dir = '' let lnum = a:ln while lnum > 0 let lnum = lnum - 1 @@ -182,7 +189,7 @@ function! s:UI.getPath(ln) let curLineStripped = self._stripMarkup(curLine) " have we reached the top of the tree? - if lnum == rootLine + if lnum ==# rootLine let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir break endif @@ -191,7 +198,7 @@ function! s:UI.getPath(ln) if lpindent < indent let indent = indent - 1 - let dir = substitute (curLineStripped,'^\\', "", "") . dir + let dir = substitute (curLineStripped,'^\\', '', '') . dir continue endif endif @@ -219,17 +226,17 @@ function! s:UI.getLineNum(node) let l:currentLine = getline(l:lineNumber) let l:indentLevel = self._indentLevelFor(l:currentLine) - if l:indentLevel != l:currentPathComponent + if l:indentLevel !=# l:currentPathComponent continue endif let l:currentLine = self._stripMarkup(l:currentLine) let l:currentPath = join(l:pathComponents, '/') . '/' . l:currentLine - " Directories: If the current path "starts with" the full path, then + " Directories: If the current path 'starts with' the full path, then " either the paths are equal or the line is a cascade containing the " full path. - if l:fullPath[-1:] == '/' && stridx(l:currentPath, l:fullPath) == 0 + if l:fullPath[-1:] ==# '/' && stridx(l:currentPath, l:fullPath) ==# 0 return l:lineNumber endif @@ -240,7 +247,7 @@ function! s:UI.getLineNum(node) " Otherwise: If the full path starts with the current path and the " current path is a directory, we add a new path component. - if stridx(l:fullPath, l:currentPath) == 0 && l:currentPath[-1:] == '/' + if stridx(l:fullPath, l:currentPath) ==# 0 && l:currentPath[-1:] ==# '/' let l:currentLine = substitute(l:currentLine, '/\s*$', '', '') call add(l:pathComponents, l:currentLine) let l:currentPathComponent += 1 @@ -280,11 +287,20 @@ function! s:UI.getShowHidden() return self._showHidden endfunction +" FUNCTION: s:UI.getShowFileLines() {{{1 +function! s:UI.getShowFileLines() + return self._showFileLines +endfunction + " FUNCTION: s:UI._indentLevelFor(line) {{{1 function! s:UI._indentLevelFor(line) " Replace multi-character DirArrows with a single space so the " indentation calculation doesn't get messed up. - let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + if g:NERDTreeDirArrowExpandable ==# '' + let l:line = ' '.a:line + else + let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + endif let leadChars = match(l:line, '\M\[^ ]') return leadChars / s:UI.IndentWid() endfunction @@ -296,7 +312,7 @@ endfunction " FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 function! s:UI.isIgnoreFilterEnabled() - return self._ignoreEnabled == 1 + return self._ignoreEnabled ==# 1 endfunction " FUNCTION: s:UI.isMinimal() {{{1 @@ -313,21 +329,21 @@ endfunction function! s:UI._renderBookmarks() if !self.isMinimal() - call setline(line(".")+1, ">----------Bookmarks----------") - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, '>----------Bookmarks----------') + call cursor(line('.')+1, col('.')) endif - if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 + if g:NERDTreeBookmarksSort ==# 1 || g:NERDTreeBookmarksSort ==# 2 call g:NERDTreeBookmark.SortBookmarksList() endif for i in g:NERDTreeBookmark.Bookmarks() - call setline(line(".")+1, i.str()) - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, i.str()) + call cursor(line('.')+1, col('.')) endfor - call setline(line(".")+1, '') - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, '') + call cursor(line('.')+1, col('.')) endfunction " FUNCTION: s:UI.restoreScreenState() {{{1 @@ -340,13 +356,13 @@ function! s:UI.restoreScreenState() if !has_key(self, '_screenState') return endif - call nerdtree#exec("silent vertical resize " . self._screenState['oldWindowSize'], 1) + call nerdtree#exec('silent vertical resize ' . self._screenState['oldWindowSize'], 1) let old_scrolloff=&scrolloff let &scrolloff=0 call cursor(self._screenState['oldTopLine'], 0) normal! zt - call setpos(".", self._screenState['oldPos']) + call setpos('.', self._screenState['oldPos']) let &scrolloff=old_scrolloff endfunction @@ -355,12 +371,15 @@ endfunction " scroll position function! s:UI.saveScreenState() let win = winnr() - call g:NERDTree.CursorToTreeWin() let self._screenState = {} - let self._screenState['oldPos'] = getpos(".") - let self._screenState['oldTopLine'] = line("w0") - let self._screenState['oldWindowSize']= winwidth("") - call nerdtree#exec(win . "wincmd w", 1) + try + call g:NERDTree.CursorToTreeWin() + let self._screenState['oldPos'] = getpos('.') + let self._screenState['oldTopLine'] = line('w0') + let self._screenState['oldWindowSize'] = winnr('$')==1 ? g:NERDTreeWinSize : winwidth('') + call nerdtree#exec(win . 'wincmd w', 1) + catch + endtry endfunction " FUNCTION: s:UI.setShowHidden(val) {{{1 @@ -384,9 +403,9 @@ function! s:UI.render() " remember the top line of the buffer and the current line so we can " restore the view exactly how it was - let curLine = line(".") - let curCol = col(".") - let topLine = line("w0") + let curLine = line('.') + let curCol = col('.') + let topLine = line('w0') " delete all lines in the buffer (being careful not to clobber a register) silent 1,$delete _ @@ -395,8 +414,8 @@ function! s:UI.render() " delete the blank line before the help and add one after it if !self.isMinimal() - call setline(line(".")+1, "") - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, '') + call cursor(line('.')+1, col('.')) endif if self.getShowBookmarks() @@ -405,14 +424,14 @@ function! s:UI.render() " add the 'up a dir' line if !self.isMinimal() - call setline(line(".")+1, s:UI.UpDirLine()) - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, s:UI.UpDirLine()) + call cursor(line('.')+1, col('.')) endif " draw the header line let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) - call setline(line(".")+1, header) - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, header) + call cursor(line('.')+1, col('.')) " draw the tree silent put =self.nerdtree.root.renderToString() @@ -440,13 +459,13 @@ function! s:UI.renderViewSavingPosition() " go up the tree till we find a node that will be visible or till we run " out of nodes - while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() + while currentNode !=# {} && !currentNode.isVisible() && !currentNode.isRoot() let currentNode = currentNode.parent endwhile call self.render() - if currentNode != {} + if currentNode !=# {} call currentNode.putCursorHere(0, 0) endif endfunction @@ -464,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() @@ -485,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() @@ -501,15 +526,26 @@ function! s:UI.toggleShowHidden() call self.centerView() endfunction +" FUNCTION: s:UI.toggleShowFileLines() {{{1 +" toggles the display of file lines +function! s:UI.toggleShowFileLines() + let self._showFileLines = !self._showFileLines + call self.nerdtree.root.refresh() + call self.renderViewSavingPosition() + call self.centerView() +endfunction + " FUNCTION: s:UI.toggleZoom() {{{1 " zoom (maximize/minimize) the NERDTree window function! s:UI.toggleZoom() - if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call nerdtree#exec("silent vertical resize ". size, 1) + if exists('b:NERDTreeZoomed') && b:NERDTreeZoomed + setlocal nowinfixwidth + wincmd = + setlocal winfixwidth + call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1) let b:NERDTreeZoomed = 0 else - call nerdtree#exec("vertical resize ". get(g:, 'NERDTreeWinSizeMax', ''), 1) + call nerdtree#exec('vertical resize '. get(g:, 'NERDTreeWinSizeMax', ''), 1) let b:NERDTreeZoomed = 1 endif endfunction diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim b/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim index c53650a5..fb6c4862 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim @@ -9,7 +9,7 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " " ============================================================================ -if exists("g:loaded_nerdtree_exec_menuitem") +if exists('g:loaded_nerdtree_exec_menuitem') finish endif let g:loaded_nerdtree_exec_menuitem = 1 @@ -32,9 +32,9 @@ function! NERDTreeExecFile() let cmd = treenode.path.str({'escape': 1}) let cmd = input(':!', cmd . ' ') - if cmd != '' + if cmd !=# '' exec ':!' . cmd else - echo "Aborted" + echo 'Aborted' endif endfunction diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim index 0a5de8a4..45126dde 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -9,13 +9,13 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " " ============================================================================ -if exists("g:loaded_nerdtree_fs_menu") +if exists('g:loaded_nerdtree_fs_menu') finish endif let g:loaded_nerdtree_fs_menu = 1 "Automatically delete the buffer after deleting or renaming a file -if !exists("g:NERDTreeAutoDeleteBuffer") +if !exists('g:NERDTreeAutoDeleteBuffer') let g:NERDTreeAutoDeleteBuffer = 0 endif @@ -23,65 +23,75 @@ call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callbac call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -if has("gui_mac") || has("gui_macvim") || has("mac") - call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) +if nerdtree#runningMac() + call NERDTreeAddMenuItem({'text': '(r)eveal the current node in the Finder', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) endif -if executable("xdg-open") +if executable('xdg-open') call NERDTreeAddMenuItem({'text': '(r)eveal the current node in file manager', 'shortcut': 'r', 'callback': 'NERDTreeRevealFileLinux'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) endif +if nerdtree#runningWindows() + call NERDTreeAddMenuItem({'text': '(r)eveal the current node in the Explorer', 'shortcut': 'r', 'callback': 'NERDTreeRevealInExplorer'}) + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'}) +endif + if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif -call NERDTreeAddMenuItem({'text': (has("clipboard")?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) +call NERDTreeAddMenuItem({'text': (has('clipboard')?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) -if has("unix") || has("osx") +if has('unix') || has('osx') call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) + call NERDTreeAddMenuItem({'text': '(C)hange node permissions', 'shortcut':'C', 'callback': 'NERDTreeChangePermissions'}) else call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) endif +if exists('*system') + call NERDTreeAddMenuItem({'text': 'Run (s)ystem command in this directory', 'shortcut':'s', 'callback': 'NERDTreeSystemCommand'}) +endif + "FUNCTION: s:inputPrompt(action){{{1 "returns the string that should be prompted to the user for the given action " "Args: "action: the action that is being performed, e.g. 'delete' function! s:inputPrompt(action) - if a:action == "add" - let title = "Add a childnode" + if a:action ==# 'add' + let title = 'Add a childnode' let info = "Enter the dir/file name to be created. Dirs end with a '/'" - let minimal = "Add node:" + let minimal = 'Add node:' - elseif a:action == "copy" - let title = "Copy the current node" - let info = "Enter the new path to copy the node to:" - let minimal = "Copy to:" + elseif a:action ==# 'copy' + let title = 'Copy the current node' + let info = 'Enter the new path to copy the node to:' + let minimal = 'Copy to:' - elseif a:action == "delete" - let title = "Delete the current node" - let info = "Are you sure you wish to delete the node:" - let minimal = "Delete?" + elseif a:action ==# 'delete' + let title = 'Delete the current node' + let info = 'Are you sure you wish to delete the node:' + let minimal = 'Delete?' - elseif a:action == "deleteNonEmpty" - let title = "Delete the current node" + elseif a:action ==# 'deleteNonEmpty' + let title = 'Delete the current node' let info = "STOP! Directory is not empty! To delete, type 'yes'" - let minimal = "Delete directory?" + let minimal = 'Delete directory?' - elseif a:action == "move" - let title = "Rename the current node" - let info = "Enter the new path for the node:" - let minimal = "Move to:" + elseif a:action ==# 'move' + let title = 'Rename the current node' + let info = 'Enter the new path for the node:' + let minimal = 'Move to:' endif if g:NERDTreeMenuController.isMinimal() redraw! " Clear the menu - return minimal . " " + return minimal . ' ' else - let divider = "==========================================================" + let divider = '==========================================================' return title . "\n" . divider . "\n" . info . "\n" end endfunction @@ -114,14 +124,14 @@ function! s:promptToDelBuffer(bufnum, msg) let l:listedBufferCount = 0 endif if l:listedBufferCount > 1 - call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':bnext! ' | endif", 1) else - call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':enew! ' | endif", 1) endif - call nerdtree#exec("tabnext " . s:originalTabNumber, 1) - call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1) + call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) + call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) " 3. We don't need a previous buffer anymore - call nerdtree#exec("bwipeout! " . a:bufnum, 0) + call nerdtree#exec('bwipeout! ' . a:bufnum, 0) endif endfunction @@ -140,18 +150,38 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) let quotedFileName = fnameescape(a:newNodeName) let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) endif - " 1. ensure that a new buffer is loaded - call nerdtree#exec("badd " . quotedFileName, 1) - " 2. ensure that all windows which display the just deleted filename - " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) - call nerdtree#exec("tabnext " . s:originalTabNumber, 1) - call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1) - " 3. We don't need a previous buffer anymore + let l:tempBufferName = 'NERDTreeRenameTempBuffer' + + " 1. swap deleted file buffer with a temporary one + " this step is needed to compensate for case insensitive filesystems + + " 1.1. create an intermediate(temporary) buffer + call nerdtree#exec('badd ' . l:tempBufferName, 0) + let l:tempBufNum = bufnr(l:tempBufferName) + " 1.2. ensure that all windows which display the just deleted filename + " display the new temp buffer. + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . l:tempBufferName . "' | endif", 0) + " 1.3. We don't need the deleted file buffer anymore try - call nerdtree#exec("confirm bwipeout " . a:bufNum, 0) + call nerdtree#exec('confirm bwipeout ' . a:bufNum, 0) + catch + " This happens when answering Cancel if confirmation is needed. Do nothing. + endtry + + " 2. swap temporary buffer with the new filename buffer + " 2.1. create the actual new file buffer + call nerdtree#exec('badd ' . quotedFileName, 0) + + " 2.2. ensure that all windows which display the temporary buffer + " display a buffer for the new filename. + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . l:tempBufNum . " | exec ':e! " . editStr . "' | endif", 0) + call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) + call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) + " 2.3. We don't need the temporary buffer anymore + try + call nerdtree#exec('confirm bwipeout ' . l:tempBufNum, 0) catch " This happens when answering Cancel if confirmation is needed. Do nothing. endtry @@ -160,11 +190,11 @@ endfunction "FUNCTION: NERDTreeAddNode(){{{1 function! NERDTreeAddNode() let curDirNode = g:NERDTreeDirNode.GetSelected() - let prompt = s:inputPrompt("add") - let newNodeName = input(prompt, curDirNode.path.str() . g:NERDTreePath.Slash(), "file") + let prompt = s:inputPrompt('add') + let newNodeName = substitute(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'), '\(^\s*\|\s*$\)', '', 'g') if newNodeName ==# '' - call nerdtree#echo("Node Creation Aborted.") + call nerdtree#echo('Node Creation Aborted.') return endif @@ -187,26 +217,49 @@ function! NERDTreeAddNode() redraw! catch /^NERDTree/ - call nerdtree#echoWarning("Node Not Created.") + call nerdtree#echoWarning('Node Not Created.') endtry endfunction "FUNCTION: NERDTreeMoveNode(){{{1 function! NERDTreeMoveNode() let curNode = g:NERDTreeFileNode.GetSelected() - let prompt = s:inputPrompt("move") - let newNodePath = input(prompt, curNode.path.str(), "file") + let prompt = s:inputPrompt('move') + let newNodePath = input(prompt, curNode.path.str(), 'file') + while filereadable(newNodePath) + " allow renames with different casing when g:NERDTreeCaseSensitiveFS + " is set to either 0 or 3 and the 2 paths are equal + if (g:NERDTreeCaseSensitiveFS == 0 || g:NERDTreeCaseSensitiveFS == 3) && + \nerdtree#pathEquals(curNode.path.str(), newNodePath) + break + endif + + call nerdtree#echoWarning('This destination already exists, Try again.') + + " inform the user about the flag if we think it is a false positive + " when g:NERDTreeCaseSensitiveFS is set to 2 + if g:NERDTreeCaseSensitiveFS == 2 && + \!nerdtree#osDefaultCaseSensitiveFS() && + \nerdtree#pathEquals(curNode.path.str(), newNodePath) + echon "\n(If it is a false positive please consider assigning NERDTreeCaseSensitiveFS's value)" + endif + + " prompt the user again + let newNodePath = substitute(input(prompt, curNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') + endwhile + if newNodePath ==# '' - call nerdtree#echo("Node Renaming Aborted.") + call nerdtree#echo('Node Renaming Aborted.') return endif try if curNode.path.isDirectory - let l:openBuffers = filter(range(1,bufnr("$")),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"') + let l:curPath = escape(curNode.path.str(),'\') . (nerdtree#runningWindows()?'\\':'/') . '.*' + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# "'.escape(l:curPath,'\').'"') else - let l:openBuffers = filter(range(1,bufnr("$")),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') endif call curNode.rename(newNodePath) @@ -221,9 +274,9 @@ function! NERDTreeMoveNode() " renamed files. if !empty(l:openBuffers) if curNode.path.isDirectory - echo "\nDirectory renamed.\n\nFiles with the old directory name are open in buffers " . join(l:openBuffers, ', ') . ". Replace these buffers with the new files? (yN)" + echo "\nDirectory renamed.\n\nFiles with the old directory name are open in buffers " . join(l:openBuffers, ', ') . '. Replace these buffers with the new files? (yN)' else - echo "\nFile renamed.\n\nThe old file is open in buffer " . l:openBuffers[0] . ". Replace this buffer with the new file? (yN)" + echo "\nFile renamed.\n\nThe old file is open in buffer " . l:openBuffers[0] . '. Replace this buffer with the new file? (yN)' endif if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' for bufNum in l:openBuffers @@ -236,24 +289,22 @@ function! NERDTreeMoveNode() redraw! catch /^NERDTree/ - call nerdtree#echoWarning("Node Not Renamed.") + call nerdtree#echoWarning('Node Not Renamed.') endtry endfunction " FUNCTION: NERDTreeDeleteNode() {{{1 function! NERDTreeDeleteNode() - let l:shellslash = &shellslash - let &shellslash = 0 let currentNode = g:NERDTreeFileNode.GetSelected() let confirmed = 0 if currentNode.path.isDirectory && ((currentNode.isOpen && currentNode.getChildCount() > 0) || \ (len(currentNode._glob('*', 1)) > 0)) - let prompt = s:inputPrompt("deleteNonEmpty") . currentNode.path.str() . ": " + let prompt = s:inputPrompt('deleteNonEmpty') . currentNode.path.str() . ': ' let choice = input(prompt) let confirmed = choice ==# 'yes' else - let prompt = s:inputPrompt("delete") . currentNode.path.str() . " (yN): " + let prompt = s:inputPrompt('delete') . currentNode.path.str() . ' (yN): ' echo prompt let choice = nr2char(getchar()) let confirmed = choice ==# 'y' @@ -266,30 +317,29 @@ function! NERDTreeDeleteNode() "if the node is open in a buffer, ask the user if they want to "close that buffer - let bufnum = bufnr("^".currentNode.path.str()."$") + let bufnum = bufnr('^'.currentNode.path.str().'$') if buflisted(bufnum) - let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" + let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? ' (hidden)' : '') .'. Delete this buffer? (yN)' call s:promptToDelBuffer(bufnum, prompt) endif redraw! catch /^NERDTree/ - call nerdtree#echoWarning("Could not remove node") + call nerdtree#echoWarning('Could not remove node') endtry else - call nerdtree#echo("delete aborted") + call nerdtree#echo('delete aborted') endif - let &shellslash = l:shellslash endfunction " FUNCTION: NERDTreeListNode() {{{1 function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() if !empty(treenode) - let s:uname = system("uname") + let s:uname = system('uname') let stat_cmd = 'stat -c "%s" ' - if s:uname =~? "Darwin" + if s:uname =~? 'Darwin' let stat_cmd = 'stat -f "%z" ' endif @@ -300,7 +350,7 @@ function! NERDTreeListNode() let metadata = split(system(cmd),'\n') call nerdtree#echo(metadata[0]) else - call nerdtree#echo("No information available") + call nerdtree#echo('No information available') endif endfunction @@ -310,10 +360,10 @@ function! NERDTreeListNodeWin32() if !empty(l:node) let l:path = l:node.path.str() - call nerdtree#echo(printf("%s:%s MOD:%s BYTES:%d PERMISSIONS:%s", + call nerdtree#echo(printf('%s:%s MOD:%s BYTES:%d PERMISSIONS:%s', \ toupper(getftype(l:path)), \ fnamemodify(l:path, ':t'), - \ strftime("%c", getftime(l:path)), + \ strftime('%c', getftime(l:path)), \ getfsize(l:path), \ getfperm(l:path))) return @@ -322,21 +372,42 @@ function! NERDTreeListNodeWin32() call nerdtree#echo('node not recognized') endfunction +" FUNCTION: NERDTreeChangePermissions() {{{1 +function! NERDTreeChangePermissions() + let l:node = g:NERDTreeFileNode.GetSelected() + let l:prompt = "change node permissions (chmod args): " + let l:newNodePerm = input(l:prompt) + + if !empty(l:node) + let l:path = l:node.path.str() + let l:cmd = 'chmod ' .. newNodePerm .. ' ' .. path + let l:error = split(system(l:cmd), '\n') + + if !empty(l:error) + call nerdtree#echo(l:error[0]) + endif + + call b:NERDTree.root.refresh() + call b:NERDTree.render() + return + endif + + call nerdtree#echo('node not recognized') +endfunction + " FUNCTION: NERDTreeCopyNode() {{{1 function! NERDTreeCopyNode() - let l:shellslash = &shellslash - let &shellslash = 0 let currentNode = g:NERDTreeFileNode.GetSelected() - let prompt = s:inputPrompt("copy") - let newNodePath = input(prompt, currentNode.path.str(), "file") + let prompt = s:inputPrompt('copy') + let newNodePath = substitute(input(prompt, currentNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') - if newNodePath != "" + if newNodePath !=# '' "strip trailing slash let newNodePath = substitute(newNodePath, '\/$', '', '') let confirmed = 1 if currentNode.path.copyingWillOverwrite(newNodePath) - call nerdtree#echo("Warning: copying may overwrite files! Continue? (yN)") + call nerdtree#echo('Warning: copying may overwrite files! Continue? (yN)') let choice = nr2char(getchar()) let confirmed = choice ==# 'y' endif @@ -355,67 +426,132 @@ function! NERDTreeCopyNode() call newNode.putCursorHere(0, 0) endif catch /^NERDTree/ - call nerdtree#echoWarning("Could not copy node") + call nerdtree#echoWarning('Could not copy node') endtry endif else - call nerdtree#echo("Copy aborted.") + call nerdtree#echo('Copy aborted.') endif - let &shellslash = l:shellslash redraw! endfunction " FUNCTION: NERDTreeCopyPath() {{{1 function! NERDTreeCopyPath() let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() - if has("clipboard") - let @* = l:nodePath - call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.") + if has('clipboard') + if &clipboard ==# 'unnamedplus' + let @+ = l:nodePath + else + let @* = l:nodePath + endif + call nerdtree#echo('The path [' . l:nodePath . '] was copied to your clipboard.') else - call nerdtree#echo("The full path is: " . l:nodePath) + call nerdtree#echo('The full path is: ' . l:nodePath) endif endfunction " FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} - call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeRevealInFinder() {{{1 function! NERDTreeRevealInFinder() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} - call system("open -R '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('open -R ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeExecuteFile() {{{1 function! NERDTreeExecuteFile() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} - call system("open '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('open ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeRevealFileLinux() {{{1 function! NERDTreeRevealFileLinux() - let treenode = g:NERDTreeFileNode.GetSelected() - let parentnode = treenode.parent - if parentnode != {} - call system("xdg-open '" . parentnode.path.str() . "' &") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + " Handle the edge case of "/", which has no parent. + if l:node.path.str() ==# '/' + call system('xdg-open /') + return + endif + + if empty(l:node.parent) + return + endif + + call system('xdg-open ' . shellescape(l:node.parent.path.str())) endfunction " FUNCTION: NERDTreeExecuteFileLinux() {{{1 function! NERDTreeExecuteFileLinux() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} - call system("xdg-open '" . treenode.path.str() . "' &") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('xdg-open ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeRevealInExplorer() {{{1 +function! NERDTreeRevealInExplorer() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('cmd.exe /c explorer /select, ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeExecuteFileWindows() {{{1 +function! NERDTreeExecuteFileWindows() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('cmd.exe /c start "" ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeSystemCommand() {{{1 +function! NERDTreeSystemCommand() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + let l:cwd = getcwd() + let l:directory = l:node.path.isDirectory ? l:node.path.str() : l:node.parent.path.str() + execute 'cd '.l:directory + + let l:nl = nr2char(10) + echo l:nl . system(input(l:directory . (nerdtree#runningWindows() ? '> ' : ' $ '))) + execute 'cd '.l:cwd endfunction " vim: set sw=4 sts=4 et fdm=marker: - diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim b/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim index c30579ae..d20e35e5 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim @@ -11,12 +11,21 @@ " " ============================================================================ command! -n=? -complete=dir -bar NERDTreeVCS :call CreateTabTreeVCS('') +command! -n=? -complete=dir -bar NERDTreeToggleVCS :call ToggleTabTreeVCS('') " FUNCTION: s:CreateTabTreeVCS(a:name) {{{1 function! s:CreateTabTreeVCS(name) let l:path = g:NERDTreeCreator._pathForString(a:name) let l:path = s:FindParentVCSRoot(l:path) - call g:NERDTreeCreator.createTabTree(empty(l:path) ? "" : l:path._str()) + call g:NERDTreeCreator.createTabTree(empty(l:path) ? '' : l:path._str()) +endfunction + +" FUNCTION: s:ToggleTabTreeVCS(a:name) {{{1 +" Behaves the same as ToggleTabTree except roots directory at VCS root +function! s:ToggleTabTreeVCS(name) + let l:path = g:NERDTreeCreator._pathForString(a:name) + let l:path = s:FindParentVCSRoot(l:path) + call g:NERDTreeCreator.toggleTabTree(empty(l:path) ? '' : l:path._str()) endfunction " FUNCTION: s:FindParentVCSRoot(a:path) {{{1 @@ -25,7 +34,7 @@ endfunction function! s:FindParentVCSRoot(path) let l:path = a:path while !empty(l:path) && - \ l:path._str() !~ '^\(\a:\\\|\/\)$' && + \ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' && \ !isdirectory(l:path._str() . '/.git') && \ !isdirectory(l:path._str() . '/.svn') && \ !isdirectory(l:path._str() . '/.hg') && @@ -33,6 +42,6 @@ function! s:FindParentVCSRoot(path) \ !isdirectory(l:path._str() . '/_darcs') let l:path = l:path.getParent() endwhile - return (empty(l:path) || l:path._str() =~ '^\(\a:\\\|\/\)$') ? a:path : l:path + return (empty(l:path) || l:path._str() =~# '^\(\a:[\\\/]\|\/\)$') ? a:path : l:path endfunction diff --git a/sources_non_forked/nerdtree/plugin/NERD_tree.vim b/sources_non_forked/nerdtree/plugin/NERD_tree.vim index a8e26d4e..84c04fda 100644 --- a/sources_non_forked/nerdtree/plugin/NERD_tree.vim +++ b/sources_non_forked/nerdtree/plugin/NERD_tree.vim @@ -11,7 +11,9 @@ " " SECTION: Script init stuff {{{1 "============================================================ -if exists("loaded_nerd_tree") +scriptencoding utf-8 + +if exists('loaded_nerd_tree') finish endif if v:version < 703 @@ -20,144 +22,123 @@ if v:version < 703 endif let loaded_nerd_tree = 1 -"for line continuation - i.e dont want C in &cpo -let s:old_cpo = &cpo -set cpo&vim +"for line continuation - i.e dont want C in &cpoptions +let s:old_cpo = &cpoptions +set cpoptions&vim -"Function: s:initVariable() function {{{2 -"This function is used to initialise a given variable to a given value. The -"variable is only initialised if it does not exist prior -" -"Args: -"var: the name of the var to be initialised -"value: the value to initialise var to -" -"Returns: -"1 if the var is set, 0 otherwise -function! s:initVariable(var, value) - if !exists(a:var) - exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'" - return 1 - endif - return 0 -endfunction +"SECTION: Initialize variable calls and other random constants {{{2 +let g:NERDTreeAutoCenter = get(g:, 'NERDTreeAutoCenter', 1) +let g:NERDTreeAutoCenterThreshold = get(g:, 'NERDTreeAutoCenterThreshold', 3) +let g:NERDTreeCaseSensitiveFS = get(g:, 'NERDTreeCaseSensitiveFS', 2) +let g:NERDTreeCaseSensitiveSort = get(g:, 'NERDTreeCaseSensitiveSort', 0) +let g:NERDTreeNaturalSort = get(g:, 'NERDTreeNaturalSort', 0) +let g:NERDTreeSortHiddenFirst = get(g:, 'NERDTreeSortHiddenFirst', 1) +let g:NERDTreeUseTCD = get(g:, 'NERDTreeUseTCD', 0) +let g:NERDTreeChDirMode = get(g:, 'NERDTreeChDirMode', 0) +let g:NERDTreeCreatePrefix = get(g:, 'NERDTreeCreatePrefix', 'silent') +let g:NERDTreeMinimalUI = get(g:, 'NERDTreeMinimalUI', 0) +let g:NERDTreeMinimalMenu = get(g:, 'NERDTreeMinimalMenu', 0) +let g:NERDTreeIgnore = get(g:, 'NERDTreeIgnore', ['\~$']) +let g:NERDTreeBookmarksFile = get(g:, 'NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks') +let g:NERDTreeBookmarksSort = get(g:, 'NERDTreeBookmarksSort', 1) +let g:NERDTreeHighlightCursorline = get(g:, 'NERDTreeHighlightCursorline', 1) +let g:NERDTreeHijackNetrw = get(g:, 'NERDTreeHijackNetrw', 1) +let g:NERDTreeMarkBookmarks = get(g:, 'NERDTreeMarkBookmarks', 1) +let g:NERDTreeMouseMode = get(g:, 'NERDTreeMouseMode', 1) +let g:NERDTreeNotificationThreshold = get(g:, 'NERDTreeNotificationThreshold', 100) +let g:NERDTreeQuitOnOpen = get(g:, 'NERDTreeQuitOnOpen', 0) +let g:NERDTreeRespectWildIgnore = get(g:, 'NERDTreeRespectWildIgnore', 0) +let g:NERDTreeShowBookmarks = get(g:, 'NERDTreeShowBookmarks', 0) +let g:NERDTreeShowFiles = get(g:, 'NERDTreeShowFiles', 1) +let g:NERDTreeShowHidden = get(g:, 'NERDTreeShowHidden', 0) +let g:NERDTreeShowLineNumbers = get(g:, 'NERDTreeShowLineNumbers', 0) +let g:NERDTreeSortDirs = get(g:, 'NERDTreeSortDirs', 1) +let g:NERDTreeFileLines = get(g:, 'NERDTreeFileLines', 0) -"SECTION: Init variable calls and other random constants {{{2 -call s:initVariable("g:NERDTreeAutoCenter", 1) -call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) -call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) -call s:initVariable("g:NERDTreeNaturalSort", 0) -call s:initVariable("g:NERDTreeSortHiddenFirst", 1) -call s:initVariable("g:NERDTreeChDirMode", 0) -call s:initVariable("g:NERDTreeCreatePrefix", "silent") -call s:initVariable("g:NERDTreeMinimalUI", 0) -call s:initVariable("g:NERDTreeMinimalMenu", 0) -if !exists("g:NERDTreeIgnore") - let g:NERDTreeIgnore = ['\~$'] -endif -call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks') -call s:initVariable("g:NERDTreeBookmarksSort", 1) -call s:initVariable("g:NERDTreeHighlightCursorline", 1) -call s:initVariable("g:NERDTreeHijackNetrw", 1) -call s:initVariable('g:NERDTreeMarkBookmarks', 1) -call s:initVariable("g:NERDTreeMouseMode", 1) -call s:initVariable("g:NERDTreeNotificationThreshold", 100) -call s:initVariable("g:NERDTreeQuitOnOpen", 0) -call s:initVariable("g:NERDTreeRespectWildIgnore", 0) -call s:initVariable("g:NERDTreeShowBookmarks", 0) -call s:initVariable("g:NERDTreeShowFiles", 1) -call s:initVariable("g:NERDTreeShowHidden", 0) -call s:initVariable("g:NERDTreeShowLineNumbers", 0) -call s:initVariable("g:NERDTreeSortDirs", 1) if !nerdtree#runningWindows() && !nerdtree#runningCygwin() - call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") - call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") + let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '▸') + let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '▾') else - call s:initVariable("g:NERDTreeDirArrowExpandable", "+") - call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") + let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '+') + let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '~') endif -call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) -call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) +let g:NERDTreeCascadeOpenSingleChildDir = get(g:, 'NERDTreeCascadeOpenSingleChildDir', 1) +let g:NERDTreeCascadeSingleChildDir = get(g:, 'NERDTreeCascadeSingleChildDir', 1) -if !exists("g:NERDTreeSortOrder") - let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -endif +let g:NERDTreeSortOrder = get(g:, 'NERDTreeSortOrder', ['\/$', '*', '\.swp$', '\.bak$', '\~$']) let g:NERDTreeOldSortOrder = [] -call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") +let g:NERDTreeGlyphReadOnly = get(g:, 'NERDTreeGlyphReadOnly', 'RO') -if has("conceal") - call s:initVariable("g:NERDTreeNodeDelimiter", "\x07") -elseif (g:NERDTreeDirArrowExpandable == "\u00a0" || g:NERDTreeDirArrowCollapsible == "\u00a0") - call s:initVariable("g:NERDTreeNodeDelimiter", "\u00b7") +if has('conceal') + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\x07") +elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00b7") else - call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00a0") endif -if !exists('g:NERDTreeStatusline') +"the exists() crap here is a hack to stop vim spazzing out when +"loading a session that was created with an open nerd tree. It spazzes +"because it doesnt store b:NERDTree(its a b: var, and its a hash) +let g:NERDTreeStatusline = get(g:, 'NERDTreeStatusline', "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}") - "the exists() crap here is a hack to stop vim spazzing out when - "loading a session that was created with an open nerd tree. It spazzes - "because it doesnt store b:NERDTree(its a b: var, and its a hash) - let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}" - -endif -call s:initVariable("g:NERDTreeWinPos", "left") -call s:initVariable("g:NERDTreeWinSize", 31) +let g:NERDTreeWinPos = get(g:, 'NERDTreeWinPos', 'left') +let g:NERDTreeWinSize = get(g:, 'NERDTreeWinSize', 31) "init the shell commands that will be used to copy nodes, and remove dir trees -" "Note: the space after the command is important if nerdtree#runningWindows() - call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') - call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ') - call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ') + let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rmdir /s /q ') + let g:NERDTreeCopyDirCmd = get(g:, 'NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ') + let g:NERDTreeCopyFileCmd = get(g:, 'NERDTreeCopyFileCmd', 'copy /y ') else - call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') - call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ') + let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rm -rf ') + let g:NERDTreeCopyCmd = get(g:, 'NERDTreeCopyCmd', 'cp -r ') endif - "SECTION: Init variable calls for key mappings {{{2 -call s:initVariable("g:NERDTreeMapCustomOpen", "") -call s:initVariable("g:NERDTreeMapActivateNode", "o") -call s:initVariable("g:NERDTreeMapChangeRoot", "C") -call s:initVariable("g:NERDTreeMapChdir", "cd") -call s:initVariable("g:NERDTreeMapCloseChildren", "X") -call s:initVariable("g:NERDTreeMapCloseDir", "x") -call s:initVariable("g:NERDTreeMapDeleteBookmark", "D") -call s:initVariable("g:NERDTreeMapMenu", "m") -call s:initVariable("g:NERDTreeMapHelp", "?") -call s:initVariable("g:NERDTreeMapJumpFirstChild", "K") -call s:initVariable("g:NERDTreeMapJumpLastChild", "J") -call s:initVariable("g:NERDTreeMapJumpNextSibling", "") -call s:initVariable("g:NERDTreeMapJumpParent", "p") -call s:initVariable("g:NERDTreeMapJumpPrevSibling", "") -call s:initVariable("g:NERDTreeMapJumpRoot", "P") -call s:initVariable("g:NERDTreeMapOpenExpl", "e") -call s:initVariable("g:NERDTreeMapOpenInTab", "t") -call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T") -call s:initVariable("g:NERDTreeMapOpenRecursively", "O") -call s:initVariable("g:NERDTreeMapOpenSplit", "i") -call s:initVariable("g:NERDTreeMapOpenVSplit", "s") -call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode) -call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit) -call s:initVariable("g:NERDTreeMapPreviewVSplit", "g" . NERDTreeMapOpenVSplit) -call s:initVariable("g:NERDTreeMapQuit", "q") -call s:initVariable("g:NERDTreeMapRefresh", "r") -call s:initVariable("g:NERDTreeMapRefreshRoot", "R") -call s:initVariable("g:NERDTreeMapToggleBookmarks", "B") -call s:initVariable("g:NERDTreeMapToggleFiles", "F") -call s:initVariable("g:NERDTreeMapToggleFilters", "f") -call s:initVariable("g:NERDTreeMapToggleHidden", "I") -call s:initVariable("g:NERDTreeMapToggleZoom", "A") -call s:initVariable("g:NERDTreeMapUpdir", "u") -call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") -call s:initVariable("g:NERDTreeMapCWD", "CD") -call s:initVariable("g:NERDTreeMenuDown", "j") -call s:initVariable("g:NERDTreeMenuUp", "k") +let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '') +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') +let g:NERDTreeMapCloseChildren = get(g:, 'NERDTreeMapCloseChildren', 'X') +let g:NERDTreeMapCloseDir = get(g:, 'NERDTreeMapCloseDir', 'x') +let g:NERDTreeMapDeleteBookmark = get(g:, 'NERDTreeMapDeleteBookmark', 'D') +let g:NERDTreeMapMenu = get(g:, 'NERDTreeMapMenu', 'm') +let g:NERDTreeMapHelp = get(g:, 'NERDTreeMapHelp', '?') +let g:NERDTreeMapJumpFirstChild = get(g:, 'NERDTreeMapJumpFirstChild', 'K') +let g:NERDTreeMapJumpLastChild = get(g:, 'NERDTreeMapJumpLastChild', 'J') +let g:NERDTreeMapJumpNextSibling = get(g:, 'NERDTreeMapJumpNextSibling', '') +let g:NERDTreeMapJumpParent = get(g:, 'NERDTreeMapJumpParent', 'p') +let g:NERDTreeMapJumpPrevSibling = get(g:, 'NERDTreeMapJumpPrevSibling', '') +let g:NERDTreeMapJumpRoot = get(g:, 'NERDTreeMapJumpRoot', 'P') +let g:NERDTreeMapOpenExpl = get(g:, 'NERDTreeMapOpenExpl', 'e') +let g:NERDTreeMapOpenInTab = get(g:, 'NERDTreeMapOpenInTab', 't') +let g:NERDTreeMapOpenInTabSilent = get(g:, 'NERDTreeMapOpenInTabSilent', 'T') +let g:NERDTreeMapOpenRecursively = get(g:, 'NERDTreeMapOpenRecursively', 'O') +let g:NERDTreeMapOpenSplit = get(g:, 'NERDTreeMapOpenSplit', 'i') +let g:NERDTreeMapOpenVSplit = get(g:, 'NERDTreeMapOpenVSplit', 's') +let g:NERDTreeMapPreview = get(g:, 'NERDTreeMapPreview', 'g'.NERDTreeMapActivateNode) +let g:NERDTreeMapPreviewSplit = get(g:, 'NERDTreeMapPreviewSplit', 'g'.NERDTreeMapOpenSplit) +let g:NERDTreeMapPreviewVSplit = get(g:, 'NERDTreeMapPreviewVSplit', 'g'.NERDTreeMapOpenVSplit) +let g:NERDTreeMapQuit = get(g:, 'NERDTreeMapQuit', 'q') +let g:NERDTreeMapRefresh = get(g:, 'NERDTreeMapRefresh', 'r') +let g:NERDTreeMapRefreshRoot = get(g:, 'NERDTreeMapRefreshRoot', 'R') +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', 'FL') +let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A') +let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u') +let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U') +let g:NERDTreeMapCWD = get(g:, 'NERDTreeMapCWD', 'CD') +let g:NERDTreeMenuDown = get(g:, 'NERDTreeMenuDown', 'j') +let g:NERDTreeMenuUp = get(g:, 'NERDTreeMenuUp', 'k') "SECTION: Load class files{{{2 call nerdtree#loadClassFiles() @@ -166,20 +147,27 @@ call nerdtree#loadClassFiles() "============================================================ call nerdtree#ui_glue#setupCommands() + " SECTION: Auto commands {{{1 "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" + exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* call nerdtree#onBufLeave()' "disallow insert mode in the NERDTree - exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" + exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert' augroup END if g:NERDTreeHijackNetrw augroup NERDTreeHijackNetrw autocmd VimEnter * silent! autocmd! FileExplorer - au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand("")) + au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand('')) + augroup END +endif + +if g:NERDTreeChDirMode ==# 3 + augroup NERDTreeChDirOnTabSwitch + autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif augroup END endif @@ -208,9 +196,9 @@ endfunction function! NERDTreeFocus() if g:NERDTree.IsOpen() - call g:NERDTree.CursorToTreeWin() + call g:NERDTree.CursorToTreeWin(0) else - call g:NERDTreeCreator.ToggleTabTree("") + call g:NERDTreeCreator.ToggleTabTree('') endif endfunction @@ -246,7 +234,7 @@ endfunction " SECTION: Post Source Actions {{{1 call nerdtree#postSourceActions() -"reset &cpo back to users setting -let &cpo = s:old_cpo +"reset &cpoptions back to users setting +let &cpoptions = s:old_cpo " vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/syntax/nerdtree.vim b/sources_non_forked/nerdtree/syntax/nerdtree.vim index 99773bf1..6aae6f28 100644 --- a/sources_non_forked/nerdtree/syntax/nerdtree.vim +++ b/sources_non_forked/nerdtree/syntax/nerdtree.vim @@ -3,7 +3,7 @@ syn match NERDTreeIgnore #\~# exec 'syn match NERDTreeIgnore #\['.g:NERDTreeGlyphReadOnly.'\]#' "highlighting for the .. (up dir) line at the top of the tree -execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" +execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line .'#' "quickhelp syntax elements syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1 @@ -19,36 +19,40 @@ syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir -"highlighing for directory nodes and file nodes -syn match NERDTreeDirSlash #/# containedin=NERDTreeDir - -exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' -exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' - -let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') -exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' -syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark -exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' - -"highlighting for readonly files -exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' - -syn match NERDTreeFlags #^ *\zs\[[^\]]*\]# containedin=NERDTreeFile,NERDTreeExecFile -syn match NERDTreeFlags #\[[^\]]*\]# containedin=NERDTreeDir - -"highlighing to conceal the delimiter around the file/dir name -if has("conceal") +"highlighting to conceal the delimiter around the file/dir name +if has('conceal') exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' - setlocal conceallevel=3 concealcursor=nvic + setlocal conceallevel=2 concealcursor=nvic else exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' hi! link NERDTreeNodeDelimiters Ignore endif +"highlighting for directory nodes and file nodes +syn match NERDTreeDirSlash #/# containedin=NERDTreeDir + +if g:NERDTreeDirArrowExpandable !=# '' + exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') + exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' + exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmarkName' + exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmarkName,NERDTreeExecFile' +else + exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#' + exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmarkName' + exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmarkName,NERDTreeExecFile' +endif + +"highlighting for readonly files +exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmarkName,NERDTreeFile' + +exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir' + syn match NERDTreeCWD #^[# @@ -89,3 +93,5 @@ hi def link NERDTreeBookmark Statement hi def link NERDTreeFlags Number hi def link NERDTreeCurrentNode Search + +hi NERDTreeFile ctermbg=NONE guibg=NONE diff --git a/sources_non_forked/nginx.vim/LICENSE b/sources_non_forked/nginx.vim/LICENSE deleted file mode 100644 index 536790d3..00000000 --- a/sources_non_forked/nginx.vim/LICENSE +++ /dev/null @@ -1,675 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - Vim plugin that highlights insecure SSL/TLS cipher suites and protocols. - Copyright (C) 2017 Chris Aumann - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - nginx.vim Copyright (C) 2017 Chris Aumann - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. - diff --git a/sources_non_forked/nginx.vim/README.md b/sources_non_forked/nginx.vim/README.md index 58eceefa..11f865b9 100644 --- a/sources_non_forked/nginx.vim/README.md +++ b/sources_non_forked/nginx.vim/README.md @@ -51,22 +51,42 @@ For help with secure cipher selection, visit [Mozillas SSL Configuration Generat ## Installation -### Pathogen +If your Vim is at version 8 or later, the first method below is the quickest. Otherwise, install this plugin with any Vim plugin manager ([``vim-plug``](https://github.com/junegunn/vim-plug) is recommended). -```bash -git clone https://github.com/chr4/nginx.vim ~/.vim/bundle/nginx.vim +### Native plugin management (Vim 8+) + +Clone or submodule this repo into your Vim packages location. Example: + +``` +mkdir -p ~/.vim/pack/plugins/start +cd ~/.vim/pack/plugins/start +git clone https://github.com/chr4/nginx.vim.git ``` -### Other (Plug, Dein.vim, Vundle) -```vim -" Plug +### Plug +``` Plug 'chr4/nginx.vim' +``` -" Dein.vim +### Dein.vim +``` call dein#add('chr4/nginx.vim') +``` -" Vundle +### Vundle +``` Plugin 'chr4/nginx.vim' ``` +### Pathogen +``` +git clone https://github.com/chr4/nginx.vim ~/.vim/bundle/nginx.vim +``` + Optionally, if you like [Jinja](http://jinja.pocoo.org/) template syntax highlighting, install `lepture/vim-jinja`, too. + + +## License + +Copyright (c) Chris Aumann. Distributed under the same terms as Vim itself. +See `:help license`. diff --git a/sources_non_forked/nginx.vim/ftplugin/nginx.vim b/sources_non_forked/nginx.vim/ftplugin/nginx.vim index 463eea98..cfedff87 100644 --- a/sources_non_forked/nginx.vim/ftplugin/nginx.vim +++ b/sources_non_forked/nginx.vim/ftplugin/nginx.vim @@ -1 +1,5 @@ +setlocal comments=:# setlocal commentstring=#\ %s +setlocal formatoptions+=croql formatoptions-=t + +let b:undo_ftplugin = "setl fo< cms< com<" diff --git a/sources_non_forked/nginx.vim/indent/nginx.vim b/sources_non_forked/nginx.vim/indent/nginx.vim index 86013668..19e9bf3c 100644 --- a/sources_non_forked/nginx.vim/indent/nginx.vim +++ b/sources_non_forked/nginx.vim/indent/nginx.vim @@ -1,11 +1,73 @@ -if exists("b:did_indent") - finish +" Only load this indent file when no other was loaded. +if exists('b:did_indent') + finish endif let b:did_indent = 1 -setlocal indentexpr= +setlocal indentexpr=GetNginxIndent() -" cindent actually works for nginx' simple file structure -setlocal cindent -" Just make sure that the comments are not reset as defs would be. -setlocal cinkeys-=0# +setlocal indentkeys=0{,0},0#,!^F,o,O + +let b:undo_indent = 'setl inde< indk<' + +" Only define the function once. +if exists('*GetNginxIndent') + finish +endif + +function GetNginxIndent() abort + let plnum = s:PrevNotAsBlank(v:lnum - 1) + + " Hit the start of the file, use zero indent. + if plnum == 0 + return 0 + endif + + let ind = indent(plnum) + + " Add a 'shiftwidth' after '{' + if s:AsEndWith(getline(plnum), '{') + let ind = ind + shiftwidth() + end + + " Subtract a 'shiftwidth' on '}' + " This is the part that requires 'indentkeys'. + if getline(v:lnum) =~ '^\s*}' + let ind = ind - shiftwidth() + endif + + let pplnum = s:PrevNotAsBlank(plnum - 1) + + if s:IsLineContinuation(plnum) + if !s:IsLineContinuation(pplnum) + let ind = ind + shiftwidth() + end + else + if s:IsLineContinuation(pplnum) + let ind = ind - shiftwidth() + end + endif + + return ind +endfunction + +" Find the first line at or above {lnum} that is non-blank and not a comment. +function s:PrevNotAsBlank(lnum) abort + let lnum = prevnonblank(a:lnum) + while lnum > 0 + if getline(lnum) !~ '^\s*#' + break + endif + let lnum = prevnonblank(lnum - 1) + endwhile + return lnum +endfunction + +" Check whether {line} ends with {pat}, ignoring trailing comments. +function s:AsEndWith(line, pat) abort + return a:line =~ a:pat . '\m\s*\%(#.*\)\?$' +endfunction + +function s:IsLineContinuation(lnum) abort + return a:lnum > 0 && !s:AsEndWith(getline(a:lnum), '[;{}]') +endfunction diff --git a/sources_non_forked/nginx.vim/syntax/nginx.vim b/sources_non_forked/nginx.vim/syntax/nginx.vim index 9e3b16b8..d036c123 100644 --- a/sources_non_forked/nginx.vim/syntax/nginx.vim +++ b/sources_non_forked/nginx.vim/syntax/nginx.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: nginx.conf " Maintainer: Chris Aumann -" Last Change: Apr 15, 2017 +" Last Change: Nov 25, 2023 if exists("b:current_syntax") finish @@ -84,6 +84,8 @@ syn keyword ngxListenOptions default_server contained syn keyword ngxListenOptions ssl contained syn keyword ngxListenOptions http2 contained syn keyword ngxListenOptions spdy contained +syn keyword ngxListenOptions http3 contained +syn keyword ngxListenOptions quic contained syn keyword ngxListenOptions proxy_protocol contained syn keyword ngxListenOptions setfib contained syn keyword ngxListenOptions fastopen contained @@ -258,6 +260,7 @@ syn keyword ngxDirective hls_forward_args syn keyword ngxDirective hls_fragment syn keyword ngxDirective hls_mp4_buffer_size syn keyword ngxDirective hls_mp4_max_buffer_size +syn keyword ngxDirective http2 syn keyword ngxDirective http2_chunk_size syn keyword ngxDirective http2_body_preread_size syn keyword ngxDirective http2_idle_timeout @@ -265,8 +268,17 @@ syn keyword ngxDirective http2_max_concurrent_streams syn keyword ngxDirective http2_max_field_size syn keyword ngxDirective http2_max_header_size syn keyword ngxDirective http2_max_requests +syn keyword ngxDirective http2_push +syn keyword ngxDirective http2_push_preload syn keyword ngxDirective http2_recv_buffer_size syn keyword ngxDirective http2_recv_timeout +syn keyword ngxDirective http3 +syn keyword ngxDirective http3_hq +syn keyword ngxDirective http3_max_concurrent_pushes +syn keyword ngxDirective http3_max_concurrent_streams +syn keyword ngxDirective http3_push +syn keyword ngxDirective http3_push_preload +syn keyword ngxDirective http3_stream_buffer_size syn keyword ngxDirective if_modified_since syn keyword ngxDirective ignore_invalid_headers syn keyword ngxDirective image_filter @@ -298,12 +310,15 @@ syn keyword ngxDirective large_client_header_buffers syn keyword ngxDirective least_conn syn keyword ngxDirective least_time syn keyword ngxDirective limit_conn +syn keyword ngxDirective limit_conn_dry_run syn keyword ngxDirective limit_conn_log_level syn keyword ngxDirective limit_conn_status syn keyword ngxDirective limit_conn_zone +syn keyword ngxDirective limit_except syn keyword ngxDirective limit_rate syn keyword ngxDirective limit_rate_after syn keyword ngxDirective limit_req +syn keyword ngxDirective limit_req_dry_run syn keyword ngxDirective limit_req_log_level syn keyword ngxDirective limit_req_status syn keyword ngxDirective limit_req_zone @@ -441,6 +456,10 @@ syn keyword ngxDirective proxy_temp_path syn keyword ngxDirective proxy_timeout syn keyword ngxDirective proxy_upload_rate syn keyword ngxDirective queue +syn keyword ngxDirective quic_gso +syn keyword ngxDirective quic_host_key +syn keyword ngxDirective quic_mtu +syn keyword ngxDirective quic_retry syn keyword ngxDirective random_index syn keyword ngxDirective read_ahead syn keyword ngxDirective real_ip_header @@ -542,8 +561,10 @@ syn keyword ngxDirective ssl_certificate syn keyword ngxDirective ssl_certificate_key syn keyword ngxDirective ssl_ciphers syn keyword ngxDirective ssl_client_certificate +syn keyword ngxDirective ssl_conf_command syn keyword ngxDirective ssl_crl syn keyword ngxDirective ssl_dhparam +syn keyword ngxDirective ssl_early_data syn keyword ngxDirective ssl_ecdh_curve syn keyword ngxDirective ssl_engine syn keyword ngxDirective ssl_handshake_timeout @@ -553,6 +574,7 @@ syn keyword ngxSSLPreferServerCiphersOn on contained syn keyword ngxSSLPreferServerCiphersOff off contained syn keyword ngxDirective ssl_preread syn keyword ngxDirective ssl_protocols nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite +syn keyword ngxDirective ssl_reject_handshake syn match ngxSSLProtocol 'TLSv1' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite syn match ngxSSLProtocol 'TLSv1\.1' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite syn match ngxSSLProtocol 'TLSv1\.2' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite @@ -619,6 +641,7 @@ syn keyword ngxDirective uwsgi_buffering syn keyword ngxDirective uwsgi_buffers syn keyword ngxDirective uwsgi_busy_buffers_size syn keyword ngxDirective uwsgi_cache +syn keyword ngxDirective uwsgi_cache_background_update syn keyword ngxDirective uwsgi_cache_bypass syn keyword ngxDirective uwsgi_cache_key syn keyword ngxDirective uwsgi_cache_lock @@ -2222,6 +2245,19 @@ syn keyword ngxDirectiveThirdParty xss_override_status syn keyword ngxDirectiveThirdParty xss_check_status syn keyword ngxDirectiveThirdParty xss_input_types +" CT Module +" Certificate Transparency module for nginx +syn keyword ngxDirectiveThirdParty ssl_ct +syn keyword ngxDirectiveThirdParty ssl_ct_static_scts + +" Dynamic TLS records patch +" TLS Dynamic Record Resizing +syn keyword ngxDirectiveThirdParty ssl_dyn_rec_enable +syn keyword ngxDirectiveThirdParty ssl_dyn_rec_size_hi +syn keyword ngxDirectiveThirdParty ssl_dyn_rec_size_lo +syn keyword ngxDirectiveThirdParty ssl_dyn_rec_threshold +syn keyword ngxDirectiveThirdParty ssl_dyn_rec_timeout + " ZIP Module " ZIP archiver for nginx @@ -2273,7 +2309,6 @@ hi link ngxComment Comment hi link ngxVariable Identifier hi link ngxVariableBlock Identifier hi link ngxVariableString PreProc -hi link ngxBlock Normal hi link ngxString String hi link ngxIPaddr Delimiter hi link ngxBoolean Boolean diff --git a/sources_non_forked/tlib/README b/sources_non_forked/tlib/README deleted file mode 100644 index f5a6792e..00000000 --- a/sources_non_forked/tlib/README +++ /dev/null @@ -1,72 +0,0 @@ -This is a mirror of http://www.vim.org/scripts/script.php?script_id=1863 - -This library provides some utility functions. There isn't much need to -install it unless another plugin requires you to do so. - -The most useful functions provided by this library probably are: - -tlib#input#List(), tlib#input#ListW() - - Display a list - - Dynamically filter items matching a pattern (somethat like google) - - E.g. you filter for "foo -bar": show all entries containing foo but not bar. - - Select items from a list - - Do stuff - - Developers can define keys that trigger some action with the - selected items - - Demo: http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html - -tlib#input#EditList - + Edit a list (copy, cut, paste, delete, edit ...) - -:TLet VAR = VALUE - Set a variable only if it doesn't already exist. - -:TScratch - Open a scratch buffer (a buffer without a file). - -:TVarArg VAR1, [VAR2, DEFAULT2] ... - Handle "rest" (variable) arguments in functions. - EXAMPLES: - function! Foo(...) - TVarArg ['a', 1], 'b' - echo 'a='. a - echo 'b='. b - endf - -TBrowseOutput COMMAND - Every wondered how to effciently browse the output of a command - without redirecting it to a file? This command takes a command as - argument and presents the output via |tlib#input#List()| so that you - can easily search for a keyword (e.g. the name of a variable or - function) and the like. - - If you press enter, the selected line will be copied to the command - line. Press ESC to cancel browsing. - - EXAMPLES: - TBrowseOutput 20verb TeaseTheCulprit - TBrowseOutput let - TBrowseOutput map - - -Related (small) plugins that utilize tlib and thus provide some degree of uniform user experience: - tbibtools (vimscript #1915): bibtex-related utilities (sort, reformat, list contents ...) - tmarks (vimscript #2594): Browse, place, & delete marks - tmboxbrowser (vimscript #1906): A mbox browser -- Read your e-mails with vim - tmru (vimscript #1864): Most Recently Used Files - trag (vimscript #2033): A slightly language-aware alternative to grep - tregisters (vimscript #2017): List, edit, and run/execute registers/clipboards - tselectbuffer (vimscript #1866): A quick buffer selector/switcher - tselectfiles (vimscript #1865): A quick file selector/browser/explorer (sort of) - ttagecho (vimscript #2055): Show current tag information - ttagcomplete (vimscript #2069): Context-sensitive tags-based completion and code skeletons - ttags (vimscript #2018): Tag list browser (List, filter, preview, jump to tags) - ttoc (vimscript #2014): A regexp-based table of contents of the current buffer - vikitasks (vimscript #2894): Search viki files for tasks and display them in a list - - -For full details, please see: -http://github.com/tomtom/tlib_vim/blob/master/doc/tlib.txt - -Also available via git -http://github.com/tomtom/tlib_vim diff --git a/sources_non_forked/tlib/autoload/tlib.vim b/sources_non_forked/tlib/autoload/tlib.vim deleted file mode 100644 index 5d805ac9..00000000 --- a/sources_non_forked/tlib/autoload/tlib.vim +++ /dev/null @@ -1,8 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 13 - -" :nodefault: -TLet g:tlib#debug = 0 - diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim deleted file mode 100644 index 0bcb6c0e..00000000 --- a/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim +++ /dev/null @@ -1,151 +0,0 @@ -" Filter_cnf.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2008-11-25. -" @Last Change: 2014-11-18. -" @Revision: 0.0.114 - -let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2 -let s:prototype.highlight = g:tlib#input#higroup - -" The search pattern for |tlib#input#List()| is in conjunctive normal -" form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... -" The pattern is a '/\V' very no-'/magic' regexp pattern. -" -" Pressing joins two patterns with AND. -" Pressing | joins two patterns with OR. -" I.e. In order to get "lala AND (foo OR bar)", you type -" "lala foo|bar". -" -" This is also the base class for other filters. -function! tlib#Filter_cnf#New(...) "{{{3 - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object -endf - - -" :nodoc: -function! s:prototype.Init(world) dict "{{{3 -endf - - -" :nodoc: -function! s:prototype.Help(world) dict "{{{3 - call a:world.PushHelp( - \ printf('"%s", "%s", "%sWORD"', g:tlib#input#and, g:tlib#input#or, g:tlib#input#not), - \ 'AND, OR, NOT') -endf - - -" :nodoc: -function! s:prototype.AssessName(world, name) dict "{{{3 - let xa = 0 - let prefix = self.FilterRxPrefix() - for flt in a:world.filter_pos - " let flt = prefix . a:world.GetRx(fltl) - " if flt =~# '\u' && a:name =~# flt - " let xa += 5 - " endif - - if a:name =~ '\^'. flt - let xa += 4 - elseif a:name =~ '\<'. flt - let xa += 3 - " elseif a:name =~ '[[:punct:][:space:][:digit:]]'. flt - " let xa += 2 - elseif a:name =~ '\A'. flt .'\|'. flt .'\A' - let xa += 1 - endif - endfor - " TLogVAR a:name, xa - return xa -endf - - -" :nodoc: -function! s:prototype.Match(world, text) dict "{{{3 - " TLogVAR a:text - " let sc = &smartcase - " let ic = &ignorecase - " if &ignorecase - " set smartcase - " endif - " try - if !empty(a:world.filter_neg) - for rx in a:world.filter_neg - " TLogVAR rx - if a:text =~ rx - return 0 - endif - endfor - endif - if !empty(a:world.filter_pos) - for rx in a:world.filter_pos - " TLogVAR rx - if a:text !~ rx - return 0 - endif - endfor - endif - " finally - " let &smartcase = sc - " let &ignorecase = ic - " endtry - return 1 -endf - - -" :nodoc: -function! s:prototype.DisplayFilter(filter) dict "{{{3 - let filter1 = deepcopy(a:filter) - call map(filter1, '"(". join(reverse(self.Pretty(v:val)), " OR ") .")"') - return join(reverse(filter1), ' AND ') -endf - - -function! s:prototype.Pretty(filter) dict "{{{3 - " call map(a:filter, 'substitute(v:val, ''\\\.\\{-}'', ''=>'', ''g'')') - call map(a:filter, 'self.CleanFilter(v:val)') - return a:filter -endf - - -" :nodoc: -function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 - let a:world.filter[0] = reverse(split(a:pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] -endf - - -" :nodoc: -function! s:prototype.PushFrontFilter(world, char) dict "{{{3 - let a:world.filter[0][0] .= nr2char(a:char) -endf - - -" :nodoc: -function! s:prototype.ReduceFrontFilter(world) dict "{{{3 - let filter = a:world.filter[0][0] - " TLogVAR filter - let str = matchstr(filter, '\(\\\(\.\\{-}\|[.?*+$^]\)\|\)$') - if empty(str) - let filter = filter[0 : -2] - else - let filter = strpart(filter, 0, len(filter) - len(str)) - endif - " TLogVAR str, filter - let a:world.filter[0][0] = filter -endf - - -" :nodoc: -function! s:prototype.FilterRxPrefix() dict "{{{3 - return '\V' -endf - - -" :nodoc: -function! s:prototype.CleanFilter(filter) dict "{{{3 - return a:filter -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim deleted file mode 100644 index 27f00fe1..00000000 --- a/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim +++ /dev/null @@ -1,53 +0,0 @@ -" Filter_cnfd.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2008-11-25. -" @Last Change: 2014-01-23. -" @Revision: 0.0.57 - -let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2 -let s:prototype.highlight = g:tlib#input#higroup - - -" The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. -" As a consequence, patterns cannot match dots. -" The pattern is a '/\V' very no-'/magic' regexp pattern. -function! tlib#Filter_cnfd#New(...) "{{{3 - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object -endf - - -" :nodoc: -function! s:prototype.Init(world) dict "{{{3 -endf - - -let s:Help = s:prototype.Help - -" :nodoc: -function! s:prototype.Help(world) dict "{{{3 - call call(s:Help, [a:world], self) - call a:world.PushHelp('.', 'Any characters') -endf - - -" :nodoc: -function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 - let pattern = substitute(a:pattern, '\.', '\\.\\{-}', 'g') - let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] -endf - - -" :nodoc: -function! s:prototype.PushFrontFilter(world, char) dict "{{{3 - let a:world.filter[0][0] .= a:char == 46 ? '\.\{-}' : nr2char(a:char) -endf - - -" :nodoc: -function! s:prototype.CleanFilter(filter) dict "{{{3 - return substitute(a:filter, '\\.\\{-}', '.', 'g') -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim b/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim deleted file mode 100644 index 349bfd57..00000000 --- a/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim +++ /dev/null @@ -1,83 +0,0 @@ -" Filter_fuzzy.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2008-11-25. -" @Last Change: 2013-09-25. -" @Revision: 0.0.47 - -let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2 -let s:prototype.highlight = g:tlib#input#higroup - - -" Support for "fuzzy" pattern matching in |tlib#input#List()|. -" Patterns are interpreted as if characters were connected with '.\{-}'. -" -" In "fuzzy" mode, the pretty printing of filenames is disabled. -function! tlib#Filter_fuzzy#New(...) "{{{3 - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object -endf - - -" :nodoc: -function! s:prototype.Init(world) dict "{{{3 - " TLogVAR a:world.display_format - " :nodoc: - function! a:world.Set_display_format(value) dict - if a:value == 'filename' - let self.display_format = '' - else - let self.display_format = a:value - endif - endf -endf - - -let s:Help = s:prototype.Help - -" :nodoc: -function! s:prototype.Help(world) dict "{{{3 - call call(s:Help, [a:world], self) - call a:world.PushHelp('Patterns are interpreted as if characters were connected with .\{-}') -endf - - -" :nodoc: -function! s:prototype.DisplayFilter(filter) dict "{{{3 - " TLogVAR a:filter - let filter1 = deepcopy(a:filter) - call map(filter1, '"{". join(reverse(v:val), " OR ") ."}"') - return join(reverse(filter1), ' AND ') -endf - - -" :nodoc: -function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 - let a:world.filter[0] = map(reverse(split(a:pattern, '\s*|\s*')), 'join(map(split(v:val, ''\zs''), ''tlib#rx#Escape(v:val, "V")''), ''\.\{-}'')') + a:world.filter[0][1 : -1] - endif -endf - - -" :nodoc: -function! s:prototype.PushFrontFilter(world, char) dict "{{{3 - let ch = tlib#rx#Escape(nr2char(a:char), 'V') - if empty(a:world.filter[0][0]) - let a:world.filter[0][0] .= ch - else - let a:world.filter[0][0] .= '\.\{-}'. ch - endif -endf - - -" :nodoc: -function! s:prototype.ReduceFrontFilter(world) dict "{{{3 - let a:world.filter[0][0] = substitute(a:world.filter[0][0], '\(\\\.\\{-}\)\?.$', '', '') -endf - - -" :nodoc: -function! s:prototype.CleanFilter(filter) dict "{{{3 - return substitute(a:filter, '\\\.\\{-}', '', 'g') -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim b/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim deleted file mode 100644 index 904b2261..00000000 --- a/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim +++ /dev/null @@ -1,68 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2008-11-25. -" @Last Change: 2014-11-18. -" @Revision: 0.0.82 - -let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_glob'], 'name': 'glob'}) "{{{2 -let s:prototype.highlight = g:tlib#input#higroup - - -" A character that should be expanded to '\.\{-}'. -TLet g:tlib#Filter_glob#seq = '*' - - -" A character that should be expanded to '\.\?'. -TLet g:tlib#Filter_glob#char = '?' - - -" The same as |tlib#Filter_cnf#New()| but a a customizable character -" |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and -" |g:tlib#Filter_glob#char| is expanded to '\.'. -" The pattern is a '/\V' very no-'/magic' regexp pattern. -function! tlib#Filter_glob#New(...) "{{{3 - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object -endf - - -let s:Help = s:prototype.Help - -" :nodoc: -function! s:prototype.Help(world) dict "{{{3 - call call(s:Help, [a:world], self) - call a:world.PushHelp(g:tlib#Filter_glob#seq, 'Any characters') - call a:world.PushHelp(g:tlib#Filter_glob#char, 'Single characters') -endf - - -" :nodoc: -function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 - let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#seq, 'V'), '\\.\\{-}', 'g') - let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#char, 'V'), '\\.', 'g') - let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] -endf - - -" :nodoc: -function! s:prototype.PushFrontFilter(world, char) dict "{{{3 - " TLogVAR a:char, nr2char(a:char) - if a:char == char2nr(g:tlib#Filter_glob#seq) - let char = '\.\{-}' - elseif a:char == char2nr(g:tlib#Filter_glob#char) - let char = '\.' - else - let char = nr2char(a:char) - endif - let a:world.filter[0][0] .= char -endf - - -" :nodoc: -function! s:prototype.CleanFilter(filter) dict "{{{3 - let filter = substitute(a:filter, '\\\.\\{-}', g:tlib#Filter_glob#seq, 'g') - let filter = substitute(filter, '\\\.', g:tlib#Filter_glob#char, 'g') - return filter -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/Object.vim b/sources_non_forked/tlib/autoload/tlib/Object.vim deleted file mode 100644 index 21f38b24..00000000 --- a/sources_non_forked/tlib/autoload/tlib/Object.vim +++ /dev/null @@ -1,154 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 127 - -" :filedoc: -" Provides a prototype plus some OO-like methods. - -let s:id_counter = 0 -let s:prototype = {'_class': ['object'], '_super': [], '_id': 0} "{{{2 - -" :def: function! tlib#Object#New(?fields={}) -" This function creates a prototype that provides some kind of -" inheritance mechanism and a way to call parent/super methods. -" -" The usage demonstrated in the following example works best when every -" class/prototype is defined in a file of its own. -" -" The reason for why there is a dedicated constructor function is that -" this layout facilitates the use of templates and that methods are -" hidden from the user. Other solutions are possible. -" -" EXAMPLES: > -" let s:prototype = tlib#Object#New({ -" \ '_class': ['FooBar'], -" \ 'foo': 1, -" \ 'bar': 2, -" \ }) -" " Constructor -" function! FooBar(...) -" let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) -" return object -" endf -" function! s:prototype.babble() { -" echo "I think, therefore I am ". (self.foo * self.bar) ." months old." -" } -" -" < This could now be used like this: > -" let myfoo = FooBar({'foo': 3}) -" call myfoo.babble() -" => I think, therefore I am 6 months old. -" echo myfoo.IsA('FooBar') -" => 1 -" echo myfoo.IsA('object') -" => 1 -" echo myfoo.IsA('Foo') -" => 0 -" echo myfoo.RespondTo('babble') -" => 1 -" echo myfoo.RespondTo('speak') -" => 0 -function! tlib#Object#New(...) "{{{3 - return s:prototype.New(a:0 >= 1 ? a:1 : {}) -endf - - -function! s:prototype.New(...) dict "{{{3 - let object = deepcopy(self) - let s:id_counter += 1 - let object._id = s:id_counter - if a:0 >= 1 && !empty(a:1) - " call object.Extend(deepcopy(a:1)) - call object.Extend(a:1) - endif - return object -endf - - -function! s:prototype.Inherit(object) dict "{{{3 - let class = copy(self._class) - " TLogVAR class - let objid = self._id - for c in get(a:object, '_class', []) - " TLogVAR c - if index(class, c) == -1 - call add(class, c) - endif - endfor - call extend(self, a:object, 'keep') - let self._class = class - " TLogVAR self._class - let self._id = objid - " let self._super = [super] + self._super - call insert(self._super, a:object) - return self -endf - - -function! s:prototype.Extend(dictionary) dict "{{{3 - let super = copy(self) - let class = copy(self._class) - " TLogVAR class - let objid = self._id - let thisclass = get(a:dictionary, '_class', []) - for c in type(thisclass) == 3 ? thisclass : [thisclass] - " TLogVAR c - if index(class, c) == -1 - call add(class, c) - endif - endfor - call extend(self, a:dictionary) - let self._class = class - " TLogVAR self._class - let self._id = objid - " let self._super = [super] + self._super - call insert(self._super, super) - return self -endf - - -function! s:prototype.IsA(class) dict "{{{3 - return index(self._class, a:class) != -1 -endf - - -function! s:prototype.IsRelated(object) dict "{{{3 - return len(filter(a:object._class, 'self.IsA(v:val)')) > 1 -endf - - -function! s:prototype.RespondTo(name) dict "{{{3 - " return has_key(self, a:name) && type(self[a:name]) == 2 - return has_key(self, a:name) -endf - - -function! s:prototype.Super(method, arglist) dict "{{{3 - for o in self._super - " TLogVAR o - if o.RespondTo(a:method) - " let self._tmp_method = o[a:method] - " TLogVAR self._tmp_method - " return call(self._tmp_method, a:arglist, self) - return call(o[a:method], a:arglist, self) - endif - endfor - echoerr 'tlib#Object: Does not respond to '. a:method .': '. string(self) -endf - - -function! tlib#Object#Methods(object, ...) "{{{3 - TVarArg ['pattern', '\d\+'] - let o = items(a:object) - call filter(o, 'type(v:val[1]) == 2 && string(v:val[1]) =~ "^function(''\\d\\+'')"') - let acc = {} - for e in o - let id = matchstr(string(e[1]), pattern) - if !empty(id) - let acc[id] = e[0] - endif - endfor - return acc -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/Test.vim b/sources_non_forked/tlib/autoload/tlib/Test.vim deleted file mode 100644 index 4a4281e8..00000000 --- a/sources_non_forked/tlib/autoload/tlib/Test.vim +++ /dev/null @@ -1,19 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 11 - -" :enddoc: - - -let s:prototype = tlib#Object#New({'_class': ['Test']}) "{{{2 -function! tlib#Test#New(...) "{{{3 - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object -endf - - -function! s:prototype.Dummy() dict "{{{3 - return 'Test.vim' -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/TestChild.vim b/sources_non_forked/tlib/autoload/tlib/TestChild.vim deleted file mode 100644 index 16979a75..00000000 --- a/sources_non_forked/tlib/autoload/tlib/TestChild.vim +++ /dev/null @@ -1,19 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 15 - -" :enddoc: - - -let s:prototype = tlib#Test#New({'_class': ['TestChild']}) "{{{2 -function! tlib#TestChild#New(...) "{{{3 - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object -endf - - -function! s:prototype.Dummy() dict "{{{3 - return 'TestChild.vim' -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/World.vim b/sources_non_forked/tlib/autoload/tlib/World.vim deleted file mode 100644 index fddf7b2f..00000000 --- a/sources_non_forked/tlib/autoload/tlib/World.vim +++ /dev/null @@ -1,1404 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 1432 - -" :filedoc: -" A prototype used by |tlib#input#List|. -" Inherits from |tlib#Object#New|. - - -" Size of the input list window (in percent) from the main size (of &lines). -" See |tlib#input#List()|. -TLet g:tlib_inputlist_pct = 50 - -" Size of filename columns when listing filenames. -" See |tlib#input#List()|. -TLet g:tlib_inputlist_width_filename = '&co / 3' -" TLet g:tlib_inputlist_width_filename = 25 - -" If true, |tlib#input#List()| will show some indicators about the -" status of a filename (e.g. buflisted(), bufloaded() etc.). -" This is disabled by default because vim checks also for the file on -" disk when doing this. -TLet g:tlib_inputlist_filename_indicators = 0 - -" If not null, display only a short info about the filter. -TLet g:tlib_inputlist_shortmessage = 0 - - - -" Known keys & values: -" scratch_split ... See |tlib#scratch#UseScratch()| -let s:prototype = tlib#Object#New({ - \ '_class': 'World', - \ 'name': 'world', - \ 'allow_suspend': 1, - \ 'base': [], - \ 'bufnr': -1, - \ 'buffer_local': 1, - \ 'cache_var': '', - \ 'display_format': '', - \ 'fileencoding': &fileencoding, - \ 'fmt_display': {}, - \ 'fmt_filter': {}, - \ 'fmt_options': {}, - \ 'filetype': '', - \ 'filter': [['']], - \ 'filter_format': '', - \ 'filter_options': '', - \ 'follow_cursor': '', - \ 'has_menu': 0, - \ 'help_extra': [], - \ 'index_table': [], - \ 'initial_filter': [['']], - \ 'initial_index': 1, - \ 'initial_display': 1, - \ 'initialized': 0, - \ 'key_handlers': [], - \ 'list': [], - \ 'matcher': {}, - \ 'next_agent': '', - \ 'next_eval': '', - \ 'next_state': '', - \ 'numeric_chars': g:tlib#input#numeric_chars, - \ 'offset': 1, - \ 'offset_horizontal': 0, - \ 'on_leave': [], - \ 'pick_last_item': tlib#var#Get('tlib#input#pick_last_item', 'bg'), - \ 'post_handlers': [], - \ 'query': '', - \ 'resize': 0, - \ 'resize_vertical': 0, - \ 'restore_from_cache': [], - \ 'filtered_items': [], - \ 'resume_state': '', - \ 'retrieve_eval': '', - \ 'return_agent': '', - \ 'rv': '', - \ 'scratch': '__InputList__', - \ 'scratch_filetype': 'tlibInputList', - \ 'scratch_hidden': g:tlib#scratch#hidden, - \ 'scratch_vertical': 0, - \ 'scratch_split': 1, - \ 'sel_idx': [], - \ 'show_empty': 0, - \ 'state': 'display', - \ 'state_handlers': [], - \ 'sticky': 0, - \ 'temp_lines': [], - \ 'temp_prompt': [], - \ 'timeout': 0, - \ 'timeout_resolution': 2, - \ 'tabpagenr': -1, - \ 'type': '', - \ 'win_wnr': -1, - \ 'win_height': -1, - \ 'win_width': -1, - \ 'win_pct': 25, - \ }) - " \ 'handlers': [], - " \ 'filter_options': '\c', - -function! tlib#World#New(...) - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - call object.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'g', 'cnf')) - return object -endf - - -" :nodoc: -function! s:prototype.Set_display_format(value) dict "{{{3 - if a:value == 'filename' - call self.Set_highlight_filename() - let self.display_format = 'world.FormatFilename(%s)' - else - let self.display_format = a:value - endif -endf - - -" :nodoc: -function! s:prototype.DisplayFormat(list) dict "{{{3 - let display_format = self.display_format - if !empty(display_format) - if has_key(self, 'InitFormatName') - call self.InitFormatName() - endif - let cache = self.fmt_display - " TLogVAR display_format, fmt_entries - return map(copy(a:list), 'self.FormatName(cache, display_format, v:val)') - else - return a:list - endif -endf - - -" :nodoc: -function! s:prototype.Set_highlight_filename() dict "{{{3 - let self.tlib_UseInputListScratch = 'call world.Highlight_filename()' -endf - - -if g:tlib#input#format_filename == 'r' - - " :nodoc: - function! s:prototype.Highlight_filename() dict "{{{3 - syntax match TLibDir /\s\+\zs.\{-}[\/]\ze[^\/]\+$/ - hi def link TLibDir Directory - syntax match TLibFilename /[^\/]\+$/ - hi def link TLibFilename Normal - endf - - " :nodoc: - function! s:prototype.FormatFilename(file) dict "{{{3 - if !has_key(self.fmt_options, 'maxlen') - let maxco = &co - len(len(self.base)) - eval(g:tlib#input#filename_padding_r) - let maxfi = max(map(copy(self.base), 'strwidth(v:val)')) - let self.fmt_options.maxlen = min([maxco, maxfi]) - " TLogVAR maxco, maxfi, self.fmt_options.maxlen - endif - let max = self.fmt_options.maxlen - if len(a:file) > max - let filename = '...' . strpart(a:file, len(a:file) - max + 3) - else - let filename = printf('% '. max .'s', a:file) - endif - return filename - endf - -else - - " :nodoc: - function! s:prototype.Highlight_filename() dict "{{{3 - " let self.width_filename = 1 + eval(g:tlib_inputlist_width_filename) - " TLogVAR self.base - let self.width_filename = min([ - \ get(self, 'width_filename', &co), - \ empty(g:tlib#input#filename_max_width) ? &co : eval(g:tlib#input#filename_max_width), - \ max(map(copy(self.base), 'strwidth(matchstr(v:val, "[^\\/]*$"))')) - \ ]) - " TLogVAR self.width_filename - exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' - exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir' - " exec 'syntax match TLibDir /\(|\|\[.\{-}\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' - " exec 'syntax match TLibMarker /\(|\|\[.\{-}\]\) \S.*$/ contains=TLibDir' - exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir' - hi def link TLibMarker Special - hi def link TLibDir Directory - hi def link TLibFilename NonText - " :nodoc: - function! self.Highlighter(rx) dict - let rx = '/\c\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) .\{-}\zs'. escape(a:rx, '/') .'/' - exec 'match' self.matcher.highlight rx - endf - endf - - - " :nodoc: - function! s:prototype.UseFilenameIndicators() dict "{{{3 - return g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators') - endf - - - " :nodoc: - function! s:prototype.InitFormatName() dict "{{{3 - if self.UseFilenameIndicators() - let self._buffers = {} - for bufnr in range(1, bufnr('$')) - let filename = fnamemodify(bufname(bufnr), ':p') - " TLogVAR filename - let bufdef = { - \ 'bufnr': bufnr, - \ } - " '&buflisted' - for opt in ['&modified', '&bufhidden'] - let bufdef[opt] = getbufvar(bufnr, opt) - endfor - let self._buffers[filename] = bufdef - endfor - endif - endf - - - " :nodoc: - function! s:prototype.FormatFilename(file) dict "{{{3 - " TLogVAR a:file - let width = self.width_filename - let split = match(a:file, '[/\\]\zs[^/\\]\+$') - if split == -1 - let fname = a:file - let dname = a:file - else - let fname = strpart(a:file, split) - " let dname = strpart(a:file, 0, split - 1) - let dname = a:file - endif - if strwidth(fname) > width - let fname = strpart(fname, 0, width - 3) .'...' - endif - let dnmax = &co - max([width, strwidth(fname)]) - 8 - self.index_width - &fdc - let use_indicators = self.UseFilenameIndicators() - " TLogVAR use_indicators - let marker = [] - if use_indicators - call insert(marker, '[') - if g:tlib_inputlist_filename_indicators - let bufdef = get(self._buffers, a:file, {}) - " let bnr = bufnr(a:file) - let bnr = get(bufdef, 'bufnr', -1) - " TLogVAR a:file, bnr, self.bufnr - if bnr != -1 - if bnr == self.bufnr - call add(marker, '%') - else - call add(marker, bnr) - endif - if get(bufdef, '&modified', 0) - call add(marker, '+') - endif - if get(bufdef, '&bufhidden', '') == 'hide' - call add(marker, 'h') - endif - " if !get(bufdef, '&buflisted', 1) - " call add(marker, 'u') - " endif - " echom "DBG" a:file string(get(self,'filename_indicators')) - endif - endif - if has_key(self, 'filename_indicators') && has_key(self.filename_indicators, a:file) - if len(marker) > 1 - call add(marker, '|') - endif - call add(marker, self.filename_indicators[a:file]) - endif - if len(marker) <= 1 - call add(marker, ' ') - endif - call add(marker, ']') - else - call add(marker, '|') - endif - let markers = join(marker, '') - if !empty(markers) - let dnmax -= len(markers) - endif - if strwidth(dname) > dnmax - let dname = '...'. strpart(dname, len(dname) - dnmax) - endif - return printf("%-*s %s %s", - \ self.width_filename + len(fname) - strwidth(fname), - \ fname, markers, dname) - endf - -endif - - -" :nodoc: -function! s:prototype.GetSelectedItems(current) dict "{{{3 - " TLogVAR a:current - if stridx(self.type, 'i') != -1 - let rv = copy(self.sel_idx) - else - let rv = map(copy(self.sel_idx), 'self.GetBaseItem(v:val)') - endif - if !empty(a:current) - " TLogVAR a:current, rv, type(a:current) - if tlib#type#IsNumber(a:current) || tlib#type#IsString(a:current) - call s:InsertSelectedItems(rv, a:current) - elseif tlib#type#IsList(a:current) - for item in a:current - call s:InsertSelectedItems(rv, item) - endfor - elseif tlib#type#IsDictionary(a:current) - for [inum, item] in items(a:current) - call s:InsertSelectedItems(rv, item) - endfor - endif - endif - " TAssert empty(rv) || rv[0] == a:current - if stridx(self.type, 'i') != -1 - if !empty(self.index_table) - " TLogVAR rv, self.index_table - call map(rv, 'self.index_table[v:val - 1]') - " TLogVAR rv - endif - endif - return rv -endf - - -function! s:InsertSelectedItems(rv, current) "{{{3 - let ci = index(a:rv, a:current) - if ci != -1 - call remove(a:rv, ci) - endif - call insert(a:rv, a:current) -endf - - -" :nodoc: -function! s:prototype.SelectItemsByNames(mode, items) dict "{{{3 - for item in a:items - let bi = index(self.base, item) + 1 - " TLogVAR item, bi - if bi > 0 - let si = index(self.sel_idx, bi) - " TLogVAR self.sel_idx - " TLogVAR si - if si == -1 - call add(self.sel_idx, bi) - elseif a:mode == 'toggle' - call remove(self.sel_idx, si) - endif - endif - endfor - return 1 -endf - - -" :nodoc: -function! s:prototype.SelectItem(mode, index) dict "{{{3 - " TLogVAR a:mode, a:index - let bi = self.GetBaseIdx(a:index) - " if self.RespondTo('MaySelectItem') - " if !self.MaySelectItem(bi) - " return 0 - " endif - " endif - " TLogVAR bi - let si = index(self.sel_idx, bi) - " TLogVAR self.sel_idx - " TLogVAR si - if si == -1 - call add(self.sel_idx, bi) - elseif a:mode == 'toggle' - call remove(self.sel_idx, si) - endif - return 1 -endf - - -" :nodoc: -function! s:prototype.FormatBaseFromData() abort dict "{{{3 - if has_key(self, 'format_data') && has_key(self, 'data') - let self.base = map(copy(self.data), 'call(self.format_data, [v:val], self)') - endif -endf - - -" :nodoc: -function! s:prototype.FormatArgs(format_string, arg) dict "{{{3 - let nargs = len(substitute(a:format_string, '%%\|[^%]', '', 'g')) - return [a:format_string] + repeat([string(a:arg)], nargs) -endf - - -" :nodoc: -function! s:prototype.GetRx(filter) dict "{{{3 - return '\('. join(filter(copy(a:filter), 'v:val[0] != "!"'), '\|') .'\)' -endf - - -" :nodoc: -function! s:prototype.GetRx0(...) dict "{{{3 - exec tlib#arg#Let(['negative']) - let rx0 = [] - for filter in self.filter - " TLogVAR filter - let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') - " TLogVAR rx - if !empty(rx) && (negative ? rx[0] == g:tlib#input#not : rx[0] != g:tlib#input#not) - call add(rx0, rx) - endif - endfor - let rx0s = join(rx0, '\|') - if empty(rx0s) - return '' - else - return self.FilterRxPrefix() .'\('. rx0s .'\)' - endif -endf - - -" :nodoc: -function! s:prototype.FormatName(cache, format, value) dict "{{{3 - " TLogVAR a:format, a:value - " TLogDBG has_key(self.fmt_display, a:value) - if has_key(a:cache, a:value) - " TLogDBG "cached" - return a:cache[a:value] - else - let world = self - let ftpl = self.FormatArgs(a:format, a:value) - let fn = call(function("printf"), ftpl) - let fmt = eval(fn) - " TLogVAR ftpl, fn, fmt - let a:cache[a:value] = fmt - return fmt - endif -endf - - -" :nodoc: -function! s:prototype.GetItem(idx) dict "{{{3 - return self.list[a:idx - 1] -endf - - -" :nodoc: -function! s:prototype.GetListIdx(baseidx) dict "{{{3 - " if empty(self.index_table) - let baseidx = a:baseidx - " else - " let baseidx = 0 + self.index_table[a:baseidx - 1] - " " TLogVAR a:baseidx, baseidx, self.index_table - " endif - let rv = index(self.table, baseidx) - " TLogVAR rv, self.table - return rv -endf - - -" :nodoc: -" The first index is 1. -function! s:prototype.GetBaseIdx(idx) dict "{{{3 - " TLogVAR a:idx, self.table, self.index_table - if !empty(self.table) && a:idx > 0 && a:idx <= len(self.table) - return self.table[a:idx - 1] - else - return 0 - endif -endf - - -" :nodoc: -function! s:prototype.GetBaseIdx0(idx) dict "{{{3 - let idx0 = self.GetBaseIdx(a:idx) - 1 - if idx0 < 0 - call tlib#notify#Echo('TLIB: Internal Error: GetBaseIdx0: idx0 < 0', 'WarningMsg') - endif - return idx0 -endf - - -" :nodoc: -function! s:prototype.GetBaseItem(idx) dict "{{{3 - return self.base[a:idx - 1] -endf - - -" :nodoc: -function! s:prototype.SetBaseItem(idx, item) dict "{{{3 - let self.base[a:idx - 1] = a:item -endf - - -" :nodoc: -function! s:prototype.GetLineIdx(lnum) dict "{{{3 - let line = getline(a:lnum) - let prefidx = substitute(matchstr(line, '^\d\+\ze[*:]'), '^0\+', '', '') - return prefidx -endf - - -" :nodoc: -function! s:prototype.SetPrefIdx() dict "{{{3 - " let pref = sort(range(1, self.llen), 'self.SortPrefs') - " let self.prefidx = get(pref, 0, self.initial_index) - let pref_idx = -1 - let pref_weight = -1 - " TLogVAR self.filter_pos, self.filter_neg - " let t0 = localtime() " DBG - for idx in range(1, self.llen) - let item = self.GetItem(idx) - let weight = self.matcher.AssessName(self, item) - " TLogVAR item, weight - if weight > pref_weight - let pref_idx = idx - let pref_weight = weight - endif - endfor - " TLogVAR localtime() - t0 - " TLogVAR pref_idx - " TLogDBG self.GetItem(pref_idx) - if pref_idx == -1 - let self.prefidx = self.initial_index - else - let self.prefidx = pref_idx - endif -endf - - -" " :nodoc: -" function! s:prototype.GetCurrentItem() dict "{{{3 -" let idx = self.prefidx -" " TLogVAR idx -" if stridx(self.type, 'i') != -1 -" return idx -" elseif !empty(self.list) -" if len(self.list) >= idx -" let idx1 = idx - 1 -" let rv = self.list[idx - 1] -" " TLogVAR idx, idx1, rv, self.list -" return rv -" endif -" else -" return '' -" endif -" endf - - -" :nodoc: -function! s:prototype.CurrentItem() dict "{{{3 - if stridx(self.type, 'i') != -1 - return self.GetBaseIdx(self.llen == 1 ? 1 : self.prefidx) - else - if self.llen == 1 - " TLogVAR self.llen - return self.list[0] - elseif self.prefidx > 0 - " TLogVAR self.prefidx - " return self.GetCurrentItem() - if len(self.list) >= self.prefidx - let rv = self.list[self.prefidx - 1] - " TLogVAR idx, rv, self.list - return rv - endif - else - return '' - endif - endif -endf - - -" :nodoc: -function! s:prototype.FilterRxPrefix() dict "{{{3 - return self.matcher.FilterRxPrefix() -endf - - -" :nodoc: -function! s:prototype.SetFilter() dict "{{{3 - " let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '') - let mrx = self.FilterRxPrefix() . self.filter_options - let self.filter_pos = [] - let self.filter_neg = [] - " TLogVAR mrx, self.filter - for filter in self.filter - " TLogVAR filter - let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') - " TLogVAR rx - if !empty(rx) - if rx =~ '\u' - let mrx1 = mrx .'\C' - else - let mrx1 = mrx - endif - " TLogVAR rx - if rx[0] == g:tlib#input#not - if len(rx) > 1 - call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)') - endif - else - call add(self.filter_pos, mrx1 .'\('. rx .'\)') - endif - endif - endfor - " TLogVAR self.filter_pos, self.filter_neg -endf - - -" :nodoc: -function! s:prototype.IsValidFilter() dict "{{{3 - let last = self.FilterRxPrefix() .'\('. self.filter[0][0] .'\)' - Tlibtrace 'tlib', last - " TLogVAR last - try - let a = match("", last) - return 1 - catch - Tlibtrace 'tlib', v:exception - return 0 - endtry -endf - - -" :nodoc: -function! s:prototype.SetMatchMode(match_mode) dict "{{{3 - " TLogVAR a:match_mode - if !empty(a:match_mode) - unlet self.matcher - try - let self.matcher = tlib#Filter_{a:match_mode}#New() - call self.matcher.Init(self) - catch /^Vim\%((\a\+)\)\=:E117/ - throw 'tlib: Unknown mode for tlib#input#filter_mode: '. a:match_mode - endtry - endif -endf - - -" function! s:prototype.Match(text) dict "{{{3 -" return self.matcher.Match(self, text) -" endf - - -" :nodoc: -function! s:prototype.MatchBaseIdx(idx) dict "{{{3 - let text = self.GetBaseItem(a:idx) - if !empty(self.filter_format) - let text = self.FormatName(self.fmt_filter, self.filter_format, text) - endif - " TLogVAR text - " return self.Match(text) - return self.matcher.Match(self, text) -endf - - -" :nodoc: -function! s:prototype.BuildTableList() dict "{{{3 - " let time0 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time0 - call self.SetFilter() - " TLogVAR self.filter_neg, self.filter_pos - let self.table = range(1, len(self.base)) - " TLogVAR self.filtered_items - let copy_base = 1 - if !empty(self.filtered_items) - let self.table = filter(self.table, 'index(self.filtered_items, v:val) != -1') - let copy_base = 0 - endif - if !empty(self.filter_pos) || !empty(self.filter_neg) - let self.table = filter(self.table, 'self.MatchBaseIdx(v:val)') - let copy_base = 0 - endif - if copy_base - let self.list = copy(self.base) - else - let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)') - endif -endf - - -" :nodoc: -function! s:prototype.ReduceFilter() dict "{{{3 - " TLogVAR self.filter - let reduced = 0 - while !reduced - if self.filter[0] == [''] && len(self.filter) > 1 - call remove(self.filter, 0) - elseif empty(self.filter[0][0]) && len(self.filter[0]) > 1 - call remove(self.filter[0], 0) - else - call self.matcher.ReduceFrontFilter(self) - endif - if self.IsValidFilter() - let reduced = 1 - endif - endwh -endf - - -" :nodoc: -" filter is either a string or a list of list of strings. -function! s:prototype.SetInitialFilter(filter) dict "{{{3 - " let self.initial_filter = [[''], [a:filter]] - Tlibtrace 'tlib', a:filter - if type(a:filter) == 3 - let self.initial_filter = deepcopy(a:filter) - else - let self.initial_filter = [[a:filter]] - endif -endf - - -" :nodoc: -function! s:prototype.PopFilter() dict "{{{3 - " TLogVAR self.filter - if len(self.filter[0]) > 1 - call remove(self.filter[0], 0) - elseif len(self.filter) > 1 - call remove(self.filter, 0) - else - let self.filter[0] = [''] - endif -endf - - -" :nodoc: -function! s:prototype.FilterIsEmpty() dict "{{{3 - " TLogVAR self.filter - return self.filter == copy(self.initial_filter) -endf - - -" :nodoc: -function! s:prototype.DisplayFilter() dict "{{{3 - let filter1 = copy(self.filter) - call filter(filter1, 'v:val != [""]') - " TLogVAR self.matcher['_class'] - let rv = self.matcher.DisplayFilter(filter1) - let rv = self.CleanFilter(rv) - return rv -endf - - -" :nodoc: -function! s:prototype.SetFrontFilter(pattern) dict "{{{3 - call self.matcher.SetFrontFilter(self, a:pattern) -endf - - -" :nodoc: -function! s:prototype.PushFrontFilter(char) dict "{{{3 - call self.matcher.PushFrontFilter(self, a:char) -endf - - -" :nodoc: -function! s:prototype.CleanFilter(filter) dict "{{{3 - return self.matcher.CleanFilter(a:filter) -endf - - -" :nodoc: -function! s:prototype.UseScratch() dict "{{{3 - " if type(self.scratch) != 0 && get(self, 'buffer_local', 1) - " if self.scratch != fnamemodify(self.scratch, ':p') - " let self.scratch = tlib#file#Join([expand('%:p:h'), self.scratch]) - " " TLogVAR self.scratch - " endif - " " let self.scratch_hidden = 'wipe' - " endif - keepjumps keepalt let rv = tlib#scratch#UseScratch(self) - " if expand('%:t') == self.scratch - let b:tlib_world = self - " endif - return rv -endf - - -" :nodoc: -function! s:prototype.CloseScratch(...) dict "{{{3 - TVarArg ['reset_scratch', 0] - " TVarArg ['reset_scratch', 1] - " TLogVAR reset_scratch - if self.sticky - return 0 - else - let rv = tlib#scratch#CloseScratch(self, reset_scratch) - " TLogVAR rv - if rv - call self.SwitchWindow('win') - endif - return rv - endif -endf - - -" :nodoc: -function! s:prototype.Initialize() dict "{{{3 - let self.initialized = 1 - call self.SetOrigin(1) - call self.Reset(1) - if !empty(self.cache_var) && exists(self.cache_var) - for prop in self.restore_from_cache - exec 'let self[prop] = get('. self.cache_var .', prop, self[prop])' - endfor - exec 'unlet '. self.cache_var - endif -endf - - -" :nodoc: -function! s:prototype.Leave() dict "{{{3 - if !empty(self.cache_var) - exec 'let '. self.cache_var .' = self' - endif - for handler in self.on_leave - call call(handler, [self]) - endfor -endf - - -" :nodoc: -function! s:prototype.UseInputListScratch() dict "{{{3 - let scratch = self.UseScratch() - if !exists('b:tlib_list_init') - call tlib#autocmdgroup#Init() - autocmd TLib VimResized call feedkeys("\", 't') - " autocmd TLib WinLeave let b:tlib_world_event = 'WinLeave' | call feedkeys("\", 't') - let b:tlib_list_init = 1 - endif - if !exists('w:tlib_list_init') - " TLogVAR scratch - if has_key(self, 'index_next_syntax') - if type(self.index_next_syntax) == 1 - exec 'syntax match InputlListIndex /^\d\+:\s/ nextgroup='. self.index_next_syntax - elseif type(self.index_next_syntax) == 4 - for [n, nsyn] in items(self.index_next_syntax) - let fn = printf('%0'. world.index_width .'d', n) - exec 'syntax match InputlListIndex /^'. fn .':\s/ nextgroup='. nsyn - endfor - endif - else - syntax match InputlListIndex /^\d\+:\s/ - endif - call tlib#hook#Run('tlib_UseInputListScratch', self) - syntax match InputlListCursor /^\d\+\* .*$/ contains=InputlListIndex - syntax match InputlListSelected /^\d\+# .*$/ contains=InputlListIndex - hi def link InputlListIndex Constant - hi def link InputlListCursor Search - hi def link InputlListSelected IncSearch - setlocal nowrap - " hi def link InputlListIndex Special - " let b:tlibDisplayListMarks = {} - let b:tlibDisplayListMarks = [] - let b:tlibDisplayListWorld = self - let w:tlib_list_init = 1 - endif - return scratch -endf - - -" s:prototype.Reset(?initial=0) -" :nodoc: -function! s:prototype.Reset(...) dict "{{{3 - TVarArg ['initial', 0] - " TLogVAR initial - Tlibtrace 'tlib', initial, self.initial_filter - let self.state = 'display' - let self.offset = 1 - let self.filter = deepcopy(self.initial_filter) - let self.idx = '' - let self.prefidx = 0 - let self.initial_display = 1 - let self.fmt_display = {} - let self.fmt_filter = {} - call self.UseInputListScratch() - call self.ResetSelected() - call self.Retrieve(!initial) - call self.FormatBaseFromData() - return self -endf - - -" :nodoc: -function! s:prototype.ResetSelected() dict "{{{3 - let self.sel_idx = [] -endf - - -" :nodoc: -function! s:prototype.Retrieve(anyway) dict "{{{3 - " TLogVAR a:anyway, self.base - " TLogDBG (a:anyway || empty(self.base)) - if (a:anyway || empty(self.base)) - let ra = self.retrieve_eval - " TLogVAR ra - if !empty(ra) - let back = self.SwitchWindow('win') - let world = self - let self.base = eval(ra) - " TLogVAR self.base - exec back - return 1 - endif - endif - return 0 -endf - - -function! s:FormatHelp(help) "{{{3 - " TLogVAR a:help - let max = [0, 0] - for item in a:help - " TLogVAR item - if type(item) == 3 - let itemlen = map(copy(item), 'strwidth(v:val)') - " TLogVAR itemlen - let max = map(range(2), 'max[v:val] >= itemlen[v:val] ? max[v:val] : itemlen[v:val]') - endif - unlet item - endfor - " TLogVAR max - let cols = float2nr((winwidth(0) - &foldcolumn - 1) / (max[0] + max[1] + 2)) - if cols < 1 - let cols = 1 - endif - let fmt = printf('%%%ds: %%-%ds', max[0], max[1]) - " TLogVAR cols, fmt - let help = [] - let idx = -1 - let maxidx = len(a:help) - while idx < maxidx - let push_item = 0 - let accum = [] - for i in range(cols) - let idx += 1 - if idx >= maxidx - break - endif - let item = a:help[idx] - if type(item) == 3 - call add(accum, item) - else - let push_item = 1 - break - endif - unlet item - endfor - if !empty(accum) - call add(help, s:FormatHelpItem(accum, fmt)) - endif - if push_item - call add(help, a:help[idx]) - endif - endwh - " TLogVAR help - return help -endf - - -function! s:FormatHelpItem(item, fmt) "{{{3 - let args = [join(repeat([a:fmt], len(a:item)), ' ')] - for item in a:item - " TLogVAR item - let args += item - endfor - " TLogVAR args - return call('printf', args) -endf - - -" :nodoc: -function! s:prototype.InitHelp() dict "{{{3 - return [] -endf - - -" :nodoc: -function! s:prototype.PushHelp(...) dict "{{{3 - " TLogVAR a:000 - if a:0 == 1 - if type(a:1) == 3 - let self.temp_lines += a:1 - else - call add(self.temp_lines, a:1) - endif - elseif a:0 == 2 - call add(self.temp_lines, a:000) - else - throw "TLIB: PushHelp: Wrong number of arguments: ". string(a:000) - endif - " TLogVAR helpstring -endf - - -" :nodoc: -function! s:prototype.DisplayHelp() dict "{{{3 - let self.temp_lines = self.InitHelp() - call self.PushHelp('', self.key_mode == 'default' ? 'Abort' : 'Reset keymap') - call self.PushHelp('Enter, ', 'Pick the current item') - call self.PushHelp('Mouse', 'L: Pick item, R: Show menu') - call self.PushHelp('', 'Select an item') - call self.PushHelp(', ', 'Reduce filter') - call self.PushHelp('', 'Complete word') - call self.PushHelp(', ', 'Enter command') - - if self.key_mode == 'default' - call self.PushHelp('', 'Reset the display') - call self.PushHelp('Up/Down', 'Next/previous item') - call self.PushHelp('', 'Edit top filter string') - call self.PushHelp('Page Up/Down', 'Scroll') - call self.PushHelp('', 'Enter * Wildcard') - if self.allow_suspend - call self.PushHelp('', 'Suspend/Resume') - call self.PushHelp('', 'Switch to origin') - endif - if stridx(self.type, 'm') != -1 - call self.PushHelp('', '(Un)Select items') - call self.PushHelp('#', '(Un)Select the current item') - call self.PushHelp('', '(Un)Select all items') - call self.PushHelp('', '(Un)Restrict view to selection') - " \ ' ... Show only selected', - endif - endif - - " TLogVAR len(self.temp_lines) - call self.matcher.Help(self) - - " TLogVAR self.key_mode - for handler in values(self.key_map[self.key_mode]) - " TLogVAR handler - let key = get(handler, 'key_name', '') - " TLogVAR key - if !empty(key) - let desc = get(handler, 'help', '') - if empty(desc) - let desc = get(handler, 'agent', '') - endif - call self.PushHelp(key, desc) - endif - endfor - - if !has_key(self.key_map[self.key_mode], 'unknown_key') - call self.PushHelp('Letter', 'Filter the list') - endif - - if self.key_mode == 'default' && !empty(self.help_extra) - call self.PushHelp(self.help_extra) - endif - - " TLogVAR len(self.temp_lines) - call self.PushHelp([ - \ '', - \ 'Matches at word boundaries are prioritized.', - \ ]) - let self.temp_lines = s:FormatHelp(self.temp_lines) - call self.PrintLines() -endf - - -function! s:prototype.PrintLines() dict "{{{3 - let self.temp_prompt = ['Press any key to continue.', 'Question'] - call tlib#buffer#DeleteRange('1', '$') - call append(0, self.temp_lines) - call tlib#buffer#DeleteRange('$', '$') - 1 - call self.Resize(len(self.temp_lines), 0) - let self.temp_lines = [] -endf - - -" :nodoc: -function! s:prototype.Resize(hsize, vsize) dict "{{{3 - " TLogVAR self.scratch_vertical, a:hsize, a:vsize - let world_resize = '' - let winpos = '' - let scratch_split = get(self, 'scratch_split', 1) - " TLogVAR scratch_split - if scratch_split > 0 - if self.scratch_vertical - if a:vsize - let world_resize = 'vert resize '. a:vsize - let winpos = tlib#fixes#Winpos() - " let w:winresize = {'v': a:vsize} - setlocal winfixwidth - endif - else - if a:hsize - let world_resize = 'resize '. a:hsize - " let w:winresize = {'h': a:hsize} - setlocal winfixheight - endif - endif - endif - if !empty(world_resize) - " TLogVAR world_resize, winpos - exec world_resize - if !empty(winpos) - exec winpos - endif - " redraw! - endif -endf - - -" :nodoc: -function! s:prototype.GetResize(size) dict "{{{3 - let resize0 = get(self, 'resize', 0) - let resize = empty(resize0) ? 0 : eval(resize0) - " TLogVAR resize0, resize - let resize = resize == 0 ? a:size : min([a:size, resize]) - " let min = self.scratch_vertical ? &cols : &lines - let min1 = (self.scratch_vertical ? self.win_width : self.win_height) * g:tlib_inputlist_pct - let min2 = (self.scratch_vertical ? &columns : &lines) * self.win_pct - let min = max([min1, min2]) - let resize = min([resize, (min / 100)]) - " TLogVAR resize, a:size, min, min1, min2 - return resize -endf - - -" function! s:prototype.DisplayList(?query=self.Query(), ?list=[]) -" :nodoc: -function! s:prototype.DisplayList(...) dict "{{{3 - " TLogVAR self.state - let query = a:0 >= 1 ? a:1 : self.Query() - let list = a:0 >= 2 ? a:2 : [] - " TLogVAR query, len(list) - " TLogDBG 'len(list) = '. len(list) - call self.UseScratch() - " TLogVAR self.scratch - " TAssert IsNotEmpty(self.scratch) - if self.state == 'scroll' - call self.ScrollToOffset() - elseif self.state == 'help' - call self.DisplayHelp() - call self.SetStatusline(query) - elseif self.state == 'printlines' - call self.PrintLines() - call self.SetStatusline(query) - else - " TLogVAR query - " let ll = len(list) - let ll = self.llen - " let x = len(ll) + 1 - let x = self.index_width + 1 - " TLogVAR ll - if self.state =~ '\' - call self.Resize(self.GetResize(ll), eval(get(self, 'resize_vertical', 0))) - call tlib#normal#WithRegister('gg"tdG', 't') - let lines = copy(list) - let lines = map(lines, 'substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g")') - let w = winwidth(0) - &fdc - " let w = winwidth(0) - &fdc - 1 - let lines = map(lines, 'printf("%-'. w .'.'. w .'s", v:val)') - " TLogVAR lines - call append(0, lines) - call tlib#normal#WithRegister('G"tddgg', 't') - endif - " TLogVAR self.prefidx - let base_pref = self.GetBaseIdx(self.prefidx) - " TLogVAR base_pref - if self.state =~ '\' - call filter(b:tlibDisplayListMarks, 'index(self.sel_idx, v:val) == -1 && v:val != base_pref') - " TLogVAR b:tlibDisplayListMarks - call map(b:tlibDisplayListMarks, 'self.DisplayListMark(x, v:val, ":")') - " let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') - " call add(b:tlibDisplayListMarks, self.prefidx) - " call self.DisplayListMark(x, self.GetBaseIdx(self.prefidx), '*') - endif - let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') - call add(b:tlibDisplayListMarks, base_pref) - call self.DisplayListMark(x, base_pref, '*') - call self.SetOffset() - call self.SetStatusline(query) - " TLogVAR self.offset - call self.ScrollToOffset() - let rx0 = self.GetRx0() - " TLogVAR rx0 - if !empty(self.matcher.highlight) - if empty(rx0) - match none - elseif self.IsValidFilter() - if has_key(self, 'Highlighter') - call self.Highlighter(rx0) - else - exec 'match '. self.matcher.highlight .' /\c'. escape(rx0, '/') .'/' - endif - endif - endif - endif - redraw -endf - - -" :nodoc: -function! s:prototype.SetStatusline(query) dict "{{{3 - " TLogVAR a:query - if !empty(self.temp_prompt) - let echo = get(self.temp_prompt, 0, '') - let hl = get(self.temp_prompt, 1, 'Normal') - let self.temp_prompt = [] - else - let hl = 'Normal' - let query = a:query - let options = [self.matcher.name] - if self.sticky - call add(options, '#') - endif - if self.key_mode != 'default' - call add(options, 'map:'. self.key_mode) - endif - if !empty(self.filtered_items) - if g:tlib_inputlist_shortmessage - call add(options, 'R') - else - call add(options, 'restricted') - endif - endif - if !empty(options) - let sopts = printf('[%s]', join(options, ', ')) - " let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts - let echo = query . ' ' . sopts - " let query .= '%%='. sopts .' ' - endif - " TLogVAR &l:statusline, query - " let &l:statusline = query - endif - echo - if hl != 'Normal' - exec 'echohl' hl - echo echo - echohl None - else - echo echo - endif -endf - - -" :nodoc: -function! s:prototype.Query() dict "{{{3 - let flt = self.DisplayFilter() - if g:tlib_inputlist_shortmessage - let query = 'Filter: '. flt - else - let query = self.query .' (filter: '. flt .'; press for help)' - endif - return query -endf - - -" :nodoc: -function! s:prototype.ScrollToOffset() dict "{{{3 - " TLogVAR self.scratch_vertical, self.llen, winheight(0) - exec 'norm! '. self.offset .'zt' -endf - - -" :nodoc: -function! s:prototype.SetOffset() dict "{{{3 - " TLogVAR self.prefidx, self.offset - " TLogDBG winheight(0) - " TLogDBG self.prefidx > self.offset + winheight(0) - 1 - let listtop = len(self.list) - winheight(0) + 1 - if listtop < 1 - let listtop = 1 - endif - if self.prefidx > listtop - let self.offset = listtop - elseif self.prefidx > self.offset + winheight(0) - 1 - let listoff = self.prefidx - winheight(0) + 1 - let self.offset = min([listtop, listoff]) - " TLogVAR self.prefidx - " TLogDBG len(self.list) - " TLogDBG winheight(0) - " TLogVAR listtop, listoff, self.offset - elseif self.prefidx < self.offset - let self.offset = self.prefidx - endif - " TLogVAR self.offset -endf - - -" :nodoc: -function! s:prototype.ClearAllMarks() dict "{{{3 - let x = self.index_width + 1 - call map(range(1, line('$')), 'self.DisplayListMark(x, v:val, ":")') -endf - - -" :nodoc: -function! s:prototype.MarkCurrent(y) dict "{{{3 - let x = self.index_width + 1 - call self.DisplayListMark(x, a:y, '*') -endf - - -" :nodoc: -function! s:prototype.DisplayListMark(x, y, mark) dict "{{{3 - " TLogVAR a:y, a:mark - if a:x > 0 && a:y >= 0 - " TLogDBG a:x .'x'. a:y .' '. a:mark - let sy = self.GetListIdx(a:y) + 1 - " TLogVAR sy - if sy >= 1 - call setpos('.', [0, sy, a:x, 0]) - exec 'norm! r'. a:mark - " exec 'norm! '. a:y .'gg'. a:x .'|r'. a:mark - endif - endif - return a:y -endf - - -" :nodoc: -function! s:prototype.SwitchWindow(where) dict "{{{3 - " TLogDBG string(tlib#win#List()) - if self.tabpagenr != tabpagenr() - call tlib#tab#Set(self.tabpagenr) - endif - let wnr = get(self, a:where.'_wnr') - " TLogVAR self, wnr - return tlib#win#Set(wnr) -endf - - -" :nodoc: -function! s:prototype.FollowCursor() dict "{{{3 - if !empty(self.follow_cursor) - let back = self.SwitchWindow('win') - " TLogVAR back - " TLogDBG winnr() - try - call call(self.follow_cursor, [self, [self.CurrentItem()]]) - finally - exec back - endtry - endif -endf - - -" :nodoc: -function! s:prototype.SetOrigin(...) dict "{{{3 - TVarArg ['winview', 0] - " TLogVAR self.win_wnr, self.bufnr - " TLogDBG bufname('%') - " TLogDBG winnr() - " TLogDBG winnr('$') - let self.win_wnr = winnr() - let self.win_height = winheight(self.win_wnr) - let self.win_width = winwidth(self.win_wnr) - " TLogVAR self.win_wnr, self.win_height, self.win_width - let self.bufnr = bufnr('%') - let self.tabpagenr = tabpagenr() - let self.cursor = getpos('.') - if winview - let self.winview = tlib#win#GetLayout() - endif - " TLogVAR self.win_wnr, self.bufnr, self.winview - return self -endf - - -" :nodoc: -function! s:prototype.RestoreOrigin(...) dict "{{{3 - TVarArg ['winview', 0] - if winview - " TLogVAR winview - call tlib#win#SetLayout(self.winview) - endif - " TLogVAR self.win_wnr, self.bufnr, self.cursor, &splitbelow - " TLogDBG "RestoreOrigin0 ". string(tlib#win#List()) - " If &splitbelow or &splitright is false, we cannot rely on - " self.win_wnr to be our source buffer since, e.g, opening a buffer - " in a split window changes the whole layout. - " Possible solutions: - " - Restrict buffer switching to cases when the number of windows - " hasn't changed. - " - Guess the right window, which we try to do here. - if &splitbelow == 0 || &splitright == 0 - let wn = bufwinnr(self.bufnr) - " TLogVAR wn - if wn == -1 - let wn = 1 - end - else - let wn = self.win_wnr - endif - if wn != winnr() - exec wn .'wincmd w' - endif - exec 'buffer! '. self.bufnr - call setpos('.', self.cursor) - " TLogDBG "RestoreOrigin1 ". string(tlib#win#List()) -endf - - -function! s:prototype.Suspend() dict "{{{3 - call tlib#agent#Suspend(self, self.rv) -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/agent.vim b/sources_non_forked/tlib/autoload/tlib/agent.vim deleted file mode 100644 index 98275f12..00000000 --- a/sources_non_forked/tlib/autoload/tlib/agent.vim +++ /dev/null @@ -1,664 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 328 - - -" :filedoc: -" Various agents for use as key handlers in tlib#input#List() - -" Number of items to move when pressing in the input list window. -TLet g:tlib_scroll_lines = 10 - - -" General {{{1 - -function! tlib#agent#Exit(world, selected) "{{{3 - if a:world.key_mode == 'default' - call a:world.CloseScratch() - let a:world.state = 'exit empty escape' - let a:world.list = [] - " let a:world.base = [] - call a:world.ResetSelected() - else - let a:world.key_mode = 'default' - let a:world.state = 'redisplay' - endif - return a:world -endf - - -function! tlib#agent#CopyItems(world, selected) "{{{3 - let @* = join(a:selected, "\n") - let a:world.state = 'redisplay' - return a:world -endf - - - -" InputList related {{{1 - -function! tlib#agent#PageUp(world, selected) "{{{3 - let a:world.offset -= (winheight(0) / 2) - let a:world.state = 'scroll' - return a:world -endf - - -function! tlib#agent#PageDown(world, selected) "{{{3 - let a:world.offset += (winheight(0) / 2) - let a:world.state = 'scroll' - return a:world -endf - - -function! tlib#agent#Home(world, selected) "{{{3 - let a:world.prefidx = 1 - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#End(world, selected) "{{{3 - let a:world.prefidx = len(a:world.list) - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#Up(world, selected, ...) "{{{3 - TVarArg ['lines', 1] - let a:world.idx = '' - if a:world.prefidx > lines - let a:world.prefidx -= lines - else - let a:world.prefidx = len(a:world.list) - endif - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#Down(world, selected, ...) "{{{3 - TVarArg ['lines', 1] - let a:world.idx = '' - if a:world.prefidx <= (len(a:world.list) - lines) - let a:world.prefidx += lines - else - let a:world.prefidx = 1 - endif - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#UpN(world, selected) "{{{3 - return tlib#agent#Up(a:world, a:selected, g:tlib_scroll_lines) -endf - - -function! tlib#agent#DownN(world, selected) "{{{3 - return tlib#agent#Down(a:world, a:selected, g:tlib_scroll_lines) -endf - - -function! tlib#agent#ShiftLeft(world, selected) "{{{3 - let a:world.offset_horizontal -= (winwidth(0) / 2) - if a:world.offset_horizontal < 0 - let a:world.offset_horizontal = 0 - endif - let a:world.state = 'display shift' - return a:world -endf - - -function! tlib#agent#ShiftRight(world, selected) "{{{3 - let a:world.offset_horizontal += (winwidth(0) / 2) - let a:world.state = 'display shift' - return a:world -endf - - -function! tlib#agent#Reset(world, selected) "{{{3 - let a:world.state = 'reset' - return a:world -endf - - -function! tlib#agent#ToggleRestrictView(world, selected) "{{{3 - if empty(a:world.filtered_items) - return tlib#agent#RestrictView(a:world, a:selected) - else - return tlib#agent#UnrestrictView(a:world, a:selected) - endif -endf - - -function! tlib#agent#RestrictView(world, selected) "{{{3 - " TLogVAR a:selected - let filtered_items = map(copy(a:selected), 'index(a:world.base, v:val) + 1') - " TLogVAR 1, filtered_items - let filtered_items = filter(filtered_items, 'v:val > 0') - " TLogVAR 2, filtered_items - if !empty(filtered_items) - let a:world.filtered_items = filtered_items - endif - let a:world.state = 'display' - return a:world -endf - - -function! tlib#agent#UnrestrictView(world, selected) "{{{3 - let a:world.filtered_items = [] - let a:world.state = 'display' - return a:world -endf - - -function! tlib#agent#Input(world, selected) "{{{3 - let flt0 = a:world.CleanFilter(a:world.filter[0][0]) - let flt1 = input('Filter: ', flt0) - echo - if flt1 != flt0 - if empty(flt1) - call getchar(0) - else - call a:world.SetFrontFilter(flt1) - endif - endif - let a:world.state = 'display' - return a:world -endf - - -" Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the -" original position in the parent window. -function! tlib#agent#SuspendToParentWindow(world, selected) "{{{3 - let world = a:world - let winnr = world.win_wnr - " TLogVAR winnr - if winnr != -1 - let world = tlib#agent#Suspend(world, a:selected) - if world.state =~ '\' - call world.SwitchWindow('win') - " let pos = world.cursor - " " TLogVAR pos - " if !empty(pos) - " call setpos('.', pos) - " endif - return world - endif - endif - let world.state = 'redisplay' - return world -endf - - -" Suspend lets you temporarily leave the input loop of -" |tlib#input#List|. You can resume editing the list by pressing , -" . , or in the suspended window. -" and will immediatly select the item under the cursor. -" < will select the item but the window will remain opened. -function! tlib#agent#Suspend(world, selected) "{{{3 - if a:world.allow_suspend - " TAssert IsNotEmpty(a:world.scratch) - " TLogDBG bufnr('%') - let br = tlib#buffer#Set(a:world.scratch) - " TLogVAR br, a:world.bufnr, a:world.scratch - if bufnr('%') != a:world.scratch - echohl WarningMsg - echom "tlib#agent#Suspend: Internal error: Not a scratch buffer:" bufname('%') - echohl NONE - endif - " TLogVAR bufnr('%'), bufname('%'), a:world.scratch - call tlib#autocmdgroup#Init() - exec 'autocmd TLib BufEnter call tlib#input#Resume("world", 0, '. a:world.scratch .')' - let b:tlib_world = a:world - exec br - let a:world.state = 'exit suspend' - else - echom 'Suspend disabled' - let a:world.state = 'redisplay' - endif - return a:world -endf - - -function! tlib#agent#Help(world, selected) "{{{3 - let a:world.state = 'help' - return a:world -endf - - -function! tlib#agent#OR(world, selected) "{{{3 - if !empty(a:world.filter[0]) - call insert(a:world.filter[0], '') - endif - let a:world.state = 'display' - return a:world -endf - - -function! tlib#agent#AND(world, selected) "{{{3 - if !empty(a:world.filter[0]) - call insert(a:world.filter, ['']) - endif - let a:world.state = 'display' - return a:world -endf - - -function! tlib#agent#ReduceFilter(world, selected) "{{{3 - call a:world.ReduceFilter() - let a:world.offset = 1 - let a:world.state = 'display' - return a:world -endf - - -function! tlib#agent#PopFilter(world, selected) "{{{3 - call a:world.PopFilter() - let a:world.offset = 1 - let a:world.state = 'display' - return a:world -endf - - -function! tlib#agent#Debug(world, selected) "{{{3 - " echo string(world.state) - echo string(a:world.filter) - echo string(a:world.idx) - echo string(a:world.prefidx) - echo string(a:world.sel_idx) - call getchar() - let a:world.state = 'display' - return a:world -endf - - -function! tlib#agent#Select(world, selected) "{{{3 - call a:world.SelectItem('toggle', a:world.prefidx) - " let a:world.state = 'display keepcursor' - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#SelectUp(world, selected) "{{{3 - call a:world.SelectItem('toggle', a:world.prefidx) - if a:world.prefidx > 1 - let a:world.prefidx -= 1 - endif - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#SelectDown(world, selected) "{{{3 - call a:world.SelectItem('toggle', a:world.prefidx) - if a:world.prefidx < len(a:world.list) - let a:world.prefidx += 1 - endif - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#SelectAll(world, selected) "{{{3 - let listrange = range(1, len(a:world.list)) - let mode = empty(filter(copy(listrange), 'index(a:world.sel_idx, a:world.GetBaseIdx(v:val)) == -1')) - \ ? 'toggle' : 'set' - for i in listrange - call a:world.SelectItem(mode, i) - endfor - let a:world.state = 'display keepcursor' - return a:world -endf - - -function! tlib#agent#ToggleStickyList(world, selected) "{{{3 - let a:world.sticky = !a:world.sticky - let a:world.state = 'display keepcursor' - return a:world -endf - - - -" EditList related {{{1 - -function! tlib#agent#EditItem(world, selected) "{{{3 - let lidx = a:world.prefidx - " TLogVAR lidx - " TLogVAR a:world.table - let bidx = a:world.GetBaseIdx(lidx) - " TLogVAR bidx - let item = a:world.GetBaseItem(bidx) - let item = input(lidx .'@'. bidx .': ', item) - if item != '' - call a:world.SetBaseItem(bidx, item) - endif - let a:world.state = 'display' - return a:world -endf - - -" Insert a new item below the current one. -function! tlib#agent#NewItem(world, selected) "{{{3 - let basepi = a:world.GetBaseIdx(a:world.prefidx) - let item = input('New item: ') - call insert(a:world.base, item, basepi) - let a:world.state = 'reset' - return a:world -endf - - -function! tlib#agent#DeleteItems(world, selected) "{{{3 - let remove = copy(a:world.sel_idx) - let basepi = a:world.GetBaseIdx(a:world.prefidx) - if index(remove, basepi) == -1 - call add(remove, basepi) - endif - " call map(remove, 'a:world.GetBaseIdx(v:val)') - for idx in reverse(sort(remove)) - call remove(a:world.base, idx - 1) - endfor - let a:world.state = 'display' - call a:world.ResetSelected() - " let a:world.state = 'reset' - return a:world -endf - - -function! tlib#agent#Cut(world, selected) "{{{3 - let world = tlib#agent#Copy(a:world, a:selected) - return tlib#agent#DeleteItems(world, a:selected) -endf - - -function! tlib#agent#Copy(world, selected) "{{{3 - let a:world.clipboard = [] - let bidxs = copy(a:world.sel_idx) - call add(bidxs, a:world.GetBaseIdx(a:world.prefidx)) - for bidx in sort(bidxs) - call add(a:world.clipboard, a:world.GetBaseItem(bidx)) - endfor - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#Paste(world, selected) "{{{3 - if has_key(a:world, 'clipboard') - for e in reverse(copy(a:world.clipboard)) - call insert(a:world.base, e, a:world.prefidx) - endfor - endif - let a:world.state = 'display' - call a:world.ResetSelected() - return a:world -endf - - -function! tlib#agent#EditReturnValue(world, rv) "{{{3 - return [a:world.state !~ '\', a:world.base] -endf - - - -" Files related {{{1 - -function! tlib#agent#ViewFile(world, selected) "{{{3 - if !empty(a:selected) - let back = a:world.SwitchWindow('win') - " TLogVAR back - for filename in a:selected - call tlib#file#Edit(filename) - endfor - " if !&hidden && &l:modified - " let cmd0 = 'split' - " let cmd1 = 'sbuffer' - " else - " let cmd0 = 'edit' - " let cmd1 = 'buffer' - " endif - " call tlib#file#With(cmd0, cmd1, a:selected, a:world) - " TLogVAR &filetype - exec back - let a:world.state = 'display' - endif - return a:world -endf - - -function! tlib#agent#EditFile(world, selected) "{{{3 - return tlib#agent#Exit(tlib#agent#ViewFile(a:world, a:selected), a:selected) -endf - - -function! tlib#agent#EditFileInSplit(world, selected) "{{{3 - call a:world.CloseScratch() - " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) - " call tlib#file#With('split', 'sbuffer', a:selected[1:-1], a:world) - call tlib#file#With('split', 'sbuffer', a:selected, a:world) - return tlib#agent#Exit(a:world, a:selected) -endf - - -function! tlib#agent#EditFileInVSplit(world, selected) "{{{3 - call a:world.CloseScratch() - " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) - " call tlib#file#With('vertical split', 'vertical sbuffer', a:selected[1:-1], a:world) - let winpos = tlib#fixes#Winpos() - call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world) - if !empty(winpos) - exec winpos - endif - return tlib#agent#Exit(a:world, a:selected) -endf - - -function! tlib#agent#EditFileInTab(world, selected) "{{{3 - " TLogVAR a:selected - call a:world.CloseScratch() - call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world) - return tlib#agent#Exit(a:world, a:selected) -endf - - -function! tlib#agent#ToggleScrollbind(world, selected) "{{{3 - let a:world.scrollbind = get(a:world, 'scrollbind') ? 0 : 1 - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#ShowInfo(world, selected) - let lines = [] - for f in a:selected - if filereadable(f) - let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)] - call add(lines, fnamemodify(f, ':p')) - call add(lines, ' '. join(desc, '; ')) - endif - endfor - let a:world.temp_lines = lines - let a:world.state = 'printlines' - return a:world -endf - - - -" Buffer related {{{1 - -function! tlib#agent#PreviewLine(world, selected) "{{{3 - let l = a:selected[0] - let ww = winnr() - exec a:world.win_wnr .'wincmd w' - call tlib#buffer#ViewLine(l, 1) - exec ww .'wincmd w' - let a:world.state = 'redisplay' - return a:world -endf - - -" If not called from the scratch, we assume/guess that we don't have to -" suspend the input-evaluation loop. -function! tlib#agent#GotoLine(world, selected) "{{{3 - if !empty(a:selected) - - " let l = a:selected[0] - " " TLogVAR l - " let back = a:world.SwitchWindow('win') - " " TLogVAR back - " " if a:world.win_wnr != winnr() - " " let world = tlib#agent#Suspend(a:world, a:selected) - " " exec a:world.win_wnr .'wincmd w' - " " endif - " call tlib#buffer#ViewLine(l) - " exec back - " let a:world.state = 'display' - - let l = a:selected[0] - if a:world.win_wnr != winnr() - let world = tlib#agent#Suspend(a:world, a:selected) - exec a:world.win_wnr .'wincmd w' - endif - call tlib#buffer#ViewLine(l, 1) - - endif - return a:world -endf - - -function! tlib#agent#DoAtLine(world, selected) "{{{3 - if !empty(a:selected) - let cmd = input('Command: ', '', 'command') - if !empty(cmd) - call a:world.SwitchWindow('win') - " let pos = getpos('.') - let view = winsaveview() - for l in a:selected - call tlib#buffer#ViewLine(l, '') - exec cmd - endfor - " call setpos('.', pos) - call winrestview(view) - endif - endif - call a:world.ResetSelected() - let a:world.state = 'exit' - return a:world -endf - - -function! tlib#agent#Wildcard(world, selected) "{{{3 - if !empty(a:world.filter[0]) - let rx_type = a:world.matcher.FilterRxPrefix() - let flt0 = a:world.CleanFilter(a:world.filter[0][0]) - if rx_type == '\V' - let flt0 .= '\.\{-}' - else - let flt0 .= '.\{-}' - endif - call a:world.SetFrontFilter(flt0) - endif - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#Null(world, selected) "{{{3 - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#agent#ExecAgentByName(world, selected) "{{{3 - let s:agent_names_world = a:world - let agent_names = {'Help': 'tlib#agent#Help'} - for def in values(a:world.key_map[a:world.key_mode]) - if has_key(def, 'help') && !empty(def.help) && has_key(def, 'agent') && !empty(def.agent) - let agent_names[def.help] = def.agent - endif - endfor - let s:agent_names = sort(keys(agent_names)) - let command = input('Command: ', '', 'customlist,tlib#agent#CompleteAgentNames') - " TLogVAR command - if !has_key(agent_names, command) - " TLogVAR command - silent! let matches = filter(keys(agent_names), 'v:val =~ command') - " TLogVAR matches - if len(matches) == 1 - let command = matches[0] - endif - endif - if has_key(agent_names, command) - let agent = agent_names[command] - return call(agent, [a:world, a:selected]) - else - if !empty(command) - echohl WarningMsg - echom "Unknown command:" command - echohl NONE - sleep 1 - endif - let a:world.state = 'display' - return a:world - endif -endf - - -function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) - return filter(copy(s:agent_names), 'stridx(v:val, a:ArgLead) != -1') -endf - - -function! tlib#agent#Complete(world, selected) abort "{{{3 - let rxprefix = a:world.matcher.FilterRxPrefix() - let flt = a:world.filter[0][0] - " TLogVAR flt - let fltrx = rxprefix . flt . '\m[^[:space:][:cntrl:][:punct:]<>*+?&~{}()\[\]\\/]\+' - let fltrx0 = '\m^' . fltrx - " TLogVAR fltrx, fltrx0 - let words = {} - for item in a:world.list - let parts = split(item, '\ze'. fltrx) - " TLogVAR item, parts - for part in parts - let word = matchstr(part, fltrx0) - " TLogVAR part, word - if !empty(word) - let words[word] = 1 - endif - endfor - endfor - " TLogVAR keys(words) - let completions = keys(words) - " let completions = filter(keys(words), 'matchstr(v:val, fltrx0)') - let completions = sort(completions, 's:SortCompletions') - let completions = tlib#list#Uniq(completions) - " TLogVAR 0, completions - while len(completions) > 1 - let nchar = strwidth(completions[0]) - 1 - let completions = map(completions, 'strpart(v:val, 0, nchar)') - " TLogVAR 'reduce', completions - let completions = tlib#list#Uniq(completions) - " TLogVAR 'unique', len(completions), completions - endwh - " TLogVAR 9, completions - if empty(completions) - let a:world.state = 'redisplay update' - else - let a:world.filter[0][0] = completions[0] - let a:world.state = 'display update' - endif - return a:world -endf - - -function! s:SortCompletions(a, b) abort "{{{3 - let i1 = strwidth(a:a) - let i2 = strwidth(a:b) - return i2 - i1 -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/arg.vim b/sources_non_forked/tlib/autoload/tlib/arg.vim deleted file mode 100644 index 2e995146..00000000 --- a/sources_non_forked/tlib/autoload/tlib/arg.vim +++ /dev/null @@ -1,328 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-19. -" @Revision: 251 - - -" :def: function! tlib#arg#Get(n, var, ?default="", ?test='') -" Set a positional argument from a variable argument list. -" See tlib#string#RemoveBackslashes() for an example. -function! tlib#arg#Get(n, var, ...) "{{{3 - let default = a:0 >= 1 ? a:1 : '' - let atest = a:0 >= 2 ? a:2 : '' - " TLogVAR default, atest - if !empty(atest) - let atest = ' && (a:'. a:n .' '. atest .')' - endif - let test = printf('a:0 >= %d', a:n) . atest - return printf('let %s = %s ? a:%d : %s', a:var, test, a:n, string(default)) -endf - - -" :def: function! tlib#arg#Let(list, ?default='') -" Set a positional arguments from a variable argument list. -" See tlib#input#List() for an example. -function! tlib#arg#Let(list, ...) "{{{3 - let default = a:0 >= 1 ? a:1 : '' - let list = map(copy(a:list), 'type(v:val) == 3 ? v:val : [v:val, default]') - let args = map(range(1, len(list)), 'call("tlib#arg#Get", [v:val] + list[v:val - 1])') - return join(args, ' | ') -endf - - -" :def: function! tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':', ?booleans=0) -function! tlib#arg#StringAsKeyArgs(string, ...) "{{{1 - TVarArg ['keys', {}], ['evaluate', 0], ['sep', ':'], ['booleans', 0] - let keyargs = {} - let args = split(a:string, '\\\@= 0 - let keyargs['__posargs__'] = range(0, pos) - endif - return keyargs -endf - - -function! tlib#arg#StringAsKeyArgsEqual(string) "{{{1 - return tlib#arg#StringAsKeyArgs(a:string, [], 0, '=', 1) -endf - - -" :display: tlib#arg#GetOpts(args, ?def={}) -" Convert a list of strings of command-line arguments into a dictonary. -" -" The main use case is to pass [], i.e. the command-line -" arguments of a command as list, from a command definition to this -" function. -" -" Example: -" ['-h'] -" => If def contains a 'help' key, invoke |:help| on its value. -" -" ['-ab', '--foo', '--bar=BAR', 'bla', bla'] -" => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} -" -" ['-ab', '--', '--foo', '--bar=BAR'] -" => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} -function! tlib#arg#GetOpts(args, ...) abort "{{{3 - let throw = a:0 == 0 - TVarArg ['def', {}] - " TLogVAR def - let opts = {'__exit__': 0} - for [key, vdef] in items(get(def, 'values', {})) - if has_key(vdef, 'default') - let opts[key] = vdef.default - endif - endfor - let idx = 0 - for o in a:args - let [break, idx] = s:SetOpt(def, opts, idx, o) - if break == 1 - break - elseif break == 2 - if throw - throw 'tlib#arg#GetOpts: Show help' - else - let opts.__exit__ = 5 - endif - endif - endfor - let opts.__rest__ = a:args[idx : -1] - return opts -endf - - -function! s:GetValueType(def) abort "{{{3 - return get(a:def, 'type', type(get(a:def, 'default', ''))) -endf - - -function! s:SetOpt(def, opts, idx, opt) abort "{{{3 - " TLogVAR a:def - let idx = a:idx + 1 - let break = 0 - let long = get(a:def, 'long', 1) - let short = get(a:def, 'short', 1) - if (short && a:opt =~# '^-[?h]$') || (long && a:opt ==# '--help') - if has_key(a:def, 'help') - exec 'help' a:def.help - else - " TLogVAR a:def - let values = get(a:def, 'values', {}) - let flags = get(a:def, 'flags', {}) - if empty(values) && empty(flags) - echom 'No help' - else - if !empty(values) - echom 'Options:' - for [key, vdef] in sort(items(values)) - let opt = key - let default = get(vdef, 'default', '') - let type = s:GetValueType(vdef) - if default =~ '^-\?\d\+\%(\.\d\+\)$' - if type == -1 - let opt .= ' (flag)' - elseif type == 1 - let opt .= '=INT' - else - let opt .= '=INT or maybe BOOL' - endif - elseif type(default) == 1 - let opt .= '=STRING' - elseif type(default) == 3 - let opt .= '=COMMA-LIST' - endif - echom printf(' --%20s (default: %s)', opt, string(default)) - endfor - endif - if !empty(flags) - echom 'Short flags:' - for [sflag, lflag] in sort(items(flags)) - echom printf(' -%s -> %s', sflag, lflag) - endfor - endif - endif - endif - let break = 2 - elseif long && a:opt =~# '^--no-.\+' - let key = matchstr(a:opt, '^--no-\zs.\+$') - let a:opts[key] = s:Validate(a:def, key, 0) - elseif long && a:opt =~# '^--\w\+$' - let key = matchstr(a:opt, '^--\zs.\+$') - let a:opts[key] = s:Validate(a:def, key, 1) - elseif long && a:opt =~# '^--\w\+=' - let ml = matchlist(a:opt, '^--\(\w\+\)=\(.*\)$') - if empty(ml) - throw 'tlib#arg#GetOpts: Cannot parse: '. a:opt - else - let values = get(a:def, 'values', {}) - if has_key(values, ml[1]) - let vdef = values[ml[1]] - let type = s:GetValueType(vdef) - if type == -1 - let opt_value = !!str2nr(ml[2]) - elseif type == 0 - let opt_value = str2nr(ml[2]) - elseif type == 1 - let opt_value = ml[2] - elseif type == 2 - let opt_value = function(ml[2]) - elseif type == 3 - let opt_value = tlib#string#SplitCommaList(ml[2]) - elseif type == 4 - throw 'tlib#arg#GetOpts: Unsupported type conversion for '. ml[1] - elseif type == 5 - let opt_value = str2float(ml[2]) - endif - else - let opt_value = ml[2] - endif - let a:opts[ml[1]] = s:Validate(a:def, ml[1], opt_value) - unlet opt_value - endif - elseif short && a:opt =~# '^-\w=' - let flagdefs = get(a:def, 'flags', {}) - let flag = matchstr(a:opt, '^-\zs\w') - let rest = matchstr(a:opt, '^-\w\zs.*$') - call s:SetFlag(a:def, a:opts, idx, flag, rest, flagdefs) - elseif short && a:opt =~# '^-\w\+$' - let flagdefs = get(a:def, 'flags', {}) - for flag in split(substitute(a:opt, '^-', '', ''), '\zs') - call s:SetFlag(a:def, a:opts, idx, flag, '', flagdefs) - endfor - else - let break = 1 - if a:opt !=# '--' - let idx -= 1 - endif - endif - return [break, idx] -endf - - -function! s:SetFlag(def, opts, idx, flag, rest, flagdefs) abort "{{{3 - " TLogVAR a:def - if has_key(a:flagdefs, a:flag) - call s:SetOpt(a:def, a:opts, a:idx, a:flagdefs[a:flag] . a:rest) - else - let a:opts[a:flag] = s:Validate(a:def, a:flag, 1) - endif -endf - - -function! s:Validate(def, name, value) abort "{{{3 - let values = get(a:def, 'values', {}) - if has_key(values, a:name) - let vdef = values[a:name] - if has_key(vdef, 'validate') - if !call(vdef.validate, [a:value]) - throw printf('tlib#arg: %s has invalid value: %s', string(a:name), string(a:value)) - endif - endif - endif - return a:value -endf - - -":nodoc: -function! tlib#arg#CComplete(def, ArgLead) abort "{{{3 - let values = get(a:def, 'values', {}) - let opt = matchstr(a:ArgLead, '^--\zs\w\+\ze=') - if has_key(values, opt) - let words = [] - let vals = values[opt] - let complete_customlist = get(vals, 'complete_customlist', '') - if !empty(complete_customlist) - let words = eval(complete_customlist) - " else - " let complete = get(vals, 'complete', '') - " if !empty(complete) - " endif - endif - if !empty(words) - let lead = substitute(a:ArgLead, '^--\w\+=', '', '') - if !empty(lead) - let nchar = len(lead) - call filter(words, 'strpart(v:val, 0, nchar) ==# lead') - endif - let words = map(words, '"--". opt ."=". v:val') - return sort(words) - endif - endif - let cs = {'-h': 1, '--help': 1} - for [name, vdef] in items(values) - let type = s:GetValueType(vdef) - if type >= 0 - let name .= '=' - else - let cs['--no-'. name] = 1 - endif - let cs['--'. name] = 1 - endfor - for [name, subst] in items(get(a:def, 'flags', {})) - let ldef = get(values, substitute(subst, '^--', '', ''), {}) - let type = s:GetValueType(ldef) - if type >= 0 - let name .= '=' - endif - let cs['-'. name] = 1 - endfor - let nchar = len(a:ArgLead) - if nchar > 0 - call filter(cs, 'strpart(v:key, 0, nchar) ==# a:ArgLead') - endif - return sort(keys(cs)) -endf - - - -""" Command line {{{1 - -" :def: function! tlib#arg#Ex(arg, ?chars='%#! ') -" Escape some characters in a string. -" -" Use |fnamescape()| if available. -" -" EXAMPLES: > -" exec 'edit '. tlib#arg#Ex('foo%#bar.txt') -function! tlib#arg#Ex(arg, ...) "{{{3 - if exists('*fnameescape') && a:0 == 0 - return fnameescape(a:arg) - else - " let chars = '%# \' - let chars = '%#! ' - if a:0 >= 1 - let chars .= a:1 - endif - return escape(a:arg, chars) - endif -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/assert.vim b/sources_non_forked/tlib/autoload/tlib/assert.vim deleted file mode 100644 index dbf48369..00000000 --- a/sources_non_forked/tlib/autoload/tlib/assert.vim +++ /dev/null @@ -1,44 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: https://github.com/tomtom -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-23 -" @Revision: 38 - - -" Enable tracing via |:Tlibassert|. -function! tlib#assert#Enable() abort "{{{3 - " :nodoc: - command! -nargs=+ -bar Tlibassert call tlib#assert#Assert(expand(''), , []) -endf - - -" Disable tracing via |:Tlibassert|. -function! tlib#assert#Disable() abort "{{{3 - " :nodoc: - command! -nargs=+ -bang -bar Tlibassert : -endf - - -function! tlib#assert#Assert(caller, check, vals) abort "{{{3 - for val in a:vals - " TLogVAR val - if type(val) == 3 - call tlib#assert#Assert(a:caller, a:check, val) - elseif !val - throw 'Tlibassert: '. tlib#trace#Backtrace(a:caller) .': '. a:check - endif - endfor -endf - - -function! tlib#assert#Map(vals, expr) abort "{{{3 - return tlib#assert#All(map(a:vals, a:expr)) -endf - - -function! tlib#assert#All(vals) abort "{{{3 - " TLogVAR a:vals, empty(filter(a:vals, '!v:val')) - return empty(filter(a:vals, '!v:val')) -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim b/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim deleted file mode 100644 index 84395248..00000000 --- a/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim +++ /dev/null @@ -1,14 +0,0 @@ -" autocmdgroup.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 7 - -augroup TLib - autocmd! -augroup END - - -function! tlib#autocmdgroup#Init() "{{{3 -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/balloon.vim b/sources_non_forked/tlib/autoload/tlib/balloon.vim deleted file mode 100644 index 69675239..00000000 --- a/sources_non_forked/tlib/autoload/tlib/balloon.vim +++ /dev/null @@ -1,73 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @GIT: http://github.com/tomtom/tlib_vim/ -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2010-08-30. -" @Last Change: 2015-11-23. -" @Revision: 48 - - -function! tlib#balloon#Register(expr) "{{{3 - if !has('balloon_eval') - return - endif - if !exists('b:tlib_balloons') - let b:tlib_balloons = [] - endif - if !&ballooneval - setlocal ballooneval - endif - if &balloonexpr != 'tlib#balloon#Expr()' - if !empty(&balloonexpr) - call add(b:tlib_balloons, &balloonexpr) - endif - setlocal ballooneval balloonexpr=tlib#balloon#Expr() - endif - if index(b:tlib_balloons, a:expr) == -1 - call add(b:tlib_balloons, a:expr) - endif -endf - - -function! tlib#balloon#Remove(expr) "{{{3 - if exists('b:tlib_balloons') - call filter(b:tlib_balloons, 'v:val != a:expr') - if empty(b:tlib_balloons) - setlocal ballooneval& - setlocal balloonexpr& - unlet b:tlib_balloons - endif - endif -endf - - -function! tlib#balloon#Expr() "{{{3 - " TLogVAR exists('b:tlib_balloons') - if !exists('b:tlib_balloons') - return '' - endif - let text = map(copy(b:tlib_balloons), 'eval(v:val)') - " TLogVAR b:tlib_balloons, text - call filter(text, '!empty(v:val)') - if has('balloon_multiline') - return join(text, "\n----------------------------------\n") - else - return get(text, 0, '') - endif -endf - - -function! tlib#balloon#Expand(expr) abort "{{{3 - if v:beval_bufnr != bufnr('%') - " TLogVAR v:beval_bufnr, bufnr('%') - return '' - endif - let win = winsaveview() - try - call setpos('.', [v:beval_bufnr, v:beval_lnum, v:beval_col, 0]) - return expand(a:expr) - finally - call winrestview(win) - endtry -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/bitwise.vim b/sources_non_forked/tlib/autoload/tlib/bitwise.vim deleted file mode 100644 index 54a4258d..00000000 --- a/sources_non_forked/tlib/autoload/tlib/bitwise.vim +++ /dev/null @@ -1,141 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 124 - - -function! tlib#bitwise#Num2Bits(num) "{{{3 - if type(a:num) <= 1 || type(a:num) == 5 - let bits = reverse(tlib#number#ConvertBase(a:num, 2, 'list')) - elseif type(a:num) == 3 - let bits = copy(a:num) - else - throw "tlib#bitwise#Num2Bits: Must be number of list: ". string(a:num) - endif - return bits -endf - - -function! tlib#bitwise#Bits2Num(bits, ...) "{{{3 - let base = a:0 >= 1 ? a:1 : 10 - " TLogVAR a:bits - let num = 0.0 - for i in range(len(a:bits)) - if get(a:bits, i, 0) - let num += pow(2, i) - endif - endfor - " TLogVAR num - if base == 10 - if type(base) == 5 - return num - else - return float2nr(num) - endif - else - return tlib#number#ConvertBase(num, base) - endif -endf - - -function! tlib#bitwise#AND(num1, num2, ...) "{{{3 - let rtype = a:0 >= 1 ? a:1 : 'num' - return s:BitwiseComparison(a:num1, a:num2, rtype, - \ 'get(bits1, v:val) && get(bits2, v:val)') -endf - - -function! tlib#bitwise#OR(num1, num2, ...) "{{{3 - let rtype = a:0 >= 1 ? a:1 : 'num' - return s:BitwiseComparison(a:num1, a:num2, rtype, - \ 'get(bits1, v:val) || get(bits2, v:val)') -endf - - -function! tlib#bitwise#XOR(num1, num2, ...) "{{{3 - let rtype = a:0 >= 1 ? a:1 : 'num' - return s:BitwiseComparison(a:num1, a:num2, rtype, - \ 'get(bits1, v:val) ? !get(bits2, v:val) : get(bits2, v:val)') -endf - - -function! s:BitwiseComparison(num1, num2, rtype, expr) "{{{3 - let bits1 = tlib#bitwise#Num2Bits(a:num1) - let bits2 = tlib#bitwise#Num2Bits(a:num2) - let range = range(max([len(bits1), len(bits2)])) - let bits = map(range, a:expr) - if a:rtype == 'num' || (a:rtype == 'auto' && type(a:num1) <= 1) - return tlib#bitwise#Bits2Num(bits) - else - return bits - endif -endf - - -function! tlib#bitwise#ShiftRight(bits, n) "{{{3 - let bits = a:bits[a:n : -1] - if empty(bits) - let bits = [0] - endif - return bits -endf - - -function! tlib#bitwise#ShiftLeft(bits, n) "{{{3 - let bits = repeat([0], a:n) + a:bits - return bits -endf - - -function! tlib#bitwise#Add(num1, num2, ...) "{{{3 - let rtype = a:0 >= 1 ? a:1 : 'num' - let bits1 = tlib#bitwise#Num2Bits(a:num1) - let bits2 = tlib#bitwise#Num2Bits(a:num2) - let range = range(max([len(bits1), len(bits2)])) - " TLogVAR bits1, bits2, range - let carry = 0 - let bits = [] - for i in range - let sum = get(bits1, i) + get(bits2, i) + carry - if sum == 3 - let bit = 1 - let carry = 1 - elseif sum == 2 - let bit = 0 - let carry = 1 - elseif sum == 1 - let bit = 1 - let carry = 0 - elseif sum == 0 - let bit = 0 - let carry = 0 - endif - call add(bits, bit) - " TLogVAR i, bits, bit - endfor - if carry == 1 - call add(bits, carry) - endif - if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) - return tlib#bitwise#Bits2Num(bits) - else - return bits - endif -endf - - -function! tlib#bitwise#Sub(num1, num2, ...) "{{{3 - let rtype = a:0 >= 1 ? a:1 : 'num' - let bits1 = tlib#bitwise#Num2Bits(a:num1) - let bits2 = tlib#bitwise#Num2Bits(a:num2) - let range = range(max([len(bits1), len(bits2)])) - let bits2 = map(range, '!get(bits2, v:val)') - let bits2 = tlib#bitwise#Add(bits2, [1], 'bits') - let bits3 = tlib#bitwise#Add(bits1, bits2, 'bits') - let bits = bits3[0 : -2] - if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) - return tlib#bitwise#Bits2Num(bits) - else - return bits - endif -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/buffer.vim b/sources_non_forked/tlib/autoload/tlib/buffer.vim deleted file mode 100644 index 24e4e0a7..00000000 --- a/sources_non_forked/tlib/autoload/tlib/buffer.vim +++ /dev/null @@ -1,401 +0,0 @@ -" buffer.vim -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-06-30. -" @Last Change: 2015-11-06. -" @Revision: 7.1.352 - - -" Where to display the line when using |tlib#buffer#ViewLine|. -" For possible values for position see |scroll-cursor|. -TLet g:tlib_viewline_position = 'zz' - - -let s:bmru = [] - - -function! tlib#buffer#EnableMRU() "{{{3 - call tlib#autocmdgroup#Init() - autocmd TLib BufEnter * call s:BMRU_Push(bufnr('%')) -endf - - -function! tlib#buffer#DisableMRU() "{{{3 - call tlib#autocmdgroup#Init() - autocmd! TLib BufEnter -endf - - -function! s:BMRU_Push(bnr) "{{{3 - let i = index(s:bmru, a:bnr) - if i >= 0 - call remove(s:bmru, i) - endif - call insert(s:bmru, a:bnr) -endf - - -function! s:CompareBuffernameByBasename(a, b) "{{{3 - let rx = '"\zs.\{-}\ze" \+\S\+ \+\d\+$' - let an = matchstr(a:a, rx) - let an = fnamemodify(an, ':t') - let bn = matchstr(a:b, rx) - let bn = fnamemodify(bn, ':t') - let rv = an == bn ? 0 : an > bn ? 1 : -1 - return rv -endf - - -function! s:CompareBufferNrByMRU(a, b) "{{{3 - let an = matchstr(a:a, '\s*\zs\d\+\ze') - let bn = matchstr(a:b, '\s*\zs\d\+\ze') - let ai = index(s:bmru, 0 + an) - if ai == -1 - return 1 - else - let bi = index(s:bmru, 0 + bn) - if bi == -1 - return -1 - else - return ai == bi ? 0 : ai > bi ? 1 : -1 - endif - endif -endf - - -" Set the buffer to buffer and return a command as string that can be -" evaluated by |:execute| in order to restore the original view. -function! tlib#buffer#Set(buffer) "{{{3 - let lazyredraw = &lazyredraw - set lazyredraw - try - let cb = bufnr('%') - let sn = bufnr(a:buffer) - if sn != cb - let ws = bufwinnr(sn) - if ws != -1 - let wb = bufwinnr('%') - exec ws.'wincmd w' - return wb.'wincmd w' - else - silent exec 'sbuffer! '. sn - return 'wincmd c' - endif - else - return '' - endif - finally - let &lazyredraw = lazyredraw - endtry -endf - - -" :def: function! tlib#buffer#Eval(buffer, code) -" Evaluate CODE in BUFFER. -" -" EXAMPLES: > -" call tlib#buffer#Eval('foo.txt', 'echo b:bar') -function! tlib#buffer#Eval(buffer, code) "{{{3 - " let cb = bufnr('%') - " let wb = bufwinnr('%') - " " TLogVAR cb - " let sn = bufnr(a:buffer) - " let sb = sn != cb - let lazyredraw = &lazyredraw - set lazyredraw - let restore = tlib#buffer#Set(a:buffer) - try - exec a:code - " if sb - " let ws = bufwinnr(sn) - " if ws != -1 - " try - " exec ws.'wincmd w' - " exec a:code - " finally - " exec wb.'wincmd w' - " endtry - " else - " try - " silent exec 'sbuffer! '. sn - " exec a:code - " finally - " wincmd c - " endtry - " endif - " else - " exec a:code - " endif - finally - exec restore - let &lazyredraw = lazyredraw - endtry -endf - - -" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') -" Possible values for the "order" argument: -" bufnr :: Default behaviour -" mru :: Sort buffers according to most recent use -" basename :: Sort by the file's basename (last component) -" -" NOTE: MRU order works on second invocation only. If you want to always -" use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. -function! tlib#buffer#GetList(...) - TVarArg ['show_hidden', 0], ['show_number', 0], ['order', ''] - " TLogVAR show_hidden, show_number, order - let ls_bang = show_hidden ? '!' : '' - redir => bfs - exec 'silent ls'. ls_bang - redir END - let buffer_list = split(bfs, '\n') - if order == 'mru' - if empty(s:bmru) - call tlib#buffer#EnableMRU() - echom 'tlib: Installed Buffer MRU logger; disable with: call tlib#buffer#DisableMRU()' - else - call sort(buffer_list, function('s:CompareBufferNrByMRU')) - endif - elseif order == 'basename' - call sort(buffer_list, function('s:CompareBuffernameByBasename')) - endif - let buffer_nr = map(copy(buffer_list), 'str2nr(matchstr(v:val, ''\s*\zs\d\+\ze''))') - " TLogVAR buffer_list, buffer_nr - if show_number - call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+.\{-}\ze\s\+\S\+ \d\+\s*$'')') - else - call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+\zs.\{-}\ze\s\+\S\+ \d\+\s*$'')') - endif - " TLogVAR buffer_list - " call map(buffer_list, 'matchstr(v:val, ''^.\{-}\ze\s\+line \d\+\s*$'')') - " TLogVAR buffer_list - call map(buffer_list, 'matchstr(v:val, ''^[^"]\+''). printf("%-20s %s", fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":t"), fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":h"))') - " TLogVAR buffer_list - return [buffer_nr, buffer_list] -endf - - -" :def: function! tlib#buffer#ViewLine(line, ?position='z') -" line is either a number or a string that begins with a number. -" For possible values for position see |scroll-cursor|. -" See also |g:tlib_viewline_position|. -function! tlib#buffer#ViewLine(line, ...) "{{{3 - if a:line - TVarArg 'pos' - let ln = matchstr(a:line, '^\d\+') - let lt = matchstr(a:line, '^\d\+: \zs.*') - " TLogVAR pos, ln, lt - exec ln - if empty(pos) - let pos = tlib#var#Get('tlib_viewline_position', 'wbg') - endif - " TLogVAR pos - if !empty(pos) - exec 'norm! '. pos - endif - call tlib#buffer#HighlightLine(ln) - " let @/ = '\%'. ln .'l.*' - endif -endf - - -function! s:UndoHighlightLine() "{{{3 - 2match none - autocmd! TLib CursorMoved,CursorMovedI - autocmd! TLib CursorHold,CursorHoldI - autocmd! TLib InsertEnter,InsertChange,InsertLeave - autocmd! TLib BufLeave,BufWinLeave,WinLeave,BufHidden -endf - - -function! tlib#buffer#HighlightLine(...) "{{{3 - TVarArg ['line', line('.')] - " exec '2match MatchParen /^\%'. a:line .'l.*/' - exec '2match Search /^\%'. line .'l.*/' - call tlib#autocmdgroup#Init() - exec 'autocmd TLib CursorMoved,CursorMovedI if line(".") != '. line .' | call s:UndoHighlightLine() | endif' - autocmd TLib CursorHold,CursorHoldI call s:UndoHighlightLine() - autocmd TLib InsertEnter call s:UndoHighlightLine() - " autocmd TLib BufLeave,BufWinLeave,WinLeave,BufHidden call s:UndoHighlightLine() -endf - - -" Delete the lines in the current buffer. Wrapper for |:delete|. -function! tlib#buffer#DeleteRange(line1, line2) "{{{3 - let r = @t - try - exec a:line1.','.a:line2.'delete t' - finally - let @t = r - endtry -endf - - -" Replace a range of lines. -function! tlib#buffer#ReplaceRange(line1, line2, lines) - call tlib#buffer#DeleteRange(a:line1, a:line2) - call append(a:line1 - 1, a:lines) -endf - - -" Initialize some scratch area at the bottom of the current buffer. -function! tlib#buffer#ScratchStart() "{{{3 - norm! Go - let b:tlib_inbuffer_scratch = line('$') - return b:tlib_inbuffer_scratch -endf - - -" Remove the in-buffer scratch area. -function! tlib#buffer#ScratchEnd() "{{{3 - if !exists('b:tlib_inbuffer_scratch') - echoerr 'tlib: In-buffer scratch not initalized' - endif - call tlib#buffer#DeleteRange(b:tlib_inbuffer_scratch, line('$')) - unlet b:tlib_inbuffer_scratch -endf - - -" Run exec on all buffers via bufdo and return to the original buffer. -function! tlib#buffer#BufDo(exec) "{{{3 - let bn = bufnr('%') - exec 'bufdo '. a:exec - exec 'buffer! '. bn -endf - - -" :def: function! tlib#buffer#InsertText(text, keyargs) -" Keyargs: -" 'shift': 0|N -" 'col': col('.')|N -" 'lineno': line('.')|N -" 'indent': 0|1 -" 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) -" Insert text (a string) in the buffer. -function! tlib#buffer#InsertText(text, ...) "{{{3 - TVarArg ['keyargs', {}] - " TLogVAR a:text, keyargs - let keyargs = extend({ - \ 'shift': 0, 'col': col('.'), 'lineno': line('.'), 'pos': 'e', 'indent': 0 - \ }, keyargs) - " TLogVAR keyargs - let grow = 0 - let post_del_last_line = line('$') == 1 - let line = getline(keyargs.lineno) - if keyargs.col + keyargs.shift > 0 - let pre = line[0 : (keyargs.col - 1 + keyargs.shift)] - let post = line[(keyargs.col + keyargs.shift): -1] - else - let pre = '' - let post = line - endif - " TLogVAR keyargs.lineno, line, pre, post - let text0 = pre . a:text . post - let text = split(text0, '\n', 1) - " TLogVAR text - let icol = len(pre) - " exec 'norm! '. keyargs.lineno .'G' - call cursor(keyargs.lineno, keyargs.col) - if keyargs.indent && keyargs.col > 1 - if &fo =~# '[or]' - " FIXME: Is the simple version sufficient? - " VERSION 1 - " " This doesn't work because it's not guaranteed that the - " " cursor is set. - " let cline = getline('.') - " norm! a - " "norm! o - " " TAssertExec redraw | sleep 3 - " let idt = strpart(getline('.'), 0, keyargs.col('.') + keyargs.shift) - " " TLogVAR idt - " let idtl = len(idt) - " -1,.delete - " " TAssertExec redraw | sleep 3 - " call append(keyargs.lineno - 1, cline) - " call cursor(keyargs.lineno, keyargs.col) - " " TAssertExec redraw | sleep 3 - " if idtl == 0 && icol != 0 - " let idt = matchstr(pre, '^\s\+') - " let idtl = len(idt) - " endif - " VERSION 2 - let idt = matchstr(pre, '^\s\+') - let idtl = len(idt) - else - let [m_0, idt, iline; rest] = matchlist(pre, '^\(\s*\)\(.*\)$') - let idtl = len(idt) - endif - if idtl < icol - let idt .= repeat(' ', icol - idtl) - endif - " TLogVAR idt - let idtl1 = len(idt) - for i in range(1, len(text) - 1) - let text[i] = idt . text[i] - let grow += idtl1 - endfor - endif - " TLogVAR text - " exec 'norm! '. keyargs.lineno .'Gdd' - call tlib#normal#WithRegister('"tdd', 't') - call append(keyargs.lineno - 1, text) - if post_del_last_line - call tlib#buffer#KeepCursorPosition('$delete') - endif - let tlen = len(text) - let posshift = matchstr(keyargs.pos, '\d\+') - " TLogVAR keyargs.pos - if keyargs.pos =~ '^e' - exec keyargs.lineno + tlen - 1 - exec 'norm! 0'. (len(text[-1]) - len(post) + posshift - 1) .'l' - elseif keyargs.pos =~ '^s' - " TLogVAR keyargs.lineno, pre, posshift - exec keyargs.lineno - exec 'norm! '. len(pre) .'|' - if !empty(posshift) - exec 'norm! '. posshift .'h' - endif - endif - " TLogDBG getline(keyargs.lineno) - " TLogDBG string(getline(1, '$')) - return grow -endf - - -function! tlib#buffer#InsertText0(text, ...) "{{{3 - TVarArg ['keyargs', {}] - let mode = get(keyargs, 'mode', 'i') - " TLogVAR mode - if !has_key(keyargs, 'shift') - let col = col('.') - " if mode =~ 'i' - " let col += 1 - " endif - let keyargs.shift = col >= col('$') ? 0 : -1 - " let keyargs.shift = col('.') >= col('$') ? 0 : -1 - " TLogVAR col - " TLogDBG col('.') .'-'. col('$') .': '. string(getline('.')) - endif - " TLogVAR keyargs.shift - return tlib#buffer#InsertText(a:text, keyargs) -endf - - -function! tlib#buffer#CurrentByte() "{{{3 - return line2byte(line('.')) + col('.') -endf - - -" Evaluate cmd while maintaining the cursor position and jump registers. -function! tlib#buffer#KeepCursorPosition(cmd) "{{{3 - " let pos = getpos('.') - let view = winsaveview() - try - keepjumps exec a:cmd - finally - " call setpos('.', pos) - call winrestview(view) - endtry -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/cache.vim b/sources_non_forked/tlib/autoload/tlib/cache.vim deleted file mode 100644 index 7d2266fd..00000000 --- a/sources_non_forked/tlib/autoload/tlib/cache.vim +++ /dev/null @@ -1,356 +0,0 @@ -" cache.vim -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-06-30. -" @Last Change: 2015-10-24. -" @Revision: 31.1.243 - - -" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. -" You might want to delete old files from this directory from time to -" time with a command like: > -" find ~/vimfiles/cache/ -atime +31 -type f -print -delete -TLet g:tlib_cache = '' - -" |tlib#cache#Purge()|: Remove cache files older than N days. -TLet g:tlib#cache#purge_days = 31 - -" Purge the cache every N days. Disable automatic purging by setting -" this value to a negative value. -TLet g:tlib#cache#purge_every_days = 31 - -" The encoding used for the purge-cache script. -" Default: 'enc' -TLet g:tlib#cache#script_encoding = &enc - -" Whether to run the directory removal script: -" 0 ... No -" 1 ... Query user -" 2 ... Yes -TLet g:tlib#cache#run_script = 1 - -" Verbosity level: -" 0 ... Be quiet -" 1 ... Display informative message -" 2 ... Display detailed messages -TLet g:tlib#cache#verbosity = 1 - -" A list of regexps that are matched against partial filenames of the -" cached files. If a regexp matches, the file won't be removed by -" |tlib#cache#Purge()|. -TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$'] - -" If the cache filename is longer than N characters, use -" |pathshorten()|. -TLet g:tlib#cache#max_filename = 200 - -let s:cache = {} - - -" :display: tlib#cache#Dir(?mode = 'bg') -" The default cache directory. -function! tlib#cache#Dir(...) "{{{3 - TVarArg ['mode', 'bg'] - let dir = tlib#var#Get('tlib_cache', mode) - if empty(dir) - let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache']) - endif - return dir -endf - - -" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') -function! tlib#cache#Filename(type, ...) "{{{3 - " TLogDBG 'bufname='. bufname('.') - let dir0 = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir() - let dir = dir0 - if a:0 >= 1 && !empty(a:1) - let file = a:1 - else - if empty(expand('%:t')) - return '' - endif - let file = expand('%:p') - let file = tlib#file#Relative(file, tlib#file#Join([dir, '..'])) - endif - " TLogVAR file, dir - let mkdir = a:0 >= 2 ? a:2 : 0 - let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g') - let dirs = [dir, a:type] - let dirf = fnamemodify(file, ':h') - if dirf != '.' - call add(dirs, dirf) - endif - let dir = tlib#file#Join(dirs) - " TLogVAR dir - let dir = tlib#dir#PlainName(dir) - " TLogVAR dir - let file = fnamemodify(file, ':t') - " TLogVAR file, dir, mkdir - let cache_file = tlib#file#Join([dir, file]) - if len(cache_file) > g:tlib#cache#max_filename - if v:version >= 704 - let shortfilename = pathshorten(file) .'_'. sha256(file) - else - let shortfilename = pathshorten(file) .'_'. tlib#hash#Adler32(file) - endif - let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0) - else - if mkdir && !isdirectory(dir) - try - call mkdir(dir, 'p') - catch /^Vim\%((\a\+)\)\=:E739:/ - if filereadable(dir) && !isdirectory(dir) - echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir - " call delete(dir) - " call mkdir(dir, 'p') - endif - endtry - endif - endif - " TLogVAR cache_file - return cache_file -endf - - -let s:timestamps = {} - - -function! s:SetTimestamp(cfile, type) "{{{3 - if !has_key(s:timestamps, a:cfile) - let s:timestamps[a:cfile] = {} - endif - let s:timestamps[a:cfile].atime = getftime(a:cfile) - let s:timestamps[a:cfile][a:type] = s:timestamps[a:cfile].atime -endf - - -function! tlib#cache#Save(cfile, dictionary, ...) "{{{3 - TVarArg ['options', {}] - let in_memory = get(options, 'in_memory', 0) - if in_memory - " TLogVAR in_memory, a:cfile, localtime() - let s:cache[a:cfile] = {'mtime': localtime(), 'data': a:dictionary} - elseif !empty(a:cfile) - " TLogVAR a:dictionary - call writefile([string(a:dictionary)], a:cfile, 'b') - call s:SetTimestamp(a:cfile, 'write') - endif -endf - - -function! tlib#cache#MTime(cfile) "{{{3 - let mtime = {'mtime': getftime(a:cfile)} - let mtime = extend(mtime, get(s:timestamps, a:cfile, {})) - return mtime -endf - - -function! tlib#cache#Get(cfile, ...) "{{{3 - TVarArg ['default', {}], ['options', {}] - let in_memory = get(options, 'in_memory', 0) - if in_memory - " TLogVAR in_memory, a:cfile - return get(get(s:cache, a:cfile, {}), 'data', default) - else - call tlib#cache#MaybePurge() - if !empty(a:cfile) && filereadable(a:cfile) - let val = readfile(a:cfile, 'b') - call s:SetTimestamp(a:cfile, 'read') - return eval(join(val, "\n")) - else - return default - endif - endif -endf - - -" :display: tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) -" Get a cached value from cfile. If it is outdated (compared to ftime) -" or does not exist, create it calling a generator function. -function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3 - TVarArg ['args', []], ['options', {}] - let in_memory = get(options, 'in_memory', 0) - let not_found = in_memory ? !has_key(s:cache, a:cfile) : !filereadable(a:cfile) - " TLogVAR in_memory, not_found - let cftime = in_memory ? (not_found ? 0 : s:cache[a:cfile].mtime) : getftime(a:cfile) - if not_found || (a:ftime != 0 && cftime < a:ftime) - " TLogVAR a:generator, args - let val = call(a:generator, args) - " TLogVAR val - let cval = {'val': val} - " TLogVAR cval - call tlib#cache#Save(a:cfile, cval, options) - return val - else - let val = tlib#cache#Get(a:cfile, {}, options) - if !has_key(val, 'val') - throw 'tlib#cache#Value: Internal error: '. a:cfile - else - return val.val - endif - endif -endf - - -" Call |tlib#cache#Purge()| if the last purge was done before -" |g:tlib#cache#purge_every_days|. -function! tlib#cache#MaybePurge() "{{{3 - if g:tlib#cache#purge_every_days < 0 - return - endif - let dir = tlib#cache#Dir('g') - let last_purge = tlib#file#Join([dir, '.last_purge']) - let last_purge_exists = filereadable(last_purge) - if last_purge_exists - let threshold = localtime() - g:tlib#cache#purge_every_days * g:tlib#date#dayshift - let should_purge = getftime(last_purge) < threshold - else - let should_purge = 0 " should ignore empty dirs, like the tmru one: !empty(glob(tlib#file#Join([dir, '**']))) - endif - if should_purge - if last_purge_exists - let yn = 'y' - else - let txt = "TLib: The cache directory '". dir ."' should be purged of old files.\nDelete files older than ". g:tlib#cache#purge_days ." days now?" - let yn = tlib#input#Dialog(txt, ['yes', 'no'], 'no') - endif - if yn =~ '^y\%[es]$' - call tlib#cache#Purge() - else - let g:tlib#cache#purge_every_days = -1 - if !last_purge_exists - call s:PurgeTimestamp(dir) - endif - echohl WarningMsg - echom "TLib: Please run :call tlib#cache#Purge() to clean up ". dir - echohl NONE - endif - elseif !last_purge_exists - call s:PurgeTimestamp(dir) - endif -endf - - -" Delete old files. -function! tlib#cache#Purge() "{{{3 - let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift - let dir = tlib#cache#Dir('g') - if g:tlib#cache#verbosity >= 1 - echohl WarningMsg - echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir - echohl NONE - endif - let files = tlib#cache#ListFilesInCache() - let deldir = [] - let newer = [] - let msg = [] - let more = &more - set nomore - try - for file in files - if isdirectory(file) - if empty(filter(copy(newer), 'strpart(v:val, 0, len(file)) ==# file')) - call add(deldir, file) - endif - else - if getftime(file) < threshold - if delete(file) - call add(msg, "TLib: Could not delete cache file: ". file) - elseif g:tlib#cache#verbosity >= 2 - call add(msg, "TLib: Delete cache file: ". file) - endif - else - call add(newer, file) - endif - endif - endfor - finally - let &more = more - endtry - if !empty(msg) && g:tlib#cache#verbosity >= 1 - echo join(msg, "\n") - endif - if !empty(deldir) - if &shell =~ 'sh\(\.exe\)\?$' - let scriptfile = 'deldir.sh' - let rmdir = 'rm -rf %s' - else - let scriptfile = 'deldir.bat' - let rmdir = 'rmdir /S /Q %s' - endif - let enc = g:tlib#cache#script_encoding - if has('multi_byte') && enc != &enc - call map(deldir, 'iconv(v:val, &enc, enc)') - endif - let scriptfile = tlib#file#Join([dir, scriptfile]) - if filereadable(scriptfile) - let script = readfile(scriptfile) - else - let script = [] - endif - let script += map(copy(deldir), 'printf(rmdir, shellescape(v:val, 1))') - let script = tlib#list#Uniq(script) - call writefile(script, scriptfile) - call inputsave() - if g:tlib#cache#run_script == 0 - if g:tlib#cache#verbosity >= 1 - echohl WarningMsg - if g:tlib#cache#verbosity >= 2 - echom "TLib: Purged cache. Need to run script to delete directories" - endif - echom "TLib: Please review and execute: ". scriptfile - echohl NONE - endif - else - try - let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no') - if yn =~ '^y\%[es]$' - exec 'cd '. fnameescape(dir) - exec '! ' &shell shellescape(scriptfile, 1) - exec 'cd -' - call delete(scriptfile) - elseif yn =~ '^e\%[dit]$' - exec 'edit '. fnameescape(scriptfile) - endif - finally - call inputrestore() - endtry - endif - endif - call s:PurgeTimestamp(dir) -endf - - -function! s:PurgeTimestamp(dir) "{{{3 - let last_purge = tlib#file#Join([a:dir, '.last_purge']) - " TLogVAR last_purge - call writefile([" "], last_purge) -endf - -function! tlib#cache#ListFilesInCache(...) "{{{3 - let dir = a:0 >= 1 ? a:1 : tlib#cache#Dir('g') - if v:version > 702 || (v:version == 702 && has('patch51')) - let filess = glob(tlib#file#Join([dir, '**']), 1) - else - let filess = glob(tlib#file#Join([dir, '**'])) - endif - let files = reverse(split(filess, '\n')) - let pos0 = len(tlib#dir#CanonicName(dir)) - call filter(files, 's:ShouldPurge(strpart(v:val, pos0))') - return files -endf - - -function! s:ShouldPurge(partial_filename) "{{{3 - " TLogVAR a:partial_filename - for rx in g:tlib#cache#dont_purge - if a:partial_filename =~ rx - " TLogVAR a:partial_filename, rx - return 0 - endif - endfor - return 1 -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/char.vim b/sources_non_forked/tlib/autoload/tlib/char.vim deleted file mode 100644 index d3d2cb6f..00000000 --- a/sources_non_forked/tlib/autoload/tlib/char.vim +++ /dev/null @@ -1,59 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 38 - - -" :def: function! tlib#char#Get(?timeout=0) -" Get a character. -" -" EXAMPLES: > -" echo tlib#char#Get() -" echo tlib#char#Get(5) -function! tlib#char#Get(...) "{{{3 - TVarArg ['timeout', 0], ['resolution', 0], ['getmod', 0] - let char = -1 - let mode = 0 - if timeout == 0 || !has('reltime') - let char = getchar() - else - let char = tlib#char#GetWithTimeout(timeout, resolution) - endif - if getmod - if char != -1 - let mode = getcharmod() - endif - return [char, mode] - else - return char - endif -endf - - -function! tlib#char#IsAvailable() "{{{3 - let ch = getchar(1) - return type(ch) == 0 && ch != 0 -endf - - -function! tlib#char#GetWithTimeout(timeout, ...) "{{{3 - TVarArg ['resolution', 2] - " TLogVAR a:timeout, resolution - let start = tlib#time#MSecs() - while 1 - let c = getchar(0) - if type(c) != 0 || c != 0 - return c - else - let now = tlib#time#MSecs() - let diff = tlib#time#DiffMSecs(now, start, resolution) - " TLogVAR diff - if diff > a:timeout - return -1 - endif - endif - endwh - return -1 -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/cmd.vim b/sources_non_forked/tlib/autoload/tlib/cmd.vim deleted file mode 100644 index f65a2372..00000000 --- a/sources_non_forked/tlib/autoload/tlib/cmd.vim +++ /dev/null @@ -1,117 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 58 - - -let g:tlib#cmd#last_output = [] - - -function! tlib#cmd#OutputAsList(command) "{{{3 - " TLogVAR a:command - if exists('s:redir_lines') - redir END - let cache = s:redir_lines - endif - let s:redir_lines = '' - redir =>> s:redir_lines - silent! exec a:command - redir END - let g:tlib#cmd#last_output = split(s:redir_lines, '\n') - unlet s:redir_lines - if exists('cache') - let s:redir_lines = cache - redir =>> s:redir_lines - endif - return g:tlib#cmd#last_output -endf - - -" See |:TBrowseOutput|. -function! tlib#cmd#BrowseOutput(command) "{{{3 - call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#DefaultBrowseOutput", a:command) -endf - -" :def: function! tlib#cmd#BrowseOutputWithCallback(callback, command) -" Execute COMMAND and present its output in a |tlib#input#List()|; -" when a line is selected, execute the function named as the CALLBACK -" and pass in that line as an argument. -" -" The CALLBACK function gives you an opportunity to massage the COMMAND output -" and possibly act on it in a meaningful way. For example, if COMMAND listed -" all URIs found in the current buffer, CALLBACK could validate and then open -" the selected URI in the system's default browser. -" -" This function is meant to be a tool to help compose the implementations of -" powerful commands that use |tlib#input#List()| as a common interface. See -" |TBrowseScriptnames| as an example. -" -" EXAMPLES: > -" call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') -function! tlib#cmd#BrowseOutputWithCallback(callback, command) "{{{3 - let list = tlib#cmd#OutputAsList(a:command) - let cmds = tlib#input#List('m', 'Output of: '. a:command, list) - if !empty(cmds) - for cmd in cmds - let Callback = function(a:callback) - call call(Callback, [cmd]) - endfor - endif -endf - -function! tlib#cmd#DefaultBrowseOutput(cmd) "{{{3 - call feedkeys(':'. a:cmd) -endf - -function! tlib#cmd#ParseScriptname(line) "{{{3 - " let parsedValue = substitute(a:line, '^.\{-}\/', '/', '') - let parsedValue = matchstr(a:line, '^\s*\d\+:\s*\zs.*$') - exe 'drop '. fnameescape(parsedValue) -endf - - -function! tlib#cmd#TBrowseScriptnames() abort "{{{3 - call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#ParseScriptname", "scriptnames") -endf - - -" :def: function! tlib#cmd#UseVertical(?rx='') -" Look at the history whether the command was called with vertical. If -" an rx is provided check first if the last entry in the history matches -" this rx. -function! tlib#cmd#UseVertical(...) "{{{3 - TVarArg ['rx'] - let h0 = histget(':') - let rx0 = '\C\\s\+' - if !empty(rx) - let rx0 .= '.\{-}'.rx - endif - " TLogVAR h0, rx0 - return h0 =~ rx0 -endf - - -" Print the time in seconds or milliseconds (if your version of VIM -" has |+reltime|) a command takes. -function! tlib#cmd#Time(cmd) "{{{3 - if has('reltime') - let start = tlib#time#Now() - exec a:cmd - let end = tlib#time#Now() - let diff = string(tlib#time#Diff(end, start)) .'ms' - else - let start = localtime() - exec a:cmd - let diff = (localtime() - start) .'s' - endif - echom 'Time: '. diff .': '. a:cmd -endf - - -function! tlib#cmd#Capture(cmd) "{{{3 - redir => s - silent exec a:cmd - redir END - return s -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/comments.vim b/sources_non_forked/tlib/autoload/tlib/comments.vim deleted file mode 100644 index 879cde17..00000000 --- a/sources_non_forked/tlib/autoload/tlib/comments.vim +++ /dev/null @@ -1,26 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 25 - - -" function! tlib#comments#Comments(?rx='') -function! tlib#comments#Comments(...) - TVarArg ['rx', ''] - let comments = {} - let co = &comments - while !empty(co) - " TLogVAR co - let [m_0, m_key, m_val, m_val1, co0, co; rest] = matchlist(co, '^\([^:]*\):\(\(\\.\|[^,]*\)\+\)\(,\(.*\)$\|$\)') - " TLogVAR m_key, m_val, co - if empty(m_key) - let m_key = ':' - endif - if empty(rx) || m_key =~ rx - let comments[m_key] = m_val - endif - endwh - return comments -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/date.vim b/sources_non_forked/tlib/autoload/tlib/date.vim deleted file mode 100644 index 7be5e9fb..00000000 --- a/sources_non_forked/tlib/autoload/tlib/date.vim +++ /dev/null @@ -1,163 +0,0 @@ -" date.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2010-03-25. -" @Last Change: 2015-11-23. -" @Revision: 21.0.34 - - -if !exists('g:tlib#date#ShortDatePrefix') | let g:tlib#date#ShortDatePrefix = '20' | endif "{{{2 -if !exists('g:tlib#date#TimeZoneShift') | let g:tlib#date#TimeZoneShift = 0 | endif "{{{2 - -let g:tlib#date#dayshift = 60 * 60 * 24 -" let g:tlib#date#date_rx = '\<\(\d\{4}\)-\(\d\d\)-\(\d\d\)\%(\s\+\(\(\d\d\):\(\d\d\)\)\)\?\>' -let g:tlib#date#date_rx = '\<\(\d\{4}\)-\(\d\d\)-\(\d\d\)\>' -let g:tlib#date#date_format = '%Y-%m-%d' - - -function! tlib#date#IsDate(text) abort "{{{3 - return a:text =~# '^'. g:tlib#date#date_rx .'$' -endf - - -function! tlib#date#Format(secs1970) abort "{{{3 - return strftime(g:tlib#date#date_format, a:secs1970) -endf - - -" :display: tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) -function! tlib#date#DiffInDays(date, ...) - let allow_zero = a:0 >= 2 ? a:2 : 0 - let s0 = tlib#date#SecondsSince1970(a:date, 0, allow_zero) - let s1 = a:0 >= 1 ? tlib#date#SecondsSince1970(a:1, 0, allow_zero) : localtime() - let dd = (s0 - s1) / g:tlib#date#dayshift - " TLogVAR dd - return dd -endf - - -" :display: tlib#date#Parse(date, ?allow_zero=0) "{{{3 -function! tlib#date#Parse(date, ...) "{{{3 - let min = a:0 >= 1 && a:1 ? 0 : 1 - " TLogVAR a:date, min - let m = matchlist(a:date, '^\(\d\{2}\|\d\{4}\)-\(\d\{1,2}\)-\(\d\{1,2}\)$') - if !empty(m) - let year = m[1] - let month = m[2] - let days = m[3] - else - let m = matchlist(a:date, '^\(\d\+\)/\(\d\{1,2}\)/\(\d\{1,2}\)$') - if !empty(m) - let year = m[1] - let month = m[3] - let days = m[2] - else - let m = matchlist(a:date, '^\(\d\{1,2}\)\.\s*\(\d\{1,2}\)\.\s*\(\d\d\{2}\|\d\{4}\)$') - if !empty(m) - let year = m[3] - let month = m[2] - let days = m[1] - endif - endif - endif - if empty(m) || year == '' || month == '' || days == '' || - \ month < min || month > 12 || days < min || days > 31 - echoerr 'TLib: Invalid date: '. a:date - return [] - endif - if strlen(year) == 2 - let year = g:tlib#date#ShortDatePrefix . year - endif - return [0 + year, 0 + month, 0 + days] -endf - - -" tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) -function! tlib#date#SecondsSince1970(date, ...) "{{{3 - let allow_zero = a:0 >= 2 ? a:2 : 0 - " TLogVAR a:date, allow_zero - let date = tlib#date#Parse(a:date, allow_zero) - if empty(date) - return 0 - endif - let [year, month, days] = date - if a:0 >= 1 && a:1 > 0 - let days = days + a:1 - end - let days_passed = days - let i = 1970 - while i < year - let days_passed = days_passed + 365 - if i % 4 == 0 || i == 2000 - let days_passed = days_passed + 1 - endif - let i = i + 1 - endwh - let i = 1 - while i < month - if i == 1 - let days_passed = days_passed + 31 - elseif i == 2 - let days_passed = days_passed + 28 - if year % 4 == 0 || year == 2000 - let days_passed = days_passed + 1 - endif - elseif i == 3 - let days_passed = days_passed + 31 - elseif i == 4 - let days_passed = days_passed + 30 - elseif i == 5 - let days_passed = days_passed + 31 - elseif i == 6 - let days_passed = days_passed + 30 - elseif i == 7 - let days_passed = days_passed + 31 - elseif i == 8 - let days_passed = days_passed + 31 - elseif i == 9 - let days_passed = days_passed + 30 - elseif i == 10 - let days_passed = days_passed + 31 - elseif i == 11 - let days_passed = days_passed + 30 - endif - let i = i + 1 - endwh - let seconds = (days_passed - 1) * 24 * 60 * 60 - let seconds = seconds + (strftime('%H') + g:tlib#date#TimeZoneShift) * 60 * 60 - let seconds = seconds + strftime('%M') * 60 - let seconds = seconds + strftime('%S') - return seconds -endf - - -function! tlib#date#Shift(date, shift) abort "{{{3 - let n = str2nr(matchstr(a:shift, '\d\+')) - let ml = matchlist(a:date, g:tlib#date#date_rx) - " TLogVAR a:date, a:shift, n, ml - if a:shift =~ 'd$' - let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * n - " TLogVAR secs - let date = tlib#date#Format(secs) - elseif a:shift =~ 'w$' - let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * n * 7 - let date = tlib#date#Format(secs) - elseif a:shift =~ 'm$' - let d = str2nr(ml[3]) - let ms = str2nr(ml[2]) + n - let m = (ms - 1) % 12 + 1 - let yr = str2nr(ml[1]) + ms / 12 - let date = printf('%04d-%02d-%02d', yr, m, d) - " TLogVAR d, ms, m, yr, date - elseif a:shift =~ 'y$' - let yr = str2nr(ml[1]) + n - let date = substitute(a:date, '^\d\{4}', yr, '') - endif - " if !empty(ml[4]) && date !~ '\s'. ml[4] .'$' - " let date .= ' '. ml[4] - " endif - " TLogVAR date - return date -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/dictionary.vim b/sources_non_forked/tlib/autoload/tlib/dictionary.vim deleted file mode 100644 index 77712b03..00000000 --- a/sources_non_forked/tlib/autoload/tlib/dictionary.vim +++ /dev/null @@ -1,15 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: https://github.com/tomtom -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-10-14 -" @Revision: 2 - - -function! tlib#dictionary#Rev(dict) abort "{{{3 - let rev = {} - for [m, f] in items(a:dict) - let rev[f] = m - endfor - return rev -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/dir.vim b/sources_non_forked/tlib/autoload/tlib/dir.vim deleted file mode 100644 index f6f3e4e9..00000000 --- a/sources_non_forked/tlib/autoload/tlib/dir.vim +++ /dev/null @@ -1,93 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 40 - -" TLet g:tlib#dir#sep = '/' -TLet g:tlib#dir#sep = exists('+shellslash') && !&shellslash ? '\' : '/' - - -let s:dir_stack = [] - -" EXAMPLES: > -" tlib#dir#CanonicName('foo/bar') -" => 'foo/bar/' -function! tlib#dir#CanonicName(dirname) "{{{3 - let dirname = tlib#file#Canonic(a:dirname) - if dirname !~ '[/\\]$' - return dirname . g:tlib#dir#sep - endif - return dirname -endf - - -" EXAMPLES: > -" tlib#dir#NativeName('foo/bar/') -" On Windows: -" => 'foo\bar\' -" On Linux: -" => 'foo/bar/' -function! tlib#dir#NativeName(dirname) "{{{3 - let sep = tlib#rx#EscapeReplace(g:tlib#dir#sep) - let dirname = substitute(a:dirname, '[\/]', sep, 'g') - return dirname -endf - - -" EXAMPLES: > -" tlib#dir#PlainName('foo/bar/') -" => 'foo/bar' -function! tlib#dir#PlainName(dirname) "{{{3 - let dirname = a:dirname - while index(['/', '\'], dirname[-1 : -1]) != -1 - let dirname = dirname[0 : -2] - endwh - return dirname - " return substitute(a:dirname, tlib#rx#Escape(g:tlib#dir#sep).'\+$', '', '') -endf - - -" Create a directory if it doesn't already exist. -function! tlib#dir#Ensure(dir) "{{{3 - if !isdirectory(a:dir) - let dir = tlib#dir#PlainName(a:dir) - return mkdir(dir, 'p') - endif - return 1 -endf - - -" Return the first directory in &rtp. -function! tlib#dir#MyRuntime() "{{{3 - return get(split(&rtp, ','), 0) -endf - - -" :def: function! tlib#dir#CD(dir, ?locally=0) => CWD -function! tlib#dir#CD(dir, ...) "{{{3 - TVarArg ['locally', 0] - let cmd = locally ? 'lcd! ' : 'cd! ' - " let cwd = getcwd() - let cmd .= tlib#arg#Ex(a:dir) - " TLogVAR a:dir, locally, cmd - exec cmd - " return cwd - return getcwd() -endf - - -" :def: function! tlib#dir#Push(dir, ?locally=0) => CWD -function! tlib#dir#Push(dir, ...) "{{{3 - TVarArg ['locally', 0] - call add(s:dir_stack, [getcwd(), locally]) - return tlib#dir#CD(a:dir, locally) -endf - - -" :def: function! tlib#dir#Pop() => CWD -function! tlib#dir#Pop() "{{{3 - let [dir, locally] = remove(s:dir_stack, -1) - return tlib#dir#CD(dir, locally) -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/eval.vim b/sources_non_forked/tlib/autoload/tlib/eval.vim deleted file mode 100644 index 117209ed..00000000 --- a/sources_non_forked/tlib/autoload/tlib/eval.vim +++ /dev/null @@ -1,72 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 56 - - -function! tlib#eval#FormatValue(value, ...) "{{{3 - TVarArg ['indent', 0] - " TLogVAR a:value, indent - let indent1 = indent + 1 - let indenti = repeat(' ', &sw) - let type = type(a:value) - let acc = [] - if type == 0 || type == 1 || type == 2 - " TLogDBG 'Use string() for type='. type - call add(acc, string(a:value)) - elseif type == 3 "List - " TLogDBG 'List' - call add(acc, '[') - for e in a:value - call add(acc, printf('%s%s,', indenti, tlib#eval#FormatValue(e, indent1))) - unlet e - endfor - call add(acc, ']') - elseif type == 4 "Dictionary - " TLogDBG 'Dictionary' - call add(acc, '{') - let indent1 = indent + 1 - for [k, v] in items(a:value) - call add(acc, printf("%s%s: %s,", indenti, string(k), tlib#eval#FormatValue(v, indent1))) - unlet k v - endfor - call add(acc, '}') - else - " TLogDBG 'Unknown type: '. string(a:value) - call add(acc, string(a:value)) - endif - if indent > 0 - let is = repeat(' ', indent * &sw) - for i in range(1,len(acc) - 1) - let acc[i] = is . acc[i] - endfor - endif - return join(acc, "\n") -endf - - -function! tlib#eval#Extend(a, b, ...) abort "{{{3 - let mode = a:0 >= 1 ? a:1 : 'force' - if type(a:a) != type(a:b) - throw 'tlib#eval#Extend: Incompatible types: a='. string(a:a) .' b='. string(a:b) - elseif type(a:a) == 3 " list - return extend(a:a, a:b, mode) - elseif type(a:a) == 4 " dict - for k in keys(a:b) - if has_key(a:a, k) - if mode == 'force' - let a:a[k] = tlib#eval#Extend(copy(a:a[k]), a:b[k], mode) - elseif mode == 'error' - throw 'tlib#eval#Extend: Key already exists: '. k - endif - else - let a:a[k] = a:b[k] - endif - unlet! k - endfor - return a:a - else - return a:b - endif -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/file.vim b/sources_non_forked/tlib/autoload/tlib/file.vim deleted file mode 100644 index d0f89b96..00000000 --- a/sources_non_forked/tlib/autoload/tlib/file.vim +++ /dev/null @@ -1,278 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 168 - - -if !exists('g:tlib#file#drop') - " If true, use |:drop| to edit loaded buffers (only available with GUI). - let g:tlib#file#drop = has('gui') "{{{2 -endif - - -if !exists('g:tlib#file#use_tabs') - let g:tlib#file#use_tabs = 0 "{{{2 -endif - - -if !exists('g:tlib#file#edit_cmds') - let g:tlib#file#edit_cmds = g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {} "{{{2 -endif - - -if !exists('g:tlib#file#absolute_filename_rx') - let g:tlib#file#absolute_filename_rx = '^\~\?[\/]' "{{{2 -endif - -""" File related {{{1 -" For the following functions please see ../../test/tlib.vim for examples. - - -" EXAMPLES: > -" tlib#file#Split('foo/bar/filename.txt') -" => ['foo', 'bar', 'filename.txt'] -function! tlib#file#Split(filename) "{{{3 - let prefix = matchstr(a:filename, '^\(\w\+:\)\?/\+') - " TLogVAR prefix - if !empty(prefix) - let filename = a:filename[len(prefix) : -1] - else - let filename = a:filename - endif - let rv = split(filename, '[\/]') - " let rv = split(filename, '[\/]', 1) - if !empty(prefix) - call insert(rv, prefix[0:-2]) - endif - return rv -endf - - -" :display: tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) -" EXAMPLES: > -" tlib#file#Join(['foo', 'bar', 'filename.txt']) -" => 'foo/bar/filename.txt' -function! tlib#file#Join(filename_parts, ...) "{{{3 - TVarArg ['strip_slashes', 1], 'maybe_absolute' - " TLogVAR a:filename_parts, strip_slashes - if maybe_absolute - let filename_parts = [] - for part in a:filename_parts - if part =~ g:tlib#file#absolute_filename_rx - let filename_parts = [] - endif - call add(filename_parts, part) - endfor - else - let filename_parts = a:filename_parts - endif - if strip_slashes - " let rx = tlib#rx#Escape(g:tlib#dir#sep) .'$' - let rx = '[/\\]\+$' - let parts = map(copy(filename_parts), 'substitute(v:val, rx, "", "")') - " TLogVAR parts - return join(parts, g:tlib#dir#sep) - else - return join(filename_parts, g:tlib#dir#sep) - endif -endf - - -" EXAMPLES: > -" tlib#file#Relative('foo/bar/filename.txt', 'foo') -" => 'bar/filename.txt' -function! tlib#file#Relative(filename, basedir) "{{{3 - " TLogVAR a:filename, a:basedir - " TLogDBG getcwd() - " TLogDBG expand('%:p') - let b0 = tlib#file#Absolute(a:basedir) - let b = tlib#file#Split(b0) - " TLogVAR b - let f0 = tlib#file#Absolute(a:filename) - let fn = fnamemodify(f0, ':t') - let fd = fnamemodify(f0, ':h') - let f = tlib#file#Split(fd) - " TLogVAR f0, fn, fd, f - if f[0] != b[0] - let rv = f0 - else - while !empty(f) && !empty(b) - if f[0] != b[0] - break - endif - call remove(f, 0) - call remove(b, 0) - endwh - " TLogVAR f, b - let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn]) - endif - " TLogVAR rv - return rv -endf - - -function! tlib#file#Absolute(filename, ...) "{{{3 - if filereadable(a:filename) - let filename = fnamemodify(a:filename, ':p') - elseif a:filename =~ '^\(/\|[^\/]\+:\)' - let filename = a:filename - else - let cwd = a:0 >= 1 ? a:1 : getcwd() - let filename = tlib#file#Join([cwd, a:filename]) - endif - let filename = substitute(filename, '\(^\|[\/]\)\zs\.[\/]', '', 'g') - let filename = substitute(filename, '[\/]\zs[^\/]\+[\/]\.\.[\/]', '', 'g') - return filename -endf - - -function! tlib#file#Canonic(filename, ...) "{{{3 - TVarArg ['mode', ''] - if a:filename =~ '^\\\\' - let mode = 'windows' - elseif a:filename =~ '^\(file\|ftp\|http\)s\?:' - let mode = 'url' - elseif (empty(mode) && g:tlib#sys#windows) - let mode = 'windows' - endif - let filename = a:filename - if mode == 'windows' - let filename = substitute(filename, '/', '\\', 'g') - else - let filename = substitute(filename, '\\', '/', 'g') - endif - return filename -endf - - -function! s:SetScrollBind(world) "{{{3 - let sb = get(a:world, 'scrollbind', &scrollbind) - if sb != &scrollbind - let &scrollbind = sb - endif -endf - - -" :def: function! tlib#file#With(fcmd, bcmd, files, ?world={}) -function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3 - " TLogVAR a:fcmd, a:bcmd, a:files - exec tlib#arg#Let([['world', {}]]) - call tlib#autocmdgroup#Init() - augroup TLibFileRead - autocmd! - augroup END - for f in a:files - let bn = bufnr('^'.f.'$') - " TLogVAR f, bn - let bufloaded = bufloaded(bn) - let ok = 0 - let s:bufread = "" - if bn != -1 && buflisted(bn) - if !empty(a:bcmd) - " TLogDBG a:bcmd .' '. bn - exec a:bcmd .' '. bn - let ok = 1 - call s:SetScrollBind(world) - endif - else - if filereadable(f) - if !empty(a:fcmd) - " TLogDBG a:fcmd .' '. tlib#arg#Ex(f) - exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand(":p")' - try - exec a:fcmd .' '. tlib#arg#Ex(f) - finally - exec 'autocmd! TLibFileRead BufRead' - endtry - let ok = 1 - call s:SetScrollBind(world) - endif - else - echohl error - echom 'File not readable: '. f - echohl NONE - endif - endif - " TLogVAR ok, bufloaded, &filetype - if empty(s:bufread) && ok && !bufloaded && empty(&filetype) - doautocmd BufRead - endif - endfor - augroup! TLibFileRead - unlet! s:bufread - " TLogDBG "done" -endf - - -" Return 0 if the file isn't readable/doesn't exist. -" Otherwise return 1. -function! tlib#file#Edit(fileid) "{{{3 - if type(a:fileid) == 0 - let bn = a:fileid - let filename = fnamemodify(bufname(bn), ':p') - else - let filename = fnamemodify(a:fileid, ':p') - let bn = bufnr(filename) - endif - if filename == expand('%:p') - return 1 - else - " TLogVAR a:fileid, bn, filename, g:tlib#file#drop, filereadable(filename) - if bn != -1 && buflisted(bn) - if g:tlib#file#drop - " echom "DBG" get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) - exec get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) - else - " echom "DBG" get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn - exec get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn - endif - return 1 - elseif filereadable(filename) - try - " let file = tlib#arg#Ex(filename) - " " TLogVAR file - " echom "DBG" get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) - exec get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) - catch /E325/ - " swap file exists, let the user handle it - catch - echohl error - echom v:exception - echohl NONE - endtry - return 1 - else - echom "TLIB: File not readable: " . filename - if filename != a:fileid - echom "TLIB: original filename: " . a:fileid - endif - endif - endif - return 0 -endf - - -if v:version > 704 || (v:version == 704 && has('patch279')) - - function! tlib#file#Glob(pattern) abort "{{{3 - return glob(a:pattern, 0, 1) - endf - - function! tlib#file#Globpath(path, pattern) abort "{{{3 - return globpath(a:path, a:pattern, 0, 1) - endf - -else - - " :nodoc: - function! tlib#file#Glob(pattern) abort "{{{3 - return split(glob(a:pattern), '\n') - endf - - " :nodoc: - function! tlib#file#Globpath(path, pattern) abort "{{{3 - return split(globpath(a:path, a:pattern), '\n') - endf - -endif - diff --git a/sources_non_forked/tlib/autoload/tlib/fixes.vim b/sources_non_forked/tlib/autoload/tlib/fixes.vim deleted file mode 100644 index e9247dd6..00000000 --- a/sources_non_forked/tlib/autoload/tlib/fixes.vim +++ /dev/null @@ -1,14 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2013-02-22. -" @Revision: 3 - - -function! tlib#fixes#Winpos() "{{{3 - if has('gui_win32') - return 'winpos '. getwinposx() .' '. getwinposy() - else - return '' - endif -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/grep.vim b/sources_non_forked/tlib/autoload/tlib/grep.vim deleted file mode 100644 index 894b1ee7..00000000 --- a/sources_non_forked/tlib/autoload/tlib/grep.vim +++ /dev/null @@ -1,38 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2013-10-16. -" @Revision: 31 - - -function! tlib#grep#Do(cmd, rx, files) "{{{3 - " TLogVAR a:cmd, a:rx, a:files - let files = join(map(copy(a:files), 'tlib#arg#Ex(v:val, "")'), ' ') - let rx = '/'. escape(a:rx, '/') .'/j' - " TLogVAR rx, files - silent exec a:cmd rx files -endf - - -function! tlib#grep#LocList(rx, files) "{{{3 - return tlib#grep#Do('noautocmd lvimgrep', a:rx, a:files) -endf - - -function! tlib#grep#QuickFixList(rx, files) "{{{3 - return tlib#grep#Do('noautocmd vimgrep', a:rx, a:files) -endf - - -function! tlib#grep#List(rx, files) "{{{3 - call setqflist([]) - call tlib#grep#Do('noautocmd vimgrepadd', a:rx, a:files) - let qfl = getqflist() - " TLogVAR qfl - " try - silent! colder - " catch - " call setqflist([], 'r') - " endtry - return qfl -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/hash.vim b/sources_non_forked/tlib/autoload/tlib/hash.vim deleted file mode 100644 index 29c9ef67..00000000 --- a/sources_non_forked/tlib/autoload/tlib/hash.vim +++ /dev/null @@ -1,145 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 276 - - -if !exists('g:tlib#hash#use_crc32') - let g:tlib#hash#use_crc32 = '' "{{{2 -endif - - -if !exists('g:tlib#hash#use_adler32') - let g:tlib#hash#use_adler32 = '' "{{{2 -endif - - -function! tlib#hash#CRC32B(chars) "{{{3 - if !empty(g:tlib#hash#use_crc32) - let use = g:tlib#hash#use_crc32 - elseif has('ruby') - let use = 'ruby' - else - let use = 'vim' - endif - if exists('*tlib#hash#CRC32B_'. use) - return tlib#hash#CRC32B_{use}(a:chars) - else - throw "Unknown version of tlib#hash#CRC32B: ". use - endif -endf - - -function! tlib#hash#CRC32B_ruby(chars) "{{{3 - if has('ruby') - let rv = '' - if !exists('s:loaded_ruby_zlib') - ruby require 'zlib' - let s:loaded_ruby_zlib = 1 - endif - ruby VIM::command('let rv = "%08X"' % Zlib.crc32(VIM::evaluate("a:chars"))) - return rv - else - throw "tlib#hash#CRC32B_ruby not supported in this version of vim" - endif -endf - - -function! tlib#hash#CRC32B_vim(chars) "{{{3 - if !exists('s:crc_table') - let cfile = tlib#persistent#Filename('tlib', 'crc_table', 1) - let s:crc_table = tlib#persistent#Value(cfile, 'tlib#hash#CreateCrcTable', 0) - endif - let xFFFF_FFFF = repeat([1], 32) - let crc = tlib#bitwise#XOR([0], xFFFF_FFFF, 'bits') - for char in split(a:chars, '\zs') - let octet = char2nr(char) - let r1 = tlib#bitwise#ShiftRight(crc, 8) - let i0 = tlib#bitwise#AND(crc, xFFFF_FFFF, 'bits') - let i1 = tlib#bitwise#XOR(i0, octet, 'bits') - let i2 = tlib#bitwise#Bits2Num(tlib#bitwise#AND(i1, 0xff, 'bits')) - let r2 = s:crc_table[i2] - let crc = tlib#bitwise#XOR(r1, r2, 'bits') - endfor - let crc = tlib#bitwise#XOR(crc, xFFFF_FFFF, 'bits') - let rv = tlib#bitwise#Bits2Num(crc, 16) - if len(rv) < 8 - let rv = repeat('0', 8 - len(rv)) . rv - endif - return rv -endf - - -" :nodoc: -function! tlib#hash#CreateCrcTable() "{{{3 - let sum = 0.0 - for exponent in [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32] - let exp = tlib#bitwise#Bits2Num(repeat([0], 32 - exponent) + [1], 10.0) - let sum += exp - endfor - let divisor = tlib#bitwise#Num2Bits(sum) - let crc_table = [] - for octet in range(256) - let remainder = tlib#bitwise#Num2Bits(octet) - for i in range(8) - if get(remainder, i) != 0 - let remainder = tlib#bitwise#XOR(remainder, tlib#bitwise#ShiftLeft(divisor, i), "bits") - endif - endfor - let remainder = tlib#bitwise#ShiftRight(remainder, 8) - call add(crc_table, remainder) - endfor - return crc_table -endf - - -function! tlib#hash#Adler32(chars) "{{{3 - if !empty(g:tlib#hash#use_adler32) - let use = g:tlib#hash#use_adler32 - elseif exists('*or') - let use = 'vim' - else - let use = 'tlib' - endif - if exists('*tlib#hash#Adler32_'. use) - return tlib#hash#Adler32_{use}(a:chars) - else - throw "Unknown version of tlib#hash#Adler32_: ". use - endif -endf - - -function! tlib#hash#Adler32_vim(chars) "{{{3 - if exists('*or') - let mod_adler = 65521 - let a = 1 - let b = 0 - for index in range(len(a:chars)) - let c = char2nr(a:chars[index]) - let a = (a + c) % mod_adler - let b = (b + a) % mod_adler - endfor - let bb = b * float2nr(pow(2, 16)) - let checksum = or(bb, a) - " TLogVAR checksum, a, b, bb - return printf("%08X", checksum) - else - throw "TLIB: Vim version doesn't support bitwise or()" - endif -endf - - -function! tlib#hash#Adler32_tlib(chars) "{{{3 - let mod_adler = 65521 - let a = 1 - let b = 0 - for index in range(len(a:chars)) - let c = char2nr(a:chars[index]) - let a = (a + c) % mod_adler - let b = (b + a) % mod_adler - endfor - let bb = tlib#bitwise#ShiftLeft(tlib#bitwise#Num2Bits(b), 16) - let checksum = tlib#bitwise#OR(bb, a, "bits") - return printf('%08s', tlib#bitwise#Bits2Num(checksum, 16)) -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/hook.vim b/sources_non_forked/tlib/autoload/tlib/hook.vim deleted file mode 100644 index 07d05041..00000000 --- a/sources_non_forked/tlib/autoload/tlib/hook.vim +++ /dev/null @@ -1,25 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 11 - - -" :def: function! tlib#hook#Run(hook, ?dict={}) -" Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. -function! tlib#hook#Run(hook, ...) "{{{3 - TVarArg ['dict', {}] - if has_key(dict, a:hook) - let hook = dict[a:hook] - else - let hook = tlib#var#Get(a:hook, 'wbg') - endif - if empty(hook) - return 0 - else - let world = dict - exec hook - return 1 - endif -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/input.vim b/sources_non_forked/tlib/autoload/tlib/input.vim deleted file mode 100644 index e8f892b0..00000000 --- a/sources_non_forked/tlib/autoload/tlib/input.vim +++ /dev/null @@ -1,1336 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 1366 - - -" :filedoc: -" Input-related, select from a list etc. - -" If a list is bigger than this value, don't try to be smart when -" selecting an item. Be slightly faster instead. -" See |tlib#input#List()|. -TLet g:tlib#input#sortprefs_threshold = 200 - - -" If a list contains more items, |tlib#input#List()| does not perform an -" incremental "live search" but uses |input()| to query the user for a -" filter. This is useful on slower machines or with very long lists. -TLet g:tlib#input#livesearch_threshold = 1000 - - -" Determine how |tlib#input#List()| and related functions work. -" Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: -" glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, -" |g:tlib#Filter_glob#char|) are interpreted as glob-like -" |wildcards| (this is the default method) -" - Examples: -" - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match -" "far". -" - Otherwise it is a derivate of the cnf method (see below). -" - See also |tlib#Filter_glob#New()|. -" cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is -" expanded to "\.\{-}" -" - A period character (".") acts as a wildcard as if ".\{-}" (see -" |/\{-|) were entered. -" - Examples: -" - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match -" "far". -" - Otherwise it is a derivate of the cnf method (see below). -" - See also |tlib#Filter_cnfd#New()|. -" cnf .... Match substrings -" - A blank creates an AND conjunction, i.e. the next pattern has to -" match too. -" - A pipe character ("|") creates an OR conjunction, either this or -" the next next pattern has to match. -" - Patterns are very 'nomagic' |regexp| with a |\V| prefix. -" - A pattern starting with "-" makes the filter exclude items -" matching that pattern. -" - Examples: -" - "foo bar" matches items that contain the strings "foo" AND -" "bar". -" - "foo|bar boo|far" matches items that contain either ("foo" OR -" "bar") AND ("boo" OR "far"). -" - See also |tlib#Filter_cnf#New()|. -" seq .... Match sequences of characters -" - |tlib#Filter_seq#New()| -" fuzzy .. Match fuzzy character sequences -" - |tlib#Filter_fuzzy#New()| -TLet g:tlib#input#filter_mode = 'glob' - - -" The highlight group to use for showing matches in the input list -" window. -" See |tlib#input#List()|. -TLet g:tlib#input#higroup = 'IncSearch' - -" When 1, automatically select the last remaining item only if the list -" had only one item to begin with. -" When 2, automatically select a last remaining item after applying -" any filters. -" See |tlib#input#List()|. -TLet g:tlib_pick_last_item = 1 - - -" :doc: -" Keys for |tlib#input#List|~ - -TLet g:tlib#input#and = ' ' -TLet g:tlib#input#or = '|' -TLet g:tlib#input#not = '-' - -" When editing a list with |tlib#input#List|, typing these numeric chars -" (as returned by getchar()) will select an item based on its index, not -" based on its name. I.e. in the default setting, typing a "4" will -" select the fourth item, not the item called "4". -" In order to make keys 0-9 filter the items in the list and make -" select an item by its index, remove the keys 48 to 57 from -" this dictionary. -" Format: [KEY] = BASE ... the number is calculated as KEY - BASE. -" :nodefault: -TLet g:tlib#input#numeric_chars = { - \ 176: 176, - \ 177: 176, - \ 178: 176, - \ 179: 176, - \ 180: 176, - \ 181: 176, - \ 182: 176, - \ 183: 176, - \ 184: 176, - \ 185: 176, - \} - " \ 48: 48, - " \ 49: 48, - " \ 50: 48, - " \ 51: 48, - " \ 52: 48, - " \ 53: 48, - " \ 54: 48, - " \ 55: 48, - " \ 56: 48, - " \ 57: 48, - - -" :nodefault: -" The default key bindings for single-item-select list views. -" -" This variable is best customized via the variable -" g:tlib_extend_keyagents_InputList_s. If you want to use , -" to move the cursor up and down, add these two lines to your |vimrc| -" file: -" -" let g:tlib_extend_keyagents_InputList_s = { -" \ 10: 'tlib#agent#Down', -" \ 11: 'tlib#agent#Up' -" \ } -TLet g:tlib#input#keyagents_InputList_s = { - \ "\": 'tlib#agent#PageUp', - \ "\": 'tlib#agent#PageDown', - \ "\": 'tlib#agent#Home', - \ "\": 'tlib#agent#End', - \ "\": 'tlib#agent#Up', - \ "\": 'tlib#agent#Down', - \ 9: 'tlib#agent#Complete', - \ "\": 'tlib#agent#UpN', - \ "\": 'tlib#agent#DownN', - \ "\": 'tlib#agent#ShiftLeft', - \ "\": 'tlib#agent#ShiftRight', - \ 18: 'tlib#agent#Reset', - \ 242: 'tlib#agent#Reset', - \ 17: 'tlib#agent#Input', - \ 241: 'tlib#agent#Input', - \ 27: 'tlib#agent#Exit', - \ 26: 'tlib#agent#Suspend', - \ 250: 'tlib#agent#Suspend', - \ 15: 'tlib#agent#SuspendToParentWindow', - \ "\": 'tlib#agent#Help', - \ "\": 'tlib#agent#ExecAgentByName', - \ "\": 'tlib#agent#ExecAgentByName', - \ "\": 'tlib#agent#ReduceFilter', - \ "\": 'tlib#agent#ReduceFilter', - \ "\": 'tlib#agent#PopFilter', - \ "\": 'tlib#agent#PopFilter', - \ "\": 'tlib#agent#PopFilter', - \ "\": 'tlib#agent#PopFilter', - \ "\": 'tlib#agent#Wildcard', - \ 191: 'tlib#agent#Debug', - \ char2nr(g:tlib#input#or): 'tlib#agent#OR', - \ char2nr(g:tlib#input#and): 'tlib#agent#AND', - \ } - " \ 63: 'tlib#agent#Help', - -if exists('g:tlib_extend_keyagents_InputList_s') - let g:tlib#input#keyagents_InputList_s = extend(g:tlib#input#keyagents_InputList_s, g:tlib_extend_keyagents_InputList_s) -endif - - -" :nodefault: -TLet g:tlib#input#keyagents_InputList_m = { - \ 35: 'tlib#agent#Select', - \ "\": 'tlib#agent#SelectUp', - \ "\": 'tlib#agent#SelectDown', - \ 1: 'tlib#agent#SelectAll', - \ 225: 'tlib#agent#SelectAll', - \ "\": 'tlib#agent#ToggleRestrictView', - \ } -" "\": 'tlib#agent#Select' - -if exists('g:tlib_extend_keyagents_InputList_m') - let g:tlib#input#keyagents_InputList_m = extend(g:tlib#input#keyagents_InputList_m, g:tlib_extend_keyagents_InputList_m) -endif - - - -" :nodefault: -TLet g:tlib#input#handlers_EditList = [ - \ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '', 'help': 'Edit item'}, - \ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '', 'help': 'Delete item(s)'}, - \ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '', 'help': 'New item'}, - \ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '', 'help': 'Cut item(s)'}, - \ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '', 'help': 'Copy item(s)'}, - \ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '', 'help': 'Paste item(s)'}, - \ {'pick_last_item': 0}, - \ {'return_agent': 'tlib#agent#EditReturnValue'}, - \ {'help_extra': [ - \ 'Submit changes by pressing ENTER or or ', - \ 'Cancel editing by pressing c' - \ ]}, - \ ] - - -" A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to -" customize keyboard shortcuts in the list view. -TLet g:tlib#input#user_shortcuts = {} - - -" If true, define a popup menu for |tlib#input#List()| and related -" functions. -TLet g:tlib#input#use_popup = has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32')) - - -" How to format filenames: -" l ... Show basenames on the left side, separated from the -" directory names -" r ... Show basenames on the right side -TLet g:tlib#input#format_filename = 'l' - - -" If g:tlib#input#format_filename == 'r', how much space should be kept -" free on the right side. -TLet g:tlib#input#filename_padding_r = '&co / 10' - - -" If g:tlib#input#format_filename == 'l', an expression that -" |eval()|uates to the maximum display width of filenames. -TLet g:tlib#input#filename_max_width = '&co / 2' - - -" Functions related to tlib#input#List(type, ...) "{{{2 - -" :def: function! tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) -" Select a single or multiple items from a list. Return either the list -" of selected elements or its indexes. -" -" By default, typing numbers will select an item by its index. See -" |g:tlib#input#numeric_chars| to find out how to change this. -" -" The item is automatically selected if the numbers typed equals the -" number of digits of the list length. I.e. if a list contains 20 items, -" typing 1 will first highlight item 1 but it won't select/use it -" because 1 is an ambiguous input in this context. If you press enter, -" the first item will be selected. If you press another digit (e.g. 0), -" item 10 will be selected. Another way to select item 1 would be to -" type 01. If the list contains only 9 items, typing 1 would select the -" first item right away. -" -" type can be: -" s ... Return one selected element -" si ... Return the index of the selected element -" m ... Return a list of selected elements -" mi ... Return a list of indexes -" -" Several pattern matching styles are supported. See -" |g:tlib#input#filter_mode|. -" -" Users can type to complete the current filter with the longest -" match. -" -" EXAMPLES: > -" echo tlib#input#List('s', 'Select one item', [100,200,300]) -" echo tlib#input#List('si', 'Select one item', [100,200,300]) -" echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) -" echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) -" -" See ../samples/tlib/input/tlib_input_list.vim (move the cursor over -" the filename and press gf) for a more elaborated example. -function! tlib#input#List(type, ...) "{{{3 - exec tlib#arg#Let([ - \ ['query', ''], - \ ['list', []], - \ ['handlers', []], - \ ['rv', ''], - \ ['timeout', 0], - \ ]) - " let handlers = a:0 >= 1 ? a:1 : [] - " let rv = a:0 >= 2 ? a:2 : '' - " let timeout = a:0 >= 3 ? a:3 : 0 - " let backchar = ["\", "\"] - - if a:type =~ '^resume' - let world = b:tlib_{matchstr(a:type, ' \zs.\+')} - else - let world = tlib#World#New({ - \ 'type': a:type, - \ 'base': list, - \ 'query': query, - \ 'timeout': timeout, - \ 'rv': rv, - \ 'handlers': handlers, - \ }) - let scratch_name = tlib#list#Find(handlers, 'has_key(v:val, "scratch_name")', '', 'v:val.scratch_name') - if !empty(scratch_name) - let world.scratch = scratch_name - endif - let world.scratch_vertical = tlib#list#Find(handlers, 'has_key(v:val, "scratch_vertical")', 0, 'v:val.scratch_vertical') - call world.Set_display_format(tlib#list#Find(handlers, 'has_key(v:val, "display_format")', '', 'v:val.display_format')) - let world.initial_index = tlib#list#Find(handlers, 'has_key(v:val, "initial_index")', 1, 'v:val.initial_index') - let world.index_table = tlib#list#Find(handlers, 'has_key(v:val, "index_table")', [], 'v:val.index_table') - let world.state_handlers = filter(copy(handlers), 'has_key(v:val, "state")') - let world.post_handlers = filter(copy(handlers), 'has_key(v:val, "postprocess")') - let world.filter_format = tlib#list#Find(handlers, 'has_key(v:val, "filter_format")', '', 'v:val.filter_format') - let world.return_agent = tlib#list#Find(handlers, 'has_key(v:val, "return_agent")', '', 'v:val.return_agent') - let world.help_extra = tlib#list#Find(handlers, 'has_key(v:val, "help_extra")', '', 'v:val.help_extra') - let world.resize = tlib#list#Find(handlers, 'has_key(v:val, "resize")', '', 'v:val.resize') - let world.show_empty = tlib#list#Find(handlers, 'has_key(v:val, "show_empty")', 0, 'v:val.show_empty') - let world.pick_last_item = tlib#list#Find(handlers, 'has_key(v:val, "pick_last_item")', - \ tlib#var#Get('tlib_pick_last_item', 'bg'), 'v:val.pick_last_item') - let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")', - \ g:tlib#input#numeric_chars, 'v:val.numeric_chars') - let world.key_handlers = filter(copy(handlers), 'has_key(v:val, "key")') - let filter = tlib#list#Find(handlers, 'has_key(v:val, "filter")', '', 'v:val.filter') - if !empty(filter) - " let world.initial_filter = [[''], [filter]] - " let world.initial_filter = [[filter]] - " TLogVAR world.initial_filter - call world.SetInitialFilter(filter) - endif - endif - return tlib#input#ListW(world) -endf - - -" A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from -" dict. -function! tlib#input#ListD(dict) "{{{3 - return tlib#input#ListW(tlib#World#New(a:dict)) -endf - - -" :def: function! tlib#input#ListW(world, ?command='') -" The second argument (command) is meant for internal use only. -" The same as |tlib#input#List| but the arguments are packed into world -" (an instance of tlib#World as returned by |tlib#World#New|). -function! tlib#input#ListW(world, ...) "{{{3 - TVarArg 'cmd' - " let time0 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time0 - let world = a:world - if world.pick_last_item >= 1 && stridx(world.type, 'e') == -1 && len(world.base) <= 1 - let rv = get(world.base, 0, world.rv) - if stridx(world.type, 'm') != -1 - return [rv] - else - return rv - endif - endif - call s:Init(world, cmd) - " TLogVAR world.state, world.sticky, world.initial_index - " let statusline = &l:statusline - " let laststatus = &laststatus - let showmode = &showmode - set noshowmode - let lastsearch = @/ - let scrolloff = &l:scrolloff - let &l:scrolloff = 0 - let @/ = '' - let dlist = [] - let post_keys = '' - " let &laststatus = 2 - - try - while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base)) - let post_keys = '' - " TLogDBG 'while' - " TLogVAR world.state - " let time01 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time01, time01 - time0 - try - let world = s:RunStateHandlers(world) - - " if exists('b:tlib_world_event') - " let event = b:tlib_world_event - " unlet! b:tlib_world_event - " if event == 'WinLeave' - " " let world.resume_state = world.state - " let world = tlib#agent#Suspend(world, world.rv) - " break - " endif - " endif - - " let time02 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time02, time02 - time0 - if world.state =~ '\' - " TLogDBG 'reset' - " call world.Reset(world.state =~ '\') - call world.Reset() - continue - endif - - call s:SetOffset(world) - - " let time02 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time02, time02 - time0 - " TLogDBG 1 - " TLogVAR world.state - if world.state == 'scroll' - let world.prefidx = world.offset - let world.state = 'redisplay' - endif - - if world.state =~ '\' - let world.sticky = 1 - endif - - " TLogVAR world.filter - " TLogVAR world.sticky - if world.state =~ '\' - " TLogVAR world.rv - throw 'picked' - elseif world.state =~ '\' - let world.rv = world.CurrentItem() - " TLogVAR world.rv - throw 'picked' - elseif world.state =~ 'display' - if world.state =~ '^display' - " let time03 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time03, time03 - time0 - if world.IsValidFilter() - - " let time1 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time1, time1 - time0 - call world.BuildTableList() - " let time2 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time2, time2 - time0 - " TLogDBG 2 - " TLogDBG len(world.table) - " TLogVAR world.table - " let world.list = map(copy(world.table), 'world.GetBaseItem(v:val)') - " TLogDBG 3 - let world.llen = len(world.list) - " TLogVAR world.index_table - if empty(world.index_table) - let dindex = range(1, world.llen) - let world.index_width = len(world.llen) - else - let dindex = world.index_table - let world.index_width = len(max(dindex)) - endif - " let time3 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time3, time3 - time0 - if world.llen == 0 && !world.show_empty - call world.ReduceFilter() - let world.offset = 1 - " TLogDBG 'ReduceFilter' - continue - else - if world.llen == 1 - let world.last_item = world.list[0] - if world.pick_last_item >= 2 - " echom 'Pick last item: '. world.list[0] - let world.prefidx = '1' - " TLogDBG 'pick last item' - throw 'pick' - endif - else - let world.last_item = '' - endif - endif - " let time4 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time4, time4 - time0 - " TLogDBG 4 - " TLogVAR world.idx, world.llen, world.state - " TLogDBG world.FilterIsEmpty() - if world.state == 'display' - if world.idx == '' && world.llen < g:tlib#input#sortprefs_threshold && !world.FilterIsEmpty() - call world.SetPrefIdx() - else - let world.prefidx = world.idx == '' ? world.initial_index : world.idx - endif - if world.prefidx > world.llen - let world.prefidx = world.llen - elseif world.prefidx < 1 - let world.prefidx = 1 - endif - endif - " let time5 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time5, time5 - time0 - " TLogVAR world.initial_index, world.prefidx - " TLogDBG 5 - " TLogDBG len(world.list) - " TLogVAR world.list - let dlist = world.DisplayFormat(world.list) - " TLogVAR world.prefidx - " TLogDBG 6 - " let time6 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time6, time6 - time0 - if world.offset_horizontal > 0 - call map(dlist, 'v:val[world.offset_horizontal:-1]') - endif - " let time7 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time7, time7 - time0 - " TLogVAR dindex - let dlist = map(range(0, world.llen - 1), 'printf("%0'. world.index_width .'d", dindex[v:val]) .": ". dlist[v:val]') - " TLogVAR dlist - " let time8 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time8, time8 - time0 - - else - - let dlist = ['Malformed filter'] - - endif - else - if world.prefidx == 0 - let world.prefidx = 1 - endif - endif - " TLogVAR world.idx, world.prefidx - - " TLogDBG 7 - " TLogVAR world.prefidx, world.offset - " TLogDBG (world.prefidx > world.offset + winheight(0) - 1) - " if world.prefidx > world.offset + winheight(0) - 1 - " let listtop = world.llen - winheight(0) + 1 - " let listoff = world.prefidx - winheight(0) + 1 - " let world.offset = min([listtop, listoff]) - " TLogVAR world.prefidx - " TLogDBG len(list) - " TLogDBG winheight(0) - " TLogVAR listtop, listoff, world.offset - " elseif world.prefidx < world.offset - " let world.offset = world.prefidx - " endif - " TLogDBG 8 - " TLogVAR world.initial_display, !tlib#char#IsAvailable() - if world.state =~ '\' || world.initial_display || !tlib#char#IsAvailable() - " TLogDBG len(dlist) - call world.DisplayList(world.Query(), dlist) - call world.FollowCursor() - let world.initial_display = 0 - " TLogDBG 9 - endif - if world.state =~ '\' - let world.state = 'suspend' - else - let world.state = '' - endif - else - " if world.state == 'scroll' - " let world.prefidx = world.offset - " endif - call world.DisplayList() - if world.state == 'help' || world.state == 'printlines' - let world.state = 'display' - else - let world.state = '' - call world.FollowCursor() - endif - endif - " TAssert IsNotEmpty(world.scratch) - let world.list_wnr = winnr() - - " TLogVAR world.state, world.next_state - if !empty(world.next_state) - let world.state = world.next_state - let world.next_state = '' - endif - - if world.state =~ '\' - let world = tlib#agent#SuspendToParentWindow(world, world.rv) - continue - endif - - if world.state =~ '\' - let query = matchstr(world.state, '\" - if v:mouse_win == world.list_wnr - let world.prefidx = world.GetLineIdx(v:mouse_lnum) - " let world.offset = world.prefidx - if empty(world.prefidx) - " call feedkeys(c, 't') - let c = s:GetModdedChar(world) - let world.state = 'help' - continue - endif - throw 'pick' - else - let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c - if world.allow_suspend - let world = tlib#agent#SuspendToParentWindow(world, world.rv) - else - let world.state = 'exit empty' - endif - endif - elseif c == "\" - if v:mouse_win == world.list_wnr - call s:BuildMenu(world) - let world.state = 'redisplay' - if s:PopupmenuExists() == 1 - " if v:mouse_lnum != line('.') - " endif - let world.prefidx = world.GetLineIdx(v:mouse_lnum) - let world.next_state = 'eval[Waiting for popup menu ... Press ESC to continue]' - call world.DisplayList() - if line('w$') - v:mouse_lnum < 6 - popup ]TLibInputListPopupMenu - else - popup! ]TLibInputListPopupMenu - endif - endif - else - let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c - if world.allow_suspend - let world = tlib#agent#SuspendToParentWindow(world, world.rv) - else - let world.state = 'exit empty' - endif - endif - " TLogVAR world.prefidx, world.state - elseif has_key(world.key_map[world.key_mode], 'unknown_key') - let agent = world.key_map[world.key_mode].unknown_key.agent - " let world = call(agent, [world, c]) - " call s:CheckAgentReturnValue(agent, world) - let world = s:CallAgent({'agent': agent}, world, c) - elseif c >= 32 - let world.state = 'display' - let numbase = get(world.numeric_chars, c, -99999) - " TLogVAR numbase, world.numeric_chars, c - if numbase != -99999 - let world.idx .= (c - numbase) - if len(world.idx) == world.index_width - let world.prefidx = world.idx - " TLogVAR world.prefidx - throw 'pick' - endif - else - let world.idx = '' - " TLogVAR world.filter - if world.llen > g:tlib#input#livesearch_threshold - let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c)) - if empty(pattern) - let world.state = 'exit empty' - else - call world.SetFrontFilter(pattern) - echo - endif - elseif c == 124 - call insert(world.filter[0], []) - else - call world.PushFrontFilter(c) - endif - " continue - if c == 45 && world.filter[0][0] == '-' - let world.state = 'redisplay' - end - endif - else - let world.state = 'redisplay' - " let world.state = 'continue' - endif - - catch /^picked$/ - call world.ClearAllMarks() - call world.MarkCurrent(world.prefidx) - let world.state = 'exit' - - catch /^pick$/ - call world.ClearAllMarks() - call world.MarkCurrent(world.prefidx) - let world.state = '' - " TLogDBG 'Pick item #'. world.prefidx - - finally - " TLogDBG 'finally 1', world.state - if world.state =~ '\' - " if !world.allow_suspend - " echom "Cannot be suspended" - " let world.state = 'redisplay' - " endif - elseif !empty(world.list) && !empty(world.base) - " TLogVAR world.list - if empty(world.state) - let world.rv = world.CurrentItem() - " TLogVAR world.state, world.rv - endif - " TLogVAR "postprocess" - for handler in world.post_handlers - let state = get(handler, 'postprocess', '') - " TLogVAR handler - " TLogVAR state - " TLogVAR world.state - if state == world.state - let agent = handler.agent - let [world, world.rv] = call(agent, [world, world.rv]) - " TLogVAR world.state, world.rv - call s:CheckAgentReturnValue(agent, world) - endif - endfor - endif - " TLogDBG 'state0='. world.state - endtry - " TLogDBG 'state1='. world.state - endwh - - " TLogVAR world.state - " TLogDBG string(tlib#win#List()) - " TLogDBG 'exit while loop' - " TLogVAR world.list - " TLogVAR world.sel_idx - " TLogVAR world.idx - " TLogVAR world.prefidx - " TLogVAR world.rv - " TLogVAR world.type, world.state, world.return_agent, world.index_table, world.rv - if world.state =~ '\<\(empty\|escape\)\>' - let world.sticky = 0 - endif - if world.state =~ '\' - " TLogDBG 'return suspended' - " TLogVAR world.prefidx - " exec world.prefidx - return - elseif world.state =~ '\' - " TLog "empty" - " TLogDBG 'return empty' - " TLogVAR world.type - if stridx(world.type, 'm') != -1 - return [] - elseif stridx(world.type, 'i') != -1 - return 0 - else - return '' - endif - elseif !empty(world.return_agent) - " TLogDBG 'return agent' - " TLogVAR world.return_agent - call world.CloseScratch() - " TLogDBG "return_agent ". string(tlib#win#List()) - " TAssert IsNotEmpty(world.scratch) - return call(world.return_agent, [world, world.GetSelectedItems(world.rv)]) - elseif stridx(world.type, 'w') != -1 - " TLog "return_world" - " TLogDBG 'return world' - return world - elseif stridx(world.type, 'm') != -1 - " TLog "return_multi" - " TLogDBG 'return multi' - return world.GetSelectedItems(world.rv) - elseif stridx(world.type, 'i') != -1 - " TLog "return_index" - " TLogDBG 'return index' - if empty(world.index_table) - return world.rv - else - return world.index_table[world.rv - 1] - endif - else - " TLog "return_else" - " TLogDBG 'return normal' - return world.rv - endif - - finally - call world.Leave() - - " TLogVAR statusline - " let &l:statusline = statusline - " let &laststatus = laststatus - if &showmode != showmode - let &showmode = showmode - endif - silent! let @/ = lastsearch - let &l:scrolloff = scrolloff - if s:PopupmenuExists() == 1 - silent! aunmenu ]TLibInputListPopupMenu - endif - - " TLogDBG 'finally 2' - " TLogDBG string(world.Methods()) - " TLogVAR world.state - " TLogDBG string(tlib#win#List()) - if world.state !~ '\' - " redraw - " TLogVAR world.sticky, bufnr("%") - if world.sticky - " TLogDBG "sticky" - " TLogVAR world.bufnr - " TLogDBG bufwinnr(world.bufnr) - if world.scratch_split > 0 - if bufwinnr(world.bufnr) == -1 - " TLogDBG "UseScratch" - call world.UseScratch() - endif - let world = tlib#agent#SuspendToParentWindow(world, world.GetSelectedItems(world.rv)) - endif - else - " TLogDBG "non sticky" - " TLogVAR world.state, world.win_wnr, world.bufnr - if world.CloseScratch() - " TLogVAR world.winview - call tlib#win#SetLayout(world.winview) - endif - endif - endif - " for i in range(0,5) - " call getchar(0) - " endfor - echo - redraw! - if !empty(post_keys) - " TLogVAR post_keys - call feedkeys(post_keys) - endif - endtry -endf - - -function! s:CallAgent(handler, world, list) abort "{{{3 - let agent = a:handler.agent - let args = [a:world, a:list] - if has_key(a:handler, 'args') - let args += a:handler.args - endif - let world = call(agent, args) - " TLogVAR world.state, world.rv - call s:CheckAgentReturnValue(agent, world) - return world -endf - -function! s:GetModdedChar(world) "{{{3 - let [char, mode] = tlib#char#Get(a:world.timeout, a:world.timeout_resolution, 1) - if char !~ '\D' && char > 0 && mode != 0 - return printf("<%s-%s>", mode, char) - else - return char - endif -endf - - -function! s:Init(world, cmd) "{{{3 - " TLogVAR a:cmd - let a:world.initial_display = 1 - if a:cmd =~ '\' - let a:world.sticky = 1 - endif - if a:cmd =~ '^resume' - call a:world.UseInputListScratch() - let a:world.initial_index = line('.') - if a:cmd =~ '\' - let a:world.state = 'pick' - let a:world.prefidx = a:world.initial_index - else - call a:world.Retrieve(1) - endif - " if !empty(a:world.resume_state) - " let a:world.state = a:world.resume_state - " endif - elseif !a:world.initialized - " TLogVAR a:world.initialized, a:world.win_wnr, a:world.bufnr - let a:world.filetype = &filetype - let a:world.fileencoding = &fileencoding - call a:world.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'wb')) - call a:world.Initialize() - if !has_key(a:world, 'key_mode') - let a:world.key_mode = 'default' - endif - " TLogVAR has_key(a:world,'key_map') - if has_key(a:world, 'key_map') - " TLogVAR has_key(a:world.key_map,a:world.key_mode) - if has_key(a:world.key_map, a:world.key_mode) - let a:world.key_map[a:world.key_mode] = extend( - \ a:world.key_map[a:world.key_mode], - \ copy(g:tlib#input#keyagents_InputList_s), - \ 'keep') - else - let a:world.key_map[a:world.key_mode] = copy(g:tlib#input#keyagents_InputList_s) - endif - else - let a:world.key_map = { - \ a:world.key_mode : copy(g:tlib#input#keyagents_InputList_s) - \ } - endif - " TLogVAR a:world.type - if stridx(a:world.type, 'm') != -1 - call extend(a:world.key_map[a:world.key_mode], g:tlib#input#keyagents_InputList_m, 'force') - endif - for key_mode in keys(a:world.key_map) - let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}') - endfor - " TLogVAR a:world.key_mode - if type(a:world.key_handlers) == 3 - call s:ExtendKeyMap(a:world, a:world.key_mode, a:world.key_handlers) - elseif type(a:world.key_handlers) == 4 - for [world_key_mode, world_key_handlers] in items(a:world.key_handlers) - call s:ExtendKeyMap(a:world, world_key_mode, world_key_handlers) - endfor - else - throw "tlib#input#ListW: key_handlers must be either a list or a dictionary" - endif - " TLogVAR a:world.type, a:world.key_map - if !empty(a:cmd) - let a:world.state .= ' '. a:cmd - endif - endif - " TLogVAR a:world.state, a:world.sticky -endf - - -function! s:ExtendKeyMap(world, key_mode, key_handlers) "{{{3 - for handler in a:key_handlers - let k = get(handler, 'key', '') - if !empty(k) - let a:world.key_map[a:key_mode][k] = handler - endif - endfor -endf - - -function! s:PopupmenuExists() - if !g:tlib#input#use_popup - \ || exists(':popup') != 2 - \ || !(has('gui_win32') || has('gui_gtk') || has('gui_gtk2')) - " \ || !has('gui_win32') - let rv = -1 - else - try - let rv = 1 - silent amenu ]TLibInputListPopupMenu - catch - let rv = 0 - endtry - endif - " TLogVAR rv - return rv -endf - - -function! s:BuildMenu(world) "{{{3 - if g:tlib#input#use_popup && s:PopupmenuExists() == 0 - call s:BuildItem('Pick\ selected\ item', {'key_name': '', 'eval': 'let world.state = "pick"'}) - call s:BuildItem('Cancel', {'key_name': '', 'agent': 'tlib#agent#Exit'}) - call s:BuildItem('Select', {'key_name': '#', 'agent': 'tlib#agent#Select'}) - call s:BuildItem('Select\ all', {'key_name': '', 'agent': 'tlib#agent#SelectAll'}) - call s:BuildItem('Reset\ list', {'key_name': '', 'agent': 'tlib#agent#Reset'}) - call s:BuildItem('-StandardEntries-', {'key': ":", 'eval': 'let world.state = "redisplay"'}) - for [key_mode, key_handlers] in items(a:world.key_map) - let keys = sort(keys(key_handlers)) - let mitems = {} - for key in keys - let handler = key_handlers[key] - let k = get(handler, 'key', '') - if !empty(k) && has_key(handler, 'help') && !empty(handler.help) - if empty(key_mode) || key_mode == 'default' - let mname = '' - else - let mname = escape(key_mode, ' .\') .'.' - endif - if has_key(handler, 'submenu') - let submenu = escape(handler.submenu, ' .\') - else - let submenu = '~' - endif - for mfield in ['menu', 'help', 'key_name', 'agent'] - if has_key(handler, mfield) - let mname .= escape(handler[mfield], ' .\') - break - endif - endfor - if !has_key(mitems, submenu) - let mitems[submenu] = {} - endif - let mitems[submenu][mname] = handler - endif - endfor - for msubname in sort(keys(mitems)) - let msubitems = mitems[msubname] - if msubname == '~' - let msubmname = '' - else - let msubmname = msubname .'.' - endif - for mname in sort(keys(msubitems)) - let msname = msubmname . mname - let handler = msubitems[mname] - call s:BuildItem(msname, handler) - " if has_key(handler, 'agent') - " call s:BuildItem(msname, {'agent': handler.agent}) - " else - " call s:BuildItem(msname, {'key': handler.key_name}) - " endif - endfor - endfor - endfor - endif -endf - - -function! s:BuildItem(menu, def) "{{{3 - if has('gui_win32') - let key_mode = 'c' - elseif has('gui_gtk') || has('gui_gtk2') - let key_mode = 'raw' - endif - for k in ['agent', 'eval', 'key_name', 'key'] - if has('gui_win32') - elseif has('gui_gtk') || has('gui_gtk') - if k == 'agent' || k == 'eval' - continue - endif - endif - try - if has_key(a:def, k) - let v = a:def[k] - if k == 'key' - if key_mode == 'c' - " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' - exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' - else - " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) v - exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) v - endif - elseif k == 'key_name' - if key_mode == 'c' - " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' - exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' - else - let key = v - " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) key - exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) key - endif - elseif k == 'agent' - " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' - exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' - elseif k == 'eval' - " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' - exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' - endif - return - endif - catch - endtry - endfor -endf - - -function! s:RunStateHandlers(world) "{{{3 - " Provide the variable "world" in the environment of an "exec" - " handler (ea). - let world = a:world - for handler in a:world.state_handlers - let eh = get(handler, 'state', '') - if !empty(eh) && a:world.state =~ eh - let ea = get(handler, 'exec', '') - if !empty(ea) - exec ea - else - let agent = get(handler, 'agent', '') - " let world = call(agent, [a:world, a:world.GetSelectedItems(a:world.CurrentItem())]) - " call s:CheckAgentReturnValue(agent, a:world) - let world = s:CallAgent({'agent': agent}, world, world.GetSelectedItems(world.CurrentItem())) - endif - endif - endfor - return world -endf - - -function! s:CheckAgentReturnValue(name, value) "{{{3 - if type(a:value) != 4 && !has_key(a:value, 'state') - echoerr 'Malformed agent: '. a:name - endif - return a:value -endf - - -function! s:SetOffset(world) "{{{3 - let llenw = len(a:world.base) - winheight(0) + 1 - if a:world.offset > llenw - let a:world.offset = llenw - endif - if a:world.offset < 1 - let a:world.offset = 1 - endif -endf - - -" Functions related to tlib#input#EditList(type, ...) "{{{2 - -" :def: function! tlib#input#EditList(query, list, ?timeout=0) -" Edit a list. -" -" EXAMPLES: > -" echo tlib#input#EditList('Edit:', [100,200,300]) -function! tlib#input#EditList(query, list, ...) "{{{3 - let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib#input#handlers_EditList - let default = a:0 >= 2 ? a:2 : [] - let timeout = a:0 >= 3 ? a:3 : 0 - " TLogVAR handlers - let rv = tlib#input#List('me', a:query, copy(a:list), handlers, default, timeout) - " TLogVAR rv - if empty(rv) - return a:list - else - let [success, list] = rv - return success ? list : a:list - endif -endf - - -function! tlib#input#Resume(name, pick, bufnr) "{{{3 - " TLogVAR a:name, a:pick - echo - if bufnr('%') != a:bufnr - if g:tlib#debug - echohl WarningMsg - echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%') - echohl NONE - endif - let br = tlib#buffer#Set(a:bufnr) - endif - if !exists('b:tlib_'. a:name) - if g:tlib#debug - echohl WarningMsg - echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%') - echohl NONE - redir => varss - silent let b: - redir END - let vars = split(varss, '\n') - call filter(vars, 'v:val =~ "^b:tlib_"') - echom "DEBUG tlib#input#Resume" string(vars) - endif - else - call tlib#autocmdgroup#Init() - autocmd! TLib BufEnter - if b:tlib_{a:name}.state =~ '\' - let b:tlib_{a:name}.state = 'redisplay' - else - let b:tlib_{a:name}.state .= ' redisplay' - endif - " call tlib#input#List('resume '. a:name) - let cmd = 'resume '. a:name - if a:pick >= 1 - let cmd .= ' pick' - if a:pick >= 2 - let cmd .= ' sticky' - end - endif - call tlib#input#ListW(b:tlib_{a:name}, cmd) - endif -endf - - -" :def: function! tlib#input#CommandSelect(command, ?keyargs={}) -" Take a command, view the output, and let the user select an item from -" its output. -" -" EXAMPLE: > -" command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') -" command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') -function! tlib#input#CommandSelect(command, ...) "{{{3 - TVarArg ['args', {}] - if has_key(args, 'retrieve') - let list = call(args.retrieve) - elseif has_key(args, 'list') - let list = args.list - else - let list = tlib#cmd#OutputAsList(a:command) - endif - if has_key(args, 'filter') - call map(list, args.filter) - endif - let type = has_key(args, 'type') ? args.type : 's' - let handlers = has_key(args, 'handlers') ? args.handlers : [] - let rv = tlib#input#List(type, 'Select', list, handlers) - if !empty(rv) - if has_key(args, 'process') - let rv = call(args.process, [rv]) - endif - endif - return rv -endf - - -" :def: function! tlib#input#Edit(name, value, callback, ?cb_args=[]) -" -" Edit a value (asynchronously) in a scratch buffer. Use name for -" identification. Call callback when done (or on cancel). -" In the scratch buffer: -" Press or to enter the new value, c to cancel -" editing. -" EXAMPLES: > -" fun! FooContinue(success, text) -" if a:success -" let b:var = a:text -" endif -" endf -" call tlib#input#Edit('foo', b:var, 'FooContinue') -function! tlib#input#Edit(name, value, callback, ...) "{{{3 - " TLogVAR a:value - TVarArg ['args', []] - let sargs = {'scratch': '__EDIT__'. a:name .'__', 'win_wnr': winnr()} - let scr = tlib#scratch#UseScratch(sargs) - - " :nodoc: - map c :call EditCallback(0) - " :nodoc: - imap c call EditCallback(0) - " :nodoc: - map :call EditCallback(1) - " :nodoc: - imap call EditCallback(1) - " :nodoc: - map :call EditCallback(1) - " :nodoc: - imap call EditCallback(1) - - call tlib#normal#WithRegister('gg"tdG', 't') - call append(1, split(a:value, "\", 1)) - " let hrm = 'DON''T DELETE THIS HEADER' - " let hr3 = repeat('"', (tlib#win#Width(0) - len(hrm)) / 2) - let s:horizontal_line = repeat('`', tlib#win#Width(0)) - " hr3.hrm.hr3 - let hd = ['Keys: , ... save/accept; c ... cancel', s:horizontal_line] - call append(1, hd) - call tlib#normal#WithRegister('gg"tdd', 't') - syntax match TlibEditComment /^\%1l.*/ - syntax match TlibEditComment /^```.*/ - hi link TlibEditComment Comment - exec len(hd) + 1 - if type(a:callback) == 4 - let b:tlib_scratch_edit_callback = get(a:callback, 'submit', '') - call call(get(a:callback, 'init', ''), []) - else - let b:tlib_scratch_edit_callback = a:callback - endif - let b:tlib_scratch_edit_args = args - let b:tlib_scratch_edit_scratch = sargs - " exec 'autocmd BufDelete,BufHidden,BufUnload call s:EditCallback('. string(a:name) .')' - " echohl MoreMsg - " echom 'Press to enter, c to cancel editing.' - " echohl NONE -endf - - -function! s:EditCallback(...) "{{{3 - TVarArg ['ok', -1] - " , ['bufnr', -1] - " autocmd! BufDelete,BufHidden,BufUnload - if ok == -1 - let ok = confirm('Use value') - endif - let start = getline(2) == s:horizontal_line ? 3 : 1 - let text = ok ? join(getline(start, '$'), "\n") : '' - let cb = b:tlib_scratch_edit_callback - let args = b:tlib_scratch_edit_args - let sargs = b:tlib_scratch_edit_scratch - " TLogVAR cb, args, sargs - call tlib#scratch#CloseScratch(b:tlib_scratch_edit_scratch) - call tlib#win#Set(sargs.win_wnr) - call call(cb, args + [ok, text]) -endf - - -function! tlib#input#Dialog(text, options, default) "{{{3 - if has('dialog_con') || has('dialog_gui') - let opts = join(map(a:options, '"&". v:val'), "\n") - let val = confirm(a:text, opts) - if val - let yn = a:options[val - 1] - else - let yn = a:default - endif - else - let oi = index(a:options, a:default) - if oi == -1 - let opts = printf("(%s|%s)", join(a:options, '/'), a:default) - else - let options = copy(a:options) - let options[oi] = toupper(options[oi]) - let opts = printf("(%s)", join(a:options, '/')) - endif - let yn = inputdialog(a:text .' '. opts) - endif - return yn -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/list.vim b/sources_non_forked/tlib/autoload/tlib/list.vim deleted file mode 100644 index dbbc702f..00000000 --- a/sources_non_forked/tlib/autoload/tlib/list.vim +++ /dev/null @@ -1,183 +0,0 @@ -" list.vim -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-06-30. -" @Last Change: 2015-10-21. -" @Revision: 61 - - -""" List related functions {{{1 -" For the following functions please see ../../test/tlib.vim for examples. - -" :def: function! tlib#list#Inject(list, initial_value, funcref) -" EXAMPLES: > -" echo tlib#list#Inject([1,2,3], 0, function('Add') -" => 6 -function! tlib#list#Inject(list, value, Function) "{{{3 - if empty(a:list) - return a:value - else - let item = a:list[0] - let rest = a:list[1:-1] - let value = call(a:Function, [a:value, item]) - return tlib#list#Inject(rest, value, a:Function) - endif -endf - - -" EXAMPLES: > -" tlib#list#Compact([0,1,2,3,[], {}, ""]) -" => [1,2,3] -function! tlib#list#Compact(list) "{{{3 - return filter(copy(a:list), '!empty(v:val)') -endf - - -" EXAMPLES: > -" tlib#list#Flatten([0,[1,2,[3,""]]]) -" => [0,1,2,3,""] -function! tlib#list#Flatten(list) "{{{3 - let acc = [] - for e in a:list - if type(e) == 3 - let acc += tlib#list#Flatten(e) - else - call add(acc, e) - endif - unlet e - endfor - return acc -endf - - -" :def: function! tlib#list#FindAll(list, filter, ?process_expr="") -" Basically the same as filter() -" -" EXAMPLES: > -" tlib#list#FindAll([1,2,3], 'v:val >= 2') -" => [2, 3] -function! tlib#list#FindAll(list, filter, ...) "{{{3 - let rv = filter(copy(a:list), a:filter) - if a:0 >= 1 && a:1 != '' - let rv = map(rv, a:1) - endif - return rv -endf - - -" :def: function! tlib#list#Find(list, filter, ?default="", ?process_expr="") -" -" EXAMPLES: > -" tlib#list#Find([1,2,3], 'v:val >= 2') -" => 2 -function! tlib#list#Find(list, filter, ...) "{{{3 - let default = a:0 >= 1 ? a:1 : '' - let expr = a:0 >= 2 ? a:2 : '' - return get(tlib#list#FindAll(a:list, a:filter, expr), 0, default) -endf - - -" EXAMPLES: > -" tlib#list#Any([1,2,3], 'v:val >= 2') -" => 1 -function! tlib#list#Any(list, expr) "{{{3 - return !empty(tlib#list#FindAll(a:list, a:expr)) -endf - - -" EXAMPLES: > -" tlib#list#All([1,2,3], 'v:val >= 2') -" => 0 -function! tlib#list#All(list, expr) "{{{3 - return len(tlib#list#FindAll(a:list, a:expr)) == len(a:list) -endf - - -" EXAMPLES: > -" tlib#list#Remove([1,2,1,2], 2) -" => [1,1,2] -function! tlib#list#Remove(list, element) "{{{3 - let idx = index(a:list, a:element) - if idx != -1 - call remove(a:list, idx) - endif - return a:list -endf - - -" EXAMPLES: > -" tlib#list#RemoveAll([1,2,1,2], 2) -" => [1,1] -function! tlib#list#RemoveAll(list, element) "{{{3 - call filter(a:list, 'v:val != a:element') - return a:list -endf - - -" :def: function! tlib#list#Zip(lists, ?default='') -" EXAMPLES: > -" tlib#list#Zip([[1,2,3], [4,5,6]]) -" => [[1,4], [2,5], [3,6]] -function! tlib#list#Zip(lists, ...) "{{{3 - TVarArg 'default' - let lists = copy(a:lists) - let max = 0 - for l in lists - let ll = len(l) - if ll > max - let max = ll - endif - endfor - " TLogVAR default, max - return map(range(0, max - 1), 's:GetNthElement(v:val, lists, default)') -endf - -function! s:GetNthElement(n, lists, default) "{{{3 - " TLogVAR a:n, a:lists, a:default - return map(copy(a:lists), 'get(v:val, a:n, a:default)') -endf - - -function! tlib#list#Uniq(list, ...) "{{{3 - " TLogVAR a:list - TVarArg ['get_value', ''], ['remove_empty', 0] - if remove_empty - call filter(a:list, 'type(v:val) == 0 || !empty(v:val)') - endif - " CREDITS: Based on syntastic#util#unique(list) by scrooloose - let seen = {} - let uniques = [] - if empty(get_value) - for e in a:list - if !has_key(seen, e) - let seen[e] = 1 - call add(uniques, e) - endif - unlet e - endfor - else - for e in a:list - let v = eval(printf(get_value, string(e))) - if !has_key(seen, v) - let seen[v] = 1 - call add(uniques, e) - endif - unlet e - endfor - endif - return uniques -endf - - -function! tlib#list#ToDictionary(list, default, ...) "{{{3 - TVarArg ['generator', ''] - let dict = {} - for item in a:list - if !empty(item) - let dict[item] = empty(generator) ? a:default : call(generator, [item, a:default]) - endif - endfor - return dict -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/loclist.vim b/sources_non_forked/tlib/autoload/tlib/loclist.vim deleted file mode 100644 index 198dd1be..00000000 --- a/sources_non_forked/tlib/autoload/tlib/loclist.vim +++ /dev/null @@ -1,13 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-10-24 -" @Revision: 2 - - -function! tlib#loclist#Browse(...) abort "{{{3 - let list = getloclist(0) - return call(function('tlib#qfl#QflList'), [list] + a:000) -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/map.vim b/sources_non_forked/tlib/autoload/tlib/map.vim deleted file mode 100644 index c1af13f6..00000000 --- a/sources_non_forked/tlib/autoload/tlib/map.vim +++ /dev/null @@ -1,23 +0,0 @@ -" map.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2009-08-23. -" @Last Change: 2009-08-23. -" @Revision: 0.0.4 - -let s:save_cpo = &cpo -set cpo&vim - - -" If |pumvisible()| is true, return "\". Otherwise return a:key. -" For use in maps like: > -" imap tlib#map#PumAccept("\") -function! tlib#map#PumAccept(key) "{{{3 - return pumvisible() ? "\" : a:key -endf - - - -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/normal.vim b/sources_non_forked/tlib/autoload/tlib/normal.vim deleted file mode 100644 index faaa4448..00000000 --- a/sources_non_forked/tlib/autoload/tlib/normal.vim +++ /dev/null @@ -1,34 +0,0 @@ -" normal.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2008-10-06. -" @Last Change: 2010-09-22. -" @Revision: 28 - -let s:save_cpo = &cpo -set cpo&vim - - -" :display: tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') -" Execute a normal command while maintaining all registers. -function! tlib#normal#WithRegister(cmd, ...) "{{{3 - TVarArg ['register', 't'], ['norm_cmd', 'norm!'] - let registers = {} - for reg in split('123456789'. register, '\zs') - exec 'let registers[reg] = @'. reg - endfor - exec 'let reg = @'. register - try - exec norm_cmd .' '. a:cmd - exec 'return @'. register - finally - for [reg, value] in items(registers) - exec 'let @'. reg .' = value' - endfor - endtry -endf - - -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/notify.vim b/sources_non_forked/tlib/autoload/tlib/notify.vim deleted file mode 100644 index 2f45bdb8..00000000 --- a/sources_non_forked/tlib/autoload/tlib/notify.vim +++ /dev/null @@ -1,105 +0,0 @@ -" notify.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2008-09-19. -" @Last Change: 2015-04-07. -" @Revision: 0.3.19 - -let s:save_cpo = &cpo -set cpo&vim - - -" :display: tlib#notify#Echo(text, ?style='') -" Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' -" in order to prevent |press-enter| messages. -function! tlib#notify#Echo(text, ...) - TVarArg 'style' - let ruler = &ruler - let showcmd = &showcmd - let text = substitute(a:text, '\n', '|', 'g') - try - set noruler - set noshowcmd - if !empty(style) - exec 'echohl' style - endif - echo strpart(text, 0, &columns - 1) - finally - if !empty(style) - echohl None - endif - let &ruler = ruler - let &showcmd = showcmd - endtry -endf - - -" Contributed by Erik Falor: -" If the line containing the message is too long, echoing it will cause -" a 'Hit ENTER' prompt to appear. This function cleans up the line so -" that does not happen. -" The echoed line is too long if it is wider than the width of the -" window, minus cmdline space taken up by the ruler and showcmd -" features. -function! tlib#notify#TrimMessage(message) "{{{3 - let filler = '...' - - " If length of message with tabs converted into spaces + length of - " line number + 2 (for the ': ' that follows the line number) is - " greater than the width of the screen, truncate in the middle - let to_fill = &columns - " TLogVAR to_fill - - " Account for space used by elements in the command-line to avoid - " 'Hit ENTER' prompts. - " If showcmd is on, it will take up 12 columns. - " If the ruler is enabled, but not displayed in the statusline, it - " will in its default form take 17 columns. If the user defines a - " custom &rulerformat, they will need to specify how wide it is. - if has('cmdline_info') - if &showcmd - let to_fill -= 12 - else - let to_fill -= 1 - endif - " TLogVAR &showcmd, to_fill - - " TLogVAR &laststatus, &ruler, &rulerformat - if &ruler - if &laststatus == 0 || winnr('$') == 1 - if has('statusline') - if &rulerformat == '' - " default ruler is 17 chars wide - let to_fill -= 17 - elseif exists('g:MP_rulerwidth') - let to_fill -= g:MP_rulerwidth - else - " tml: fallback: guess length - let to_fill -= strlen(&rulerformat) - endif - else - endif - endif - else - endif - else - let to_fill -= 1 - endif - - " TLogVAR to_fill - " TLogDBG strlen(a:message) - if strlen(a:message) > to_fill - let front = to_fill / 2 - 1 - let back = front - if to_fill % 2 == 0 | let back -= 1 | endif - return strpart(a:message, 0, front) . filler . - \strpart(a:message, strlen(a:message) - back) - else - return a:message - endif -endfunction - - -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/number.vim b/sources_non_forked/tlib/autoload/tlib/number.vim deleted file mode 100644 index 94fde02f..00000000 --- a/sources_non_forked/tlib/autoload/tlib/number.vim +++ /dev/null @@ -1,30 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 14 - - -function! tlib#number#ConvertBase(num, base, ...) "{{{3 - let rtype = a:0 >= 1 ? a:1 : 'string' - " TLogVAR a:num, a:base, rtype - let rv = [] - let num = 0.0 + a:num - while floor(num) > 0.0 - let div = floor(num / a:base) - let num1 = float2nr(num - a:base * div) - if a:base <= 10 - call insert(rv, num1) - elseif a:base == 16 - let char = "0123456789ABCDEF"[num1] - call insert(rv, char) - endif - let num = num / a:base - endwh - " TLogVAR rv - if rtype == 'list' - return rv - else - return join(rv, '') - endif -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/paragraph.vim b/sources_non_forked/tlib/autoload/tlib/paragraph.vim deleted file mode 100644 index dd0d1123..00000000 --- a/sources_non_forked/tlib/autoload/tlib/paragraph.vim +++ /dev/null @@ -1,97 +0,0 @@ -" paragraph.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2009-10-26. -" @Last Change: 2011-04-03. -" @Revision: 62 - -let s:save_cpo = &cpo -set cpo&vim - - -" Return an object describing a |paragraph|. -function! tlib#paragraph#GetMetric() "{{{3 - let sp = {'text_start': line("'{") + 1} - if line("'}") == line("$") - let sp.last = 1 - let sp.text_end = line("'}") - if line("'{") == 1 - let sp.ws_start = 0 - let sp.ws_end = 0 - let sp.top = sp.text_start - let sp.bottom = sp.text_end - else - let sp.ws_start = prevnonblank(line("'{")) + 1 - let sp.ws_end = line("'{") - let sp.top = sp.ws_start - let sp.bottom = sp.text_end - endif - else - let sp.last = 0 - let sp.text_end = line("'}") - 1 - let sp.ws_start = line("'}") - for i in range(line("'}"), line('$')) - if getline(i) =~ '\w' - let sp.ws_end = i - 1 - break - elseif i == line("$") - let sp.ws_end = i - endif - endfor - let sp.top = sp.text_start - let sp.bottom = sp.ws_end - endif - return sp -endf - - -" This function can be used with the tinymode plugin to move around -" paragraphs. -" -" Example configuration: > -" -" call tinymode#EnterMap("para_move", "gp") -" call tinymode#ModeMsg("para_move", "Move paragraph: j/k") -" call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") -" call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") -" call tinymode#ModeArg("para_move", "owncount", 1) -function! tlib#paragraph#Move(direction, count) - " TLogVAR a:direction, a:count - let mycount = empty(a:count) ? 1 : a:count - for i in range(1, mycount) - let para = tlib#paragraph#GetMetric() - " TLogVAR para - let text = getline(para.text_start, para.text_end) - let ws = getline(para.ws_start, para.ws_end) - " TLogVAR text, ws - exec para.top .','. para.bottom .'delete' - if a:direction == "Down" - let other = tlib#paragraph#GetMetric() - let target = other.bottom + 1 - if other.last - let lines = ws + text - let pos = target + len(ws) - else - let lines = text + ws - let pos = target - endif - elseif a:direction == "Up" - if !para.last - norm! { - endif - let other = tlib#paragraph#GetMetric() - let target = other.text_start - let lines = text + ws - let pos = target - endif - " TLogVAR other, target - " TLogVAR lines - call append(target - 1, lines) - exec pos - endfor -endf - - -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/persistent.vim b/sources_non_forked/tlib/autoload/tlib/persistent.vim deleted file mode 100644 index de3d4878..00000000 --- a/sources_non_forked/tlib/autoload/tlib/persistent.vim +++ /dev/null @@ -1,47 +0,0 @@ -" persistent.vim -- Persistent data -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2012-05-11. -" @Last Change: 2012-05-11. -" @Revision: 12 - -" The directory for persistent data files. If empty, use -" |tlib#dir#MyRuntime|.'/share'. -TLet g:tlib_persistent = '' - - -" :display: tlib#persistent#Dir(?mode = 'bg') -" Return the full directory name for persistent data files. -function! tlib#persistent#Dir() "{{{3 - TVarArg ['mode', 'bg'] - let dir = tlib#var#Get('tlib_persistent', mode) - if empty(dir) - let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'share']) - endif - return dir -endf - -" :def: function! tlib#persistent#Filename(type, ?file=%, ?mkdir=0) -function! tlib#persistent#Filename(type, ...) "{{{3 - " TLogDBG 'bufname='. bufname('.') - let file = a:0 >= 1 ? a:1 : '' - let mkdir = a:0 >= 2 ? a:2 : 0 - return tlib#cache#Filename(a:type, file, mkdir, tlib#persistent#Dir()) -endf - -function! tlib#persistent#Get(...) "{{{3 - return call('tlib#cache#Get', a:000) -endf - -function! tlib#persistent#MTime(cfile) "{{{3 - return tlib#cache#MTime(a:cfile) -endf - -function! tlib#persistent#Value(...) "{{{3 - return call('tlib#cache#Value', a:000) -endf - -function! tlib#persistent#Save(cfile, dictionary) "{{{3 - call tlib#cache#Save(a:cfile, a:dictionary) -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/progressbar.vim b/sources_non_forked/tlib/autoload/tlib/progressbar.vim deleted file mode 100644 index e739eb3c..00000000 --- a/sources_non_forked/tlib/autoload/tlib/progressbar.vim +++ /dev/null @@ -1,72 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 72 - -let s:statusline = [] -let s:laststatus = [] -let s:max = [] -let s:format = [] -let s:width = [] -let s:value = [] -let s:timestamp = -1 - -" EXAMPLE: > -" call tlib#progressbar#Init(20) -" try -" for i in range(20) -" call tlib#progressbar#Display(i) -" call DoSomethingThatTakesSomeTime(i) -" endfor -" finally -" call tlib#progressbar#Restore() -" endtry -function! tlib#progressbar#Init(max, ...) "{{{3 - TVarArg ['format', '%s'], ['width', 10] - call insert(s:statusline, &statusline) - call insert(s:laststatus, &laststatus) - call insert(s:max, a:max) - call insert(s:format, format) - call insert(s:width, width) - call insert(s:value, -1) - let &laststatus = 2 - let s:timestamp = localtime() -endf - - -function! tlib#progressbar#Display(value, ...) "{{{3 - TVarArg 'extra', ['always', 0] - let ts = localtime() - if !always && ts == s:timestamp - return - else - let s:timestamp = ts - endif - let val = a:value * s:width[0] / s:max[0] - if always || val != s:value[0] - let s:value[0] = val - let pbl = repeat('#', val) - let pbr = repeat('.', s:width[0] - val) - let txt = printf(s:format[0], '['.pbl.pbr.']') . extra - let &l:statusline = txt - " TLogDBG txt - redrawstatus - " redraw - " call tlib#notify#Echo(txt) - endif -endf - - -function! tlib#progressbar#Restore() "{{{3 - let &l:statusline = remove(s:statusline, 0) - let &laststatus = remove(s:laststatus, 0) - redrawstatus - " redraw - " echo - call remove(s:max, 0) - call remove(s:format, 0) - call remove(s:width, 0) - call remove(s:value, 0) -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/qfl.vim b/sources_non_forked/tlib/autoload/tlib/qfl.vim deleted file mode 100644 index 7d4b442d..00000000 --- a/sources_non_forked/tlib/autoload/tlib/qfl.vim +++ /dev/null @@ -1,314 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: https://github.com/tomtom -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-13 -" @Revision: 59 - -" :nodoc: -TLet g:tlib#qfl#world = { - \ 'type': 'mi', - \ 'query': 'Select entry', - \ 'pick_last_item': 0, - \ 'resize_vertical': 0, - \ 'resize': 20, - \ 'scratch': '__TLibQFL__', - \ 'tlib_UseInputListScratch': 'call tlib#qfl#InitListBuffer(world)', - \ 'key_handlers': [ - \ {'key': 5, 'agent': 'tlib#qfl#AgentWithSelected', 'key_name': '', 'help': 'Run a command on selected lines'}, - \ {'key': 16, 'agent': 'tlib#qfl#AgentPreviewQFE', 'key_name': '', 'help': 'Preview'}, - \ {'key': 60, 'agent': 'tlib#qfl#AgentGotoQFE', 'key_name': '<', 'help': 'Jump (don''t close the list)'}, - \ {'key': 19, 'agent': 'tlib#qfl#AgentSplitBuffer', 'key_name': '', 'help': 'Show in split buffer'}, - \ {'key': 20, 'agent': 'tlib#qfl#AgentTabBuffer', 'key_name': '', 'help': 'Show in tab'}, - \ {'key': 22, 'agent': 'tlib#qfl#AgentVSplitBuffer', 'key_name': '', 'help': 'Show in vsplit buffer'}, - \ {'key': 12, 'agent': 'tlib#qfl#AgentEditLine', 'key_name': '', 'help': 'Edit selected line(s)'}, - \ {'key': "\", 'agent': 'tlib#qfl#SetFollowCursor', 'key_name': '', 'help': 'Toggle trace cursor'}, - \ ], - \ 'return_agent': 'tlib#qfl#AgentEditQFE', - \ } - - -function! tlib#qfl#FormatQFLE(qfe) dict abort "{{{3 - let filename = tlib#qfl#QfeFilename(a:qfe) - if get(self, 'qfl_short_filename', '') - let filename = pathshorten(filename) - endif - return printf("%s|%d| %s", filename, a:qfe.lnum, get(a:qfe, "text")) -endf - - -function! tlib#qfl#QfeFilename(qfe) abort "{{{3 - let filename = get(a:qfe, 'filename') - if empty(filename) - let filename = bufname(get(a:qfe, 'bufnr')) - endif - return filename -endf - - -function! tlib#qfl#InitListBuffer(world) "{{{3 - let set_syntax = get(a:world, 'set_syntax', 'tlib#qfl#SetSyntax') - call call(set_syntax, [], a:world) - if has('balloon_eval') - setlocal ballooneval balloonexpr=tlib#qfl#Balloon() - endif -endf - - -function! tlib#qfl#SetSyntax() dict abort "{{{3 - let syntax = get(self, 'qfl_list_syntax', '') - let nextgroup = get(self, 'qfl_list_syntax_nextgroup', '') - " TLogVAR syntax, nextgroup - if !empty(syntax) - exec printf('runtime syntax/%s.vim', syntax) - endif - syn match TTagedFilesFilename /\%(\f\+\| \)\+\ze|\d\+| / nextgroup=TTagedFilesLNum - if !empty(nextgroup) - exec 'syn match TTagedFilesLNum /|\d\+|\s\+/ nextgroup='. nextgroup - else - syn match TTagedFilesLNum /|\d\+|/ - endif - hi def link TTagedFilesFilename Directory - hi def link TTagedFilesLNum LineNr -endf - - -function! tlib#qfl#Balloon() "{{{3 - let world = getbufvar(v:beval_bufnr, 'tlibDisplayListWorld') - let current = max([1, world.offset]) + v:beval_lnum - 1 - if current > len(world.table) - let current = len(world.table) - endif - let baseidx = world.GetBaseIdx0(current) - " TLogVAR world.offset, v:beval_lnum, current, baseidx - let item = world.data[baseidx] - let bufnr = get(item, 'bufnr', 0) - let bufname = get(item, 'filename', '') - if bufnr == 0 && !empty(bufname) - let bufnr = bufnr(bufname) - endif - if empty(bufname) && bufnr > 0 - let bufname = bufname(bufnr) - endif - " TLogVAR item - if bufnr == 0 - return '' - else - let lines = [printf("%d#%d: %s", bufnr, item.lnum, bufname)] - if has('balloon_multiline') - let desc = {'nr': 'Error number', 'type': 'Error type', 'text': ''} - for key in ['nr', 'type', 'text'] - if has_key(item, key) && !empty(item[key]) - let keydesc = get(desc, key, key) - if empty(keydesc) - let text = item[key] - else - let text = printf("%s: %s", key, item[key]) - endif - call add(lines, text) - endif - endfor - endif - return join(lines, "\n") - endif - " v:beval_bufnr number of the buffer in which balloon is going to show - " v:beval_winnr number of the window - " v:beval_lnum line number - " v:beval_col column number (byte index) - " v:beval_text word under or after the mouse pointer -endf - - -function! tlib#qfl#AgentEditQFE(world, selected, ...) "{{{3 - TVarArg ['cmd_edit', ''], ['cmd_buffer', ''] - " TVarArg ['cmd_edit', 'edit'], ['cmd_buffer', 'buffer'] - " TLogVAR a:selected - if empty(a:selected) - call a:world.RestoreOrigin() - " call a:world.ResetSelected() - else - call a:world.RestoreOrigin() - for idx in a:selected - let idx -= 1 - " TLogVAR idx - if idx >= 0 - " TLogVAR a:world.data - " call tlog#Debug(string(map(copy(a:world.data), 'v:val.bufnr'))) - " TLogVAR idx, a:world.data[idx] - let qfe = a:world.data[idx] - " let back = a:world.SwitchWindow('win') - " TLogVAR cmd_edit, cmd_buffer, qfe - let fn = tlib#qfl#QfeFilename(qfe) - " TLogVAR cmd_edit, cmd_buffer, fn - if empty(cmd_edit) && empty(cmd_buffer) - if tlib#file#Edit(fn) - call tlib#buffer#ViewLine(qfe.lnum) - endif - else - call tlib#file#With(cmd_edit, cmd_buffer, [fn], a:world) - " TLogDBG bufname('%') - " TLogVAR &filetype - call tlib#buffer#ViewLine(qfe.lnum) - " call a:world.SetOrigin() - " exec back - endif - endif - endfor - endif - return a:world -endf - - -function! tlib#qfl#AgentPreviewQFE(world, selected) "{{{3 - " TLogVAR a:selected - let back = a:world.SwitchWindow('win') - call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0]) - exec back - redraw - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#qfl#AgentGotoQFE(world, selected) "{{{3 - if !empty(a:selected) - if a:world.win_wnr != winnr() - let world = tlib#agent#Suspend(a:world, a:selected) - exec a:world.win_wnr .'wincmd w' - endif - call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0]) - endif - return a:world -endf - - -function! tlib#qfl#AgentWithSelected(world, selected, ...) "{{{3 - let cmd = a:0 >= 1 ? a:1 : input('Ex command: ', '', 'command') - let world = a:world - if !empty(cmd) - let world = tlib#qfl#RunCmdOnSelected(world, a:selected, cmd) - else - let world.state = 'redisplay' - endif - return world -endf - - -function! tlib#qfl#RunCmdOnSelected(world, selected, cmd, ...) "{{{3 - let close_scratch = a:0 >= 1 ? a:1 : 1 - if close_scratch - call a:world.CloseScratch() - endif - " TLogVAR a:cmd - for entry in a:selected - " TLogVAR entry, a:world.GetBaseItem(entry) - call tlib#qfl#AgentEditQFE(a:world, [entry]) - " TLogDBG bufname('%') - exec a:cmd - " let item = a:world.data[a:world.GetBaseIdx(entry - 1)] - " <+TODO+> - let item = a:world.data[entry - 1] - " TLogVAR entry, item, getline('.') - if has_key(a:world, 'GetBufferLines') - let lines = a:world.GetBufferLines('.', '.') - else - let lines = getline('.', '.') - endif - let item['text'] = tlib#string#Strip(lines[0]) - endfor - if has_key(a:world, 'AfterRunCmd') - if bufnr('%') == a:world.bufnr - call a:world.AfterRunCmd() - else - " <+TODO+> Run in other buffer - endif - endif - " call s:FormatBase(a:world) - call a:world.RestoreOrigin() - let a:world.state = 'reset' - return a:world -endf - - -function! tlib#qfl#AgentSplitBuffer(world, selected) "{{{3 - call a:world.CloseScratch() - return tlib#qfl#AgentEditQFE(a:world, a:selected, 'split', 'sbuffer') -endf - - -function! tlib#qfl#AgentTabBuffer(world, selected) "{{{3 - call a:world.CloseScratch() - return tlib#qfl#AgentEditQFE(a:world, a:selected, 'tabedit', 'tab sbuffer') -endf - - -function! tlib#qfl#AgentVSplitBuffer(world, selected) "{{{3 - call a:world.CloseScratch() - return tlib#qfl#AgentEditQFE(a:world, a:selected, 'vertical split', 'vertical sbuffer') -endf - - -" function! tlib#qfl#AgentOpenBuffer(world, selected) "{{{3 -" endf - - -function! tlib#qfl#AgentEditLine(world, selected) "{{{3 - call a:world.CloseScratch() - let cmd = 'call tlib#qfl#EditLine(".")' - return tlib#qfl#RunCmdOnSelected(a:world, a:selected, cmd) - let a:world.state = 'reset' - return a:world -endf - - -function! tlib#qfl#EditLine(lnum) "{{{3 - call inputsave() - let line = input('', getline(a:lnum)) - call inputrestore() - if !empty(line) - call setline(line(a:lnum), line) - endif -endf - - -function! tlib#qfl#SetFollowCursor(world, selected) "{{{3 - if empty(a:world.follow_cursor) - let a:world.follow_cursor = 'tlib#qfl#AgentPreviewQFE' - else - let a:world.follow_cursor = '' - endif - let a:world.state = 'redisplay' - return a:world -endf - - -function! tlib#qfl#QflList(list, ...) abort "{{{3 - TVarArg ['world_dict', {}], ['anyway', 0], ['suspended', 0] - Tlibtrace 'tlib', world_dict, anyway, suspended - " TLogVAR a:list, world_dict, anyway, suspended - if !anyway && empty(a:list) - return - endif - let world = copy(g:tlib#qfl#world) - if !empty(world_dict) - let world = tlib#eval#Extend(world, world_dict) - endif - " TLogVAR world - let world = tlib#World#New(world) - " echom "DBG world" string(sort(keys(world))) - let world.data = copy(a:list) - if !has_key(world, 'format_data') - let world.format_data = 'tlib#qfl#FormatQFLE' - endif - " TLogVAR world - " TLogVAR world.data - " call s:FormatBase(world) - " TLogVAR world.base - return tlib#input#ListW(world, suspended ? 'hibernate' : '') -endf - - -function! tlib#qfl#Browse(...) abort "{{{3 - let list = getqflist() - return call(function('tlib#qfl#QflList'), [list] + a:000) -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/rx.vim b/sources_non_forked/tlib/autoload/tlib/rx.vim deleted file mode 100644 index 83899838..00000000 --- a/sources_non_forked/tlib/autoload/tlib/rx.vim +++ /dev/null @@ -1,60 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 113 - - -" :def: function! tlib#rx#Escape(text, ?magic='m') -" magic can be one of: m, M, v, V -" See :help 'magic' -function! tlib#rx#Escape(text, ...) "{{{3 - TVarArg 'magic' - if empty(magic) - let magic = 'm' - endif - if magic =~# '^\\\?m$' - return escape(a:text, '^$.*\[]~') - elseif magic =~# '^\\\?M$' - return escape(a:text, '^$\') - elseif magic =~# '^\\\?V$' - return escape(a:text, '\') - elseif magic =~# '^\\\?v$' - return substitute(a:text, '[^0-9a-zA-Z_]', '\\&', 'g') - else - echoerr 'tlib: Unsupported magic type' - return a:text - endif -endf - -" :def: function! tlib#rx#EscapeReplace(text, ?magic='m') -" Escape return |sub-replace-special|. -function! tlib#rx#EscapeReplace(text, ...) "{{{3 - TVarArg ['magic', 'm'] - if magic ==# 'm' || magic ==# 'v' - return escape(a:text, '\&~') - elseif magic ==# 'M' || magic ==# 'V' - return escape(a:text, '\') - else - echoerr 'magic must be one of: m, v, M, V' - endif -endf - - -function! tlib#rx#Suffixes(...) "{{{3 - TVarArg ['magic', 'm'] - let sfx = split(&suffixes, ',') - call map(sfx, 'tlib#rx#Escape(v:val, magic)') - if magic ==# 'v' - return '('. join(sfx, '|') .')$' - elseif magic ==# 'V' - return '\('. join(sfx, '\|') .'\)\$' - else - return '\('. join(sfx, '\|') .'\)$' - endif -endf - - -function! tlib#rx#LooksLikeRegexp(text) abort "{{{3 - return a:text =~ '[.?*+{}\[\]]' -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/scratch.vim b/sources_non_forked/tlib/autoload/tlib/scratch.vim deleted file mode 100644 index c9df64d3..00000000 --- a/sources_non_forked/tlib/autoload/tlib/scratch.vim +++ /dev/null @@ -1,136 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 255 - - -" Scratch window position. By default the list window is opened on the -" bottom. Set this variable to 'topleft' or '' to change this behaviour. -" See |tlib#input#List()|. -TLet g:tlib_scratch_pos = 'botright' - -" If you want the scratch buffer to be fully removed, you might want to -" set this variable to 'wipe'. -" See also https://github.com/tomtom/tlib_vim/pull/16 -TLet g:tlib#scratch#hidden = 'hide' - - -" :def: function! tlib#scratch#UseScratch(?keyargs={}) -" Display a scratch buffer (a buffer with no file). See :TScratch for an -" example. -" Return the scratch buffer's number. -" Values for keyargs: -" scratch_split ... 1: split, 0: window, -1: tab -function! tlib#scratch#UseScratch(...) "{{{3 - exec tlib#arg#Let([['keyargs', {}]]) - " TLogDBG string(keys(keyargs)) - let id = get(keyargs, 'scratch', '__Scratch__') - " TLogVAR id, bufwinnr(id) - " TLogVAR bufnr(id), bufname(id) - " TLogVAR 1, winnr(), bufnr('%'), bufname("%") - if bufwinnr(id) != -1 - " echom 'DBG noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' - exec 'noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' - " TLogVAR "reuse", bufnr("%"), bufname("%") - else - let winpos = '' - let bn = bufnr(id) - let wpos = get(keyargs, 'scratch_pos', g:tlib_scratch_pos) - " TLogVAR keyargs.scratch_vertical - if get(keyargs, 'scratch_vertical') - let wpos .= ' vertical' - let winpos = tlib#fixes#Winpos() - endif - " TLogVAR wpos - let scratch_split = get(keyargs, 'scratch_split', 1) - if bn != -1 - " TLogVAR bn - let wn = bufwinnr(bn) - if wn != -1 - " TLogVAR wn - exec 'noautocmd keepalt keepj' (wn .'wincmd w') - else - if scratch_split == 1 - let cmd = wpos.' sbuffer!' - elseif scratch_split == -1 - let cmd = wpos.' tab sbuffer!' - else - let cmd = 'buffer!' - endif - " TLogVAR cmd, bn - silent exec 'noautocmd keepalt keepj' cmd bn - endif - else - " TLogVAR id - if scratch_split == 1 - let cmd = wpos.' split' - elseif scratch_split == -1 - let cmd = wpos.' tab split' - else - let cmd = 'edit' - endif - " TLogVAR cmd, id - silent exec 'noautocmd keepalt keepj' cmd escape(id, '%#\ ') - " silent exec 'split '. id - endif - let ft = get(keyargs, 'scratch_filetype', '') - " TLogVAR ft, winpos - if !empty(winpos) - exec winpos - endif - setlocal buftype=nofile - let &l:bufhidden = get(keyargs, 'scratch_hidden', g:tlib#scratch#hidden) - setlocal noswapfile - setlocal nobuflisted - setlocal foldmethod=manual - setlocal foldcolumn=0 - setlocal nospell - setlocal modifiable - setlocal noreadonly - " TLogVAR &ft, ft - if !empty(ft) - let &l:ft = ft - endif - endif - let keyargs.scratch = bufnr('%') - let keyargs.scratch_tabpagenr = tabpagenr() - let keyargs.scratch_winnr = winnr() - " TLogVAR 2, winnr(), bufnr('%'), bufname("%"), keyargs.scratch - return keyargs.scratch -endf - - -" Close a scratch buffer as defined in keyargs (usually a World). -" Return 1 if the scratch buffer is closed (or if it already was -" closed). -function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3 - TVarArg ['reset_scratch', 1] - let scratch = get(a:keyargs, 'scratch', '') - " TLogVAR scratch, reset_scratch - " TLogDBG string(tlib#win#List()) - if !empty(scratch) && winnr('$') > 1 - let wn = bufwinnr(scratch) - " TLogVAR wn - try - if wn != -1 - " TLogDBG winnr() - let wb = tlib#win#Set(wn) - let winpos = tlib#fixes#Winpos() - wincmd c - if get(a:keyargs, 'scratch_vertical') && !empty(winpos) - exec winpos - endif - " exec wb - " redraw - " TLogVAR winnr() - endif - return 1 - finally - if reset_scratch - let a:keyargs.scratch = '' - endif - endtry - endif - return 0 -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/signs.vim b/sources_non_forked/tlib/autoload/tlib/signs.vim deleted file mode 100644 index 16646807..00000000 --- a/sources_non_forked/tlib/autoload/tlib/signs.vim +++ /dev/null @@ -1,103 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2009-03-12. -" @Last Change: 2011-03-10. -" @Revision: 0.0.45 - -let s:save_cpo = &cpo -set cpo&vim - - -let s:base = 2327 -let s:register = {} - - -" Clear all signs with name SIGN. -function! tlib#signs#ClearAll(sign) "{{{3 - " TLog a:sign - for bn in keys(s:register) - let idxs = keys(s:register) - call filter(idxs, 's:register[v:val].sign == a:sign') - " TLogVAR bns - for idx in idxs - exec 'sign unplace '. idx .' buffer='. s:register[idx].bn - call remove(s:register, idx) - endfor - endfor -endf - - -" Clear all signs with name SIGN in buffer BUFNR. -function! tlib#signs#ClearBuffer(sign, bufnr) "{{{3 - for bn in keys(s:register) - let idxs = keys(s:register) - call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == a:bufnr') - " TLogVAR bns - for idx in idxs - exec 'sign unplace '. idx .' buffer='. s:register[idx].bn - call remove(s:register, idx) - endfor - endfor -endf - - -" function! tlib#signs#Clear(sign, list) "{{{3 -" " TLogVAR a:sign -" let done = [] -" for item in a:list -" let bn = get(item, 'bufnr', -1) -" if index(done, bn) == -1 -" let idxs = keys(s:register) -" call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == bn') -" for idx in idxs -" exec 'sign unplace '. idx .' buffer='. s:register[idx].bn -" call remove(s:register, idx) -" endfor -" call add(done, bn) -" endif -" endfor -" endf - - -" Add signs for all locations in LIST. LIST must adhere with the -" quickfix list format (see |getqflist()|; only the fields lnum and -" bufnr are required). -" -" list:: a quickfix or location list -" sign:: a sign defined with |:sign-define| -function! tlib#signs#Mark(sign, list) "{{{3 - " TLogVAR a:sign - for item in a:list - let idx = s:SignId(item) - if idx >= 0 - let lnum = get(item, 'lnum', 0) - if lnum > 0 - let bn = get(item, 'bufnr') - exec ':sign place '. idx .' line='. lnum .' name='. a:sign .' buffer='. bn - let s:register[idx] = {'sign': a:sign, 'bn': bn} - endif - endif - endfor -endf - - -function! s:SignId(item) "{{{3 - " TLogVAR a:item - " let bn = bufnr('%') - let bn = get(a:item, 'bufnr', -1) - if bn == -1 - return -1 - else - let idx = s:base + bn * 500 - while has_key(s:register, idx) - let idx += 1 - endwh - return idx - endif -endf - - - -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/string.vim b/sources_non_forked/tlib/autoload/tlib/string.vim deleted file mode 100644 index e5f8943a..00000000 --- a/sources_non_forked/tlib/autoload/tlib/string.vim +++ /dev/null @@ -1,158 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 121 - - -" :def: function! tlib#string#RemoveBackslashes(text, ?chars=' ') -" Remove backslashes from text (but only in front of the characters in -" chars). -function! tlib#string#RemoveBackslashes(text, ...) "{{{3 - exec tlib#arg#Get(1, 'chars', ' ') - " TLogVAR chars - let rv = substitute(a:text, '\\\(['. chars .']\)', '\1', 'g') - return rv -endf - - -" :display: tlib#string#Chomp(string, ?max=0) -function! tlib#string#Chomp(string, ...) "{{{3 - let quant = a:0 >= 1 ? '\{,'. a:1 .'}' : '\+' - return substitute(a:string, '[[:cntrl:][:space:]]'. quant .'$', '', '') -endf - - -function! tlib#string#Format(template, dict) "{{{3 - let parts = split(a:template, '\ze%\({.\{-}}\|.\)') - let out = [] - for part in parts - let ml = matchlist(part, '^%\({\(.\{-}\)}\|\(.\)\)\(.*\)$') - if empty(ml) - let rest = part - else - let var = empty(ml[2]) ? ml[3] : ml[2] - let rest = ml[4] - if has_key(a:dict, var) - call add(out, a:dict[var]) - elseif var == '%%' - call add(out, '%') - else - call add(out, ml[1]) - endif - endif - call add(out, rest) - endfor - return join(out, '') -endf - - -" This function deviates from |printf()| in certain ways. -" Additional items: -" %{rx} ... insert escaped regexp -" %{fuzzyrx} ... insert typo-tolerant regexp -function! tlib#string#Printf1(format, string) "{{{3 - let s = split(a:format, '%.\zs') - " TLogVAR s - return join(map(s, 's:PrintFormat(v:val, a:string)'), '') -endf - -function! s:PrintFormat(format, string) "{{{3 - let cut = match(a:format, '%\({.\{-}}\|.\)$') - if cut == -1 - return a:format - else - let head = cut > 0 ? a:format[0 : cut - 1] : '' - let tail = a:format[cut : -1] - " TLogVAR head, tail - if tail == '%{fuzzyrx}' - let frx = [] - for i in range(len(a:string)) - if i > 0 - let pb = i - 1 - else - let pb = 0 - endif - let slice = tlib#rx#Escape(a:string[pb : i + 1]) - call add(frx, '['. slice .']') - call add(frx, '.\?') - endfor - let tail = join(frx, '') - elseif tail == '%{rx}' - let tail = tlib#rx#Escape(a:string) - elseif tail == '%%' - let tail = '%' - elseif tail == '%s' - let tail = a:string - endif - " TLogVAR tail - return head . tail - endif -endf -" function! tlib#string#Printf1(format, string) "{{{3 -" let n = len(split(a:format, '%\@ 0 -" let pb = i - 1 -" else -" let pb = 0 -" endif -" let slice = tlib#rx#Escape(a:string[pb : i + 1]) -" call add(frx, '['. slice .']') -" call add(frx, '.\?') -" endfor -" let f = s:RewriteFormatString(f, '%{fuzzyrx}', join(frx, '')) -" endif -" if f =~ '%\@= 1 ? a:1 : ',\s*' - let parts = split(a:text, '\\\@= 1 ? a:1 : !g:tlib#sys#windows - if !executable && !ignore_cyg - let executable = tlib#sys#IsCygwinBin(a:cmd) - " TLogVAR 2, executable - endif - let s:executables[a:cmd] = executable - endif - " echom "DBG s:executables[a:cmd]" s:executables[a:cmd] - return s:executables[a:cmd] -endf - - -if !exists('g:tlib#sys#check_cygpath') - " If true, check whether we have to convert a path via cyppath -- - " see |tlib#sys#MaybeUseCygpath| - let g:tlib#sys#check_cygpath = g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1) "{{{2 -endif - - -if !exists('g:tlib#sys#cygwin_path_rx') - " If a full windows filename (with slashes instead of backslashes) - " matches this |regexp|, it is assumed to be a cygwin executable. - let g:tlib#sys#cygwin_path_rx = '/cygwin/' "{{{2 -endif - - -if !exists('g:tlib#sys#cygwin_expr') - " For cygwin binaries, convert command calls using this vim - " expression. - let g:tlib#sys#cygwin_expr = '"bash -c ''". escape(%s, "''\\") ."''"' "{{{2 -endif - - -function! tlib#sys#GetCmd(cmd) "{{{3 - if !empty(g:tlib#sys#cygwin_expr) && tlib#sys#IsCygwinBin(matchstr(a:cmd, '^\S\+')) - let cmd = eval(printf(g:tlib#sys#cygwin_expr, string(a:cmd))) - " TLogVAR cmd - return cmd - else - return a:cmd - endif -endf - - -" If cmd seems to be a cygwin executable, use cygpath to convert -" filenames. This assumes that cygwin's which command returns full -" filenames for non-cygwin executables. -function! tlib#sys#MaybeUseCygpath(cmd) "{{{3 - " echom "DBG" a:cmd - if g:tlib#sys#check_cygpath && tlib#sys#IsCygwinBin(a:cmd) - return 'cygpath -u "%s"' - endif - return '' -endf - - -function! tlib#sys#ConvertPath(converter, filename) "{{{3 - return tlib#string#Chomp(system(printf(a:converter, shellescape(a:filename)))) -endf - - -let s:native_filenames = {} - -function! tlib#sys#FileArgs(cmd, files) "{{{3 - let cygpath = tlib#sys#MaybeUseCygpath(a:cmd) - " TLogVAR cygpath - if empty(cygpath) - return a:files - else - let files = map(copy(a:files), 'has_key(s:native_filenames, v:val) ? s:native_filenames[v:val] : tlib#sys#CygPath(v:val)') - return files - endif -endf - - -" Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it -" is a special file that should not be opened in vim. -function! tlib#sys#IsSpecial(filename) abort "{{{3 - return a:filename =~ g:tlib#sys#system_rx -endf - - -" Open filename with the default OS application (see -" |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. -" Returns 1 if successful or 0 otherwise. -function! tlib#sys#Open(filename) abort "{{{3 - Tlibtrace 'tlib', a:filename - if !empty(g:tlib#sys#system_browser) && tlib#sys#IsSpecial(a:filename) - try - let cmd = printf(g:tlib#sys#system_browser, escape(a:filename, ' %#!')) - Tlibtrace 'tlib', cmd - exec cmd - return 1 - catch - echohl ErrorMsg - echom v:exception - echohl NONE - endtry - endif - return 0 -endf - - -" :def: function! tlib#sys#SystemInDir(dir, expr, ?input='') -function! tlib#sys#SystemInDir(dir, ...) abort "{{{3 - call tlib#dir#CD(a:dir) - try - return call(function('system'), a:000) - finally - cd! - - endtry -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/tab.vim b/sources_non_forked/tlib/autoload/tlib/tab.vim deleted file mode 100644 index fa6bb8d0..00000000 --- a/sources_non_forked/tlib/autoload/tlib/tab.vim +++ /dev/null @@ -1,49 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 31 - - -" Return a dictionary of bufnumbers => [[tabpage, winnr] ...] -function! tlib#tab#BufMap() "{{{3 - let acc = {} - for t in range(tabpagenr('$')) - let bb = tabpagebuflist(t + 1) - for b in range(len(bb)) - let bn = bb[b] - let bd = [t + 1, b + 1] - if has_key(acc, bn) - call add(acc[bn], bd) - else - let acc[bn] = [bd] - endif - endfor - endfor - return acc -endf - - -" Find a buffer's window at some tab page. -function! tlib#tab#TabWinNr(buffer) "{{{3 - let bn = bufnr(a:buffer) - let bt = tlib#tab#BufMap() - let tn = tabpagenr() - let wn = winnr() - let bc = get(bt, bn) - if !empty(bc) - for [t, w] in bc - if t == tn - return [t, w] - endif - endfor - return bc[0] - endif -endf - - -function! tlib#tab#Set(tabnr) "{{{3 - if a:tabnr > 0 - exec a:tabnr .'tabnext' - endif -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/tag.vim b/sources_non_forked/tlib/autoload/tlib/tag.vim deleted file mode 100644 index e4239d37..00000000 --- a/sources_non_forked/tlib/autoload/tlib/tag.vim +++ /dev/null @@ -1,132 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 59 - - -" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. -TLet g:tlib_tags_extra = '' - -" Filter the tag description through |substitute()| for these filetypes. -" This applies only if the tag cmd field (see |taglist()|) is used. -" :nodefault: -TLet g:tlib_tag_substitute = { - \ 'java': [['\s*{\s*$', '', '']], - \ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']], - \ 'vim': [ - \ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''], - \ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''], - \ ['"\?\s*{{{\d.*$', '', ''], - \ ], - \ } - - -" :def: function! tlib#tag#Retrieve(rx, ?extra_tags=0) -" Get all tags matching rx. Basically, this function simply calls -" |taglist()|, but when extra_tags is true, the list of the tag files -" (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. -" -" Example use: -" If you want to include tags for, eg, JDK, normal tags use can become -" slow. You could proceed as follows: -" 1. Create a tags file for the JDK sources. When creating the tags -" file, make sure to include inheritance information and the like -" (command-line options like --fields=+iaSm --extra=+q should be ok). -" In this example, we want tags only for public methods (there are -" most likely better ways to do this): > -" ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src -" head -n 6 tags > tags0 -" grep access:public tags >> tags0 -" < 2. Make 'tags' include project specific tags files. In -" ~/vimfiles/after/ftplugin/java.vim insert: > -" let b:tlib_tags_extra = $JAVA_HOME .'/tags0' -" < 3. When this function is invoked as > -" echo tlib#tag#Retrieve('print') -" < it will return only project-local tags. If it is invoked as > -" echo tlib#tag#Retrieve('print', 1) -" < tags from the JDK will be included. -function! tlib#tag#Retrieve(rx, ...) "{{{3 - TVarArg ['extra_tags', 0] - " TLogVAR a:rx, extra_tags - if extra_tags - let tags_orig = &l:tags - if empty(tags_orig) - setlocal tags< - endif - try - let more_tags = tlib#var#Get('tlib_tags_extra', 'bg') - if !empty(more_tags) - let &l:tags .= ','. more_tags - endif - let taglist = taglist(a:rx) - finally - let &l:tags = tags_orig - endtry - else - let taglist = taglist(a:rx) - endif - return taglist -endf - - -" Retrieve tags that meet the constraints (a dictionnary of fields and -" regexp, with the exception of the kind field which is a list of chars). -" For the use of the optional use_extra argument see -" |tlib#tag#Retrieve()|. -" :def: function! tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) -function! tlib#tag#Collect(constraints, ...) "{{{3 - TVarArg ['use_extra', 0], ['match_end', 1], ['match_front', 1] - " TLogVAR a:constraints, use_extra - let rx = get(a:constraints, 'name', '') - if empty(rx) || rx == '*' - let rx = '.' - else - let rxl = ['\C'] - if match_front - call add(rxl, '^') - endif - " call add(rxl, tlib#rx#Escape(rx)) - call add(rxl, rx) - if match_end - call add(rxl, '$') - endif - let rx = join(rxl, '') - endif - " TLogVAR rx, use_extra - let tags = tlib#tag#Retrieve(rx, use_extra) - " TLogDBG len(tags) - for [field, rx] in items(a:constraints) - if !empty(rx) && rx != '*' - " TLogVAR field, rx - if field == 'kind' - call filter(tags, 'v:val.kind =~ "['. rx .']"') - elseif field != 'name' - call filter(tags, '!empty(get(v:val, field)) && get(v:val, field) =~ rx') - endif - endif - endfor - " TLogVAR tags - return tags -endf - - -function! tlib#tag#Format(tag) "{{{3 - if has_key(a:tag, 'signature') - let name = a:tag.name . a:tag.signature - elseif a:tag.cmd[0] == '/' - let name = a:tag.cmd - let name = substitute(name, '^/\^\?\s*', '', '') - let name = substitute(name, '\s*\$\?/$', '', '') - let name = substitute(name, '\s\{2,}', ' ', 'g') - let tsub = tlib#var#Get('tlib_tag_substitute', 'bg') - if has_key(tsub, &filetype) - for [rx, rplc, sub] in tsub[&filetype] - let name = substitute(name, rx, rplc, sub) - endfor - endif - else - let name = a:tag.name - endif - return name -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/textobjects.vim b/sources_non_forked/tlib/autoload/tlib/textobjects.vim deleted file mode 100644 index fb4170e5..00000000 --- a/sources_non_forked/tlib/autoload/tlib/textobjects.vim +++ /dev/null @@ -1,45 +0,0 @@ -" textobjects.vim -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2010-01-09. -" @Last Change: 2010-01-10. -" @Revision: 0.0.29 - -let s:save_cpo = &cpo -set cpo&vim - - -" :tag: standard-paragraph -" Select a "Standard Paragraph", i.e. a text block followed by blank -" lines. Other than |ap|, the last paragraph in a document is handled -" just the same. -" -" The |text-object| can be accessed as "sp". Example: > -" -" vsp ... select the current standard paragraph -" -" Return 1, if the paragraph is the last one in the document. -function! tlib#textobjects#StandardParagraph() "{{{3 - if line("'}") == line('$') - norm! vip - return 1 - else - norm! vap - return 0 - endif -endf - - -function! tlib#textobjects#Init() "{{{3 - if !exists('s:tlib_done_textobjects') - " sp ... Standard paragraph (for use as |text-objects|). - vnoremap sp :call tlib#textobjects#StandardParagraph() - onoremap sp :normal Vsp - let s:tlib_done_textobjects = 1 - endif -endf - - -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/time.vim b/sources_non_forked/tlib/autoload/tlib/time.vim deleted file mode 100644 index 2273d555..00000000 --- a/sources_non_forked/tlib/autoload/tlib/time.vim +++ /dev/null @@ -1,67 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 36 - - -function! tlib#time#MSecs() "{{{3 - let rts = reltimestr(reltime()) - return substitute(rts, '\.', '', '') -endf - - -function! tlib#time#Now() "{{{3 - if has('reltime') - let rts = reltimestr(reltime()) - let rtl = map(split(rts, '\.'), 'str2nr(v:val)') - else - let rtl = [localtime()] - endif - return rtl -endf - - -function! tlib#time#FormatNow() "{{{3 - let rtl = tlib#time#Now() - if len(rtl) == 2 - let rts = strftime(g:tlib#date#date_format .' %H:%M:%S', rtl[0]) .'.'. rtl[1] - else - let rts = strftime(g:tlib#date#date_format .' %H:%M:%S', rtl[0]) - endif - return rts -endf - - -function! tlib#time#Diff(a, b, ...) "{{{3 - TVarArg ['resolution', 2] - let [as, am] = a:a - let [bs, bm] = a:b - let rv = 0 + (as - bs) - if resolution > 0 - let rv .= repeat('0', resolution) - let am = am[0 : resolution - 1] - let bm = bm[0 : resolution - 1] - let rv += (am - bm) - endif - return rv -endf - - -function! tlib#time#DiffMSecs(a, b, ...) "{{{3 - TVarArg ['resolution', 2] - if a:a == a:b - return 0 - endif - let a = printf('%30s', a:a[0 : -(7 - resolution)]) - let b = printf('%30s', a:b[0 : -(7 - resolution)]) - for i in range(0, 29) - if a[i] != b[i] - let a = a[i : -1] - let b = b[i : -1] - return a - b - endif - endfor - return 0 -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/trace.vim b/sources_non_forked/tlib/autoload/tlib/trace.vim deleted file mode 100644 index 0a98d1e9..00000000 --- a/sources_non_forked/tlib/autoload/tlib/trace.vim +++ /dev/null @@ -1,117 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: https://github.com/tomtom -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-23 -" @Revision: 134 - - -if !exists('g:tlib#trace#backtrace') - " The length of the backtrace that should be included in - " |tlib#trace#Print()|. - let g:tlib#trace#backtrace = 2 "{{{2 -endif - - -if !exists('g:tlib#trace#printf') - " The command used for printing traces from |tlib#trace#Print()|. - let g:tlib#trace#printf = 'echom %s' "{{{2 -endif - - -let s:trace_hl = {'error': 'ErrorMsg', 'fatal': 'ErrorMsg', 'warning': 'WarningMsg'} - - -" Set |g:tlib#trace#printf| to make |tlib#trace#Print()| print to -" `filename`. -function! tlib#trace#PrintToFile(filename) abort "{{{3 - let g:tlib#trace#printf = 'call writefile([%s], '. string(a:filename) .', "a")' -endf - - -" Set the tracing |regexp|. See |:Tlibtrace|. -" This will also call |tlib#trace#Enable()|. -" -" Examples: -" call tlib#trace#Set(["+foo", "-bar"]) -" call tlib#trace#Set("+foo,-bar") -function! tlib#trace#Set(vars) abort "{{{3 - call tlib#trace#Enable() - if type(a:vars) == 1 - let vars = tlib#string#SplitCommaList(a:vars, '[,[:space:]]\+') - else - let vars = a:vars - endif - for rx in vars - let rx1 = substitute(rx, '^[+-]', '', 'g') - if rx1 !~# '^\%(error\|fatal\)$' && s:trace_rx !~# '[(|]'. tlib#rx#Escape(rx1) .'\\' - " TLogVAR rx, rx1 - if rx =~ '^+' - let s:trace_rx = substitute(s:trace_rx, '\ze\\)\$', '\\|'. tlib#rx#EscapeReplace(rx1), '') - elseif rx =~ '^-' - let s:trace_rx = substitute(s:trace_rx, '\\|'. tlib#rx#Escape(rx1), '', '') - else - echohl WarningMsg - echom 'tlib#trace#Print: Unsupported syntax:' rx - echohl NONE - endif - endif - endfor - echom "SetTrace:" s:trace_rx -endf - - -function! tlib#trace#Backtrace(caller) abort "{{{3 - let caller = split(a:caller, '\.\.') - let start = max([0, len(caller) - g:tlib#trace#backtrace - 1]) - let caller = caller[start : -1] - return join(caller, '..') -endf - - -" Print the values of vars. The first value is a "guard" (see -" |:Tlibtrace|). -function! tlib#trace#Print(caller, vars, values) abort "{{{3 - let msg = ['TRACE'] - let guard = a:values[0] - if type(guard) == 0 - let cond = guard - else - let cond = guard =~# s:trace_rx - endif - " TLogVAR guard, cond, a:vars, a:values - if cond - call add(msg, guard) - call add(msg, tlib#time#FormatNow() .':') - if g:tlib#trace#backtrace > 0 - let bt = tlib#trace#Backtrace(a:caller) - if !empty(bt) - call add(msg, bt .':') - endif - endif - for i in range(1, len(a:vars) - 1) - let v = substitute(a:vars[i], ',$', '', '') - let r = string(a:values[i]) - call add(msg, v .'='. r .';') - endfor - exec printf(g:tlib#trace#printf, string(join(msg))) - endif -endf - - -" Enable tracing via |:Tlibtrace|. -function! tlib#trace#Enable() abort "{{{3 - if !exists('s:trace_rx') - let s:trace_rx = '^\%(error\)$' - " :nodoc: - command! -nargs=+ -bar Tlibtrace call tlib#trace#Print(expand(''), [], []) - endif -endf - - -" Disable tracing via |:Tlibtrace|. -function! tlib#trace#Disable() abort "{{{3 - " :nodoc: - command! -nargs=+ -bang -bar Tlibtrace : - unlet! s:trace_rx -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/type.vim b/sources_non_forked/tlib/autoload/tlib/type.vim deleted file mode 100644 index 455343f9..00000000 --- a/sources_non_forked/tlib/autoload/tlib/type.vim +++ /dev/null @@ -1,71 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-09-30. -" @Last Change: 2015-11-23. -" @Revision: 6 - - -function! tlib#type#IsNumber(expr) - return tlib#type#Is(a:expr, 0) -endf - - -function! tlib#type#IsString(expr) - return tlib#type#Is(a:expr, 1) -endf - - -function! tlib#type#IsFuncref(expr) - return tlib#type#Is(a:expr, 2) -endf - - -function! tlib#type#IsList(expr) - return tlib#type#Is(a:expr, 3) -endf - - -function! tlib#type#IsDictionary(expr) - return tlib#type#Is(a:expr, 4) -endf - - -function! tlib#type#Is(val, type) abort "{{{3 - if type(a:type) == 0 - let type = a:type - elseif a:type =~? '^n\%[umber]' - let type = 0 - elseif a:type =~? '^s\%[tring]' - let type = 1 - elseif a:type =~? '^fu\%[ncref]' - let type = 2 - elseif a:type =~? '^l\%[ist]' - let type = 3 - elseif a:type =~? '^d\%[ictionary]' - let type = 4 - elseif a:type =~? '^fl\%[oat]' - let type = 5 - else - throw 'tlib#type#Is: Unknown type: ' a:type - endif - " TLogVAR a:val, a:type, type, type(a:val), type(a:val) == a:type - return type(a:val) == type -endf - - -function! tlib#type#Are(vals, type) abort "{{{3 - return tlib#assert#Map(a:vals, 'tlib#type#Is(v:val,'. string(a:type) .')') -endf - - -function! tlib#type#Has(val, lst) abort "{{{3 - return tlib#assert#All(map(a:lst, 'has_key(a:val, v:val)')) -endf - - -function! tlib#type#Have(vals, lst) abort "{{{3 - return tlib#assert#Map(a:vals, 'tlib#type#Has(v:val,'. string(a:lst) .')') -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/url.vim b/sources_non_forked/tlib/autoload/tlib/url.vim deleted file mode 100644 index b948d48a..00000000 --- a/sources_non_forked/tlib/autoload/tlib/url.vim +++ /dev/null @@ -1,52 +0,0 @@ -" url.vim -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-06-30. -" @Last Change: 2011-03-10. -" @Revision: 0.0.28 - - -" TODO: These functions could use printf() now. - -" Decode an encoded URL. -function! tlib#url#Decode(url) "{{{3 - return substitute(a:url, '\(+\|%\(%\|\x\x\)\)', '\=tlib#url#DecodeChar(submatch(1))', 'g') -endf - - -" Decode a single character. -function! tlib#url#DecodeChar(char) "{{{3 - if a:char == '%%' - return '%' - elseif a:char == '+' - return ' ' - else - return nr2char("0x".a:char[1 : -1]) - endif -endf - - -" Encode a single character. -function! tlib#url#EncodeChar(char) "{{{3 - if a:char == '%' - return '%%' - elseif a:char == ' ' - return '+' - else - return printf("%%%X", char2nr(a:char)) - endif -endf - - -" Encode an URL. -function! tlib#url#Encode(url, ...) "{{{3 - TVarArg ['extrachars', ''] - let rx = '\([^a-zA-Z0-9_.'. extrachars .'-]\)' - " TLogVAR a:url, rx - let rv = substitute(a:url, rx, '\=tlib#url#EncodeChar(submatch(1))', 'g') - " TLogVAR rv - return rv -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/var.vim b/sources_non_forked/tlib/autoload/tlib/var.vim deleted file mode 100644 index dcd9264b..00000000 --- a/sources_non_forked/tlib/autoload/tlib/var.vim +++ /dev/null @@ -1,83 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 30 - - -" Define a variable called NAME if yet undefined. -" You can also use the :TLLet command. -" -" EXAMPLES: > -" exec tlib#var#Let('g:foo', 1) -" TLet g:foo = 1 -function! tlib#var#Let(name, val) "{{{3 - return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, string(a:val)) - " return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, a:val) -endf - - -" :def: function! tlib#var#EGet(var, namespace, ?default='') -" Retrieve a variable by searching several namespaces. -" -" EXAMPLES: > -" let g:foo = 1 -" let b:foo = 2 -" let w:foo = 3 -" echo eval(tlib#var#EGet('foo', 'vg')) => 1 -" echo eval(tlib#var#EGet('foo', 'bg')) => 2 -" echo eval(tlib#var#EGet('foo', 'wbg')) => 3 -function! tlib#var#EGet(var, namespace, ...) "{{{3 - let pre = [] - let post = [] - for namespace in split(a:namespace, '\zs') - let var = namespace .':'. a:var - call add(pre, printf('exists("%s") ? %s : (', var, var)) - call add(post, ')') - endfor - let default = a:0 >= 1 ? a:1 : '' - return join(pre) . string(default) . join(post) -endf - - -" :def: function! tlib#var#Get(var, namespace, ?default='') -" Retrieve a variable by searching several namespaces. -" -" EXAMPLES: > -" let g:foo = 1 -" let b:foo = 2 -" let w:foo = 3 -" echo tlib#var#Get('foo', 'bg') => 1 -" echo tlib#var#Get('foo', 'bg') => 2 -" echo tlib#var#Get('foo', 'wbg') => 3 -function! tlib#var#Get(var, namespace, ...) "{{{3 - let var_ = substitute(a:var, '#', '_', 'g') - for namespace in split(a:namespace, '\zs') - let vname = namespace == 'g' ? a:var : var_ - let var = namespace .':'. vname - if exists(var) - return {var} - endif - endfor - return a:0 >= 1 ? a:1 : '' -endf - - -" :def: function! tlib#var#List(rx, ?prefix='') -" Get a list of variables matching rx. -" EXAMPLE: -" echo tlib#var#List('tlib_', 'g:') -function! tlib#var#List(rx, ...) "{{{3 - TVarArg ['prefix', 'g:'] - if v:version >= 704 - exec 'let varlist = keys('. prefix .')' - else - redir => vars - silent! exec 'let '. prefix - redir END - let varlist = split(vars, '\n') - call map(varlist, 'matchstr(v:val, ''^\S\+'')') - endif - call filter(varlist, 'v:val =~ a:rx') - return varlist -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/vcs.vim b/sources_non_forked/tlib/autoload/tlib/vcs.vim deleted file mode 100644 index 15d051fa..00000000 --- a/sources_non_forked/tlib/autoload/tlib/vcs.vim +++ /dev/null @@ -1,189 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2012-03-08. -" @Last Change: 2015-11-07. -" @Revision: 190 - -scriptencoding utf-8 - - -" A dictionarie of supported VCS (currently: git, hg, svn, bzr). -" :display: g:tlib#vcs#def {...} -TLet g:tlib#vcs#def = { - \ 'git': { - \ 'dir': '.git', - \ 'ls': 'git ls-files --full-name', - \ 'ls.postprocess': '*tlib#vcs#GitLsPostprocess', - \ 'diff': 'git diff --no-ext-diff -U0 %s' - \ }, - \ 'hg': { - \ 'dir': '.hg', - \ 'diff': 'hg diff -U0 %s', - \ 'ls': 'hg manifest' - \ }, - \ 'svn': { - \ 'dir': '.svn', - \ 'diff': 'svn diff --diff-cmd diff --extensions -U0 %s', - \ }, - \ 'bzr': { - \ 'dir': '.bzr', - \ 'diff': 'bzr diff --diff-options=-U0 %s', - \ } - \ } - - -" A dictionary of custom executables for VCS commands. If the value is -" empty, support for that VCS will be removed. If no key is present, it -" is assumed that the VCS "type" is the name of the executable. -" :display: g:tlib#vcs#executables {...} -TLet g:tlib#vcs#executables = {} - - -" If non-empty, use it as a format string to check whether a VCS is -" installed on your computer. -TLet g:tlib#vcs#check = has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s' - - -if !empty(g:tlib#vcs#check) - for [s:cmd, s:def] in items(g:tlib#vcs#def) - if !has_key(g:tlib#vcs#executables, s:cmd) - let s:cmd1 = printf(g:tlib#vcs#check, s:cmd) - let g:tlib#vcs#executables[s:cmd] = executable(s:cmd1) ? s:cmd1 : '' - endif - endfor - unlet! s:cmd s:def s:cmd1 -endif - - -function! tlib#vcs#Executable(type) "{{{3 - return get(g:tlib#vcs#executables, a:type, '') -endf - - -function! tlib#vcs#FindVCS(filename) "{{{3 - let type = '' - let dir = '' - let dirname = fnamemodify(a:filename, isdirectory(a:filename) ? ':p' : ':p:h') - let path = escape(dirname, ';') .';' - " TLogVAR a:filename, dirname, path - Tlibtrace 'tlib', a:filename, path - let depth = -1 - for vcs in keys(g:tlib#vcs#def) - let subdir = g:tlib#vcs#def[vcs].dir - let vcsdir = finddir(subdir, path) - " TLogVAR vcs, subdir, vcsdir - Tlibtrace 'tlib', vcs, subdir, vcsdir - if !empty(vcsdir) - let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/')) - if vcsdir_depth > depth - let depth = vcsdir_depth - let type = vcs - let dir = vcsdir - " TLogVAR type, depth - endif - endif - endfor - Tlibtrace 'tlib', type, dir - " TLogVAR type, dir - if empty(type) - return ['', ''] - else - return [type, dir] - endif -endf - - -function! s:GetCmd(vcstype, cmd) - let vcsdef = get(g:tlib#vcs#def, a:vcstype, {}) - if has_key(vcsdef, a:cmd) - let cmd = vcsdef[a:cmd] - if cmd =~ '^\*' - let cmd = substitute(cmd, '^\*', '', '') - else - let bin = get(g:tlib#vcs#executables, a:vcstype, '') - if empty(bin) - let cmd = '' - elseif bin != a:vcstype - " let bin = escape(shellescape(bin), '\') - let bin = escape(bin, '\') - let cmd = substitute(cmd, '^.\{-}\zs'. escape(a:vcstype, '\'), bin, '') - endif - endif - return cmd - else - return '' - endif -endf - - -" :display: tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) -" Return the files under VCS. -function! tlib#vcs#Ls(...) "{{{3 - if a:0 >= 2 - let vcs = a:2 - else - let vcs = tlib#vcs#FindVCS(a:0 >= 1 ? a:1 : bufname('%')) - endif - Tlibtrace 'tlib', vcs, a:000 - " TLogVAR vcs - if !empty(vcs) - let [vcstype, vcsdir] = vcs - if has_key(g:tlib#vcs#def, vcstype) - let ls = s:GetCmd(vcstype, 'ls') - " TLogVAR ls - if !empty(ls) - let rootdir = fnamemodify(vcsdir, ':p:h:h') - " TLogVAR vcsdir, rootdir - if ls =~ '%s' - let cmd = printf(ls, shellescape(rootdir)) - else - let cmd = ls - endif - " TLogVAR cmd, getcwd() - Tlibtrace 'tlib', getcwd(), vcstype, vcsdir, rootdir, cmd - let filess = tlib#sys#SystemInDir(rootdir, cmd) - " TLogVAR filess - let files = split(filess, '\n') - let postprocess = s:GetCmd(vcstype, 'ls.postprocess') - if !empty(postprocess) - call map(files, 'call(postprocess, [v:val])') - endif - call map(files, 'join([rootdir, v:val], "/")') - " TLogVAR files - return files - endif - endif - endif - return [] -endf - - -" :display: tlib#vcs#Diff(filename, ?vcs=[type, dir]) -" Return the diff for "filename" -function! tlib#vcs#Diff(filename, ...) "{{{3 - let vcs = a:0 >= 1 ? a:1 : tlib#vcs#FindVCS(a:filename) - if !empty(vcs) - let [vcstype, vcsdir] = vcs - let diff = s:GetCmd(vcstype, 'diff') - if !empty(diff) - let cmd = printf(diff, shellescape(fnamemodify(a:filename, ':p'))) - let patch = system(cmd) - return patch - endif - endif - return [] -endf - - -function! tlib#vcs#GitLsPostprocess(filename) abort "{{{3 - if a:filename =~ '^".\{-}"$' - let filename = matchstr(a:filename, '^"\zs.\{-}\ze"$') - let filename = substitute(filename, '\%(\\\@= 1 ? a:1 : 0 - redir => oldfn - exec 'silent function' a:old - redir END - if exists('*'. a:new) - if overwrite > 0 - exec 'delfunction' a:new - elseif overwrite < 0 - throw 'tlib#vim##CopyFunction: Function already exists: '. a:old .' -> '. a:new - else - return - endif - endif - let fn = split(oldfn, '\n') - let fn = map(fn, 'substitute(v:val, ''^\d\+'', "", "")') - let fn[0] = substitute(fn[0], '\V\^\s\*fu\%[nction]!\?\s\+\zs'. a:old, a:new, '') - let t = @t - try - let @t = join(fn, "\n") - redir => out - @t - redir END - finally - let @t = t - endtry -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/win.vim b/sources_non_forked/tlib/autoload/tlib/win.vim deleted file mode 100644 index 4963af15..00000000 --- a/sources_non_forked/tlib/autoload/tlib/win.vim +++ /dev/null @@ -1,128 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 55 - - -" Return vim code to jump back to the original window. -function! tlib#win#Set(winnr) "{{{3 - if a:winnr > 0 - " TLogVAR a:winnr - " TLogDBG winnr() - " TLogDBG string(tlib#win#List()) - if winnr() != a:winnr && winbufnr(a:winnr) != -1 - let rv = winnr().'wincmd w' - exec a:winnr .'wincmd w' - " TLogVAR rv - " TLogDBG string(tlib#win#List()) - return rv - endif - endif - return '' -endf - - -" :def: function! tlib#win#GetLayout(?save_view=0) -function! tlib#win#GetLayout(...) "{{{3 - TVarArg ['save_view', 0] - let views = {} - if save_view - let winnr = winnr() - windo let views[winnr()] = winsaveview() - " for w in range(1, winnr('$')) - " call tlib#win#Set(w) - " let views[w] = winsaveview() - " endfor - call tlib#win#Set(winnr) - endif - return {'winnr': winnr('$'), 'winrestcmd': winrestcmd(), 'views': views, 'cmdheight': &cmdheight, 'guioptions': &guioptions, 'tabpagenr': tabpagenr()} -endf - - -function! tlib#win#SetLayout(layout) "{{{3 - if a:layout.tabpagenr == tabpagenr() && a:layout.winnr == winnr('$') - " TLogVAR a:layout.winrestcmd - " TLogDBG string(tlib#win#List()) - exec a:layout.winrestcmd - if !empty(a:layout.views) - let winnr = winnr() - " TLogVAR winnr - for [w, v] in items(a:layout.views) - " TLogVAR w, v - call tlib#win#Set(w) - call winrestview(v) - endfor - call tlib#win#Set(winnr) - endif - if a:layout.cmdheight != &cmdheight - let &cmdheight = a:layout.cmdheight - endif - " TLogDBG string(tlib#win#List()) - return 1 - endif - return 0 -endf - - -function! tlib#win#List() "{{{3 - let wl = {} - for wn in range(1, winnr('$')) - let wl[wn] = bufname(winbufnr(wn)) - endfor - return wl -endf - - -" " :def: function! tlib#win#GetLayout1(?save_view=0) -" " Contrary to |tlib#win#GetLayout|, this version doesn't use -" " |winrestcmd()|. It can also save windows views. -" function! tlib#win#GetLayout1(...) "{{{3 -" TVarArg ['save_view', 0] -" let winnr = winnr() -" let acc = {} -" for w in range(1, winnr('$')) -" let def = {'h': winheight(w), 'w': winwidth(w)} -" if save_view -" call tlib#win#Set(w) -" let def.view = winsaveview() -" endif -" let acc[w] = def -" endfor -" call tlib#win#Set(winnr) -" return acc -" endf -" -" -" " Reset layout from the value of |tlib#win#GetLayout1|. -" function! tlib#win#SetLayout1(layout) "{{{3 -" if len(a:layout) != winnr('$') -" return 0 -" endif -" let winnr = winnr() -" for [w, def] in items(a:layout) -" if tlib#win#Set(w) -" exec 'resize '. def.h -" exec 'vertical resize '. def.w -" if has_key(def, 'view') -" call winrestview(def.view) -" endif -" else -" break -" endif -" endfor -" call tlib#win#Set(winnr) -" return 1 -" endf - - -function! tlib#win#Width(wnr) "{{{3 - return winwidth(a:wnr) - &fdc -endf - - -function! tlib#win#WinDo(ex) "{{{3 - let w = winnr() - exec 'windo '. a:ex - exec w .'wincmd w' -endf - diff --git a/sources_non_forked/tlib/doc/tlib.txt b/sources_non_forked/tlib/doc/tlib.txt deleted file mode 100644 index 379dc549..00000000 --- a/sources_non_forked/tlib/doc/tlib.txt +++ /dev/null @@ -1,2497 +0,0 @@ -*tlib.txt* tlib -- A library of vim functions - Author: Tom Link, micathom at gmail com - -This library provides some utility functions. There isn't much need to -install it unless another plugin requires you to do so. - -Most of the library is included in autoload files. No autocommands are -created. With the exception of loading ../plugin/02tlib.vim at startup -the library has no impact on startup time or anything else. - -The change-log is included at the bottom of ../plugin/02tlib.vim -(move the cursor over the file name and type gfG) - -Demo of |tlib#input#List()|: -http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html - - ------------------------------------------------------------------------ -Install~ - -Edit the vba file and type: > - - :so % - -See :help vimball for details. If you have difficulties, please make -sure, you have the current version of vimball (vimscript #1502) -installed. - - -======================================================================== -Contents~ - - :TLet .................................. |:TLet| - :TScratch .............................. |:TScratch| - :TVarArg ............................... |:TVarArg| - :TBrowseOutput ......................... |:TBrowseOutput| - :TBrowseScriptnames .................... |:TBrowseScriptnames| - :Tlibtrace ............................. |:Tlibtrace| - :Tlibtraceset .......................... |:Tlibtraceset| - :Tlibassert ............................ |:Tlibassert| - Add .................................... |Add()| - TestGetArg ............................. |TestGetArg()| - TestGetArg1 ............................ |TestGetArg1()| - TestArgs ............................... |TestArgs()| - TestArgs1 .............................. |TestArgs1()| - TestArgs2 .............................. |TestArgs2()| - TestArgs3 .............................. |TestArgs3()| - g:tlib#debug ........................... |g:tlib#debug| - tlib#notify#Echo ....................... |tlib#notify#Echo()| - tlib#notify#TrimMessage ................ |tlib#notify#TrimMessage()| - g:tlib#trace#backtrace ................. |g:tlib#trace#backtrace| - g:tlib#trace#printf .................... |g:tlib#trace#printf| - tlib#trace#PrintToFile ................. |tlib#trace#PrintToFile()| - tlib#trace#Set ......................... |tlib#trace#Set()| - tlib#trace#Backtrace ................... |tlib#trace#Backtrace()| - tlib#trace#Print ....................... |tlib#trace#Print()| - tlib#trace#Enable ...................... |tlib#trace#Enable()| - tlib#trace#Disable ..................... |tlib#trace#Disable()| - tlib#dictionary#Rev .................... |tlib#dictionary#Rev()| - g:tlib_persistent ...................... |g:tlib_persistent| - tlib#persistent#Dir .................... |tlib#persistent#Dir()| - tlib#persistent#Filename ............... |tlib#persistent#Filename()| - tlib#persistent#Get .................... |tlib#persistent#Get()| - tlib#persistent#MTime .................. |tlib#persistent#MTime()| - tlib#persistent#Value .................. |tlib#persistent#Value()| - tlib#persistent#Save ................... |tlib#persistent#Save()| - g:tlib#vim#simalt_maximize ............. |g:tlib#vim#simalt_maximize| - g:tlib#vim#simalt_restore .............. |g:tlib#vim#simalt_restore| - g:tlib#vim#use_vimtweak ................ |g:tlib#vim#use_vimtweak| - tlib#vim#Maximize ...................... |tlib#vim#Maximize()| - tlib#vim#RestoreWindow ................. |tlib#vim#RestoreWindow()| - g:tlib#vim#use_wmctrl .................. |g:tlib#vim#use_wmctrl| - tlib#vim#CopyFunction .................. |tlib#vim#CopyFunction()| - tlib#progressbar#Init .................. |tlib#progressbar#Init()| - tlib#progressbar#Display ............... |tlib#progressbar#Display()| - tlib#progressbar#Restore ............... |tlib#progressbar#Restore()| - tlib#eval#FormatValue .................. |tlib#eval#FormatValue()| - tlib#eval#Extend ....................... |tlib#eval#Extend()| - tlib#list#Inject ....................... |tlib#list#Inject()| - tlib#list#Compact ...................... |tlib#list#Compact()| - tlib#list#Flatten ...................... |tlib#list#Flatten()| - tlib#list#FindAll ...................... |tlib#list#FindAll()| - tlib#list#Find ......................... |tlib#list#Find()| - tlib#list#Any .......................... |tlib#list#Any()| - tlib#list#All .......................... |tlib#list#All()| - tlib#list#Remove ....................... |tlib#list#Remove()| - tlib#list#RemoveAll .................... |tlib#list#RemoveAll()| - tlib#list#Zip .......................... |tlib#list#Zip()| - tlib#list#Uniq ......................... |tlib#list#Uniq()| - tlib#list#ToDictionary ................. |tlib#list#ToDictionary()| - tlib#cmd#OutputAsList .................. |tlib#cmd#OutputAsList()| - tlib#cmd#BrowseOutput .................. |tlib#cmd#BrowseOutput()| - tlib#cmd#BrowseOutputWithCallback ...... |tlib#cmd#BrowseOutputWithCallback()| - tlib#cmd#DefaultBrowseOutput ........... |tlib#cmd#DefaultBrowseOutput()| - tlib#cmd#ParseScriptname ............... |tlib#cmd#ParseScriptname()| - tlib#cmd#TBrowseScriptnames ............ |tlib#cmd#TBrowseScriptnames()| - tlib#cmd#UseVertical ................... |tlib#cmd#UseVertical()| - tlib#cmd#Time .......................... |tlib#cmd#Time()| - tlib#cmd#Capture ....................... |tlib#cmd#Capture()| - tlib#syntax#Collect .................... |tlib#syntax#Collect()| - tlib#syntax#Names ...................... |tlib#syntax#Names()| - tlib#balloon#Register .................. |tlib#balloon#Register()| - tlib#balloon#Remove .................... |tlib#balloon#Remove()| - tlib#balloon#Expr ...................... |tlib#balloon#Expr()| - tlib#balloon#Expand .................... |tlib#balloon#Expand()| - g:tlib#vcs#def ......................... |g:tlib#vcs#def| - g:tlib#vcs#executables ................. |g:tlib#vcs#executables| - g:tlib#vcs#check ....................... |g:tlib#vcs#check| - tlib#vcs#Executable .................... |tlib#vcs#Executable()| - tlib#vcs#FindVCS ....................... |tlib#vcs#FindVCS()| - tlib#vcs#Ls ............................ |tlib#vcs#Ls()| - tlib#vcs#Diff .......................... |tlib#vcs#Diff()| - tlib#vcs#GitLsPostprocess .............. |tlib#vcs#GitLsPostprocess()| - tlib#char#Get .......................... |tlib#char#Get()| - tlib#char#IsAvailable .................. |tlib#char#IsAvailable()| - tlib#char#GetWithTimeout ............... |tlib#char#GetWithTimeout()| - g:tlib#Filter_glob#seq ................. |g:tlib#Filter_glob#seq| - g:tlib#Filter_glob#char ................ |g:tlib#Filter_glob#char| - tlib#Filter_glob#New ................... |tlib#Filter_glob#New()| - g:tlib_scratch_pos ..................... |g:tlib_scratch_pos| - g:tlib#scratch#hidden .................. |g:tlib#scratch#hidden| - tlib#scratch#UseScratch ................ |tlib#scratch#UseScratch()| - tlib#scratch#CloseScratch .............. |tlib#scratch#CloseScratch()| - tlib#autocmdgroup#Init ................. |tlib#autocmdgroup#Init()| - g:tlib_cache ........................... |g:tlib_cache| - g:tlib#cache#purge_days ................ |g:tlib#cache#purge_days| - g:tlib#cache#purge_every_days .......... |g:tlib#cache#purge_every_days| - g:tlib#cache#script_encoding ........... |g:tlib#cache#script_encoding| - g:tlib#cache#run_script ................ |g:tlib#cache#run_script| - g:tlib#cache#verbosity ................. |g:tlib#cache#verbosity| - g:tlib#cache#dont_purge ................ |g:tlib#cache#dont_purge| - g:tlib#cache#max_filename .............. |g:tlib#cache#max_filename| - tlib#cache#Dir ......................... |tlib#cache#Dir()| - tlib#cache#Filename .................... |tlib#cache#Filename()| - tlib#cache#Save ........................ |tlib#cache#Save()| - tlib#cache#MTime ....................... |tlib#cache#MTime()| - tlib#cache#Get ......................... |tlib#cache#Get()| - tlib#cache#Value ....................... |tlib#cache#Value()| - tlib#cache#MaybePurge .................. |tlib#cache#MaybePurge()| - tlib#cache#Purge ....................... |tlib#cache#Purge()| - tlib#cache#ListFilesInCache ............ |tlib#cache#ListFilesInCache()| - tlib#normal#WithRegister ............... |tlib#normal#WithRegister()| - tlib#time#MSecs ........................ |tlib#time#MSecs()| - tlib#time#Now .......................... |tlib#time#Now()| - tlib#time#FormatNow .................... |tlib#time#FormatNow()| - tlib#time#Diff ......................... |tlib#time#Diff()| - tlib#time#DiffMSecs .................... |tlib#time#DiffMSecs()| - tlib#var#Let ........................... |tlib#var#Let()| - tlib#var#EGet .......................... |tlib#var#EGet()| - tlib#var#Get ........................... |tlib#var#Get()| - tlib#var#List .......................... |tlib#var#List()| - g:tlib_scroll_lines .................... |g:tlib_scroll_lines| - tlib#agent#Exit ........................ |tlib#agent#Exit()| - tlib#agent#CopyItems ................... |tlib#agent#CopyItems()| - tlib#agent#PageUp ...................... |tlib#agent#PageUp()| - tlib#agent#PageDown .................... |tlib#agent#PageDown()| - tlib#agent#Home ........................ |tlib#agent#Home()| - tlib#agent#End ......................... |tlib#agent#End()| - tlib#agent#Up .......................... |tlib#agent#Up()| - tlib#agent#Down ........................ |tlib#agent#Down()| - tlib#agent#UpN ......................... |tlib#agent#UpN()| - tlib#agent#DownN ....................... |tlib#agent#DownN()| - tlib#agent#ShiftLeft ................... |tlib#agent#ShiftLeft()| - tlib#agent#ShiftRight .................. |tlib#agent#ShiftRight()| - tlib#agent#Reset ....................... |tlib#agent#Reset()| - tlib#agent#ToggleRestrictView .......... |tlib#agent#ToggleRestrictView()| - tlib#agent#RestrictView ................ |tlib#agent#RestrictView()| - tlib#agent#UnrestrictView .............. |tlib#agent#UnrestrictView()| - tlib#agent#Input ....................... |tlib#agent#Input()| - tlib#agent#SuspendToParentWindow ....... |tlib#agent#SuspendToParentWindow()| - tlib#agent#Suspend ..................... |tlib#agent#Suspend()| - tlib#agent#Help ........................ |tlib#agent#Help()| - tlib#agent#OR .......................... |tlib#agent#OR()| - tlib#agent#AND ......................... |tlib#agent#AND()| - tlib#agent#ReduceFilter ................ |tlib#agent#ReduceFilter()| - tlib#agent#PopFilter ................... |tlib#agent#PopFilter()| - tlib#agent#Debug ....................... |tlib#agent#Debug()| - tlib#agent#Select ...................... |tlib#agent#Select()| - tlib#agent#SelectUp .................... |tlib#agent#SelectUp()| - tlib#agent#SelectDown .................. |tlib#agent#SelectDown()| - tlib#agent#SelectAll ................... |tlib#agent#SelectAll()| - tlib#agent#ToggleStickyList ............ |tlib#agent#ToggleStickyList()| - tlib#agent#EditItem .................... |tlib#agent#EditItem()| - tlib#agent#NewItem ..................... |tlib#agent#NewItem()| - tlib#agent#DeleteItems ................. |tlib#agent#DeleteItems()| - tlib#agent#Cut ......................... |tlib#agent#Cut()| - tlib#agent#Copy ........................ |tlib#agent#Copy()| - tlib#agent#Paste ....................... |tlib#agent#Paste()| - tlib#agent#EditReturnValue ............. |tlib#agent#EditReturnValue()| - tlib#agent#ViewFile .................... |tlib#agent#ViewFile()| - tlib#agent#EditFile .................... |tlib#agent#EditFile()| - tlib#agent#EditFileInSplit ............. |tlib#agent#EditFileInSplit()| - tlib#agent#EditFileInVSplit ............ |tlib#agent#EditFileInVSplit()| - tlib#agent#EditFileInTab ............... |tlib#agent#EditFileInTab()| - tlib#agent#ToggleScrollbind ............ |tlib#agent#ToggleScrollbind()| - tlib#agent#ShowInfo .................... |tlib#agent#ShowInfo()| - tlib#agent#PreviewLine ................. |tlib#agent#PreviewLine()| - tlib#agent#GotoLine .................... |tlib#agent#GotoLine()| - tlib#agent#DoAtLine .................... |tlib#agent#DoAtLine()| - tlib#agent#Wildcard .................... |tlib#agent#Wildcard()| - tlib#agent#Null ........................ |tlib#agent#Null()| - tlib#agent#ExecAgentByName ............. |tlib#agent#ExecAgentByName()| - tlib#agent#CompleteAgentNames .......... |tlib#agent#CompleteAgentNames()| - tlib#agent#Complete .................... |tlib#agent#Complete()| - tlib#bitwise#Num2Bits .................. |tlib#bitwise#Num2Bits()| - tlib#bitwise#Bits2Num .................. |tlib#bitwise#Bits2Num()| - tlib#bitwise#AND ....................... |tlib#bitwise#AND()| - tlib#bitwise#OR ........................ |tlib#bitwise#OR()| - tlib#bitwise#XOR ....................... |tlib#bitwise#XOR()| - tlib#bitwise#ShiftRight ................ |tlib#bitwise#ShiftRight()| - tlib#bitwise#ShiftLeft ................. |tlib#bitwise#ShiftLeft()| - tlib#bitwise#Add ....................... |tlib#bitwise#Add()| - tlib#bitwise#Sub ....................... |tlib#bitwise#Sub()| - tlib#url#Decode ........................ |tlib#url#Decode()| - tlib#url#DecodeChar .................... |tlib#url#DecodeChar()| - tlib#url#EncodeChar .................... |tlib#url#EncodeChar()| - tlib#url#Encode ........................ |tlib#url#Encode()| - tlib#signs#ClearAll .................... |tlib#signs#ClearAll()| - tlib#signs#ClearBuffer ................. |tlib#signs#ClearBuffer()| - tlib#signs#Mark ........................ |tlib#signs#Mark()| - tlib#rx#Escape ......................... |tlib#rx#Escape()| - tlib#rx#EscapeReplace .................. |tlib#rx#EscapeReplace()| - tlib#rx#Suffixes ....................... |tlib#rx#Suffixes()| - tlib#rx#LooksLikeRegexp ................ |tlib#rx#LooksLikeRegexp()| - g:tlib_tags_extra ...................... |g:tlib_tags_extra| - g:tlib_tag_substitute .................. |g:tlib_tag_substitute| - tlib#tag#Retrieve ...................... |tlib#tag#Retrieve()| - tlib#tag#Collect ....................... |tlib#tag#Collect()| - tlib#tag#Format ........................ |tlib#tag#Format()| - tlib#map#PumAccept ..................... |tlib#map#PumAccept()| - tlib#Filter_cnfd#New ................... |tlib#Filter_cnfd#New()| - g:tlib#input#sortprefs_threshold ....... |g:tlib#input#sortprefs_threshold| - g:tlib#input#livesearch_threshold ...... |g:tlib#input#livesearch_threshold| - g:tlib#input#filter_mode ............... |g:tlib#input#filter_mode| - g:tlib#input#higroup ................... |g:tlib#input#higroup| - g:tlib_pick_last_item .................. |g:tlib_pick_last_item| - g:tlib#input#and ....................... |g:tlib#input#and| - g:tlib#input#or ........................ |g:tlib#input#or| - g:tlib#input#not ....................... |g:tlib#input#not| - g:tlib#input#numeric_chars ............. |g:tlib#input#numeric_chars| - g:tlib#input#keyagents_InputList_s ..... |g:tlib#input#keyagents_InputList_s| - g:tlib#input#keyagents_InputList_m ..... |g:tlib#input#keyagents_InputList_m| - g:tlib#input#handlers_EditList ......... |g:tlib#input#handlers_EditList| - g:tlib#input#user_shortcuts ............ |g:tlib#input#user_shortcuts| - g:tlib#input#use_popup ................. |g:tlib#input#use_popup| - g:tlib#input#format_filename ........... |g:tlib#input#format_filename| - g:tlib#input#filename_padding_r ........ |g:tlib#input#filename_padding_r| - g:tlib#input#filename_max_width ........ |g:tlib#input#filename_max_width| - tlib#input#List ........................ |tlib#input#List()| - tlib#input#ListD ....................... |tlib#input#ListD()| - tlib#input#ListW ....................... |tlib#input#ListW()| - tlib#input#EditList .................... |tlib#input#EditList()| - tlib#input#Resume ...................... |tlib#input#Resume()| - tlib#input#CommandSelect ............... |tlib#input#CommandSelect()| - tlib#input#Edit ........................ |tlib#input#Edit()| - tlib#input#Dialog ...................... |tlib#input#Dialog()| - tlib#number#ConvertBase ................ |tlib#number#ConvertBase()| - g:tlib#file#drop ....................... |g:tlib#file#drop| - g:tlib#file#use_tabs ................... |g:tlib#file#use_tabs| - g:tlib#file#edit_cmds .................. |g:tlib#file#edit_cmds| - g:tlib#file#absolute_filename_rx ....... |g:tlib#file#absolute_filename_rx| - tlib#file#Split ........................ |tlib#file#Split()| - tlib#file#Join ......................... |tlib#file#Join()| - tlib#file#Relative ..................... |tlib#file#Relative()| - tlib#file#Absolute ..................... |tlib#file#Absolute()| - tlib#file#Canonic ...................... |tlib#file#Canonic()| - tlib#file#With ......................... |tlib#file#With()| - tlib#file#Edit ......................... |tlib#file#Edit()| - tlib#file#Glob ......................... |tlib#file#Glob()| - tlib#file#Globpath ..................... |tlib#file#Globpath()| - g:tlib#sys#special_protocols ........... |g:tlib#sys#special_protocols| - g:tlib#sys#special_suffixes ............ |g:tlib#sys#special_suffixes| - g:tlib#sys#system_rx ................... |g:tlib#sys#system_rx| - g:tlib#sys#system_browser .............. |g:tlib#sys#system_browser| - g:tlib#sys#windows ..................... |g:tlib#sys#windows| - g:tlib#sys#null ........................ |g:tlib#sys#null| - tlib#sys#IsCygwinBin ................... |tlib#sys#IsCygwinBin()| - tlib#sys#IsExecutable .................. |tlib#sys#IsExecutable()| - g:tlib#sys#check_cygpath ............... |g:tlib#sys#check_cygpath| - g:tlib#sys#cygwin_path_rx .............. |g:tlib#sys#cygwin_path_rx| - g:tlib#sys#cygwin_expr ................. |g:tlib#sys#cygwin_expr| - tlib#sys#GetCmd ........................ |tlib#sys#GetCmd()| - tlib#sys#MaybeUseCygpath ............... |tlib#sys#MaybeUseCygpath()| - tlib#sys#ConvertPath ................... |tlib#sys#ConvertPath()| - tlib#sys#FileArgs ...................... |tlib#sys#FileArgs()| - tlib#sys#IsSpecial ..................... |tlib#sys#IsSpecial()| - tlib#sys#Open .......................... |tlib#sys#Open()| - tlib#sys#SystemInDir ................... |tlib#sys#SystemInDir()| - tlib#paragraph#GetMetric ............... |tlib#paragraph#GetMetric()| - tlib#paragraph#Move .................... |tlib#paragraph#Move()| - g:tlib_inputlist_pct ................... |g:tlib_inputlist_pct| - g:tlib_inputlist_width_filename ........ |g:tlib_inputlist_width_filename| - g:tlib_inputlist_filename_indicators ... |g:tlib_inputlist_filename_indicators| - g:tlib_inputlist_shortmessage .......... |g:tlib_inputlist_shortmessage| - tlib#World#New ......................... |tlib#World#New()| - prototype.PrintLines - prototype.Suspend - tlib#loclist#Browse .................... |tlib#loclist#Browse()| - tlib#tab#BufMap ........................ |tlib#tab#BufMap()| - tlib#tab#TabWinNr ...................... |tlib#tab#TabWinNr()| - tlib#tab#Set ........................... |tlib#tab#Set()| - tlib#date#IsDate ....................... |tlib#date#IsDate()| - tlib#date#Format ....................... |tlib#date#Format()| - tlib#date#DiffInDays ................... |tlib#date#DiffInDays()| - tlib#date#Parse ........................ |tlib#date#Parse()| - tlib#date#SecondsSince1970 ............. |tlib#date#SecondsSince1970()| - tlib#date#Shift ........................ |tlib#date#Shift()| - tlib#type#IsNumber ..................... |tlib#type#IsNumber()| - tlib#type#IsString ..................... |tlib#type#IsString()| - tlib#type#IsFuncref .................... |tlib#type#IsFuncref()| - tlib#type#IsList ....................... |tlib#type#IsList()| - tlib#type#IsDictionary ................. |tlib#type#IsDictionary()| - tlib#type#Is ........................... |tlib#type#Is()| - tlib#type#Are .......................... |tlib#type#Are()| - tlib#type#Has .......................... |tlib#type#Has()| - tlib#type#Have ......................... |tlib#type#Have()| - tlib#Filter_fuzzy#New .................. |tlib#Filter_fuzzy#New()| - tlib#assert#Enable ..................... |tlib#assert#Enable()| - tlib#assert#Disable .................... |tlib#assert#Disable()| - tlib#assert#Assert ..................... |tlib#assert#Assert()| - tlib#assert#Map ........................ |tlib#assert#Map()| - tlib#assert#All ........................ |tlib#assert#All()| - tlib#textobjects#StandardParagraph ..... |standard-paragraph| - tlib#textobjects#Init .................. |tlib#textobjects#Init()| - v_sp ................................... |v_sp| - o_sp ................................... |o_sp| - tlib#arg#Get ........................... |tlib#arg#Get()| - tlib#arg#Let ........................... |tlib#arg#Let()| - tlib#arg#StringAsKeyArgs ............... |tlib#arg#StringAsKeyArgs()| - tlib#arg#StringAsKeyArgsEqual .......... |tlib#arg#StringAsKeyArgsEqual()| - tlib#arg#GetOpts ....................... |tlib#arg#GetOpts()| - tlib#arg#Ex ............................ |tlib#arg#Ex()| - tlib#fixes#Winpos ...................... |tlib#fixes#Winpos()| - g:tlib#dir#sep ......................... |g:tlib#dir#sep| - tlib#dir#CanonicName ................... |tlib#dir#CanonicName()| - tlib#dir#NativeName .................... |tlib#dir#NativeName()| - tlib#dir#PlainName ..................... |tlib#dir#PlainName()| - tlib#dir#Ensure ........................ |tlib#dir#Ensure()| - tlib#dir#MyRuntime ..................... |tlib#dir#MyRuntime()| - tlib#dir#CD ............................ |tlib#dir#CD()| - tlib#dir#Push .......................... |tlib#dir#Push()| - tlib#dir#Pop ........................... |tlib#dir#Pop()| - g:tlib#hash#use_crc32 .................. |g:tlib#hash#use_crc32| - g:tlib#hash#use_adler32 ................ |g:tlib#hash#use_adler32| - tlib#hash#CRC32B ....................... |tlib#hash#CRC32B()| - tlib#hash#CRC32B_ruby .................. |tlib#hash#CRC32B_ruby()| - tlib#hash#CRC32B_vim ................... |tlib#hash#CRC32B_vim()| - tlib#hash#Adler32 ...................... |tlib#hash#Adler32()| - tlib#hash#Adler32_vim .................. |tlib#hash#Adler32_vim()| - tlib#hash#Adler32_tlib ................. |tlib#hash#Adler32_tlib()| - tlib#win#Set ........................... |tlib#win#Set()| - tlib#win#GetLayout ..................... |tlib#win#GetLayout()| - tlib#win#SetLayout ..................... |tlib#win#SetLayout()| - tlib#win#List .......................... |tlib#win#List()| - tlib#win#Width ......................... |tlib#win#Width()| - tlib#win#WinDo ......................... |tlib#win#WinDo()| - tlib#comments#Comments ................. |tlib#comments#Comments()| - tlib#grep#Do ........................... |tlib#grep#Do()| - tlib#grep#LocList ...................... |tlib#grep#LocList()| - tlib#grep#QuickFixList ................. |tlib#grep#QuickFixList()| - tlib#grep#List ......................... |tlib#grep#List()| - tlib#qfl#FormatQFLE .................... |tlib#qfl#FormatQFLE()| - tlib#qfl#QfeFilename ................... |tlib#qfl#QfeFilename()| - tlib#qfl#InitListBuffer ................ |tlib#qfl#InitListBuffer()| - tlib#qfl#SetSyntax ..................... |tlib#qfl#SetSyntax()| - tlib#qfl#Balloon ....................... |tlib#qfl#Balloon()| - tlib#qfl#AgentEditQFE .................. |tlib#qfl#AgentEditQFE()| - tlib#qfl#AgentPreviewQFE ............... |tlib#qfl#AgentPreviewQFE()| - tlib#qfl#AgentGotoQFE .................. |tlib#qfl#AgentGotoQFE()| - tlib#qfl#AgentWithSelected ............. |tlib#qfl#AgentWithSelected()| - tlib#qfl#RunCmdOnSelected .............. |tlib#qfl#RunCmdOnSelected()| - tlib#qfl#AgentSplitBuffer .............. |tlib#qfl#AgentSplitBuffer()| - tlib#qfl#AgentTabBuffer ................ |tlib#qfl#AgentTabBuffer()| - tlib#qfl#AgentVSplitBuffer ............. |tlib#qfl#AgentVSplitBuffer()| - tlib#qfl#AgentEditLine ................. |tlib#qfl#AgentEditLine()| - tlib#qfl#EditLine ...................... |tlib#qfl#EditLine()| - tlib#qfl#SetFollowCursor ............... |tlib#qfl#SetFollowCursor()| - tlib#qfl#QflList ....................... |tlib#qfl#QflList()| - tlib#qfl#Browse ........................ |tlib#qfl#Browse()| - tlib#Filter_cnf#New .................... |tlib#Filter_cnf#New()| - prototype.Pretty - tlib#Object#New ........................ |tlib#Object#New()| - prototype.New - prototype.Inherit - prototype.Extend - prototype.IsA - prototype.IsRelated - prototype.RespondTo - prototype.Super - tlib#Object#Methods .................... |tlib#Object#Methods()| - g:tlib_viewline_position ............... |g:tlib_viewline_position| - tlib#buffer#EnableMRU .................. |tlib#buffer#EnableMRU()| - tlib#buffer#DisableMRU ................. |tlib#buffer#DisableMRU()| - tlib#buffer#Set ........................ |tlib#buffer#Set()| - tlib#buffer#Eval ....................... |tlib#buffer#Eval()| - tlib#buffer#GetList .................... |tlib#buffer#GetList()| - tlib#buffer#ViewLine ................... |tlib#buffer#ViewLine()| - tlib#buffer#HighlightLine .............. |tlib#buffer#HighlightLine()| - tlib#buffer#DeleteRange ................ |tlib#buffer#DeleteRange()| - tlib#buffer#ReplaceRange ............... |tlib#buffer#ReplaceRange()| - tlib#buffer#ScratchStart ............... |tlib#buffer#ScratchStart()| - tlib#buffer#ScratchEnd ................. |tlib#buffer#ScratchEnd()| - tlib#buffer#BufDo ...................... |tlib#buffer#BufDo()| - tlib#buffer#InsertText ................. |tlib#buffer#InsertText()| - tlib#buffer#InsertText0 ................ |tlib#buffer#InsertText0()| - tlib#buffer#CurrentByte ................ |tlib#buffer#CurrentByte()| - tlib#buffer#KeepCursorPosition ......... |tlib#buffer#KeepCursorPosition()| - tlib#hook#Run .......................... |tlib#hook#Run()| - tlib#string#RemoveBackslashes .......... |tlib#string#RemoveBackslashes()| - tlib#string#Chomp ...................... |tlib#string#Chomp()| - tlib#string#Format ..................... |tlib#string#Format()| - tlib#string#Printf1 .................... |tlib#string#Printf1()| - tlib#string#TrimLeft ................... |tlib#string#TrimLeft()| - tlib#string#TrimRight .................. |tlib#string#TrimRight()| - tlib#string#Strip ...................... |tlib#string#Strip()| - tlib#string#Count ...................... |tlib#string#Count()| - tlib#string#SplitCommaList ............. |tlib#string#SplitCommaList()| - - -======================================================================== -plugin/02tlib.vim~ - - *:TLet* -:TLet VAR = VALUE - Set a variable only if it doesn't already exist. - EXAMPLES: > - TLet foo = 1 - TLet foo = 2 - echo foo - => 1 -< - - *:TScratch* -:TScratch - Open a scratch buffer (a buffer without a file). - TScratch ... use split window - TScratch! ... use the whole frame - This command takes an (inner) dictionary as optional argument. - EXAMPLES: > - TScratch 'scratch': '__FOO__' - => Open a scratch buffer named __FOO__ -< - - *:TVarArg* -:TVarArg VAR1, [VAR2, DEFAULT2] ... - A convenience wrapper for |tlib#arg#Let|. - EXAMPLES: > - function! Foo(...) - TVarArg ['a', 1], 'b' - echo 'a='. a - echo 'b='. b - endf -< - - *:TBrowseOutput* -:TBrowseOutput COMMAND - Ever wondered how to efficiently browse the output of a command - without redirecting it to a file? This command takes a command as - argument and presents the output via |tlib#input#List()| so that you - can easily search for a keyword (e.g. the name of a variable or - function) and the like. - - If you press enter, the selected line will be copied to the command - line. Press ESC to cancel browsing. - - EXAMPLES: > - TBrowseOutput 20verb TeaseTheCulprit -< - - *:TBrowseScriptnames* -:TBrowseScriptnames - List all sourced script names (the output of ':scriptnames'). - - When you press enter, the selected script will be opened in the current - window. Press ESC to cancel. - - EXAMPLES: > - TBrowseScriptnames -< - - *:Tlibtrace* -:Tlibtrace GUARD, VAR1, VAR2... - Do nothing unless |tlib#trace#Enable()| was called. - - When |:Tlibtraceset| or |tlib#trace#Enable()| were called: - - If GUARD is a number that evaluates to true or if it is a string that - matches a |regexp|, which was added using Tlibtrace! (with '!'), - display the values of VAR1, VAR2 ... - - *:Tlibtraceset* -:Tlibtraceset - :Tlibtraceset +RX1, -RX2... - If |tlib#trace#Enable()| was called: With the optional , users - can add and remove GUARDs (actually a |regexp|) that should be traced. - - *:Tlibassert* -:Tlibtrace ASSERTION - - -======================================================================== -test/tlib.vim~ - - *Add()* -Add(a,b) - List - - *TestGetArg()* -TestGetArg(...) - Optional arguments - - *TestGetArg1()* -TestGetArg1(...) - - *TestArgs()* -TestArgs(...) - - *TestArgs1()* -TestArgs1(...) - - *TestArgs2()* -TestArgs2(...) - - *TestArgs3()* -TestArgs3(...) - - -======================================================================== -autoload/tlib.vim~ - - *g:tlib#debug* -g:tlib#debug - - -======================================================================== -autoload/tlib/notify.vim~ - - *tlib#notify#Echo()* -tlib#notify#Echo(text, ?style='') - Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' - in order to prevent |press-enter| messages. - - *tlib#notify#TrimMessage()* -tlib#notify#TrimMessage(message) - Contributed by Erik Falor: - If the line containing the message is too long, echoing it will cause - a 'Hit ENTER' prompt to appear. This function cleans up the line so - that does not happen. - The echoed line is too long if it is wider than the width of the - window, minus cmdline space taken up by the ruler and showcmd - features. - - -======================================================================== -autoload/tlib/trace.vim~ - - *g:tlib#trace#backtrace* -g:tlib#trace#backtrace (default: 2) - The length of the backtrace that should be included in - |tlib#trace#Print()|. - - *g:tlib#trace#printf* -g:tlib#trace#printf (default: 'echom %s') - The command used for printing traces from |tlib#trace#Print()|. - - *tlib#trace#PrintToFile()* -tlib#trace#PrintToFile(filename) - Set |g:tlib#trace#printf| to make |tlib#trace#Print()| print to - `filename`. - - *tlib#trace#Set()* -tlib#trace#Set(vars) - Set the tracing |regexp|. See |:Tlibtrace|. - This will also call |tlib#trace#Enable()|. - - Examples: - call tlib#trace#Set(["+foo", "-bar"]) - call tlib#trace#Set("+foo,-bar") - - *tlib#trace#Backtrace()* -tlib#trace#Backtrace(caller) - - *tlib#trace#Print()* -tlib#trace#Print(caller, vars, values) - Print the values of vars. The first value is a "guard" (see - |:Tlibtrace|). - - *tlib#trace#Enable()* -tlib#trace#Enable() - Enable tracing via |:Tlibtrace|. - - *tlib#trace#Disable()* -tlib#trace#Disable() - Disable tracing via |:Tlibtrace|. - - -======================================================================== -autoload/tlib/dictionary.vim~ - - *tlib#dictionary#Rev()* -tlib#dictionary#Rev(dict) - - -======================================================================== -autoload/tlib/persistent.vim~ - - *g:tlib_persistent* -g:tlib_persistent (default: '') - The directory for persistent data files. If empty, use - |tlib#dir#MyRuntime|.'/share'. - - *tlib#persistent#Dir()* -tlib#persistent#Dir(?mode = 'bg') - Return the full directory name for persistent data files. - - *tlib#persistent#Filename()* -tlib#persistent#Filename(type, ?file=%, ?mkdir=0) - - *tlib#persistent#Get()* -tlib#persistent#Get(...) - - *tlib#persistent#MTime()* -tlib#persistent#MTime(cfile) - - *tlib#persistent#Value()* -tlib#persistent#Value(...) - - *tlib#persistent#Save()* -tlib#persistent#Save(cfile, dictionary) - - -======================================================================== -autoload/tlib/vim.vim~ - - *g:tlib#vim#simalt_maximize* -g:tlib#vim#simalt_maximize (default: 'x') - The alt-key for maximizing the window. - CAUTION: The value of this paramter depends on your locale and - maybe the windows version you are running. - - *g:tlib#vim#simalt_restore* -g:tlib#vim#simalt_restore (default: 'r') - The alt-key for restoring the window. - CAUTION: The value of this paramter depends on your locale and - maybe the windows version you are running. - - *g:tlib#vim#use_vimtweak* -g:tlib#vim#use_vimtweak (default: 0) - If true, use the vimtweak.dll for windows. This will enable - tlib to remove the caption for fullscreen windows. - - *tlib#vim#Maximize()* -tlib#vim#Maximize(fullscreen) - Maximize the window. - You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't - work for you. - - *tlib#vim#RestoreWindow()* -tlib#vim#RestoreWindow() - Restore the original vimsize after having called |tlib#vim#Maximize()|. - - *g:tlib#vim#use_wmctrl* -g:tlib#vim#use_wmctrl (default: executable('wmctrl')) - If true, use wmctrl for X windows to make a window - maximized/fullscreen. - - This is the preferred method for maximizing windows under X - windows. Some window managers have problem coping with the - default method of setting 'lines' and 'columns' to a large - value. - - *tlib#vim#CopyFunction()* -tlib#vim##CopyFunction(old, new, overwrite=0) - - -======================================================================== -autoload/tlib/progressbar.vim~ - - *tlib#progressbar#Init()* -tlib#progressbar#Init(max, ...) - EXAMPLE: > - call tlib#progressbar#Init(20) - try - for i in range(20) - call tlib#progressbar#Display(i) - call DoSomethingThatTakesSomeTime(i) - endfor - finally - call tlib#progressbar#Restore() - endtry -< - - *tlib#progressbar#Display()* -tlib#progressbar#Display(value, ...) - - *tlib#progressbar#Restore()* -tlib#progressbar#Restore() - - -======================================================================== -autoload/tlib/eval.vim~ - - *tlib#eval#FormatValue()* -tlib#eval#FormatValue(value, ...) - - *tlib#eval#Extend()* -tlib#eval#Extend(a, b, ...) - - -======================================================================== -autoload/tlib/list.vim~ - - *tlib#list#Inject()* -tlib#list#Inject(list, initial_value, funcref) - EXAMPLES: > - echo tlib#list#Inject([1,2,3], 0, function('Add') - => 6 -< - - *tlib#list#Compact()* -tlib#list#Compact(list) - EXAMPLES: > - tlib#list#Compact([0,1,2,3,[], {}, ""]) - => [1,2,3] -< - - *tlib#list#Flatten()* -tlib#list#Flatten(list) - EXAMPLES: > - tlib#list#Flatten([0,[1,2,[3,""]]]) - => [0,1,2,3,""] -< - - *tlib#list#FindAll()* -tlib#list#FindAll(list, filter, ?process_expr="") - Basically the same as filter() - - EXAMPLES: > - tlib#list#FindAll([1,2,3], 'v:val >= 2') - => [2, 3] -< - - *tlib#list#Find()* -tlib#list#Find(list, filter, ?default="", ?process_expr="") - - EXAMPLES: > - tlib#list#Find([1,2,3], 'v:val >= 2') - => 2 -< - - *tlib#list#Any()* -tlib#list#Any(list, expr) - EXAMPLES: > - tlib#list#Any([1,2,3], 'v:val >= 2') - => 1 -< - - *tlib#list#All()* -tlib#list#All(list, expr) - EXAMPLES: > - tlib#list#All([1,2,3], 'v:val >= 2') - => 0 -< - - *tlib#list#Remove()* -tlib#list#Remove(list, element) - EXAMPLES: > - tlib#list#Remove([1,2,1,2], 2) - => [1,1,2] -< - - *tlib#list#RemoveAll()* -tlib#list#RemoveAll(list, element) - EXAMPLES: > - tlib#list#RemoveAll([1,2,1,2], 2) - => [1,1] -< - - *tlib#list#Zip()* -tlib#list#Zip(lists, ?default='') - EXAMPLES: > - tlib#list#Zip([[1,2,3], [4,5,6]]) - => [[1,4], [2,5], [3,6]] -< - - *tlib#list#Uniq()* -tlib#list#Uniq(list, ...) - - *tlib#list#ToDictionary()* -tlib#list#ToDictionary(list, default, ...) - - -======================================================================== -autoload/tlib/cmd.vim~ - - *tlib#cmd#OutputAsList()* -tlib#cmd#OutputAsList(command) - - *tlib#cmd#BrowseOutput()* -tlib#cmd#BrowseOutput(command) - See |:TBrowseOutput|. - - *tlib#cmd#BrowseOutputWithCallback()* -tlib#cmd#BrowseOutputWithCallback(callback, command) - Execute COMMAND and present its output in a |tlib#input#List()|; - when a line is selected, execute the function named as the CALLBACK - and pass in that line as an argument. - - The CALLBACK function gives you an opportunity to massage the COMMAND output - and possibly act on it in a meaningful way. For example, if COMMAND listed - all URIs found in the current buffer, CALLBACK could validate and then open - the selected URI in the system's default browser. - - This function is meant to be a tool to help compose the implementations of - powerful commands that use |tlib#input#List()| as a common interface. See - |TBrowseScriptnames| as an example. - - EXAMPLES: > - call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') -< - - *tlib#cmd#DefaultBrowseOutput()* -tlib#cmd#DefaultBrowseOutput(cmd) - - *tlib#cmd#ParseScriptname()* -tlib#cmd#ParseScriptname(line) - - *tlib#cmd#TBrowseScriptnames()* -tlib#cmd#TBrowseScriptnames() - - *tlib#cmd#UseVertical()* -tlib#cmd#UseVertical(?rx='') - Look at the history whether the command was called with vertical. If - an rx is provided check first if the last entry in the history matches - this rx. - - *tlib#cmd#Time()* -tlib#cmd#Time(cmd) - Print the time in seconds or milliseconds (if your version of VIM - has |+reltime|) a command takes. - - *tlib#cmd#Capture()* -tlib#cmd#Capture(cmd) - - -======================================================================== -autoload/tlib/syntax.vim~ - - *tlib#syntax#Collect()* -tlib#syntax#Collect() - - *tlib#syntax#Names()* -tlib#syntax#Names(?rx='') - - -======================================================================== -autoload/tlib/balloon.vim~ - - *tlib#balloon#Register()* -tlib#balloon#Register(expr) - - *tlib#balloon#Remove()* -tlib#balloon#Remove(expr) - - *tlib#balloon#Expr()* -tlib#balloon#Expr() - - *tlib#balloon#Expand()* -tlib#balloon#Expand(expr) - - -======================================================================== -autoload/tlib/vcs.vim~ - - *g:tlib#vcs#def* -g:tlib#vcs#def {...} - A dictionarie of supported VCS (currently: git, hg, svn, bzr). - - *g:tlib#vcs#executables* -g:tlib#vcs#executables {...} - A dictionary of custom executables for VCS commands. If the value is - empty, support for that VCS will be removed. If no key is present, it - is assumed that the VCS "type" is the name of the executable. - - *g:tlib#vcs#check* -g:tlib#vcs#check (default: has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s') - If non-empty, use it as a format string to check whether a VCS is - installed on your computer. - - *tlib#vcs#Executable()* -tlib#vcs#Executable(type) - - *tlib#vcs#FindVCS()* -tlib#vcs#FindVCS(filename) - - *tlib#vcs#Ls()* -tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) - Return the files under VCS. - - *tlib#vcs#Diff()* -tlib#vcs#Diff(filename, ?vcs=[type, dir]) - Return the diff for "filename" - - *tlib#vcs#GitLsPostprocess()* -tlib#vcs#GitLsPostprocess(filename) - - -======================================================================== -autoload/tlib/char.vim~ - - *tlib#char#Get()* -tlib#char#Get(?timeout=0) - Get a character. - - EXAMPLES: > - echo tlib#char#Get() - echo tlib#char#Get(5) -< - - *tlib#char#IsAvailable()* -tlib#char#IsAvailable() - - *tlib#char#GetWithTimeout()* -tlib#char#GetWithTimeout(timeout, ...) - - -======================================================================== -autoload/tlib/Filter_glob.vim~ - - *g:tlib#Filter_glob#seq* -g:tlib#Filter_glob#seq (default: '*') - A character that should be expanded to '\.\{-}'. - - *g:tlib#Filter_glob#char* -g:tlib#Filter_glob#char (default: '?') - A character that should be expanded to '\.\?'. - - *tlib#Filter_glob#New()* -tlib#Filter_glob#New(...) - The same as |tlib#Filter_cnf#New()| but a a customizable character - |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and - |g:tlib#Filter_glob#char| is expanded to '\.'. - The pattern is a '/\V' very no-'/magic' regexp pattern. - - -======================================================================== -autoload/tlib/scratch.vim~ - - *g:tlib_scratch_pos* -g:tlib_scratch_pos (default: 'botright') - Scratch window position. By default the list window is opened on the - bottom. Set this variable to 'topleft' or '' to change this behaviour. - See |tlib#input#List()|. - - *g:tlib#scratch#hidden* -g:tlib#scratch#hidden (default: 'hide') - If you want the scratch buffer to be fully removed, you might want to - set this variable to 'wipe'. - See also https://github.com/tomtom/tlib_vim/pull/16 - - *tlib#scratch#UseScratch()* -tlib#scratch#UseScratch(?keyargs={}) - Display a scratch buffer (a buffer with no file). See :TScratch for an - example. - Return the scratch buffer's number. - Values for keyargs: - scratch_split ... 1: split, 0: window, -1: tab - - *tlib#scratch#CloseScratch()* -tlib#scratch#CloseScratch(keyargs, ...) - Close a scratch buffer as defined in keyargs (usually a World). - Return 1 if the scratch buffer is closed (or if it already was - closed). - - -======================================================================== -autoload/tlib/autocmdgroup.vim~ - - *tlib#autocmdgroup#Init()* -tlib#autocmdgroup#Init() - - -======================================================================== -autoload/tlib/cache.vim~ - - *g:tlib_cache* -g:tlib_cache (default: '') - The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. - You might want to delete old files from this directory from time to - time with a command like: > - find ~/vimfiles/cache/ -atime +31 -type f -print -delete -< - - *g:tlib#cache#purge_days* -g:tlib#cache#purge_days (default: 31) - |tlib#cache#Purge()|: Remove cache files older than N days. - - *g:tlib#cache#purge_every_days* -g:tlib#cache#purge_every_days (default: 31) - Purge the cache every N days. Disable automatic purging by setting - this value to a negative value. - - *g:tlib#cache#script_encoding* -g:tlib#cache#script_encoding (default: &enc) - The encoding used for the purge-cache script. - Default: 'enc' - - *g:tlib#cache#run_script* -g:tlib#cache#run_script (default: 1) - Whether to run the directory removal script: - 0 ... No - 1 ... Query user - 2 ... Yes - - *g:tlib#cache#verbosity* -g:tlib#cache#verbosity (default: 1) - Verbosity level: - 0 ... Be quiet - 1 ... Display informative message - 2 ... Display detailed messages - - *g:tlib#cache#dont_purge* -g:tlib#cache#dont_purge (default: ['[\/]\.last_purge$']) - A list of regexps that are matched against partial filenames of the - cached files. If a regexp matches, the file won't be removed by - |tlib#cache#Purge()|. - - *g:tlib#cache#max_filename* -g:tlib#cache#max_filename (default: 200) - If the cache filename is longer than N characters, use - |pathshorten()|. - - *tlib#cache#Dir()* -tlib#cache#Dir(?mode = 'bg') - The default cache directory. - - *tlib#cache#Filename()* -tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') - - *tlib#cache#Save()* -tlib#cache#Save(cfile, dictionary, ...) - - *tlib#cache#MTime()* -tlib#cache#MTime(cfile) - - *tlib#cache#Get()* -tlib#cache#Get(cfile, ...) - - *tlib#cache#Value()* -tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) - Get a cached value from cfile. If it is outdated (compared to ftime) - or does not exist, create it calling a generator function. - - *tlib#cache#MaybePurge()* -tlib#cache#MaybePurge() - Call |tlib#cache#Purge()| if the last purge was done before - |g:tlib#cache#purge_every_days|. - - *tlib#cache#Purge()* -tlib#cache#Purge() - Delete old files. - - *tlib#cache#ListFilesInCache()* -tlib#cache#ListFilesInCache(...) - - -======================================================================== -autoload/tlib/normal.vim~ - - *tlib#normal#WithRegister()* -tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') - Execute a normal command while maintaining all registers. - - -======================================================================== -autoload/tlib/time.vim~ - - *tlib#time#MSecs()* -tlib#time#MSecs() - - *tlib#time#Now()* -tlib#time#Now() - - *tlib#time#FormatNow()* -tlib#time#FormatNow() - - *tlib#time#Diff()* -tlib#time#Diff(a, b, ...) - - *tlib#time#DiffMSecs()* -tlib#time#DiffMSecs(a, b, ...) - - -======================================================================== -autoload/tlib/var.vim~ - - *tlib#var#Let()* -tlib#var#Let(name, val) - Define a variable called NAME if yet undefined. - You can also use the :TLLet command. - - EXAMPLES: > - exec tlib#var#Let('g:foo', 1) - TLet g:foo = 1 -< - - *tlib#var#EGet()* -tlib#var#EGet(var, namespace, ?default='') - Retrieve a variable by searching several namespaces. - - EXAMPLES: > - let g:foo = 1 - let b:foo = 2 - let w:foo = 3 - echo eval(tlib#var#EGet('foo', 'vg')) => 1 - echo eval(tlib#var#EGet('foo', 'bg')) => 2 - echo eval(tlib#var#EGet('foo', 'wbg')) => 3 -< - - *tlib#var#Get()* -tlib#var#Get(var, namespace, ?default='') - Retrieve a variable by searching several namespaces. - - EXAMPLES: > - let g:foo = 1 - let b:foo = 2 - let w:foo = 3 - echo tlib#var#Get('foo', 'bg') => 1 - echo tlib#var#Get('foo', 'bg') => 2 - echo tlib#var#Get('foo', 'wbg') => 3 -< - - *tlib#var#List()* -tlib#var#List(rx, ?prefix='') - Get a list of variables matching rx. - EXAMPLE: - echo tlib#var#List('tlib_', 'g:') - - -======================================================================== -autoload/tlib/agent.vim~ -Various agents for use as key handlers in tlib#input#List() - - *g:tlib_scroll_lines* -g:tlib_scroll_lines (default: 10) - Number of items to move when pressing in the input list window. - - *tlib#agent#Exit()* -tlib#agent#Exit(world, selected) - - *tlib#agent#CopyItems()* -tlib#agent#CopyItems(world, selected) - - *tlib#agent#PageUp()* -tlib#agent#PageUp(world, selected) - - *tlib#agent#PageDown()* -tlib#agent#PageDown(world, selected) - - *tlib#agent#Home()* -tlib#agent#Home(world, selected) - - *tlib#agent#End()* -tlib#agent#End(world, selected) - - *tlib#agent#Up()* -tlib#agent#Up(world, selected, ...) - - *tlib#agent#Down()* -tlib#agent#Down(world, selected, ...) - - *tlib#agent#UpN()* -tlib#agent#UpN(world, selected) - - *tlib#agent#DownN()* -tlib#agent#DownN(world, selected) - - *tlib#agent#ShiftLeft()* -tlib#agent#ShiftLeft(world, selected) - - *tlib#agent#ShiftRight()* -tlib#agent#ShiftRight(world, selected) - - *tlib#agent#Reset()* -tlib#agent#Reset(world, selected) - - *tlib#agent#ToggleRestrictView()* -tlib#agent#ToggleRestrictView(world, selected) - - *tlib#agent#RestrictView()* -tlib#agent#RestrictView(world, selected) - - *tlib#agent#UnrestrictView()* -tlib#agent#UnrestrictView(world, selected) - - *tlib#agent#Input()* -tlib#agent#Input(world, selected) - - *tlib#agent#SuspendToParentWindow()* -tlib#agent#SuspendToParentWindow(world, selected) - Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the - original position in the parent window. - - *tlib#agent#Suspend()* -tlib#agent#Suspend(world, selected) - Suspend lets you temporarily leave the input loop of - |tlib#input#List|. You can resume editing the list by pressing , - . , or in the suspended window. - and will immediatly select the item under the cursor. - < will select the item but the window will remain opened. - - *tlib#agent#Help()* -tlib#agent#Help(world, selected) - - *tlib#agent#OR()* -tlib#agent#OR(world, selected) - - *tlib#agent#AND()* -tlib#agent#AND(world, selected) - - *tlib#agent#ReduceFilter()* -tlib#agent#ReduceFilter(world, selected) - - *tlib#agent#PopFilter()* -tlib#agent#PopFilter(world, selected) - - *tlib#agent#Debug()* -tlib#agent#Debug(world, selected) - - *tlib#agent#Select()* -tlib#agent#Select(world, selected) - - *tlib#agent#SelectUp()* -tlib#agent#SelectUp(world, selected) - - *tlib#agent#SelectDown()* -tlib#agent#SelectDown(world, selected) - - *tlib#agent#SelectAll()* -tlib#agent#SelectAll(world, selected) - - *tlib#agent#ToggleStickyList()* -tlib#agent#ToggleStickyList(world, selected) - - *tlib#agent#EditItem()* -tlib#agent#EditItem(world, selected) - - *tlib#agent#NewItem()* -tlib#agent#NewItem(world, selected) - Insert a new item below the current one. - - *tlib#agent#DeleteItems()* -tlib#agent#DeleteItems(world, selected) - - *tlib#agent#Cut()* -tlib#agent#Cut(world, selected) - - *tlib#agent#Copy()* -tlib#agent#Copy(world, selected) - - *tlib#agent#Paste()* -tlib#agent#Paste(world, selected) - - *tlib#agent#EditReturnValue()* -tlib#agent#EditReturnValue(world, rv) - - *tlib#agent#ViewFile()* -tlib#agent#ViewFile(world, selected) - - *tlib#agent#EditFile()* -tlib#agent#EditFile(world, selected) - - *tlib#agent#EditFileInSplit()* -tlib#agent#EditFileInSplit(world, selected) - - *tlib#agent#EditFileInVSplit()* -tlib#agent#EditFileInVSplit(world, selected) - - *tlib#agent#EditFileInTab()* -tlib#agent#EditFileInTab(world, selected) - - *tlib#agent#ToggleScrollbind()* -tlib#agent#ToggleScrollbind(world, selected) - - *tlib#agent#ShowInfo()* -tlib#agent#ShowInfo(world, selected) - - *tlib#agent#PreviewLine()* -tlib#agent#PreviewLine(world, selected) - - *tlib#agent#GotoLine()* -tlib#agent#GotoLine(world, selected) - If not called from the scratch, we assume/guess that we don't have to - suspend the input-evaluation loop. - - *tlib#agent#DoAtLine()* -tlib#agent#DoAtLine(world, selected) - - *tlib#agent#Wildcard()* -tlib#agent#Wildcard(world, selected) - - *tlib#agent#Null()* -tlib#agent#Null(world, selected) - - *tlib#agent#ExecAgentByName()* -tlib#agent#ExecAgentByName(world, selected) - - *tlib#agent#CompleteAgentNames()* -tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) - - *tlib#agent#Complete()* -tlib#agent#Complete(world, selected) - - -======================================================================== -autoload/tlib/bitwise.vim~ - - *tlib#bitwise#Num2Bits()* -tlib#bitwise#Num2Bits(num) - - *tlib#bitwise#Bits2Num()* -tlib#bitwise#Bits2Num(bits, ...) - - *tlib#bitwise#AND()* -tlib#bitwise#AND(num1, num2, ...) - - *tlib#bitwise#OR()* -tlib#bitwise#OR(num1, num2, ...) - - *tlib#bitwise#XOR()* -tlib#bitwise#XOR(num1, num2, ...) - - *tlib#bitwise#ShiftRight()* -tlib#bitwise#ShiftRight(bits, n) - - *tlib#bitwise#ShiftLeft()* -tlib#bitwise#ShiftLeft(bits, n) - - *tlib#bitwise#Add()* -tlib#bitwise#Add(num1, num2, ...) - - *tlib#bitwise#Sub()* -tlib#bitwise#Sub(num1, num2, ...) - - -======================================================================== -autoload/tlib/url.vim~ - - *tlib#url#Decode()* -tlib#url#Decode(url) - Decode an encoded URL. - - *tlib#url#DecodeChar()* -tlib#url#DecodeChar(char) - Decode a single character. - - *tlib#url#EncodeChar()* -tlib#url#EncodeChar(char) - Encode a single character. - - *tlib#url#Encode()* -tlib#url#Encode(url, ...) - Encode an URL. - - -======================================================================== -autoload/tlib/signs.vim~ - - *tlib#signs#ClearAll()* -tlib#signs#ClearAll(sign) - Clear all signs with name SIGN. - - *tlib#signs#ClearBuffer()* -tlib#signs#ClearBuffer(sign, bufnr) - Clear all signs with name SIGN in buffer BUFNR. - - *tlib#signs#Mark()* -tlib#signs#Mark(sign, list) - Add signs for all locations in LIST. LIST must adhere with the - quickfix list format (see |getqflist()|; only the fields lnum and - bufnr are required). - - list:: a quickfix or location list - sign:: a sign defined with |:sign-define| - - -======================================================================== -autoload/tlib/rx.vim~ - - *tlib#rx#Escape()* -tlib#rx#Escape(text, ?magic='m') - magic can be one of: m, M, v, V - See :help 'magic' - - *tlib#rx#EscapeReplace()* -tlib#rx#EscapeReplace(text, ?magic='m') - Escape return |sub-replace-special|. - - *tlib#rx#Suffixes()* -tlib#rx#Suffixes(...) - - *tlib#rx#LooksLikeRegexp()* -tlib#rx#LooksLikeRegexp(text) - - -======================================================================== -autoload/tlib/tag.vim~ - - *g:tlib_tags_extra* -g:tlib_tags_extra (default: '') - Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. - - *g:tlib_tag_substitute* -g:tlib_tag_substitute - Filter the tag description through |substitute()| for these filetypes. - This applies only if the tag cmd field (see |taglist()|) is used. - - *tlib#tag#Retrieve()* -tlib#tag#Retrieve(rx, ?extra_tags=0) - Get all tags matching rx. Basically, this function simply calls - |taglist()|, but when extra_tags is true, the list of the tag files - (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. - - Example use: - If you want to include tags for, eg, JDK, normal tags use can become - slow. You could proceed as follows: - 1. Create a tags file for the JDK sources. When creating the tags - file, make sure to include inheritance information and the like - (command-line options like --fields=+iaSm --extra=+q should be ok). - In this example, we want tags only for public methods (there are - most likely better ways to do this): > - ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src - head -n 6 tags > tags0 - grep access:public tags >> tags0 -< 2. Make 'tags' include project specific tags files. In - ~/vimfiles/after/ftplugin/java.vim insert: > - let b:tlib_tags_extra = $JAVA_HOME .'/tags0' -< 3. When this function is invoked as > - echo tlib#tag#Retrieve('print') -< it will return only project-local tags. If it is invoked as > - echo tlib#tag#Retrieve('print', 1) -< tags from the JDK will be included. - - *tlib#tag#Collect()* -tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) - Retrieve tags that meet the constraints (a dictionnary of fields and - regexp, with the exception of the kind field which is a list of chars). - For the use of the optional use_extra argument see - |tlib#tag#Retrieve()|. - - *tlib#tag#Format()* -tlib#tag#Format(tag) - - -======================================================================== -autoload/tlib/map.vim~ - - *tlib#map#PumAccept()* -tlib#map#PumAccept(key) - If |pumvisible()| is true, return "\". Otherwise return a:key. - For use in maps like: > - imap tlib#map#PumAccept("\") -< - - -======================================================================== -autoload/tlib/Filter_cnfd.vim~ - - *tlib#Filter_cnfd#New()* -tlib#Filter_cnfd#New(...) - The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. - As a consequence, patterns cannot match dots. - The pattern is a '/\V' very no-'/magic' regexp pattern. - - -======================================================================== -autoload/tlib/input.vim~ -Input-related, select from a list etc. - - *g:tlib#input#sortprefs_threshold* -g:tlib#input#sortprefs_threshold (default: 200) - If a list is bigger than this value, don't try to be smart when - selecting an item. Be slightly faster instead. - See |tlib#input#List()|. - - *g:tlib#input#livesearch_threshold* -g:tlib#input#livesearch_threshold (default: 1000) - If a list contains more items, |tlib#input#List()| does not perform an - incremental "live search" but uses |input()| to query the user for a - filter. This is useful on slower machines or with very long lists. - - *g:tlib#input#filter_mode* -g:tlib#input#filter_mode (default: 'glob') - Determine how |tlib#input#List()| and related functions work. - Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: - glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, - |g:tlib#Filter_glob#char|) are interpreted as glob-like - |wildcards| (this is the default method) - - Examples: - - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match - "far". - - Otherwise it is a derivate of the cnf method (see below). - - See also |tlib#Filter_glob#New()|. - cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is - expanded to "\.\{-}" - - A period character (".") acts as a wildcard as if ".\{-}" (see - |/\{-|) were entered. - - Examples: - - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match - "far". - - Otherwise it is a derivate of the cnf method (see below). - - See also |tlib#Filter_cnfd#New()|. - cnf .... Match substrings - - A blank creates an AND conjunction, i.e. the next pattern has to - match too. - - A pipe character ("|") creates an OR conjunction, either this or - the next next pattern has to match. - - Patterns are very 'nomagic' |regexp| with a |\V| prefix. - - A pattern starting with "-" makes the filter exclude items - matching that pattern. - - Examples: - - "foo bar" matches items that contain the strings "foo" AND - "bar". - - "foo|bar boo|far" matches items that contain either ("foo" OR - "bar") AND ("boo" OR "far"). - - See also |tlib#Filter_cnf#New()|. - seq .... Match sequences of characters - - |tlib#Filter_seq#New()| - fuzzy .. Match fuzzy character sequences - - |tlib#Filter_fuzzy#New()| - - *g:tlib#input#higroup* -g:tlib#input#higroup (default: 'IncSearch') - The highlight group to use for showing matches in the input list - window. - See |tlib#input#List()|. - - *g:tlib_pick_last_item* -g:tlib_pick_last_item (default: 1) - When 1, automatically select the last remaining item only if the list - had only one item to begin with. - When 2, automatically select a last remaining item after applying - any filters. - See |tlib#input#List()|. - - -Keys for |tlib#input#List|~ - - *g:tlib#input#and* -g:tlib#input#and (default: ' ') - - *g:tlib#input#or* -g:tlib#input#or (default: '|') - - *g:tlib#input#not* -g:tlib#input#not (default: '-') - - *g:tlib#input#numeric_chars* -g:tlib#input#numeric_chars - When editing a list with |tlib#input#List|, typing these numeric chars - (as returned by getchar()) will select an item based on its index, not - based on its name. I.e. in the default setting, typing a "4" will - select the fourth item, not the item called "4". - In order to make keys 0-9 filter the items in the list and make - select an item by its index, remove the keys 48 to 57 from - this dictionary. - Format: [KEY] = BASE ... the number is calculated as KEY - BASE. - - *g:tlib#input#keyagents_InputList_s* -g:tlib#input#keyagents_InputList_s - The default key bindings for single-item-select list views. - - This variable is best customized via the variable - g:tlib_extend_keyagents_InputList_s. If you want to use , - to move the cursor up and down, add these two lines to your |vimrc| - file: - - let g:tlib_extend_keyagents_InputList_s = { - \ 10: 'tlib#agent#Down', - \ 11: 'tlib#agent#Up' - \ } - - *g:tlib#input#keyagents_InputList_m* -g:tlib#input#keyagents_InputList_m - - *g:tlib#input#handlers_EditList* -g:tlib#input#handlers_EditList - - *g:tlib#input#user_shortcuts* -g:tlib#input#user_shortcuts (default: {}) - A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to - customize keyboard shortcuts in the list view. - - *g:tlib#input#use_popup* -g:tlib#input#use_popup (default: has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32'))) - If true, define a popup menu for |tlib#input#List()| and related - functions. - - *g:tlib#input#format_filename* -g:tlib#input#format_filename (default: 'l') - How to format filenames: - l ... Show basenames on the left side, separated from the - directory names - r ... Show basenames on the right side - - *g:tlib#input#filename_padding_r* -g:tlib#input#filename_padding_r (default: '&co / 10') - If g:tlib#input#format_filename == 'r', how much space should be kept - free on the right side. - - *g:tlib#input#filename_max_width* -g:tlib#input#filename_max_width (default: '&co / 2') - If g:tlib#input#format_filename == 'l', an expression that - |eval()|uates to the maximum display width of filenames. - - *tlib#input#List()* -tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) - Select a single or multiple items from a list. Return either the list - of selected elements or its indexes. - - By default, typing numbers will select an item by its index. See - |g:tlib#input#numeric_chars| to find out how to change this. - - The item is automatically selected if the numbers typed equals the - number of digits of the list length. I.e. if a list contains 20 items, - typing 1 will first highlight item 1 but it won't select/use it - because 1 is an ambiguous input in this context. If you press enter, - the first item will be selected. If you press another digit (e.g. 0), - item 10 will be selected. Another way to select item 1 would be to - type 01. If the list contains only 9 items, typing 1 would select the - first item right away. - - type can be: - s ... Return one selected element - si ... Return the index of the selected element - m ... Return a list of selected elements - mi ... Return a list of indexes - - Several pattern matching styles are supported. See - |g:tlib#input#filter_mode|. - - Users can type to complete the current filter with the longest - match. - - EXAMPLES: > - echo tlib#input#List('s', 'Select one item', [100,200,300]) - echo tlib#input#List('si', 'Select one item', [100,200,300]) - echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) - echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) - -< See ../samples/tlib/input/tlib_input_list.vim (move the cursor over - the filename and press gf) for a more elaborated example. - - *tlib#input#ListD()* -tlib#input#ListD(dict) - A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from - dict. - - *tlib#input#ListW()* -tlib#input#ListW(world, ?command='') - The second argument (command) is meant for internal use only. - The same as |tlib#input#List| but the arguments are packed into world - (an instance of tlib#World as returned by |tlib#World#New|). - - *tlib#input#EditList()* -tlib#input#EditList(query, list, ?timeout=0) - Edit a list. - - EXAMPLES: > - echo tlib#input#EditList('Edit:', [100,200,300]) -< - - *tlib#input#Resume()* -tlib#input#Resume(name, pick, bufnr) - - *tlib#input#CommandSelect()* -tlib#input#CommandSelect(command, ?keyargs={}) - Take a command, view the output, and let the user select an item from - its output. - - EXAMPLE: > - command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') - command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') -< - - *tlib#input#Edit()* -tlib#input#Edit(name, value, callback, ?cb_args=[]) - - Edit a value (asynchronously) in a scratch buffer. Use name for - identification. Call callback when done (or on cancel). - In the scratch buffer: - Press or to enter the new value, c to cancel - editing. - EXAMPLES: > - fun! FooContinue(success, text) - if a:success - let b:var = a:text - endif - endf - call tlib#input#Edit('foo', b:var, 'FooContinue') -< - - *tlib#input#Dialog()* -tlib#input#Dialog(text, options, default) - - -======================================================================== -autoload/tlib/number.vim~ - - *tlib#number#ConvertBase()* -tlib#number#ConvertBase(num, base, ...) - - -======================================================================== -autoload/tlib/file.vim~ - - *g:tlib#file#drop* -g:tlib#file#drop (default: has('gui')) - If true, use |:drop| to edit loaded buffers (only available with GUI). - - *g:tlib#file#use_tabs* -g:tlib#file#use_tabs (default: 0) - - *g:tlib#file#edit_cmds* -g:tlib#file#edit_cmds (default: g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {}) - - *g:tlib#file#absolute_filename_rx* -g:tlib#file#absolute_filename_rx (default: '^\~\?[\/]') - - *tlib#file#Split()* -tlib#file#Split(filename) - EXAMPLES: > - tlib#file#Split('foo/bar/filename.txt') - => ['foo', 'bar', 'filename.txt'] -< - - *tlib#file#Join()* -tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) - EXAMPLES: > - tlib#file#Join(['foo', 'bar', 'filename.txt']) - => 'foo/bar/filename.txt' -< - - *tlib#file#Relative()* -tlib#file#Relative(filename, basedir) - EXAMPLES: > - tlib#file#Relative('foo/bar/filename.txt', 'foo') - => 'bar/filename.txt' -< - - *tlib#file#Absolute()* -tlib#file#Absolute(filename, ...) - - *tlib#file#Canonic()* -tlib#file#Canonic(filename, ...) - - *tlib#file#With()* -tlib#file#With(fcmd, bcmd, files, ?world={}) - - *tlib#file#Edit()* -tlib#file#Edit(fileid) - Return 0 if the file isn't readable/doesn't exist. - Otherwise return 1. - - *tlib#file#Glob()* -tlib#file#Glob(pattern) - - *tlib#file#Globpath()* -tlib#file#Globpath(path, pattern) - - -======================================================================== -autoload/tlib/sys.vim~ - - *g:tlib#sys#special_protocols* -g:tlib#sys#special_protocols (default: ['https\?', 'nntp', 'mailto']) - A list of |regexp|s matching protocol names that should be handled - by |g:tlib#sys#system_browser|. - CAVEAT: Must be a |\V| |regexp|. - - *g:tlib#sys#special_suffixes* -g:tlib#sys#special_suffixes (default: ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif']) - A list of |regexp|s matching suffixes that should be handled by - |g:tlib#sys#system_browser|. - CAVEAT: Must be a |\V| |regexp|. - - *g:tlib#sys#system_rx* -g:tlib#sys#system_rx (default: printf('\V\%(\^\%(%s\):\|.\%(%s\)\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|'))) - Open links matching this |regexp| with |g:tlib#sys#system_browser|. - CAVEAT: Must be a |\V| |regexp|. - - *g:tlib#sys#system_browser* -g:tlib#sys#system_browser (default: ...) - Open files in the system browser. - - *g:tlib#sys#windows* -g:tlib#sys#windows (default: &shell !~ 'sh' && (has('win16') || has('win32') || has('win64'))) - - *g:tlib#sys#null* -g:tlib#sys#null (default: g:tlib#sys#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : '')) - - *tlib#sys#IsCygwinBin()* -tlib#sys#IsCygwinBin(cmd) - - *tlib#sys#IsExecutable()* -tlib#sys#IsExecutable(cmd, ...) - - *g:tlib#sys#check_cygpath* -g:tlib#sys#check_cygpath (default: g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1)) - If true, check whether we have to convert a path via cyppath -- - see |tlib#sys#MaybeUseCygpath| - - *g:tlib#sys#cygwin_path_rx* -g:tlib#sys#cygwin_path_rx (default: '/cygwin/') - If a full windows filename (with slashes instead of backslashes) - matches this |regexp|, it is assumed to be a cygwin executable. - - *g:tlib#sys#cygwin_expr* -g:tlib#sys#cygwin_expr (default: '"bash -c ''". escape(%s, "''\\") ."''"') - For cygwin binaries, convert command calls using this vim - expression. - - *tlib#sys#GetCmd()* -tlib#sys#GetCmd(cmd) - - *tlib#sys#MaybeUseCygpath()* -tlib#sys#MaybeUseCygpath(cmd) - If cmd seems to be a cygwin executable, use cygpath to convert - filenames. This assumes that cygwin's which command returns full - filenames for non-cygwin executables. - - *tlib#sys#ConvertPath()* -tlib#sys#ConvertPath(converter, filename) - - *tlib#sys#FileArgs()* -tlib#sys#FileArgs(cmd, files) - - *tlib#sys#IsSpecial()* -tlib#sys#IsSpecial(filename) - Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it - is a special file that should not be opened in vim. - - *tlib#sys#Open()* -tlib#sys#Open(filename) - Open filename with the default OS application (see - |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. - Returns 1 if successful or 0 otherwise. - - *tlib#sys#SystemInDir()* -tlib#sys#SystemInDir(dir, expr, ?input='') - - -======================================================================== -autoload/tlib/paragraph.vim~ - - *tlib#paragraph#GetMetric()* -tlib#paragraph#GetMetric() - Return an object describing a |paragraph|. - - *tlib#paragraph#Move()* -tlib#paragraph#Move(direction, count) - This function can be used with the tinymode plugin to move around - paragraphs. - - Example configuration: > - - call tinymode#EnterMap("para_move", "gp") - call tinymode#ModeMsg("para_move", "Move paragraph: j/k") - call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") - call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") - call tinymode#ModeArg("para_move", "owncount", 1) -< - - -======================================================================== -autoload/tlib/World.vim~ -A prototype used by |tlib#input#List|. -Inherits from |tlib#Object#New|. - - *g:tlib_inputlist_pct* -g:tlib_inputlist_pct (default: 50) - Size of the input list window (in percent) from the main size (of &lines). - See |tlib#input#List()|. - - *g:tlib_inputlist_width_filename* -g:tlib_inputlist_width_filename (default: '&co / 3') - Size of filename columns when listing filenames. - See |tlib#input#List()|. - - *g:tlib_inputlist_filename_indicators* -g:tlib_inputlist_filename_indicators (default: 0) - If true, |tlib#input#List()| will show some indicators about the - status of a filename (e.g. buflisted(), bufloaded() etc.). - This is disabled by default because vim checks also for the file on - disk when doing this. - - *g:tlib_inputlist_shortmessage* -g:tlib_inputlist_shortmessage (default: 0) - If not null, display only a short info about the filter. - - *tlib#World#New()* -tlib#World#New(...) - -prototype.PrintLines - -prototype.Suspend - - -======================================================================== -autoload/tlib/loclist.vim~ - - *tlib#loclist#Browse()* -tlib#loclist#Browse(...) - - -======================================================================== -autoload/tlib/tab.vim~ - - *tlib#tab#BufMap()* -tlib#tab#BufMap() - Return a dictionary of bufnumbers => [[tabpage, winnr] ...] - - *tlib#tab#TabWinNr()* -tlib#tab#TabWinNr(buffer) - Find a buffer's window at some tab page. - - *tlib#tab#Set()* -tlib#tab#Set(tabnr) - - -======================================================================== -autoload/tlib/date.vim~ - - *tlib#date#IsDate()* -tlib#date#IsDate(text) - - *tlib#date#Format()* -tlib#date#Format(secs1970) - - *tlib#date#DiffInDays()* -tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) - - *tlib#date#Parse()* -tlib#date#Parse(date, ?allow_zero=0) "{{{3 - - *tlib#date#SecondsSince1970()* -tlib#date#SecondsSince1970(date, ...) - tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) - - *tlib#date#Shift()* -tlib#date#Shift(date, shift) - - -======================================================================== -autoload/tlib/type.vim~ - - *tlib#type#IsNumber()* -tlib#type#IsNumber(expr) - - *tlib#type#IsString()* -tlib#type#IsString(expr) - - *tlib#type#IsFuncref()* -tlib#type#IsFuncref(expr) - - *tlib#type#IsList()* -tlib#type#IsList(expr) - - *tlib#type#IsDictionary()* -tlib#type#IsDictionary(expr) - - *tlib#type#Is()* -tlib#type#Is(val, type) - - *tlib#type#Are()* -tlib#type#Are(vals, type) - - *tlib#type#Has()* -tlib#type#Has(val, lst) - - *tlib#type#Have()* -tlib#type#Have(vals, lst) - - -======================================================================== -autoload/tlib/Filter_fuzzy.vim~ - - *tlib#Filter_fuzzy#New()* -tlib#Filter_fuzzy#New(...) - Support for "fuzzy" pattern matching in |tlib#input#List()|. - Patterns are interpreted as if characters were connected with '.\{-}'. - - In "fuzzy" mode, the pretty printing of filenames is disabled. - - -======================================================================== -autoload/tlib/assert.vim~ - - *tlib#assert#Enable()* -tlib#assert#Enable() - Enable tracing via |:Tlibassert|. - - *tlib#assert#Disable()* -tlib#assert#Disable() - Disable tracing via |:Tlibassert|. - - *tlib#assert#Assert()* -tlib#assert#Assert(caller, check, vals) - - *tlib#assert#Map()* -tlib#assert#Map(vals, expr) - - *tlib#assert#All()* -tlib#assert#All(vals) - - -======================================================================== -autoload/tlib/textobjects.vim~ - - *standard-paragraph* -tlib#textobjects#StandardParagraph() - Select a "Standard Paragraph", i.e. a text block followed by blank - lines. Other than |ap|, the last paragraph in a document is handled - just the same. - - The |text-object| can be accessed as "sp". Example: > - - vsp ... select the current standard paragraph - -< Return 1, if the paragraph is the last one in the document. - - *tlib#textobjects#Init()* -tlib#textobjects#Init() - - *v_sp* -v_sp ... :call tlib#textobjects#StandardParagraph() - sp ... Standard paragraph (for use as |text-objects|). - - *o_sp* -o_sp ... :normal Vsp - - -======================================================================== -autoload/tlib/arg.vim~ - - *tlib#arg#Get()* -tlib#arg#Get(n, var, ?default="", ?test='') - Set a positional argument from a variable argument list. - See tlib#string#RemoveBackslashes() for an example. - - *tlib#arg#Let()* -tlib#arg#Let(list, ?default='') - Set a positional arguments from a variable argument list. - See tlib#input#List() for an example. - - *tlib#arg#StringAsKeyArgs()* -tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':', ?booleans=0) - - *tlib#arg#StringAsKeyArgsEqual()* -tlib#arg#StringAsKeyArgsEqual(string) - - *tlib#arg#GetOpts()* -tlib#arg#GetOpts(args, ?def={}) - Convert a list of strings of command-line arguments into a dictonary. - - The main use case is to pass [], i.e. the command-line - arguments of a command as list, from a command definition to this - function. - - Example: - ['-h'] - => If def contains a 'help' key, invoke |:help| on its value. - - ['-ab', '--foo', '--bar=BAR', 'bla', bla'] - => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} - - ['-ab', '--', '--foo', '--bar=BAR'] - => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} - - *tlib#arg#Ex()* -tlib#arg#Ex(arg, ?chars='%#! ') - Escape some characters in a string. - - Use |fnamescape()| if available. - - EXAMPLES: > - exec 'edit '. tlib#arg#Ex('foo%#bar.txt') -< - - -======================================================================== -autoload/tlib/fixes.vim~ - - *tlib#fixes#Winpos()* -tlib#fixes#Winpos() - - -======================================================================== -autoload/tlib/dir.vim~ - - *g:tlib#dir#sep* -g:tlib#dir#sep (default: exists('+shellslash') && !&shellslash ? '\' : '/') - TLet g:tlib#dir#sep = '/' - - *tlib#dir#CanonicName()* -tlib#dir#CanonicName(dirname) - EXAMPLES: > - tlib#dir#CanonicName('foo/bar') - => 'foo/bar/' -< - - *tlib#dir#NativeName()* -tlib#dir#NativeName(dirname) - EXAMPLES: > - tlib#dir#NativeName('foo/bar/') - On Windows: - => 'foo\bar\' - On Linux: - => 'foo/bar/' -< - - *tlib#dir#PlainName()* -tlib#dir#PlainName(dirname) - EXAMPLES: > - tlib#dir#PlainName('foo/bar/') - => 'foo/bar' -< - - *tlib#dir#Ensure()* -tlib#dir#Ensure(dir) - Create a directory if it doesn't already exist. - - *tlib#dir#MyRuntime()* -tlib#dir#MyRuntime() - Return the first directory in &rtp. - - *tlib#dir#CD()* -tlib#dir#CD(dir, ?locally=0) - - *tlib#dir#Push()* -tlib#dir#Push(dir, ?locally=0) - - *tlib#dir#Pop()* -tlib#dir#Pop() - - -======================================================================== -autoload/tlib/hash.vim~ - - *g:tlib#hash#use_crc32* -g:tlib#hash#use_crc32 (default: '') - - *g:tlib#hash#use_adler32* -g:tlib#hash#use_adler32 (default: '') - - *tlib#hash#CRC32B()* -tlib#hash#CRC32B(chars) - - *tlib#hash#CRC32B_ruby()* -tlib#hash#CRC32B_ruby(chars) - - *tlib#hash#CRC32B_vim()* -tlib#hash#CRC32B_vim(chars) - - *tlib#hash#Adler32()* -tlib#hash#Adler32(chars) - - *tlib#hash#Adler32_vim()* -tlib#hash#Adler32_vim(chars) - - *tlib#hash#Adler32_tlib()* -tlib#hash#Adler32_tlib(chars) - - -======================================================================== -autoload/tlib/win.vim~ - - *tlib#win#Set()* -tlib#win#Set(winnr) - Return vim code to jump back to the original window. - - *tlib#win#GetLayout()* -tlib#win#GetLayout(?save_view=0) - - *tlib#win#SetLayout()* -tlib#win#SetLayout(layout) - - *tlib#win#List()* -tlib#win#List() - - *tlib#win#Width()* -tlib#win#Width(wnr) - - *tlib#win#WinDo()* -tlib#win#WinDo(ex) - - -======================================================================== -autoload/tlib/comments.vim~ - - *tlib#comments#Comments()* -tlib#comments#Comments(...) - function! tlib#comments#Comments(?rx='') - - -======================================================================== -autoload/tlib/grep.vim~ - - *tlib#grep#Do()* -tlib#grep#Do(cmd, rx, files) - - *tlib#grep#LocList()* -tlib#grep#LocList(rx, files) - - *tlib#grep#QuickFixList()* -tlib#grep#QuickFixList(rx, files) - - *tlib#grep#List()* -tlib#grep#List(rx, files) - - -======================================================================== -autoload/tlib/qfl.vim~ - - *tlib#qfl#FormatQFLE()* -tlib#qfl#FormatQFLE(qfe) - - *tlib#qfl#QfeFilename()* -tlib#qfl#QfeFilename(qfe) - - *tlib#qfl#InitListBuffer()* -tlib#qfl#InitListBuffer(world) - - *tlib#qfl#SetSyntax()* -tlib#qfl#SetSyntax() - - *tlib#qfl#Balloon()* -tlib#qfl#Balloon() - - *tlib#qfl#AgentEditQFE()* -tlib#qfl#AgentEditQFE(world, selected, ...) - - *tlib#qfl#AgentPreviewQFE()* -tlib#qfl#AgentPreviewQFE(world, selected) - - *tlib#qfl#AgentGotoQFE()* -tlib#qfl#AgentGotoQFE(world, selected) - - *tlib#qfl#AgentWithSelected()* -tlib#qfl#AgentWithSelected(world, selected, ...) - - *tlib#qfl#RunCmdOnSelected()* -tlib#qfl#RunCmdOnSelected(world, selected, cmd, ...) - - *tlib#qfl#AgentSplitBuffer()* -tlib#qfl#AgentSplitBuffer(world, selected) - - *tlib#qfl#AgentTabBuffer()* -tlib#qfl#AgentTabBuffer(world, selected) - - *tlib#qfl#AgentVSplitBuffer()* -tlib#qfl#AgentVSplitBuffer(world, selected) - - *tlib#qfl#AgentEditLine()* -tlib#qfl#AgentEditLine(world, selected) - - *tlib#qfl#EditLine()* -tlib#qfl#EditLine(lnum) - - *tlib#qfl#SetFollowCursor()* -tlib#qfl#SetFollowCursor(world, selected) - - *tlib#qfl#QflList()* -tlib#qfl#QflList(list, ...) - - *tlib#qfl#Browse()* -tlib#qfl#Browse(...) - - -======================================================================== -autoload/tlib/Filter_cnf.vim~ - - *tlib#Filter_cnf#New()* -tlib#Filter_cnf#New(...) - The search pattern for |tlib#input#List()| is in conjunctive normal - form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... - The pattern is a '/\V' very no-'/magic' regexp pattern. - - Pressing joins two patterns with AND. - Pressing | joins two patterns with OR. - I.e. In order to get "lala AND (foo OR bar)", you type - "lala foo|bar". - - This is also the base class for other filters. - -prototype.Pretty - - -======================================================================== -autoload/tlib/Object.vim~ -Provides a prototype plus some OO-like methods. - - *tlib#Object#New()* -tlib#Object#New(?fields={}) - This function creates a prototype that provides some kind of - inheritance mechanism and a way to call parent/super methods. - - The usage demonstrated in the following example works best when every - class/prototype is defined in a file of its own. - - The reason for why there is a dedicated constructor function is that - this layout facilitates the use of templates and that methods are - hidden from the user. Other solutions are possible. - - EXAMPLES: > - let s:prototype = tlib#Object#New({ - \ '_class': ['FooBar'], - \ 'foo': 1, - \ 'bar': 2, - \ }) - " Constructor - function! FooBar(...) - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object - endf - function! s:prototype.babble() { - echo "I think, therefore I am ". (self.foo * self.bar) ." months old." - } - -< This could now be used like this: > - let myfoo = FooBar({'foo': 3}) - call myfoo.babble() - => I think, therefore I am 6 months old. - echo myfoo.IsA('FooBar') - => 1 - echo myfoo.IsA('object') - => 1 - echo myfoo.IsA('Foo') - => 0 - echo myfoo.RespondTo('babble') - => 1 - echo myfoo.RespondTo('speak') - => 0 -< - -prototype.New - -prototype.Inherit - -prototype.Extend - -prototype.IsA - -prototype.IsRelated - -prototype.RespondTo - -prototype.Super - - *tlib#Object#Methods()* -tlib#Object#Methods(object, ...) - - -======================================================================== -autoload/tlib/buffer.vim~ - - *g:tlib_viewline_position* -g:tlib_viewline_position (default: 'zz') - Where to display the line when using |tlib#buffer#ViewLine|. - For possible values for position see |scroll-cursor|. - - *tlib#buffer#EnableMRU()* -tlib#buffer#EnableMRU() - - *tlib#buffer#DisableMRU()* -tlib#buffer#DisableMRU() - - *tlib#buffer#Set()* -tlib#buffer#Set(buffer) - Set the buffer to buffer and return a command as string that can be - evaluated by |:execute| in order to restore the original view. - - *tlib#buffer#Eval()* -tlib#buffer#Eval(buffer, code) - Evaluate CODE in BUFFER. - - EXAMPLES: > - call tlib#buffer#Eval('foo.txt', 'echo b:bar') -< - - *tlib#buffer#GetList()* -tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') - Possible values for the "order" argument: - bufnr :: Default behaviour - mru :: Sort buffers according to most recent use - basename :: Sort by the file's basename (last component) - - NOTE: MRU order works on second invocation only. If you want to always - use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. - - *tlib#buffer#ViewLine()* -tlib#buffer#ViewLine(line, ?position='z') - line is either a number or a string that begins with a number. - For possible values for position see |scroll-cursor|. - See also |g:tlib_viewline_position|. - - *tlib#buffer#HighlightLine()* -tlib#buffer#HighlightLine(...) - - *tlib#buffer#DeleteRange()* -tlib#buffer#DeleteRange(line1, line2) - Delete the lines in the current buffer. Wrapper for |:delete|. - - *tlib#buffer#ReplaceRange()* -tlib#buffer#ReplaceRange(line1, line2, lines) - Replace a range of lines. - - *tlib#buffer#ScratchStart()* -tlib#buffer#ScratchStart() - Initialize some scratch area at the bottom of the current buffer. - - *tlib#buffer#ScratchEnd()* -tlib#buffer#ScratchEnd() - Remove the in-buffer scratch area. - - *tlib#buffer#BufDo()* -tlib#buffer#BufDo(exec) - Run exec on all buffers via bufdo and return to the original buffer. - - *tlib#buffer#InsertText()* -tlib#buffer#InsertText(text, keyargs) - Keyargs: - 'shift': 0|N - 'col': col('.')|N - 'lineno': line('.')|N - 'indent': 0|1 - 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) - Insert text (a string) in the buffer. - - *tlib#buffer#InsertText0()* -tlib#buffer#InsertText0(text, ...) - - *tlib#buffer#CurrentByte()* -tlib#buffer#CurrentByte() - - *tlib#buffer#KeepCursorPosition()* -tlib#buffer#KeepCursorPosition(cmd) - Evaluate cmd while maintaining the cursor position and jump registers. - - -======================================================================== -autoload/tlib/hook.vim~ - - *tlib#hook#Run()* -tlib#hook#Run(hook, ?dict={}) - Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. - - -======================================================================== -autoload/tlib/string.vim~ - - *tlib#string#RemoveBackslashes()* -tlib#string#RemoveBackslashes(text, ?chars=' ') - Remove backslashes from text (but only in front of the characters in - chars). - - *tlib#string#Chomp()* -tlib#string#Chomp(string, ?max=0) - - *tlib#string#Format()* -tlib#string#Format(template, dict) - - *tlib#string#Printf1()* -tlib#string#Printf1(format, string) - This function deviates from |printf()| in certain ways. - Additional items: - %{rx} ... insert escaped regexp - %{fuzzyrx} ... insert typo-tolerant regexp - - *tlib#string#TrimLeft()* -tlib#string#TrimLeft(string) - - *tlib#string#TrimRight()* -tlib#string#TrimRight(string) - - *tlib#string#Strip()* -tlib#string#Strip(string) - - *tlib#string#Count()* -tlib#string#Count(string, rx) - - *tlib#string#SplitCommaList()* -tlib#string#SplitCommaList(text, ...) - - - -vim:tw=78:fo=w2croql:isk=!-~,^*,^|,^":ts=8:ft=help:norl: diff --git a/sources_non_forked/tlib/plugin/02tlib.vim b/sources_non_forked/tlib/plugin/02tlib.vim deleted file mode 100644 index cc2c3ca0..00000000 --- a/sources_non_forked/tlib/plugin/02tlib.vim +++ /dev/null @@ -1,102 +0,0 @@ -" @Author: Tom Link (micathom AT gmail com?subject=[vim]) -" @Created: 2007-04-10. -" @Last Change: 2015-11-23. -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 808 -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" GetLatestVimScripts: 1863 1 tlib.vim -" tlib.vim -- Some utility functions - -if &cp || exists("g:loaded_tlib") - finish -endif -if v:version < 700 "{{{2 - echoerr "tlib requires Vim >= 7" - finish -endif -let g:loaded_tlib = 117 - -let s:save_cpo = &cpo -set cpo&vim - - -" :display: :TLet VAR = VALUE -" Set a variable only if it doesn't already exist. -" EXAMPLES: > -" TLet foo = 1 -" TLet foo = 2 -" echo foo -" => 1 -command! -nargs=+ TLet if !exists(matchstr(, '^[^=[:space:]]\+')) | exec 'let '. | endif - - -" Open a scratch buffer (a buffer without a file). -" TScratch ... use split window -" TScratch! ... use the whole frame -" This command takes an (inner) dictionary as optional argument. -" EXAMPLES: > -" TScratch 'scratch': '__FOO__' -" => Open a scratch buffer named __FOO__ -command! -bar -nargs=* -bang TScratch call tlib#scratch#UseScratch({'scratch_split': empty(''), }) - - -" :display: :TVarArg VAR1, [VAR2, DEFAULT2] ... -" A convenience wrapper for |tlib#arg#Let|. -" EXAMPLES: > -" function! Foo(...) -" TVarArg ['a', 1], 'b' -" echo 'a='. a -" echo 'b='. b -" endf -command! -nargs=+ TVarArg exec tlib#arg#Let([]) - - -" :display: :TBrowseOutput COMMAND -" Ever wondered how to efficiently browse the output of a command -" without redirecting it to a file? This command takes a command as -" argument and presents the output via |tlib#input#List()| so that you -" can easily search for a keyword (e.g. the name of a variable or -" function) and the like. -" -" If you press enter, the selected line will be copied to the command -" line. Press ESC to cancel browsing. -" -" EXAMPLES: > -" TBrowseOutput 20verb TeaseTheCulprit -command! -nargs=1 -complete=command TBrowseOutput call tlib#cmd#BrowseOutput() - - -" :display: :TBrowseScriptnames -" List all sourced script names (the output of ':scriptnames'). -" -" When you press enter, the selected script will be opened in the current -" window. Press ESC to cancel. -" -" EXAMPLES: > -" TBrowseScriptnames -command! -nargs=0 -complete=command TBrowseScriptnames call tlib#cmd#TBrowseScriptnames() - - -" :display: :Tlibtrace GUARD, VAR1, VAR2... -" Do nothing unless |tlib#trace#Enable()| was called. -" -" When |:Tlibtraceset| or |tlib#trace#Enable()| were called: -" -" If GUARD is a number that evaluates to true or if it is a string that -" matches a |regexp|, which was added using Tlibtrace! (with '!'), -" display the values of VAR1, VAR2 ... -command! -nargs=+ -bang -bar Tlibtrace : - - -" :Tlibtraceset +RX1, -RX2... -" If |tlib#trace#Enable()| was called: With the optional , users -" can add and remove GUARDs (actually a |regexp|) that should be traced. -command! -nargs=+ -bang -bar Tlibtraceset call tlib#trace#Set() - - -" :display: :Tlibtrace ASSERTION -command! -nargs=+ -bang -bar Tlibassert : - - -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/sources_non_forked/tlib/test/tlib.vim b/sources_non_forked/tlib/test/tlib.vim deleted file mode 100644 index 2277d361..00000000 --- a/sources_non_forked/tlib/test/tlib.vim +++ /dev/null @@ -1,219 +0,0 @@ -" tLib.vim -" @Author: Thomas Link (mailto:micathom AT gmail com?subject=vim-tLib) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2006-12-17. -" @Last Change: 2008-11-23. -" @Revision: 129 - -if !exists("loaded_tassert") - echoerr 'tAssert (vimscript #1730) is required' -endif - - -TAssertBegin! "tlib" - - -" List {{{2 -fun! Add(a,b) - return a:a + a:b -endf -TAssert IsEqual(tlib#list#Inject([], 0, function('Add')), 0) -TAssert IsEqual(tlib#list#Inject([1,2,3], 0, function('Add')), 6) -delfunction Add - -TAssert IsEqual(tlib#list#Compact([]), []) -TAssert IsEqual(tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3]) - -TAssert IsEqual(tlib#list#Flatten([]), []) -TAssert IsEqual(tlib#list#Flatten([1,2,3]), [1,2,3]) -TAssert IsEqual(tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3]) -TAssert IsEqual(tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""]) - -TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3]) -TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30]) - -TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2'), 2) -TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20) -TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10) - -TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 2'), 1) -TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 5'), 0) - -TAssert IsEqual(tlib#list#All([1,2,3], 'v:val < 5'), 1) -TAssert IsEqual(tlib#list#All([1,2,3], 'v:val >= 2'), 0) - -TAssert IsEqual(tlib#list#Remove([1,2,1,2], 2), [1,1,2]) -TAssert IsEqual(tlib#list#RemoveAll([1,2,1,2], 2), [1,1]) - -TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]]) -TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]]) -TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]]) -TAssert IsEqual(tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]]) - - -" Vars {{{2 -let g:foo = 1 -let g:bar = 2 -let b:bar = 3 -let s:bar = 4 - -TAssert IsEqual(tlib#var#Get('bar', 'bg'), 3) -TAssert IsEqual(tlib#var#Get('bar', 'g'), 2) -TAssert IsEqual(tlib#var#Get('foo', 'bg'), 1) -TAssert IsEqual(tlib#var#Get('foo', 'g'), 1) -TAssert IsEqual(tlib#var#Get('none', 'l'), '') - -TAssert IsEqual(eval(tlib#var#EGet('bar', 'bg')), 3) -TAssert IsEqual(eval(tlib#var#EGet('bar', 'g')), 2) -" TAssert IsEqual(eval(tlib#var#EGet('bar', 'sg')), 4) -TAssert IsEqual(eval(tlib#var#EGet('foo', 'bg')), 1) -TAssert IsEqual(eval(tlib#var#EGet('foo', 'g')), 1) -TAssert IsEqual(eval(tlib#var#EGet('none', 'l')), '') - -unlet g:foo -unlet g:bar -unlet b:bar - - - -" Filenames {{{2 -TAssert IsEqual(tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt']) -TAssert IsEqual(tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt']) -TAssert IsEqual(tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt']) - -TAssert IsEqual(tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt') -TAssert IsEqual(tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt') -TAssert IsEqual(tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt') - -TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt') -TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt') -TAssert IsEqual(tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt') -TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt') -TAssert IsEqual(tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt') -TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt') -TAssert IsEqual(tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt') - - - -" Prototype-based programming {{{2 -let test = tlib#Test#New() -TAssert test.IsA('Test') -TAssert !test.IsA('foo') -TAssert test.RespondTo('RespondTo') -TAssert !test.RespondTo('RespondToNothing') -let test1 = tlib#Test#New() -TAssert test.IsRelated(test1) -let testworld = tlib#World#New() -TAssert !test.IsRelated(testworld) - -let testc = tlib#TestChild#New() -TAssert IsEqual(testc.Dummy(), 'TestChild.vim') -TAssert IsEqual(testc.Super('Dummy', []), 'Test.vim') - - - -" Optional arguments {{{2 -function! TestGetArg(...) "{{{3 - exec tlib#arg#Get(1, 'foo', 1) - return foo -endf - -function! TestGetArg1(...) "{{{3 - exec tlib#arg#Get(1, 'foo', 1, '!= ""') - return foo -endf - -TAssert IsEqual(TestGetArg(), 1) -TAssert IsEqual(TestGetArg(''), '') -TAssert IsEqual(TestGetArg(2), 2) -TAssert IsEqual(TestGetArg1(), 1) -TAssert IsEqual(TestGetArg1(''), 1) -TAssert IsEqual(TestGetArg1(2), 2) - -function! TestArgs(...) "{{{3 - exec tlib#arg#Let([['foo', "o"], ['bar', 2]]) - return repeat(foo, bar) -endf -TAssert IsEqual(TestArgs(), 'oo') -TAssert IsEqual(TestArgs('a'), 'aa') -TAssert IsEqual(TestArgs('a', 3), 'aaa') - -function! TestArgs1(...) "{{{3 - exec tlib#arg#Let(['foo', ['bar', 2]]) - return repeat(foo, bar) -endf -TAssert IsEqual(TestArgs1(), '') -TAssert IsEqual(TestArgs1('a'), 'aa') -TAssert IsEqual(TestArgs1('a', 3), 'aaa') - -function! TestArgs2(...) "{{{3 - exec tlib#arg#Let(['foo', 'bar'], 1) - return repeat(foo, bar) -endf -TAssert IsEqual(TestArgs2(), '1') -TAssert IsEqual(TestArgs2('a'), 'a') -TAssert IsEqual(TestArgs2('a', 3), 'aaa') - -function! TestArgs3(...) - TVarArg ['a', 1], 'b' - return a . b -endf -TAssert IsEqual(TestArgs3(), '1') -TAssert IsEqual(TestArgs3('a'), 'a') -TAssert IsEqual(TestArgs3('a', 3), 'a3') - -delfunction TestGetArg -delfunction TestGetArg1 -delfunction TestArgs -delfunction TestArgs1 -delfunction TestArgs2 -delfunction TestArgs3 - - - -" Strings {{{2 -TAssert IsString(tlib#string#RemoveBackslashes('foo bar')) -TAssert IsEqual(tlib#string#RemoveBackslashes('foo bar'), 'foo bar') -TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar') -TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar') -TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar') - - - -" Regexp {{{2 -for c in split('^$.*+\()|{}[]~', '\zs') - let s = printf('%sfoo%sbar%s', c, c, c) - TAssert (s =~ '\m^'. tlib#rx#Escape(s, 'm') .'$') - TAssert (s =~ '\M^'. tlib#rx#Escape(s, 'M') .'$') - TAssert (s =~ '\v^'. tlib#rx#Escape(s, 'v') .'$') - TAssert (s =~ '\V\^'. tlib#rx#Escape(s, 'V') .'\$') -endfor - - -" Encode, decode -TAssert IsEqual(tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar') -TAssert IsEqual(tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.') - -TAssert IsEqual(tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar') -TAssert IsEqual(tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.') - -TAssertEnd test test1 testc testworld - - -TAssert IsEqual(tlib#string#Count("fooo", "o"), 3) -TAssert IsEqual(tlib#string#Count("***", "\\*"), 3) -TAssert IsEqual(tlib#string#Count("***foo", "\\*"), 3) -TAssert IsEqual(tlib#string#Count("foo***", "\\*"), 3) - - -finish "{{{1 - - -" Input {{{2 -echo tlib#input#List('s', 'Test', ['barfoobar', 'barFoobar']) -echo tlib#input#List('s', 'Test', ['barfoobar', 'bar foo bar', 'barFoobar']) -echo tlib#input#List('s', 'Test', ['barfoobar', 'bar1Foo1bar', 'barFoobar']) -echo tlib#input#EditList('Test', ['bar1', 'bar2', 'bar3', 'foo1', 'foo2', 'foo3']) - - diff --git a/sources_non_forked/vim-abolish/.github/FUNDING.yml b/sources_non_forked/vim-abolish/.github/FUNDING.yml new file mode 100644 index 00000000..e2a49d11 --- /dev/null +++ b/sources_non_forked/vim-abolish/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: tpope +custom: ["https://www.paypal.me/vimpope"] diff --git a/sources_non_forked/vim-abolish/README.markdown b/sources_non_forked/vim-abolish/README.markdown index e8dd0d03..a9b0734a 100644 --- a/sources_non_forked/vim-abolish/README.markdown +++ b/sources_non_forked/vim-abolish/README.markdown @@ -117,22 +117,19 @@ There's also a variant for searching and a variant for grepping. ## Coercion Want to turn `fooBar` into `foo_bar`? Press `crs` (coerce to -snake\_case). MixedCase (`crm`), camelCase (`crc`), snake\_case -(`crs`), UPPER\_CASE (`cru`), dash-case (`cr-`), dot.case (`cr.`), -space case (`cr`), and Title Case (`crt`) are all just 3 +snake\_case). MixedCase (`crm`), camelCase (`crc`), UPPER\_CASE +(`cru`), dash-case (`cr-`), and dot.case (`cr.`) are all just 3 keystrokes away. ## Installation -If you don't have a preferred installation method, I recommend -installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and -then simply copy and paste: +Install using your favorite package manager, or use Vim's built-in package +support: - cd ~/.vim/bundle - git clone git://github.com/tpope/vim-abolish.git - -Once help tags have been generated, you can view the manual with -`:help abolish`. + mkdir -p ~/.vim/pack/tpope/start + cd ~/.vim/pack/tpope/start + git clone https://tpope.io/vim/abolish.git + vim -u NONE -c "helptags abolish/doc" -c q ## Self-Promotion diff --git a/sources_non_forked/vim-abolish/doc/abolish.txt b/sources_non_forked/vim-abolish/doc/abolish.txt index 91f24da9..ec1dd2f3 100644 --- a/sources_non_forked/vim-abolish/doc/abolish.txt +++ b/sources_non_forked/vim-abolish/doc/abolish.txt @@ -150,16 +150,15 @@ using the cr mapping (mnemonic: CoeRce) followed by one of the following characters: c: camelCase - m: MixedCase + p: PascalCase + m: MixedCase (aka PascalCase) _: snake_case s: snake_case u: SNAKE_UPPERCASE U: SNAKE_UPPERCASE - -: dash-case (not usually reversible; see |abolish-coercion-reversible|) k: kebab-case (not usually reversible; see |abolish-coercion-reversible|) + -: dash-case (aka kebab-case) .: dot.case (not usually reversible; see |abolish-coercion-reversible|) - : space case (not usually reversible; see |abolish-coercion-reversible|) - t: Title Case (not usually reversible; see |abolish-coercion-reversible|) For example, cru on a lowercase word is a slightly easier to type equivalent to gUiw. diff --git a/sources_non_forked/vim-abolish/plugin/abolish.vim b/sources_non_forked/vim-abolish/plugin/abolish.vim index 4a97542e..93d9adcd 100644 --- a/sources_non_forked/vim-abolish/plugin/abolish.vim +++ b/sources_non_forked/vim-abolish/plugin/abolish.vim @@ -1,6 +1,6 @@ " abolish.vim - Language friendly searches, substitutions, and abbreviations " Maintainer: Tim Pope -" Version: 1.1 +" Version: 1.2 " GetLatestVimScripts: 1545 1 :AutoInstall: abolish.vim " Initialization {{{1 @@ -23,8 +23,8 @@ endif " }}}1 " Utility functions {{{1 -function! s:function(name) - return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) +function! s:function(name) abort + return function(substitute(a:name,'^s:',matchstr(expand(''), '.*\zs\d\+_'),'')) endfunction function! s:send(self,func,...) @@ -142,10 +142,6 @@ function! s:dotcase(word) return substitute(s:snakecase(a:word),'_','.','g') endfunction -function! s:titlecase(word) - return substitute(s:spacecase(a:word), '\(\<\w\)','\=toupper(submatch(1))','g') -endfunction - call extend(Abolish, { \ 'camelcase': s:function('s:camelcase'), \ 'mixedcase': s:function('s:mixedcase'), @@ -154,7 +150,6 @@ call extend(Abolish, { \ 'dashcase': s:function('s:dashcase'), \ 'dotcase': s:function('s:dotcase'), \ 'spacecase': s:function('s:spacecase'), - \ 'titlecase': s:function('s:titlecase') \ }, 'keep') function! s:create_dictionary(lhs,rhs,opts) @@ -215,7 +210,6 @@ function! s:SubComplete(A,L,P) endfunction function! s:Complete(A,L,P) - let g:L = a:L " Vim bug: :Abolish - calls this function with a:A equal to 0 if a:A =~# '^[^/?-]' && type(a:A) != type(0) return join(s:words(),"\n") @@ -285,7 +279,7 @@ function! s:parse_subvert(bang,line1,line2,count,args) else let args = a:args endif - let separator = matchstr(args,'^.') + let separator = '\v((\\)@" @@ -402,6 +394,8 @@ function! s:grep_command(args,bang,flags,word) let dict = s:create_dictionary(a:word,"",opts) if &grepprg == "internal" let lhs = "'".s:pattern(dict,opts.boundaries)."'" + elseif &grepprg =~# '^rg\|^ag' + let lhs = "'".s:egrep_pattern(dict,opts.boundaries)."'" else let lhs = "-E '".s:egrep_pattern(dict,opts.boundaries)."'" endif @@ -566,6 +560,7 @@ endfunction call extend(Abolish.Coercions, { \ 'c': Abolish.camelcase, \ 'm': Abolish.mixedcase, + \ 'p': Abolish.mixedcase, \ 's': Abolish.snakecase, \ '_': Abolish.snakecase, \ 'u': Abolish.uppercase, @@ -574,7 +569,6 @@ call extend(Abolish.Coercions, { \ 'k': Abolish.dashcase, \ '.': Abolish.dotcase, \ ' ': Abolish.spacecase, - \ 't': Abolish.titlecase, \ "function missing": s:function("s:unknown_coercion") \}, "keep") @@ -591,6 +585,7 @@ function! s:coerce(type) abort let regbody = getreg('"') let regtype = getregtype('"') let c = v:count1 + let begin = getcurpos() while c > 0 let c -= 1 if a:type ==# 'line' @@ -603,9 +598,6 @@ function! s:coerce(type) abort silent exe 'normal!' move.'y' let word = @@ let @@ = s:send(g:Abolish.Coercions,s:transformation,word) - if !exists('begin') - let begin = getpos("'[") - endif if word !=# @@ let changed = 1 exe 'normal!' move.'p' @@ -621,8 +613,8 @@ function! s:coerce(type) abort endfunction nnoremap (abolish-coerce) coerce(nr2char(getchar())) -nnoremap (abolish-coerce) coerce(nr2char(getchar())) -nnoremap (abolish-coerce-word) coerce(nr2char(getchar())).'iw' +vnoremap (abolish-coerce) coerce(nr2char(getchar())) +nnoremap (abolish-coerce-word) coerce(nr2char(getchar())).'iw' " }}}1 diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim index 6fd3f044..e93820c2 100644 --- a/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim +++ b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim @@ -2,7 +2,8 @@ " TODO refactor: create glob function " noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"\\.git\\\\.hg\\node_modules\\\\.pyc" ) " noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"default" ) -function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern) +function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern, ...) + let opts = a:0 > 0 ? a:1 : {} if a:exclude_pattern == "default" let exclude_pattern = '\.git\|\.hg\|node_modules\|\.pyc' else @@ -16,7 +17,7 @@ function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern) let exclude = exclude_pattern == '' ? '' : ' | grep -v -e '.shellescape(exclude_pattern) - let cmd = 'find | grep -e '.shellescape(g).exclude + let cmd = get(opts, 'cmd_find', 'find'). ' . | grep -e '.shellescape(g).exclude let files = split(system(cmd),"\n") " for nom in a:excludes " call filter(files,nom) diff --git a/sources_non_forked/vim-bundle-mako/README.md b/sources_non_forked/vim-bundle-mako/README.md index 037e44e4..1867831c 100644 --- a/sources_non_forked/vim-bundle-mako/README.md +++ b/sources_non_forked/vim-bundle-mako/README.md @@ -12,6 +12,7 @@ Useful configuration variables: detection. * `g:mako_default_outer_lang`: if ftdetect cannot detect the "outer" filetype of the file, this sets the default filetype used. If not set, defaults to "html". +* `g:mako_extension`: set to the default string (with leading dot). Default is ".mako" About mako: http://www.makotemplates.org/ diff --git a/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim b/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim index 3051a431..49b7be04 100644 --- a/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim +++ b/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim @@ -1,11 +1,14 @@ if !exists("g:mako_detect_lang_from_ext") let g:mako_detect_lang_from_ext = 1 endif +if !exists("g:mako_extension") + let g:mako_extension = ".mako" +endif if g:mako_detect_lang_from_ext - au BufNewFile *.*.mako execute "do BufNewFile filetypedetect " . expand(":r") | let b:mako_outer_lang = &filetype + exe 'au BufNewFile *.*' . g:mako_extension . ' execute "do BufNewFile filetypedetect " . expand(":r") | let b:mako_outer_lang = &filetype' " it's important to get this before any of the normal BufRead autocmds execute " for this file, otherwise a mako tag at the start of the file can cause the " filetype to be set to mason - au BufReadPre *.*.mako execute "do BufRead filetypedetect " . expand(":r") | let b:mako_outer_lang = &filetype + exe 'au BufReadPre *.*' . g:mako_extension . ' execute "do BufRead filetypedetect " . expand(":r") | let b:mako_outer_lang = &filetype' endif -au BufRead,BufNewFile *.mako set filetype=mako +exe 'au BufRead,BufNewFile *' . g:mako_extension . ' set filetype=mako' diff --git a/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim b/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim index 41be4705..565defc7 100644 --- a/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim +++ b/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim @@ -1,11 +1,19 @@ " Vim filetype plugin file " Language: Mako " Maintainer: Randy Stauner -" Last Change: 2014-02-07 -" Version: 0.1 +" Last Change: 2019-09-06 +" Version: 0.2 if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 setlocal comments=:## setlocal commentstring=##%s + +if exists("loaded_matchit") + let b:match_ignorecase = 1 + let b:match_words = "<:>," . + \ "<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>," . + \ "<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>," . + \ "<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>" +endif diff --git a/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim b/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim index e6c4d698..4e5285d1 100644 --- a/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim +++ b/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim @@ -7,6 +7,7 @@ autocmd BufNewFile,BufRead *.coffee set filetype=coffee autocmd BufNewFile,BufRead *Cakefile set filetype=coffee autocmd BufNewFile,BufRead *.coffeekup,*.ck set filetype=coffee autocmd BufNewFile,BufRead *._coffee set filetype=coffee +autocmd BufNewFile,BufRead *.cson set filetype=coffee function! s:DetectCoffee() if getline(1) =~ '^#!.*\' diff --git a/sources_non_forked/vim-commentary/.github/FUNDING.yml b/sources_non_forked/vim-commentary/.github/FUNDING.yml new file mode 100644 index 00000000..e2a49d11 --- /dev/null +++ b/sources_non_forked/vim-commentary/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: tpope +custom: ["https://www.paypal.me/vimpope"] diff --git a/sources_non_forked/vim-commentary/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/doc/commentary.txt b/sources_non_forked/vim-commentary/doc/commentary.txt index b0485694..01f73dad 100644 --- a/sources_non_forked/vim-commentary/doc/commentary.txt +++ b/sources_non_forked/vim-commentary/doc/commentary.txt @@ -6,6 +6,9 @@ License: Same terms as Vim itself (see |license|) Comment stuff out. Then uncomment it later. Relies on 'commentstring' to be correctly set, or uses b:commentary_format if it is set. +Assign b:commentary_startofline to insert comment characters at column 1 +regardless of indentation. + *gc* gc{motion} Comment or uncomment lines that {motion} moves over. diff --git a/sources_non_forked/vim-commentary/plugin/commentary.vim b/sources_non_forked/vim-commentary/plugin/commentary.vim index 862ca820..079bce18 100644 --- a/sources_non_forked/vim-commentary/plugin/commentary.vim +++ b/sources_non_forked/vim-commentary/plugin/commentary.vim @@ -3,7 +3,7 @@ " Version: 1.3 " GetLatestVimScripts: 3695 1 :AutoInstall: commentary.vim -if exists("g:loaded_commentary") || v:version < 700 +if exists("g:loaded_commentary") || v:version < 703 finish endif let g:loaded_commentary = 1 @@ -15,10 +15,10 @@ endfunction function! s:strip_white_space(l,r,line) abort let [l, r] = [a:l, a:r] - if l[-1:] ==# ' ' && stridx(a:line,l) == -1 && stridx(a:line,l[0:-2]) == 0 + if l[-1:] ==# ' ' && stridx(a:line . ' ', l) == -1 && stridx(a:line, l[0:-2]) == 0 let l = l[:-2] endif - if r[0] ==# ' ' && a:line[-strlen(r):] != r && a:line[1-strlen(r):] == r[1:] + if r[0] ==# ' ' && (' ' . a:line)[-strlen(r)-1:] != r && a:line[-strlen(r):] == r[1:] let r = r[1:] endif return [l, r] @@ -36,6 +36,7 @@ function! s:go(...) abort let [l, r] = s:surroundings() let uncomment = 2 + let force_uncomment = a:0 > 2 && a:3 for lnum in range(lnum1,lnum2) let line = matchstr(getline(lnum),'\S.*\s\@ 2 && l.r !~# '\\' let line = substitute(line, - \'\M'.r[0:-2].'\zs\d\*\ze'.r[-1:-1].'\|'.l[0].'\zs\d\*\ze'.l[1:-1], + \'\M' . substitute(l, '\ze\S\s*$', '\\zs\\d\\*\\ze', '') . '\|' . substitute(r, '\S\zs', '\\zs\\d\\*\\ze', ''), \'\=substitute(submatch(0)+1-uncomment,"^0$\\|^-\\d*$","","")','g') endif - if uncomment + if force_uncomment + if line =~ '^\s*' . l + let line = substitute(line,'\S.*\s\@,) +command! -range -bar -bang Commentary call s:go(,,0) xnoremap Commentary go() nnoremap Commentary go() nnoremap CommentaryLine go() . '_' onoremap Commentary :call textobject(get(v:, 'operator', '') ==# 'c') nnoremap ChangeCommentary c:call textobject(1) -nmap CommentaryUndo :echoerr "Change your CommentaryUndo map to CommentaryCommentary" if !hasmapto('Commentary') || maparg('gc','n') ==# '' xmap gc Commentary nmap gc Commentary omap gc Commentary nmap gcc CommentaryLine - if maparg('c','n') ==# '' && !exists('v:operator') - nmap cgc ChangeCommentary - endif nmap gcu CommentaryCommentary endif +nmap CommentaryUndo :echoerr "Change your CommentaryUndo map to CommentaryCommentary" + " vim:set et sw=2: diff --git a/sources_non_forked/vim-flake8/README.mdown b/sources_non_forked/vim-flake8/README.md similarity index 85% rename from sources_non_forked/vim-flake8/README.mdown rename to sources_non_forked/vim-flake8/README.md index 5d4e00c8..0079bbe7 100644 --- a/sources_non_forked/vim-flake8/README.mdown +++ b/sources_non_forked/vim-flake8/README.md @@ -49,6 +49,12 @@ the `` key if so. For example, to remap it to `` instead, use: autocmd FileType python map :call flake8#Flake8() +Since the `autocmd` order is not specified in Vim, the previous +recommendation is sometimes not sufficient to "unmap" ``. In such a +case, being more explicit about it should help (see `:h no_mail_maps`): + + let g:no_flake8_maps = 1 + For flake8 configuration options please consult the following page: http://flake8.pycqa.org/en/latest/user/configuration.html @@ -88,11 +94,11 @@ To customize the gutter markers, set any of `flake8_error_marker`, `flake8_warni `flake8_pyflake_marker`, `flake8_complexity_marker`, `flake8_naming_marker`. Setting one to the empty string disables it. Ex.: - flake8_error_marker='EE' " set error marker to 'EE' - flake8_warning_marker='WW' " set warning marker to 'WW' - flake8_pyflake_marker='' " disable PyFlakes warnings - flake8_complexity_marker='' " disable McCabe complexity warnings - flake8_naming_marker='' " disable naming warnings + let g:flake8_error_marker='EE' " set error marker to 'EE' + let g:flake8_warning_marker='WW' " set warning marker to 'WW' + let g:flake8_pyflake_marker='' " disable PyFlakes warnings + let g:flake8_complexity_marker='' " disable McCabe complexity warnings + let g:flake8_naming_marker='' " disable naming warnings To customize the colors used for markers, define the highlight groups, `Flake8_Error`, `Flake8_Warning`, `Flake8_PyFlake`, `Flake8_Complexity`, `Flake8_Naming`: @@ -104,6 +110,12 @@ To customize the colors used for markers, define the highlight groups, `Flake8_E highlight link Flake8_Naming WarningMsg highlight link Flake8_PyFlake WarningMsg +To show the error message of the current line in the ruler, call `flake8#ShowError()`: + + " add binding to call the function + nnoremap :call flake8#Flake8ShowError() + + Tips ---- A tip might be to run the Flake8 check every time you write a Python file, to @@ -126,7 +138,7 @@ maximum line length default. This is a config setting that should be set in flake8 itself. (vim-flake8 "just" invokes it and deals with showing the output in Vim's quickfix window.) -To do so, put the following into your `~/.config/flake8` file: +To do so, put the following into a `.flake8` file at the root of your project: [flake8] max-line-length = 120 @@ -135,7 +147,7 @@ To do so, put the following into your `~/.config/flake8` file: History ------- 1.6: Deprecated configuring flake8 options through Vim settings. Instead, -advise users to use the `~/.config/flake8` config file. +advise users to use a `.flake8` config file in the root of your project. - Decprecated options: - `g:flake8_builtins` diff --git a/sources_non_forked/vim-flake8/autoload/flake8.vim b/sources_non_forked/vim-flake8/autoload/flake8.vim index cf592cf7..921e0fdb 100644 --- a/sources_non_forked/vim-flake8/autoload/flake8.vim +++ b/sources_non_forked/vim-flake8/autoload/flake8.vim @@ -20,6 +20,18 @@ function! flake8#Flake8UnplaceMarkers() call s:Warnings() endfunction +function! flake8#Flake8ShowError() + call s:ShowErrorMessage() +endfunction + +function! flake8#Flake8NextError() + call s:JumpNextError() +endfunction + +function! flake8#Flake8PrevError() + call s:JumpPrevError() +endfunction + "" }}} "" ** internal ** {{{ @@ -101,6 +113,7 @@ function! s:Setup() " {{{ let s:markerdata['F'].marker = s:flake8_pyflake_marker let s:markerdata['C'].marker = s:flake8_complexity_marker let s:markerdata['N'].marker = s:flake8_naming_marker + endfunction " }}} "" do flake8 @@ -141,7 +154,7 @@ function! s:Flake8() " {{{ set t_te= " perform the grep itself - let &grepformat="%f:%l:%c: %m\,%f:%l: %m" + let &grepformat="%f:%l:%c: %m\,%f:%l: %m,%-G%\\d" let &grepprg=s:flake8_cmd silent! grep! "%" " close any existing cwindows, @@ -154,11 +167,20 @@ function! s:Flake8() " {{{ let &shellpipe=l:old_shellpipe let &t_ti=l:old_t_ti let &t_te=l:old_t_te + " store mapping of line number to error string " process results + let s:resultDict = {} + let l:results=getqflist() let l:has_results=results != [] if l:has_results + " save line number of each error message + for result in l:results + let linenum = result.lnum + let s:resultDict[linenum] = result.text + endfor + " markers if !s:flake8_show_in_gutter == 0 || !s:flake8_show_in_file == 0 call s:PlaceMarkers(l:results) @@ -184,8 +206,8 @@ function! s:Flake8() " {{{ endif endfunction " }}} -"" markers +"" markers function! s:PlaceMarkers(results) " {{{ " in gutter? if !s:flake8_show_in_gutter == 0 @@ -253,8 +275,85 @@ function! s:UnplaceMarkers() " {{{ endfor endfunction " }}} +function! s:ShowErrorMessage() " {{{ + let l:cursorPos = getpos(".") + if !exists('s:resultDict') + return + endif + if !exists('b:showing_message') + " ensure showing msg is always defined + let b:showing_message = ' ' + endif + + " if there is a message on the current line, + " then echo it + if has_key(s:resultDict, l:cursorPos[1]) + let l:errorText = get(s:resultDict, l:cursorPos[1]) + echo strpart(l:errorText, 0, &columns-1) + let b:showing_message = 1 + endif + + " if a message is already being shown, + " then clear it + if !b:showing_message == 0 + echo + let b:showing_message = 0 + endif +endfunction " }}} + +function! s:JumpNextError() " {{{ + let l:cursorLine = getpos(".")[1] + if !exists('s:resultDict') + return + endif + + " Convert list of strings to ints + let l:lineList = [] + for line in keys(s:resultDict) + call insert(l:lineList, line+0) + endfor + + let l:sortedLineList = sort(l:lineList, 'n') + for line in l:sortedLineList + let l:line_int = line + 0 + if line > l:cursorLine + call cursor(line, 1) + call s:ShowErrorMessage() + return + endif + endfor + call cursor(l:cursorLine, 1) + echo "Reached last error!" + +endfunction " }}} + +function! s:JumpPrevError() " {{{ + let l:cursorLine = getpos(".")[1] + if !exists('s:resultDict') + return + endif + + " Convert list of strings to ints + let l:lineList = [] + for line in keys(s:resultDict) + call insert(l:lineList, line+0) + endfor + + let l:sortedLineList = reverse(sort(l:lineList, 'n')) + for line in l:sortedLineList + let l:line_int = line + 0 + if line < l:cursorLine + call cursor(line, 1) + call s:ShowErrorMessage() + return + endif + endfor + call cursor(l:cursorLine, 1) + echo "Reached first error!" + +endfunction " }}} + "" }}} let &cpo = s:save_cpo unlet s:save_cpo - diff --git a/sources_non_forked/vim-flake8/ftplugin/python_flake8.vim b/sources_non_forked/vim-flake8/ftplugin/python_flake8.vim index dd062d91..cf4cdcff 100644 --- a/sources_non_forked/vim-flake8/ftplugin/python_flake8.vim +++ b/sources_non_forked/vim-flake8/ftplugin/python_flake8.vim @@ -50,6 +50,8 @@ if !exists("no_plugin_maps") && !exists("no_flake8_maps") endif endif +command! Flake :call flake8#Flake8() + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/sources_non_forked/vim-fugitive/autoload/fugitive.vim b/sources_non_forked/vim-fugitive/autoload/fugitive.vim index b012f20d..1cbc2ebc 100644 --- a/sources_non_forked/vim-fugitive/autoload/fugitive.vim +++ b/sources_non_forked/vim-fugitive/autoload/fugitive.vim @@ -1,21 +1,18 @@ " Location: autoload/fugitive.vim " Maintainer: Tim Pope +" The functions contained within this file are for internal use only. For the +" official API, see the commented functions in plugin/fugitive.vim. + if exists('g:autoloaded_fugitive') finish endif let g:autoloaded_fugitive = 1 -if !exists('g:fugitive_git_executable') - let g:fugitive_git_executable = 'git' -elseif g:fugitive_git_executable =~# '^\w\+=' - let g:fugitive_git_executable = 'env ' . g:fugitive_git_executable -endif - " Section: Utility function! s:function(name) abort - return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) + return function(substitute(a:name,'^s:',matchstr(expand(''), '.*\zs\d\+_'),'')) endfunction function! s:sub(str,pat,rep) abort @@ -41,30 +38,65 @@ function! s:Uniq(list) abort return a:list endfunction +function! s:JoinChomp(list) abort + if empty(a:list[-1]) + return join(a:list[0:-2], "\n") + else + return join(a:list, "\n") + endif +endfunction + function! s:winshell() abort return has('win32') && &shellcmdflag !~# '^-' endfunction +function! s:WinShellEsc(arg) abort + if type(a:arg) == type([]) + return join(map(copy(a:arg), 's:WinShellEsc(v:val)')) + elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' + return a:arg + else + return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' + endif +endfunction + function! s:shellesc(arg) abort if type(a:arg) == type([]) return join(map(copy(a:arg), 's:shellesc(v:val)')) - elseif a:arg =~ '^[A-Za-z0-9_/:.-]\+$' + elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' return a:arg elseif s:winshell() - return '"'.s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"').'"' + return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' else return shellescape(a:arg) endif endfunction -let s:fnameescape = " \t\n*?[{`$\\%#'\"|!<" function! s:fnameescape(file) abort if type(a:file) == type([]) return join(map(copy(a:file), 's:fnameescape(v:val)')) - elseif exists('*fnameescape') - return fnameescape(a:file) else - return escape(a:file, s:fnameescape) + return fnameescape(a:file) + endif +endfunction + +function! fugitive#UrlDecode(str) abort + return substitute(a:str, '%\(\x\x\)', '\=iconv(nr2char("0x".submatch(1)), "utf-8", "latin1")', 'g') +endfunction + +function! s:UrlEncode(str) abort + return substitute(a:str, '[%#?&;+=\<> [:cntrl:]]', '\=printf("%%%02X", char2nr(submatch(0)))', 'g') +endfunction + +function! s:PathUrlEncode(str) abort + return substitute(a:str, '[%#?[:cntrl:]]', '\=printf("%%%02X", char2nr(submatch(0)))', 'g') +endfunction + +function! s:PathJoin(prefix, str) abort + if a:prefix =~# '://' + return a:prefix . s:PathUrlEncode(a:str) + else + return a:prefix . a:str endif endfunction @@ -72,58 +104,152 @@ function! s:throw(string) abort throw 'fugitive: '.a:string endfunction -function! s:DirCheck(...) abort - if empty(a:0 ? s:Dir(a:1) : s:Dir()) - return 'return ' . string('echoerr "fugitive: not a Git repository"') +function! s:VersionCheck() abort + if v:version < 704 + return 'return ' . string('echoerr "fugitive: Vim 7.4 or newer required"') + elseif empty(fugitive#GitVersion()) + let exe = get(s:GitCmd(), 0, '') + if len(exe) && !executable(exe) + return 'return ' . string('echoerr "fugitive: cannot find ' . string(exe) . ' in PATH"') + endif + return 'return ' . string('echoerr "fugitive: cannot execute Git"') + elseif !fugitive#GitVersion(1, 8, 5) + return 'return ' . string('echoerr "fugitive: Git 1.8.5 or newer required"') + else + if exists('b:git_dir') && empty(b:git_dir) + unlet! b:git_dir + endif + return '' + endif +endfunction + +let s:worktree_error = "core.worktree is required when using an external Git dir" +function! s:DirCheck(...) abort + let dir = call('FugitiveGitDir', a:000) + if !empty(dir) && FugitiveWorkTree(dir, 1) is# 0 + return 'return ' . string('echoerr "fugitive: ' . s:worktree_error . '"') + elseif !empty(dir) + return '' + elseif empty(bufname('')) + return 'return ' . string('echoerr "fugitive: working directory does not belong to a Git repository"') + else + return 'return ' . string('echoerr "fugitive: file does not belong to a Git repository"') endif - return '' endfunction function! s:Mods(mods, ...) abort let mods = substitute(a:mods, '\C', '', '') let mods = mods =~# '\S$' ? mods . ' ' : mods - if a:0 && mods !~# '\<\%(aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright\|tab\)\>' - let mods = a:1 . ' ' . mods + if a:0 && mods !~# '\<\d*\%(aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright\|tab\)\>' + let default = a:1 + if default ==# 'SpanOrigin' + if s:OriginBufnr() > 0 && (mods =~# '\' ? &winfixheight : &winfixwidth) + let default = 'Edge' + else + let default = '' + endif + endif + if default ==# 'Edge' + if mods =~# '\' ? &splitright : &splitbelow + let mods = 'botright ' . mods + else + let mods = 'topleft ' . mods + endif + else + let mods = default . ' ' . mods + endif endif return substitute(mods, '\s\+', ' ', 'g') endfunction -function! s:Slash(path) abort - if exists('+shellslash') +if exists('+shellslash') + + let s:dir_commit_file = '\c^fugitive://\%(/[^/]\@=\)\=\([^?#]\{-1,\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/[^?#]*\)\=\)\=$' + + function! s:Slash(path) abort return tr(a:path, '\', '/') - else + endfunction + + function! s:VimSlash(path) abort + return tr(a:path, '\/', &shellslash ? '//' : '\\') + endfunction + +else + + let s:dir_commit_file = '\c^fugitive://\([^?#]\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/[^?#]*\)\=\)\=$' + + function! s:Slash(path) abort return a:path + endfunction + + function! s:VimSlash(path) abort + return a:path + endfunction + +endif + +function! s:AbsoluteVimPath(...) abort + if a:0 && type(a:1) == type('') + let path = a:1 + else + let path = bufname(a:0 && a:1 > 0 ? a:1 : '') + if getbufvar(a:0 && a:1 > 0 ? a:1 : '', '&buftype') !~# '^\%(nowrite\|acwrite\)\=$' + return path + endif + endif + if s:Slash(path) =~# '^/\|^\a\+:' + return path + else + return getcwd() . matchstr(getcwd(), '[\\/]') . path endif endfunction function! s:Resolve(path) abort let path = resolve(a:path) if has('win32') - let path = FugitiveVimPath(fnamemodify(fnamemodify(path, ':h'), ':p') . fnamemodify(path, ':t')) + let path = s:VimSlash(fnamemodify(fnamemodify(path, ':h'), ':p') . fnamemodify(path, ':t')) endif return path endfunction +function! s:FileIgnoreCase(for_completion) abort + return (exists('+fileignorecase') && &fileignorecase) + \ || (a:for_completion && exists('+wildignorecase') && &wildignorecase) +endfunction + function! s:cpath(path, ...) abort - if exists('+fileignorecase') && &fileignorecase - let path = FugitiveVimPath(tolower(a:path)) + if s:FileIgnoreCase(0) + let path = s:VimSlash(tolower(a:path)) else - let path = FugitiveVimPath(a:path) + let path = s:VimSlash(a:path) endif return a:0 ? path ==# s:cpath(a:1) : path endfunction -function! s:Cd(...) abort - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd' - if !a:0 - return cd +let s:quote_chars = { + \ "\007": 'a', "\010": 'b', "\011": 't', "\012": 'n', "\013": 'v', "\014": 'f', "\015": 'r', + \ '"': '"', '\': '\'} + +let s:unquote_chars = { + \ 'a': "\007", 'b': "\010", 't': "\011", 'n': "\012", 'v': "\013", 'f': "\014", 'r': "\015", + \ '"': '"', '\': '\'} + +function! s:Quote(string) abort + let string = substitute(a:string, "[\001-\037\"\\\177]", '\="\\" . get(s:quote_chars, submatch(0), printf("%03o", char2nr(submatch(0))))', 'g') + if string !=# a:string + return '"' . string . '"' + else + return string endif - let cwd = getcwd() - if s:cpath(cwd, a:1) - return '' +endfunction + +function! fugitive#Unquote(string) abort + let string = substitute(a:string, "\t*$", '', '') + if string =~# '^".*"$' + return substitute(string[1:-2], '\\\(\o\o\o\|.\)', '\=get(s:unquote_chars, submatch(1), iconv(nr2char("0" . submatch(1)), "utf-8", "latin1"))', 'g') + else + return string endif - exe cd s:fnameescape(a:1) - return cd . ' ' . s:fnameescape(cwd) endfunction let s:executables = {} @@ -135,36 +261,1252 @@ function! s:executable(binary) abort return s:executables[a:binary] endfunction -let s:nowait = v:version >= 704 ? '' : '' +if !exists('s:temp_scripts') + let s:temp_scripts = {} +endif +function! s:TempScript(...) abort + let body = join(a:000, "\n") + if !has_key(s:temp_scripts, body) + let s:temp_scripts[body] = tempname() . '.sh' + endif + let temp = s:temp_scripts[body] + if !filereadable(temp) + call writefile(['#!/bin/sh'] + a:000, temp) + endif + let temp = FugitiveGitPath(temp) + if temp =~# '\s' + let temp = '"' . temp . '"' + endif + return temp +endfunction + +function! s:DoAutocmd(...) abort + return join(map(copy(a:000), "'doautocmd ' . v:val"), '|') +endfunction function! s:Map(mode, lhs, rhs, ...) abort + let maps = [] + let flags = a:0 && type(a:1) == type('') ? a:1 : '' + let defer = flags =~# '' + let flags = substitute(flags, '', '', '') . (a:rhs =~# '' ? '' : ' snippet scripts diff --git a/sources_non_forked/vim-snippets/snippets/htmltornado.snippets b/sources_non_forked/vim-snippets/snippets/htmltornado.snippets index 1620e11d..5dd81555 100644 --- a/sources_non_forked/vim-snippets/snippets/htmltornado.snippets +++ b/sources_non_forked/vim-snippets/snippets/htmltornado.snippets @@ -24,11 +24,11 @@ snippet for snippet from {% from ${1:x} import ${0:y} %} snippet if - {% if ${1:condition} %} + {% if $1 %} ${0} {% end %} snippet eif - {% elif ${0:condition} %} + {% elif $0 %} snippet el {% else %} snippet import @@ -50,6 +50,6 @@ snippet try ${0} {% end %} snippet wh - {% while ${1:condition} %} + {% while $1 %} ${0} {% end %} diff --git a/sources_non_forked/vim-snippets/snippets/java.snippets b/sources_non_forked/vim-snippets/snippets/java.snippets index 66821c16..d3e69684 100644 --- a/sources_non_forked/vim-snippets/snippets/java.snippets +++ b/sources_non_forked/vim-snippets/snippets/java.snippets @@ -142,9 +142,9 @@ snippet ae snippet aae assertArrayEquals("${1:Failure message}", ${2:expecteds}, ${3:actuals}); snippet af - assertFalse("${1:Failure message}", ${2:condition}); + assertFalse("${1:Failure message}", $2); snippet at - assertTrue("${1:Failure message}", ${2:condition}); + assertTrue("${1:Failure message}", $2); snippet an assertNull("${1:Failure message}", ${2:object}); snippet ann @@ -175,9 +175,9 @@ snippet tryf ## ## Find Methods snippet findall - List<${1:listName}> ${2:items} = ${1}.findAll(); + List<${1:listName}> ${2:items} = $1.findAll(); snippet findbyid - ${1:var} ${2:item} = ${1}.findById(${3}); + ${1:var} ${2:item} = $1.findById(${3}); ## ## Javadocs snippet /** @@ -211,7 +211,9 @@ snippet enfor snippet for for (${1}; ${2}; ${3}) ${0} snippet wh - while (${1}) ${0} + while (${1:true}) ${0} +snippet wht + while (true) ${0} ## ## Main method snippet psvm diff --git a/sources_non_forked/vim-snippets/snippets/javascript-es6-react.snippets b/sources_non_forked/vim-snippets/snippets/javascript-es6-react.snippets deleted file mode 100644 index c9138752..00000000 --- a/sources_non_forked/vim-snippets/snippets/javascript-es6-react.snippets +++ /dev/null @@ -1,82 +0,0 @@ -# Import only React -snippet ri1 - import React from 'react' - -# Import both React and Component -snippet ri2 - import React, { Component } from 'react' - import PropTypes from 'prop-types' - -# React class -snippet rcla - class ${1:MyComponent} extends Component { - render() { - return ( - ${0:
} - ) - } - } - -# React constructor -snippet rcon - constructor(props) { - super(props) - - this.state = { - ${1}: ${0}, - } - } - -# Proptypes for React Class -snippet rcpt - static propTypes = { - ${1}: PropTypes.${0}, - } - -# Default props for React Class -snippet rcdp - static defaultProps = { - ${1}: ${0}, - } - -# Presentational component -snippet rcom - props => { - return ( - ${0:
} - ) - } - -# Proptypes for Presentational component -snippet rpt - ${1}.propTypes = { - ${2}: PropTypes.${0}, - } - -# Default props for Presentational component -snippet rdp - ${1}.defaultProps = { - ${2}: ${0}, - } - -# Lifecycle Methods -snippet rcdm - componentDidMount() { - ${0:${VISUAL}} - } - -# State -snippet rsst - this.setState({ - ${1}: ${0}, - }) - -snippet rtst - this.state.${0} - -# Props -snippet rp - props.${0} - -snippet rtp - this.props.${0} diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript-jasmine.snippets b/sources_non_forked/vim-snippets/snippets/javascript-jasmine.snippets similarity index 100% rename from sources_non_forked/vim-snippets/snippets/javascript/javascript-jasmine.snippets rename to sources_non_forked/vim-snippets/snippets/javascript-jasmine.snippets diff --git a/sources_non_forked/vim-snippets/snippets/javascript-mocha.snippets b/sources_non_forked/vim-snippets/snippets/javascript-mocha.snippets index eb5c381d..180555fc 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript-mocha.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript-mocha.snippets @@ -1,29 +1,29 @@ -snippet des "describe('thing', () => { ... })" b - describe('${1:}', () => { +snippet des "describe('thing', function() { ... })" b + describe('${1:}', function() { ${0:${VISUAL}} }); -snippet it "it('should do', () => { ... })" b - it('${1:}', () => { +snippet it "it('should do', function() { ... })" b + it('${1:}', function() { ${0:${VISUAL}} }); -snippet xit "xit('should do', () => { ... })" b - xit('${1:}', () => { +snippet xit "xit('should do', function() { ... })" b + xit('${1:}', function() { ${0:${VISUAL}} }); -snippet bef "before(() => { ... })" b - before(() => { +snippet bef "before(function() { ... })" b + before(function() { ${0:${VISUAL}} }); -snippet befe "beforeEach(() => { ... })" b - beforeEach(() => { +snippet befe "beforeEach(function() { ... })" b + beforeEach(function() { ${0:${VISUAL}} }); -snippet aft "after(() => { ... })" b - after(() => { +snippet aft "after(function() { ... })" b + after(function() { ${0:${VISUAL}} }); -snippet afte "afterEach(() => { ... })" b - afterEach(() => { +snippet afte "afterEach(function() { ... })" b + afterEach(function() { ${0:${VISUAL}} }); snippet exp "expect(...)" b diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets index 0e8d3602..65cb4e1d 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets @@ -1,98 +1,190 @@ -snippet ir +# Import +snippet ir import React import React from 'react'; -snippet irc + +snippet irc import React and Component import React, { Component } from 'react'; -snippet ird + +snippet irh import React hooks + import { use$1 } from 'react'; + +snippet ird import ReactDOM import ReactDOM from 'react-dom'; -snippet cdm + +snippet irp import PropTypes + import PropTypes from 'prop-types'; + +# Lifecycle Methods +snippet cdm componentDidMount componentDidMount() { ${1} - } -snippet cdup + }; + +snippet cdup componentDidUpdate componentDidUpdate(prevProps, prevState) { ${1} - } -snippet cwm + }; + +snippet cwm componentWillMount componentWillMount() { ${1} - } -snippet cwr + }; + +snippet cwr componentWillReceiveProps componentWillReceiveProps(nextProps) { ${1} - } -snippet cwun + }; + +snippet cwun componentWillUnmount componentWillUnmount() { ${1} - } -snippet cwu + }; + +snippet cwu componentWillUpdate componentWillUpdate(nextProps, nextState) { ${1} + }; + +snippet scu shouldComponentUpdate + shouldComponentUpdate(nextProps, nextState) { + ${1} } -snippet fup - forceUpdate(${1:callback}); -snippet dp + +# Props +snippet spt static propTypes + static propTypes = { + ${1}: PropTypes.${2} + }; + +snippet pt propTypes + ${1}.propTypes = { + ${2}: PropTypes.${2} + }; + +snippet sdp static defaultProps static defaultProps = { - ${1}: ${2}, - } + ${1}: ${2} + }; + +snippet dp defaultProps + ${1}.defaultProps = { + ${2}: ${3} + }; + +snippet pp props + props.${1}; + +snippet tp this props + this.props.${1}; + +# State snippet st state = { ${1}: ${2}, - } -snippet pt - static propTypes = { - ${1}: React.PropTypes.${2:type}, - } -snippet rfc - const ${1:ComponentName} = (${2:props}) => { - return ( -
- $1 -
- ); - } -snippet rcc - class ${1:ClassName} extends React.Component { - state = { + }; - } - render() { - return ( -
- $1 -
- ); - } - } -snippet rdr - ReactDOM.render(${1}, ${2}) -snippet ercc - export default class ${1:ClassName} extends React.Component { - render() { - return ( - ${0:
} - ); - } - } -snippet ctor - constructor() { - super(); - ${1} - } -snippet ren - render() { - return ( - ${1:
} - ); - } snippet sst this.setState({ ${1}: ${2} }); -snippet scu - shouldComponentUpdate(nextProps, nextState) { - ${1} + +snippet tst + this.state.${1}; + +# Component +snippet raf + const ${1:ComponentName} = (${2:props}) => { + ${3:state} + + return ( + <> + ${4} + + ); + }; + +snippet rcla + class ${1:ClassName} extends Component { + render() { + return ( + <> + ${2} + + ); + } } -snippet prp i - this.props.${1} -snippet ste i - this.state.${1} + +snippet ercla + export default class ${1:ClassName} extends Component { + render() { + return ( + <> + ${2} + + ); + }; + }; + +snippet ctor + constructor() { + super(); + + ${1:state} + } + +snippet ren + render() { + return ( + <> + ${2} + + ); + } + +snippet fup + forceUpdate(${1:callback}); + +# Hooks +snippet uses useState + const [${1:state}, set${2}] = useState(${3:initialState}); + +snippet usee useEffect + useEffect(() => { + ${1} + }); + +snippet userd useReducer + const [${1:state}, ${2:dispatch}] = useReducer(${3:reducer}); + +snippet userf useRef + const ${1:refContainer} = useRef(${2:initialValue}); + +snippet usect useContext + const ${1:value} = useContext(${2:MyContext}); + +snippet usecb useCallback + const ${1:memoizedCallback} = useCallback( + () => { + ${2}(${3}) + }, + [$3] + ); + +snippet usem useMemo + const ${1:memoizedCallback} = useMemo(() => ${2}(${3}), [$3]); + +snippet usei useImperativeHandle + useImperativeHandle(${1:ref}, ${2:createHandle}); + +snippet used useDebugValue + useDebugValue(${1:value}); + +# ReactDOM methods +snippet rdr ReactDOM.render + ReactDOM.render(${1}, ${2}); + +snippet rdh ReactDOM.hydrate + ReactDOM.hydrate(${1:element}, ${2:container}[, ${3:callback}]); + +snippet rdcp ReactDOM.createPortal + ReactDOM.createPortal(${1:child}, ${2:container}); diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets index 489e0abb..52a2ba4c 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets @@ -5,7 +5,7 @@ snippet ex module.exports = ${1}; # require snippet re - ${1:const} ${2} = require('${3:module_name}'); + const ${1} = require('${2:module_name}'); # EventEmitter snippet on on('${1:event_name}', function(${2:stream}) { diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets index 8cf7c6e0..de1ca113 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets @@ -9,7 +9,8 @@ snippet fun "function" function ${1:function_name}(${2}) { ${0:${VISUAL}} } -snippet fun "async function" +# Asynchronous Function +snippet asf "async function" async function ${1:function_name}(${2}) { ${0:${VISUAL}} } @@ -61,8 +62,8 @@ snippet ife "if (condition) { ... } else { ... }" ${2} } # tertiary conditional -snippet ter - ${1:/* condition */} ? ${2:/* if true */} : ${0:/* if false */} +snippet ter Ternary: `condition ? true : false` + $1 ? $2: $0 # switch snippet switch switch (${1:expression}) { @@ -98,24 +99,28 @@ snippet terr snippet ret return ${0:result}; snippet for "for (...) {...}" - for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) { + for (let ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) { ${0:${VISUAL}} } snippet forr "reversed for (...) {...}" - for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) { + for (let ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) { ${0:${VISUAL}} } snippet wh "(condition) { ... }" - while (${1:/* condition */}) { + while (${1:true}) { + ${0:${VISUAL}} + } +snippet wht "(true) { ... }" + while (true) { ${0:${VISUAL}} } snippet do "do { ... } while (condition)" do { ${0:${VISUAL}} - } while (${1:/* condition */}); + } while ($1); # For in loop snippet fori - for (var ${1:prop} in ${2:object}) { + for (let ${1:prop} in ${2:object}) { ${0:$2[$1]} } # Objects @@ -274,6 +279,8 @@ snippet cprof "console.profile" console.profileEnd(); snippet ctable "console.table" console.table(${1:"${2:value}"}); +snippet clstr "console.log stringified" + console.log(JSON.stringify(${0}, null, 2)); # Misc snippet us 'use strict'; @@ -282,6 +289,8 @@ snippet timeout setTimeout(function () {${0}}${2}, ${1:10}); snippet const const ${1} = ${0}; +snippet constn + const ${1} = new ${0}; snippet let let ${1} = ${0}; snippet im "import xyz from 'xyz'" @@ -308,6 +317,10 @@ snippet foro "for (const prop of object}) { ... }" for (const ${1:prop} of ${2:object}) { ${0:$1} } +snippet forl "for (let prop of object}) { ... }" + for (let ${1:prop} of ${2:object}) { + ${0:$1} + } snippet fun* function* ${1:function_name}(${2}) { ${0:${VISUAL}} @@ -316,15 +329,25 @@ snippet c=> const ${1:function_name} = (${2}) => { ${0:${VISUAL}} } +snippet ca=> + const ${1:function_name} = async (${2}) => { + ${0:${VISUAL}} + } snippet caf const ${1:function_name} = (${2}) => { ${0:${VISUAL}} } +snippet casf + const ${1:function_name} = async (${2}) => { + ${0:${VISUAL}} + } snippet => (${1}) => { ${0:${VISUAL}} } -snippet af +snippet af "() =>" + (${1}) => ${0:${VISUAL}} +snippet afb "() => {}" (${1}) => { ${0:${VISUAL}} } @@ -333,6 +356,8 @@ snippet sym snippet ed export default ${0} snippet ${ - ${${1}}${0} + \${${1}}${0} +snippet as "async" + async ${0} snippet aw "await" await ${0:${VISUAL}} diff --git a/sources_non_forked/vim-snippets/snippets/jsp.snippets b/sources_non_forked/vim-snippets/snippets/jsp.snippets index db185b2a..a53c415b 100644 --- a/sources_non_forked/vim-snippets/snippets/jsp.snippets +++ b/sources_non_forked/vim-snippets/snippets/jsp.snippets @@ -18,7 +18,7 @@ snippet cremove snippet ccatch snippet cif - + ${0} snippet cchoose @@ -26,7 +26,7 @@ snippet cchoose ${0} snippet cwhen - + ${0} snippet cother @@ -34,12 +34,12 @@ snippet cother ${0} snippet cfore - + ${0:} snippet cfort ${2:item1,item2,item3} - + ${0:} snippet cparam @@ -56,13 +56,13 @@ snippet cimport+ snippet curl - ${0} + ${0} snippet curl+ cparam+${0} - ${3} + ${3} snippet credirect snippet contains diff --git a/sources_non_forked/vim-snippets/snippets/julia.snippets b/sources_non_forked/vim-snippets/snippets/julia.snippets index 490d050d..1e0d3f2f 100644 --- a/sources_non_forked/vim-snippets/snippets/julia.snippets +++ b/sources_non_forked/vim-snippets/snippets/julia.snippets @@ -89,14 +89,26 @@ snippet thr throw ${0} # Messages -snippet in - info("${1}") - ${0} +snippet @i + @info "${1}" ${0} -snippet wa - warn("${1}") - ${0} +snippet @w + @warn "${1}" ${0} -snippet err - error("${1}") - ${0} +snippet @e + @error "${1}" ${0} + +snippet @d + @debug "${1}" ${0} + +snippet @t @testset with @test + @testset "${1}" begin + ${2} + @test ${0} + end + +snippet @tt @testset with @test_throws + @testset "${1}" begin + ${2} + @test_throws ${0} + end diff --git a/sources_non_forked/vim-snippets/snippets/kotlin.snippets b/sources_non_forked/vim-snippets/snippets/kotlin.snippets index 98f8dbc4..54ba5e44 100644 --- a/sources_non_forked/vim-snippets/snippets/kotlin.snippets +++ b/sources_non_forked/vim-snippets/snippets/kotlin.snippets @@ -6,6 +6,11 @@ snippet pfun private fun ${1:name}(${2}): ${3:String} { ${4} } +snippet main + @JvmStatic + fun main(args: Array) { + ${0} + } snippet ret return ${0} snippet whe diff --git a/sources_non_forked/vim-snippets/snippets/liquid.snippets b/sources_non_forked/vim-snippets/snippets/liquid.snippets index 4f11f086..e12bf060 100644 --- a/sources_non_forked/vim-snippets/snippets/liquid.snippets +++ b/sources_non_forked/vim-snippets/snippets/liquid.snippets @@ -2,33 +2,33 @@ # https://marketplace.visualstudio.com/items?itemName=killalau.vscode-liquid-snippets snippet if - {% if ${1:condition} %} + {% if $1 %} ${0:${VISUAL}} {% endif %} snippet else {% else %} snippet elsif - {% elsif ${1:condition} %} + {% elsif $1 %} snippet ifelse - {% if ${1:condition} %} + {% if $1 %} ${2} {% else %} ${0} {% endif %} snippet unless - {% unless ${1:condition} %} + {% unless $1 %} ${0:${VISUAL}} {% endunless %} snippet case {% case ${1:variable} %} - {% when ${2:condition} %} + {% when $2 %} ${3} {% else %} ${0} {% endcase %} snippet when - {% when ${1:condition} %} - ${0} + {% when $1 %} + ${0:${VISUAL}} snippet cycle {% cycle '${1:odd}', '${2:even}' %} snippet cyclegroup @@ -63,6 +63,10 @@ snippet include {% include '${0:snippet}' %} snippet includewith {% include '${1:snippet}', ${2:variable}: ${0:value} %} +snippet render + {% render '${0:snippet}' %} +snippet renderwith + {% render '${1:snippet}', ${2:variable}: ${0:value} %} snippet section {% section '${1:snippet}' %} snippet raw @@ -96,35 +100,35 @@ snippet javascript ${0} {% endjavascript %} snippet comment- - {%- comment -%}${0}{%- endcomment -%} + {%- comment -%}${0:${VISUAL}}{%- endcomment -%} snippet if- - {%- if ${1:condition} -%} + {%- if $1 -%} ${0:${VISUAL}} {%- endif -%} snippet else- {%- else -%} snippet elsif- - {%- elsif ${1:condition} -%} + {%- elsif $1 -%} snippet ifelse- - {%- if ${1:condition} -%} + {%- if $1 -%} ${2} {%- else -%} ${0} {%- endif -%} snippet unless- - {%- unless ${1:condition} -%} + {%- unless $1 -%} ${0:${VISUAL}} {%- endunless -%} snippet case- {%- case ${1:variable} -%} - {%- when ${2:condition} -%} + {%- when $2 -%} ${3} {%- else -%} ${0} {%- endcase -%} snippet when- - {%- when ${1:condition} -%} - ${0} + {%- when $1 -%} + ${0:${VISUAL}} snippet cycle- {%- cycle '${1:odd}', '${2:even}' -%} snippet cyclegroup- @@ -147,6 +151,22 @@ snippet include- {%- include '${0:snippet}' -%} snippet includewith- {%- include '${1:snippet}', ${2:variable}: ${0:value} -%} +snippet render- + {%- render '${0:snippet}' -%} +snippet renderwith- + {%- render '${1:snippet}', ${2:variable}: ${0:value} -%} +snippet section- + {%- section '${1:snippet}' -%} +snippet layout- + {%- layout '${1:layout}' -%} +snippet layoutnone- + {%- layout none -%} +snippet paginate- + {%- paginate ${1:collection.products} by ${2:12} -%} + {%- for ${3:product} in $1 -%} + ${0} + {%- endfor -%} + {%- endpaginate -%} snippet join | join: '${1:, }' snippet first @@ -261,3 +281,192 @@ snippet asset_img_url | asset_img_url: '${1:medium}' snippet img_url | img_url: '${1:medium}' +snippet _schema + {% schema %} + { + "name": "${1}", + "class": "${2}", + "settings": [ + ${0} + ] + } + {% endschema %} +snippet _blocks + "blocks": [ + { + "type": "${1}", + "name": "${2}", + "settings": [ + ${0} + ] + } + ] +snippet _text + { + "type": "text", + "id": "${1}", + "label": "${2}", + "default": "${3}", + "info": "${4}", + "placeholder": "${0}" + } +snippet _textarea + { + "type": "textarea", + "id": "${1}", + "label": "${2}", + "default": "${3}", + "info": "${4}", + "placeholder": "${0}" + } +snippet _image_picker + { + "type": "image_picker", + "id": "${1}", + "label": "${0}" + } +snippet _radio + { + "type": "radio", + "id": "${1}", + "label": "${2}", + "options": [ + { "value": "${5}", "label": "${0}" } + ], + "default": "${3}", + "info": "${4}" + } +snippet _select + { + "type": "select", + "id": "${1}", + "label": "${2}", + "options": [ + { + "group": "${5}", + "value": "${6}", + "label": "${0}" + } + ], + "default": "${3}", + "info": "${4}" + } +snippet _checkbox + { + "type": "checkbox", + "id": "${1}", + "label": "${2}", + "default": ${3:true}, + "info": "${0}" + } +snippet _range + { + "type": "range", + "id": "${1}", + "min": ${2}, + "max": ${3}, + "step": ${4}, + "unit": "${5}", + "label": "${6}", + "default": ${0} + } +snippet _color + { + "type": "color", + "id": "${1}", + "label": "${2}", + "default": "${3}", + "info": "${0}" + } +snippet _font + { + "type": "font_picker", + "id": "${1}", + "label": "${2}", + "info": "${3}", + "default": "${0:helvetica_n4}" + } +snippet _collection + { + "type": "collection", + "id": "${1}", + "label": "${2}", + "info": "${0}" + } +snippet _product + { + "type": "product", + "id": "${1}", + "label": "${2}", + "info": "${0}" + } +snippet _blog + { + "type": "blog", + "id": "${1}", + "label": "${2}", + "info": "${0}" + } +snippet _page + { + "type": "page", + "id": "${1}", + "label": "${2}", + "info": "${0}" + } +snippet _link_list + { + "type": "link_list", + "id": "${1}", + "label": "${2}", + "info": "${0}" + } +snippet _url + { + "type": "url", + "id": "${1}", + "label": "${2}", + "info": "${0}" + } +snippet _video + { + "type": "video_url", + "id": "${1}", + "label": "${2}", + "accept": ["youtube", "vimeo"${0}], + "default": "${3}", + "info": "${4}", + "placeholder": "${5}" + } +snippet _richtext + { + "type": "richtext", + "id": "${1}", + "label": "${2}", + "default": "

${0}

" + } +snippet _html + { + "type": "html", + "id": "${1}", + "label": "${2}", + "default": "
${0}
" + } +snippet _article + { + "type": "article", + "id": "${1}", + "label": "${2}", + "info": "${0}" + } +snippet _header + { + "type": "header", + "content": "${1}", + "info": "${0}" + } +snippet _paragraph + { + "type": "paragraph", + "content": "${0}" + } diff --git a/sources_non_forked/vim-snippets/snippets/lpc.snippets b/sources_non_forked/vim-snippets/snippets/lpc.snippets new file mode 100644 index 00000000..3410c93b --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/lpc.snippets @@ -0,0 +1,190 @@ +## +## Preprocessor +# #include <...> +snippet inc + #include <${1:stdio}.h> +# #include "..." +snippet Inc + #include "${1:`vim_snippets#Filename("$1.h")`}" +# ifndef...define...endif +snippet ndef + #ifndef $1 + #define ${1:SYMBOL} ${2:value} + #endif /* ifndef $1 */ +# define +snippet def + #define +# ifdef...endif +snippet ifdef + #ifdef ${1:FOO} + ${2:#define } + #endif +# if +snippet #if + #if ${1:FOO} + ${0:${VISUAL}} + #endif +# header include guard +snippet once + #ifndef ${1:`toupper(vim_snippets#Filename('$1_H', 'UNTITLED_H'))`} + + #define $1 + + ${0} + + #endif /* end of include guard: $1 */ +## +## Control Statements +# if +snippet if + if(${1:true}) + { + ${0:${VISUAL}} + } +snippet ife + if(${1:true}) + { + ${2:${VISUAL}} + } + else + { + ${0} + } +# else +snippet el + else + { + ${0:${VISUAL}} + } +# else if +snippet elif + else if(${1:true}) + { + ${0:${VISUAL}} + } +# ifi +snippet ifi + if(${1:true}) ${0}; +# ternary +snippet t Ternary: `condition ? true : false` + $1 ? $2 : $0 +# switch +snippet switch + switch(${1:/* variable */}) + { + case ${2:/* variable case */}: + ${3} + ${4:break;}${5} + default: + ${6} + } +# switch without default +snippet switchndef + switch(${1:/* variable */}) + { + case ${2:/* variable case */}: + ${3} + ${4:break;}${5} + } +# case +snippet case + case ${1:/* variable case */}: + ${2} + ${3:break;} +snippet ret + return ${0}; +## +## Loops +#foreach +snippet fore + foreach(${1:mixed} ${2:ele} in ${3:arr}) + { + ${4} + } +# for +snippet for + for(int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) + { + ${4} + } +# for (custom) +snippet forr + for(int ${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) + { + ${5} + } +# while +snippet wh + while($1) + { + ${0:${VISUAL}} + } +# do... while +snippet do + do{ + ${0:${VISUAL}} + }while ($1); +## +## Functions +# function definition +snippet fnc + ${1:void} ${2:function_name}(${3}) + { + ${4} + } +# function definition with zero parameters +snippet defun0 + ${1:void} ${2:function_name}() + { + ${3} + } +# function definition with one parameter +snippet defun1 + ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}) + { + ${5} + } +# function definition with two parameters +snippet defun2 + ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}) + { + ${7} + } +# function definition with three parameters +snippet defun3 + ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}, ${7:Type} ${8:Parameter}) + { + ${9} + } +# function declaration +snippet fund + ${1:void} ${2:function_name}(${3}); +## +## Input/Output +# printf +snippet pr + printf("${1:%s}\n"${2}); +# fprintf (again, this isn't as nice as TextMate's version, but it works) +snippet fpr + fprintf(${1:stderr}, "${2:%s}\n"${3}); +snippet prd + printf("${1:} = %d\n", $1); +snippet prf + printf("${1:} = %f\n", $1); +snippet prx + printf("${1:} = %${2}\n", $1); +## +# TODO section +snippet todo + /*! TODO: ${1:Todo description here} */ + +## Miscellaneous +# This is kind of convenient +snippet . + [${1}] + + +## +## MHXY +snippet head + // code for ${1} by `$USER` create at `strftime("%Y-%m-%d %H:%M:%S")` diff --git a/sources_non_forked/vim-snippets/snippets/ls.snippets b/sources_non_forked/vim-snippets/snippets/ls.snippets index 7c924e64..822119d9 100644 --- a/sources_non_forked/vim-snippets/snippets/ls.snippets +++ b/sources_non_forked/vim-snippets/snippets/ls.snippets @@ -54,24 +54,24 @@ snippet cla class .. extends .. constructor: .. ${5} # If snippet if - if ${1:condition} + if $1 ${2} # If __ Else snippet ife - if ${1:condition} + if $1 ${2} else ${3} # Else if snippet elif - else if ${1:condition} + else if $1 ${2} # Ternary If snippet ifte - if ${1:condition} then ${2:value} else ${3:other} + if $1 then $2 else $0 # Unless snippet unl - ${1:action} unless ${2:condition} + $1 unless $0 # Switch snippet swi switch ${1:object} diff --git a/sources_non_forked/vim-snippets/snippets/lua.snippets b/sources_non_forked/vim-snippets/snippets/lua.snippets index ff6c0619..6fe3fd36 100644 --- a/sources_non_forked/vim-snippets/snippets/lua.snippets +++ b/sources_non_forked/vim-snippets/snippets/lua.snippets @@ -5,7 +5,7 @@ snippet local local ${1:x} = ${0:1} snippet fun function ${1:fname}(${2:...}) - ${0:-- body} + $0 end snippet for for ${1:i}=${2:1},${3:10} do @@ -13,34 +13,60 @@ snippet for end snippet forp for ${1:i},${2:v} in pairs(${3:table_name}) do - ${0:-- body} + $0 end snippet fori for ${1:i},${2:v} in ipairs(${3:table_name}) do - ${0:-- body} + $0 end snippet if - if ${1:condition} then - ${2:-- body} + if $1 then + $2 end snippet ife - if ${1:condition} then + if $1 then ${2:-- if condition} else ${0:-- else} end snippet elif - elseif ${1:condition} then - ${0:--body} + elseif $1 then + $0 snippet repeat repeat - ${1:--body} - until ${0:condition} + $1 + until $0 snippet while - while ${1:condition} do - ${0:--body} + while $1 do + $0 + end +snippet wh + while ${1:true} do + ${0} + end +snippet wht + while true do + ${0} end snippet print print("${1:string}") -snippet im - import "${1:import file}" +snippet pr + print($0) +snippet prs + print("$0") +snippet prf + print(string.format("${1:%s}"$0)) +snippet wr + io.write($0) +snippet wrs + io.write("$0") +snippet wrf + io.write(string.format("${1:%s}"$0)) +snippet fwr + io.${1:stderr}:write($0) +snippet fwrs + io.${1:stderr}:write("$0") +snippet fwrf + io.${1:stderr}:write(string.format("${2:%s}"$0)) +snippet req + require('${1:mod}') diff --git a/sources_non_forked/vim-snippets/snippets/mako.snippets b/sources_non_forked/vim-snippets/snippets/mako.snippets index 659caf77..b2ff4052 100644 --- a/sources_non_forked/vim-snippets/snippets/mako.snippets +++ b/sources_non_forked/vim-snippets/snippets/mako.snippets @@ -19,11 +19,11 @@ snippet for ${0:} % endfor snippet if if - % if ${1:condition}: + % if $1: ${0:} % endif snippet ife if/else - % if ${1:condition}: + % if $1: ${2:} % else: ${0:} diff --git a/sources_non_forked/vim-snippets/snippets/markdown.snippets b/sources_non_forked/vim-snippets/snippets/markdown.snippets index 303271ed..a8b00cfb 100644 --- a/sources_non_forked/vim-snippets/snippets/markdown.snippets +++ b/sources_non_forked/vim-snippets/snippets/markdown.snippets @@ -5,19 +5,19 @@ # The suffix `c` stands for "Clipboard". snippet [ - [${1:text}](http://${2:address}) + [${1:text}](${2:address}) snippet [* [${1:link}](${2:`@*`}) snippet [c [${1:link}](${2:`@+`}) snippet [" - [${1:text}](http://${2:address} "${3:title}") + [${1:text}](https://${2:address} "${3:title}") snippet ["* [${1:link}](${2:`@*`} "${3:title}") snippet ["c [${1:link}](${2:`@+`} "${3:title}") snippet [: - [${1:id}]: http://${2:url} + [${1:id}]: https://${2:url} snippet [:* [${1:id}]: ${2:`@*`} @@ -26,7 +26,7 @@ snippet [:c [${1:id}]: ${2:`@+`} snippet [:" - [${1:id}]: http://${2:url} "${3:title}" + [${1:id}]: https://${2:url} "${3:title}" snippet [:"* [${1:id}]: ${2:`@*`} "${3:title}" @@ -67,17 +67,21 @@ snippet <* <`@*`> snippet -snippet ** - **${1:bold}** -snippet __ - __${1:bold}__ -snippet === +snippet ** Bold + **$0** +snippet __ Bold + __$0__ +snippet --- Front matter + --- + $0 + --- +snippet ==== `repeat('=', strlen(getline(line('.') - 3)))` ${0} snippet - - ${0} -snippet --- +snippet ---- `repeat('-', strlen(getline(line('.') - 3)))` ${0} @@ -129,6 +133,12 @@ snippet img snippet youtube {% youtube ${0:video_id} %} +snippet tb + | ${0:factors} | ${1:a} | ${2:b} | + | ------------- |------------- | ------- | + | ${3:f1} | Y | N | + | ${4:f2} | Y | N | + # The quote should appear only once in the text. It is inherently part of it. # See http://octopress.org/docs/plugins/pullquote/ for more info. @@ -136,3 +146,11 @@ snippet pullquote {% pullquote %} ${1:text} {" ${2:quote} "} ${0:text} {% endpullquote %} + +# Definition lists +snippet : Definition list + $1 + : $0 +snippet :: Alternate definition list + $1 + - $0 diff --git a/sources_non_forked/vim-snippets/snippets/ocaml.snippets b/sources_non_forked/vim-snippets/snippets/ocaml.snippets index eb5a799c..aec43bed 100644 --- a/sources_non_forked/vim-snippets/snippets/ocaml.snippets +++ b/sources_non_forked/vim-snippets/snippets/ocaml.snippets @@ -1,7 +1,7 @@ snippet doc - (* - ${0} - *) + (** ${0} *) +snippet comment + (* ${0} *) snippet let let ${1} = ${2} in ${0} diff --git a/sources_non_forked/vim-snippets/snippets/octave.snippets b/sources_non_forked/vim-snippets/snippets/octave.snippets new file mode 100644 index 00000000..c11805ff --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/octave.snippets @@ -0,0 +1,2 @@ +extends matlab + diff --git a/sources_non_forked/vim-snippets/snippets/org.snippets b/sources_non_forked/vim-snippets/snippets/org.snippets new file mode 100644 index 00000000..0559cd68 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/org.snippets @@ -0,0 +1,135 @@ +# Org Mode Snippets Imported from (https://github.com/doomemacs/snippets/) +# Imported by ybenel (github.com/m1ndo) + +# Begin +snippet begin + #+begin_${1:type} ${2:options} + $0 + #+end_$1 +# Begin Center +snippet sub { ${2} diff --git a/sources_non_forked/vim-snippets/snippets/perl6.snippets b/sources_non_forked/vim-snippets/snippets/perl6.snippets index 21ddf5bd..e7db89a1 100644 --- a/sources_non_forked/vim-snippets/snippets/perl6.snippets +++ b/sources_non_forked/vim-snippets/snippets/perl6.snippets @@ -28,12 +28,12 @@ snippet ife ${3} } snippet eif - elsif ${1) { + elsif ${1} { ${2} } # Conditional One-line snippet xif - ${1:expression} if ${2:condition}; + ${1} if $2; # Unless conditional snippet unless unless ${1} { @@ -41,14 +41,14 @@ snippet unless } # Unless conditional One-line snippet xunless - ${1:expression} unless ${2:condition}; + ${1} unless $2; # Ternary conditional snippet tc - ${1:condition} ?? ${2:value-if-true} !! ${3:value-if-false}; + $1 ?? ${2:value-if-true} !! ${3:value-if-false}; # given - when (perl6 switch) snippet switch given ${1:$var} { - when ${2:condition} { + when $2 { ${3:# code block ...} } ${4} diff --git a/sources_non_forked/vim-snippets/snippets/php.snippets b/sources_non_forked/vim-snippets/snippets/php.snippets index 2828f2fb..b0bae1b3 100644 --- a/sources_non_forked/vim-snippets/snippets/php.snippets +++ b/sources_non_forked/vim-snippets/snippets/php.snippets @@ -38,7 +38,7 @@ snippet i ${0:${VISUAL}} } snippet t. - $this-> + \$this-> snippet f function ${1}(${3}) { @@ -86,7 +86,7 @@ snippet =?: snippet ?: ${1:true} ? ${2:a} : ${0} snippet t "$retVal = (condition) ? a : b" - $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b}; + $${1:retVal} = ($2) ? ${3:a} : ${4:b}; # Predefined variables snippet C $_COOKIE['${1:variable}'] @@ -283,7 +283,7 @@ snippet def "define('VARIABLE_NAME', 'definition')" snippet def? ${1}defined('${2}') snippet wh "while (condition) { ... }" - while (${1:/* condition */}) { + while ($1) { ${0:${VISUAL}} } snippet do "do { ... } while (condition)" diff --git a/sources_non_forked/vim-snippets/snippets/plsql.snippets b/sources_non_forked/vim-snippets/snippets/plsql.snippets index 2920758a..6a75f773 100644 --- a/sources_non_forked/vim-snippets/snippets/plsql.snippets +++ b/sources_non_forked/vim-snippets/snippets/plsql.snippets @@ -8,7 +8,7 @@ snippet ps snippet pb create or replace package body ${1:name} as - ${0:-- body} + $0 end; -- end of package body $1; # package procedure spec snippet pps @@ -18,7 +18,7 @@ snippet ppb procedure ${1:name}(${2:args}) as begin - ${0:-- body} + $0 end $2; # package function spec snippet pfs @@ -31,7 +31,7 @@ snippet pfb as l_res $3; begin - ${0:-- body}; + $0; return l_res; end $1; # snow errors diff --git a/sources_non_forked/vim-snippets/snippets/processing.snippets b/sources_non_forked/vim-snippets/snippets/processing.snippets index 798e5458..0fe69022 100644 --- a/sources_non_forked/vim-snippets/snippets/processing.snippets +++ b/sources_non_forked/vim-snippets/snippets/processing.snippets @@ -64,7 +64,7 @@ snippet for }; #loop while snippet wh - while (${1:/* condition */}) { + while ($1) { ${0} } #break diff --git a/sources_non_forked/vim-snippets/snippets/ps1.snippets b/sources_non_forked/vim-snippets/snippets/ps1.snippets index 41099d9d..652f0d86 100644 --- a/sources_non_forked/vim-snippets/snippets/ps1.snippets +++ b/sources_non_forked/vim-snippets/snippets/ps1.snippets @@ -29,8 +29,8 @@ snippet function # PowerShell Splatting snippet splatting $Params = @{ - ${1:Param1} = '{2:Value1}' - ${3:Param2} = '{4:Value2}' + ${1:Param1} = '${2:Value1}' + ${3:Param2} = '${4:Value2}' } ${5:CommandName} @Params @@ -43,13 +43,13 @@ snippet enum # PowerShell if..then snippet if - if (${1:condition}) { - ${2:statement} + if ($1) { + $0 } # PowerShell if..else snippet ife - if ( ${1:condition} ) { + if ( $1 ) { ${2} } else { @@ -58,8 +58,8 @@ snippet ife # PowerShell While Loop snippet while - while (${1:condition}) { - ${2:statement} + while ($1) { + $0 } # PowerShell Filter..Sort @@ -69,7 +69,7 @@ snippet filtersort # PowerShell foreach snippet foreach foreach ( $${1:iterator} in $${2:collection} ) { - ${3:statement} + $0 } # PowerShell export-csv @@ -99,4 +99,3 @@ snippet switch ${2:condition1} { ${3:action} } ${4:condition2} { ${5:action} } default { ${6:action} } - diff --git a/sources_non_forked/vim-snippets/snippets/puppet.snippets b/sources_non_forked/vim-snippets/snippets/puppet.snippets index adb781dd..5a1dd6a1 100644 --- a/sources_non_forked/vim-snippets/snippets/puppet.snippets +++ b/sources_non_forked/vim-snippets/snippets/puppet.snippets @@ -207,7 +207,7 @@ snippet define } snippet service - service { "${1:service}" : + service { "${1:service}": ensure => running, enable => true, require => [ Package["${2:package}"], File["${3:file}"], ], @@ -215,7 +215,7 @@ snippet service } snippet file - file { "${1:filename}" : + file { "${1:filename}": ensure => ${2:present}, owner => "${3:root}", group => "${4:root}", @@ -227,7 +227,7 @@ snippet file } snippet archive - archive { "${1:filename}" : + archive { "${1:filename}": ensure => ${2:present}, url => "http://${3:url}", extension => "${4:tgz}", @@ -237,7 +237,7 @@ snippet archive } snippet firewall - firewall { "${1:comment}" : + firewall { "${1:comment}": proto => ${2:tcp}, action => ${3:accept}, port => ${4}, diff --git a/sources_non_forked/vim-snippets/snippets/python.snippets b/sources_non_forked/vim-snippets/snippets/python.snippets index 42832815..75302a49 100644 --- a/sources_non_forked/vim-snippets/snippets/python.snippets +++ b/sources_non_forked/vim-snippets/snippets/python.snippets @@ -12,6 +12,7 @@ snippet uni ${0:representation} snippet from from ${1:package} import ${0:module} + # Module Docstring snippet docs """ @@ -27,20 +28,24 @@ snippet sk "skip unittests" b @unittest.skip(${1:skip_reason}) snippet wh - while ${1:condition}: + while $1: ${0:${VISUAL}} + # dowh - does the same as do...while in other languages snippet dowh while True: ${1} - if ${0:condition}: + if $0: break + snippet with with ${1:expr} as ${2:var}: ${0:${VISUAL}} + snippet awith async with ${1:expr} as ${2:var}: ${0:${VISUAL}} + # New Class snippet cl class ${1:ClassName}(${2:object}): @@ -52,11 +57,24 @@ snippet cl snippet cla class ${1:class_name}: """${0:description}""" + snippet clai class ${1:class_name}: """${2:description}""" def __init__(self, ${3:args}): ${0} + +# Data class +snippet dcl dataclass + @dataclass + class ${1:ClassName}: + """${2:description}""" + ${3:var_1}: ${4:int} + ${5:var_2}: ${6:float} = ${7:0} + + def ${8:total}(self): -> $6: + return ${0:self.$3 * self.$5} + # New Function snippet def def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): @@ -72,6 +90,7 @@ snippet adef snippet adeff async def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): ${0} + # New Method snippet defi def __init__(self, ${1:args}): @@ -85,30 +104,47 @@ snippet adefm # New Property snippet property - def ${1:foo}(): - doc = "${2:The $1 property.}" - def fget(self): - ${3:return self._$1} - def fset(self, value): - ${4:self._$1 = value} - def fdel(self): - ${0:del self._$1} - return locals() - $1 = property(**$1()) + @property + def ${1:foo}(self) -> ${2:type}: + """${3:doc}""" + return self._$1 + + @$1.setter + def $1(self, value: $2): + self._$1 = value + # Ifs snippet if - if ${1:condition}: + if $1: ${0:${VISUAL}} snippet el else: ${0:${VISUAL}} snippet ei - elif ${1:condition}: + elif $1: ${0:${VISUAL}} + +# Match +snippet match Structural pattern matching + match ${1:expression}: + case ${2:pattern_1}: + ${3:pass} + case ${4:pattern_2}: + ${5:pass} + +# Match with wildcard +snippet matchw Pattern matching with wildcard + match ${1:expression}: + case ${2:pattern_1}: + ${3:pass} + case _: + ${0:pass} + # For snippet for for ${1:item} in ${2:items}: ${0} + # Encodes snippet cutf8 # -*- coding: utf-8 -*- @@ -116,13 +152,18 @@ snippet clatin1 # -*- coding: latin-1 -*- snippet cascii # -*- coding: ascii -*- + # Lambda snippet ld ${1:var} = lambda ${2:vars} : ${0:action} + snippet ret return ${0} snippet . self. +snippet sa self.attribute = attribute + self.${1:attribute} = $1 + snippet try Try/Except try: ${1:${VISUAL}} @@ -151,6 +192,7 @@ snippet tryef Try/Except/Else/Finally ${5} finally: ${0} + # if __name__ == '__main__': snippet ifmain if __name__ == '__main__': @@ -158,6 +200,10 @@ snippet ifmain # __magic__ snippet _ __${1:init}__ + +# debugger breakpoint +snippet br + breakpoint() # python debugger (pdb) snippet pdb __import__('pdb').set_trace() @@ -182,14 +228,20 @@ snippet ptpython # python console debugger (pudb) snippet pudb __import__('pudb').set_trace() +# python console debugger remote (pudb) +snippet pudbr + from pudb.remote import set_trace + set_trace() # pdb in nosetests snippet nosetrace __import__('nose').tools.set_trace() snippet pprint __import__('pprint').pprint(${1}) + snippet " """${0:doc} """ + # assertions snippet a= self.assertEqual(${0}, ${1}) @@ -210,6 +262,7 @@ snippet tgwt # then: ${3} snippet fut from __future__ import ${0} + #getopt snippet getopt try: @@ -227,6 +280,7 @@ snippet getopt ${0} elif option in ("-v", "--verbose"): verbose = argument + # argparse snippet addp parser = ${VISUAL:argparse.}ArgumentParser() @@ -235,7 +289,7 @@ snippet addsp snippet addarg parser.add_argument("${0:short_arg}", "${1:long_arg}", default=${2:None}, help="${3:Help text}") snippet addnarg - parser.add_argument("${0:arg}", nargs="${1:*}", default"${2:None}, help="${3:Help text}") + parser.add_argument("${0:arg}", nargs="${1:*}", default=${2:None}, help="${3:Help text}") snippet addaarg parser.add_argument("${0:arg}", "${1:long_arg}", action="${2:store_true}", default=${3:False}, help="${4:Help text}") snippet pargs @@ -270,7 +324,7 @@ snippet epydoc """ snippet dol def ${1:__init__}(self, *args, **kwargs): - super(${0:ClassName}, self).$1(*args, **kwargs) + super(${0:ClassName}, self).$1(*args, **kwargs) snippet kwg self.${1:var_name} = kwargs.get('$1', ${2:None}) snippet lkwg @@ -454,3 +508,16 @@ snippet numeric "methods for emulating a numeric type" b def __coerce__(self, other): ${25:pass} +# Printing +snippet pr + print($0) +snippet prs + print("$0") +snippet prf + print(f"$0") +snippet fpr + print($0, file=${1:sys.stderr}) +snippet fprs + print("$0", file=${1:sys.stderr}) +snippet fprf + print(f"$0", file=${1:sys.stderr}) diff --git a/sources_non_forked/vim-snippets/snippets/r.snippets b/sources_non_forked/vim-snippets/snippets/r.snippets index 7bdeeec0..46f316c9 100644 --- a/sources_non_forked/vim-snippets/snippets/r.snippets +++ b/sources_non_forked/vim-snippets/snippets/r.snippets @@ -11,7 +11,7 @@ snippet source # conditionals snippet if - if (${1:condition}) { + if ($1) { ${0} } snippet el @@ -19,19 +19,27 @@ snippet el ${0} } snippet ei - else if (${1:condition}) { + else if ($1) { ${0} } # loops snippet wh - while(${1}) { - ${2} + while(${1:true}) { + ${0} + } +snippet wht + while(true) { + ${0} } snippet for for (${1:item} in ${2:list}) { ${3} } +snippet foreach + foreach (${1:item} = ${2:list}) { + ${3} + } # functions snippet fun diff --git a/sources_non_forked/vim-snippets/snippets/racket.snippets b/sources_non_forked/vim-snippets/snippets/racket.snippets index 723d7383..5304cd8b 100644 --- a/sources_non_forked/vim-snippets/snippets/racket.snippets +++ b/sources_non_forked/vim-snippets/snippets/racket.snippets @@ -1,3 +1,4 @@ +# Languages snippet #r #lang racket snippet #tr @@ -10,56 +11,38 @@ snippet #d #lang datalog snippet #wi #lang web-server/insta + +# Defines snippet def (define ${1} ${0}) snippet defun (define (${1}) ${0}) +snippet defv "define-values" + (define-values (${1}) (${0})) +snippet defm "define/match" + (define/match (${1}) + [(${2}) ${3}] + ${0}) +snippet defs "define-syntax" + (define-syntax (${1}) + ${0}) + +# Conditionals snippet if (if ${1} ${2} ${0}) snippet ifn - (if (not ${1}) ${2} {0}) + (if (not ${1}) ${2} ${0}) snippet ifl (if ${1} - (let () - ${2}) + (let (${2}) + ${3}) ${0}) snippet ifnl (if (not ${1}) - (let () - ${2}) + (let (${2}) + ${3}) ${0}) -snippet when - (when ${1} - ${0}) -snippet cond - (cond - [(${1}) - ${0}]) -snippet case - (case ${1} - [(${2}) - ${0}]) -snippet match - (match ${1} - [(${2}) - ${0}]) -snippet letcc - (let/cc here (set! ${1} here) ${0}) -snippet for - (for ([${1} ${2}]) - ${0}) -snippet req - (require ${0}) -snippet unless - (unless ${1} ${2} ${0}) -snippet let - (let ([${1}]) ${0}) -snippet begin - (begin - ${0}) -snippet lambda - (lambda (${1}) ${0}) snippet ifb (if ${1} (begin @@ -70,3 +53,79 @@ snippet ifnb (begin ${2}) ${0}) +snippet when + (when ${1} + ${0}) +snippet unless + (unless ${1} ${2} ${0}) +snippet cond + (cond + [(${1}) ${0}]) +snippet conde + (cond + [(${1}) ${2}] + [else ${0}]) +snippet case + (case ${1} + [(${2}) ${0}]) +snippet match + (match ${1} + [(${2}) ${0}]) + +# For iterations +snippet for + (for ([${1}]) + ${0}) +snippet forl "for/list" + (for/list ([${1}]) + ${0}) +snippet forf "for/fold" + (for/fold + ([${1}]) + ([${2}]) + ${0}) +snippet forfr "for/foldr" + (for/foldr + ([${1}]) + ([${2}]) + ${0}) +snippet fora "for/and" + (for/and ([${1}]) + ${0}) +snippet foro "for/or" + (for/or ([${1}]) + ${0}) +snippet fors "for/sum" + (for/sum ([${1}]) + ${0}) +snippet forp "for/product" + (for/product ([${1}]) + ${0}) +snippet forfi "for/first" + (for/first ([${1}]) + ${0}) +snippet forla "for/last" + (for/last ([${1}]) + ${0}) + +snippet lambda + (lambda (${1}) ${0}) +snippet apply + (apply ${1} ${0}) +snippet map + (map ${1} ${0}) +snippet filter + (filter ${1} ${0}) + +snippet req + (require ${0}) +snippet prov + (provide ${0}) + +snippet let + (let ([${1}]) ${0}) +snippet letcc + (let/cc here (set! ${1} here) ${0}) +snippet begin + (begin + ${0}) diff --git a/sources_non_forked/vim-snippets/snippets/rails.snippets b/sources_non_forked/vim-snippets/snippets/rails.snippets index 4678de92..624a48c2 100644 --- a/sources_non_forked/vim-snippets/snippets/rails.snippets +++ b/sources_non_forked/vim-snippets/snippets/rails.snippets @@ -274,22 +274,6 @@ snippet sl end snippet sha1 Digest::SHA1.hexdigest(${0:string}) -snippet sweeper - class ${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper - observe $1 - - def after_save(${0:model_class_name}) - expire_cache($2) - end - - def after_destroy($2) - expire_cache($2) - end - - def expire_cache($2) - expire_page - end - end snippet va validates_associated validates_associated :${0:attribute} snippet va validates .., acceptance: true diff --git a/sources_non_forked/vim-snippets/snippets/rmd.snippets b/sources_non_forked/vim-snippets/snippets/rmd.snippets new file mode 100644 index 00000000..13d55363 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/rmd.snippets @@ -0,0 +1,149 @@ +# +# Snipmate Snippets for Pandoc Markdown +# +# Many snippets have starred versions, i.e., versions +# that end with an asterisk (`*`). These snippets use +# vim's `"*` register---i.e., the contents of the +# system clipboard---to insert text. + +extends markdown + +# Insert Title Block +snippet %% + % ${1:`Filename('', 'title')`} + % ${2:`g:snips_author`} + % ${3:`strftime("%d %B %Y")`} + + ${4} +snippet %%* + % ${1:`Filename('', @*)`} + % ${2:`g:snips_author`} + % ${3:`strftime("%d %b %Y")`} + + ${4} + +# library() +snippet req + require(${1:}, quietly = TRUE) +# If Condition +snippet if + if ( $1 ) + { + ${2:} + } +snippet el + else + { + ${1:} + } + +# Function +snippet fun + ${1:funname} <- # ${2:} + function + ( + ${3:} + ) + { + ${4:} + } +# repeat +snippet re + repeat{ + ${2:} + if($1) break + } + +# matrix +snippet ma + matrix(NA, nrow = ${1:}, ncol = ${2:}) + +# data frame +snippet df + data.frame(${1:}, header = TRUE) + +snippet cmdarg + args <- commandArgs(TRUE) + if (length(args) == 0) + stop("Please give ${1:}!") + if (!all(file.exists(args))) + stop("Couln't find input files!") + +snippet getopt + require('getopt', quietly = TRUE) + opt_spec <- matrix(c( + 'help', 'h', 0, "logical", "Getting help", + 'file', 'f', 1, "character","File to process" + ), ncol = 5, byrow = TRUE) + opt <- getopt(spec = opt_spec) + if ( !is.null(opt$help) || is.null(commandArgs()) ) { + cat(getopt(spec = opt_spec, usage = TRUE, command = "yourCmd")) + q(status=0) + } + # some inital value + if ( is.null(opt$???) ) { opt$??? <- ??? } + +snippet optparse + require("optparse", quietly = TRUE) + option_list <- + list(make_option(c("-n", "--add_numbers"), action="store_true", default=FALSE, + help="Print line number at the beginning of each line [default]") + ) + parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) + arguments <- parse_args(parser, positional_arguments = TRUE) + opt <- arguments$options + + if(length(arguments$args) != 1) { + cat("Incorrect number of required positional arguments\n\n") + print_help(parser) + stop() + } else { + file <- arguments$args + } + + if( file.access(file) == -1) { + stop(sprintf("Specified file ( %s ) does not exist", file)) + } else { + file_text <- readLines(file) + } + +snippet #! + #!/usr/bin/env Rscript + +snippet debug + # Development & Debugging, don't forget to uncomment afterwards! + #-------------------------------------------------------------------------------- + #setwd("~/Projekte/${1:}") + #opt <- list(${2:} + # ) + #-------------------------------------------------------------------------------- + + +# Took from pandoc-plugin <<<< +# Underline with `=`s or `-`s +snippet #=== + #`repeat('=', strlen(getline(line(".") - 1)))` + ${1} +snippet #--- + #`repeat('-', strlen(getline(line(".") - 1)))` + ${1} + +# >>>> + +snippet r + \`\`\`{r ${1:chung_tag}, echo = FALSE ${2:options}} + ${3:} + \`\`\` +snippet ri + \`{r ${1:}}\` + +snippet copt + \`\`\` {r setup, echo = FALSE} + opts_chunk$set(fig.path='../figures/${1:}', cache.path='../cache/-' + , fig.align='center', fig.show='hold', par=TRUE) + #opts_knit$set(upload.fun = imgur_upload) # upload images + \`\`\` + + +# End of File =================================================================== +# vim: set noexpandtab: diff --git a/sources_non_forked/vim-snippets/snippets/rst.snippets b/sources_non_forked/vim-snippets/snippets/rst.snippets index dd47863e..8279af5a 100644 --- a/sources_non_forked/vim-snippets/snippets/rst.snippets +++ b/sources_non_forked/vim-snippets/snippets/rst.snippets @@ -1,7 +1,7 @@ # rst snippet : - :${1:field name}: ${0:field body} + :${1:field name}: $0 snippet * *${1:Emphasis}* ${0} snippet ** @@ -19,16 +19,17 @@ snippet - ${0} #some directive snippet img: - .. |${0:alias}| image:: ${1:img} + .. |${1:alias}| image:: ${0:img} snippet fig: .. figure:: ${1:img} - :alt: ${0:alter text} + :alt: ${2:alter text} + + $0 +snippet con: + .. contents:: ${1:Table of Contents} - $2 -snippet cont: - .. contents:: ${0:content} -snippet code: +snippet cod: .. code:: ${1:type} ${0:write some code} @@ -65,34 +66,36 @@ snippet tod: .. todo:: ${0} snippet lis: - .. list-table:: ${0:Title} + .. list-table:: ${1:Title} :header-rows: 1 - :stub-columns: 1 + :stub-columns: 0 - * - x1,y1 - - x2,y1 - - x3,y1 - * - x1,y2 - - x2,y2 - - x3,y2 - * - x1,y3 - - x2,y3 - - x3,y3 + * - ${0:R1C1} + - R1C2 + * - R2C1 + - R2C2 +snippet csv: + .. csv-table:: ${1:Title} + :header-rows: 1 + :stub-columns: 0 + ${0:R1C1}, R1C2 + R2C1, R2C2 snippet toc: .. toctree:: :maxdepth: 2 ${0} snippet dow: - :download:\`${0:text} <${1:path}>\` + :download:\`${1:text} <${0:path}>\` snippet ref: - :ref:\`${0:text} <${1:path}>\` + :ref:\`${1:text} <${0:path}>\` snippet doc: - :doc:`${0:text} <${1:path}>` + :doc:\`${1:text} <${0:path}>\` # CJK optimize, CJK has no space between charaters snippet *c \ *${1:Emphasis}*\ ${0} snippet **c \ **${1:Strong emphasis}**\ ${0} +# vim:set list noet sts=0 sw=4 ts=4: diff --git a/sources_non_forked/vim-snippets/snippets/ruby.snippets b/sources_non_forked/vim-snippets/snippets/ruby.snippets index ff5fede1..8aadb71d 100644 --- a/sources_non_forked/vim-snippets/snippets/ruby.snippets +++ b/sources_non_forked/vim-snippets/snippets/ruby.snippets @@ -24,7 +24,7 @@ snippet rb snippet beg begin ${0} - rescue ${1:Exception} => ${2:e} + rescue ${1:StandardError} => ${2:e} end snippet req require require '${1}' @@ -34,16 +34,20 @@ snippet # # => snippet case case ${1:object} - when ${2:condition} + when $2 ${0} end snippet when - when ${1:condition} + when $1 ${0:${VISUAL}} snippet def def ${1:method_name} ${0} end +snippet defm + def ${1:method} + @$1 ||= ${0} + end snippet deft def test_${1:case_name} ${0} @@ -55,46 +59,46 @@ snippet descendants end end snippet if - if ${1:condition} + if $1 ${0:${VISUAL}} end snippet ife - if ${1:condition} + if $1 ${2:${VISUAL}} else ${0} end snippet eif - elsif ${1:condition} + elsif $1 ${0:${VISUAL}} snippet ifee - if ${1:condition} + if $1 $2 - elsif ${3:condition} + elsif $3 $4 else $0 end snippet unless - unless ${1:condition} + unless $1 ${0:${VISUAL}} end snippet unlesse - unless ${1:condition} + unless $1 $2 else $0 end snippet unlesee - unless ${1:condition} + unless $1 $2 - elsif ${3:condition} + elsif $3 $4 else $0 end snippet wh - while ${1:condition} + while $1 ${0:${VISUAL}} end snippet for @@ -102,7 +106,7 @@ snippet for ${0} end snippet until - until ${1:condition} + until $1 ${0:${VISUAL}} end snippet cla class .. end @@ -199,18 +203,18 @@ snippet defds snippet am alias_method :${1:new_name}, :${0:old_name} snippet app - if __FILE__ == $PROGRAM_NAME + if __FILE__ == \$PROGRAM_NAME ${0} end # usage_if() snippet usai if ARGV.${1} - abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0} + abort "Usage: #{\$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0} end # usage_unless() snippet usau unless ARGV.${1} - abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0} + abort "Usage: #{\$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0} end snippet array Array.new(${1:10}) { |${2:i}| ${0} } @@ -372,6 +376,8 @@ snippet finad end snippet gre grep(${1:/pattern/}) { |${2:match}| ${0} } +snippet grepv + select { |${1:line}| $1 !~ ${2:/pattern/} }${0} snippet sub ${1:g}sub(${2:/pattern/}) { |${3:match}| ${0} } snippet sca @@ -439,7 +445,7 @@ snippet optp options = { ${0:default: 'args'} } ARGV.options do |opts| - opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}" + opts.banner = "Usage: #{File.basename(\$PROGRAM_NAME)}" end snippet opt opts.on('-${1:o}', '--${2:long-option-name}', ${3:String}, '${4:Option description.}') do |${5:opt}| @@ -485,22 +491,22 @@ snippet asnm snippet aso assert_operator ${1:left}, :${2:operator}, ${3:right} snippet asr - assert_raise ${1:Exception} { ${0} } + assert_raises(${1:StandardError}) { ${0} } snippet asrd - assert_raise ${1:Exception} do + assert_raises ${1:StandardError} do ${0} end snippet asnr - assert_nothing_raised ${1:Exception} { ${0} } + assert_nothing_raised(${1:StandardError}) { ${0} } snippet asnrd - assert_nothing_raised ${1:Exception} do + assert_nothing_raised ${1:StandardError} do ${0} end snippet asrt assert_respond_to ${1:object}, :${2:method} snippet ass assert_same(..) assert_same ${1:expected}, ${2:actual} -snippet ass assert_send(..) +snippet asss assert_send(..) assert_send [${1:object}, :${2:message}, ${3:args}] snippet asns assert_not_same ${1:unexpected}, ${2:actual} @@ -518,6 +524,24 @@ snippet asntd end snippet fl flunk '${1:Failure message.}' +snippet rf + refute ${1:test}, '${2:Failure message.}' +snippet rfe + refute_equal ${1:unexpected}, ${2:actual} +snippet rfko + refute_kind_of ${1:UnexpectedKind}, ${2:actual_instance} +snippet rfn + refute_nil ${1:instance} +snippet rfo + refute_operator ${1:left}, :${2:operator}, ${3:right} +snippet rfi + refute_includes ${1:collection}, ${2:object} +snippet rfid + refute_in_delta ${1:unexpected_float}, ${2:actual_float}, ${3:2**-20} +snippet rfio + refute_instance_of ${1:UnexpectedClass}, ${2:actual_instance} +snippet rfs + refute_same ${1:unexpected}, ${2:actual} # Benchmark.bmbm do .. end snippet bm- TESTS = ${1:10_000} @@ -568,7 +592,7 @@ snippet b snippet begin begin fail 'A test exception.' - rescue Exception => e + rescue StandardError => e puts e.message puts e.backtrace.inspect else @@ -580,12 +604,16 @@ snippet begin #debugging snippet debug require 'byebug'; byebug +snippet dbg + require 'debug'; debugger snippet debug19 require 'debugger'; debugger 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} # @@ -640,7 +668,7 @@ snippet wm snippet mout -> { ${1} }.must_output '${0}' snippet mra - -> { ${1} }.must_raise ${0:Exception} + -> { ${1} }.must_raise ${0:StandardError} snippet mrt must_respond_to :${0:method} snippet wrt diff --git a/sources_non_forked/vim-snippets/snippets/rust.snippets b/sources_non_forked/vim-snippets/snippets/rust.snippets index 7a97fdc2..04f05dd6 100644 --- a/sources_non_forked/vim-snippets/snippets/rust.snippets +++ b/sources_non_forked/vim-snippets/snippets/rust.snippets @@ -11,6 +11,14 @@ snippet pfn "Function definition" pub fn ${1:function_name}(${2})${3} { ${0} } +snippet afn "Async function definition" + async fn ${1:function_name}(${2})${3} { + ${0} + } +snippet pafn "Async function definition" + pub async fn ${1:function_name}(${2})${3} { + ${0} + } snippet bench "Bench function" b #[bench] fn ${1:bench_function_name}(b: &mut test::Bencher) { @@ -93,7 +101,7 @@ snippet crate "Define create meta attributes" // Crate name #![crate_name = "${1:crate_name}"] // Additional metadata attributes - #![desc = "${2:Descrption.}"] + #![desc = "${2:Description.}"] #![license = "${3:BSD}"] #![comment = "${4:Comment.}"] // Specify the output type @@ -102,7 +110,7 @@ snippet crate "Define create meta attributes" snippet opt "Option" Option<${1:i32}> snippet res "Result" - Result<${1:~str}, ${2:()}> + Result<${1:&str}, ${2:()}> # Control structures snippet if if ${1} { @@ -114,6 +122,10 @@ snippet ife "if / else" } else { ${0} } +snippet ifl "if let (...)" + if let ${1:Some($2)} = $3 { + ${0:${VISUAL}} + } snippet el "else" else { ${0:${VISUAL}} @@ -135,7 +147,11 @@ snippet loop "loop {}" b ${0:${VISUAL}} } snippet wh "while loop" - while ${1:condition} { + while $1 { + ${0:${VISUAL}} + } +snippet whl "while let (...)" + while let ${1:Some($2)} = $3 { ${0:${VISUAL}} } snippet for "for ... in ... loop" @@ -153,7 +169,7 @@ snippet st "Struct definition" ${0} } snippet impl "Struct/Trait implementation" - impl ${1:Type/Trait}${2: for ${3:Type}} { + impl ${1:Type/Trait}${2: for $3} { ${0} } snippet stn "Struct with new constructor" @@ -161,9 +177,9 @@ snippet stn "Struct with new constructor" ${0} } - impl $1 { - pub fn new(${2}) -> Self { - $1 { ${3} } + impl$2 $1$2 { + pub fn new(${4}) -> Self { + $1 { ${5} } } } snippet ty "Type alias" @@ -182,7 +198,7 @@ snippet trait "Trait definition" ${0} } snippet drop "Drop trait implementation (destructor)" - impl Drop for ${1:Name} { + impl Drop for $1 { fn drop(&mut self) { ${0} } @@ -193,10 +209,6 @@ snippet ss "static string declaration" snippet stat "static item declaration" static ${1}: ${2:usize} = ${0}; # Concurrency -snippet scoped "spawn a scoped thread" - thread::scoped(${1:move }|| { - ${0} - }); snippet spawn "spawn a thread" thread::spawn(${1:move }|| { ${0} @@ -230,5 +242,11 @@ snippet macro "macro_rules!" b $3 ) } -snippet box "Box::new()" +snippet boxp "Box::new()" Box::new(${0:${VISUAL}}) +snippet rc "Rc::new()" + Rc::new(${0:${VISUAL}}) +snippet unim "unimplemented!()" + unimplemented!() +snippet use "use ...;" b + use ${1:std::$2}; diff --git a/sources_non_forked/vim-snippets/snippets/sass.snippets b/sources_non_forked/vim-snippets/snippets/sass.snippets index 5bef5937..992341e7 100644 --- a/sources_non_forked/vim-snippets/snippets/sass.snippets +++ b/sources_non_forked/vim-snippets/snippets/sass.snippets @@ -13,15 +13,15 @@ snippet fun @function ${1:name}(${2:args}) ${0} snippet if - @if ${1:condition} + @if $1 ${0:${VISUAL}} snippet ife - @if ${1:condition} + @if $1 ${2:${VISUAL}} @else ${0} snippet eif - @else if ${1:condition} + @else if $1 ${0:${VISUAL}} snippet for @for ${1:$i} from ${2:1} through ${3:3} @@ -722,7 +722,7 @@ snippet jc:sa snippet jc:se justify-content: space-evenly snippet jc:st - justify-content: space-evenly + justify-content: stretch snippet jc:l justify-content: left snippet jc:r diff --git a/sources_non_forked/vim-snippets/snippets/scheme.snippets b/sources_non_forked/vim-snippets/snippets/scheme.snippets index bdd445f9..0aa13794 100644 --- a/sources_non_forked/vim-snippets/snippets/scheme.snippets +++ b/sources_non_forked/vim-snippets/snippets/scheme.snippets @@ -17,7 +17,7 @@ snippet * # Definition snippet def (define (${1:name}) - (${0:definition})) + ${0:definition}) # Definition with lambda snippet defl diff --git a/sources_non_forked/vim-snippets/snippets/scss.snippets b/sources_non_forked/vim-snippets/snippets/scss.snippets index 998a1200..475c2b38 100644 --- a/sources_non_forked/vim-snippets/snippets/scss.snippets +++ b/sources_non_forked/vim-snippets/snippets/scss.snippets @@ -17,17 +17,17 @@ snippet fun ${0} } snippet if - @if ${1:condition} { + @if $1 { ${0} } snippet ife - @if ${1:condition} { + @if $1 { ${2} } @else { ${0} } snippet eif - @else if ${1:condition} { + @else if $1 { ${0} } snippet for diff --git a/sources_non_forked/vim-snippets/snippets/sh.snippets b/sources_non_forked/vim-snippets/snippets/sh.snippets index 35afa301..ef94e683 100644 --- a/sources_non_forked/vim-snippets/snippets/sh.snippets +++ b/sources_non_forked/vim-snippets/snippets/sh.snippets @@ -1,13 +1,13 @@ -# Shebang. Executing bash via /usr/bin/env makes scripts more portable. +# Shebang snippet #! - #!/usr/bin/env sh + #!/bin/sh snippet s#! - #!/usr/bin/env sh - set -euo pipefail + #!/bin/sh + set -eu snippet safe - set -euo pipefail + set -eu snippet bash #!/usr/bin/env bash @@ -18,11 +18,11 @@ snippet sbash IFS=$'\n\t' snippet if - if [[ ${1:condition} ]]; then + if [ $1 ]; then ${0:${VISUAL}} fi snippet elif - elif [[ ${1:condition} ]]; then + elif [ $1 ]; then ${0:${VISUAL}} snippet for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do @@ -33,11 +33,15 @@ snippet fori ${0:${VISUAL}} done snippet wh - while [[ ${1:condition} ]]; do + while [ $1 ]; do + ${0:${VISUAL}} + done +snippet wht + while true; do ${0:${VISUAL}} done snippet until - until [[ ${1:condition} ]]; do + until [ $1 ]; do ${0:${VISUAL}} done snippet case @@ -55,7 +59,7 @@ snippet go done # Set SCRIPT_DIR variable to directory script is located. snippet sdir - SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + SCRIPT_DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" && pwd )" # getopt snippet getopt __ScriptVersion="${1:version}" @@ -66,7 +70,7 @@ snippet getopt #=============================================================================== function usage () { - echo "Usage : $${0:0} [options] [--] + echo "Usage : \$${0:0} [options] [--] Options: -h|help Display this message @@ -80,27 +84,27 @@ snippet getopt while getopts ":hv" opt do - case $opt in + case \$opt in h|help ) usage; exit 0 ;; - v|version ) echo "$${0:0} -- Version $__ScriptVersion"; exit 0 ;; + v|version ) echo "\$${0:0} -- Version \$__ScriptVersion"; exit 0 ;; - * ) echo -e "\n Option does not exist : $OPTARG\n" + * ) echo -e "\\n Option does not exist : \$OPTARG\\n" usage; exit 1 ;; esac # --- end of case --- done - shift $(($OPTIND-1)) + shift \$(($OPTIND-1)) snippet root if [ \$(id -u) -ne 0 ]; then exec sudo \$0; fi snippet fun-sh ${1:function_name}() { - ${0:#function_body} + $0 } snippet fun function ${1:function_name}() { - ${0:#function_body} + $0 } diff --git a/sources_non_forked/vim-snippets/snippets/smarty.snippets b/sources_non_forked/vim-snippets/snippets/smarty.snippets new file mode 100644 index 00000000..070fcd7e --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/smarty.snippets @@ -0,0 +1,139 @@ +# snippets for smarty3 + +extends html +extends javascript +extends css + +# https://www.smarty.net/docs/en/language.function.if.tpl +snippet if "{if cond} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {/if} + +snippet ifn "{if !cond} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {/if} + +snippet ife "{if cond} ... {else} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {else} + ${2} + {/if} + +snippet eif "{elseif cond} ... {/if}" + {elseif ${1}} + ${0:${VISUAL}} + {/if} + +snippet el "{else} ... {/if}" + {else} + ${1} + {/if} + +# https://www.smarty.net/docs/en/language.function.for.tpl +snippet for "The {for} tag is used to create simple loops." + {for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}} + ${0:${VISUAL}} + {/for} + +snippet forelse "The {for}{forelse} tag is used to create simple loops." + {for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}} + ${0:${VISUAL}} + {forelse} + ${8} + {/for} + +# https://www.smarty.net/docs/en/language.function.foreach.tpl +snippet foreach "{foreach} is used for looping over arrays of data." + {foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}} + ${0:${VISUAL}} + {/foreach} + +snippet foreach2 "[Smarty2] {foreach} is used for looping over arrays of data." + {foreach from=$${1:collection} item='${2}'${3: key='${4}'}${5: name='${6}'}} + ${0:${VISUAL}} + {/foreach} + +snippet foreachelse "{foreach} is used for looping over arrays of data." + {foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}} + ${0:${VISUAL}} + {foreachelse} + ${5} + {/foreach} + +snippet wh "{while} loops in Smarty have much the same flexibility as PHP while statements, with a few added features for the template engine. Every {while} must be paired with a matching {/while}. All PHP conditionals and functions are recognized, such as ||, or, &&, and, is_array(), etc." + {while ${1}} + ${0:${VISUAL}} + {/while} + + + +# https://www.smarty.net/docs/en/language.function.append.tpl +#snippet append implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.assign.tpl +#snippet assign implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.block.tpl +snippet block "{block} is used to define a named area of template source for template inheritance." + {block name='${1}'} + ${0:${VISUAL}} + {/block} + +# https://www.smarty.net/docs/en/language.function.call.tpl +snippet call "{call} is used to call a template function defined by the {function} tag just like a plugin function." + {call name=${1}${2: assign=${3}}${4: variables}} + +# https://www.smarty.net/docs/en/language.function.capture.tpl +snippet capture "{capture} is used to collect the output of the template between the tags into a variable instead of displaying it. Any content between {capture name='foo'} and {/capture} is collected into the variable specified in the name attribute. " + {capture name='${1}'${2: assign='${3}' }${4: append='${5:array_variable}'}} + ${0:${VISUAL}} + {/capture} + +# https://www.smarty.net/docs/en/language.function.config.load.tpl +#snippet config_load implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.extends.tpl +snippet extends "{extends} tags are used in child templates in template inheritance for extending parent templates." + {extends file='${1}'} + +# https://www.smarty.net/docs/en/language.function.function.tpl +snippet function "{function} is used to create functions within a template and call them just like a plugin function. Instead of writing a plugin that generates presentational content, keeping it in the template is often a more manageable choice. It also simplifies data traversal, such as deeply nested menus." + {function name='${1}' ${2:variables}} + ${0:${VISUAL}} + {/function} + +# https://www.smarty.net/docs/en/language.function.include.tpl +#snippet include implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.literal.tpl +snippet literal "{literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax" + {literal} + ${0:${VISUAL}} + {/literal} + +# https://www.smarty.net/docs/en/language.function.nocache.tpl +snippet nocache "{nocache} is used to disable caching of a template section. Every {nocache} must be paired with a matching {/nocache}." + {nocache} + ${0:${VISUAL}} + {/nocache} + +# https://www.smarty.net/docs/en/language.function.section.tpl +snippet section "A {section} is for looping over sequentially indexed arrays of data, unlike {foreach} which is used to loop over a single associative array. Every {section} tag must be paired with a closing {/section} tag." + {section name='${1}'${2: loop='${3}'}${4: start=${5}}${6: step=${7}}${8: max=${9}}${10: show=${11}}} + ${0:${VISUAL}} + {/section} + +# https://www.smarty.net/docs/en/language.function.setfilter.tpl +snippet setfilter "The {setfilter}...{/setfilter} block tag allows the definition of template instance's variable filters." + {setfilter ${1:filters}} + ${0:${VISUAL}} + {/setfilter} + +# https://www.smarty.net/docs/en/language.function.strip.tpl +snippet strip "Anything within {strip}{/strip} tags are stripped of the extra spaces or carriage returns at the beginnings and ends of the lines before they are displayed. This way you can keep your templates readable, and not worry about extra white space causing problems." + {strip} + ${0:${VISUAL}} + {/strip} diff --git a/sources_non_forked/vim-snippets/snippets/svelte.snippets b/sources_non_forked/vim-snippets/snippets/svelte.snippets new file mode 100644 index 00000000..4e09d0cc --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/svelte.snippets @@ -0,0 +1 @@ +extends html, javascript, css diff --git a/sources_non_forked/vim-snippets/snippets/systemverilog.snippets b/sources_non_forked/vim-snippets/snippets/systemverilog.snippets index 70a9d2d3..828a6de9 100644 --- a/sources_non_forked/vim-snippets/snippets/systemverilog.snippets +++ b/sources_non_forked/vim-snippets/snippets/systemverilog.snippets @@ -1,7 +1,7 @@ extends verilog # Foreach Loop -snippet fe +snippet forea foreach (${1}) begin ${0} end @@ -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 . + // extern virtual task pre_start(); + + // Task: pre_body + // This task is a user-definable callback that is called before the execution + // of ~only~ when the sequence is started with . + // If 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 ~only~ when the sequence is started with . + // If 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 . + // 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 . + // extern virtual task pre_start(); + + // Task: pre_body + // This task is a user-definable callback that is called before the execution + // of ~only~ when the sequence is started with . + // If 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 ~only~ when the sequence is started with . + // If 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 . + // 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 */ + // ; + 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 &= ( + // && + // + ); + 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 + diff --git a/sources_non_forked/vim-snippets/snippets/tex.snippets b/sources_non_forked/vim-snippets/snippets/tex.snippets index 24d4ff8a..4d54fe01 100644 --- a/sources_non_forked/vim-snippets/snippets/tex.snippets +++ b/sources_non_forked/vim-snippets/snippets/tex.snippets @@ -1,5 +1,32 @@ #version 1 #PREAMBLE +#documentclass without options +snippet dcl \documentclass{} + \\documentclass{${1:class}} ${0} +#documentclass with options +snippet dclo \documentclass[]{} + \\documentclass[${1:options}]{${2:class}} ${0} + +snippet tmplt "Template" + \\documentclass{${1:article}} + + \\usepackage{import} + \\usepackage{pdfpages} + \\usepackage{transparent} + \\usepackage{xcolor} + $2 + + \\newcommand{\incfig}[2][1]{% + \def\svgwidth{#1\columnwidth} + \import{./figures/}{#2.pdf_tex} + } + $3 + \\pdfsuppresswarningpagegroup=1 + + \\begin{document} + $0 + \\end{document} + #newcommand snippet nc \newcommand \\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0} @@ -19,6 +46,11 @@ snippet begin \begin{} ... \end{} block \\begin{${1:env}} ${0:${VISUAL}} \\end{$1} + +# Maketitle +snippet mkt maketitle + \\maketitle + # Tabular snippet tab tabular (or arbitrary) environment \\begin{${1:tabular}}{${2:c}} @@ -52,7 +84,7 @@ snippet eq equation environment snippet eql Labeled equation environment \\begin{equation} \\label{eq:${2}} - ${0:${VISUAL}} + ${0:${VISUAL}} \\end{equation} # Equation snippet eq* unnumbered equation environment @@ -163,11 +195,21 @@ snippet par \paragraph \\paragraph{${1:paragraph name}}% \\label{par:${2:$1}} ${0} +# Paragraph* +snippet par* \paragraph* + \\paragraph*{${1:paragraph name}}% + \\label{par:${2:$1}} + ${0} # Sub Paragraph snippet subp \subparagraph \\subparagraph{${1:subparagraph name}}% \\label{subp:${2:$1}} ${0} +# Sub Paragraph* +snippet subp* \subparagraph* + \\subparagraph*{${1:subparagraph name}}% + \\label{subp:${2:$1}} + ${0} snippet ni \noindent \\noindent ${0} @@ -222,6 +264,10 @@ snippet rm roman font text \\textrm{${1:${VISUAL:text}}}${0} snippet tt typewriter (monospace) text \\texttt{${1:${VISUAL:text}}}${0} +snippet tsub subscripted text + \\textsubscript{${1:${VISUAL:text}}}${0} +snippet tsup superscripted text + \\textsuperscript{${1:${VISUAL:text}}}${0} #Math font snippet mf mathfrak \\mathfrak{${1:${VISUAL:text}}}${0} @@ -285,7 +331,9 @@ snippet sum \sum^{}_{} snippet lim \lim_{} \\lim_{${1:n \\to \\infty}} ${0} snippet frame frame environment - \\begin{frame}[${1:t}]{${2:title}} + \\begin{frame}[${1:t}] + \frametitle{${2:title}} + \framesubtitle{${3:subtitle}} ${0:${VISUAL}} \\end{frame} snippet block block environment @@ -352,3 +400,48 @@ snippet hrefc # enquote from package csquotes snippet enq enquote \\enquote{${1:${VISUAL:text}}} ${0} +# Time derivative +snippet ddt time derivative + \\frac{d}{dt} {$1} {$0} +# Limit +snippet lim limit + \\lim_{{$1}} {{$2}} {$0} +# Partial derivative +snippet pdv partial derivation + \\frac{\\partial {$1}}{\\partial {$2}} {$0} +# Second order partial derivative +snippet ppdv second partial derivation + \\frac{\\partial^2 {$1}}{\\partial {$2} \\partial {$3}} {$0} +# Ordinary derivative +snippet dv derivative + \\frac{d {$1}}{d {$2}} {$0} +# Summation +snippet summ summation + \\sum_{{$1}} {$0} +# Shorthand for time derivative +snippet dot dot + \\dot{{$1}} {$0} +# Shorthand for second order time derivative +snippet ddot ddot + \\ddot{{$1}} {$0} +# Vector +snippet vec vector + \\vec{{$1}} {$0} +# Bar +snippet bar bar + \\bar{{$1}} {$0} +# Cross product +snippet \x cross product + \\times {$0} +# Dot product +snippet . dot product + \\cdot {$0} +# Integral +snippet int integral + \\int_{{$1}}^{{$2}} {$3} \\: d{$4} {$0} +# Right arrow +snippet ra rightarrow + \\rightarrow {$0} +# Long right arrow +snippet lra longrightarrow + \\longrightarrow {$0} diff --git a/sources_non_forked/vim-snippets/snippets/twig.snippets b/sources_non_forked/vim-snippets/snippets/twig.snippets index d0d7e1c9..8102984d 100644 --- a/sources_non_forked/vim-snippets/snippets/twig.snippets +++ b/sources_non_forked/vim-snippets/snippets/twig.snippets @@ -1,34 +1,177 @@ -snippet bl "{% block xyz %} .. {% endblock xyz %}" +# Tags +snippet apply "twig apply" + {% apply ${1} %} + ${0} + {% endapply %} +snippet autoescape "twig autoescape" + {% autoescape %} + ${0} + {% endautoescape %} +snippet endautoescape "twig endautoescape" + {% endautoescape %}${0} +snippet bl "twig block" {% block ${1} %} - ${2:${VISUAL}} - {% endblock $1 %} -snippet js "{% javascripts 'xyz' %} .. {% endjavascripts %}" - {% javascripts '${1}' %} - - {% endjavascripts %} -snippet css "{% stylesheets 'xyz' %} .. {% endstylesheets %}" - {% stylesheets '${1}' %} - - {% endstylesheets %} -snippet if "{% if %} .. {% endif %}" - {% if ${1} %} - ${2:${VISUAL}} - {% endif %} -snippet ife "{% if %} .. {% else %} .. {% endif %}" - {% if ${1} %} - ${2:${VISUAL}} - {% else %} - ${0} - {% endif %} -snippet el "{% else %}" - {% else %} - ${0:${VISUAL}} -snippet eif "{% elseif %}" - {% elseif ${1} %} - ${0} -snippet for "{% for x in y %} .. {% endfor %}" + ${0} + {% endblock %} +snippet block "twig block" + {% block ${1} %} + ${0} + {% endblock %} +snippet endblock "twig endblock" + {% endblock %}${0} +snippet cache "twig cache" + {% cache %} + ${0} + {% endcache %} +snippet endcache "twig endcache" + {% endcache %}${0} +snippet css "twig css" + {% css %} + ${0} + {% endcss %} +snippet endcss "twig endcss" + {% endcss %}${0} +snippet dd "twig dd" + {% dd ${1} %}${0} +snippet do "twig do" + {% do ${1} %}${0} +snippet embed "twig embed" + {% embed "${1}" %} + ${0} + {% endembed %} +snippet endembed "twig endembed" + {% endembed %}${0} +snippet exit "twig exit" + {% exit ${1} %} +snippet extends "twig extends" + {% extends "${1}" %}${0} +snippet ext "twig extends" + {% extends "${1}" %}${0} +snippet for "twig for" {% for ${1} in ${2} %} - ${3} + ${0} {% endfor %} -snippet ext "{% extends xyz %}" - {% extends ${1} %} +snippet fore "twig for else" + {% for ${1} in ${2} %} + ${3} + {% else %} + ${0} + {% endfor %} +snippet endfor "twig endfor" + {% endfor %}${0} +snippet from "twig from" + {% from "${1}" import ${2} %}${0} +snippet header "twig header" + {% header "${1}" %}${0} +snippet hook "twig hook" + {% hook "${1}" %}${0} +snippet html "twig html" + {% html %} + ${0} + {% endhtml %} +snippet endhtml "twig endhtml" + {% endhtml %}${0} +snippet if "twig if" + {% if ${1} %} + ${0} + {% endif %} +snippet ife "twig if else" + {% if ${1} %} + ${2} + {% else %} + ${0} + {% endif %} +snippet el "twig else" + {% else %} +snippet eif "twig elseif" + {% elseif ${1} %} + ${0} +snippet endif "twig endif" + {% endif %}${0} +snippet import "twig import" + {% import "${1}" as ${2} %}${0} +snippet include "twig include" + {% include "${1}" %}${0} +snippet includewith "twig include with parameters" + {% include "${1}" with ${2} %}${0} +snippet js "twig js" + {% js %} + ${0} + {% endjs %} +snippet endjs "twig endjs" + {% endjs %}${0} +snippet macro "twig macro" + {% macro ${1}(${2}) %} + ${0} + {% endmacro %} +snippet endmacro "twig endmacro" + {% endmacro %}${0} +snippet namespace "twig namespace" + {% namespace "${1}" %} + ${0} + {% endnamespace %} +snippet endnamespace "twig endnamespace" + {% endnamespace %}${0} +snippet nav "twig nav" + {% nav ${1} in ${2} %} + ${0} + {% endnav %} +snippet endnav "twig endnav" + {% endnav %}${0} +snippet paginate "twig paginate" + {% paginate ${1} as ${2} %}${0} +snippet redirect "twig redirect" + {% redirect "${1}" %}${0} +snippet requireguest "twig requireguest" + {% requireGuest %}${0} +snippet requirelogin "twig requirelogin" + {% requireLogin %}${0} +snippet requirepermission "twig requirepermission" + {% requirePermission "${1}" %}${0} +snippet set "twig set" + {% set ${1} = ${2} %}${0} +snippet setb "twig set block" + {% set ${1} %} + ${0} + {% endset %} +snippet endset "twig endset" + {% endset %}${0} +snippet switch "twig switch" + {% switch ${1} %} + {% case "${2}" %} + ${0} + {% default %} + + {% endswitch %} +snippet case "twig switch case" + {% case "${1}" %} + ${0} +snippet default "twig switch default" + {% default %} + ${0} +snippet endswitch "twig endswitch" + {% endswitch %}${0} +snippet use "twig use" + {% use "${1}" %}${0} +snippet verbatim "twig verbatim" + {% verbatim %} + ${0} + {% endverbatim %} +snippet endverbatim "twig endverbatim" + {% endverbatim %}${0} +snippet with "twig with" + {% with %} + ${0} + {% endwith %} +snippet endwith "twig endwith" + {% endwith %}${0} + +# Functions +snippet dump "twig dump" +
+		{{ dump(${1}) }}
+	
+ +# Filters +snippet translate "twig translate" + {{ "${1}"|t }}${0} diff --git a/sources_non_forked/vim-snippets/snippets/typescript.snippets b/sources_non_forked/vim-snippets/snippets/typescript.snippets index aa87242f..a784c5ef 100644 --- a/sources_non_forked/vim-snippets/snippets/typescript.snippets +++ b/sources_non_forked/vim-snippets/snippets/typescript.snippets @@ -1 +1,67 @@ extends javascript + +snippet tconst "ts const" + const ${1}: ${2:any} = ${3}; + ${0} +snippet tlet "ts let" + let ${1}: ${2:any} = ${3}; + ${0} +snippet tvar "ts var" + var ${1}: ${2:any} = ${3}; + ${0} +snippet + "ts create field" + ${1}: ${0:any} +snippet #+ "ts create private field using #" + #${1}: ${0:any} +snippet tpfi "ts create public field" + public ${1}: ${0:any} +snippet tprfi "ts create private field" + private ${1}: ${0:any} +snippet tprofi "ts create protected field" + protected ${1}: ${0:any} +snippet int "interface" + interface ${1} { + ${2}: ${3:any}; + ${0} + } +snippet intx "interface extends" + interface ${1} extends ${2} { + ${3}: ${4:any}; + ${0} + } +snippet tfun "ts function" + function ${1}(${2}): ${3:any} { + ${0} + } +snippet tpmet "ts public method" + public ${1}(${2}): ${3:any} { + ${0} + } +snippet tpsmet "ts public static method" + public static ${1}(${2}): ${3:any} { + ${0} + } +snippet tprmet "ts private method" + private ${1}(${2}): ${3:any} { + ${0} + } +snippet tpromet "ts protected method" + protected ${1}(${2}): ${3:any} { + ${0} + } +snippet tcla "ts class" + class ${1} { + ${2} + constructor(public ${3}: ${4: any}) { + ${5} + } + ${0} + } +snippet tclax "ts class extends" + class ${1} extends ${2} { + ${3} + constructor(public ${4}: ${5: any}) { + ${6} + } + ${0} + } diff --git a/sources_non_forked/vim-snippets/snippets/verilog.snippets b/sources_non_forked/vim-snippets/snippets/verilog.snippets index 5cd80f39..16bacc2a 100644 --- a/sources_non_forked/vim-snippets/snippets/verilog.snippets +++ b/sources_non_forked/vim-snippets/snippets/verilog.snippets @@ -9,7 +9,7 @@ snippet ife ${2} end else begin - ${1} + ${3} end # Else if statement snippet eif @@ -58,6 +58,42 @@ snippet al end # Module block snippet mod - module ${1:module_name} (${2}); + module ${1:`vim_snippets#Filename('$1', 'name')`} (${2}); ${0} endmodule +# For +snippet for + for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) begin + ${4} + end +# Forever +snippet forev + forever begin + ${0} + end +# Function +snippet fun + function ${1:void} ${2:name}(${3}); + ${0} + endfunction: $2 +# Task +snippet task + task ${1:name}(${2}); + ${0} + endtask: $1 +# Initial +snippet ini + initial begin + ${0} + end +# typedef struct packed +snippet tdsp + typedef struct packed { + int ${2:data}; + } ${1:`vim_snippets#Filename('$1_t', 'name')`}; +# typedef eum +snippet tde + typedef enum ${2:logic[15:0]} + { + ${3:REG = 16'h0000} + } ${1:my_dest_t}; diff --git a/sources_non_forked/vim-snippets/snippets/vhdl.snippets b/sources_non_forked/vim-snippets/snippets/vhdl.snippets index f13f5bf9..0683a218 100644 --- a/sources_non_forked/vim-snippets/snippets/vhdl.snippets +++ b/sources_non_forked/vim-snippets/snippets/vhdl.snippets @@ -3,7 +3,7 @@ snippet lib library ${1} - use ${1}.${2} + use $1.${2} # Standard Libraries snippet libs @@ -75,6 +75,16 @@ snippet prc ${2} end if; end process; +# process with clock and reset +snippet prcr + process (${1:clk}, ${2:nrst}) + begin + if ($2 = '${3:0}') then + ${4} + elsif rising_edge($1) then + ${5} + end if; + end process; # process all snippet pra process (${1:all}) diff --git a/sources_non_forked/vim-snippets/snippets/vim.snippets b/sources_non_forked/vim-snippets/snippets/vim.snippets index 6822b8a9..85cf2922 100644 --- a/sources_non_forked/vim-snippets/snippets/vim.snippets +++ b/sources_non_forked/vim-snippets/snippets/vim.snippets @@ -43,9 +43,14 @@ snippet ife if ... else statement endif snippet au augroup ... autocmd block augroup ${1:AU_NAME} - " this one is which you're most likely to use? + autocmd! autocmd ${2:BufRead,BufNewFile} ${3:*.ext,*.ext3|} ${0} - augroup end + augroup END +snippet auv augroupvisual ... autocmd block with visual placeholder + augroup ${1:AU_NAME} + autocmd! + ${0:${VISUAL}} + augroup END snippet bun Vundle.vim Plugin definition Plugin '${0}' snippet plug vim-plug Plugin definition @@ -76,3 +81,5 @@ snippet im imap ${1} ${2} snippet exe execute ${1} +snippet filename + `Filename()` diff --git a/sources_non_forked/vim-snippets/snippets/vue.snippets b/sources_non_forked/vim-snippets/snippets/vue.snippets index 0f14caec..9462635f 100644 --- a/sources_non_forked/vim-snippets/snippets/vue.snippets +++ b/sources_non_forked/vim-snippets/snippets/vue.snippets @@ -50,7 +50,7 @@ snippet vactions ${1:updateValue}({commit}, ${2:payload}) { commit($1, $2); } - } + }, # Add in js animation hooks snippet vanim:js:el @@ -106,26 +106,45 @@ snippet vdata return { ${1:key}: ${2:value} }; - } + }, + +snippet vmounted + mounted() { + console.log('mounted'); + }, + +snippet vmethods + methods: { + ${1:method}() { + console.log('method'); + } + }, + +snippet vcomputed + computed: { + ${1:fnName}() { + return; + } + }, snippet vfilter filters: { ${1:fnName}: function(${2:value}) { return; } - } + }, snippet vfor
{{ $1 }} -
snippet vgetters getters: { ${1:value}: state => { return state.$1; } - } + }, snippet vimport import ${1:New} from './components/$1.vue'; @@ -152,7 +171,7 @@ snippet vmutations ${1:updateValue}(state, ${3:payload}) => { state.${2:value} = $3; } - } + }, snippet vprops:d ${1:propName}: { @@ -176,3 +195,14 @@ snippet vstore ${1:key}: ${2:value} } }); + + +# vue-i18n snippets https://github.com/kazupon/vue-i18n + +snippet trans + $t('$1') + +# Translation with parameter +snippet transc + $t('$1', { $2: $3 }) + diff --git a/sources_non_forked/vim-snippets/snippets/yii.snippets b/sources_non_forked/vim-snippets/snippets/yii.snippets index 1f9fc6f7..1aecad29 100644 --- a/sources_non_forked/vim-snippets/snippets/yii.snippets +++ b/sources_non_forked/vim-snippets/snippets/yii.snippets @@ -144,7 +144,7 @@ snippet yrp #----------------Yii Model----------------------------- #Yii Model count snippet ycountm - ${1:ModelName}::model()->count(${2:condition}, array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->count($2, array('${3:key}'=>${0:value})); #Yii Model countBySql snippet ycountbs @@ -152,35 +152,35 @@ snippet ycountbs #Yii Model updateAll snippet yupdatea - ${1:ModelName}::model()->updateAll(${2:array('attributes')}, ${3:condition},array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->updateAll(${2:array('attributes')}, $3,array('${4:key}'=>${0:value})); #Yii Model updateByPk snippet yupdatebp - ${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, ${4:condition},array('${5:key}'=>${0:value})); + ${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, $4,array('${5:key}'=>${0:value})); #Yii Model deleteAll snippet ydela - ${1:ModelName}::model()->deleteAll(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->deleteAll($2,array('${3:key}'=>${0:value})); #Yii Model deleteByPk snippet ydelbp - ${1:ModelName}::model()->deleteByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->deleteByPk(${2:pk}, $3, array('${4:key}'=>${0:value})); #Yii Model find snippet yfind - ${1:ModelName}::model()->find(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->find($2,array('${3:key}'=>${0:value})); #Yii Model findAll snippet yfinda - ${1:ModelName}::model()->findAll(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->findAll($2,array('${3:key}'=>${0:value})); #Yii Model findByPk snippet yfindbp - ${1:ModelName}::model()->findByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->findByPk(${2:pk}, $3, array('${4:key}'=>${0:value})); #Yii Model findAllByPk snippet yfindabp - ${1:ModelName}::model()->findAllByPk(${2:pk}, ${3:condition},array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->findAllByPk(${2:pk}, $3,array('${4:key}'=>${0:value})); #Yii Model findBySql snippet yfindbs @@ -188,11 +188,11 @@ snippet yfindbs #Yii Model findAllByAttributes snippet yfindaba - ${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), ${4:condition}, array('${5:key}'=>${0:value})); + ${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), $4, array('${5:key}'=>${0:value})); #Yii Model exists snippet yexists - ${1:ModelName}::model()->exists(${2:condition}, array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->exists($2, array('${3:key}'=>${0:value})); #Yii Create model class snippet ymodel diff --git a/sources_non_forked/vim-snippets/snippets/zsh.snippets b/sources_non_forked/vim-snippets/snippets/zsh.snippets index a8173c26..485766fe 100644 --- a/sources_non_forked/vim-snippets/snippets/zsh.snippets +++ b/sources_non_forked/vim-snippets/snippets/zsh.snippets @@ -1,19 +1,21 @@ # #!/bin/zsh +extends bash + snippet #! - #!/bin/zsh + #!/usr/bin/env zsh snippet if - if ${1:condition}; then + if $1; then ${0:${VISUAL}} fi snippet ife - if ${1:condition}; then + if $1; then ${2:${VISUAL}} else ${0:# statements} fi snippet eif - elif ${1:condition}; then + elif $1; then ${0:${VISUAL}} snippet for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do @@ -28,11 +30,11 @@ snippet fore ${0:${VISUAL}} done snippet wh - while ${1:condition}; do + while $1; do ${0:${VISUAL}} done snippet until - until ${1:condition}; do + until $1; do ${0:${VISUAL}} done snippet repeat diff --git a/sources_non_forked/vim-surround/.github/FUNDING.yml b/sources_non_forked/vim-surround/.github/FUNDING.yml new file mode 100644 index 00000000..e2a49d11 --- /dev/null +++ b/sources_non_forked/vim-surround/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: tpope +custom: ["https://www.paypal.me/vimpope"] diff --git a/sources_non_forked/vim-surround/README.markdown b/sources_non_forked/vim-surround/README.markdown index 5321eec4..d2a5c298 100644 --- a/sources_non_forked/vim-surround/README.markdown +++ b/sources_non_forked/vim-surround/README.markdown @@ -70,6 +70,13 @@ support: git clone https://tpope.io/vim/surround.git vim -u NONE -c "helptags surround/doc" -c q +## FAQ + +> How do I surround without adding a space? + +Only the opening brackets—`[`, `{`, and `(`—add a space. Use a closing +bracket, or the `b` (`(`) and `B` (`{`) aliases. + ## Contributing See the contribution guidelines for diff --git a/sources_non_forked/vim-surround/doc/surround.txt b/sources_non_forked/vim-surround/doc/surround.txt index fd395d23..f39efb28 100644 --- a/sources_non_forked/vim-surround/doc/surround.txt +++ b/sources_non_forked/vim-surround/doc/surround.txt @@ -202,16 +202,4 @@ that allow you to jump to such markings. > let g:surround_insert_tail = "<++>" < -ISSUES *surround-issues* - -Vim could potentially get confused when deleting/changing occurs at the very -end of the line. Please report any repeatable instances of this. - -Do we need to use |inputsave()|/|inputrestore()| with the tag replacement? - -Indenting is handled haphazardly. Need to decide the most appropriate -behavior and implement it. Right now one can do :let b:surround_indent = 1 -(or the global equivalent) to enable automatic re-indenting by Vim via |=|; -should this be the default? - vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-surround/plugin/surround.vim b/sources_non_forked/vim-surround/plugin/surround.vim index 59092601..8a4016e9 100644 --- a/sources_non_forked/vim-surround/plugin/surround.vim +++ b/sources_non_forked/vim-surround/plugin/surround.vim @@ -1,6 +1,6 @@ " surround.vim - Surroundings " Author: Tim Pope -" Version: 2.1 +" Version: 2.2 " GetLatestVimScripts: 1697 1 :AutoInstall: surround.vim if exists("g:loaded_surround") || &cp || v:version < 700 @@ -323,7 +323,7 @@ function! s:insert(...) " {{{1 let cb_save = &clipboard set clipboard-=unnamed clipboard-=unnamedplus let reg_save = @@ - call setreg('"',"\r",'v') + call setreg('"',"\032",'v') call s:wrapreg('"',char,"",linemode) " If line mode is used and the surrounding consists solely of a suffix, " remove the initial newline. This fits a use case of mine but is a @@ -354,19 +354,21 @@ function! s:insert(...) " {{{1 call s:reindent() endif norm! `] - call search('\r','bW') + call search("\032",'bW') let @@ = reg_save let &clipboard = cb_save return "\" endfunction " }}}1 -function! s:reindent() " {{{1 - if exists("b:surround_indent") ? b:surround_indent : (!exists("g:surround_indent") || g:surround_indent) +function! s:reindent() abort " {{{1 + if get(b:, 'surround_indent', get(g:, 'surround_indent', 1)) && (!empty(&equalprg) || !empty(&indentexpr) || &cindent || &smartindent || &lisp) silent norm! '[='] endif endfunction " }}}1 function! s:dosurround(...) " {{{1 + let sol_save = &startofline + set startofline let scount = v:count1 let char = (a:0 ? a:1 : s:inputtarget()) let spc = "" @@ -388,6 +390,9 @@ function! s:dosurround(...) " {{{1 if a:0 > 1 let newchar = a:2 if newchar == "\" || newchar == "\" || newchar == "" + if !sol_save + set nostartofline + endif return s:beep() endif endif @@ -414,6 +419,9 @@ function! s:dosurround(...) " {{{1 if keeper == "" call setreg('"',original,otype) let &clipboard = cb_save + if !sol_save + set nostartofline + endif return "" endif let oldline = getline('.') @@ -447,7 +455,7 @@ function! s:dosurround(...) " {{{1 let keeper = substitute(keeper,'^\s\+','','') let keeper = substitute(keeper,'\s\+$','','') endif - if col("']") == col("$") && col('.') + 1 == col('$') + if col("']") == col("$") && virtcol('.') + 1 == virtcol('$') if oldhead =~# '^\s*$' && a:0 < 2 let keeper = substitute(keeper,'\%^\n'.oldhead.'\(\s*.\{-\}\)\n\s*\%$','\1','') endif @@ -478,6 +486,9 @@ function! s:dosurround(...) " {{{1 else silent! call repeat#set("\C".(a:0 > 2 && a:3 ? "S" : "s")."urround".char.newchar.s:input,scount) endif + if !sol_save + set nostartofline + endif endfunction " }}}1 function! s:changesurround(...) " {{{1