diff options
author | Eric Zhao <21zhaoe@protonmail.com> | 2020-11-21 15:56:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-21 20:56:38 +0000 |
commit | 9692c0c64c83bb8f67962cf35e7dc3f1757aa8cc (patch) | |
tree | d672572b9eb885b5807f441cb792c9a57c1dc15a /ale_linters/r | |
parent | 5458a1b29167b1fefde5fb6545e371a9d77ca36e (diff) | |
download | ale-9692c0c64c83bb8f67962cf35e7dc3f1757aa8cc.zip |
Add support for R languageserver (#3370)
Diffstat (limited to 'ale_linters/r')
-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..c625d8b4 --- /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_options', {}) + +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_options')}, +\ 'executable': 'Rscript', +\ 'command': function('ale_linters#r#languageserver#GetCommand'), +\ 'project_root': function('ale_linters#r#languageserver#GetProjectRoot') +\}) |