summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/completion.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index c3139da5..a338ce76 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -30,6 +30,7 @@ let s:LSP_COMPLETION_REFERENCE_KIND = 18
" the insert cursor is. If one of these matches, we'll check for completions.
let s:should_complete_map = {
\ '<default>': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$',
+\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$',
\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$',
\}
@@ -41,6 +42,7 @@ let s:omni_start_map = {
" A map of exact characters for triggering LSP completions.
let s:trigger_character_map = {
\ '<default>': ['.'],
+\ 'typescript': ['.', '''', '"'],
\ 'rust': ['.', '::'],
\}
@@ -198,7 +200,9 @@ function! ale#completion#ParseTSServerCompletions(response) abort
endfunction
function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
+ let l:buffer = bufnr('')
let l:results = []
+ let l:names_with_details = []
for l:suggestion in a:response.body
let l:displayParts = []
@@ -232,6 +236,26 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
\})
endfor
+ let l:names = getbufvar(l:buffer, 'ale_tsserver_completion_names', [])
+
+ if !empty(l:names) && len(l:names) != len(l:results)
+ let l:names_with_details = map(copy(l:results), 'v:val.word')
+ let l:missing_names = filter(
+ \ copy(l:names),
+ \ 'index(l:names_with_details, v:val) < 0',
+ \)
+
+ for l:name in l:missing_names
+ call add(l:results, {
+ \ 'word': l:name,
+ \ 'kind': 'v',
+ \ 'icase': 1,
+ \ 'menu': '',
+ \ 'info': '',
+ \})
+ endfor
+ endif
+
return l:results
endfunction
@@ -322,6 +346,10 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort
\ b:ale_completion_info.prefix,
\)[: g:ale_completion_max_suggestions - 1]
+ " We need to remember some names for tsserver, as it doesn't send
+ " details back for everything we send.
+ call setbufvar(l:buffer, 'ale_tsserver_completion_names', l:names)
+
if !empty(l:names)
let b:ale_completion_info.request_id = ale#lsp#Send(
\ b:ale_completion_info.conn_id,