diff options
author | Bartek thindil Jasicki <thindil@laeran.pl> | 2020-11-27 13:38:24 +0100 |
---|---|---|
committer | Bartek thindil Jasicki <thindil@laeran.pl> | 2020-11-27 13:38:24 +0100 |
commit | 09b8cc97de2bd78f09c8331be25ede9e4ef8abb1 (patch) | |
tree | 62407f3473347c164aaa8960cb6796c790d99ecd /ale_linters/r/languageserver.vim | |
parent | f156548c16d87a60664002a4c88c534486b84de5 (diff) | |
parent | 1365dce921c1fb84a668ae121d5d5aeebef99fbc (diff) | |
download | ale-09b8cc97de2bd78f09c8331be25ede9e4ef8abb1.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'ale_linters/r/languageserver.vim')
-rw-r--r-- | ale_linters/r/languageserver.vim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ale_linters/r/languageserver.vim b/ale_linters/r/languageserver.vim new file mode 100644 index 00000000..febe66bd --- /dev/null +++ b/ale_linters/r/languageserver.vim @@ -0,0 +1,26 @@ +" Author: Eric Zhao <21zhaoe@protonmail.com> +" Description: Implementation of the Language Server Protocol for R. + +call ale#Set('r_languageserver_cmd', 'languageserver::run()') +call ale#Set('r_languageserver_config', {}) + +function! ale_linters#r#languageserver#GetCommand(buffer) abort + let l:cmd_string = ale#Var(a:buffer, 'r_languageserver_cmd') + + return 'Rscript --vanilla -e ' . ale#Escape(l:cmd_string) +endfunction + +function! ale_linters#r#languageserver#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, '.Rprofile') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : fnamemodify(a:buffer, ':h') +endfunction + +call ale#linter#Define('r', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'r_languageserver_config')}, +\ 'executable': 'Rscript', +\ 'command': function('ale_linters#r#languageserver#GetCommand'), +\ 'project_root': function('ale_linters#r#languageserver#GetProjectRoot') +\}) |