summaryrefslogtreecommitdiff
path: root/ale_linters/go/langserver.vim
blob: e049be7bfb319a86f1d238398a37c56fd85fe30e (plain)
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
28
" Author: Horacio Sanson <https://github.com/hsanson>
" Description: Support for go-langserver https://github.com/sourcegraph/go-langserver

call ale#Set('go_langserver_executable', 'go-langserver')
call ale#Set('go_langserver_options', '')

function! ale_linters#go#langserver#GetCommand(buffer) abort
    let l:executable = [ale#Escape(ale#Var(a:buffer, 'go_langserver_executable'))]
    let l:options = ale#Var(a:buffer, 'go_langserver_options')
    let l:options = substitute(l:options, '-gocodecompletion', '', 'g')
    let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1')

    if ale#Var(a:buffer, 'completion_enabled')
        call add(l:options, '-gocodecompletion')
    endif

    let l:options = uniq(sort(l:options))

    return join(extend(l:executable, l:options), ' ')
endfunction

call ale#linter#Define('go', {
\   'name': 'golangserver',
\   'lsp': 'stdio',
\   'executable_callback': ale#VarFunc('go_langserver_executable'),
\   'command_callback': 'ale_linters#go#langserver#GetCommand',
\   'project_root_callback': 'ale#go#FindProjectRoot',
\})