mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-25 09:48:43 +08:00
Add tsserver support
This commit is contained in:
@@ -15,7 +15,7 @@ function! ale#lsp#response#ReadDiagnostics(params) abort
|
||||
for l:diagnostic in a:params.diagnostics
|
||||
let l:severity = get(l:diagnostic, 'severity', 0)
|
||||
let l:loclist_item = {
|
||||
\ 'message': l:diagnostic.message,
|
||||
\ 'text': l:diagnostic.message,
|
||||
\ 'type': 'E',
|
||||
\ 'lnum': l:diagnostic.range.start.line + 1,
|
||||
\ 'col': l:diagnostic.range.start.character + 1,
|
||||
@@ -42,3 +42,26 @@ function! ale#lsp#response#ReadDiagnostics(params) abort
|
||||
|
||||
return [l:filename, l:loclist]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#response#ReadTSServerDiagnostics(response) abort
|
||||
let l:loclist = []
|
||||
|
||||
for l:diagnostic in a:response.body.diagnostics
|
||||
let l:loclist_item = {
|
||||
\ 'text': l:diagnostic.text,
|
||||
\ 'type': 'E',
|
||||
\ 'lnum': l:diagnostic.start.line,
|
||||
\ 'col': l:diagnostic.start.offset,
|
||||
\ 'end_lnum': l:diagnostic.end.line,
|
||||
\ 'end_col': l:diagnostic.end.offset,
|
||||
\}
|
||||
|
||||
if has_key(l:diagnostic, 'code')
|
||||
let l:loclist_item.nr = l:diagnostic.code
|
||||
endif
|
||||
|
||||
call add(l:loclist, l:loclist_item)
|
||||
endfor
|
||||
|
||||
return l:loclist
|
||||
endfunction
|
||||
|
||||
@@ -19,16 +19,19 @@ endfunction
|
||||
function! ale#lsp#tsserver_message#Change(buffer) abort
|
||||
let l:lines = getbufline(a:buffer, 1, '$')
|
||||
|
||||
" We will always use a very high endLine number, so we can delete
|
||||
" lines from files. tsserver will gladly accept line numbers beyond the
|
||||
" end.
|
||||
return [1, 'ts@change', {
|
||||
\ 'file': expand('#' . a:buffer . ':p'),
|
||||
\ 'line': 1,
|
||||
\ 'offset': 1,
|
||||
\ 'endLine': len(l:lines),
|
||||
\ 'endOffset': len(l:lines[-1]),
|
||||
\ 'endLine': 1073741824 ,
|
||||
\ 'endOffset': 1,
|
||||
\ 'insertString': join(l:lines, "\n"),
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#tsserver_message#Geterr(buffer) abort
|
||||
return [1, 'ts@geterr', {'files': [expand('#' . a:buffer . ':p')]}]
|
||||
return [0, 'ts@geterr', {'files': [expand('#' . a:buffer . ':p')]}]
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user