mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-23 20:41:29 +08:00
This commit adds support for renaming symbols in tsserver and with LSP tools, and for organising imports with tsserver. Completion results for symbols that can be imported are now suggested if enabled for tsserver completion done via ALE.
200 lines
4.5 KiB
Plaintext
200 lines
4.5 KiB
Plaintext
After:
|
|
unlet! b:ale_tsserver_completion_names
|
|
|
|
Execute(TypeScript completions responses should be parsed correctly):
|
|
AssertEqual [],
|
|
\ ale#completion#ParseTSServerCompletions({
|
|
\ 'body': [],
|
|
\})
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'word': 'foo',
|
|
\ 'source': '/path/to/foo.ts',
|
|
\ },
|
|
\ {
|
|
\ 'word': 'bar',
|
|
\ 'source': '',
|
|
\ },
|
|
\ {
|
|
\ 'word': 'baz',
|
|
\ 'source': '',
|
|
\ }
|
|
\ ],
|
|
\ ale#completion#ParseTSServerCompletions({
|
|
\ 'body': [
|
|
\ {'name': 'foo', 'source': '/path/to/foo.ts'},
|
|
\ {'name': 'bar'},
|
|
\ {'name': 'baz'},
|
|
\ ],
|
|
\})
|
|
|
|
Execute(TypeScript completion details responses should be parsed correctly):
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'word': 'abc',
|
|
\ 'menu': '(property) Foo.abc: number',
|
|
\ 'info': '',
|
|
\ 'kind': 'f',
|
|
\ 'icase': 1,
|
|
\ 'dup': g:ale_completion_tsserver_autoimport,
|
|
\ },
|
|
\ {
|
|
\ 'word': 'def',
|
|
\ 'menu': '(property) Foo.def: number',
|
|
\ 'info': 'foo bar baz',
|
|
\ 'kind': 'f',
|
|
\ 'icase': 1,
|
|
\ 'dup': g:ale_completion_tsserver_autoimport,
|
|
\ },
|
|
\ {
|
|
\ 'word': 'ghi',
|
|
\ 'menu': '(class) Foo',
|
|
\ 'info': '',
|
|
\ 'kind': 'f',
|
|
\ 'icase': 1,
|
|
\ 'dup': g:ale_completion_tsserver_autoimport,
|
|
\ },
|
|
\ ],
|
|
\ ale#completion#ParseTSServerCompletionEntryDetails({
|
|
\ 'body': [
|
|
\ {
|
|
\ 'name': 'abc',
|
|
\ 'kind': 'parameterName',
|
|
\ 'displayParts': [
|
|
\ {'text': '('},
|
|
\ {'text': 'property'},
|
|
\ {'text': ')'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'Foo'},
|
|
\ {'text': '.'},
|
|
\ {'text': 'abc'},
|
|
\ {'text': ':'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'number'},
|
|
\ ],
|
|
\ },
|
|
\ {
|
|
\ 'name': 'def',
|
|
\ 'kind': 'parameterName',
|
|
\ 'displayParts': [
|
|
\ {'text': '('},
|
|
\ {'text': 'property'},
|
|
\ {'text': ')'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'Foo'},
|
|
\ {'text': '.'},
|
|
\ {'text': 'def'},
|
|
\ {'text': ':'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'number'},
|
|
\ ],
|
|
\ 'documentation': [
|
|
\ {'text': 'foo'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'bar'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'baz'},
|
|
\ ],
|
|
\ },
|
|
\ {
|
|
\ 'name': 'ghi',
|
|
\ 'kind': 'className',
|
|
\ 'displayParts': [
|
|
\ {'text': '('},
|
|
\ {'text': 'class'},
|
|
\ {'text': ')'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'Foo'},
|
|
\ ],
|
|
\ },
|
|
\ ],
|
|
\})
|
|
|
|
Execute(Entries without details should be included in the responses):
|
|
let b:ale_tsserver_completion_names = [{
|
|
\ 'word': 'xyz',
|
|
\ 'source': '/path/to/xyz.ts',
|
|
\ }]
|
|
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'word': 'abc',
|
|
\ 'menu': '(property) Foo.abc: number',
|
|
\ 'info': '',
|
|
\ 'kind': 'f',
|
|
\ 'icase': 1,
|
|
\ 'user_data': json_encode({
|
|
\ 'codeActions': [{
|
|
\ 'description': 'abc action',
|
|
\ 'changes': [],
|
|
\ }],
|
|
\ }),
|
|
\ 'dup': g:ale_completion_tsserver_autoimport,
|
|
\ },
|
|
\ {
|
|
\ 'word': 'def',
|
|
\ 'menu': '(property) Foo.def: number',
|
|
\ 'info': 'foo bar baz',
|
|
\ 'kind': 'f',
|
|
\ 'icase': 1,
|
|
\ 'dup': g:ale_completion_tsserver_autoimport,
|
|
\ },
|
|
\ {
|
|
\ 'word': 'xyz',
|
|
\ 'menu': '',
|
|
\ 'info': '',
|
|
\ 'kind': 'v',
|
|
\ 'icase': 1,
|
|
\ },
|
|
\ ],
|
|
\ ale#completion#ParseTSServerCompletionEntryDetails({
|
|
\ 'body': [
|
|
\ {
|
|
\ 'name': 'abc',
|
|
\ 'kind': 'parameterName',
|
|
\ 'displayParts': [
|
|
\ {'text': '('},
|
|
\ {'text': 'property'},
|
|
\ {'text': ')'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'Foo'},
|
|
\ {'text': '.'},
|
|
\ {'text': 'abc'},
|
|
\ {'text': ':'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'number'},
|
|
\ ],
|
|
\ 'codeActions': [{
|
|
\ 'description': 'abc action',
|
|
\ 'changes': [],
|
|
\ }],
|
|
\ },
|
|
\ {
|
|
\ 'name': 'def',
|
|
\ 'kind': 'parameterName',
|
|
\ 'displayParts': [
|
|
\ {'text': '('},
|
|
\ {'text': 'property'},
|
|
\ {'text': ')'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'Foo'},
|
|
\ {'text': '.'},
|
|
\ {'text': 'def'},
|
|
\ {'text': ':'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'number'},
|
|
\ ],
|
|
\ 'documentation': [
|
|
\ {'text': 'foo'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'bar'},
|
|
\ {'text': ' '},
|
|
\ {'text': 'baz'},
|
|
\ ],
|
|
\ },
|
|
\ ],
|
|
\})
|