summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/typescript/tsserver.vim5
-rw-r--r--autoload/ale/linter.vim13
-rw-r--r--test/test_linter_defintion_processing.vader4
3 files changed, 8 insertions, 14 deletions
diff --git a/ale_linters/typescript/tsserver.vim b/ale_linters/typescript/tsserver.vim
index df979c6b..465e80c7 100644
--- a/ale_linters/typescript/tsserver.vim
+++ b/ale_linters/typescript/tsserver.vim
@@ -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',
\})
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 3419f5af..4138b876 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -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
diff --git a/test/test_linter_defintion_processing.vader b/test/test_linter_defintion_processing.vader
index 7ff8ddbf..572591db 100644
--- a/test/test_linter_defintion_processing.vader
+++ b/test/test_linter_defintion_processing.vader
@@ -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)