diff options
author | w0rp <devw0rp@gmail.com> | 2017-07-30 23:34:58 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-07-30 23:34:58 +0100 |
commit | 2c252c0f12868c5bbe9a00bd8bc37b32ae3802c4 (patch) | |
tree | 25d7576f34e756aed31c22dadf16ec116dbba545 /ale_linters/rust | |
parent | 6000d956f0a3e217c3a0563abef738616feb73e6 (diff) | |
download | ale-2c252c0f12868c5bbe9a00bd8bc37b32ae3802c4.zip |
#517 - Get the Rust language server working in a basic way
Diffstat (limited to 'ale_linters/rust')
-rw-r--r-- | ale_linters/rust/langserver.vim | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ale_linters/rust/langserver.vim b/ale_linters/rust/langserver.vim new file mode 100644 index 00000000..5e42a97f --- /dev/null +++ b/ale_linters/rust/langserver.vim @@ -0,0 +1,33 @@ +" 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', +\}) |