summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-08-02 23:21:30 +0100
committerw0rp <devw0rp@gmail.com>2017-08-02 23:21:30 +0100
commit09d50ebe3110bfee5ac505aa29704d980ba156f3 (patch)
tree2b2d17d5f8dba9a13c18b7a79cba3fde63e15402 /autoload
parent617582c5d3833cf3143067870c87a09647ccf028 (diff)
downloadale-09d50ebe3110bfee5ac505aa29704d980ba156f3.zip
Cover the Rust LSP with tests, allow LSP linters to be named anything, and rename the Rust LSP linter to `rls`
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/completion.vim2
-rw-r--r--autoload/ale/engine.vim22
-rw-r--r--autoload/ale/lsp.vim2
3 files changed, 20 insertions, 6 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index 214891fb..3eeb6173 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -170,7 +170,7 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
return l:results
endfunction
-function! s:HandleTSServerLSPResponse(response) abort
+function! s:HandleTSServerLSPResponse(conn_id, response) abort
if !s:CompletionStillValid(get(a:response, 'request_seq'))
return
endif
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 52acfe7f..a5a5f524 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -11,6 +11,11 @@ if !has_key(s:, 'job_info_map')
let s:job_info_map = {}
endif
+" Associates LSP connection IDs with linter names.
+if !has_key(s:, 'lsp_linter_map')
+ let s:lsp_linter_map = {}
+endif
+
let s:executable_cache_map = {}
" Check if files are executable, and if they are, remember that they are
@@ -192,12 +197,18 @@ function! s:HandleExit(job_id, exit_code) abort
call s:HandleLoclist(l:linter.name, l:buffer, l:loclist)
endfunction
-function! s:HandleLSPDiagnostics(response) abort
+function! s:HandleLSPDiagnostics(conn_id, response) abort
+ let l:linter_name = s:lsp_linter_map[a:conn_id]
let l:filename = ale#path#FromURI(a:response.params.uri)
let l:buffer = bufnr(l:filename)
+
+ if l:buffer <= 0
+ return
+ endif
+
let l:loclist = ale#lsp#response#ReadDiagnostics(a:response)
- call s:HandleLoclist('langserver', l:buffer, l:loclist)
+ call s:HandleLoclist(l:linter_name, l:buffer, l:loclist)
endfunction
function! s:HandleTSServerDiagnostics(response, error_type) abort
@@ -233,14 +244,14 @@ function! s:HandleLSPErrorMessage(error_message) abort
endfor
endfunction
-function! ale#engine#HandleLSPResponse(response) abort
+function! ale#engine#HandleLSPResponse(conn_id, response) abort
let l:method = get(a:response, 'method', '')
if get(a:response, 'jsonrpc', '') ==# '2.0' && has_key(a:response, 'error')
" Uncomment this line to print LSP error messages.
" call s:HandleLSPErrorMessage(a:response.error.message)
elseif l:method ==# 'textDocument/publishDiagnostics'
- call s:HandleLSPDiagnostics(a:response)
+ call s:HandleLSPDiagnostics(a:conn_id, a:response)
elseif get(a:response, 'type', '') ==# 'event'
\&& get(a:response, 'event', '') ==# 'semanticDiag'
call s:HandleTSServerDiagnostics(a:response, 'semantic')
@@ -617,6 +628,9 @@ function! s:CheckWithLSP(buffer, linter) abort
let l:id = l:lsp_details.connection_id
let l:root = l:lsp_details.project_root
+ " Remember the linter this connection is for.
+ let s:lsp_linter_map[l:id] = a:linter.name
+
let l:change_message = a:linter.lsp ==# 'tsserver'
\ ? ale#lsp#tsserver_message#Geterr(a:buffer)
\ : ale#lsp#message#DidChange(a:buffer)
diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim
index eb66eb47..bb9a24f2 100644
--- a/autoload/ale/lsp.vim
+++ b/autoload/ale/lsp.vim
@@ -222,7 +222,7 @@ function! ale#lsp#HandleMessage(conn, message) abort
" Call all of the registered handlers with the response.
for l:Callback in a:conn.callback_list
- call ale#util#GetFunction(l:Callback)(l:response)
+ call ale#util#GetFunction(l:Callback)(a:conn.id, l:response)
endfor
endif
endfor