Merge pull request #1771 from fredemmott/lsp
Show LSP diagnostic codes for `%code%` in message formats
This commit is contained in:
commit
5f024eda09
@ -47,7 +47,12 @@ function! ale#lsp#response#ReadDiagnostics(response) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if has_key(l:diagnostic, 'code')
|
if has_key(l:diagnostic, 'code')
|
||||||
let l:loclist_item.nr = l:diagnostic.code
|
if type(l:diagnostic.code) == v:t_string
|
||||||
|
let l:loclist_item.code = l:diagnostic.code
|
||||||
|
elseif type(l:diagnostic.code) == v:t_number && l:diagnostic.code != -1
|
||||||
|
let l:loclist_item.code = string(l:diagnostic.code)
|
||||||
|
let l:loclist_item.nr = l:diagnostic.code
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(l:loclist, l:loclist_item)
|
call add(l:loclist, l:loclist_item)
|
||||||
@ -70,7 +75,12 @@ function! ale#lsp#response#ReadTSServerDiagnostics(response) abort
|
|||||||
\}
|
\}
|
||||||
|
|
||||||
if has_key(l:diagnostic, 'code')
|
if has_key(l:diagnostic, 'code')
|
||||||
let l:loclist_item.nr = l:diagnostic.code
|
if type(l:diagnostic.code) == v:t_string
|
||||||
|
let l:loclist_item.code = l:diagnostic.code
|
||||||
|
elseif type(l:diagnostic.code) == v:t_number && l:diagnostic.code != -1
|
||||||
|
let l:loclist_item.code = string(l:diagnostic.code)
|
||||||
|
let l:loclist_item.nr = l:diagnostic.code
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get(l:diagnostic, 'category') is# 'warning'
|
if get(l:diagnostic, 'category') is# 'warning'
|
||||||
|
@ -2328,6 +2328,13 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()*
|
|||||||
`type` - Defaults to `'E'`.
|
`type` - Defaults to `'E'`.
|
||||||
`nr` - Defaults to `-1`.
|
`nr` - Defaults to `-1`.
|
||||||
|
|
||||||
|
Numeric error code. If `nr` is not `-1`, `code`
|
||||||
|
likely should contain the string representation of
|
||||||
|
the same value.
|
||||||
|
`code` - No default; may be unset.
|
||||||
|
|
||||||
|
Human-readable |String| error code.
|
||||||
|
|
||||||
`executable` A |String| naming the executable itself which
|
`executable` A |String| naming the executable itself which
|
||||||
will be run. This value will be used to check if the
|
will be run. This value will be used to check if the
|
||||||
program requested is installed or not.
|
program requested is installed or not.
|
||||||
|
@ -18,7 +18,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle errors):
|
|||||||
\ 'col': 11,
|
\ 'col': 11,
|
||||||
\ 'end_lnum': 5,
|
\ 'end_lnum': 5,
|
||||||
\ 'end_col': 16,
|
\ 'end_col': 16,
|
||||||
\ 'nr': 'some-error',
|
\ 'code': 'some-error',
|
||||||
\ }
|
\ }
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
||||||
@ -39,7 +39,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle warnings):
|
|||||||
\ 'col': 4,
|
\ 'col': 4,
|
||||||
\ 'end_lnum': 2,
|
\ 'end_lnum': 2,
|
||||||
\ 'end_col': 4,
|
\ 'end_col': 4,
|
||||||
\ 'nr': 'some-warning',
|
\ 'code': 'some-warning',
|
||||||
\ }
|
\ }
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
||||||
@ -60,7 +60,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing se
|
|||||||
\ 'col': 11,
|
\ 'col': 11,
|
||||||
\ 'end_lnum': 5,
|
\ 'end_lnum': 5,
|
||||||
\ 'end_col': 16,
|
\ 'end_col': 16,
|
||||||
\ 'nr': 'some-error',
|
\ 'code': 'some-error',
|
||||||
\ }
|
\ }
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
||||||
@ -89,6 +89,26 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes)
|
|||||||
\ },
|
\ },
|
||||||
\ ]}})
|
\ ]}})
|
||||||
|
|
||||||
|
Execute(ale#lsp#response#ReadDiagnostics() should consider -1 to be a meaningless code):
|
||||||
|
AssertEqual [
|
||||||
|
\ {
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'text': 'Something went wrong!',
|
||||||
|
\ 'lnum': 3,
|
||||||
|
\ 'col': 11,
|
||||||
|
\ 'end_lnum': 5,
|
||||||
|
\ 'end_col': 16,
|
||||||
|
\ }
|
||||||
|
\ ],
|
||||||
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
||||||
|
\ {
|
||||||
|
\ 'range': Range(2, 10, 4, 15),
|
||||||
|
\ 'message': 'Something went wrong!',
|
||||||
|
\ 'code': -1,
|
||||||
|
\ },
|
||||||
|
\ ]}})
|
||||||
|
|
||||||
|
|
||||||
Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
|
Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
|
||||||
AssertEqual [
|
AssertEqual [
|
||||||
\ {
|
\ {
|
||||||
@ -126,6 +146,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver respon
|
|||||||
\ {
|
\ {
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'nr': 2365,
|
\ 'nr': 2365,
|
||||||
|
\ 'code': '2365',
|
||||||
\ 'text': 'Operator ''''+'''' cannot be applied to types ''''3'''' and ''''{}''''.',
|
\ 'text': 'Operator ''''+'''' cannot be applied to types ''''3'''' and ''''{}''''.',
|
||||||
\ 'lnum': 1,
|
\ 'lnum': 1,
|
||||||
\ 'col': 11,
|
\ 'col': 11,
|
||||||
@ -142,6 +163,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle warnings from t
|
|||||||
\ 'lnum': 27,
|
\ 'lnum': 27,
|
||||||
\ 'col': 3,
|
\ 'col': 3,
|
||||||
\ 'nr': 2515,
|
\ 'nr': 2515,
|
||||||
|
\ 'code': '2515',
|
||||||
\ 'end_lnum': 27,
|
\ 'end_lnum': 27,
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ 'end_col': 14,
|
\ 'end_col': 14,
|
||||||
@ -157,6 +179,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle suggestions fro
|
|||||||
\ 'lnum': 27,
|
\ 'lnum': 27,
|
||||||
\ 'col': 3,
|
\ 'col': 3,
|
||||||
\ 'nr': 2515,
|
\ 'nr': 2515,
|
||||||
|
\ 'code': '2515',
|
||||||
\ 'end_lnum': 27,
|
\ 'end_lnum': 27,
|
||||||
\ 'type': 'I',
|
\ 'type': 'I',
|
||||||
\ 'end_col': 14,
|
\ 'end_col': 14,
|
||||||
|
@ -62,6 +62,7 @@ Execute(tsserver syntax error responses should be handled correctly):
|
|||||||
\ 'col': 14,
|
\ 'col': 14,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'nr': 1005,
|
\ 'nr': 1005,
|
||||||
|
\ 'code': '1005',
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'text': ''','' expected.',
|
\ 'text': ''','' expected.',
|
||||||
\ 'valid': 1,
|
\ 'valid': 1,
|
||||||
@ -135,6 +136,7 @@ Execute(tsserver semantic error responses should be handled correctly):
|
|||||||
\ 'col': 14,
|
\ 'col': 14,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'nr': 1005,
|
\ 'nr': 1005,
|
||||||
|
\ 'code': '1005',
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'text': 'Some semantic error',
|
\ 'text': 'Some semantic error',
|
||||||
\ 'valid': 1,
|
\ 'valid': 1,
|
||||||
|
@ -190,6 +190,7 @@ Execute(Buffer ignore lists should be applied for tsserver):
|
|||||||
\ 'lnum': 2,
|
\ 'lnum': 2,
|
||||||
\ 'col': 14,
|
\ 'col': 14,
|
||||||
\ 'nr': 1005,
|
\ 'nr': 1005,
|
||||||
|
\ 'code': '1005',
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'end_col': 15,
|
\ 'end_col': 15,
|
||||||
\ 'end_lnum': 2,
|
\ 'end_lnum': 2,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user