let the user set the format hook
This commit is contained in:
parent
28e37b608d
commit
352c56bfb5
|
@ -54,7 +54,7 @@ def go-disable-autocomplete -docstring "Disable gocode completion" %{
|
||||||
decl -hidden str go_format_tmp_dir
|
decl -hidden str go_format_tmp_dir
|
||||||
|
|
||||||
def -params ..1 go-format \
|
def -params ..1 go-format \
|
||||||
-docstring "go-format [goimports]: custom formatter for go files" %{
|
-docstring "go-format [-use-goimports]: custom formatter for go files" %{
|
||||||
%sh{
|
%sh{
|
||||||
dir=$(mktemp -d -t kak-go.XXXXXXXX)
|
dir=$(mktemp -d -t kak-go.XXXXXXXX)
|
||||||
printf %s\\n "set buffer go_format_tmp_dir ${dir}"
|
printf %s\\n "set buffer go_format_tmp_dir ${dir}"
|
||||||
|
@ -62,7 +62,7 @@ def -params ..1 go-format \
|
||||||
}
|
}
|
||||||
%sh{
|
%sh{
|
||||||
dir=${kak_opt_go_format_tmp_dir}
|
dir=${kak_opt_go_format_tmp_dir}
|
||||||
if [ "$1" = "1" ]; then
|
if [ "$1" = "-use-goimports" ]; then
|
||||||
fmt_cmd="goimports -srcdir '${kak_buffile}'"
|
fmt_cmd="goimports -srcdir '${kak_buffile}'"
|
||||||
else
|
else
|
||||||
fmt_cmd="gofmt -s"
|
fmt_cmd="gofmt -s"
|
||||||
|
@ -79,18 +79,6 @@ def -params ..1 go-format \
|
||||||
edit!
|
edit!
|
||||||
}
|
}
|
||||||
|
|
||||||
def go-enable-format-onsave -docstring "Enable formatting on save for go files" %{
|
|
||||||
hook buffer -group go-format-onsave BufWritePre .+\.go %{ go-format }
|
|
||||||
}
|
|
||||||
|
|
||||||
def go-enable-format-imports-onsave -docstring "Enable formatting (with goimports) on save for go files" %{
|
|
||||||
hook buffer -group go-format-onsave BufWritePre .+\.go %{ go-format 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
def go-disable-format-onsave -docstring "Disable formatting on save for go files" %{
|
|
||||||
rmhooks buffer go-format-onsave
|
|
||||||
}
|
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user