diff options
74 files changed, 1199 insertions, 319 deletions
diff --git a/.github/ISSUE_TEMPLATE/report-a-bug.md b/.github/ISSUE_TEMPLATE/report-a-bug.md index 6d345c4a..4169029d 100644 --- a/.github/ISSUE_TEMPLATE/report-a-bug.md +++ b/.github/ISSUE_TEMPLATE/report-a-bug.md @@ -1,5 +1,6 @@ --- name: Report a bug +labels: bug about: Report a bug with ALE. --- diff --git a/.github/ISSUE_TEMPLATE/suggest-a-new-linter-or-fixer.md b/.github/ISSUE_TEMPLATE/suggest-a-new-linter-or-fixer.md index 75c7637f..ad235e57 100644 --- a/.github/ISSUE_TEMPLATE/suggest-a-new-linter-or-fixer.md +++ b/.github/ISSUE_TEMPLATE/suggest-a-new-linter-or-fixer.md @@ -1,5 +1,6 @@ --- name: Suggest a new linter or fixer +labels: new tool about: Suggest a new tool ALE can officially integrate with. --- diff --git a/.github/ISSUE_TEMPLATE/suggest-an-improvement.md b/.github/ISSUE_TEMPLATE/suggest-an-improvement.md index 855a6493..d39d0ac8 100644 --- a/.github/ISSUE_TEMPLATE/suggest-an-improvement.md +++ b/.github/ISSUE_TEMPLATE/suggest-an-improvement.md @@ -1,5 +1,6 @@ --- name: Suggest an improvement +labels: enhancement about: Suggest some way to improve ALE, or add a new feature. --- @@ -35,6 +35,10 @@ If you don't care about Language Server Protocol, ALE won't load any of the code for working with it unless needed. One of ALE's general missions is that you won't pay for the features that you don't use. +**Help Wanted:** If you would like to help maintain this plugin by managing the +many issues and pull requests that are submitted, please send the author an +email at [dev@w0rp.com](mailto:dev@w0rp.com?subject=Helping%20with%20ALE). + If you enjoy this plugin, feel free to contribute or check out the author's other content at [w0rp.com](https://w0rp.com). diff --git a/ale_linters/c/clangd.vim b/ale_linters/c/clangd.vim index ab8a0259..c42d4497 100644 --- a/ale_linters/c/clangd.vim +++ b/ale_linters/c/clangd.vim @@ -8,7 +8,7 @@ call ale#Set('c_build_dir', '') function! ale_linters#c#clangd#GetCommand(buffer) abort let l:build_dir = ale#c#GetBuildDirectory(a:buffer) - return '%e -x c' + return '%e' \ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') endfunction diff --git a/ale_linters/cpp/clangcheck.vim b/ale_linters/cpp/clangcheck.vim index 7d32a57c..4cb04864 100644 --- a/ale_linters/cpp/clangcheck.vim +++ b/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/ale_linters/crystal/crystal.vim b/ale_linters/crystal/crystal.vim index 3c2fefb7..8a905b12 100644 --- a/ale_linters/crystal/crystal.vim +++ b/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/ale_linters/graphql/eslint.vim b/ale_linters/graphql/eslint.vim index 654b8c17..aed1a371 100644 --- a/ale_linters/graphql/eslint.vim +++ b/ale_linters/graphql/eslint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('graphql', { \ 'name': 'eslint', \ 'executable': function('ale#handlers#eslint#GetExecutable'), \ 'command': function('ale#handlers#eslint#GetCommand'), -\ 'callback': 'ale#handlers#eslint#Handle', +\ 'callback': 'ale#handlers#eslint#HandleJSON', \}) diff --git a/ale_linters/javascript/standard.vim b/ale_linters/javascript/standard.vim index 203a803e..1990adce 100644 --- a/ale_linters/javascript/standard.vim +++ b/ale_linters/javascript/standard.vim @@ -7,6 +7,7 @@ call ale#Set('javascript_standard_options', '') function! ale_linters#javascript#standard#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/semistandard/bin/cmd.js', \ 'node_modules/.bin/standard', diff --git a/ale_linters/nim/nimcheck.vim b/ale_linters/nim/nimcheck.vim index b5796dcd..b739ca04 100644 --- a/ale_linters/nim/nimcheck.vim +++ b/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/ale_linters/php/psalm.vim b/ale_linters/php/psalm.vim index 834d0993..ab4dbbc9 100644 --- a/ale_linters/php/psalm.vim +++ b/ale_linters/php/psalm.vim @@ -2,6 +2,7 @@ " Description: plugin for Psalm, static analyzer for PHP call ale#Set('psalm_langserver_executable', 'psalm') +call ale#Set('psalm_langserver_options', '') call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#psalm#GetProjectRoot(buffer) abort @@ -10,12 +11,16 @@ function! ale_linters#php#psalm#GetProjectRoot(buffer) abort return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' endfunction +function! ale_linters#php#psalm#GetCommand(buffer) abort + return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'psalm_langserver_options')) +endfunction + call ale#linter#Define('php', { \ 'name': 'psalm', \ 'lsp': 'stdio', \ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [ \ 'vendor/bin/psalm', \ ])}, -\ 'command': '%e --language-server', +\ 'command': function('ale_linters#php#psalm#GetCommand'), \ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'), \}) diff --git a/ale_linters/powershell/powershell.vim b/ale_linters/powershell/powershell.vim index a63191fd..5f49f72c 100644 --- a/ale_linters/powershell/powershell.vim +++ b/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/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim index dc4044e6..94dfae7d 100644 --- a/ale_linters/python/mypy.vim +++ b/ale_linters/python/mypy.vim @@ -3,6 +3,7 @@ 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) @@ -18,6 +19,15 @@ endfunction " The directory to change to before running mypy function! s:GetDir(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) @@ -51,7 +61,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 +84,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 diff --git a/ale_linters/typescript/standard.vim b/ale_linters/typescript/standard.vim new file mode 100644 index 00000000..da8f14eb --- /dev/null +++ b/ale_linters/typescript/standard.vim @@ -0,0 +1,31 @@ +" Author: Ahmed El Gabri <@ahmedelgabri> +" Description: standardjs for typescript files + +call ale#Set('typescript_standard_executable', 'standard') +call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typescript_standard_options', '') + +function! ale_linters#typescript#standard#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'typescript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', + \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/.bin/standard', + \]) +endfunction + +function! ale_linters#typescript#standard#GetCommand(buffer) abort + let l:executable = ale_linters#typescript#standard#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'typescript_standard_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin %s' +endfunction + +" standard uses eslint and the output format is the same +call ale#linter#Define('typescript', { +\ 'name': 'standard', +\ 'executable': function('ale_linters#typescript#standard#GetExecutable'), +\ 'command': function('ale_linters#typescript#standard#GetCommand'), +\ 'callback': 'ale#handlers#eslint#Handle', +\}) diff --git a/autoload/ale/ant.vim b/autoload/ale/ant.vim index 689b444b..7d02484e 100644 --- a/autoload/ale/ant.vim +++ b/autoload/ale/ant.vim @@ -1,4 +1,4 @@ -" Author: Andrew Lee <andrewl@mbda.fun>. +" Author: Andrew Lee <andrew.lambda@tuta.io>. " Inspired by ale/gradle.vim by Michael Pardo <michael@michaelpardo.com> " Description: Functions for working with Ant projects. diff --git a/autoload/ale/assert.vim b/autoload/ale/assert.vim index dac5efb7..291edcee 100644 --- a/autoload/ale/assert.vim +++ b/autoload/ale/assert.vim @@ -267,14 +267,22 @@ function! ale#assert#TearDownLinterTest() abort endif endfunction -function! ale#assert#SetUpFixerTest(filetype, name) abort +function! ale#assert#SetUpFixerTest(filetype, name, ...) abort + " If the suffix of the option names format is different, an additional + " argument can be used for that instead. + if a:0 > 1 + throw 'Too many arguments' + endif + " Set up a marker so ALE doesn't create real random temporary filenames. let g:ale_create_dummy_temporary_file = 1 let l:function_name = ale#fix#registry#GetFunc(a:name) let s:FixerFunction = function(l:function_name) - let l:prefix = 'ale_' . a:filetype . '_' . a:name + let l:option_suffix = get(a:000, 0, a:name) + let l:prefix = 'ale_' . a:filetype . '_' + \ . substitute(l:option_suffix, '-', '_', 'g') let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' for l:key in filter(keys(g:), b:filter_expr) @@ -286,7 +294,7 @@ function! ale#assert#SetUpFixerTest(filetype, name) abort unlet b:[l:key] endfor - execute 'runtime autoload/ale/fixers/' . a:name . '.vim' + execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim' if !exists('g:dir') call ale#test#SetDirectory('/testplugin/test/fixers') diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index 005caf17..2b5756e4 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -1,5 +1,6 @@ " Author: w0rp <devw0rp@gmail.com> " 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 @@ -21,24 +22,101 @@ 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', +\ '<default>': 'v' +\ }) let s:LSP_INSERT_TEXT_FORMAT_PLAIN = 1 let s:LSP_INSERT_TEXT_FORMAT_SNIPPET = 2 @@ -183,6 +261,8 @@ function! s:ReplaceCompletionOptions() abort if &l:completeopt =~# 'preview' let &l:completeopt = 'menu,menuone,preview,noselect,noinsert' + elseif &l:completeopt =~# 'popup' + let &l:completeopt = 'menu,menuone,popup,noselect,noinsert' else let &l:completeopt = 'menu,menuone,noselect,noinsert' endif @@ -278,6 +358,27 @@ function! ale#completion#GetAllTriggers() abort return deepcopy(s:trigger_character_map) endfunction +function! ale#completion#GetCompletionKind(kind) abort + let l:lsp_symbol = get(g:ale_lsp_types, a:kind, '') + + if !empty(l:lsp_symbol) + return l:lsp_symbol + endif + + return get(g:ale_tsserver_types, a:kind, '') +endfunction + +function! ale#completion#GetCompletionSymbols(kind) abort + let l:kind = ale#completion#GetCompletionKind(a:kind) + let l:symbol = get(g:ale_completion_symbols, l:kind, '') + + if !empty(l:symbol) + return l:symbol + endif + + return get(g:ale_completion_symbols, '<default>', 'v') +endfunction + function! s:CompletionStillValid(request_id) abort let [l:line, l:column] = getpos('.')[1:2] @@ -287,7 +388,6 @@ function! s:CompletionStillValid(request_id) abort \&& 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' \) @@ -329,18 +429,10 @@ 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 let l:result = { \ 'word': l:suggestion.name, - \ 'kind': l:kind, + \ 'kind': ale#completion#GetCompletionSymbols(l:suggestion.kind), \ 'icase': 1, \ 'menu': join(l:displayParts, ''), \ 'dup': g:ale_completion_tsserver_autoimport, @@ -425,23 +517,6 @@ function! ale#completion#ParseLSPCompletions(response) abort continue endif - " See :help complete-items for Vim completion kinds - if !has_key(l:item, 'kind') - let l:kind = 'v' - elseif l:item.kind is s:LSP_COMPLETION_METHOD_KIND - let l:kind = 'm' - elseif l:item.kind is s:LSP_COMPLETION_CONSTRUCTOR_KIND - let l:kind = 'm' - elseif l:item.kind is s:LSP_COMPLETION_FUNCTION_KIND - let l:kind = 'f' - elseif l:item.kind is s:LSP_COMPLETION_CLASS_KIND - let l:kind = 'f' - elseif l:item.kind is s:LSP_COMPLETION_INTERFACE_KIND - let l:kind = 'f' - else - let l:kind = 'v' - endif - let l:doc = get(l:item, 'documentation', '') if type(l:doc) is v:t_dict && has_key(l:doc, 'value') @@ -450,7 +525,7 @@ function! ale#completion#ParseLSPCompletions(response) abort call add(l:results, { \ 'word': l:word, - \ 'kind': l:kind, + \ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')), \ 'icase': 1, \ 'menu': get(l:item, 'detail', ''), \ 'info': (type(l:doc) is v:t_string ? l:doc : ''), @@ -729,7 +804,9 @@ endfunction function! ale#completion#HandleUserData(completed_item) abort let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') - if l:source isnot# 'ale-automatic' && l:source isnot# 'ale-manual' && l:source isnot# 'ale-callback' + if l:source isnot# 'ale-automatic' + \&& l:source isnot# 'ale-manual' + \&& l:source isnot# 'ale-callback' return endif diff --git a/autoload/ale/definition.vim b/autoload/ale/definition.vim index 3915cac1..ffcd9d10 100644 --- a/autoload/ale/definition.vim +++ b/autoload/ale/definition.vim @@ -5,6 +5,7 @@ let s:go_to_definition_map = {} " Enable automatic updates of the tagstack let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1) +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') " Used to get the definition map in tests. function! ale#definition#GetMap() abort @@ -134,6 +135,10 @@ function! s:GoToLSPDefinition(linter, options, capability) abort endfunction function! ale#definition#GoTo(options) abort + if !get(g:, 'ale_ignore_2_7_warnings') && has_key(a:options, 'deprecated_command') + execute 'echom '':' . a:options.deprecated_command . ' is deprecated. Use `let g:ale_ignore_2_7_warnings = 1` to disable this message.''' + endif + for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) call s:GoToLSPDefinition(l:linter, a:options, 'definition') @@ -142,6 +147,10 @@ function! ale#definition#GoTo(options) abort endfunction function! ale#definition#GoToType(options) abort + if !get(g:, 'ale_ignore_2_7_warnings') && has_key(a:options, 'deprecated_command') + execute 'echom '':' . a:options.deprecated_command . ' is deprecated. Use `let g:ale_ignore_2_7_warnings = 1` to disable this message.''' + endif + for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) " TODO: handle typeDefinition for tsserver if supported by the @@ -154,3 +163,33 @@ function! ale#definition#GoToType(options) abort endif endfor endfunction + +function! ale#definition#GoToCommandHandler(command, ...) abort + let l:options = {} + + if len(a:000) > 0 + for l:option in a:000 + if l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' + endif + endfor + endif + + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + + if a:command is# 'type' + call ale#definition#GoToType(l:options) + else + call ale#definition#GoTo(l:options) + endif +endfunction diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 2a96a7d6..1b3ca1a8 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -54,6 +54,11 @@ let s:default_registry = { \ 'description': 'Apply elm-format to a file.', \ 'aliases': ['format'], \ }, +\ 'nimpretty': { +\ 'function': 'ale#fixers#nimpretty#Fix', +\ 'suggested_filetypes': ['nim'], +\ 'description': 'Apply nimpretty to a file.', +\ }, \ 'eslint': { \ 'function': 'ale#fixers#eslint#Fix', \ 'suggested_filetypes': ['javascript', 'typescript'], @@ -235,6 +240,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['haskell'], \ 'description': 'Refactor Haskell files with stylish-haskell.', \ }, +\ 'purty': { +\ 'function': 'ale#fixers#purty#Fix', +\ 'suggested_filetypes': ['purescript'], +\ 'description': 'Format PureScript files with purty.', +\ }, \ 'ocamlformat': { \ 'function': 'ale#fixers#ocamlformat#Fix', \ 'suggested_filetypes': ['ocaml'], @@ -350,6 +360,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['nix'], \ 'description': 'A formatter for Nix code', \ }, +\ 'html-beautify': { +\ 'function': 'ale#fixers#html_beautify#Fix', +\ 'suggested_filetypes': ['html', 'htmldjango'], +\ 'description': 'Fix HTML files with html-beautify.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/html_beautify.vim b/autoload/ale/fixers/html_beautify.vim new file mode 100644 index 00000000..236cb6ec --- /dev/null +++ b/autoload/ale/fixers/html_beautify.vim @@ -0,0 +1,21 @@ +" Author: WhyNotHugo <hugo@barrera.io> +" Description: Lint HTML files with html-beautify. +" +call ale#Set('html_beautify_executable', 'html-beautify') +call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('html_beautify_options', '') +call ale#Set('html_beautify_change_directory', 1) + +function! ale#fixers#html_beautify#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'html_beautify', + \ ['html-beautify'] + \) + + let l:options = ale#Var(a:buffer, 'html_beautify_options') + + return { + \ 'command': ale#Escape(l:executable). ' ' . l:options . ' -', + \} +endfunction diff --git a/autoload/ale/fixers/nimpretty.vim b/autoload/ale/fixers/nimpretty.vim new file mode 100644 index 00000000..fe2e7136 --- /dev/null +++ b/autoload/ale/fixers/nimpretty.vim @@ -0,0 +1,15 @@ +" Author: Nhan <hi@imnhan.com> +" 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/autoload/ale/fixers/purty.vim b/autoload/ale/fixers/purty.vim new file mode 100644 index 00000000..46d2cacd --- /dev/null +++ b/autoload/ale/fixers/purty.vim @@ -0,0 +1,22 @@ +" Author: iclanzan <sorin@iclanzan.com> +" 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/autoload/ale/fixers/standard.vim b/autoload/ale/fixers/standard.vim index 77712d40..cffa9f9d 100644 --- a/autoload/ale/fixers/standard.vim +++ b/autoload/ale/fixers/standard.vim @@ -7,6 +7,7 @@ call ale#Set('javascript_standard_options', '') function! ale#fixers#standard#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/.bin/standard', \]) @@ -14,7 +15,14 @@ endfunction function! ale#fixers#standard#Fix(buffer) abort let l:executable = ale#fixers#standard#GetExecutable(a:buffer) - let l:options = ale#Var(a:buffer, 'javascript_standard_options') + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:options_type = 'javascript_standard_options' + + if l:filetype =~# 'typescript' + let l:options_type = 'typescript_standard_options' + endif + + let l:options = ale#Var(a:buffer, l:options_type) return { \ 'command': ale#node#Executable(a:buffer, l:executable) diff --git a/autoload/ale/fixers/stylelint.vim b/autoload/ale/fixers/stylelint.vim index 6bfb2fde..6f4cf177 100644 --- a/autoload/ale/fixers/stylelint.vim +++ b/autoload/ale/fixers/stylelint.vim @@ -3,6 +3,7 @@ call ale#Set('stylelint_executable', 'stylelint') call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('stylelint_options', '') function! ale#fixers#stylelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'stylelint', [ @@ -13,10 +14,14 @@ endfunction function! ale#fixers#stylelint#Fix(buffer) abort let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'stylelint_options') return { - \ 'command': ale#node#Executable(a:buffer, l:executable) - \ . ' --fix %t', + \ 'command': ale#path#BufferCdString(a:buffer) + \ . ale#node#Executable(a:buffer, l:executable) + \ . ' %t' + \ . ale#Pad(l:options) + \ . ' --fix', \ 'read_temporary_file': 1, \} endfunction diff --git a/autoload/ale/fixers/styler.vim b/autoload/ale/fixers/styler.vim index 7ff3275c..1c7607bd 100644 --- a/autoload/ale/fixers/styler.vim +++ b/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/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim index 4d533ff2..156b939f 100644 --- a/autoload/ale/handlers/eslint.vim +++ b/autoload/ale/handlers/eslint.vim @@ -42,7 +42,18 @@ function! ale#handlers#eslint#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'javascript_eslint_options') - return ale#node#Executable(a:buffer, l:executable) + " ESLint 6 loads plugins/configs/parsers from the project root + " By default, the project root is simply the CWD of the running process. + " https://github.com/eslint/rfcs/blob/master/designs/2018-simplified-package-loading/README.md + " https://github.com/dense-analysis/ale/issues/2787 + " Identify project root from presence of node_modules dir. + " Note: If node_modules not present yet, can't load local deps anyway. + let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules') + let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : '' + let l:cd_command = !empty(l:project_dir) ? ale#path#CdString(l:project_dir) : '' + + return l:cd_command + \ . ale#node#Executable(a:buffer, l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -f json --stdin --stdin-filename %s' endfunction @@ -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/autoload/ale/highlight.vim b/autoload/ale/highlight.vim index 82ad57e0..473ad354 100644 --- a/autoload/ale/highlight.vim +++ b/autoload/ale/highlight.vim @@ -210,6 +210,12 @@ function! ale#highlight#SetHighlights(buffer, loclist) abort " Set the list in the buffer variable. call setbufvar(str2nr(a:buffer), 'ale_highlight_items', l:new_list) + let l:exclude_list = ale#Var(a:buffer, 'exclude_highlights') + + if !empty(l:exclude_list) + call filter(l:new_list, 'empty(ale#util#GetMatches(v:val.text, l:exclude_list))') + endif + " Update highlights for the current buffer, which may or may not " be the buffer we just set highlights for. call ale#highlight#UpdateHighlights() diff --git a/autoload/ale/hover.vim b/autoload/ale/hover.vim index 2af35aa4..8fdd288c 100644 --- a/autoload/ale/hover.vim +++ b/autoload/ale/hover.vim @@ -42,6 +42,11 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort \&& exists('*balloon_show') \&& ale#Var(l:options.buffer, 'set_balloons') call balloon_show(a:response.body.displayString) + 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 @@ -98,6 +103,11 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort \&& exists('*balloon_show') \&& ale#Var(l:options.buffer, 'set_balloons') call balloon_show(l:str) + elseif g:ale_hover_to_preview + call ale#preview#Show(split(l:str, "\n"), { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \}) else call ale#util#ShowMessage(l:str) endif diff --git a/autoload/ale/preview.vim b/autoload/ale/preview.vim index 6d58aca9..7902ec63 100644 --- a/autoload/ale/preview.vim +++ b/autoload/ale/preview.vim @@ -1,6 +1,14 @@ " Author: w0rp <devw0rp@gmail.com> " Description: Preview windows for showing whatever information in. +if !has_key(s:, 'last_selection_list') + let s:last_selection_list = [] +endif + +if !has_key(s:, 'last_selection_open_in') + let s:last_selection_open_in = 'current-buffer' +endif + " Open a preview window and show some lines in it. " A second argument can be passed as a Dictionary with options. They are... " @@ -67,9 +75,24 @@ function! ale#preview#ShowSelection(item_list, ...) abort call ale#preview#Show(l:lines, {'filetype': 'ale-preview-selection'}) let b:ale_preview_item_list = a:item_list + let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer') + + " Remove the last preview + let s:last_selection_list = b:ale_preview_item_list + let s:last_selection_open_in = b:ale_preview_item_open_in endfunction -function! s:Open(open_in_tab) abort +function! ale#preview#RepeatSelection() abort + if empty(s:last_selection_list) + return + endif + + call ale#preview#ShowSelection(s:last_selection_list, { + \ 'open_in': s:last_selection_open_in, + \}) +endfunction + +function! s:Open(open_in) abort let l:item_list = get(b:, 'ale_preview_item_list', []) let l:item = get(l:item_list, getpos('.')[1] - 1, {}) @@ -77,22 +100,20 @@ function! s:Open(open_in_tab) abort return endif - if !a:open_in_tab - :q! - endif + :q! call ale#util#Open( \ l:item.filename, \ l:item.line, \ l:item.column, - \ {'open_in_tab': a:open_in_tab}, + \ {'open_in': a:open_in}, \) endfunction -function! ale#preview#OpenSelectionInBuffer() abort - call s:Open(0) +function! ale#preview#OpenSelection() abort + call s:Open(b:ale_preview_item_open_in) endfunction function! ale#preview#OpenSelectionInTab() abort - call s:Open(1) + call s:Open('tab') endfunction diff --git a/autoload/ale/references.vim b/autoload/ale/references.vim index b9725e1e..38ff0d3d 100644 --- a/autoload/ale/references.vim +++ b/autoload/ale/references.vim @@ -1,3 +1,5 @@ +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') + let s:references_map = {} " Used to get the references map in tests. @@ -99,7 +101,8 @@ function! s:OnReady(line, column, options, linter, lsp_details) abort let l:request_id = ale#lsp#Send(l:id, l:message) let s:references_map[l:request_id] = { - \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0 + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0, + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), \} endfunction @@ -110,10 +113,24 @@ function! ale#references#Find(...) abort for l:option in a:000 if l:option is? '-relative' let l:options.use_relative_paths = 1 + elseif l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' endif endfor endif + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + let l:buffer = bufnr('') let [l:line, l:column] = getpos('.')[1:2] let l:column = min([l:column, len(getline(l:line))]) diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim index db0e1ab6..8109c60e 100644 --- a/autoload/ale/sign.vim +++ b/autoload/ale/sign.vim @@ -23,7 +23,7 @@ let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0) -let s:supports_sign_groups = has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) +let s:supports_sign_groups = has('nvim-0.4.2') || has('patch-8.1.614') if !hlexists('ALEErrorSign') highlight link ALEErrorSign error diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim index b7594167..ee62af28 100644 --- a/autoload/ale/util.vim +++ b/autoload/ale/util.vim @@ -91,17 +91,17 @@ endfunction " options['open_in'] can be: " current-buffer (default) " tab -" vertical-split -" horizontal-split +" split +" vsplit function! ale#util#Open(filename, line, column, options) abort let l:open_in = get(a:options, 'open_in', 'current-buffer') let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename) if l:open_in is# 'tab' call ale#util#Execute('tabedit ' . l:args_to_open) - elseif l:open_in is# 'horizontal-split' + elseif l:open_in is# 'split' call ale#util#Execute('split ' . l:args_to_open) - elseif l:open_in is# 'vertical-split' + elseif l:open_in is# 'vsplit' call ale#util#Execute('vsplit ' . l:args_to_open) elseif bufnr(a:filename) isnot bufnr('') " Open another file only if we need to. @@ -336,15 +336,11 @@ function! ale#util#GetMatches(lines, patterns) abort endfunction function! s:LoadArgCount(function) abort - let l:Function = a:function - - redir => l:output - silent! function Function - redir END - - if !exists('l:output') + try + let l:output = execute('function a:function') + catch /E123/ return 0 - endif + endtry let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2] let l:arg_list = filter(split(l:match, ', '), 'v:val isnot# ''...''') diff --git a/doc/ale-html.txt b/doc/ale-html.txt index 5d6b20e2..c78dc4cd 100644 --- a/doc/ale-html.txt +++ b/doc/ale-html.txt @@ -9,6 +9,16 @@ fecs *ale-html-fecs* and both of them reads `./.fecsrc` as the default configuration file. See: |ale-javascript-fecs|. +=============================================================================== +html-beautify *ale-html-beautify* + +g:ale_html_beautify_options *g:ale_html_beautify_options* + *b:ale_html_beautify_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to html-beautify. + =============================================================================== htmlhint *ale-html-htmlhint* diff --git a/doc/ale-nim.txt b/doc/ale-nim.txt index ad7aa686..8985aeb8 100644 --- a/doc/ale-nim.txt +++ b/doc/ale-nim.txt @@ -22,4 +22,24 @@ g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources* =============================================================================== +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/doc/ale-php.txt b/doc/ale-php.txt index e17e1023..645decd7 100644 --- a/doc/ale-php.txt +++ b/doc/ale-php.txt @@ -189,6 +189,13 @@ g:ale_php_psalm_executable *g:ale_php_psalm_executable* This variable sets the executable used for psalm. +g:ale_psalm_langserver_options *g:ale_psalm_langserver_options* + *b:ale_psalm_langserver_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to psalm. + =============================================================================== php-cs-fixer *ale-php-php-cs-fixer* diff --git a/doc/ale-purescript.txt b/doc/ale-purescript.txt index 33fd2429..e809f2c9 100644 --- a/doc/ale-purescript.txt +++ b/doc/ale-purescript.txt @@ -30,4 +30,13 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config \ } \} =============================================================================== +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/doc/ale-python.txt b/doc/ale-python.txt index 9d5846d2..93f1d668 100644 --- a/doc/ale-python.txt +++ b/doc/ale-python.txt @@ -145,8 +145,8 @@ 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` @@ -263,6 +263,15 @@ 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_executable *g:ale_python_mypy_executable* *b:ale_python_mypy_executable* Type: |String| @@ -272,6 +281,7 @@ g:ale_python_mypy_executable *g:ale_python_mypy_executable* Set this to `'pipenv'` to invoke `'pipenv` `run` `mypy'`. + g:ale_python_mypy_ignore_invalid_syntax *g:ale_python_mypy_ignore_invalid_syntax* *b:ale_python_mypy_ignore_invalid_syntax* @@ -292,6 +302,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,14 +318,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* diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index e2379b70..29dabab7 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -194,6 +194,7 @@ Notes: * HTML * `alex`!! * `fecs` + * `html-beautify` * `HTMLHint` * `prettier` * `proselint` @@ -283,6 +284,7 @@ Notes: * Nim * `nim check`!! * `nimlsp` + * `nimpretty` * nix * `nix-instantiate` * `nixpkgs-fmt` @@ -348,6 +350,7 @@ Notes: * `puppet-lint` * PureScript * `purescript-language-server` + * `purty` * Python * `autopep8` * `bandit` @@ -466,6 +469,7 @@ Notes: * `eslint` * `fecs` * `prettier` + * `standard` * `tslint` * `tsserver` * `typecheck` diff --git a/doc/ale-typescript.txt b/doc/ale-typescript.txt index 7dc59820..2c50d119 100644 --- a/doc/ale-typescript.txt +++ b/doc/ale-typescript.txt @@ -17,6 +17,33 @@ 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* This linter isn't recommended, because TSLint can't be used for checking for diff --git a/doc/ale.txt b/doc/ale.txt index 291e90fb..469fa106 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -433,17 +433,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', + \ '<default>': '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`. @@ -453,15 +490,10 @@ set to `0`. ALE supports jumping to the files and locations where symbols' types are defined through any enabled LSP linters. The locations ALE will jump to depend -on the information returned by LSP servers. The following commands are -supported: - -|ALEGoToTypeDefinition| - Open the definition of the symbol's type under - the cursor. -|ALEGoToTypeDefinitionInTab| - The same, but for opening the file in a new tab. -|ALEGoToTypeDefinitionInSplit| - The same, but in a new split. -|ALEGoToTypeDefinitionInVSplit| - The same, but in a new vertical split. - +on the information returned by LSP servers. The |ALEGoToTypeDefinition| +command will jump to the definition of symbols under the cursor. See the +documentation for the command for configuring how the location will be +displayed. ------------------------------------------------------------------------------- 5.4 Find References *ale-find-references* @@ -490,6 +522,9 @@ 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`. + 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 @@ -623,7 +658,7 @@ g:ale_completion_delay *g:ale_completion_delay* g:ale_completion_enabled *g:ale_completion_enabled* -b:ale_completion_enabled *b:ale_completion_enabled* + *b:ale_completion_enabled* Type: |Number| Default: `0` @@ -671,6 +706,47 @@ g:ale_completion_excluded_words *g:ale_completion_excluded_words* let b:ale_completion_excluded_words = ['it', 'describe'] < +g:ale_completion_symbols *g:ale_completion_symbols* + + Type: |Dictionary| + + + A mapping from completion types to symbols for completions. See + |ale-symbols| for more information. + + By default, this mapping only uses built in Vim completion kinds, but it can + be updated to use any unicode character for the completion kind. For + example: > + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'v', + \ 'value': 'v', + \ 'enum': 't', + \ 'keyword': 'v', + \ 'snippet': 'v', + \ 'color': 'v', + \ 'file': 'v', + \ 'reference': 'v', + \ 'folder': 'v', + \ 'enum_member': 'm', + \ 'constant': 'm', + \ 'struct': 't', + \ 'event': 'v', + \ 'operator': 'f', + \ 'type_parameter': 'p', + \ '<default>': 'v' + \ }) +< + g:ale_completion_max_suggestions *g:ale_completion_max_suggestions* Type: |Number| @@ -709,6 +785,16 @@ g:ale_cursor_detail *g:ale_cursor_detail* loaded for messages to be displayed. See |ale-lint-settings-on-startup|. +g:ale_default_navigation *g:ale_default_navigation* + *b:ale_default_navigation* + + Type: |String| + Default: `'buffer'` + + The default method for navigating away from the current buffer to another + buffer, such as for |ALEFindReferences:|, or |ALEGoToDefinition|. + + g:ale_disable_lsp *g:ale_disable_lsp* *b:ale_disable_lsp* @@ -761,7 +847,7 @@ g:ale_echo_msg_error_str *g:ale_echo_msg_error_str* g:ale_echo_msg_format *g:ale_echo_msg_format* -b:ale_echo_msg_format *b:ale_echo_msg_format* + *b:ale_echo_msg_format* Type: |String| Default: `'%code: %%s'` @@ -839,6 +925,21 @@ g:ale_enabled *g:ale_enabled* See |g:ale_pattern_options| for more information on that option. +g:ale_exclude_highlights *g:ale_exclude_highlights* + *b:ale_exclude_highlights* + + Type: |List| + Default: `[]` + + A list of regular expressions for matching against highlight messages to + remove. For example: > + + " Do not highlight messages matching strings like these. + let b:ale_exclude_highlights = ['line too long', 'foo.*bar'] +< + See also: |g:ale_set_highlights| + + g:ale_fixers *g:ale_fixers* *b:ale_fixers* @@ -862,7 +963,7 @@ g:ale_fixers *g:ale_fixers* < g:ale_fix_on_save *g:ale_fix_on_save* -b:ale_fix_on_save *b:ale_fix_on_save* + *b:ale_fix_on_save* Type: |Number| Default: `0` @@ -884,7 +985,7 @@ b:ale_fix_on_save *b:ale_fix_on_save* g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore* -b:ale_fix_on_save_ignore *b:ale_fix_on_save_ignore* + *b:ale_fix_on_save_ignore* Type: |Dictionary| or |List| Default: `{}` @@ -947,6 +1048,16 @@ g:ale_history_log_output *g:ale_history_log_output* if you want to save on some memory usage. +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_keep_list_window_open *g:ale_keep_list_window_open* *b:ale_keep_list_window_open* Type: |Number| @@ -1250,7 +1361,7 @@ g:ale_list_vertical *g:ale_list_vertical* g:ale_loclist_msg_format *g:ale_loclist_msg_format* -b:ale_loclist_msg_format *b:ale_loclist_msg_format* + *b:ale_loclist_msg_format* Type: |String| Default: `g:ale_echo_msg_format` @@ -1261,7 +1372,7 @@ b:ale_loclist_msg_format *b:ale_loclist_msg_format* The strings for configuring `%severity%` are also used for this option. -g:ale_lsp_show_message_format *g:ale_lsp_show_message_format* +g:ale_lsp_show_message_format *g:ale_lsp_show_message_format* Type: |String| Default: `'%severity%:%linter%: %s'` @@ -1283,7 +1394,7 @@ g:ale_lsp_show_message_format *g:ale_lsp_show_message_ separately for each buffer like |g:ale_echo_msg_format| can. -g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* +g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* Type: |String| Default: `'error'` @@ -1302,7 +1413,7 @@ g:ale_lsp_show_message_severity *g:ale_lsp_show_message_ g:ale_lsp_root *g:ale_lsp_root* -b:ale_lsp_root *b:ale_lsp_root* + *b:ale_lsp_root* Type: |Dictionary| or |String| Default: {} @@ -1515,6 +1626,8 @@ g:ale_set_highlights *g:ale_set_highlights* match highlights, whereas the line highlights when signs are enabled will run to the edge of the screen. + Highlights can be excluded with the |g:ale_exclude_highlights| option. + g:ale_set_loclist *g:ale_set_loclist* @@ -1781,7 +1894,8 @@ g:ale_virtualtext_cursor *g:ale_virtualtext_cursor* g:ale_virtualtext_delay *g:ale_virtualtext_delay* -b:ale_virtualtext_delay *b:ale_virtualtext_delay* + *b:ale_virtualtext_delay* + Type: |Number| Default: `10` @@ -1800,7 +1914,7 @@ g:ale_virtualtext_prefix *g:ale_virtualtext_prefix* Prefix to be used with |g:ale_virtualtext_cursor|. g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names* -b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* + *b:ale_virtualenv_dir_names* Type: |List| Default: `['.env', '.venv', 'env', 've-py3', 've', 'virtualenv', 'venv']` @@ -1814,7 +1928,7 @@ b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* g:ale_warn_about_trailing_blank_lines *g:ale_warn_about_trailing_blank_lines* -b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines* + *b:ale_warn_about_trailing_blank_lines* Type: |Number| Default: `1` @@ -1826,7 +1940,7 @@ b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines* g:ale_warn_about_trailing_whitespace *g:ale_warn_about_trailing_whitespace* -b:ale_warn_about_trailing_whitespace *b:ale_warn_about_trailing_whitespace* + *b:ale_warn_about_trailing_whitespace* Type: |Number| Default: `1` @@ -2293,6 +2407,7 @@ documented in additional help files. terraform-fmt.........................|ale-hcl-terraform-fmt| html....................................|ale-html-options| fecs..................................|ale-html-fecs| + html-beautify.........................|ale-html-beautify| htmlhint..............................|ale-html-htmlhint| tidy..................................|ale-html-tidy| prettier..............................|ale-html-prettier| @@ -2360,6 +2475,7 @@ documented in additional help files. nim.....................................|ale-nim-options| nimcheck..............................|ale-nim-nimcheck| nimlsp................................|ale-nim-nimlsp| + nimpretty.............................|ale-nim-nimpretty| nix.....................................|ale-nix-options| nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt| nroff...................................|ale-nroff-options| @@ -2417,6 +2533,7 @@ documented in additional help files. puppet-languageserver.................|ale-puppet-languageserver| purescript..............................|ale-purescript-options| purescript-language-server............|ale-purescript-language-server| + purty.................................|ale-purescript-purty| pyrex (cython)..........................|ale-pyrex-options| cython................................|ale-pyrex-cython| python..................................|ale-python-options| @@ -2522,6 +2639,7 @@ documented in additional help files. typescript..............................|ale-typescript-options| eslint................................|ale-typescript-eslint| prettier..............................|ale-typescript-prettier| + standard..............................|ale-typescript-standard| tslint................................|ale-typescript-tslint| tsserver..............................|ale-typescript-tsserver| vala....................................|ale-vala-options| @@ -2589,11 +2707,23 @@ ALEFindReferences *ALEFindReferences* Enter key (`<CR>`) can be used to jump to a referencing location, or the `t` key can be used to jump to the location in a new tab. + The locations opened in different ways using the following variations. + + `:ALEFindReferences -tab` - Open the location in a new tab. + `:ALEFindReferences -split` - Open the location in a horizontal split. + `:ALEFindReferences -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + The selection can be opened again with the |ALERepeatSelection| command. + You can jump back to the position you were at before going to a reference of something with jump motions like CTRL-O. See |jump-motions|. A plug mapping `<Plug>(ale_find_references)` is defined for this command. + ALEFix *ALEFix* Fix problems with the current buffer. See |ale-fix| for more information. @@ -2608,40 +2738,29 @@ ALEFixSuggest *ALEFixSuggest* 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. - 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 `<Plug>(ale_go_to_definition)` is defined for this command. - - -ALEGoToDefinitionInTab *ALEGoToDefinitionInTab* - - The same as |ALEGoToDefinition|, but opens results in a new tab. + The locations opened in different ways using the following variations. - A plug mapping `<Plug>(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 `<Plug>(ale_go_to_definition_in_split)` is defined for this - command. + `: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|. -ALEGoToDefinitionInVSplit *ALEGoToDefinitionInVSplit* + 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 same as |ALEGoToDefinition|, but opens results in a new vertical split. + You should consider using the 'hidden' option in combination with this + command. Otherwise, Vim will refuse to leave the buffer you're jumping from + unless you have saved your edits. - A plug mapping `<Plug>(ale_go_to_definition_in_vsplit)` is defined for this - command. + A plug mapping `<Plug>(ale_go_to_definition)` is defined for this command. ALEGoToTypeDefinition *ALEGoToTypeDefinition* @@ -2651,6 +2770,15 @@ ALEGoToTypeDefinition *ALEGoToTypeDefinition* definition if an LSP server provides a location to jump to. Otherwise, ALE will do nothing. + The locations opened in different ways using the following variations. + + `:ALEGoToTypeDefinition -tab` - Open the location in a new tab. + `:ALEGoToTypeDefinition -split` - Open the location in a horizontal split. + `:ALEGoToTypeDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + You can jump back to the position you were at before going to the definition of something with jump motions like CTRL-O. See |jump-motions|. @@ -2658,31 +2786,6 @@ ALEGoToTypeDefinition *ALEGoToTypeDefinition* command. -ALEGoToTypeDefinitionInTab *ALEGoToTypeDefinitionInTab* - - The same as |ALEGoToTypeDefinition|, but opens results in a new tab. - - A plug mapping `<Plug>(ale_go_to_type_definition_in_tab)` is defined for - this command. - - -ALEGoToTypeDefinitionInSplit *ALEGoToTypeDefinitionInSplit* - - The same as |ALEGoToTypeDefinition|, but opens results in a new split. - - A plug mapping `<Plug>(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 `<Plug>(ale_go_to_type_definition_in_vsplit)` is defined for - this command. - - ALEHover *ALEHover* Print brief information about the symbol under the cursor, taken from any @@ -2708,6 +2811,11 @@ ALERename *ALERename* The user will be prompted for a new name. +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. @@ -3016,7 +3124,6 @@ ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()* 'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))} < - The following `options` can be provided. `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for diff --git a/ftplugin/ale-preview-selection.vim b/ftplugin/ale-preview-selection.vim index d77b4f98..7ec84068 100644 --- a/ftplugin/ale-preview-selection.vim +++ b/ftplugin/ale-preview-selection.vim @@ -12,5 +12,5 @@ noremap <buffer> A <NOP> noremap <buffer> o <NOP> noremap <buffer> O <NOP> " Keybinds for opening selection items. -noremap <buffer> <CR> :call ale#preview#OpenSelectionInBuffer()<CR> +noremap <buffer> <CR> :call ale#preview#OpenSelection()<CR> noremap <buffer> t :call ale#preview#OpenSelectionInTab()<CR> diff --git a/plugin/ale.vim b/plugin/ale.vim index 1912a9c0..e1ddf7b7 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -109,6 +109,9 @@ let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs')) " This flag can be set to 0 to disable setting error highlights. let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax')) +" This List can be configured to exclude particular highlights. +let g:ale_exclude_highlights = get(g:, 'ale_exclude_highlights', []) + " This flag can be set to 0 to disable echoing when the cursor moves. let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1) @@ -125,6 +128,9 @@ 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) + " 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 @@ -196,16 +202,23 @@ command! -bar -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEF command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype) " Go to definition for tsserver and LSP -command! -bar ALEGoToDefinition :call ale#definition#GoTo({}) -command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab'}) -command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'horizontal-split'}) -command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vertical-split'}) +command! -bar -nargs=* ALEGoToDefinition :call ale#definition#GoToCommandHandler('', <f-args>) + +" Deprecated commands we have to keep for now. +command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab', 'deprecated_command': 'ALEGoToDefinitionInTab'}) +command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'split', 'deprecated_command': 'ALEGoToDefinitionInSplit'}) +command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vsplit', 'deprecated_command': 'ALEGoToDefinitionInVSplit'}) " Go to type definition for tsserver and LSP -command! -bar ALEGoToTypeDefinition :call ale#definition#GoToType({}) -command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab'}) -command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'horizontal-split'}) -command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vertical-split'}) +command! -bar -nargs=* ALEGoToTypeDefinition :call ale#definition#GoToCommandHandler('type', <f-args>) + +" Deprecated commands we have to keep for now. +command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab', 'deprecated_command': 'ALEGoToTypeDefinitionInTab'}) +command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'split', 'deprecated_command': 'ALEGoToTypeDefinitionInSplit'}) +command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vsplit', 'deprecated_command': 'ALEGoToTypeDefinitionInVSplit'}) + +" Repeat a previous selection in the preview window +command! -bar ALERepeatSelection :call ale#preview#RepeatSelection() " Find references for tsserver and LSP command! -bar -nargs=* ALEFindReferences :call ale#references#Find(<f-args>) @@ -254,18 +267,21 @@ nnoremap <silent> <Plug>(ale_lint) :ALELint<Return> nnoremap <silent> <Plug>(ale_detail) :ALEDetail<Return> nnoremap <silent> <Plug>(ale_fix) :ALEFix<Return> nnoremap <silent> <Plug>(ale_go_to_definition) :ALEGoToDefinition<Return> -nnoremap <silent> <Plug>(ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab<Return> -nnoremap <silent> <Plug>(ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit<Return> -nnoremap <silent> <Plug>(ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit<Return> nnoremap <silent> <Plug>(ale_go_to_type_definition) :ALEGoToTypeDefinition<Return> -nnoremap <silent> <Plug>(ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab<Return> -nnoremap <silent> <Plug>(ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit<Return> -nnoremap <silent> <Plug>(ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit<Return> nnoremap <silent> <Plug>(ale_find_references) :ALEFindReferences<Return> nnoremap <silent> <Plug>(ale_hover) :ALEHover<Return> nnoremap <silent> <Plug>(ale_documentation) :ALEDocumentation<Return> inoremap <silent> <Plug>(ale_complete) <C-\><C-O>:ALEComplete<Return> nnoremap <silent> <Plug>(ale_rename) :ALERename<Return> +nnoremap <silent> <Plug>(ale_repeat_selection) :ALERepeatSelection<Return> + +" Deprecated <Plug> mappings +nnoremap <silent> <Plug>(ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab<Return> +nnoremap <silent> <Plug>(ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit<Return> +nnoremap <silent> <Plug>(ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit<Return> +nnoremap <silent> <Plug>(ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab<Return> +nnoremap <silent> <Plug>(ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit<Return> +nnoremap <silent> <Plug>(ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit<Return> " Set up autocmd groups now. call ale#events#Init() diff --git a/rplugin/python3/deoplete/sources/ale.py b/rplugin/python3/deoplete/sources/ale.py index 3955ed2d..ae1f4039 100644 --- a/rplugin/python3/deoplete/sources/ale.py +++ b/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 = { @@ -44,21 +45,16 @@ 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') + return result or [] - if result is not None: - context['is_async'] = False - - 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/supported-tools.md b/supported-tools.md index c302d38c..0abc6b75 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -203,6 +203,7 @@ formatting. * HTML * [alex](https://github.com/wooorm/alex) :floppy_disk: * [fecs](http://fecs.baidu.com/) + * [html-beautify](https://beautifier.io/) * [HTMLHint](http://htmlhint.com/) * [prettier](https://github.com/prettier/prettier) * [proselint](http://proselint.com/) @@ -292,6 +293,7 @@ formatting. * Nim * [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk: * [nimlsp](https://github.com/PMunch/nimlsp) + * nimpretty * nix * [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) * [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) @@ -357,6 +359,7 @@ formatting. * [puppet-lint](https://puppet-lint.com) * PureScript * [purescript-language-server](https://github.com/nwolverson/purescript-language-server) + * [purty](https://gitlab.com/joneshf/purty) * Python * [autopep8](https://github.com/hhatto/autopep8) * [bandit](https://github.com/PyCQA/bandit) :warning: @@ -475,6 +478,7 @@ formatting. * [eslint](http://eslint.org/) * [fecs](http://fecs.baidu.com/) * [prettier](https://github.com/prettier/prettier) + * [standard](http://standardjs.com/) * [tslint](https://github.com/palantir/tslint) * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) * typecheck diff --git a/test/command_callback/html_beautify_paths/html-beautify b/test/command_callback/html_beautify_paths/html-beautify new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/html_beautify_paths/html-beautify diff --git a/test/command_callback/html_beautify_paths/test.html b/test/command_callback/html_beautify_paths/test.html new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/html_beautify_paths/test.html diff --git a/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/mypy.ini b/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/mypy.ini new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/mypy.ini diff --git a/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/tests/pytest.ini b/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/tests/pytest.ini new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/tests/pytest.ini diff --git a/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/tests/testsubfolder/my_tests.py b/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/tests/testsubfolder/my_tests.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_mypy_ini_and_pytest_ini/tests/testsubfolder/my_tests.py diff --git a/test/command_callback/test_c_clangd_command_callbacks.vader b/test/command_callback/test_c_clangd_command_callbacks.vader index 555122f6..753dc9a8 100644 --- a/test/command_callback/test_c_clangd_command_callbacks.vader +++ b/test/command_callback/test_c_clangd_command_callbacks.vader @@ -9,18 +9,14 @@ Before: Save b:ale_c_build_dir_names Save b:ale_c_parse_compile_commands - let b:command_tail = ' -x c' - After: - unlet! b:command_tail - call ale#assert#TearDownLinterTest() Execute(The language string should be correct): AssertLSPLanguage 'c' Execute(The default executable should be correct): - AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail + AssertLinter 'clangd', ale#Escape('clangd') Execute(The project root should be detected correctly): call ale#test#SetFilename(tempname() . '/dummy.c') @@ -34,12 +30,12 @@ Execute(The project root should be detected correctly): Execute(The executable should be configurable): let g:ale_c_clangd_executable = 'foobar' - AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail + AssertLinter 'foobar', ale#Escape('foobar') Execute(The options should be configurable): let b:ale_c_clangd_options = '-compile-commands-dir=foo' - AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail . ' ' . b:ale_c_clangd_options + AssertLinter 'clangd', ale#Escape('clangd') . ' ' . b:ale_c_clangd_options Execute(The compile command database should be detected correctly): call ale#test#SetFilename('clangd_paths/with_build_dir/dummy_src/dummy.c') @@ -49,7 +45,7 @@ Execute(The compile command database should be detected correctly): let b:ale_c_build_dir_names = ['unusual_build_dir_name'] let b:ale_c_parse_compile_commands = 1 - AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail + AssertLinter 'clangd', ale#Escape('clangd') \ . ' -compile-commands-dir=' \ . ale#Escape(ale#path#Simplify(g:dir . '/clangd_paths/with_build_dir/unusual_build_dir_name')) diff --git a/test/command_callback/test_cpp_clangcheck_command_callbacks.vader b/test/command_callback/test_cpp_clangcheck_command_callbacks.vader index 7aa09eed..188141d5 100644 --- a/test/command_callback/test_cpp_clangcheck_command_callbacks.vader +++ b/test/command_callback/test_cpp_clangcheck_command_callbacks.vader @@ -7,7 +7,7 @@ After: Execute(The executable should be configurable): AssertLinter 'clang-check', \ ale#Escape('clang-check') - \ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text' + \ . ' -analyze %s --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics' let b:ale_cpp_clangcheck_executable = 'foobar' @@ -15,7 +15,7 @@ Execute(The executable should be configurable): " being generated. AssertLinter 'foobar', \ ale#Escape('foobar') - \ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text' + \ . ' -analyze %s --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics' Execute(The options should be configurable): let b:ale_cpp_clangcheck_options = '--something' @@ -23,7 +23,7 @@ Execute(The options should be configurable): AssertLinter 'clang-check', \ ale#Escape('clang-check') \ . ' -analyze %s' - \ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text' + \ . ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics' \ . ' --something' Execute(The build directory should be used when set): diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader index 8ca35207..afa9f9af 100644 --- a/test/command_callback/test_mypy_command_callback.vader +++ b/test/command_callback/test_mypy_command_callback.vader @@ -52,6 +52,15 @@ Execute(The mypy callbacks should detect virtualenv directories and switch to th \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s' +Execute(The mypy callbacks should cd to directory containing mypy.ini if found): + silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_mypy_ini_and_pytest_ini/tests/testsubfolder/my_tests.py') + + AssertLinter 'mypy', + \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_mypy_ini_and_pytest_ini')) + \ . ale#Escape('mypy') + \ . ' --show-column-numbers ' + \ . '--shadow-file %s %t %s' + Execute(You should able able to use the global mypy instead): silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') let g:ale_python_mypy_use_global = 1 diff --git a/test/command_callback/test_psalm_command_callbacks.vader b/test/command_callback/test_psalm_command_callbacks.vader index 74c68d43..70b5af95 100644 --- a/test/command_callback/test_psalm_command_callbacks.vader +++ b/test/command_callback/test_psalm_command_callbacks.vader @@ -22,6 +22,14 @@ Execute(Vendor executables should be detected): \ . '/psalm-project/vendor/bin/psalm' \ )) . ' --language-server' +Execute(User provided options should be used): + let g:ale_psalm_langserver_options = '--my-user-provided-option my-value' + + AssertLinter 'psalm', + \ ale#Escape('psalm') + \ . ' --language-server --my-user-provided-option my-value' + + Execute(The project path should be correct for .git directories): call ale#test#SetFilename('psalm-project/test.php') diff --git a/test/command_callback/test_standardts_command_callback.vader b/test/command_callback/test_standardts_command_callback.vader new file mode 100644 index 00000000..d769e712 --- /dev/null +++ b/test/command_callback/test_standardts_command_callback.vader @@ -0,0 +1,43 @@ +Before: + call ale#assert#SetUpLinterTest('typescript', 'standard') + call ale#test#SetFilename('testfile.js') + unlet! b:executable + +After: + call ale#assert#TearDownLinterTest() + +Execute(bin/cmd.js paths should be preferred): + call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' + \) + + AssertLinter b:executable, + \ (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(b:executable) + \ . ' --stdin %s' + +Execute(.bin directories should be used too): + call ale#test#SetFilename('standard-test-files/with-bin/testfile.js') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/standard-test-files/with-bin/node_modules/.bin/standard' + \) + + AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin %s' + +Execute(The global executable should be used otherwise): + AssertLinter 'standard', ale#Escape('standard') . ' --stdin %s' + +Execute(The global executable should be configurable): + let b:ale_typescript_standard_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin %s' + +Execute(The options should be configurable): + let b:ale_typescript_standard_options = '--wat' + + AssertLinter 'standard', ale#Escape('standard') . ' --wat --stdin %s' diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index 90a2e3a2..3a7a31d0 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -234,7 +234,7 @@ Execute(ale#completion#Show() should make the correct feedkeys() call for manual AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls Execute(ale#completion#Show() should not call feedkeys() for other sources): - let b:ale_completion_info = {'source': 'deoplete'} + let b:ale_completion_info = {'source': 'other-source'} call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) sleep 1ms @@ -335,7 +335,7 @@ Execute(b:ale_completion_info should be set up correctly when requesting complet Execute(b:ale_completion_info should be set up correctly for other sources): let b:ale_completion_result = [] call setpos('.', [bufnr(''), 3, 14, 0]) - call ale#completion#GetCompletions('deoplete') + call ale#completion#GetCompletions('ale-callback') AssertEqual \ { @@ -345,7 +345,7 @@ Execute(b:ale_completion_info should be set up correctly for other sources): \ 'line_length': 14, \ 'line': 3, \ 'prefix': 'ab', - \ 'source': 'deoplete', + \ 'source': 'ale-callback', \ }, \ b:ale_completion_info Assert !exists('b:ale_completion_result') diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader index ef954564..1fdbbd96 100644 --- a/test/completion/test_lsp_completion_parsing.vader +++ b/test/completion/test_lsp_completion_parsing.vader @@ -17,17 +17,17 @@ Execute(Should handle Rust completion results correctly): \ {'word': 'from_iter', 'menu': 'fn from_iter<I: IntoIterator<Item = &''a str>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1}, \ {'word': 'from_iter', 'menu': 'fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1}, \ {'word': 'from_iter', 'menu': 'fn from_iter<I: IntoIterator<Item = Cow<''a, str>>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Searcher', 'menu': 'type Searcher = <&''b str as Pattern<''a>>::Searcher;', 'info': '', 'kind': 'f', 'icase': 1}, + \ {'word': 'Searcher', 'menu': 'type Searcher = <&''b str as Pattern<''a>>::Searcher;', 'info': '', 'kind': 't', 'icase': 1}, \ {'word': 'default', 'menu': 'fn default() -> String', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = String;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Target', 'menu': 'type Target = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Err', 'menu': 'type Err = ParseError;', 'info': '', 'kind': 'f', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = String;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Target', 'menu': 'type Target = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Err', 'menu': 'type Err = ParseError;', 'info': '', 'kind': 't', 'icase': 1}, \ {'word': 'from_str', 'menu': 'fn from_str(s: &str) -> Result<String, ParseError>', 'info': '', 'kind': 'f', 'icase': 1}, \ {'word': 'from', 'menu': 'fn from(s: &''a str) -> String', 'info': '', 'kind': 'f', 'icase': 1}, \ {'word': 'from', 'menu': 'fn from(s: Box<str>) -> String', 'info': '', 'kind': 'f', 'icase': 1}, diff --git a/test/completion/test_tsserver_completion_parsing.vader b/test/completion/test_tsserver_completion_parsing.vader index dbb8de32..6beb7b0a 100644 --- a/test/completion/test_tsserver_completion_parsing.vader +++ b/test/completion/test_tsserver_completion_parsing.vader @@ -36,7 +36,7 @@ Execute(TypeScript completion details responses should be parsed correctly): \ 'word': 'abc', \ 'menu': '(property) Foo.abc: number', \ 'info': '', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'dup': g:ale_completion_tsserver_autoimport, \ }, @@ -44,7 +44,7 @@ Execute(TypeScript completion details responses should be parsed correctly): \ 'word': 'def', \ 'menu': '(property) Foo.def: number', \ 'info': 'foo bar baz', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'dup': g:ale_completion_tsserver_autoimport, \ }, @@ -52,7 +52,7 @@ Execute(TypeScript completion details responses should be parsed correctly): \ 'word': 'ghi', \ 'menu': '(class) Foo', \ 'info': '', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'dup': g:ale_completion_tsserver_autoimport, \ }, @@ -124,7 +124,7 @@ Execute(Entries without details should be included in the responses): \ 'word': 'abc', \ 'menu': 'import { def } from "./Foo"; (property) Foo.abc: number', \ 'info': '', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'user_data': json_encode({ \ 'codeActions': [{ @@ -138,7 +138,7 @@ Execute(Entries without details should be included in the responses): \ 'word': 'def', \ 'menu': '(property) Foo.def: number', \ 'info': 'foo bar baz', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'dup': g:ale_completion_tsserver_autoimport, \ }, diff --git a/test/fixers/test_html_beautify_fixer_callback.vader b/test/fixers/test_html_beautify_fixer_callback.vader new file mode 100644 index 00000000..372572e4 --- /dev/null +++ b/test/fixers/test_html_beautify_fixer_callback.vader @@ -0,0 +1,16 @@ +Before: + call ale#assert#SetUpFixerTest('html', 'html-beautify', 'beautify') + + call ale#test#SetDirectory('/testplugin/test/fixers') + silent cd .. + silent cd command_callback + +After: + Restore + + call ale#assert#TearDownFixerTest() + +Execute(The html-beautify callback should return the correct default command): + AssertEqual + \ {'command': ale#Escape('html-beautify') . ' -'}, + \ ale#fixers#html_beautify#Fix(bufnr('')) diff --git a/test/fixers/test_nimpretty_fixer_callback.vader b/test/fixers/test_nimpretty_fixer_callback.vader new file mode 100644 index 00000000..a26f649a --- /dev/null +++ b/test/fixers/test_nimpretty_fixer_callback.vader @@ -0,0 +1,23 @@ +Before: + call ale#assert#SetUpFixerTest('nim', 'nimpretty') + +After: + call ale#assert#TearDownFixerTest() + +Execute(The nimpretty callback should return the correct default values): + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('nimpretty') . ' %t --maxLineLen:80' + \ }, + \ ale#fixers#nimpretty#Fix(bufnr('')) + +Execute(The nimpretty callback should include any additional options): + let g:ale_nim_nimpretty_options = '--some-option' + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('nimpretty') . ' %t --some-option' + \ }, + \ ale#fixers#nimpretty#Fix(bufnr('')) diff --git a/test/fixers/test_purty_fixer_callback.vader b/test/fixers/test_purty_fixer_callback.vader new file mode 100644 index 00000000..e83b8c18 --- /dev/null +++ b/test/fixers/test_purty_fixer_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:ale_purescript_purty_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_purescript_purty_executable = 'my-special-purty' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The purty callback should return the correct options): + call ale#test#SetFilename('../purescript_files/testfile.purs') + + AssertEqual + \ { + \ 'command': ale#Escape('my-special-purty') + \ . ' --write' + \ . ' %t', + \ 'read_temporary_file': 1, + \ }, + \ ale#fixers#purty#Fix(bufnr('')) diff --git a/test/fixers/test_stylelint_fixer_callback.vader b/test/fixers/test_stylelint_fixer_callback.vader index 90a9dc1f..f677cdf7 100644 --- a/test/fixers/test_stylelint_fixer_callback.vader +++ b/test/fixers/test_stylelint_fixer_callback.vader @@ -1,17 +1,33 @@ Before: - call ale#test#SetDirectory('/testplugin/test/fixers') + call ale#assert#SetUpFixerTest('css', 'stylelint') After: - call ale#test#RestoreDirectory() + call ale#assert#TearDownFixerTest() -Execute(The executable path should be correct): +Execute(The stylelint callback should return the correct default values): call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css') - AssertEqual + AssertFixer \ { \ 'read_temporary_file': 1, - \ 'command': (has('win32') ? 'node.exe ' : '') + \ 'command': ale#path#CdString(expand('%:p:h')) + \ . (has('win32') ? 'node.exe ' : '') \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) - \ . ' --fix %t', - \ }, - \ ale#fixers#stylelint#Fix(bufnr('')) + \ . ' %t' + \ . ' --fix', + \ } + +Execute(The stylelint callback should include custom stylelint options): + let g:ale_stylelint_options = '--cache' + call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css') + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#path#CdString(expand('%:p:h')) + \ . (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) + \ . ' %t' + \ . ' --cache' + \ . ' --fix', + \ } diff --git a/test/fixers/test_styler_fixer_callback.vader b/test/fixers/test_styler_fixer_callback.vader index 85e45c1d..79f71ba9 100644 --- a/test/fixers/test_styler_fixer_callback.vader +++ b/test/fixers/test_styler_fixer_callback.vader @@ -13,7 +13,7 @@ Execute(The styler callback should include custom styler options): \ { \ 'command': 'Rscript --vanilla -e ' \ . '"suppressPackageStartupMessages(library(styler));' - \ . 'style_file(commandArgs(TRUE), style = ' + \ . 'style_file(commandArgs(TRUE), transformers = ' \ . 'a_custom_option)"' \ . ' %t', \ 'read_temporary_file': 1, diff --git a/test/handler/test_crystal_handler.vader b/test/handler/test_crystal_handler.vader index a7b7f3ab..209632e9 100644 --- a/test/handler/test_crystal_handler.vader +++ b/test/handler/test_crystal_handler.vader @@ -16,3 +16,13 @@ Execute(The crystal handler should parse lines correctly and add the column if i \ ale_linters#crystal#crystal#Handle(255, [ \ '[{"file":"/tmp/test.cr","line":2,"column":1,"size":null,"message":"unexpected token: EOF"}]' \ ]) + +Execute(The crystal handler should not fail when a missing file is required): + AssertEqual + \ [ { 'lnum':1, 'col': 1, 'text': 'while requiring "./nonexistent.cr"' } ], + \ ale_linters#crystal#crystal#Handle(255, + \ json_encode([ + \ { "file":"/tmp/file.cr","line":1,"column":1,"size":0,"message":"while requiring \"./nonexistent.cr\"" }, + \ { "message": "can't find file './nonexistent.cr' relative to '/tmp'" }, + \ ]) + \ ) diff --git a/test/handler/test_eslint_json_handler.vader b/test/handler/test_eslint_json_handler.vader index 8e07bd80..6235794a 100644 --- a/test/handler/test_eslint_json_handler.vader +++ b/test/handler/test_eslint_json_handler.vader @@ -21,6 +21,7 @@ After: unlet! g:config_error_lines Execute(The eslint handler should parse json correctly): + call ale#test#SetFilename('foo.js') AssertEqual \ [ \ { @@ -53,6 +54,21 @@ Execute(The eslint handler should parse json correctly): \ '[{"filePath":"foo.js","messages":[{"ruleId":"no-unused-vars","severity":1,"message":"''variable'' is assigned a value but never used.","line":1,"column":7,"nodeType":"Identifier","endLine":1,"endColumn":15},{"ruleId":"semi","severity":1,"message":"Missing semicolon.","line":5,"column":15,"nodeType":"ExpressionStatement","fix":{"range":[46,46],"text":";"}},{"ruleId":"no-redeclare","severity":2,"message":"''variable'' is already defined.","line":7,"column":7,"nodeType":"Identifier","endLine":7,"endColumn":15}],"errorCount":1,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":1,"source":"const variable = {\n a: 3\n};\n\nconsole.log(1)\n\nclass variable {\n}\n"}]' \ ]) +Execute(The eslint handler should suppress deprecation warnings): + call ale#test#SetFilename('foo.js') + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 9, + \ 'text': 'Parsing error: Unexpected token Controller', + \ 'type': 'E', + \ } + \ ], + \ ale#handlers#eslint#HandleJSON(bufnr(''), [ + \ '[{"filePath":"foo.js","messages":[{"ruleId":null,"fatal":true,"severity":2 ,"message":"Parsing error: Unexpected token Controller","line":1,"column":9}],"errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount": 0,"source":"i:mport Controller from \"@ember/controller\";\nimport listViewControllerMixin from \"elearning/mixins/list-view-controller\";\nimport { inject as service } from \"@ember/service\";\n\nexport default Controller.extend(listViewControllerMixin(), {\n modelName: \"notification\",\n intl: service(),\n\n flatpickrLocale: computed(\"intl.locale\", function() {\n return this.intl.locale.firstObject.split(\"-\")[0];\n })\n});\n"}]', '(node:616989) [ESLINT_LEGACY_OBJECT_REST_SPREAD] DeprecationWarning: The ''parserOptions.ecmaFeatures.experimentalObjectRestSpread'' option is deprecated. Use ''parser Options.ecmaVersion'' instead. (found in "node_modules/eslint-plugin-ember/lib/config/base.js")]' + \ ]) + Execute(The eslint handler should print a message about a missing configuration file): let g:config_error_lines = [ \ '', @@ -262,7 +278,7 @@ Execute(Suppressing missing configs shouldn't suppress module import errors): \ ale#handlers#eslint#HandleJSON(bufnr(''), g:config_error_lines[:]) Execute(The eslint handler should hint about using typescript-eslint-parser): - silent! noautocmd file foo.ts + call ale#test#SetFilename('foo.ts') AssertEqual \ [ @@ -326,7 +342,7 @@ Execute(Failing to connect to eslint_d should be handled correctly): \ ]) Execute(Disabling warnings about trailing spaces should work): - silent! noautocmd file foo.ts + call ale#test#SetFilename('foo.js') AssertEqual \ [ diff --git a/test/handler/test_mypy_handler.vader b/test/handler/test_mypy_handler.vader index 6e96f3f3..039155a2 100644 --- a/test/handler/test_mypy_handler.vader +++ b/test/handler/test_mypy_handler.vader @@ -1,6 +1,8 @@ Before: Save g:ale_python_mypy_ignore_invalid_syntax + Save g:ale_python_mypy_show_notes + unlet! g:ale_python_mypy_show_notes unlet! g:ale_python_mypy_ignore_invalid_syntax runtime ale_linters/python/mypy.vim @@ -16,6 +18,8 @@ After: Execute(The mypy handler should parse lines correctly): call ale#test#SetFilename('__init__.py') + let g:ale_python_mypy_show_notes = 0 + AssertEqual \ [ \ { @@ -69,6 +73,31 @@ Execute(The mypy handler should parse lines correctly): \ '__init__.py:72:1: warning: Some warning', \ ]) +Execute(The mypy handler should show notes if enabled): + call ale#test#SetFilename('__init__.py') + + AssertEqual + \ [ + \ { + \ 'lnum': 72, + \ 'col': 1, + \ 'filename': ale#path#Simplify(g:dir . '/__init__.py'), + \ 'type': 'I', + \ 'text': 'A note', + \ }, + \ ], + \ ale_linters#python#mypy#Handle(bufnr(''), [ + \ '__init__.py:72:1: note: A note', + \ ]) + + let g:ale_python_mypy_show_notes = 0 + + AssertEqual + \ [], + \ ale_linters#python#mypy#Handle(bufnr(''), [ + \ '__init__.py:72:1: note: A note', + \ ]) + Execute(The mypy handler should handle Windows names with spaces): " This test works on Unix, where this is seen as a single filename silent file C:\\something\\with\ spaces.py diff --git a/test/handler/test_nim_handler.vader b/test/handler/test_nim_handler.vader index e484000e..b6784d84 100644 --- a/test/handler/test_nim_handler.vader +++ b/test/handler/test_nim_handler.vader @@ -21,6 +21,7 @@ Execute(Parsing nim errors should work): \ 'col': 2, \ 'text': 'identifier expected, but found ''a.barfoo''', \ 'type': 'E', + \ 'end_col': 9, \ }, \ { \ 'lnum': 2, @@ -28,6 +29,7 @@ Execute(Parsing nim errors should work): \ 'text': '''NotUsed'' is declared but not used', \ 'code': 'XDeclaredButNotUsed', \ 'type': 'W', + \ 'end_col': 11, \ }, \ { \ 'lnum': 12, @@ -35,6 +37,35 @@ Execute(Parsing nim errors should work): \ 'text': 'with : character', \ 'type': 'E', \ }, + \ { + \ 'lnum': 1, + \ 'col': 8, + \ 'text': 'imported and not used: ''strutils''', + \ 'code': 'UnusedImport', + \ 'type': 'W', + \ 'end_col': 15, + \ }, + \ { + \ 'lnum': 12, + \ 'col': 9, + \ 'text': 'undeclared identifier: ''total''', + \ 'type': 'E', + \ 'end_col': 13, + \ }, + \ { + \ 'lnum': 14, + \ 'col': 1, + \ 'text': '''sum'' cannot be assigned to', + \ 'type': 'E', + \ 'end_col': 3, + \ }, + \ { + \ 'lnum': 15, + \ 'col': 1, + \ 'text': 'redefinition of ''getName''; previous declaration here: /nested/folder/foobar.nim(14, 6)', + \ 'type': 'E', + \ 'end_col': 7, + \ }, \ ], \ ale_linters#nim#nimcheck#Handle(bufnr(''), [ \ 'Line with wrong( format)', @@ -42,4 +73,8 @@ Execute(Parsing nim errors should work): \ 'foobar.nim(12, 2) Error: identifier expected, but found ''a.barfoo''', \ '/nested/folder/foobar.nim(2, 5) Hint: ''NotUsed'' is declared but not used [XDeclaredButNotUsed]', \ 'foobar.nim(12, 2) Error: with : character', + \ 'foobar.nim(1, 8) Warning: imported and not used: ''strutils'' [UnusedImport]', + \ 'foobar.nim(12, 9) Error: undeclared identifier: ''total''', + \ 'foobar.nim(14, 1) Error: ''sum'' cannot be assigned to', + \ 'foobar.nim(15, 1) Error: redefinition of ''getName''; previous declaration here: /nested/folder/foobar.nim(14, 6)', \ ]) diff --git a/test/python/test_deoplete_source.py b/test/python/test_deoplete_source.py index 9e56a10d..8304fa25 100644 --- a/test/python/test_deoplete_source.py +++ b/test/python/test_deoplete_source.py @@ -8,15 +8,20 @@ ale_module = imp.load_source( class VimMock(object): - def __init__(self, call_list, call_results): + def __init__(self, call_list, call_results, commands): self.__call_list = call_list self.__call_results = call_results + self.__commands = commands + def call(self, function, *args): self.__call_list.append((function, args)) return self.__call_results.get(function, 0) + def command(self, command): + self.__commands.append(command) + class DeopleteSourceTest(unittest.TestCase): def setUp(self): @@ -24,8 +29,10 @@ class DeopleteSourceTest(unittest.TestCase): self.call_list = [] self.call_results = {'ale#completion#CanProvideCompletions': 1} + self.commands = [] self.source = ale_module.Source('vim') - self.source.vim = VimMock(self.call_list, self.call_results) + self.source.vim = VimMock( + self.call_list, self.call_results, self.commands) def test_attributes(self): """ @@ -48,6 +55,7 @@ class DeopleteSourceTest(unittest.TestCase): 'cpp': r'(\.|::|->)\w*$', }, 'is_bytepos': True, + 'is_volatile': True, 'mark': '[L]', 'min_pattern_length': 1, 'name': 'ale', @@ -64,70 +72,28 @@ class DeopleteSourceTest(unittest.TestCase): ]) def test_request_completion_results(self): - context = {'is_async': False} + context = {'event': 'TextChangedI', 'is_refresh': True} self.assertEqual(self.source.gather_candidates(context), []) - self.assertEqual(context, {'is_async': True}) self.assertEqual(self.call_list, [ ('ale#completion#CanProvideCompletions', ()), - ('ale#completion#GetCompletions', ('deoplete',)), + ]) + self.assertEqual(self.commands, [ + "call ale#completion#GetCompletions('ale-callback', " + \ + "{'callback': {completions -> deoplete#auto_complete() }})" ]) def test_request_completion_results_from_buffer_without_providers(self): self.call_results['ale#completion#CanProvideCompletions'] = 0 - context = {'is_async': False} + context = {'event': 'TextChangedI', 'is_refresh': True} self.assertIsNone(self.source.gather_candidates(context), []) - self.assertEqual(context, {'is_async': False}) - self.assertEqual(self.call_list, [ - ('ale#completion#CanProvideCompletions', ()), - ]) - - def test_refresh_completion_results(self): - context = {'is_async': False} - - self.assertEqual(self.source.gather_candidates(context), []) - self.assertEqual(context, {'is_async': True}) - self.assertEqual(self.call_list, [ - ('ale#completion#CanProvideCompletions', ()), - ('ale#completion#GetCompletions', ('deoplete',)), - ]) - - context = {'is_async': True, 'is_refresh': True} - - self.assertEqual(self.source.gather_candidates(context), []) - self.assertEqual(context, {'is_async': True, 'is_refresh': True}) self.assertEqual(self.call_list, [ ('ale#completion#CanProvideCompletions', ()), - ('ale#completion#GetCompletions', ('deoplete',)), - ('ale#completion#CanProvideCompletions', ()), - ('ale#completion#GetCompletions', ('deoplete',)), ]) - def test_poll_no_result(self): - context = {'is_async': True} - self.call_results['ale#completion#GetCompletionResult'] = None - - self.assertEqual(self.source.gather_candidates(context), []) - self.assertEqual(context, {'is_async': True}) - self.assertEqual(self.call_list, [ - ('ale#completion#CanProvideCompletions', ()), - ('ale#completion#GetCompletionResult', ()), - ]) - - def test_poll_empty_result_ready(self): - context = {'is_async': True} - self.call_results['ale#completion#GetCompletionResult'] = [] - - self.assertEqual(self.source.gather_candidates(context), []) - self.assertEqual(context, {'is_async': False}) - self.assertEqual(self.call_list, [ - ('ale#completion#CanProvideCompletions', ()), - ('ale#completion#GetCompletionResult', ()), - ]) - - def test_poll_non_empty_result_ready(self): - context = {'is_async': True} + def test_async_event(self): + context = {'event': 'Async', 'is_refresh': True} self.call_results['ale#completion#GetCompletionResult'] = [ { 'word': 'foobar', @@ -147,7 +113,7 @@ class DeopleteSourceTest(unittest.TestCase): 'info': '', }, ]) - self.assertEqual(context, {'is_async': False}) + self.assertEqual(self.call_list, [ ('ale#completion#CanProvideCompletions', ()), ('ale#completion#GetCompletionResult', ()), diff --git a/test/sign/test_linting_sets_signs.vader b/test/sign/test_linting_sets_signs.vader index 60ae0a83..1d1f9802 100644 --- a/test/sign/test_linting_sets_signs.vader +++ b/test/sign/test_linting_sets_signs.vader @@ -32,7 +32,7 @@ Before: function! CollectSigns() redir => l:output - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') silent exec 'sign place group=ale' else silent exec 'sign place' diff --git a/test/sign/test_sign_parsing.vader b/test/sign/test_sign_parsing.vader index 157ff2f4..c0967f43 100644 --- a/test/sign/test_sign_parsing.vader +++ b/test/sign/test_sign_parsing.vader @@ -1,5 +1,5 @@ Execute (Parsing English signs should work): - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') AssertEqual \ [0, [[9, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([ @@ -16,7 +16,7 @@ Execute (Parsing English signs should work): endif Execute (Parsing Russian signs should work): - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') AssertEqual \ [0, [[1, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([' строка=1 id=1000001 группа=ale имя=ALEErrorSign']) @@ -27,7 +27,7 @@ Execute (Parsing Russian signs should work): endif Execute (Parsing Japanese signs should work): - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') AssertEqual \ [0, [[1, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' 行=1 識別子=1000001 グループ=ale 名前=ALEWarningSign']) @@ -38,7 +38,7 @@ Execute (Parsing Japanese signs should work): endif Execute (Parsing Spanish signs should work): - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') AssertEqual \ [0, [[12, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' línea=12 id=1000001 grupo=ale nombre=ALEWarningSign']) @@ -49,7 +49,7 @@ Execute (Parsing Spanish signs should work): endif Execute (Parsing Italian signs should work): - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') AssertEqual \ [0, [[1, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' riga=1 id=1000001, gruppo=ale nome=ALEWarningSign']) @@ -60,7 +60,7 @@ Execute (Parsing Italian signs should work): endif Execute (Parsing German signs should work): - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') AssertEqual \ [0, [[235, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([' Zeile=235 id=1000001 Gruppe=ale Name=ALEErrorSign']) @@ -71,7 +71,7 @@ Execute (Parsing German signs should work): endif Execute (The sign parser should indicate if the dummy sign is set): - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') AssertEqual \ [1, [[1, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([ diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader index 80153b22..d8d05b28 100644 --- a/test/sign/test_sign_placement.vader +++ b/test/sign/test_sign_placement.vader @@ -68,7 +68,7 @@ Before: function! ParseSigns() redir => l:output - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') silent sign place group=ale else silent sign place @@ -152,7 +152,7 @@ Execute(The current signs should be set for running a job): \ ParseSigns() Execute(Loclist items with sign_id values should be kept): - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000348 group=ale line=15 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000349 group=ale line=16 name=ALEWarningSign buffer=' . bufnr('') @@ -297,7 +297,7 @@ Execute(No exceptions should be thrown when setting signs for invalid buffers): Execute(Signs should be removed when lines have multiple sign IDs on them): " We can fail to remove signs if there are multiple signs on one line, " say after deleting lines in Vim, etc. - if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || has('patch-8.1.614') exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000348 group=ale line=3 name=ALEWarningSign buffer=' . bufnr('') exec 'sign place 1000349 group=ale line=10 name=ALEErrorSign buffer=' . bufnr('') diff --git a/test/test_eslint_executable_detection.vader b/test/test_eslint_executable_detection.vader index 64383dcb..c2071131 100644 --- a/test/test_eslint_executable_detection.vader +++ b/test/test_eslint_executable_detection.vader @@ -57,13 +57,25 @@ Execute(eslint.js executables should be run with node on Windows): " We have to execute the file with node. if has('win32') AssertEqual - \ ale#Escape('node.exe') . ' ' + \ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app')) + \ . ale#Escape('node.exe') . ' ' \ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) \ . ' -f json --stdin --stdin-filename %s', \ ale#handlers#eslint#GetCommand(bufnr('')) else AssertEqual - \ ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app')) + \ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) \ . ' -f json --stdin --stdin-filename %s', \ ale#handlers#eslint#GetCommand(bufnr('')) endif + +Execute(eslint.js executables can be run outside project dir): + " Set filename above eslint-test-files (which contains node_modules) + call ale#test#SetFilename('testfile.js') + + " cd "..." not present, since project root not found (from node_modules) + AssertEqual + \ ale#Escape(ale#handlers#eslint#GetExecutable(bufnr(''))) + \ . ' -f json --stdin --stdin-filename %s', + \ ale#handlers#eslint#GetCommand(bufnr('')) diff --git a/test/test_find_references.vader b/test/test_find_references.vader index 1a147849..9949362a 100644 --- a/test/test_find_references.vader +++ b/test/test_find_references.vader @@ -2,6 +2,8 @@ Before: call ale#test#SetDirectory('/testplugin/test') call ale#test#SetFilename('dummy.txt') + Save g:ale_default_navigation + let g:old_filename = expand('%:p') let g:Callback = '' let g:expr_list = [] @@ -12,6 +14,7 @@ Before: let g:capability_checked = '' let g:conn_id = v:null let g:InitCallback = v:null + let g:ale_default_navigation = 'buffer' runtime autoload/ale/lsp_linter.vim runtime autoload/ale/lsp.vim @@ -63,6 +66,8 @@ Before: endfunction After: + Restore + if g:conn_id isnot v:null call ale#lsp#RemoveConnectionWithID(g:conn_id) endif @@ -152,6 +157,20 @@ Execute(Results should be shown for tsserver responses): \ g:item_list AssertEqual {}, ale#references#GetMap() + " We should be able to repeat selections with ALERepeatSelection + let g:ale_item_list = [] + + ALERepeatSelection + + AssertEqual + \ [ + \ {'filename': '/foo/bar/app.ts', 'column': 9, 'line': 9, 'match': 'import {doSomething} from ''./whatever'''}, + \ {'filename': '/foo/bar/app.ts', 'column': 3, 'line': 804, 'match': 'doSomething()'}, + \ {'filename': '/foo/bar/other/app.ts', 'column': 3, 'line': 51, 'match': 'doSomething()'}, + \ ], + \ g:item_list + AssertEqual {}, ale#references#GetMap() + Execute(The preview window should not be opened for empty tsserver responses): call ale#references#SetMap({3: {}}) call ale#references#HandleTSServerResponse(1, { @@ -195,7 +214,7 @@ Execute(tsserver reference requests should be sent): \ [0, 'ts@references', {'file': expand('%:p'), 'line': 2, 'offset': 5}] \ ], \ g:message_list - AssertEqual {'42': {'use_relative_paths': 0}}, ale#references#GetMap() + AssertEqual {'42': {'open_in': 'current-buffer', 'use_relative_paths': 0}}, ale#references#GetMap() Execute('-relative' argument should enable 'use_relative_paths' in HandleTSServerResponse): runtime ale_linters/typescript/tsserver.vim @@ -205,7 +224,48 @@ Execute('-relative' argument should enable 'use_relative_paths' in HandleTSServe call g:InitCallback() - AssertEqual {'42': {'use_relative_paths': 1}}, ale#references#GetMap() + AssertEqual {'42': {'open_in': 'current-buffer', 'use_relative_paths': 1}}, ale#references#GetMap() + +Execute(`-tab` should display results in tabs): + runtime ale_linters/typescript/tsserver.vim + call setpos('.', [bufnr(''), 2, 5, 0]) + + ALEFindReferences -tab + + call g:InitCallback() + + AssertEqual {'42': {'open_in': 'tab', 'use_relative_paths': 0}}, ale#references#GetMap() + +Execute(The default navigation type should be used): + runtime ale_linters/typescript/tsserver.vim + call setpos('.', [bufnr(''), 2, 5, 0]) + + let g:ale_default_navigation = 'tab' + ALEFindReferences + + call g:InitCallback() + + AssertEqual {'42': {'open_in': 'tab', 'use_relative_paths': 0}}, ale#references#GetMap() + +Execute(`-split` should display results in splits): + runtime ale_linters/typescript/tsserver.vim + call setpos('.', [bufnr(''), 2, 5, 0]) + + ALEFindReferences -split + + call g:InitCallback() + + AssertEqual {'42': {'open_in': 'split', 'use_relative_paths': 0}}, ale#references#GetMap() + +Execute(`-vsplit` should display results in vsplits): + runtime ale_linters/typescript/tsserver.vim + call setpos('.', [bufnr(''), 2, 5, 0]) + + ALEFindReferences -vsplit + + call g:InitCallback() + + AssertEqual {'42': {'open_in': 'vsplit', 'use_relative_paths': 0}}, ale#references#GetMap() Given python(Some Python file): foo @@ -302,7 +362,7 @@ Execute(LSP reference requests should be sent): \ ], \ g:message_list - AssertEqual {'42': {'use_relative_paths': 0}}, ale#references#GetMap() + AssertEqual {'42': {'open_in': 'current-buffer', 'use_relative_paths': 0}}, ale#references#GetMap() Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResponse): runtime ale_linters/python/pyls.vim @@ -313,4 +373,4 @@ Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResp call g:InitCallback() - AssertEqual {'42': {'use_relative_paths': 1}}, ale#references#GetMap() + AssertEqual {'42': {'open_in': 'current-buffer', 'use_relative_paths': 1}}, ale#references#GetMap() diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader index 3479d7b5..a517bd54 100644 --- a/test/test_go_to_definition.vader +++ b/test/test_go_to_definition.vader @@ -2,6 +2,8 @@ Before: call ale#test#SetDirectory('/testplugin/test') call ale#test#SetFilename('dummy.txt') + Save g:ale_default_navigation + let g:old_filename = expand('%:p') let g:Callback = '' let g:message_list = [] @@ -9,6 +11,7 @@ Before: let g:capability_checked = '' let g:conn_id = v:null let g:InitCallback = v:null + let g:ale_default_navigation = 'buffer' runtime autoload/ale/linter.vim runtime autoload/ale/lsp_linter.vim @@ -54,6 +57,8 @@ Before: endfunction After: + Restore + if g:conn_id isnot v:null call ale#lsp#RemoveConnectionWithID(g:conn_id) endif @@ -164,7 +169,7 @@ Execute(Other files should be jumped to for definition responses in tabs too): AssertEqual {}, ale#definition#GetMap() Execute(Other files should be jumped to for definition responses in splits too): - call ale#definition#SetMap({3: {'open_in': 'horizontal-split'}}) + call ale#definition#SetMap({3: {'open_in': 'split'}}) call ale#definition#HandleTSServerResponse( \ 1, \ { @@ -189,7 +194,7 @@ Execute(Other files should be jumped to for definition responses in splits too): AssertEqual {}, ale#definition#GetMap() Execute(Other files should be jumped to for definition responses in vsplits too): - call ale#definition#SetMap({3: {'open_in': 'vertical-split'}}) + call ale#definition#SetMap({3: {'open_in': 'vsplit'}}) call ale#definition#HandleTSServerResponse( \ 1, \ { @@ -241,7 +246,32 @@ Execute(tsserver tab definition requests should be sent): runtime ale_linters/typescript/tsserver.vim call setpos('.', [bufnr(''), 2, 5, 0]) - ALEGoToDefinitionInTab + ALEGoToDefinition -tab + + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + + AssertEqual 'definition', g:capability_checked + AssertEqual + \ 'function(''ale#definition#HandleTSServerResponse'')', + \ string(g:Callback) + AssertEqual + \ [ + \ ale#lsp#tsserver_message#Change(bufnr('')), + \ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}] + \ ], + \ g:message_list + AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap() + +Execute(The default navigation type should be used): + runtime ale_linters/typescript/tsserver.vim + call setpos('.', [bufnr(''), 2, 5, 0]) + + let g:ale_default_navigation = 'tab' + ALEGoToDefinition " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) @@ -448,7 +478,7 @@ Execute(LSP tab definition requests should be sent): let b:ale_linters = ['pyls'] call setpos('.', [bufnr(''), 1, 5, 0]) - ALEGoToDefinitionInTab + ALEGoToDefinition -tab " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader index 3b259655..dab73073 100644 --- a/test/test_highlight_placement.vader +++ b/test/test_highlight_placement.vader @@ -7,6 +7,8 @@ Before: Save g:ale_set_loclist Save g:ale_set_quickfix Save g:ale_set_signs + Save g:ale_exclude_highlights + Save b:ale_exclude_highlights runtime autoload/ale/highlight.vim @@ -20,6 +22,8 @@ Before: let g:ale_set_quickfix = 0 let g:ale_set_loclist = 0 let g:ale_echo_cursor = 0 + let g:ale_exclude_highlights = [] + let b:ale_exclude_highlights = [] function! GenerateResults(buffer, output) return [ @@ -363,6 +367,23 @@ Execute(Highlights should always be cleared when the buffer highlight list is em \ GetMatchesWithoutIDs() endif +Execute(Highlights should be hidden when excluded): + let b:ale_exclude_highlights = ['ig.*ore', 'nope'] + + call ale#highlight#SetHighlights(bufnr('%'), [ + \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 1, 'col': 1, 'text': 'hello'}, + \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 2, 'col': 1, 'text': 'ignore'}, + \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 1, 'text': 'nope'}, + \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 4, 'col': 1, 'text': 'world'}, + \]) + + AssertEqual + \ [ + \ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]}, + \ {'group': 'ALEError', 'priority': 10, 'pos1': [4, 1, 1]}, + \ ], + \ GetMatchesWithoutIDs() + Execute(Highlights should be cleared when ALE is disabled): let g:ale_enabled = 1 call ale#highlight#SetHighlights(bufnr(''), [ |