diff --git a/.config/kak/autoload/filetype.kak b/.config/kak/autoload/filetype.kak index 192d1b5f..303d4cf8 100644 --- a/.config/kak/autoload/filetype.kak +++ b/.config/kak/autoload/filetype.kak @@ -1,11 +1,14 @@ hook global WinSetOption filetype=python %{ # set-option window expandtab true # set-option window softtabstop 4 - set-option window formatcmd "ruff format --line-length 74 -" - hook -group python-auto-format window BufWritePre .* %{ - try format + set-option window formatcmd %{ + ruff check --select I --fix --stdin-filename $kak_buffile - 2>/dev/null | + ruff format --line-length 74 - } - hook -once -always WinSetOption filetype=.* %{ + hook -group python-auto-format window BufWritePre .* %{ + try format + } + hook -once -always window WinSetOption filetype=.* %{ unset-option window formatcmd remove-hooks window python-auto-format } @@ -13,64 +16,64 @@ hook global WinSetOption filetype=python %{ hook global WinSetOption filetype=yaml %{ set-option window formatcmd %{ - if dprint output-resolved-config >/dev/null 2>&1; then - dprint fmt --stdin yaml - else - dprint fmt --stdin yaml --config "$HOME/.dprint.jsonc" - fi + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin yaml + else + dprint fmt --stdin yaml --config "$HOME/.dprint.jsonc" + fi } } hook global WinSetOption filetype=html %{ set-option window formatcmd %{ - if dprint output-resolved-config >/dev/null 2>&1; then - dprint fmt --stdin html - else - dprint fmt --stdin html --config "$HOME/.dprint.jsonc" - fi + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin html + else + dprint fmt --stdin html --config "$HOME/.dprint.jsonc" + fi } } hook global WinSetOption filetype=css %{ set-option window formatcmd %{ - if dprint output-resolved-config >/dev/null 2>&1; then - dprint fmt --stdin css - else - dprint fmt --stdin css --config "$HOME/.dprint.jsonc" - fi + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin css + else + dprint fmt --stdin css --config "$HOME/.dprint.jsonc" + fi } } hook global WinSetOption filetype=json %{ set-option window formatcmd %{ - if dprint output-resolved-config >/dev/null 2>&1; then - dprint fmt --stdin json - else - dprint fmt --stdin json --config "$HOME/.dprint.jsonc" - fi + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin json + else + dprint fmt --stdin json --config "$HOME/.dprint.jsonc" + fi } } hook global WinSetOption filetype=jsonc %{ set-option window formatcmd %{ - if dprint output-resolved-config >/dev/null 2>&1; then - dprint fmt --stdin jsonc - else - dprint fmt --stdin jsonc --config "$HOME/.dprint.jsonc" - fi + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin jsonc + else + dprint fmt --stdin jsonc --config "$HOME/.dprint.jsonc" + fi } } hook global WinSetOption filetype=toml %{ set-option window formatcmd %{ - if dprint output-resolved-config >/dev/null 2>&1; then - dprint fmt --stdin toml - else - dprint fmt --stdin toml --config "$HOME/.dprint.jsonc" - fi + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin toml + else + dprint fmt --stdin toml --config "$HOME/.dprint.jsonc" + fi } # hook -group toml-auto-format window BufWritePre .* %{ - # try format + # try format # } # hook -once -always window WinSetOption filetype=.* %{ # unset-option window formatcmd @@ -81,9 +84,9 @@ hook global WinSetOption filetype=toml %{ hook global WinSetOption filetype=latex %{ set-option window formatcmd "tex-fmt --stdin" set-option window autowrap_fmtcmd 'tex-fmt --stdin -l %c' - set-option window autowrap_format_paragraph true + set-option window autowrap_format_paragraph true # hook -group latex-auto-format window BufWritePre .* %{ - # try format + # try format # } # hook -once -always window WinSetOption filetype=.* %{ # unset-option window formatcmd @@ -110,15 +113,15 @@ hook global WinSetOption filetype=typst %{ unset-option window formatcmd remove-hooks window typst-auto-format } - define-command -docstring %{ - Spawns a Zathura pdf preview and Typst watcher for the currently open Typst file - } typst %{ - nop %sh{ - { - "$kak_config/scripts/kak-typ-zathura.fish" -k -w "$kak_buffile" "$kak_client_pid" - } > /dev/null 2>&1 < /dev/null & - } - } + define-command -docstring %{ + Spawns a Zathura pdf preview and Typst watcher for the currently open Typst file + } typst %{ + nop %sh{ + { + "$kak_config/scripts/kak-typ-zathura.fish" -k -w "$kak_buffile" "$kak_client_pid" + } > /dev/null 2>&1 < /dev/null & + } + } } hook global WinSetOption filetype=fish %{ @@ -149,45 +152,45 @@ hook global WinSetOption filetype=man %{ } hook global WinSetOption filetype=kdl %{ - set-option window formatcmd "kdlfmt format -" - hook -group kdl-auto-format window BufWritePre .* format - hook -once -always WinSetOption filetype=.* %{ - unset-option window formatcmd - remove-hooks window kdl-auto-format - } + set-option window formatcmd "kdlfmt format -" + hook -group kdl-auto-format window BufWritePre .* format + hook -once -always WinSetOption filetype=.* %{ + unset-option window formatcmd + remove-hooks window kdl-auto-format + } } hook global WinSetOption filetype=mail %~ - evaluate-commands %sh{ - # stdin, we assume it's a pager - if [ "$kak_bufname" = "*stdin*" ]; then - echo 'define-command -hidden ismailreader nop' - fi - } - try %{ - ismailreader - set buffer readonly true - try %{ - # remove these highlighters so everything displays properly - remove-highlighter window/number-lines - remove-highlighter window/show-whitespaces - ui-wrap-disable - ui-scrolloff-disable - } - } catch %{ - set-option window formatcmd 'mailfmt' - set-option window comment_line '>' - try autospell-enable - hook -group mail-auto-format window BufWritePre .* format - hook -once -always window WinSetOption filetype=.* %{ - unset-option window formatcmd - remove-hooks window mail-auto-format - } - } +evaluate-commands %sh{ + # stdin, we assume it's a pager + if [ "$kak_bufname" = "*stdin*" ]; then + echo 'define-command -hidden ismailreader nop' + fi +} +try %{ + ismailreader + set buffer readonly true + try %{ + # remove these highlighters so everything displays properly + remove-highlighter window/number-lines + remove-highlighter window/show-whitespaces + ui-wrap-disable + ui-scrolloff-disable + } +} catch %{ + set-option window formatcmd 'mailfmt' + set-option window comment_line '>' + try autospell-enable + hook -group mail-auto-format window BufWritePre .* format + hook -once -always window WinSetOption filetype=.* %{ + unset-option window formatcmd + remove-hooks window mail-auto-format + } +} ~ hook global WinSetOption filetype=ini %{ - set-option window comment_line '#' + set-option window comment_line '#' } hook global BufCreate .*[.](conf) %{ @@ -195,7 +198,5 @@ hook global BufCreate .*[.](conf) %{ } hook global BufCreate .*[.](jinja) %{ - set-option buffer filetype html + set-option buffer filetype html } - -