summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-08-14 01:55:48 +0100
committerw0rp <devw0rp@gmail.com>2020-08-14 01:55:54 +0100
commit5a4fad6172472fd2cc316ff72b827ed726e69a5b (patch)
tree5e47df5ecc0e956d9b10b589d9d8a403848a2a90 /autoload
parent2b2403a20d59ea4207be01ca308ec43a90e9453f (diff)
downloadale-5a4fad6172472fd2cc316ff72b827ed726e69a5b.zip
Fix #2899 - Handle tsserver default import completion
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/completion.vim18
1 files changed, 17 insertions, 1 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index bffcdc8a..a273d4e1 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -418,12 +418,22 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
for l:suggestion in a:response.body
let l:displayParts = []
+ let l:local_name = v:null
for l:action in get(l:suggestion, 'codeActions', [])
call add(l:displayParts, l:action.description . ' ')
endfor
for l:part in l:suggestion.displayParts
+ " Stop on stop on line breaks for the menu.
+ if get(l:part, 'kind') is# 'lineBreak'
+ break
+ endif
+
+ if get(l:part, 'kind') is# 'localName'
+ let l:local_name = l:part.text
+ endif
+
call add(l:displayParts, l:part.text)
endfor
@@ -436,7 +446,13 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
" See :help complete-items
let l:result = {
- \ 'word': l:suggestion.name,
+ \ 'word': (
+ \ l:suggestion.name is# 'default'
+ \ && l:suggestion.kind is# 'alias'
+ \ && !empty(l:local_name)
+ \ ? l:local_name
+ \ : l:suggestion.name
+ \ ),
\ 'kind': ale#completion#GetCompletionSymbols(l:suggestion.kind),
\ 'icase': 1,
\ 'menu': join(l:displayParts, ''),