File: rls.vim

package info (click to toggle)
vim-ale 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,764 kB
  • sloc: sh: 499; python: 311; perl: 31; makefile: 4; xml: 4; javascript: 1
file content (27 lines) | stat: -rw-r--r-- 945 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
" Author: w0rp <devw0rp@gmail.com>
" Description: A language server for Rust

call ale#Set('rust_rls_executable', 'rls')
call ale#Set('rust_rls_toolchain', '')
call ale#Set('rust_rls_config', {})

function! ale_linters#rust#rls#GetCommand(buffer) abort
    let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain')

    return '%e' . (!empty(l:toolchain) ? ' +' . ale#Escape(l:toolchain) : '')
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',
\   'lsp_config': {b -> ale#Var(b, 'rust_rls_config')},
\   'executable': {b -> ale#Var(b, 'rust_rls_executable')},
\   'command': function('ale_linters#rust#rls#GetCommand'),
\   'project_root': function('ale_linters#rust#rls#GetProjectRoot'),
\})