mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-28 20:42:26 +08:00
Fix completion with langserver (autoimport in go)
This commit is contained in:
@@ -523,13 +523,45 @@ function! ale#completion#ParseLSPCompletions(response) abort
|
|||||||
let l:doc = l:doc.value
|
let l:doc = l:doc.value
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(l:results, {
|
let l:result = {
|
||||||
\ 'word': l:word,
|
\ 'word': l:word,
|
||||||
\ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')),
|
\ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')),
|
||||||
\ 'icase': 1,
|
\ 'icase': 1,
|
||||||
\ 'menu': get(l:item, 'detail', ''),
|
\ 'menu': get(l:item, 'detail', ''),
|
||||||
\ 'info': (type(l:doc) is v:t_string ? l:doc : ''),
|
\ 'info': (type(l:doc) is v:t_string ? l:doc : ''),
|
||||||
\})
|
\}
|
||||||
|
|
||||||
|
if has_key(l:item, 'additionalTextEdits')
|
||||||
|
let l:text_changes = []
|
||||||
|
for l:edit in l:item.additionalTextEdits
|
||||||
|
let l:range = l:edit.range
|
||||||
|
call add(l:text_changes, {
|
||||||
|
\ 'start': {
|
||||||
|
\ 'line': l:range.start.line + 1,
|
||||||
|
\ 'offset': l:range.start.character + 1,
|
||||||
|
\ },
|
||||||
|
\ 'end': {
|
||||||
|
\ 'line': l:range.end.line + 1,
|
||||||
|
\ 'offset': l:range.end.character + 1,
|
||||||
|
\ },
|
||||||
|
\ 'newText': l:edit.newText,
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
let l:changes = [{
|
||||||
|
\ 'fileName': expand('%:p'),
|
||||||
|
\ 'textChanges': l:text_changes,
|
||||||
|
\}]
|
||||||
|
\
|
||||||
|
let l:result.user_data = json_encode({
|
||||||
|
\ 'codeActions': [{
|
||||||
|
\ 'description': 'completion',
|
||||||
|
\ 'changes': l:changes,
|
||||||
|
\ }],
|
||||||
|
\ })
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(l:results, l:result)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
if has_key(l:info, 'prefix')
|
if has_key(l:info, 'prefix')
|
||||||
|
|||||||
Reference in New Issue
Block a user