Remove the need for pointless callbacks for LSP linters
This commit is contained in:
parent
857ca941d2
commit
51f256e897
@ -11,14 +11,9 @@ function! ale_linters#typescript#tsserver#GetExecutable(buffer) abort
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#typescript#tsserver#Handle(buffer, lines) abort
|
||||
return a:lines
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('typescript', {
|
||||
\ 'name': 'tsserver',
|
||||
\ 'lsp': 'tsserver',
|
||||
\ 'executable_callback': 'ale_linters#typescript#tsserver#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#typescript#tsserver#GetExecutable',
|
||||
\ 'callback': 'ale_linters#typescript#tsserver#Handle',
|
||||
\})
|
||||
|
@ -52,21 +52,24 @@ function! ale#linter#PreProcess(linter) abort
|
||||
let l:obj = {
|
||||
\ 'name': get(a:linter, 'name'),
|
||||
\ 'lsp': get(a:linter, 'lsp', ''),
|
||||
\ 'callback': get(a:linter, 'callback'),
|
||||
\}
|
||||
|
||||
if type(l:obj.name) != type('')
|
||||
throw '`name` must be defined to name the linter'
|
||||
endif
|
||||
|
||||
if !s:IsCallback(l:obj.callback)
|
||||
throw '`callback` must be defined with a callback to accept output'
|
||||
endif
|
||||
|
||||
let l:needs_address = l:obj.lsp ==# 'socket'
|
||||
let l:needs_executable = l:obj.lsp !=# 'socket'
|
||||
let l:needs_command = l:obj.lsp !=# 'socket'
|
||||
|
||||
if empty(l:obj.lsp)
|
||||
let l:obj.callback = get(a:linter, 'callback')
|
||||
|
||||
if !s:IsCallback(l:obj.callback)
|
||||
throw '`callback` must be defined with a callback to accept output'
|
||||
endif
|
||||
endif
|
||||
|
||||
if index(['', 'socket', 'stdio', 'tsserver'], l:obj.lsp) < 0
|
||||
throw '`lsp` must be either `''lsp''` or `''tsserver''` if defined'
|
||||
endif
|
||||
|
@ -372,7 +372,6 @@ Execute(PreProcess should accept tsserver LSP configuration):
|
||||
\ 'executable': 'x',
|
||||
\ 'command': 'x',
|
||||
\ 'lsp': 'tsserver',
|
||||
\ 'callback': 'x',
|
||||
\}
|
||||
|
||||
AssertEqual 'tsserver', ale#linter#PreProcess(g:linter).lsp
|
||||
@ -393,7 +392,6 @@ Execute(PreProcess should accept stdio LSP configuration):
|
||||
\ 'executable': 'x',
|
||||
\ 'command': 'x',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'callback': 'x',
|
||||
\}
|
||||
|
||||
AssertEqual 'stdio', ale#linter#PreProcess(g:linter).lsp
|
||||
@ -412,7 +410,6 @@ Execute(PreProcess should accept LSP server configurations):
|
||||
let g:linter = {
|
||||
\ 'name': 'x',
|
||||
\ 'lsp': 'socket',
|
||||
\ 'callback': 'x',
|
||||
\ 'address_callback': 'X',
|
||||
\}
|
||||
|
||||
@ -422,7 +419,6 @@ Execute(PreProcess should require an address_callback for LSP socket configurati
|
||||
let g:linter = {
|
||||
\ 'name': 'x',
|
||||
\ 'lsp': 'socket',
|
||||
\ 'callback': 'x',
|
||||
\}
|
||||
|
||||
AssertThrows call ale#linter#PreProcess(g:linter)
|
||||
|
Loading…
Reference in New Issue
Block a user