From 209cd547839c78403a2453d6a1e454d121103e28 Mon Sep 17 00:00:00 2001 From: w0rp Date: Fri, 3 Aug 2018 17:22:09 +0100 Subject: [PATCH] Fix #1781 - Fix me breaking the tsserver linter --- ale_linters/javascript/tsserver.vim | 19 +++++-------------- ale_linters/typescript/tsserver.vim | 2 +- ...javascript_tsserver_command_callback.vader | 8 ++++++++ ...typescript_tsserver_command_callback.vader | 8 ++++++++ 4 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 test/command_callback/test_javascript_tsserver_command_callback.vader create mode 100644 test/command_callback/test_typescript_tsserver_command_callback.vader diff --git a/ale_linters/javascript/tsserver.vim b/ale_linters/javascript/tsserver.vim index 62dded10..6cf08dd6 100644 --- a/ale_linters/javascript/tsserver.vim +++ b/ale_linters/javascript/tsserver.vim @@ -5,22 +5,13 @@ call ale#Set('javascript_tsserver_executable', 'tsserver') call ale#Set('javascript_tsserver_config_path', '') call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0)) -" These functions need to be defined just to comply with the API for LSP. -function! ale_linters#javascript#tsserver#GetProjectRoot(buffer) abort - return '' -endfunction - -function! ale_linters#javascript#tsserver#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_tsserver', [ - \ 'node_modules/.bin/tsserver', - \]) -endfunction - call ale#linter#Define('javascript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable_callback': 'ale_linters#javascript#tsserver#GetExecutable', -\ 'command_callback': 'ale_linters#javascript#tsserver#GetExecutable', -\ 'project_root_callback': 'ale_linters#javascript#tsserver#GetProjectRoot', +\ 'executable_callback': ale#node#FindExecutableFunc('javascript_tsserver', [ +\ 'node_modules/.bin/tsserver', +\ ]), +\ 'command': '%e', +\ 'project_root_callback': {-> ''}, \ 'language': '', \}) diff --git a/ale_linters/typescript/tsserver.vim b/ale_linters/typescript/tsserver.vim index 0ad35d37..bac63229 100644 --- a/ale_linters/typescript/tsserver.vim +++ b/ale_linters/typescript/tsserver.vim @@ -11,7 +11,7 @@ call ale#linter#Define('typescript', { \ 'executable_callback': ale#node#FindExecutableFunc('typescript_tsserver', [ \ 'node_modules/.bin/tsserver', \ ]), -\ 'command_callback': 'ale_linters#typescript#tsserver#GetExecutable', +\ 'command': '%e', \ 'project_root_callback': {-> ''}, \ 'language': '', \}) diff --git a/test/command_callback/test_javascript_tsserver_command_callback.vader b/test/command_callback/test_javascript_tsserver_command_callback.vader new file mode 100644 index 00000000..638dd873 --- /dev/null +++ b/test/command_callback/test_javascript_tsserver_command_callback.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('javascript', 'tsserver') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'tsserver', ale#Escape('tsserver') diff --git a/test/command_callback/test_typescript_tsserver_command_callback.vader b/test/command_callback/test_typescript_tsserver_command_callback.vader new file mode 100644 index 00000000..719ac184 --- /dev/null +++ b/test/command_callback/test_typescript_tsserver_command_callback.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('typescript', 'tsserver') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'tsserver', ale#Escape('tsserver')