1
0
Fork 0
mirror of synced 2024-11-15 21:48:57 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/go/gopls.vim

40 lines
1.4 KiB
VimL
Raw Normal View History

2019-05-17 10:09:13 -04:00
" Author: w0rp <devw0rp@gmail.com>
" Author: Jerko Steiner <https://github.com/jeremija>
" Description: https://github.com/saibing/gopls
call ale#Set('go_gopls_executable', 'gopls')
call ale#Set('go_gopls_options', '--mode stdio')
2021-05-05 04:25:00 -04:00
call ale#Set('go_gopls_init_options', {})
2021-05-31 16:30:26 -04:00
call ale#Set('go_gopls_use_global', get(g:, 'ale_use_global_executables', 0))
2019-05-17 10:09:13 -04:00
function! ale_linters#go#gopls#GetCommand(buffer) abort
2019-08-22 11:36:17 -04:00
return ale#go#EnvString(a:buffer)
\ . '%e'
\ . ale#Pad(ale#Var(a:buffer, 'go_gopls_options'))
2019-05-17 10:09:13 -04:00
endfunction
function! ale_linters#go#gopls#FindProjectRoot(buffer) abort
2019-08-22 11:36:17 -04:00
let l:go_modules_off = ale#Var(a:buffer, 'go_go111module') is# 'off'
let l:project_root = l:go_modules_off ?
\ '' : ale#path#FindNearestFile(a:buffer, 'go.mod')
2019-05-17 10:09:13 -04:00
let l:mods = ':h'
if empty(l:project_root)
let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git')
let l:mods = ':h:h'
endif
return !empty(l:project_root) ? fnamemodify(l:project_root, l:mods) : ''
endfunction
call ale#linter#Define('go', {
\ 'name': 'gopls',
\ 'lsp': 'stdio',
2021-05-31 16:30:26 -04:00
\ 'executable': {b -> ale#path#FindExecutable(b, 'go_gopls', [
\ ale#go#GetGoPathExecutable('bin/gopls'),
\ ])},
2019-05-17 10:09:13 -04:00
\ 'command': function('ale_linters#go#gopls#GetCommand'),
\ 'project_root': function('ale_linters#go#gopls#FindProjectRoot'),
2021-05-05 04:25:00 -04:00
\ 'initialization_options': {b -> ale#Var(b, 'go_gopls_init_options')},
2019-05-17 10:09:13 -04:00
\})