mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-20 08:38:31 +08:00
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--neovim-06-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Closes #4616
33 lines
1.1 KiB
VimL
33 lines
1.1 KiB
VimL
" Author: Ian Stapleton Cordasco <graffatcolmingov@gmail.com>
|
|
" Description: Run golangci-lint with the --fix flag to autofix some issues
|
|
|
|
call ale#Set('go_golangci_lint_options', '')
|
|
call ale#Set('go_golangci_lint_executable', 'golangci-lint')
|
|
call ale#Set('go_golangci_lint_package', 1)
|
|
|
|
function! ale#fixers#golangci_lint#GetCommand(buffer) abort
|
|
let l:filename = expand('#' . a:buffer . ':t')
|
|
let l:executable = ale#Var(a:buffer, 'go_golangci_lint_executable')
|
|
let l:options = ale#Var(a:buffer, 'go_golangci_lint_options') . ' --fix'
|
|
let l:package_mode = ale#Var(a:buffer, 'go_golangci_lint_package')
|
|
let l:env = ale#go#EnvString(a:buffer)
|
|
|
|
|
|
if l:package_mode
|
|
return l:env . ale#Escape(l:executable)
|
|
\ . ' run '
|
|
\ . l:options
|
|
endif
|
|
|
|
return l:env . ale#Escape(l:executable)
|
|
\ . ' run '
|
|
\ . l:options
|
|
\ . ' ' . ale#Escape(l:filename)
|
|
endfunction
|
|
|
|
function! ale#fixers#golangci_lint#Fix(buffer) abort
|
|
return {
|
|
\ 'command': ale#fixers#golangci_lint#GetCommand(a:buffer),
|
|
\}
|
|
endfunction
|