mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-26 21:09:08 +08:00
Add gopls format as a Go fixer
This commit is contained in:
@@ -301,6 +301,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['gomod'],
|
||||
\ 'description': 'Fix Go module files with go mod edit -fmt.',
|
||||
\ },
|
||||
\ 'gopls': {
|
||||
\ 'function': 'ale#fixers#gopls#Fix',
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
\ 'description': 'Fix Go files with gopls.',
|
||||
\ },
|
||||
\ 'tslint': {
|
||||
\ 'function': 'ale#fixers#tslint#Fix',
|
||||
\ 'suggested_filetypes': ['typescript'],
|
||||
|
||||
23
autoload/ale/fixers/gopls.vim
Normal file
23
autoload/ale/fixers/gopls.vim
Normal file
@@ -0,0 +1,23 @@
|
||||
" Author: Sean Enck <enckse@voidedtech.com>
|
||||
" Description: Integration of gopls format with ALE.
|
||||
|
||||
call ale#Set('go_gopls_fix_executable', 'gopls')
|
||||
call ale#Set('go_gopls_fix_options', '')
|
||||
|
||||
function! ale#fixers#gopls#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_gopls_fix_executable')
|
||||
let l:options = ale#Var(a:buffer, 'go_gopls_fix_options')
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:env . ale#Escape(l:executable)
|
||||
\ . ' format'
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' -l -w %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user