add project_root_callback for tsserver (#2290)
* add project_root_callback for tsserver * add tests for tsserver project root * Update test/command_callback/test_javascript_tsserver_command_callback.vader
This commit is contained in:
parent
6ebe24b5ff
commit
aca1edb476
9 changed files with 18 additions and 2 deletions
|
@ -12,6 +12,6 @@ call ale#linter#Define('javascript', {
|
||||||
\ 'node_modules/.bin/tsserver',
|
\ 'node_modules/.bin/tsserver',
|
||||||
\ ]),
|
\ ]),
|
||||||
\ 'command': '%e',
|
\ 'command': '%e',
|
||||||
\ 'project_root_callback': {-> ''},
|
\ 'project_root_callback': 'ale#handlers#tsserver#GetProjectRoot',
|
||||||
\ 'language': '',
|
\ 'language': '',
|
||||||
\})
|
\})
|
||||||
|
|
|
@ -12,6 +12,6 @@ call ale#linter#Define('typescript', {
|
||||||
\ 'node_modules/.bin/tsserver',
|
\ 'node_modules/.bin/tsserver',
|
||||||
\ ]),
|
\ ]),
|
||||||
\ 'command': '%e',
|
\ 'command': '%e',
|
||||||
\ 'project_root_callback': {-> ''},
|
\ 'project_root_callback': 'ale#handlers#tsserver#GetProjectRoot',
|
||||||
\ 'language': '',
|
\ 'language': '',
|
||||||
\})
|
\})
|
||||||
|
|
8
autoload/ale/handlers/tsserver.vim
Normal file
8
autoload/ale/handlers/tsserver.vim
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
" Author: Derek Sifford <dereksifford@gmail.com>
|
||||||
|
" Description: Handlers for tsserver
|
||||||
|
|
||||||
|
function! ale#handlers#tsserver#GetProjectRoot(buffer) abort
|
||||||
|
let l:tsconfig_file = ale#path#FindNearestFile(a:buffer, 'tsconfig.json')
|
||||||
|
|
||||||
|
return !empty(l:tsconfig_file) ? fnamemodify(l:tsconfig_file, ':h') : ''
|
||||||
|
endfunction
|
|
@ -6,3 +6,11 @@ After:
|
||||||
|
|
||||||
Execute(The default command should be correct):
|
Execute(The default command should be correct):
|
||||||
AssertLinter 'tsserver', ale#Escape('tsserver')
|
AssertLinter 'tsserver', ale#Escape('tsserver')
|
||||||
|
|
||||||
|
Execute(should resolve correct path when nested 1):
|
||||||
|
call ale#test#SetFilename('tsserver_paths/src/level-1/level-2/file3.ts')
|
||||||
|
AssertLSPProject ale#path#Simplify(g:dir . '/tsserver_paths/src/level-1')
|
||||||
|
|
||||||
|
Execute(should resolve correct path when nested 2):
|
||||||
|
call ale#test#SetFilename('tsserver_paths/src/file1.ts')
|
||||||
|
AssertLSPProject ale#path#Simplify(g:dir . '/tsserver_paths')
|
||||||
|
|
0
test/command_callback/tsserver_paths/src/file1.ts
Normal file
0
test/command_callback/tsserver_paths/src/file1.ts
Normal file
0
test/command_callback/tsserver_paths/tsconfig.json
Normal file
0
test/command_callback/tsserver_paths/tsconfig.json
Normal file
Reference in a new issue