diff options
author | jamestthompson3 <jamestthompson3@gmail.com> | 2018-07-06 21:24:19 +0300 |
---|---|---|
committer | jamestthompson3 <jamestthompson3@gmail.com> | 2018-07-06 21:24:19 +0300 |
commit | eda3878a6c121d94f83726ac5ebd059ee0d859ef (patch) | |
tree | af80668ebb4085c98c95e6adb4d21c18c6302a87 /ale_linters/javascript/flow_ls.vim | |
parent | cb8643ce7475e36a7e8e457545d4f85647a04a8d (diff) | |
download | ale-eda3878a6c121d94f83726ac5ebd059ee0d859ef.zip |
Add flow-language-server
Diffstat (limited to 'ale_linters/javascript/flow_ls.vim')
-rw-r--r-- | ale_linters/javascript/flow_ls.vim | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ale_linters/javascript/flow_ls.vim b/ale_linters/javascript/flow_ls.vim new file mode 100644 index 00000000..20fc2217 --- /dev/null +++ b/ale_linters/javascript/flow_ls.vim @@ -0,0 +1,38 @@ +" Author: t_t <jamestthompson3@gmail.com> +" Description: Integrate ALE with flow-language-server. + +call ale#Set('javascript_flow_ls_executable', 'flow') +call ale#Set('javascript_flow_ls_use_global', +\ get(g:, 'ale_use_global_executables', 0) +\) + +function! ale_linters#javascript#flow_ls#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'javascript_flow_ls', [ + \ 'node_modules/.bin/flow', + \]) +endfunction + +function! ale_linters#javascript#flow_ls#GetCommand(buffer) abort + let l:executable = ale_linters#javascript#flow_ls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' lsp --from ale-lsp' +endfunction + +function! ale_linters#javascript#flow_ls#FindProjectRoot(buffer) abort + let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') + + if !empty(l:flow_config) + return fnamemodify(l:flow_config, ':h') + endif + + return '' +endfunction + +call ale#linter#Define('javascript', { +\ 'name': 'flow-language-server', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#javascript#flow_ls#GetExecutable', +\ 'command_callback': 'ale_linters#javascript#flow_ls#GetCommand', +\ 'project_root_callback': 'ale_linters#javascript#flow_ls#FindProjectRoot', +\ 'language': 'javascript', +\}) |