summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Emmott <fe@fb.com>2018-08-15 14:19:32 -0700
committerFred Emmott <fe@fb.com>2018-08-15 14:19:32 -0700
commit484a70f0c0c9109ab6825fa67e481d862237207c (patch)
tree647f6edac2266727818fe1c4202726a8e7ee8756
parent9cdd8b67b2f52a2dd348ffb13a7fc1b2dcf84416 (diff)
downloadale-484a70f0c0c9109ab6825fa67e481d862237207c.zip
Use new-ish LSP 'relatedInformation' field for :ALEDetail
-rw-r--r--autoload/ale/lsp/response.vim10
-rw-r--r--test/lsp/test_read_lsp_diagnostics.vader29
2 files changed, 39 insertions, 0 deletions
diff --git a/autoload/ale/lsp/response.vim b/autoload/ale/lsp/response.vim
index 561be62e..7984369d 100644
--- a/autoload/ale/lsp/response.vim
+++ b/autoload/ale/lsp/response.vim
@@ -55,6 +55,16 @@ function! ale#lsp#response#ReadDiagnostics(response) abort
endif
endif
+ if has_key(l:diagnostic, 'relatedInformation')
+ let l:related = deepcopy(l:diagnostic.relatedInformation)
+ call map(l:related, {key, val ->
+ \ ale#path#FromURI(val.location.uri)) .
+ \ ':' . val.location.range.start.line . ':' . val.location.range.start.character .
+ \ ': ' . val.message
+ \ })
+ let l:loclist_item.detail = join(l:related, "\n") . "\n"
+ endif
+
call add(l:loclist, l:loclist_item)
endfor
diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader
index df187a24..c1df55f0 100644
--- a/test/lsp/test_read_lsp_diagnostics.vader
+++ b/test/lsp/test_read_lsp_diagnostics.vader
@@ -140,6 +140,35 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
\ },
\ ]}})
+Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for detail):
+ AssertEqual [
+ \ {
+ \ 'type': 'E',
+ \ 'text': 'Something went wrong!',
+ \ 'lnum': 1,
+ \ 'col': 3,
+ \ 'end_lnum': 1,
+ \ 'end_col': 3,
+ \ 'relatedInformation': [{
+ \ 'message': 'might be this',
+ \ 'location': {
+ \ 'uri': 'file:///tmp/someotherfile.txt',
+ \ 'range': {
+ \ 'start': { 'line': 42, 'character': 79 },
+ \ 'end': { 'line': 43, 'character': 80 },
+ \ }
+ \ }
+ \ }]
+ \ }
+ \ ],
+ \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
+ \ {
+ \ 'range': Range(0, 2, 0, 2),
+ \ 'message': 'Something went wrong!',
+ \ 'detail': 'file:///tmp/someotherfile.txt:42:79: might be this'
+ \ }
+ \ ]}})
+
Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses):
AssertEqual
\ [