summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/gopls.vim23
2 files changed, 28 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 6657fc3c..7040c4cc 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -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'],
diff --git a/autoload/ale/fixers/gopls.vim b/autoload/ale/fixers/gopls.vim
new file mode 100644
index 00000000..98f553c1
--- /dev/null
+++ b/autoload/ale/fixers/gopls.vim
@@ -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