Add ALERename (tsserver & LSP), ALEOrganizeImports (tsserver) and auto import support (tsserver) (#2709)

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.
This commit is contained in:
Jerko Steiner
2019-09-13 03:53:23 +07:00
committed by w0rp
parent b66d202c1d
commit 3e8c8d3ccb
20 changed files with 1633 additions and 17 deletions

View File

@@ -6,10 +6,24 @@ Execute(TypeScript completions responses should be parsed correctly):
\ ale#completion#ParseTSServerCompletions({
\ 'body': [],
\})
AssertEqual ['foo', 'bar', 'baz'],
AssertEqual
\ [
\ {
\ 'word': 'foo',
\ 'source': '/path/to/foo.ts',
\ },
\ {
\ 'word': 'bar',
\ 'source': '',
\ },
\ {
\ 'word': 'baz',
\ 'source': '',
\ }
\ ],
\ ale#completion#ParseTSServerCompletions({
\ 'body': [
\ {'name': 'foo'},
\ {'name': 'foo', 'source': '/path/to/foo.ts'},
\ {'name': 'bar'},
\ {'name': 'baz'},
\ ],
@@ -24,6 +38,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': '',
\ 'kind': 'f',
\ 'icase': 1,
\ 'dup': g:ale_completion_tsserver_autoimport,
\ },
\ {
\ 'word': 'def',
@@ -31,6 +46,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': 'foo bar baz',
\ 'kind': 'f',
\ 'icase': 1,
\ 'dup': g:ale_completion_tsserver_autoimport,
\ },
\ {
\ 'word': 'ghi',
@@ -38,6 +54,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': '',
\ 'kind': 'f',
\ 'icase': 1,
\ 'dup': g:ale_completion_tsserver_autoimport,
\ },
\ ],
\ ale#completion#ParseTSServerCompletionEntryDetails({
@@ -96,7 +113,10 @@ Execute(TypeScript completion details responses should be parsed correctly):
\})
Execute(Entries without details should be included in the responses):
let b:ale_tsserver_completion_names = ['xyz']
let b:ale_tsserver_completion_names = [{
\ 'word': 'xyz',
\ 'source': '/path/to/xyz.ts',
\ }]
AssertEqual
\ [
@@ -106,6 +126,13 @@ Execute(Entries without details should be included in the responses):
\ 'info': '',
\ 'kind': 'f',
\ 'icase': 1,
\ 'user_data': json_encode({
\ 'codeActions': [{
\ 'description': 'abc action',
\ 'changes': [],
\ }],
\ }),
\ 'dup': g:ale_completion_tsserver_autoimport,
\ },
\ {
\ 'word': 'def',
@@ -113,6 +140,7 @@ Execute(Entries without details should be included in the responses):
\ 'info': 'foo bar baz',
\ 'kind': 'f',
\ 'icase': 1,
\ 'dup': g:ale_completion_tsserver_autoimport,
\ },
\ {
\ 'word': 'xyz',
@@ -139,6 +167,10 @@ Execute(Entries without details should be included in the responses):
\ {'text': ' '},
\ {'text': 'number'},
\ ],
\ 'codeActions': [{
\ 'description': 'abc action',
\ 'changes': [],
\ }],
\ },
\ {
\ 'name': 'def',