AutoYADM commit: 2025-05-15 16:36:26
This commit is contained in:
parent
aaa2694df0
commit
13b7225f37
1 changed files with 39 additions and 16 deletions
|
@ -1,24 +1,47 @@
|
|||
hook global BufCreate .*[.](kdl) %{
|
||||
set-option buffer filetype kdl
|
||||
set-option buffer comment_line "//"
|
||||
set-option buffer comment_block_begin "/*"
|
||||
set-option buffer comment_block_end "*/"
|
||||
set-option window formatcmd "kdlfmt format -"
|
||||
set-option buffer filetype kdl
|
||||
set-option buffer comment_line "//"
|
||||
set-option buffer comment_block_begin "/*"
|
||||
set-option buffer comment_block_end "*/"
|
||||
set-option window formatcmd "kdlfmt format -"
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=kdl %{
|
||||
require-module kdl
|
||||
require-module kdl
|
||||
|
||||
hook window InsertChar \n -group kdl-indent %{ kdl-indent-newline }
|
||||
hook window InsertChar \} -group kdl-indent %{ kdl-indent-closing-brace }
|
||||
hook window InsertChar \n -group kdl-indent %{ kdl-indent-newline }
|
||||
hook window InsertChar \} -group kdl-indent %{ kdl-indent-closing-brace }
|
||||
|
||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kdl-indent }
|
||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kdl-indent }
|
||||
|
||||
hook -group kdl-auto-format window BufWritePre .* format
|
||||
hook -once -always WinSetOption filetype=.* %sh{
|
||||
if [ "$kak_opt_filetype" != "kdl" ]; then
|
||||
echo "unset-option window formatcmd"
|
||||
echo "remove-hooks window kdl-auto-format"
|
||||
fi
|
||||
}
|
||||
hook -group kdl-auto-format window BufWritePre .* format
|
||||
hook -once -always WinSetOption filetype=.* %sh{
|
||||
if [ "$kak_opt_filetype" != "kdl" ]; then
|
||||
echo "unset-option window formatcmd"
|
||||
echo "remove-hooks window kdl-auto-format"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
provide-module kdl %~
|
||||
|
||||
define-command -hidden kdl-indent-newline %(
|
||||
evaluate-commands -no-hooks -draft -itersel %(
|
||||
# preserve prev line indent
|
||||
try %{ execute-keys -draft K<a-&> }
|
||||
# rem trailing whitespace on prev line
|
||||
try %( execute-keys -draft kx <a-k>\{$<ret> j<a-gt> )
|
||||
|
||||
# deindent if next line start with {
|
||||
try %( execute-keys -draft x <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> )
|
||||
)
|
||||
)
|
||||
|
||||
define-command -hidden kdl-indent-closing-brace %(
|
||||
evaluate-commands -no-hooks -draft -itersel %(
|
||||
#align closing brace to block start
|
||||
try %( execute_keys -draft x_ <a-k>^\h*\}\z<ret> m<a-S>1<a-&> )
|
||||
)
|
||||
)
|
||||
|
||||
~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue