diff options
author | w0rp <w0rp@users.noreply.github.com> | 2019-01-26 19:40:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-26 19:40:45 +0000 |
commit | 452460b8cdff8b2809d0226b60183dbda5ae605d (patch) | |
tree | b9e0b78d7f03bcb0d6380c6bb61ba6de96f19d94 /test/lsp | |
parent | cf14d0aa53e9b51f4987dbfd3913183901bb2805 (diff) | |
parent | 6fc016ad052725e0d6a474e80f817cb1853e98e2 (diff) | |
download | ale-452460b8cdff8b2809d0226b60183dbda5ae605d.zip |
Merge pull request #2241 from bk2204/lsp-detect-hook
Add a hook to detect LSP project root
Diffstat (limited to 'test/lsp')
-rw-r--r-- | test/lsp/test_lsp_command_formatting.vader | 1 | ||||
-rw-r--r-- | test/lsp/test_lsp_root_detection.vader | 63 |
2 files changed, 64 insertions, 0 deletions
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 '' |