summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/vimrc22
1 files changed, 14 insertions, 8 deletions
diff --git a/core/vimrc b/core/vimrc
index a2b40c4..06d1782 100644
--- a/core/vimrc
+++ b/core/vimrc
@@ -181,6 +181,16 @@ endfunction
181" else it loads nothing for them (no gd/completion). The list is shared by reference with 181" else it loads nothing for them (no gd/completion). The list is shared by reference with
182" the init options below (covers the first file) and pushed as config for later files. 182" the init options below (covers the first file) and pushed as config for later files.
183let g:ra_detached = [] 183let g:ra_detached = []
184" checkOnSave runs `cargo check` on the file, which needs nightly -Zscript for a file with
185" no Cargo.toml; RustDetach turns it off when the server starts on a standalone file.
186let g:ra_init = {
187 \ 'completion': {
188 \ 'autoimport': { 'enable': v:true },
189 \ 'postfix': { 'enable': v:true },
190 \ },
191 \ 'checkOnSave': v:true,
192 \ 'detachedFiles': g:ra_detached,
193 \ }
184function! RustDetach() abort 194function! RustDetach() abort
185 if !exists('g:lsp_loaded') 195 if !exists('g:lsp_loaded')
186 return 196 return
@@ -190,6 +200,9 @@ function! RustDetach() abort
190 return 200 return
191 endif 201 endif
192 call add(g:ra_detached, l:p) 202 call add(g:ra_detached, l:p)
203 if lsp#get_server_status('rust-analyzer') !~# '^\(running\|starting\)$'
204 let g:ra_init['checkOnSave'] = v:false
205 endif
193 if lsp#get_server_status('rust-analyzer') ==# 'running' 206 if lsp#get_server_status('rust-analyzer') ==# 'running'
194 call lsp#update_workspace_config('rust-analyzer', {'rust-analyzer': {'detachedFiles': copy(g:ra_detached)}}) 207 call lsp#update_workspace_config('rust-analyzer', {'rust-analyzer': {'detachedFiles': copy(g:ra_detached)}})
195 endif 208 endif
@@ -206,14 +219,7 @@ if executable(expand('~/.cargo/bin/rust-analyzer'))
206 \ 'cmd': {server_info -> [expand('~/.cargo/bin/rust-analyzer')]}, 219 \ 'cmd': {server_info -> [expand('~/.cargo/bin/rust-analyzer')]},
207 \ 'allowlist': ['rust'], 220 \ 'allowlist': ['rust'],
208 \ 'root_uri': {server_info -> lsp#utils#path_to_uri(RustRoot())}, 221 \ 'root_uri': {server_info -> lsp#utils#path_to_uri(RustRoot())},
209 \ 'initialization_options': { 222 \ 'initialization_options': g:ra_init,
210 \ 'completion': {
211 \ 'autoimport': { 'enable': v:true },
212 \ 'postfix': { 'enable': v:true },
213 \ },
214 \ 'checkOnSave': v:true,
215 \ 'detachedFiles': g:ra_detached,
216 \ },
217 \ 'workspace_config': {'rust-analyzer': {'detachedFiles': g:ra_detached}}, 223 \ 'workspace_config': {'rust-analyzer': {'detachedFiles': g:ra_detached}},
218 \ }) 224 \ })
219endif 225endif