mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-27 21:32:18 +08:00
Close #3267 - Add a general autoimport setting
This commit is contained in:
@@ -121,7 +121,7 @@ Execute(The right message should be sent for the initial tsserver request):
|
||||
\ 'line': 1,
|
||||
\ 'offset': 3,
|
||||
\ 'prefix': 'fo',
|
||||
\ 'includeExternalModuleExports': g:ale_completion_tsserver_autoimport,
|
||||
\ 'includeExternalModuleExports': g:ale_completion_autoimport,
|
||||
\ }]],
|
||||
\ g:message_list
|
||||
" We should set up the completion info correctly.
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
Before:
|
||||
Save g:ale_completion_autoimport
|
||||
Save g:ale_completion_max_suggestions
|
||||
|
||||
let g:ale_completion_max_suggestions = 50
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:ale_completion_info
|
||||
|
||||
Execute(Should handle Rust completion results correctly):
|
||||
@@ -527,7 +535,9 @@ Execute(Should handle completion messages with the deprecated insertText attribu
|
||||
\ },
|
||||
\ })
|
||||
|
||||
Execute(Should handle completion messages with additionalTextEdits):
|
||||
Execute(Should handle completion messages with additionalTextEdits when ale_completion_autoimport is turned on):
|
||||
let g:ale_completion_autoimport = 1
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
@@ -596,3 +606,42 @@ Execute(Should handle completion messages with additionalTextEdits):
|
||||
\ ],
|
||||
\ },
|
||||
\ })
|
||||
|
||||
Execute(Should not handle completion messages with additionalTextEdits when ale_completion_autoimport is turned off):
|
||||
let g:ale_completion_autoimport = 0
|
||||
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ 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',
|
||||
\ 'additionalTextEdits': [
|
||||
\ {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 10,
|
||||
\ 'character': 1,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 12,
|
||||
\ 'character': 3,
|
||||
\ },
|
||||
\ },
|
||||
\ 'newText': 'from "module" import next_callback',
|
||||
\ },
|
||||
\ ],
|
||||
\ },
|
||||
\ ],
|
||||
\ },
|
||||
\ })
|
||||
|
||||
@@ -83,7 +83,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
|
||||
\ 'info': '',
|
||||
\ 'kind': 'v',
|
||||
\ 'icase': 1,
|
||||
\ 'dup': g:ale_completion_tsserver_autoimport,
|
||||
\ 'dup': g:ale_completion_autoimport,
|
||||
\ },
|
||||
\ {
|
||||
\ 'word': 'def',
|
||||
@@ -91,7 +91,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
|
||||
\ 'info': 'foo bar baz',
|
||||
\ 'kind': 'v',
|
||||
\ 'icase': 1,
|
||||
\ 'dup': g:ale_completion_tsserver_autoimport,
|
||||
\ 'dup': g:ale_completion_autoimport,
|
||||
\ },
|
||||
\ {
|
||||
\ 'word': 'ghi',
|
||||
@@ -99,7 +99,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
|
||||
\ 'info': '',
|
||||
\ 'kind': 'v',
|
||||
\ 'icase': 1,
|
||||
\ 'dup': g:ale_completion_tsserver_autoimport,
|
||||
\ 'dup': g:ale_completion_autoimport,
|
||||
\ },
|
||||
\ ],
|
||||
\ ale#completion#ParseTSServerCompletionEntryDetails({
|
||||
@@ -177,7 +177,7 @@ Execute(Entries without details should be included in the responses):
|
||||
\ 'changes': [],
|
||||
\ }],
|
||||
\ }),
|
||||
\ 'dup': g:ale_completion_tsserver_autoimport,
|
||||
\ 'dup': g:ale_completion_autoimport,
|
||||
\ },
|
||||
\ {
|
||||
\ 'word': 'def',
|
||||
@@ -185,7 +185,7 @@ Execute(Entries without details should be included in the responses):
|
||||
\ 'info': 'foo bar baz',
|
||||
\ 'kind': 'v',
|
||||
\ 'icase': 1,
|
||||
\ 'dup': g:ale_completion_tsserver_autoimport,
|
||||
\ 'dup': g:ale_completion_autoimport,
|
||||
\ },
|
||||
\ {
|
||||
\ 'word': 'xyz',
|
||||
|
||||
Reference in New Issue
Block a user