mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-24 17:28:42 +08:00
Implement gofumpt Fixer (#3968)
* Implement gofumpt Fixer Add an implementation with test and documentation for the gofumpt go code formatter, a stricter formatter than your standard "go fmt". Signed-off-by: David Houston <houstdav000@gmail.com> * Add gofumpt to ale.txt TOC Forgot to add gofumpt to the ALE vim help Table of Contents, so do so. Signed-off-by: David Houston <houstdav000@gmail.com> * Fix Test Setup Method Capitalization I had put "Setup" instead of "SetUp" for "ale#assert#SetUpFixerTests". Fix such. Signed-off-by: David Houston <houstdav000@gmail.com> * Fix typos Add a missing space, remove an extra bracket by actually running tests locally first. Would've been smart to do that from the beginning... Signed-off-by: David Houston <houstdav000@gmail.com>
This commit is contained in:
@@ -246,6 +246,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
\ 'description': 'Fix Go files with go fmt.',
|
||||
\ },
|
||||
\ 'gofumpt': {
|
||||
\ 'function': 'ale#fixers#gofumpt#Fix',
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
\ 'description': 'Fix Go files with gofumpt, a stricter go fmt.',
|
||||
\ },
|
||||
\ 'goimports': {
|
||||
\ 'function': 'ale#fixers#goimports#Fix',
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
" Author: David Houston <houstdav000>
|
||||
" Description: A stricter gofmt implementation.
|
||||
|
||||
call ale#Set('go_gofumpt_executable', 'gofumpt')
|
||||
call ale#Set('go_gofumpt_options', '')
|
||||
|
||||
function! ale#fixers#gofumpt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_gofumpt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'go_gofumpt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' -w -- %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user