From c07b3b9bfcc00fb8b6dd8b2e9627257df4c8ed4f Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 26 Nov 2017 18:47:30 +0000 Subject: [PATCH] Fix #1166 - Add an option for the rls toolchain --- ale_linters/rust/rls.vim | 5 ++++- doc/ale-rust.txt | 11 +++++++++++ test/command_callback/test_rust_rls_callbacks.vader | 11 ++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ale_linters/rust/rls.vim b/ale_linters/rust/rls.vim index c49d268..832fe3e 100644 --- a/ale_linters/rust/rls.vim +++ b/ale_linters/rust/rls.vim @@ -2,6 +2,7 @@ " Description: A language server for Rust call ale#Set('rust_rls_executable', 'rls') +call ale#Set('rust_rls_toolchain', 'nightly') function! ale_linters#rust#rls#GetExecutable(buffer) abort return ale#Var(a:buffer, 'rust_rls_executable') @@ -9,8 +10,10 @@ endfunction function! ale_linters#rust#rls#GetCommand(buffer) abort let l:executable = ale_linters#rust#rls#GetExecutable(a:buffer) + let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain') - return ale#Escape(l:executable) . ' +nightly' + return ale#Escape(l:executable) + \ . ' +' . ale#Escape(l:toolchain) endfunction function! ale_linters#rust#rls#GetLanguage(buffer) abort diff --git a/doc/ale-rust.txt b/doc/ale-rust.txt index 15ffef0..a32c90b 100644 --- a/doc/ale-rust.txt +++ b/doc/ale-rust.txt @@ -70,6 +70,17 @@ g:ale_rust_rls_executable *g:ale_rust_rls_executable* This variable can be modified to change the executable path for `rls`. +g:ale_rust_rls_toolchain *g:ale_rust_rls_toolchain* + *b:ale_rust_rls_toolchain* + Type: |String| + Default: `'nightly'` + + This option can be set to change the toolchain used for `rls`. Possible + values include `'nightly'`, `'beta'`, and `'stable'`. + + The `rls` server will only be started once per executable. + + =============================================================================== rustc *ale-rust-rustc* diff --git a/test/command_callback/test_rust_rls_callbacks.vader b/test/command_callback/test_rust_rls_callbacks.vader index b01f8f0..e467fd9 100644 --- a/test/command_callback/test_rust_rls_callbacks.vader +++ b/test/command_callback/test_rust_rls_callbacks.vader @@ -1,7 +1,9 @@ Before: Save g:ale_rust_rls_executable + Save g:ale_rust_rls_toolchain unlet! g:ale_rust_rls_executable + unlet! g:ale_rust_rls_toolchain runtime ale_linters/rust/rls.vim @@ -16,7 +18,14 @@ After: Execute(The default executable path should be correct): AssertEqual 'rls', ale_linters#rust#rls#GetExecutable(bufnr('')) AssertEqual - \ ale#Escape('rls') . ' +nightly', + \ ale#Escape('rls') . ' +' . ale#Escape('nightly'), + \ ale_linters#rust#rls#GetCommand(bufnr('')) + +Execute(The toolchain should be configurable): + let g:ale_rust_rls_toolchain = 'stable' + + AssertEqual + \ ale#Escape('rls') . ' +' . ale#Escape('stable'), \ ale_linters#rust#rls#GetCommand(bufnr('')) Execute(The language string should be correct):