diff options
author | w0rp <devw0rp@gmail.com> | 2017-06-08 13:52:29 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-06-08 13:52:29 +0100 |
commit | 04190cbcfe1b1b0681e3c9098b27633c2fc7c870 (patch) | |
tree | 5035a6430c2dfd6e04096b59b5142c016e51eff7 /autoload | |
parent | d8d96fb0eb193c504680d3e21489c761fce46172 (diff) | |
download | ale-04190cbcfe1b1b0681e3c9098b27633c2fc7c870.zip |
#517 Support linter settings needed for LSP, undocumented for now
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/linter.vim | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim index 09f1d597..f1d5c091 100644 --- a/autoload/ale/linter.vim +++ b/autoload/ale/linter.vim @@ -51,6 +51,7 @@ function! ale#linter#PreProcess(linter) abort let l:obj = { \ 'name': get(a:linter, 'name'), + \ 'lsp': get(a:linter, 'lsp', ''), \ 'callback': get(a:linter, 'callback'), \} @@ -62,7 +63,27 @@ function! ale#linter#PreProcess(linter) abort throw '`callback` must be defined with a callback to accept output' endif - if has_key(a:linter, 'executable_callback') + let l:needs_executable = 0 + let l:needs_address = 0 + let l:needs_command = 0 + + if l:obj.lsp ==# 'tsserver' + let l:needs_executable = 1 + elseif l:obj.lsp ==# 'lsp' + let l:needs_address = 1 + elseif !empty(l:obj.lsp) + throw '`lsp` must be either `''lsp''` or `''tsserver''` if defined' + else + let l:needs_executable = 1 + let l:needs_command = 1 + endif + + if !l:needs_executable + if has_key(a:linter, 'executable') + \|| has_key(a:linter, 'executable_callback') + throw '`executable` and `executable_callback` cannot be used when lsp == ''lsp''' + endif + elseif has_key(a:linter, 'executable_callback') let l:obj.executable_callback = a:linter.executable_callback if !s:IsCallback(l:obj.executable_callback) @@ -78,7 +99,13 @@ function! ale#linter#PreProcess(linter) abort throw 'Either `executable` or `executable_callback` must be defined' endif - if has_key(a:linter, 'command_chain') + if !l:needs_command + if has_key(a:linter, 'command') + \|| has_key(a:linter, 'command_callback') + \|| has_key(a:linter, 'command_chain') + throw '`command` and `command_callback` and `command_chain` cannot be used when `lsp` is set' + endif + elseif has_key(a:linter, 'command_chain') let l:obj.command_chain = a:linter.command_chain if type(l:obj.command_chain) != type([]) @@ -138,6 +165,20 @@ function! ale#linter#PreProcess(linter) abort \ . 'should be set' endif + if !l:needs_address + if has_key(a:linter, 'address_callback') + throw '`address_callback` cannot be used when lsp != ''lsp''' + endif + elseif has_key(a:linter, 'address_callback') + let l:obj.address_callback = a:linter.address_callback + + if !s:IsCallback(l:obj.address_callback) + throw '`address_callback` must be a callback if defined' + endif + else + throw '`address_callback` must be defined for getting the LSP address' + endif + let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout') if type(l:obj.output_stream) != type('') |