summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-09-17 11:16:46 +0100
committerw0rp <devw0rp@gmail.com>2018-09-17 11:16:46 +0100
commitf9e99d81a4187a0d017d5db3aaa5c4bbfe3ecc54 (patch)
treeff41833ff95af1d3781f5f49e1d7acc6a2243299
parent1a13963f0ddd9fe2c311a716bfc6d0884b8451a7 (diff)
downloadale-f9e99d81a4187a0d017d5db3aaa5c4bbfe3ecc54.zip
#1794 - Handle LSP documentation content as a Dictionary
-rw-r--r--autoload/ale/completion.vim8
-rw-r--r--test/completion/test_lsp_completion_parsing.vader24
2 files changed, 31 insertions, 1 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index 2556d50c..9dd913f5 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -360,12 +360,18 @@ function! ale#completion#ParseLSPCompletions(response) abort
let l:kind = 'v'
endif
+ let l:doc = get(l:item, 'documentation', '')
+
+ if type(l:doc) is v:t_dict && has_key(l:doc, 'value')
+ let l:doc = l:doc.value
+ endif
+
call add(l:results, {
\ 'word': l:word,
\ 'kind': l:kind,
\ 'icase': 1,
\ 'menu': get(l:item, 'detail', ''),
- \ 'info': get(l:item, 'documentation', ''),
+ \ 'info': (type(l:doc) is v:t_string ? l:doc : ''),
\})
endfor
diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader
index d5a45b54..71e53ab6 100644
--- a/test/completion/test_lsp_completion_parsing.vader
+++ b/test/completion/test_lsp_completion_parsing.vader
@@ -447,3 +447,27 @@ Execute(Should handle missing keys):
\ ]
\ }
\ })
+
+Execute(Should handle documentation in the markdown format):
+ AssertEqual
+ \ [
+ \ {'word': 'migrations', 'menu': 'xxx', 'info': 'Markdown documentation', 'kind': 'f', 'icase': 1},
+ \ ],
+ \ ale#completion#ParseLSPCompletions({
+ \ 'jsonrpc': '2.0',
+ \ 'id': 6,
+ \ 'result': {
+ \ 'isIncomplete': v:false,
+ \ 'items': [
+ \ {
+ \ 'label': 'migrations',
+ \ 'kind': 3,
+ \ 'detail': 'xxx',
+ \ 'documentation': {
+ \ 'kind': 'markdown',
+ \ 'value': 'Markdown documentation',
+ \ },
+ \ },
+ \ ],
+ \ },
+ \ })