diff --git a/.config/kak/autoload/email.kak b/.config/kak/autoload/email.kak index 30cd3235..8b137891 100644 --- a/.config/kak/autoload/email.kak +++ b/.config/kak/autoload/email.kak @@ -1,15 +1 @@ -declare-option -docstring 'mail formatter' str mail_fmt '/home/fic/dev/utils/mail-utils/format.py' -hook global WinSetOption filetype=mail %~ - set-option window formatcmd %opt{mail_fmt} - set-option window comment_line '>' - hook -group mail-spell window ModeChange (push|pop):.*insert %{ - try %{ spell-clear } - } - hook -group mail-spell window NormalIdle .* %{ try spell } - hook -group mail-auto-format window BufWritePre .* format - hook -once -always window WinSetOption filetype=.* %{ - unset-option window formatcmd - remove-hooks window mail-auto-format - } -~ diff --git a/.config/kak/autoload/filetype.kak b/.config/kak/autoload/filetype.kak index 1a579c23..90a26cba 100644 --- a/.config/kak/autoload/filetype.kak +++ b/.config/kak/autoload/filetype.kak @@ -71,3 +71,14 @@ hook global WinSetOption filetype=kdl %{ remove-hooks window kdl-auto-format } } + +hook global WinSetOption filetype=mail %~ + set-option window formatcmd '/home/fic/dev/utils/mail-utils/format.py' + 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 + } +~ diff --git a/.config/kak/autoload/spell.kak b/.config/kak/autoload/spell.kak index 3a42bbaa..b5ce4f63 100644 --- a/.config/kak/autoload/spell.kak +++ b/.config/kak/autoload/spell.kak @@ -1,10 +1,38 @@ # spellcheck using aspell for now (maybe better options?) provide-module spell %~ - define-command -hidden register-autospell %{ - hook -group auto-spell window ModeChange (push|pop):.*insert %{ - try %{ spell-clear } + + define-command -override -hidden true nop + define-command -override -hidden false fail + + declare-option -hidden bool autospell_enabled false + define-command -docstring %{ + Enable autospell. Autospell refreshes spellchecks and hides spelling in insert mode. + } autospell-enable %{ + try %{ + spell + hook -group auto-spell window ModeChange (push|pop):.*insert %{ + try %{ spell-clear } + } + hook -group auto-spell window NormalIdle .* %{ try spell } + } catch %{ + fail "Couldn't enable autospell!" + } + } + + define-command -docstring %{ + Disable autospell. Autospell refreshes spellchecks and hides spelling in insert mode. + } autospell-disable %{ + try spell-clear + remove-hooks window auto-spell + } + + define-command autospell-toggle %{ + try %{ + %opt{autospell_enabled} + autospell-disable + } catch %{ + autospell-enable } - hook -group auto-spell window NormalIdle .* %{ try spell } } # keybindings