mirror of
https://github.com/dense-analysis/ale
synced 2024-12-27 16:42:19 +00:00
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
@ -12,6 +12,6 @@ call ale#linter#Define('javascript', {
|
||||
\ 'node_modules/.bin/tsserver',
|
||||
\ ]),
|
||||
\ 'command': '%e',
|
||||
\ 'project_root_callback': {-> ''},
|
||||
\ 'project_root_callback': 'ale#handlers#tsserver#GetProjectRoot',
|
||||
\ 'language': '',
|
||||
\})
|
||||
|
@ -12,6 +12,6 @@ call ale#linter#Define('typescript', {
|
||||
\ 'node_modules/.bin/tsserver',
|
||||
\ ]),
|
||||
\ 'command': '%e',
|
||||
\ 'project_root_callback': {-> ''},
|
||||
\ 'project_root_callback': 'ale#handlers#tsserver#GetProjectRoot',
|
||||
\ '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):
|
||||
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
Loading…
Reference in New Issue
Block a user