mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-26 19:47:21 +08:00
#517 Support linter settings needed for LSP, undocumented for now
This commit is contained in:
@@ -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('')
|
||||
|
||||
Reference in New Issue
Block a user