AutoYADM commit: 2025-05-15 22:11:23

This commit is contained in:
Daniel Fichtinger 2025-05-15 22:11:23 -04:00
parent b171583d3d
commit 02106a54e3
2 changed files with 23 additions and 3 deletions

View file

@ -1,4 +1,4 @@
hook global WinSetOption filetype=go %{ hook global WinSetOption filetype=go %{
set-option window lsp_fmt true set-option window lsp_fmt true
# hook -group go-auto-format window BufWritePre .* lsp-formatting hook -group go-auto-format window BufWritePre .* format
} }

View file

@ -1,15 +1,35 @@
declare-option -docstring "shell command used for the 'format-selections' and 'format-buffer' commands" \ declare-option -docstring "shell command used for the 'format-selections' and 'format-buffer' commands" \
str formatcmd str formatcmd
declare-option -docstring "whether the LSP should be preferred for formatting" lsp_fmt bool false declare-option -docstring "whether the LSP should be preferred for formatting" bool lsp_fmt false
define-command format-buffer -docstring "Format the contents of the buffer" %{ define-command format-buffer -docstring "Format the contents of the buffer" %{
evaluate-commands %sh{
if [ "$kak_opt_lsp_fmt" == "false" ]; then
echo "format-buffer-pipe"
else
echo "lsp-formatting"
fi
}
}
define-command format-selections -docstring "Format the selections individually" %{
evaluate-commands %sh{
if [ "${kak_opt_lsp_fmt}" == "false" ]; then
echo "format-selections-pipe"
else
echo "lsp-range-formatting"
fi
}
}
define-command format-buffer-pipe -hidden -docstring "Format the contents of the buffer using pipe" %{
evaluate-commands -draft %{ evaluate-commands -draft %{
execute-keys '%' execute-keys '%'
format-selections format-selections
} }
} }
define-command format-selections -docstring "Format the selections individually" %{ define-command format-selections-pipe -docstring "Format the selections individually using pipe" %{
evaluate-commands %sh{ evaluate-commands %sh{
if [ -z "${kak_opt_formatcmd}" ]; then if [ -z "${kak_opt_formatcmd}" ]; then
echo "fail 'The option ''formatcmd'' must be set'" echo "fail 'The option ''formatcmd'' must be set'"