mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-17 17:55:56 +08:00
#2341 - Handle completion messages with textEdit objects
This commit is contained in:
@@ -39,6 +39,9 @@ let s:LSP_COMPLETION_COLOR_KIND = 16
|
|||||||
let s:LSP_COMPLETION_FILE_KIND = 17
|
let s:LSP_COMPLETION_FILE_KIND = 17
|
||||||
let s:LSP_COMPLETION_REFERENCE_KIND = 18
|
let s:LSP_COMPLETION_REFERENCE_KIND = 18
|
||||||
|
|
||||||
|
let s:LSP_INSERT_TEXT_FORMAT_PLAIN = 1
|
||||||
|
let s:LSP_INSERT_TEXT_FORMAT_SNIPPET = 2
|
||||||
|
|
||||||
let s:lisp_regex = '\v[a-zA-Z_\-][a-zA-Z_\-0-9]*$'
|
let s:lisp_regex = '\v[a-zA-Z_\-][a-zA-Z_\-0-9]*$'
|
||||||
|
|
||||||
" Regular expressions for checking the characters in the line before where
|
" Regular expressions for checking the characters in the line before where
|
||||||
@@ -350,7 +353,14 @@ function! ale#completion#ParseLSPCompletions(response) abort
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:word = matchstr(l:item.label, '\v^[^(]+')
|
if get(l:item, 'insertTextFormat') is s:LSP_INSERT_TEXT_FORMAT_PLAIN
|
||||||
|
\&& type(get(l:item, 'textEdit')) is v:t_dict
|
||||||
|
let l:text = l:item.textEdit.newText
|
||||||
|
else
|
||||||
|
let l:text = l:item.label
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:word = matchstr(l:text, '\v^[^(]+')
|
||||||
|
|
||||||
if empty(l:word)
|
if empty(l:word)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -471,3 +471,34 @@ Execute(Should handle documentation in the markdown format):
|
|||||||
\ ],
|
\ ],
|
||||||
\ },
|
\ },
|
||||||
\ })
|
\ })
|
||||||
|
|
||||||
|
Execute(Should handle completion messages with textEdit objects):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'word': 'next_callback', 'menu': 'PlayTimeCallback', 'info': '', 'kind': 'v', 'icase': 1},
|
||||||
|
\ ],
|
||||||
|
\ ale#completion#ParseLSPCompletions({
|
||||||
|
\ 'id': 226,
|
||||||
|
\ 'jsonrpc': '2.0',
|
||||||
|
\ 'result': {
|
||||||
|
\ 'isIncomplete': v:false,
|
||||||
|
\ 'items': [
|
||||||
|
\ {
|
||||||
|
\ 'detail': 'PlayTimeCallback',
|
||||||
|
\ 'filterText': 'next_callback',
|
||||||
|
\ 'insertText': 'next_callback',
|
||||||
|
\ 'insertTextFormat': 1,
|
||||||
|
\ 'kind': 6,
|
||||||
|
\ 'label': ' next_callback',
|
||||||
|
\ 'sortText': '3ee19999next_callback',
|
||||||
|
\ 'textEdit': {
|
||||||
|
\ 'newText': 'next_callback',
|
||||||
|
\ 'range': {
|
||||||
|
\ 'end': {'character': 13, 'line': 12},
|
||||||
|
\ 'start': {'character': 4, 'line': 12},
|
||||||
|
\ },
|
||||||
|
\ },
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ },
|
||||||
|
\ })
|
||||||
|
|||||||
Reference in New Issue
Block a user