summaryrefslogtreecommitdiff
path: root/test/lsp
diff options
context:
space:
mode:
Diffstat (limited to 'test/lsp')
-rw-r--r--test/lsp/test_lsp_client_messages.vader24
-rw-r--r--test/lsp/test_lsp_command_formatting.vader1
-rw-r--r--test/lsp/test_lsp_root_detection.vader63
-rw-r--r--test/lsp/test_read_lsp_diagnostics.vader18
4 files changed, 92 insertions, 14 deletions
diff --git a/test/lsp/test_lsp_client_messages.vader b/test/lsp/test_lsp_client_messages.vader
index 71768ce5..bdede460 100644
--- a/test/lsp/test_lsp_client_messages.vader
+++ b/test/lsp/test_lsp_client_messages.vader
@@ -112,7 +112,7 @@ Execute(ale#lsp#message#Completion() should return correct messages):
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ },
- \ 'position': {'line': 11, 'character': 34},
+ \ 'position': {'line': 11, 'character': 33},
\ }
\ ],
\ ale#lsp#message#Completion(bufnr(''), 12, 34, '')
@@ -126,7 +126,7 @@ Execute(ale#lsp#message#Completion() should return correct messages with a trigg
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ },
- \ 'position': {'line': 11, 'character': 34},
+ \ 'position': {'line': 11, 'character': 33},
\ 'context': {'triggerKind': 2, 'triggerCharacter': '.'},
\ }
\ ],
@@ -141,11 +141,25 @@ Execute(ale#lsp#message#Definition() should return correct messages):
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ },
- \ 'position': {'line': 11, 'character': 34},
+ \ 'position': {'line': 11, 'character': 33},
\ }
\ ],
\ ale#lsp#message#Definition(bufnr(''), 12, 34)
+Execute(ale#lsp#message#TypeDefinition() should return correct messages):
+ AssertEqual
+ \ [
+ \ 0,
+ \ 'textDocument/typeDefinition',
+ \ {
+ \ 'textDocument': {
+ \ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
+ \ },
+ \ 'position': {'line': 11, 'character': 33},
+ \ }
+ \ ],
+ \ ale#lsp#message#TypeDefinition(bufnr(''), 12, 34)
+
Execute(ale#lsp#message#References() should return correct messages):
AssertEqual
\ [
@@ -155,7 +169,7 @@ Execute(ale#lsp#message#References() should return correct messages):
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ },
- \ 'position': {'line': 11, 'character': 34},
+ \ 'position': {'line': 11, 'character': 33},
\ 'context': {'includeDeclaration': v:false},
\ }
\ ],
@@ -181,7 +195,7 @@ Execute(ale#lsp#message#Hover() should return correct messages):
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ },
- \ 'position': {'line': 11, 'character': 34},
+ \ 'position': {'line': 11, 'character': 33},
\ }
\ ],
\ ale#lsp#message#Hover(bufnr(''), 12, 34)
diff --git a/test/lsp/test_lsp_command_formatting.vader b/test/lsp/test_lsp_command_formatting.vader
index 9721f37f..fcd4f78c 100644
--- a/test/lsp/test_lsp_command_formatting.vader
+++ b/test/lsp/test_lsp_command_formatting.vader
@@ -17,6 +17,7 @@ Execute(Command formatting should be applied correctly for LSP linters):
call ale#lsp_linter#StartLSP(
\ bufnr(''),
\ {
+ \ 'name': 'linter',
\ 'language_callback': {-> 'x'},
\ 'project_root_callback': {-> '/foo/bar'},
\ 'lsp': 'stdio',
diff --git a/test/lsp/test_lsp_root_detection.vader b/test/lsp/test_lsp_root_detection.vader
new file mode 100644
index 00000000..2575a62c
--- /dev/null
+++ b/test/lsp/test_lsp_root_detection.vader
@@ -0,0 +1,63 @@
+Before:
+ call ale#assert#SetUpLinterTest('c', 'clangd')
+
+ function! Hook1(buffer)
+ return 'abc123'
+ endfunction
+
+After:
+ let g:ale_lsp_root = {}
+ unlet! b:ale_lsp_root
+ delfunction Hook1
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(The buffer-specific variable can be a string):
+ let b:ale_lsp_root = '/some/path'
+ call ale#test#SetFilename('other-file.c')
+
+ AssertLSPProjectFull '/some/path'
+
+Execute(The buffer-specific variable can be a dictionary):
+ let b:ale_lsp_root = {'clangd': '/some/path', 'golangserver': '/other/path'}
+ call ale#test#SetFilename('other-file.c')
+
+ AssertLSPProjectFull '/some/path'
+
+Execute(The buffer-specific variable can have funcrefs):
+ let b:ale_lsp_root = {'clangd': function('Hook1'), 'golangserver': '/path'}
+ call ale#test#SetFilename('other-file.c')
+
+ AssertLSPProjectFull 'abc123'
+
+Execute(The global variable can be a dictionary):
+ let g:ale_lsp_root = {'clangd': '/some/path', 'golangserver': '/other/path'}
+ call ale#test#SetFilename('other-file.c')
+
+ AssertLSPProjectFull '/some/path'
+
+Execute(The global variable can have funcrefs):
+ let g:ale_lsp_root = {'clangd': function('Hook1'), 'golangserver': '/path'}
+ call ale#test#SetFilename('other-file.c')
+
+ AssertLSPProjectFull 'abc123'
+
+Execute(The buffer-specific variable overrides the global variable):
+ let b:ale_lsp_root = {'clangd': '/some/path', 'golangserver': '/other/path'}
+ let g:ale_lsp_root = {'clangd': '/not/this/path', 'golangserver': '/elsewhere'}
+ call ale#test#SetFilename('other-file.c')
+
+ AssertLSPProjectFull '/some/path'
+
+Execute(The global variable is queried if the buffer-specific has no value):
+ let b:ale_lsp_root = {'golangserver': '/other/path'}
+ let g:ale_lsp_root = {'clangd': '/some/path', 'golangserver': '/elsewhere'}
+ call ale#test#SetFilename('other-file.c')
+
+ AssertLSPProjectFull '/some/path'
+
+
+Execute(The default hook value is acceptable):
+ call ale#test#SetFilename('other-file.c')
+
+ AssertLSPProjectFull ''
diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader
index a5c5ded3..c197e0c6 100644
--- a/test/lsp/test_read_lsp_diagnostics.vader
+++ b/test/lsp/test_read_lsp_diagnostics.vader
@@ -17,7 +17,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle errors):
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
- \ 'end_col': 16,
+ \ 'end_col': 15,
\ 'code': 'some-error',
\ }
\ ],
@@ -38,7 +38,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle warnings):
\ 'lnum': 2,
\ 'col': 4,
\ 'end_lnum': 2,
- \ 'end_col': 4,
+ \ 'end_col': 3,
\ 'code': 'some-warning',
\ }
\ ],
@@ -59,7 +59,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing se
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
- \ 'end_col': 16,
+ \ 'end_col': 15,
\ 'code': 'some-error',
\ }
\ ],
@@ -79,7 +79,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes)
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
- \ 'end_col': 16,
+ \ 'end_col': 15,
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
@@ -98,7 +98,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should include sources in detail):
\ 'lnum': 10,
\ 'col': 15,
\ 'end_lnum': 12,
- \ 'end_col': 23,
+ \ 'end_col': 22,
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
@@ -117,7 +117,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should consider -1 to be a meaningles
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
- \ 'end_col': 16,
+ \ 'end_col': 15,
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
@@ -136,7 +136,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
\ 'lnum': 1,
\ 'col': 3,
\ 'end_lnum': 1,
- \ 'end_col': 3,
+ \ 'end_col': 2,
\ },
\ {
\ 'type': 'W',
@@ -144,7 +144,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
\ 'lnum': 2,
\ 'col': 5,
\ 'end_lnum': 2,
- \ 'end_col': 5,
+ \ 'end_col': 4,
\ },
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
@@ -167,7 +167,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for det
\ 'lnum': 1,
\ 'col': 3,
\ 'end_lnum': 1,
- \ 'end_col': 3,
+ \ 'end_col': 2,
\ 'detail': "Something went wrong!\n/tmp/someotherfile.txt:43:80:\n\tmight be this"
\ }
\ ],