diff options
author | w0rp <devw0rp@gmail.com> | 2017-08-02 23:21:30 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-08-02 23:21:30 +0100 |
commit | 09d50ebe3110bfee5ac505aa29704d980ba156f3 (patch) | |
tree | 2b2d17d5f8dba9a13c18b7a79cba3fde63e15402 /ale_linters/rust | |
parent | 617582c5d3833cf3143067870c87a09647ccf028 (diff) | |
download | ale-09d50ebe3110bfee5ac505aa29704d980ba156f3.zip |
Cover the Rust LSP with tests, allow LSP linters to be named anything, and rename the Rust LSP linter to `rls`
Diffstat (limited to 'ale_linters/rust')
-rw-r--r-- | ale_linters/rust/langserver.vim | 33 | ||||
-rw-r--r-- | ale_linters/rust/rls.vim | 33 |
2 files changed, 33 insertions, 33 deletions
diff --git a/ale_linters/rust/langserver.vim b/ale_linters/rust/langserver.vim deleted file mode 100644 index 5e42a97f..00000000 --- a/ale_linters/rust/langserver.vim +++ /dev/null @@ -1,33 +0,0 @@ -" Author: w0rp <devw0rp@gmail.com> -" Description: A language server for Rust - -call ale#Set('rust_langserver_executable', 'rls') - -function! ale_linters#rust#langserver#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'rust_langserver_executable') -endfunction - -function! ale_linters#rust#langserver#GetCommand(buffer) abort - let l:executable = ale_linters#rust#langserver#GetExecutable(a:buffer) - - return ale#Escape(l:executable) . ' +nightly' -endfunction - -function! ale_linters#rust#langserver#GetLanguage(buffer) abort - return 'rust' -endfunction - -function! ale_linters#rust#langserver#GetProjectRoot(buffer) abort - let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') - - return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : '' -endfunction - -call ale#linter#Define('rust', { -\ 'name': 'langserver', -\ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#rust#langserver#GetExecutable', -\ 'command_callback': 'ale_linters#rust#langserver#GetCommand', -\ 'language_callback': 'ale_linters#rust#langserver#GetLanguage', -\ 'project_root_callback': 'ale_linters#rust#langserver#GetProjectRoot', -\}) diff --git a/ale_linters/rust/rls.vim b/ale_linters/rust/rls.vim new file mode 100644 index 00000000..c49d2682 --- /dev/null +++ b/ale_linters/rust/rls.vim @@ -0,0 +1,33 @@ +" Author: w0rp <devw0rp@gmail.com> +" Description: A language server for Rust + +call ale#Set('rust_rls_executable', 'rls') + +function! ale_linters#rust#rls#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'rust_rls_executable') +endfunction + +function! ale_linters#rust#rls#GetCommand(buffer) abort + let l:executable = ale_linters#rust#rls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' +nightly' +endfunction + +function! ale_linters#rust#rls#GetLanguage(buffer) abort + return 'rust' +endfunction + +function! ale_linters#rust#rls#GetProjectRoot(buffer) abort + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : '' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'rls', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#rust#rls#GetExecutable', +\ 'command_callback': 'ale_linters#rust#rls#GetCommand', +\ 'language_callback': 'ale_linters#rust#rls#GetLanguage', +\ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot', +\}) |