mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-09 04:52:29 +08:00
Added support for goimports fixer (#1123)
* Added support for goimports fixer * added test and executable check * fixed test assertions to reflect executable check
This commit is contained in:
@@ -107,6 +107,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
\ 'description': 'Fix Go files with go fmt.',
|
||||
\ },
|
||||
\ 'goimports': {
|
||||
\ 'function': 'ale#fixers#goimports#Fix',
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
\ 'description': 'Fix Go files imports with go fmt.',
|
||||
\ },
|
||||
\ 'tslint': {
|
||||
\ 'function': 'ale#fixers#tslint#Fix',
|
||||
\ 'suggested_filetypes': ['typescript'],
|
||||
|
||||
22
autoload/ale/fixers/goimports.vim
Normal file
22
autoload/ale/fixers/goimports.vim
Normal file
@@ -0,0 +1,22 @@
|
||||
" Author: Jeff Willette <jrwillette88@gmail.com>
|
||||
" Description: Integration of goimports with ALE.
|
||||
|
||||
call ale#Set('go_goimports_executable', 'goimports')
|
||||
call ale#Set('go_goimports_options', '')
|
||||
|
||||
function! ale#fixers#goimports#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_goimports_executable')
|
||||
let l:options = ale#Var(a:buffer, 'go_goimports_options')
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' -l -w'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user