2019-01-26 04:45:12 +00:00
|
|
|
Before:
|
2021-03-01 20:51:29 +00:00
|
|
|
Save g:ale_lsp_root
|
|
|
|
Save g:ale_root
|
|
|
|
Save b:ale_lsp_root
|
|
|
|
Save b:ale_root
|
|
|
|
|
|
|
|
unlet! g:ale_lsp_root
|
|
|
|
let g:ale_root = {}
|
|
|
|
|
2019-01-26 04:45:12 +00:00
|
|
|
call ale#assert#SetUpLinterTest('c', 'clangd')
|
|
|
|
|
|
|
|
function! Hook1(buffer)
|
|
|
|
return 'abc123'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
After:
|
2021-03-01 20:51:29 +00:00
|
|
|
Restore
|
|
|
|
|
2019-01-26 04:45:12 +00:00
|
|
|
delfunction Hook1
|
|
|
|
|
|
|
|
call ale#assert#TearDownLinterTest()
|
|
|
|
|
|
|
|
Execute(The buffer-specific variable can be a string):
|
2021-03-01 20:51:29 +00:00
|
|
|
let b:ale_root = '/some/path'
|
2019-01-26 04:45:12 +00:00
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
2019-02-22 18:05:04 +00:00
|
|
|
AssertLSPProject '/some/path'
|
2019-01-26 04:45:12 +00:00
|
|
|
|
|
|
|
Execute(The buffer-specific variable can be a dictionary):
|
2021-03-01 20:51:29 +00:00
|
|
|
let b:ale_root = {'clangd': '/some/path', 'golangserver': '/other/path'}
|
2019-01-26 04:45:12 +00:00
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
2019-02-22 18:05:04 +00:00
|
|
|
AssertLSPProject '/some/path'
|
2019-01-26 04:45:12 +00:00
|
|
|
|
|
|
|
Execute(The buffer-specific variable can have funcrefs):
|
2021-03-01 20:51:29 +00:00
|
|
|
let b:ale_root = {'clangd': function('Hook1'), 'golangserver': '/path'}
|
2019-01-26 04:45:12 +00:00
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
2019-02-22 18:05:04 +00:00
|
|
|
AssertLSPProject 'abc123'
|
2019-01-26 04:45:12 +00:00
|
|
|
|
2021-03-01 20:51:29 +00:00
|
|
|
Execute(The buffer-specific variable can be the old ale_lsp_root setting):
|
|
|
|
let b:ale_lsp_root = '/some/path'
|
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
|
|
|
AssertLSPProject '/some/path'
|
|
|
|
|
2019-01-26 04:45:12 +00:00
|
|
|
Execute(The global variable can be a dictionary):
|
2021-03-01 20:51:29 +00:00
|
|
|
let g:ale_root = {'clangd': '/some/path', 'golangserver': '/other/path'}
|
2019-01-26 04:45:12 +00:00
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
2019-02-22 18:05:04 +00:00
|
|
|
AssertLSPProject '/some/path'
|
2019-01-26 04:45:12 +00:00
|
|
|
|
|
|
|
Execute(The global variable can have funcrefs):
|
2021-03-01 20:51:29 +00:00
|
|
|
let g:ale_root = {'clangd': function('Hook1'), 'golangserver': '/path'}
|
2019-01-26 04:45:12 +00:00
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
2019-02-22 18:05:04 +00:00
|
|
|
AssertLSPProject 'abc123'
|
2019-01-26 04:45:12 +00:00
|
|
|
|
|
|
|
Execute(The buffer-specific variable overrides the global variable):
|
2021-03-01 20:51:29 +00:00
|
|
|
let b:ale_root = {'clangd': '/some/path', 'golangserver': '/other/path'}
|
|
|
|
let g:ale_root = {'clangd': '/not/this/path', 'golangserver': '/elsewhere'}
|
2019-01-26 04:45:12 +00:00
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
2019-02-22 18:05:04 +00:00
|
|
|
AssertLSPProject '/some/path'
|
2019-01-26 04:45:12 +00:00
|
|
|
|
|
|
|
Execute(The global variable is queried if the buffer-specific has no value):
|
2021-03-01 20:51:29 +00:00
|
|
|
let b:ale_root = {'golangserver': '/other/path'}
|
|
|
|
let g:ale_root = {'clangd': '/some/path', 'golangserver': '/elsewhere'}
|
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
|
|
|
AssertLSPProject '/some/path'
|
|
|
|
|
|
|
|
Execute(The global variable can be the old ale_lsp_root setting):
|
|
|
|
let g:ale_root = {}
|
|
|
|
let g:ale_lsp_root = {'clangd': '/some/path', 'golangserver': '/other/path'}
|
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
|
|
|
AssertLSPProject '/some/path'
|
|
|
|
|
|
|
|
Execute(A non-empty ale_root setting should replace the old ale_lsp_root):
|
|
|
|
let g:ale_root = {'clangd': '/some/path', 'golangserver': '/other/path'}
|
|
|
|
let g:ale_lsp_root = {'clangd': '/xxx', 'golangserver': '/xxx'}
|
2019-01-26 04:45:12 +00:00
|
|
|
call ale#test#SetFilename('other-file.c')
|
|
|
|
|
2019-02-22 18:05:04 +00:00
|
|
|
AssertLSPProject '/some/path'
|
2019-01-26 04:45:12 +00:00
|
|
|
|
2019-05-20 19:06:44 +00:00
|
|
|
Execute(No path should be returned by default):
|
|
|
|
call ale#test#SetFilename(tempname() . '/other-file.c')
|
2019-01-26 04:45:12 +00:00
|
|
|
|
2019-02-22 18:05:04 +00:00
|
|
|
AssertLSPProject ''
|