1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-18 17:02:06 +03:00

Merge remote-tracking branch 'lenormf/fix-rc-aliases'

This commit is contained in:
Maxime Coste 2017-11-03 19:32:30 +08:00
commit 9b216e0e79
82 changed files with 902 additions and 901 deletions

View File

@ -1,23 +1,23 @@
decl -docstring "maximum amount of characters per line, after which a newline character will be inserted" \ declare-option -docstring "maximum amount of characters per line, after which a newline character will be inserted" \
int autowrap_column 80 int autowrap_column 80
decl -docstring %{when enabled, paragraph formatting will reformat the whole paragraph in which characters are being inserted declare-option -docstring %{when enabled, paragraph formatting will reformat the whole paragraph in which characters are being inserted
This can potentially break formatting of documents containing markup (e.g. markdown)} \ This can potentially break formatting of documents containing markup (e.g. markdown)} \
bool autowrap_format_paragraph no bool autowrap_format_paragraph no
decl -docstring %{command to which the paragraphs to wrap will be passed declare-option -docstring %{command to which the paragraphs to wrap will be passed
all occurences of '%c' are replaced with `autowrap_column`} \ all occurences of '%c' are replaced with `autowrap_column`} \
str autowrap_fmtcmd 'fold -s -w %c' str autowrap_fmtcmd 'fold -s -w %c'
def -hidden autowrap-cursor %{ eval -save-regs '/"|^@m' %{ define-command -hidden autowrap-cursor %{ evaluate-commands -save-regs '/"|^@m' %{
try %{ try %{
## if the line isn't too long, do nothing ## if the line isn't too long, do nothing
exec -draft "<a-x><a-k>^[^\n]{%opt{autowrap_column},}[^\n]<ret>" execute-keys -draft "<a-x><a-k>^[^\n]{%opt{autowrap_column},}[^\n]<ret>"
try %{ try %{
reg m "%val{selections_desc}" reg m "%val{selections_desc}"
## if we're adding characters past the limit, just wrap them around ## if we're adding characters past the limit, just wrap them around
exec -draft "<a-h><a-k>.{%opt{autowrap_column}}\h*[^\s]*<ret>1s(\h+)[^\h]*\z<ret>c<ret>" execute-keys -draft "<a-h><a-k>.{%opt{autowrap_column}}\h*[^\s]*<ret>1s(\h+)[^\h]*\z<ret>c<ret>"
} catch %{ } catch %{
## if we're adding characters in the middle of a sentence, use ## if we're adding characters in the middle of a sentence, use
## the `fmtcmd` command to wrap the entire paragraph ## the `fmtcmd` command to wrap the entire paragraph
@ -27,9 +27,9 @@ def -hidden autowrap-cursor %{ eval -save-regs '/"|^@m' %{
format_cmd=$(printf %s "${kak_opt_autowrap_fmtcmd}" \ format_cmd=$(printf %s "${kak_opt_autowrap_fmtcmd}" \
| sed "s/%c/${kak_opt_autowrap_column}/g") | sed "s/%c/${kak_opt_autowrap_column}/g")
printf %s " printf %s "
eval -draft %{ evaluate-commands -draft %{
exec '<a-]>p<a-x><a-j>|${format_cmd}<ret>' execute-keys '<a-]>p<a-x><a-j>|${format_cmd}<ret>'
try %{ exec s\h+$<ret> d } try %{ execute-keys s\h+$<ret> d }
} }
select '${kak_reg_m}' select '${kak_reg_m}'
" "
@ -39,10 +39,10 @@ def -hidden autowrap-cursor %{ eval -save-regs '/"|^@m' %{
} }
} } } }
def autowrap-enable -docstring "Automatically wrap the lines in which characters are inserted" %{ define-command autowrap-enable -docstring "Automatically wrap the lines in which characters are inserted" %{
hook -group autowrap window InsertChar [^\n] autowrap-cursor hook -group autowrap window InsertChar [^\n] autowrap-cursor
} }
def autowrap-disable -docstring "Disable automatic line wrapping" %{ define-command autowrap-disable -docstring "Disable automatic line wrapping" %{
remove-hooks window autowrap remove-hooks window autowrap
} }

View File

@ -7,7 +7,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](cljs?) %{ hook global BufCreate .*[.](cljs?) %{
set buffer filetype clojure set-option buffer filetype clojure
} }
# Highlighters # Highlighters
@ -22,8 +22,8 @@ add-highlighter shared/clojure regex \b(clojure.core/['/\w]+)\b 0:keyword
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden clojure-filter-around-selections lisp-filter-around-selections define-command -hidden clojure-filter-around-selections lisp-filter-around-selections
def -hidden clojure-indent-on-new-line lisp-indent-on-new-line define-command -hidden clojure-indent-on-new-line lisp-indent-on-new-line
# Initialization # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](css) %{ hook global BufCreate .*[.](css) %{
set buffer filetype css set-option buffer filetype css
} }
# Highlighters # Highlighters
@ -38,26 +38,26 @@ add-highlighter shared/css/selector regex [*]|[#.][A-Za-z][A-Za-z0-9_-]* 0:varia
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden css-filter-around-selections %{ define-command -hidden css-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden css-indent-on-new-line %[ define-command -hidden css-indent-on-new-line %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# preserve previous line indent # preserve previous line indent
try %[ exec -draft \; K <a-&> ] try %[ execute-keys -draft \; K <a-&> ]
# filter previous line # filter previous line
try %[ exec -draft k : css-filter-around-selections <ret> ] try %[ execute-keys -draft k : css-filter-around-selections <ret> ]
# indent after lines ending with with { # indent after lines ending with with {
try %[ exec -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ]
] ]
] ]
def -hidden css-indent-on-closing-curly-brace %[ define-command -hidden css-indent-on-closing-curly-brace %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ]
] ]
] ]

View File

@ -3,10 +3,10 @@
# This script requires the readtags command available in ctags source but # This script requires the readtags command available in ctags source but
# not installed by default # not installed by default
decl -docstring "colon separated list of paths to tag files to parse when looking up a symbol" \ declare-option -docstring "colon separated list of paths to tag files to parse when looking up a symbol" \
str-list ctagsfiles 'tags' str-list ctagsfiles 'tags'
def -params ..1 \ define-command -params ..1 \
-shell-candidates ' -shell-candidates '
printf %s\\n "$kak_opt_ctagsfiles" | tr \':\' \'\n\' | printf %s\\n "$kak_opt_ctagsfiles" | tr \':\' \'\n\' |
while read -r candidate; do while read -r candidate; do
@ -37,47 +37,47 @@ If no symbol is passed then the current selection is used as symbol name} \
re=$0; re=$0;
sub(".*\t/\\^", "", re); sub("\\$?/$", "", re); gsub("(\\{|\\}|\\\\E).*$", "", re); sub(".*\t/\\^", "", re); sub("\\$?/$", "", re); gsub("(\\{|\\}|\\\\E).*$", "", re);
keys=re; gsub(/</, "<lt>", keys); gsub(/\t/, "<c-v><c-i>", keys); keys=re; gsub(/</, "<lt>", keys); gsub(/\t/, "<c-v><c-i>", keys);
out = out " %{" $2 " {MenuInfo}" re "} %{eval -collapse-jumps %{ try %{ edit %{" tagroot $2 "}; exec %{/\\Q" keys "<ret>vc} } catch %{ echo %{unable to find tag} } } }" out = out " %{" $2 " {MenuInfo}" re "} %{evaluate-commands -collapse-jumps %{ try %{ edit %{" tagroot $2 "}; execute-keys %{/\\Q" keys "<ret>vc} } catch %{ echo %{unable to find tag} } } }"
} }
/[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{eval -collapse-jumps %{ edit %{" tagroot $2 "} %{" $3 "}}}" } /[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{evaluate-commands -collapse-jumps %{ edit %{" tagroot $2 "} %{" $3 "}}}" }
END { print ( length(out) == 0 ? "echo -markup %{{Error}no such tag " ENVIRON["tagname"] "}" : "menu -markup -auto-single " out ) }' END { print ( length(out) == 0 ? "echo -markup %{{Error}no such tag " ENVIRON["tagname"] "}" : "menu -markup -auto-single " out ) }'
}} }}
def ctags-complete -docstring "Insert completion candidates for the current selection into the buffer's local variables" %{ eval -draft %{ define-command ctags-complete -docstring "Insert completion candidates for the current selection into the buffer's local variables" %{ evaluate-commands -draft %{
exec <space>hb<a-k>^\w+$<ret> execute-keys <space>hb<a-k>^\w+$<ret>
%sh{ { %sh{ {
compl=$(readtags -p "$kak_selection" | cut -f 1 | sort | uniq | sed -e 's/:/\\:/g' | sed -e 's/\n/:/g' ) compl=$(readtags -p "$kak_selection" | cut -f 1 | sort | uniq | sed -e 's/:/\\:/g' | sed -e 's/\n/:/g' )
compl="${kak_cursor_line}.${kak_cursor_column}+${#kak_selection}@${kak_timestamp}:${compl}" compl="${kak_cursor_line}.${kak_cursor_column}+${#kak_selection}@${kak_timestamp}:${compl}"
printf %s\\n "set buffer=$kak_bufname ctags_completions '${compl}'" | kak -p ${kak_session} printf %s\\n "set-option buffer=$kak_bufname ctags_completions '${compl}'" | kak -p ${kak_session}
} > /dev/null 2>&1 < /dev/null & } } > /dev/null 2>&1 < /dev/null & }
}} }}
def ctags-funcinfo -docstring "Display ctags information about a selected function" %{ define-command ctags-funcinfo -docstring "Display ctags information about a selected function" %{
eval -draft %{ evaluate-commands -draft %{
try %{ try %{
exec -no-hooks '[(;B<a-k>[a-zA-Z_]+\(<ret><a-;>' execute-keys -no-hooks '[(;B<a-k>[a-zA-Z_]+\(<ret><a-;>'
%sh{ %sh{
sigs=$(readtags -e ${kak_selection%(} | grep kind:f | sed -re 's/^(\S+).*((class|struct|namespace):(\S+))?.*signature:(.*)$/\5 [\4::\1]/') sigs=$(readtags -e ${kak_selection%(} | grep kind:f | sed -re 's/^(\S+).*((class|struct|namespace):(\S+))?.*signature:(.*)$/\5 [\4::\1]/')
if [ -n "$sigs" ]; then if [ -n "$sigs" ]; then
printf %s\\n "eval -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -placement above '$sigs'}" printf %s\\n "evaluate-commands -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -placement above '$sigs'}"
fi fi
} }
} }
} }
} }
def ctags-enable-autoinfo -docstring "Automatically display ctags information about function" %{ define-command ctags-enable-autoinfo -docstring "Automatically display ctags information about function" %{
hook window -group ctags-autoinfo NormalIdle .* ctags-funcinfo hook window -group ctags-autoinfo NormalIdle .* ctags-funcinfo
hook window -group ctags-autoinfo InsertIdle .* ctags-funcinfo hook window -group ctags-autoinfo InsertIdle .* ctags-funcinfo
} }
def ctags-disable-autoinfo -docstring "Disable automatic ctags information displaying" %{ remove-hooks window ctags-autoinfo } define-command ctags-disable-autoinfo -docstring "Disable automatic ctags information displaying" %{ remove-hooks window ctags-autoinfo }
decl -docstring "options to pass to the `ctags` shell command" \ declare-option -docstring "options to pass to the `ctags` shell command" \
str ctagsopts "-R" str ctagsopts "-R"
decl -docstring "path to the directory in which the tags file will be generated" str ctagspaths "." declare-option -docstring "path to the directory in which the tags file will be generated" str ctagspaths "."
def ctags-generate -docstring 'Generate tag file asynchronously' %{ define-command ctags-generate -docstring 'Generate tag file asynchronously' %{
echo -markup "{Information}launching tag generation in the background" echo -markup "{Information}launching tag generation in the background"
%sh{ { %sh{ {
while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done
@ -90,11 +90,11 @@ def ctags-generate -docstring 'Generate tag file asynchronously' %{
msg="tags generation failed" msg="tags generation failed"
fi fi
printf %s\\n "eval -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session} printf %s\\n "evaluate-commands -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session}
} > /dev/null 2>&1 < /dev/null & } } > /dev/null 2>&1 < /dev/null & }
} }
def ctags-update-tags -docstring 'Update tags for the given file' %{ define-command ctags-update-tags -docstring 'Update tags for the given file' %{
%sh{ { %sh{ {
while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done
trap 'rmdir .tags.kaklock' EXIT trap 'rmdir .tags.kaklock' EXIT
@ -110,6 +110,6 @@ def ctags-update-tags -docstring 'Update tags for the given file' %{
msg="tags update failed for $kak_bufname" msg="tags update failed for $kak_bufname"
fi fi
printf %s\\n "eval -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session} printf %s\\n "evaluate-commands -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session}
} > /dev/null 2>&1 < /dev/null & } } > /dev/null 2>&1 < /dev/null & }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.di? %{ hook global BufCreate .*\.di? %{
set buffer filetype d set-option buffer filetype d
} }
# Highlighters # Highlighters
@ -63,7 +63,7 @@ add-highlighter shared/d/code regex "\b(this)\b\s*[^(]" 1:value
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=d %{ printf %s\\n "hook global WinSetOption filetype=d %{
set window static_words '${keywords}:${attributes}:${types}:${values}:${decorators}:${properties}' set-option window static_words '${keywords}:${attributes}:${types}:${values}:${decorators}:${properties}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -81,33 +81,33 @@ add-highlighter shared/d/code regex "\b(this)\b\s*[^(]" 1:value
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden d-indent-on-new-line %~ define-command -hidden d-indent-on-new-line %~
eval -draft -itersel %= evaluate-commands -draft -itersel %=
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
# cleanup trailing white spaces on the previous line # cleanup trailing white spaces on the previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> } try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ exec -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ exec -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
= =
~ ~
def -hidden d-indent-on-opening-curly-brace %[ define-command -hidden d-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
def -hidden d-indent-on-closing-curly-brace %[ define-command -hidden d-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization # Initialization
@ -117,7 +117,7 @@ hook -group d-highlight global WinSetOption filetype=d %{ add-highlighter window
hook global WinSetOption filetype=d %{ hook global WinSetOption filetype=d %{
# cleanup trailing whitespaces when exiting insert mode # cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -group d-hooks %{ try %{ exec -draft <a-x>s^\h+$<ret>d } } hook window InsertEnd .* -group d-hooks %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group d-indent d-indent-on-new-line hook window InsertChar \n -group d-indent d-indent-on-new-line
hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace
hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace

View File

@ -1,15 +1,15 @@
# Highlighting for common files in /etc # Highlighting for common files in /etc
hook global BufCreate .*/etc/(hosts|networks|services) %{ set buffer filetype etc-hosts } hook global BufCreate .*/etc/(hosts|networks|services) %{ set-option buffer filetype etc-hosts }
hook global BufCreate .*/etc/resolv.conf %{ set buffer filetype etc-resolv-conf } hook global BufCreate .*/etc/resolv.conf %{ set-option buffer filetype etc-resolv-conf }
hook global BufCreate .*/etc/shadow %{ set buffer filetype etc-shadow } hook global BufCreate .*/etc/shadow %{ set-option buffer filetype etc-shadow }
hook global BufCreate .*/etc/passwd %{ set buffer filetype etc-passwd } hook global BufCreate .*/etc/passwd %{ set-option buffer filetype etc-passwd }
hook global BufCreate .*/etc/gshadow %{ set buffer filetype etc-gshadow } hook global BufCreate .*/etc/gshadow %{ set-option buffer filetype etc-gshadow }
hook global BufCreate .*/etc/group %{ set buffer filetype etc-group } hook global BufCreate .*/etc/group %{ set-option buffer filetype etc-group }
hook global BufCreate .*/etc/(fs|m)tab %{ set buffer filetype etc-fstab } hook global BufCreate .*/etc/(fs|m)tab %{ set-option buffer filetype etc-fstab }
hook global BufCreate .*/etc/environment %{ set buffer filetype sh } hook global BufCreate .*/etc/environment %{ set-option buffer filetype sh }
hook global BufCreate .*/etc/env.d/.* %{ set buffer filetype sh } hook global BufCreate .*/etc/env.d/.* %{ set-option buffer filetype sh }
hook global BufCreate .*/etc/profile(\.(csh|env))? %{ set buffer filetype sh } hook global BufCreate .*/etc/profile(\.(csh|env))? %{ set-option buffer filetype sh }
hook global BufCreate .*/etc/profile\.d/.* %{ set buffer filetype sh } hook global BufCreate .*/etc/profile\.d/.* %{ set-option buffer filetype sh }
# Highlighters # Highlighters
## /etc/resolv.conf ## /etc/resolv.conf

View File

@ -10,7 +10,7 @@ hook global BufOpenFile .* %{ %sh{
text/*) filetype="${mime#text/}" ;; text/*) filetype="${mime#text/}" ;;
esac esac
if [ -n "${filetype}" ]; then if [ -n "${filetype}" ]; then
printf "set buffer filetype '%s'\n" "${filetype}" printf "set-option buffer filetype '%s'\n" "${filetype}"
fi fi
fi fi
} } } }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](fish) %{ hook global BufCreate .*[.](fish) %{
set buffer filetype fish set-option buffer filetype fish
} }
# Highlighters # Highlighters
@ -29,41 +29,41 @@ add-highlighter shared/fish/code regex \b(and|begin|bg|bind|block|break|breakpoi
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden fish-filter-around-selections %{ define-command -hidden fish-filter-around-selections %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft <a-x>s\h+$<ret>d } try %{ execute-keys -draft <a-x>s\h+$<ret>d }
} }
} }
def -hidden fish-indent-on-char %{ define-command -hidden fish-indent-on-char %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# align middle and end structures to start and indent when necessary # align middle and end structures to start and indent when necessary
try %{ exec -draft <a-x><a-k>^\h*(else)$<ret><a-\;><a-?>^\h*(if)<ret>s\A|\z<ret>'<a-&> } try %{ execute-keys -draft <a-x><a-k>^\h*(else)$<ret><a-\;><a-?>^\h*(if)<ret>s\A|\z<ret>'<a-&> }
try %{ exec -draft <a-x><a-k>^\h*(end)$<ret><a-\;><a-?>^\h*(begin|for|function|if|switch|while)<ret>s\A|\z<ret>'<a-&> } try %{ execute-keys -draft <a-x><a-k>^\h*(end)$<ret><a-\;><a-?>^\h*(begin|for|function|if|switch|while)<ret>s\A|\z<ret>'<a-&> }
try %{ exec -draft <a-x><a-k>^\h*(case)$<ret><a-\;><a-?>^\h*(switch)<ret>s\A|\z<ret>'<a-&>'<space><a-gt> } try %{ execute-keys -draft <a-x><a-k>^\h*(case)$<ret><a-\;><a-?>^\h*(switch)<ret>s\A|\z<ret>'<a-&>'<space><a-gt> }
} }
} }
def -hidden fish-indent-on-new-line %{ define-command -hidden fish-indent-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft <space>K<a-&> } try %{ execute-keys -draft <space>K<a-&> }
# filter previous line # filter previous line
try %{ exec -draft k:fish-filter-around-selections<ret> } try %{ execute-keys -draft k:fish-filter-around-selections<ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k<a-x><a-k>^\h*(begin|case|else|for|function|if|switch|while)\b<ret>j<a-gt> } try %{ execute-keys -draft k<a-x><a-k>^\h*(begin|case|else|for|function|if|switch|while)\b<ret>j<a-gt> }
} }
} }
def -hidden fish-insert-on-new-line %{ define-command -hidden fish-insert-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# copy _#_ comment prefix and following white spaces # copy _#_ comment prefix and following white spaces
try %{ exec -draft k<a-x>s^\h*\K#\h*<ret>yjp } try %{ execute-keys -draft k<a-x>s^\h*\K#\h*<ret>yjp }
# wisely add end structure # wisely add end structure
eval -save-regs x %{ evaluate-commands -save-regs x %{
try %{ exec -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' } try %{ execute-keys -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' }
try %{ exec -draft k<a-x><a-k>^<c-r>x(begin|for|function|if|switch|while)<ret>j<a-a>iX<a-\;>K<a-K>^<c-r>x(begin|for|function|if|switch|while).*\n<c-r>xend$<ret>jxypjaend<esc><a-lt> } try %{ execute-keys -draft k<a-x><a-k>^<c-r>x(begin|for|function|if|switch|while)<ret>j<a-a>iX<a-\;>K<a-K>^<c-r>x(begin|for|function|if|switch|while).*\n<c-r>xend$<ret>jxypjaend<esc><a-lt> }
} }
} }
} }

View File

@ -1,7 +1,7 @@
# Detection # Detection
# --------- # ---------
hook global BufCreate .*\.(s|S|asm)$ %{ hook global BufCreate .*\.(s|S|asm)$ %{
set buffer filetype gas set-option buffer filetype gas
} }
@ -66,22 +66,22 @@ add-highlighter shared/gas/code regex \
^\h*(cvttp[ds]2dq|cvttp[ds]2pi|cvtts[ds]2si)\b|\ ^\h*(cvttp[ds]2dq|cvttp[ds]2pi|cvtts[ds]2si)\b|\
^\h*(vxorp[sd]|vandp[sd]|ucomis[sd])\b 0:keyword ^\h*(vxorp[sd]|vandp[sd]|ucomis[sd])\b 0:keyword
def -hidden gas-filter-around-selections %{ define-command -hidden gas-filter-around-selections %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
exec <a-x> execute-keys <a-x>
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft s \h+$ <ret> d } try %{ execute-keys -draft s \h+$ <ret> d }
} }
} }
def -hidden gas-indent-on-new-line %~ define-command -hidden gas-indent-on-new-line %~
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : gas-filter-around-selections <ret> } try %{ execute-keys -draft k : gas-filter-around-selections <ret> }
# indent after label # indent after label
try %[ exec -draft k <a-x> <a-k> :$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> :$ <ret> j <a-gt> ]
> >
~ ~

View File

@ -1,5 +1,5 @@
hook global BufCreate .*(COMMIT_EDITMSG|MERGE_MSG) %{ hook global BufCreate .*(COMMIT_EDITMSG|MERGE_MSG) %{
set buffer filetype git-commit set-option buffer filetype git-commit
} }
hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ hook -group git-commit-highlight global WinSetOption filetype=git-commit %{
@ -12,7 +12,7 @@ hook -group git-commit-highlight global WinSetOption filetype=git-commit %{
hook -group git-commit-highlight global WinSetOption filetype=(?!git-commit).* %{ remove-highlighter window/git-commit-highlight } hook -group git-commit-highlight global WinSetOption filetype=(?!git-commit).* %{ remove-highlighter window/git-commit-highlight }
hook global BufCreate .*git-rebase-todo %{ hook global BufCreate .*git-rebase-todo %{
set buffer filetype git-rebase set-option buffer filetype git-rebase
} }
hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.go %{ hook global BufCreate .*\.go %{
set buffer filetype go set-option buffer filetype go
} }
# Highlighters # Highlighters
@ -37,7 +37,7 @@ add-highlighter shared/go/code regex %{-?([0-9]*\.(?!0[xX]))?\b([0-9]+|0[xX][0-9
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=go %{ printf %s\\n "hook global WinSetOption filetype=go %{
set window static_words '${keywords}:${attributes}:${types}:${values}:${functions}' set-option window static_words '${keywords}:${attributes}:${types}:${values}:${functions}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -53,33 +53,33 @@ add-highlighter shared/go/code regex %{-?([0-9]*\.(?!0[xX]))?\b([0-9]+|0[xX][0-9
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden go-indent-on-new-line %~ define-command -hidden go-indent-on-new-line %~
eval -draft -itersel %= evaluate-commands -draft -itersel %=
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
# cleanup trailing white spaces on the previous line # cleanup trailing white spaces on the previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> } try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ exec -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ exec -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
= =
~ ~
def -hidden go-indent-on-opening-curly-brace %[ define-command -hidden go-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
def -hidden go-indent-on-closing-curly-brace %[ define-command -hidden go-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization # Initialization
@ -89,7 +89,7 @@ hook -group go-highlight global WinSetOption filetype=go %{ add-highlighter wind
hook global WinSetOption filetype=go %{ hook global WinSetOption filetype=go %{
# cleanup trailing whitespaces when exiting insert mode # cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -group go-hooks %{ try %{ exec -draft <a-x>s^\h+$<ret>d } } hook window InsertEnd .* -group go-hooks %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group go-indent go-indent-on-new-line hook window InsertChar \n -group go-indent go-indent-on-new-line
hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace
hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](hs) %{ hook global BufCreate .*[.](hs) %{
set buffer filetype haskell set-option buffer filetype haskell
} }
# Highlighters # Highlighters
@ -72,23 +72,23 @@ add-highlighter shared/haskell/code regex \B'([^\\]|[\\]['"\w\d\\])' 0:string
# http://en.wikibooks.org/wiki/Haskell/Indentation # http://en.wikibooks.org/wiki/Haskell/Indentation
def -hidden haskell-filter-around-selections %{ define-command -hidden haskell-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden haskell-indent-on-new-line %{ define-command -hidden haskell-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy -- comments prefix and following white spaces # copy -- comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# align to first clause # align to first clause
try %{ exec -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|do|let|where)\h+\K.* <ret> s \A|.\z <ret> & } try %{ execute-keys -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|do|let|where)\h+\K.* <ret> s \A|.\z <ret> & }
# filter previous line # filter previous line
try %{ exec -draft k : haskell-filter-around-selections <ret> } try %{ execute-keys -draft k : haskell-filter-around-selections <ret> }
# indent after lines beginning with condition or ending with expression or =( # indent after lines beginning with condition or ending with expression or =(
try %{ exec -draft \; k x <a-k> ^\h*(if)|(case\h+[\w']+\h+of|do|let|where|[=(])$ <ret> j <a-gt> } try %{ execute-keys -draft \; k x <a-k> ^\h*(if)|(case\h+[\w']+\h+of|do|let|where|[=(])$ <ret> j <a-gt> }
} }
} }
@ -98,7 +98,7 @@ def -hidden haskell-indent-on-new-line %{
hook -group haskell-highlight global WinSetOption filetype=haskell %{ add-highlighter window ref haskell } hook -group haskell-highlight global WinSetOption filetype=haskell %{ add-highlighter window ref haskell }
hook global WinSetOption filetype=haskell %{ hook global WinSetOption filetype=haskell %{
set window extra_word_chars "'" set-option window extra_word_chars "'"
hook window InsertEnd .* -group haskell-hooks haskell-filter-around-selections hook window InsertEnd .* -group haskell-hooks haskell-filter-around-selections
hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line
} }

View File

@ -5,11 +5,11 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.html %{ hook global BufCreate .*\.html %{
set buffer filetype html set-option buffer filetype html
} }
hook global BufCreate .*\.xml %{ hook global BufCreate .*\.xml %{
set buffer filetype xml set-option buffer filetype xml
} }
# Highlighters # Highlighters
@ -39,26 +39,26 @@ add-highlighter shared/html/tag/content/string fill string
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden html-filter-around-selections %{ define-command -hidden html-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden html-indent-on-greater-than %[ define-command -hidden html-indent-on-greater-than %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align closing tag to opening when alone on a line # align closing tag to opening when alone on a line
try %[ exec -draft <space> <a-h> s ^\h+<lt>/(\w+)<gt>$ <ret> {c<lt><c-r>1,<lt>/<c-r>1<gt> <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft <space> <a-h> s ^\h+<lt>/(\w+)<gt>$ <ret> {c<lt><c-r>1,<lt>/<c-r>1<gt> <ret> s \A|.\z <ret> 1<a-&> ]
] ]
] ]
def -hidden html-indent-on-new-line %{ define-command -hidden html-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : html-filter-around-selections <ret> } try %{ execute-keys -draft k : html-filter-around-selections <ret> }
# indent after lines ending with opening tag # indent after lines ending with opening tag
try %{ exec -draft k <a-x> <a-k> <[^/][^>]+>$ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> <[^/][^>]+>$ <ret> j <a-gt> }
} }
} }

View File

@ -1,5 +1,5 @@
hook global BufCreate .*\.(repo|service|target|socket|ini|cfg) %{ hook global BufCreate .*\.(repo|service|target|socket|ini|cfg) %{
set buffer filetype ini set-option buffer filetype ini
} }
add-highlighter shared/ regions -default code ini \ add-highlighter shared/ regions -default code ini \

View File

@ -1,5 +1,5 @@
hook global BufCreate .*\.java %{ hook global BufCreate .*\.java %{
set buffer filetype java set-option buffer filetype java
} }
add-highlighter shared/ regions -default code java \ add-highlighter shared/ regions -default code java \
@ -18,40 +18,40 @@ add-highlighter shared/java/code regex "\b(final|public|protected|private|abstra
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden java-indent-on-new-line %~ define-command -hidden java-indent-on-new-line %~
eval -draft -itersel %= evaluate-commands -draft -itersel %=
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
# cleanup trailing white spaces on the previous line # cleanup trailing white spaces on the previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> } try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ exec -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after keywords # indent after keywords
try %[ exec -draft \;<a-F>)MB <a-k> \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft \;<a-F>)MB <a-k> \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
= =
~ ~
def -hidden java-indent-on-opening-curly-brace %[ define-command -hidden java-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
def -hidden java-indent-on-closing-curly-brace %[ define-command -hidden java-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=java %{ hook global WinSetOption filetype=java %{
# cleanup trailing whitespaces when exiting insert mode # cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -group java-hooks %{ try %{ exec -draft <a-x>s^\h+$<ret>d } } hook window InsertEnd .* -group java-hooks %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group java-indent java-indent-on-new-line hook window InsertChar \n -group java-indent java-indent-on-new-line
hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace
hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace

View File

@ -2,7 +2,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](js) %{ hook global BufCreate .*[.](js) %{
set buffer filetype javascript set-option buffer filetype javascript
} }
# Highlighters # Highlighters
@ -39,28 +39,28 @@ add-highlighter shared/javascript/code regex \b(async|await|break|case|catch|cla
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden javascript-filter-around-selections %{ define-command -hidden javascript-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden javascript-indent-on-char %< define-command -hidden javascript-indent-on-char %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %/ exec -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> / try %/ execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> /
> >
> >
def -hidden javascript-indent-on-new-line %< define-command -hidden javascript-indent-on-new-line %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# copy // comments prefix and following white spaces # copy // comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : javascript-filter-around-selections <ret> } try %{ execute-keys -draft k : javascript-filter-around-selections <ret> }
# indent after lines beginning / ending with opener token # indent after lines beginning / ending with opener token
try %_ exec -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _ try %_ execute-keys -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
> >
> >

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](json) %{ hook global BufCreate .*[.](json) %{
set buffer filetype json set-option buffer filetype json
} }
# Highlighters # Highlighters
@ -21,26 +21,26 @@ add-highlighter shared/json/code regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][+
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden json-filter-around-selections %{ define-command -hidden json-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden json-indent-on-char %< define-command -hidden json-indent-on-char %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %< exec -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> >
> >
> >
def -hidden json-indent-on-new-line %< define-command -hidden json-indent-on-new-line %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : json-filter-around-selections <ret> } try %{ execute-keys -draft k : json-filter-around-selections <ret> }
# indent after lines beginning with opener token # indent after lines beginning with opener token
try %< exec -draft k <a-x> <a-k> ^\h*[[{] <ret> j <a-gt> > try %< execute-keys -draft k <a-x> <a-k> ^\h*[[{] <ret> j <a-gt> >
> >
> >

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.(jl) %{ hook global BufCreate .*\.(jl) %{
set buffer filetype julia set-option buffer filetype julia
} }
# Highlighters # Highlighters

View File

@ -1,21 +1,21 @@
decl -docstring %{shell command to which the path of a copy of the current buffer will be passed declare-option -docstring %{shell command to which the path of a copy of the current buffer will be passed
The output returned by this command is expected to comply with the following format: The output returned by this command is expected to comply with the following format:
{filename}:{line}:{column}: {kind}: {message}} \ {filename}:{line}:{column}: {kind}: {message}} \
str lintcmd str lintcmd
decl -hidden line-specs lint_flags declare-option -hidden line-specs lint_flags
decl -hidden range-specs lint_errors declare-option -hidden range-specs lint_errors
def lint -docstring 'Parse the current buffer with a linter' %{ define-command lint -docstring 'Parse the current buffer with a linter' %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-lint.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-lint.XXXXXXXX)
mkfifo "$dir"/fifo mkfifo "$dir"/fifo
printf '%s\n' "eval -no-hooks write $dir/buf" printf '%s\n' "evaluate-commands -no-hooks write $dir/buf"
printf '%s\n' "eval -draft %{ printf '%s\n' "evaluate-commands -draft %{
edit! -fifo $dir/fifo -debug *lint-output* edit! -fifo $dir/fifo -debug *lint-output*
set buffer filetype make set-option buffer filetype make
set buffer make_current_error_line 0 set-option buffer make_current_error_line 0
hook -group fifo buffer BufCloseFifo .* %{ hook -group fifo buffer BufCloseFifo .* %{
nop %sh{ rm -r '$dir' } nop %sh{ rm -r '$dir' }
remove-hooks buffer fifo remove-hooks buffer fifo
@ -24,8 +24,8 @@ def lint -docstring 'Parse the current buffer with a linter' %{
{ # do the parsing in the background and when ready send to the session { # do the parsing in the background and when ready send to the session
eval "$kak_opt_lintcmd '$dir'/buf" | sort -t: -k2,2 -n > "$dir"/stderr evaluate-commands "$kak_opt_lintcmd '$dir'/buf" | sort -t: -k2,2 -n > "$dir"/stderr
printf '%s\n' "eval -client $kak_client echo 'linting done'" | kak -p "$kak_session" printf '%s\n' "evaluate-commands -client $kak_client echo 'linting done'" | kak -p "$kak_session"
# Flags for the gutter: # Flags for the gutter:
# line3|{red}:line11|{yellow} # line3|{red}:line11|{yellow}
@ -48,10 +48,10 @@ def lint -docstring 'Parse the current buffer with a linter' %{
errors = substr(errors, 1, length(errors)-1) " (col " $3 ")" errors = substr(errors, 1, length(errors)-1) " (col " $3 ")"
} }
END { END {
print "set \"buffer=" file "\" lint_flags %{" stamp ":" substr(flags, 1, length(flags)-1) "}" print "set-option \"buffer=" file "\" lint_flags %{" stamp ":" substr(flags, 1, length(flags)-1) "}"
errors = substr(errors, 1, length(errors)-1) errors = substr(errors, 1, length(errors)-1)
gsub("~", "\\~", errors) gsub("~", "\\~", errors)
print "set \"buffer=" file "\" lint_errors %~" stamp errors "~" print "set-option \"buffer=" file "\" lint_errors %~" stamp errors "~"
} }
' "$dir"/stderr | kak -p "$kak_session" ' "$dir"/stderr | kak -p "$kak_session"
@ -61,7 +61,7 @@ def lint -docstring 'Parse the current buffer with a linter' %{
} }
} }
def -hidden lint-show %{ define-command -hidden lint-show %{
update-option buffer lint_errors update-option buffer lint_errors
%sh{ %sh{
desc=$(printf '%s\n' "$kak_opt_lint_errors" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | desc=$(printf '%s\n' "$kak_opt_lint_errors" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 |
@ -71,17 +71,17 @@ def -hidden lint-show %{
fi fi
} } } }
def lint-enable -docstring "Activate automatic diagnostics of the code" %{ define-command lint-enable -docstring "Activate automatic diagnostics of the code" %{
add-highlighter window flag_lines default lint_flags add-highlighter window flag_lines default lint_flags
hook window -group lint-diagnostics NormalIdle .* %{ lint-show } hook window -group lint-diagnostics NormalIdle .* %{ lint-show }
} }
def lint-disable -docstring "Disable automatic diagnostics of the code" %{ define-command lint-disable -docstring "Disable automatic diagnostics of the code" %{
remove-highlighter window/hlflags_lint_flags remove-highlighter window/hlflags_lint_flags
remove-hooks window lint-diagnostics remove-hooks window lint-diagnostics
} }
def lint-next-error -docstring "Jump to the next line that contains an error" %{ define-command lint-next-error -docstring "Jump to the next line that contains an error" %{
update-option buffer lint_errors update-option buffer lint_errors
%sh{ %sh{
printf '%s\n' "$kak_opt_lint_errors" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | { printf '%s\n' "$kak_opt_lint_errors" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | {
@ -102,7 +102,7 @@ def lint-next-error -docstring "Jump to the next line that contains an error" %{
} }
}} }}
def lint-previous-error -docstring "Jump to the previous line that contains an error" %{ define-command lint-previous-error -docstring "Jump to the previous line that contains an error" %{
update-option buffer lint_errors update-option buffer lint_errors
%sh{ %sh{
printf '%s\n' "$kak_opt_lint_errors" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | sort -t. -k1,1 -rn | { printf '%s\n' "$kak_opt_lint_errors" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | sort -t. -k1,1 -rn | {

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](lisp) %{ hook global BufCreate .*[.](lisp) %{
set buffer filetype lisp set-option buffer filetype lisp
} }
# Highlighters # Highlighters
@ -26,17 +26,17 @@ add-highlighter shared/lisp/code regex \b(def[a-z]+|if|do|let|lambda|catch|and|a
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden lisp-filter-around-selections %{ define-command -hidden lisp-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden lisp-indent-on-new-line %{ define-command -hidden lisp-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# indent when matches opening paren # indent when matches opening paren
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> <a-\;> \; <a-gt> } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> <a-\;> \; <a-gt> }
} }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](lua) %{ hook global BufCreate .*[.](lua) %{
set buffer filetype lua set-option buffer filetype lua
} }
# Highlighters # Highlighters
@ -26,7 +26,7 @@ add-highlighter shared/lua/code regex \b(and|break|do|else|elseif|end|false|for|
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def lua-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ %sh{ define-command lua-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ %sh{
case $kak_buffile in case $kak_buffile in
*spec/*_spec.lua) *spec/*_spec.lua)
altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
@ -51,40 +51,40 @@ def lua-alternative-file -docstring 'Jump to the alternate file (implementation
printf %s\\n "edit $altfile" printf %s\\n "edit $altfile"
}} }}
def -hidden lua-filter-around-selections %{ define-command -hidden lua-filter-around-selections %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft <a-x>s\h+$<ret>d } try %{ execute-keys -draft <a-x>s\h+$<ret>d }
} }
} }
def -hidden lua-indent-on-char %{ define-command -hidden lua-indent-on-char %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# align middle and end structures to start and indent when necessary, elseif is already covered by else # align middle and end structures to start and indent when necessary, elseif is already covered by else
try %{ exec -draft <a-x><a-k>^\h*(else)$<ret><a-\;><a-?>^\h*(if)<ret>s\A|\z<ret>'<a-&> } try %{ execute-keys -draft <a-x><a-k>^\h*(else)$<ret><a-\;><a-?>^\h*(if)<ret>s\A|\z<ret>'<a-&> }
try %{ exec -draft <a-x><a-k>^\h*(end)$<ret><a-\;><a-?>^\h*(for|function|if|while)<ret>s\A|\z<ret>'<a-&> } try %{ execute-keys -draft <a-x><a-k>^\h*(end)$<ret><a-\;><a-?>^\h*(for|function|if|while)<ret>s\A|\z<ret>'<a-&> }
} }
} }
def -hidden lua-indent-on-new-line %{ define-command -hidden lua-indent-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft <space>K<a-&> } try %{ execute-keys -draft <space>K<a-&> }
# filter previous line # filter previous line
try %{ exec -draft k:lua-filter-around-selections<ret> } try %{ execute-keys -draft k:lua-filter-around-selections<ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k<a-x><a-k>^\h*(else|elseif|for|function|if|while)\b<ret>j<a-gt> } try %{ execute-keys -draft k<a-x><a-k>^\h*(else|elseif|for|function|if|while)\b<ret>j<a-gt> }
} }
} }
def -hidden lua-insert-on-new-line %{ define-command -hidden lua-insert-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# copy -- comment prefix and following white spaces # copy -- comment prefix and following white spaces
try %{ exec -draft k<a-x>s^\h*\K--\h*<ret>yghjP } try %{ execute-keys -draft k<a-x>s^\h*\K--\h*<ret>yghjP }
# wisely add end structure # wisely add end structure
eval -save-regs x %{ evaluate-commands -save-regs x %{
try %{ exec -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' } try %{ execute-keys -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' }
try %{ exec -draft k<a-x><a-k>^<c-r>x(for|function|if|while)<ret>j<a-a>iX<a-\;>K<a-K>^<c-r>x(for|function|if|while).*\n<c-r>x(else|end|elseif[^\n]*)$<ret>jxypjaend<esc><a-lt> } try %{ execute-keys -draft k<a-x><a-k>^<c-r>x(for|function|if|while)<ret>j<a-a>iX<a-\;>K<a-K>^<c-r>x(for|function|if|while).*\n<c-r>x(else|end|elseif[^\n]*)$<ret>jxypjaend<esc><a-lt> }
} }
} }
} }

View File

@ -1,5 +1,5 @@
hook global BufCreate .+\.eml %{ hook global BufCreate .+\.eml %{
set buffer filetype mail set-option buffer filetype mail
} }
add-highlighter shared/ group mail add-highlighter shared/ group mail

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](markdown|md|mkd) %{ hook global BufCreate .*[.](markdown|md|mkd) %{
set buffer filetype markdown set-option buffer filetype markdown
} }
# Highlighters # Highlighters
@ -123,14 +123,14 @@ add-highlighter shared/markdown/content regex \H\K\h\h$ 0:PrimarySelection
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden markdown-indent-on-new-line %{ define-command -hidden markdown-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy block quote(s), list item prefix and following white spaces # copy block quote(s), list item prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel %{ k<a-x> s \h+$ <ret> d } } try %{ execute-keys -draft -itersel %{ k<a-x> s \h+$ <ret> d } }
} }
} }

View File

@ -4,13 +4,13 @@
# Faces # Faces
# ‾‾‾‾‾ # ‾‾‾‾‾
face MercurialCommitComment cyan set-face MercurialCommitComment cyan
# Detection # Detection
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*hg-editor-\w+\.txt$ %{ hook global BufCreate .*hg-editor-\w+\.txt$ %{
set buffer filetype hg-commit set-option buffer filetype hg-commit
} }
hook -group hg-commit-highlight global WinSetOption filetype=(?!hg-commit).* %{ hook -group hg-commit-highlight global WinSetOption filetype=(?!hg-commit).* %{

View File

@ -7,7 +7,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.mli? %{ hook global BufCreate .*\.mli? %{
set buffer filetype ocaml set-option buffer filetype ocaml
} }
# Highlighters # Highlighters
@ -23,9 +23,9 @@ add-highlighter shared/ocaml/comment fill comment
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden ocaml-indent-on-char %{ define-command -hidden ocaml-indent-on-char %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
exec ";i<space><esc>Gg|ocp-indent --config base=%opt{indentwidth} --indent-empty --lines %val{cursor_line}<ret>" execute-keys ";i<space><esc>Gg|ocp-indent --config base=%opt{indentwidth} --indent-empty --lines %val{cursor_line}<ret>"
} }
} }
@ -52,7 +52,7 @@ hook global WinSetOption filetype=(?!ocaml).* %{
echo " echo "
add-highlighter shared/ocaml/code regex \b($(printf $keywords | tr : '|'))\b 0:keyword add-highlighter shared/ocaml/code regex \b($(printf $keywords | tr : '|'))\b 0:keyword
hook global WinSetOption filetype=ocaml %{ hook global WinSetOption filetype=ocaml %{
set window static_words $keywords set-option window static_words $keywords
} }
hook global WinSetOption filetype=(?!ocaml).* %{ hook global WinSetOption filetype=(?!ocaml).* %{
unset window static_words unset window static_words

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.p[lm] %{ hook global BufCreate .*\.p[lm] %{
set buffer filetype perl set-option buffer filetype perl
} }
# Highlighters # Highlighters
@ -41,7 +41,7 @@ add-highlighter shared/perl/comment fill comment
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=perl %{ printf %s\\n "hook global WinSetOption filetype=perl %{
set window static_words '${keywords}:${attributes}:${values}' set-option window static_words '${keywords}:${attributes}:${values}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -70,33 +70,33 @@ add-highlighter shared/perl/code regex \$(LAST_REGEXP_CODE_RESULT|LIST_SEPARATOR
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden perl-indent-on-new-line %~ define-command -hidden perl-indent-on-new-line %~
eval -draft -itersel %= evaluate-commands -draft -itersel %=
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
# cleanup trailing white spaces on the previous line # cleanup trailing white spaces on the previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> } try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ exec -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ exec -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
= =
~ ~
def -hidden perl-indent-on-opening-curly-brace %[ define-command -hidden perl-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\' <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\' <ret> s \A|.\z <ret> 1<a-&> ]
] ]
def -hidden perl-indent-on-closing-curly-brace %[ define-command -hidden perl-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization # Initialization
@ -106,7 +106,7 @@ hook -group perl-highlight global WinSetOption filetype=perl %{ add-highlighter
hook global WinSetOption filetype=perl %{ hook global WinSetOption filetype=perl %{
# cleanup trailing whitespaces when exiting insert mode # cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -group perl-hooks %{ try %{ exec -draft <a-x>s^\h+$<ret>d } } hook window InsertEnd .* -group perl-hooks %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group perl-indent perl-indent-on-new-line hook window InsertChar \n -group perl-indent perl-indent-on-new-line
hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace
hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*(([.](rb))|(irbrc)|(pryrc)|(Capfile|[.]cap)|(Gemfile)|(Guardfile)|(Rakefile|[.]rake)|(Thorfile|[.]thor)|(Vagrantfile)) %{ hook global BufCreate .*(([.](rb))|(irbrc)|(pryrc)|(Capfile|[.]cap)|(Gemfile)|(Guardfile)|(Rakefile|[.]rake)|(Thorfile|[.]thor)|(Vagrantfile)) %{
set buffer filetype ruby set-option buffer filetype ruby
} }
# Highlighters # Highlighters
@ -60,7 +60,7 @@ add-highlighter shared/ruby/code regex \b([A-Za-z]\w*:(?!:))|([$@][A-Za-z]\w*)|(
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=ruby %{ printf %s\\n "hook global WinSetOption filetype=ruby %{
set window static_words '${keywords}:${attributes}:${values}:${meta}' set-option window static_words '${keywords}:${attributes}:${values}:${meta}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -75,7 +75,7 @@ add-highlighter shared/ruby/code regex \b([A-Za-z]\w*:(?!:))|([$@][A-Za-z]\w*)|(
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def ruby-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ %sh{ define-command ruby-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ %sh{
case $kak_buffile in case $kak_buffile in
*spec/*_spec.rb) *spec/*_spec.rb)
altfile=$(eval echo $(echo $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) altfile=$(eval echo $(echo $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
@ -100,43 +100,43 @@ def ruby-alternative-file -docstring 'Jump to the alternate file (implementation
echo "edit $altfile" echo "edit $altfile"
}} }}
def -hidden ruby-filter-around-selections %{ define-command -hidden ruby-filter-around-selections %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
exec <a-x> execute-keys <a-x>
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft s \h + $ <ret> d } try %{ execute-keys -draft s \h + $ <ret> d }
} }
} }
def -hidden ruby-indent-on-char %{ define-command -hidden ruby-indent-on-char %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# align middle and end structures to start # align middle and end structures to start
try %{ exec -draft <a-x> <a-k> ^ \h * (else|elsif) $ <ret> <a-\;> <a-?> ^ \h * (if) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (else|elsif) $ <ret> <a-\;> <a-?> ^ \h * (if) <ret> s \A | \z <ret> \' <a-&> }
try %{ exec -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-\;> <a-?> ^ \h * (case) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-\;> <a-?> ^ \h * (case) <ret> s \A | \z <ret> \' <a-&> }
try %{ exec -draft <a-x> <a-k> ^ \h * (rescue) $ <ret> <a-\;> <a-?> ^ \h * (begin) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (rescue) $ <ret> <a-\;> <a-?> ^ \h * (begin) <ret> s \A | \z <ret> \' <a-&> }
try %{ exec -draft <a-x> <a-k> ^ \h * (end) $ <ret> <a-\;> <a-?> ^ \h * (begin|case|class|def|do|for|if|module|unless|until|while) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (end) $ <ret> <a-\;> <a-?> ^ \h * (begin|case|class|def|do|for|if|module|unless|until|while) <ret> s \A | \z <ret> \' <a-&> }
} }
} }
def -hidden ruby-indent-on-new-line %{ define-command -hidden ruby-indent-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft K <a-&> } try %{ execute-keys -draft K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : ruby-filter-around-selections <ret> } try %{ execute-keys -draft k : ruby-filter-around-selections <ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k <a-x> <a-k> ^ \h * (begin|case|class|def|do|else|elsif|ensure|for|if|module|rescue|unless|until|when|while) \b <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^ \h * (begin|case|class|def|do|else|elsif|ensure|for|if|module|rescue|unless|until|when|while) \b <ret> j <a-gt> }
} }
} }
def -hidden ruby-insert-on-new-line %{ define-command -hidden ruby-insert-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# copy _#_ comment prefix and following white spaces # copy _#_ comment prefix and following white spaces
try %{ exec -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P } try %{ execute-keys -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P }
# wisely add end structure # wisely add end structure
eval -save-regs x %{ evaluate-commands -save-regs x %{
try %{ exec -draft k <a-x> s ^ \h + <ret> \" x y } catch %{ reg x '' } try %{ execute-keys -draft k <a-x> s ^ \h + <ret> \" x y } catch %{ reg x '' }
try %{ exec -draft k <a-x> <a-k> ^ <c-r> x (begin|case|class|def|do|for|if|module|unless|until|while) <ret> j <a-a> i X <a-\;> K <a-K> ^ <c-r> x (begin|case|class|def|do|for|if|module|unless|until|while) . * \n <c-r> x end $ <ret> j x y p j a end <esc> <a-lt> } try %{ execute-keys -draft k <a-x> <a-k> ^ <c-r> x (begin|case|class|def|do|for|if|module|unless|until|while) <ret> j <a-a> i X <a-\;> K <a-K> ^ <c-r> x (begin|case|class|def|do|for|if|module|unless|until|while) . * \n <c-r> x end $ <ret> j x y p j a end <esc> <a-lt> }
} }
} }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](rust|rs) %{ hook global BufCreate .*[.](rust|rs) %{
set buffer filetype rust set-option buffer filetype rust
} }
# Highlighters # Highlighters
@ -34,37 +34,37 @@ add-highlighter shared/rust/code regex \b(?:u8|u16|u32|u64|usize|i8|i16|i32|i64|
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden rust-filter-around-selections %{ define-command -hidden rust-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden rust-indent-on-new-line %~ define-command -hidden rust-indent-on-new-line %~
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# copy // comments prefix and following white spaces # copy // comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K//\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K//\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : rust-filter-around-selections <ret> } try %{ execute-keys -draft k : rust-filter-around-selections <ret> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ]
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> & }
> >
~ ~
def -hidden rust-indent-on-opening-curly-brace %[ define-command -hidden rust-indent-on-opening-curly-brace %[
eval -draft -itersel %_ evaluate-commands -draft -itersel %_
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft h <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft h <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
_ _
] ]
def -hidden rust-indent-on-closing-curly-brace %[ define-command -hidden rust-indent-on-closing-curly-brace %[
eval -draft -itersel %_ evaluate-commands -draft -itersel %_
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z <ret> 1<a-&> ]
_ _
] ]

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](scala) %{ hook global BufCreate .*[.](scala) %{
set buffer filetype scala set-option buffer filetype scala
} }
# Highlighters # Highlighters
@ -34,28 +34,28 @@ add-highlighter shared/scala/code regex "'[_A-Za-z0-9$]+" 0:variable
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden scala-filter-around-selections %{ define-command -hidden scala-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden scala-indent-on-new-line %[ define-command -hidden scala-indent-on-new-line %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# copy // comments prefix and following white spaces # copy // comments prefix and following white spaces
try %[ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ] try %[ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ]
# preserve previous line indent # preserve previous line indent
try %[ exec -draft \; K <a-&> ] try %[ execute-keys -draft \; K <a-&> ]
# filter previous line # filter previous line
try %[ exec -draft k : scala-filter-around-selections <ret> ] try %[ execute-keys -draft k : scala-filter-around-selections <ret> ]
# indent after lines ending with { # indent after lines ending with {
try %[ exec -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ]
] ]
] ]
def -hidden scala-indent-on-closing-curly-brace %[ define-command -hidden scala-indent-on-closing-curly-brace %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ]
] ]
] ]

View File

@ -1,8 +1,8 @@
decl -hidden range-specs spell_regions declare-option -hidden range-specs spell_regions
decl -hidden str spell_lang declare-option -hidden str spell_lang
decl -hidden str spell_tmp_file declare-option -hidden str spell_tmp_file
def -params ..1 \ define-command -params ..1 \
-docstring %{spell [<language>]: spell check the current buffer -docstring %{spell [<language>]: spell check the current buffer
The first optional argument is the language against which the check will be performed The first optional argument is the language against which the check will be performed
Formats of language supported: Formats of language supported:
@ -13,7 +13,7 @@ Formats of language supported:
%sh{ %sh{
file=$(mktemp -d "${TMPDIR:-/tmp}"/kak-spell.XXXXXXXX)/buffer file=$(mktemp -d "${TMPDIR:-/tmp}"/kak-spell.XXXXXXXX)/buffer
printf 'eval -no-hooks write %s\n' "${file}" printf 'eval -no-hooks write %s\n' "${file}"
printf 'set buffer spell_tmp_file %s\n' "${file}" printf 'set-option buffer spell_tmp_file %s\n' "${file}"
} }
%sh{ %sh{
if [ $# -ge 1 ]; then if [ $# -ge 1 ]; then
@ -23,7 +23,7 @@ Formats of language supported:
exit 1 exit 1
else else
options="-l '$1'" options="-l '$1'"
printf 'set buffer spell_lang %s\n' "$1" printf 'set-option buffer spell_lang %s\n' "$1"
fi fi
fi fi
@ -49,7 +49,7 @@ Formats of language supported:
*) printf 'echo -markup %%{{Error}%s}\n' "${line}" | kak -p "${kak_session}";; *) printf 'echo -markup %%{{Error}%s}\n' "${line}" | kak -p "${kak_session}";;
esac esac
done done
printf 'set "buffer=%s" spell_regions %%{%s}' "${kak_bufname}" "${regions}" \ printf 'set-option "buffer=%s" spell_regions %%{%s}' "${kak_bufname}" "${regions}" \
| kak -p "${kak_session}" | kak -p "${kak_session}"
} }
rm -rf $(dirname "$kak_opt_spell_tmp_file") rm -rf $(dirname "$kak_opt_spell_tmp_file")
@ -57,7 +57,7 @@ Formats of language supported:
} }
} }
def spell-next %{ %sh{ define-command spell-next %{ %sh{
anchor_line="${kak_selection_desc%%.*}" anchor_line="${kak_selection_desc%%.*}"
anchor_col="${kak_selection_desc%%,*}" anchor_col="${kak_selection_desc%%,*}"
anchor_col="${anchor_col##*.}" anchor_col="${anchor_col##*.}"
@ -101,7 +101,7 @@ def spell-next %{ %sh{
fi fi
} } } }
def spell-replace %{ %sh{ define-command spell-replace %{ %sh{
if [ -n "$kak_opt_spell_lang" ]; then if [ -n "$kak_opt_spell_lang" ]; then
options="-l '$kak_opt_spell_lang'" options="-l '$kak_opt_spell_lang'"
fi fi
@ -109,7 +109,7 @@ def spell-replace %{ %sh{
menu=$(printf %s "${suggestions#?}" | awk -F', ' ' menu=$(printf %s "${suggestions#?}" | awk -F', ' '
{ {
for (i=1; i<=NF; i++) for (i=1; i<=NF; i++)
printf "%s", "%{"$i"}" "%{exec -itersel c"$i"<esc>be}" printf "%s", "%{"$i"}" "%{execute-keys -itersel c"$i"<esc>be}"
} }
') ')
printf 'try %%{ menu -auto-single %s }' "${menu}" printf 'try %%{ menu -auto-single %s }' "${menu}"

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*/?(?i)sql %{ hook global BufCreate .*/?(?i)sql %{
set buffer filetype sql set-option buffer filetype sql
} }
# Highlighters # Highlighters
@ -80,7 +80,7 @@ add-highlighter shared/ regions -default code sql \
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=sql %{ printf %s\\n "hook global WinSetOption filetype=sql %{
set window static_words '${keywords}:${operators}:${functions}:${data_types}:${data_types_fn}:NULL' set-option window static_words '${keywords}:${operators}:${functions}:${data_types}:${data_types_fn}:NULL'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords

View File

@ -1,5 +1,5 @@
hook global BufCreate .*\.(swift) %{ hook global BufCreate .*\.(swift) %{
set buffer filetype swift set-option buffer filetype swift
} }
add-highlighter shared/ regions -default code swift \ add-highlighter shared/ regions -default code swift \

View File

@ -14,7 +14,7 @@ hook global KakBegin .* %{
} }
## Temporarily override the default client creation command ## Temporarily override the default client creation command
def -hidden -params 1.. tmux-new-impl %{ define-command -hidden -params 1.. tmux-new-impl %{
%sh{ %sh{
tmux=${kak_client_env_TMUX:-$TMUX} tmux=${kak_client_env_TMUX:-$TMUX}
if [ -z "$tmux" ]; then if [ -z "$tmux" ]; then
@ -28,24 +28,24 @@ def -hidden -params 1.. tmux-new-impl %{
} }
} }
def tmux-new-vertical -params .. -command-completion -docstring "Create a new vertical pane" %{ define-command tmux-new-vertical -params .. -command-completion -docstring "Create a new vertical pane" %{
tmux-new-impl 'split-window -v' %arg{@} tmux-new-impl 'split-window -v' %arg{@}
} }
def tmux-new-horizontal -params .. -command-completion -docstring "Create a new horizontal pane" %{ define-command tmux-new-horizontal -params .. -command-completion -docstring "Create a new horizontal pane" %{
tmux-new-impl 'split-window -h' %arg{@} tmux-new-impl 'split-window -h' %arg{@}
} }
def tmux-new-window -params .. -command-completion -docstring "Create a new window" %{ define-command tmux-new-window -params .. -command-completion -docstring "Create a new window" %{
tmux-new-impl 'new-window' %arg{@} tmux-new-impl 'new-window' %arg{@}
} }
def -docstring %{tmux-focus [<client>]: focus the given client define-command -docstring %{tmux-focus [<client>]: focus the given client
If no client is passed then the current one is used} \ If no client is passed then the current one is used} \
-params ..1 -client-completion \ -params ..1 -client-completion \
tmux-focus %{ %sh{ tmux-focus %{ %sh{
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
printf %s\\n "eval -client '$1' focus" printf %s\\n "evaluate-commands -client '$1' focus"
elif [ -n "${kak_client_env_TMUX}" ]; then elif [ -n "${kak_client_env_TMUX}" ]; then
TMUX="${kak_client_env_TMUX}" tmux select-pane -t "${kak_client_env_TMUX_PANE}" > /dev/null TMUX="${kak_client_env_TMUX}" tmux select-pane -t "${kak_client_env_TMUX_PANE}" > /dev/null
fi fi

View File

@ -1,7 +1,7 @@
# termcmd should be set such as the next argument is the whole # termcmd should be set-option such as the next argument is the whole
# command line to execute # command line to execute
decl -docstring %{shell command run to spawn a new terminal declare-option -docstring %{shell command run to spawn a new terminal
A shell command is appended to the one set in this option at runtime} \ A shell command is appended to the one set-option in this option at runtime} \
str termcmd %sh{ str termcmd %sh{
for termcmd in 'alacritty -e sh -c' \ for termcmd in 'alacritty -e sh -c' \
'termite -e ' \ 'termite -e ' \
@ -21,25 +21,25 @@ A shell command is appended to the one set in this option at runtime} \
done done
} }
def -docstring %{x11-new [<command>]: create a new kak client for the current session define-command -docstring %{x11-new [<command>]: create a new kak client for the current session
The optional arguments will be passed as arguments to the new client} \ The optional arguments will be passed as arguments to the new client} \
-params .. \ -params .. \
-command-completion \ -command-completion \
x11-new %{ %sh{ x11-new %{ %sh{
if [ -z "${kak_opt_termcmd}" ]; then if [ -z "${kak_opt_termcmd}" ]; then
echo "echo -markup '{Error}termcmd option is not set'" echo "echo -markup '{Error}termcmd option is not set-option'"
exit exit
fi fi
if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi
setsid ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 & setsid ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
}} }}
def -docstring %{x11-focus [<client>]: focus a given client's window define-command -docstring %{x11-focus [<client>]: focus a given client's window
If no client is passed, then the current client is used} \ If no client is passed, then the current client is used} \
-params ..1 -client-completion \ -params ..1 -client-completion \
x11-focus %{ %sh{ x11-focus %{ %sh{
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
printf %s\\n "eval -client '$1' focus" printf %s\\n "evaluate-commands -client '$1' focus"
else else
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
fi fi

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](ya?ml) %{ hook global BufCreate .*[.](ya?ml) %{
set buffer filetype yaml set-option buffer filetype yaml
} }
# Highlighters # Highlighters
@ -28,21 +28,21 @@ add-highlighter shared/yaml/code regex ^\h*-?\h*(\S+): 1:attribute
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden yaml-filter-around-selections %{ define-command -hidden yaml-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden yaml-indent-on-new-line %{ define-command -hidden yaml-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : yaml-filter-around-selections <ret> } try %{ execute-keys -draft k : yaml-filter-around-selections <ret> }
# indent after : # indent after :
try %{ exec -draft <space> k x <a-k> :$ <ret> j <a-gt> } try %{ execute-keys -draft <space> k x <a-k> :$ <ret> j <a-gt> }
} }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .+\.(a(scii)?doc|asc) %{ hook global BufCreate .+\.(a(scii)?doc|asc) %{
set buffer filetype asciidoc set-option buffer filetype asciidoc
} }
# Highlighters # Highlighters

View File

@ -1,125 +1,125 @@
hook global BufCreate .*\.(cc|cpp|cxx|C|hh|hpp|hxx|H)$ %{ hook global BufCreate .*\.(cc|cpp|cxx|C|hh|hpp|hxx|H)$ %{
set buffer filetype cpp set-option buffer filetype cpp
} }
hook global BufSetOption filetype=c\+\+ %{ hook global BufSetOption filetype=c\+\+ %{
set buffer filetype cpp set-option buffer filetype cpp
} }
hook global BufCreate .*\.c$ %{ hook global BufCreate .*\.c$ %{
set buffer filetype c set-option buffer filetype c
} }
hook global BufCreate .*\.h$ %{ hook global BufCreate .*\.h$ %{
try %{ try %{
exec -draft %{%s\b::\b|\btemplate\h*<lt>|\bclass\h+\w+|\b(typename|namespace)\b|\b(public|private|protected)\h*:<ret>} execute-keys -draft %{%s\b::\b|\btemplate\h*<lt>|\bclass\h+\w+|\b(typename|namespace)\b|\b(public|private|protected)\h*:<ret>}
set buffer filetype cpp set-option buffer filetype cpp
} catch %{ } catch %{
set buffer filetype c set-option buffer filetype c
} }
} }
hook global BufCreate .*\.m %{ hook global BufCreate .*\.m %{
set buffer filetype objc set-option buffer filetype objc
} }
def -hidden c-family-trim-autoindent %[ eval -draft -itersel %[ define-command -hidden c-family-trim-autoindent %[ evaluate-commands -draft -itersel %[
# remove the line if it's empty when leaving the insert mode # remove the line if it's empty when leaving the insert mode
try %[ exec <a-x> 1s^(\h+)$<ret> d ] try %[ execute-keys <a-x> 1s^(\h+)$<ret> d ]
] ] ] ]
def -hidden c-family-indent-on-newline %< eval -draft -itersel %< define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -itersel %<
exec \; execute-keys \;
try %< try %<
# if previous line closed a paren, copy indent of the opening paren line # if previous line closed a paren, copy indent of the opening paren line
exec -draft k<a-x> 1s(\))(\h+\w+)*\h*(\;\h*)?$<ret> m<a-\;>J s\A|.\z<ret> 1<a-&> execute-keys -draft k<a-x> 1s(\))(\h+\w+)*\h*(\;\h*)?$<ret> m<a-\;>J s\A|.\z<ret> 1<a-&>
> catch %< > catch %<
# else indent new lines with the same level as the previous one # else indent new lines with the same level as the previous one
exec -draft K <a-&> execute-keys -draft K <a-&>
> >
# remove previous empty lines resulting from the automatic indent # remove previous empty lines resulting from the automatic indent
try %< exec -draft k <a-x> <a-k>^\h+$<ret> Hd > try %< execute-keys -draft k <a-x> <a-k>^\h+$<ret> Hd >
# indent after an opening brace # indent after an opening brace
try %< exec -draft k <a-x> s\{\h*$<ret> j <a-gt> > try %< execute-keys -draft k <a-x> s\{\h*$<ret> j <a-gt> >
# indent after a label # indent after a label
try %< exec -draft k <a-x> s[a-zA-Z0-9_-]+:\h*$<ret> j <a-gt> > try %< execute-keys -draft k <a-x> s[a-zA-Z0-9_-]+:\h*$<ret> j <a-gt> >
# indent after a statement not followed by an opening brace # indent after a statement not followed by an opening brace
try %< exec -draft k <a-x> <a-k>\b(if|else|for|while)\h*\(.+?\)\h*$<ret> j <a-gt> > try %< execute-keys -draft k <a-x> <a-k>\b(if|else|for|while)\h*\(.+?\)\h*$<ret> j <a-gt> >
# align to the opening parenthesis or opening brace (whichever is first) # align to the opening parenthesis or opening brace (whichever is first)
# on a previous line if its followed by text on the same line # on a previous line if its followed by text on the same line
try %< eval -draft %< try %< evaluate-commands -draft %<
# Go to opening parenthesis and opening brace, then select the most nested one # Go to opening parenthesis and opening brace, then select the most nested one
try %< try %< exec [bZ<a-\;>[B<a-z><gt> > catch %< exec [B > > try %< try %< execute-keys [bZ<a-\;>[B<a-z><gt> > catch %< execute-keys [B > >
# Validate selection and get first and last char # Validate selection and get first and last char
exec <a-k>\A[{(](\h*\S+)+\n<ret> <a-:><a-\;>L s\A|.\z<ret> execute-keys <a-k>\A[{(](\h*\S+)+\n<ret> <a-:><a-\;>L s\A|.\z<ret>
# Remove eventual indent from new line # Remove eventual indent from new line
try %< exec -draft <space> <a-h> s\h+<ret> d > try %< execute-keys -draft <space> <a-h> s\h+<ret> d >
# Now align that new line with the opening parenthesis/brace # Now align that new line with the opening parenthesis/brace
exec & execute-keys &
> > > >
> > > >
def -hidden c-family-indent-on-opening-curly-brace %[ define-command -hidden c-family-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
def -hidden c-family-indent-on-closing-curly-brace %[ define-command -hidden c-family-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
def -hidden c-family-insert-on-closing-curly-brace %[ define-command -hidden c-family-insert-on-closing-curly-brace %[
# add a semicolon after a closing brace if part of a class, union or struct definition # add a semicolon after a closing brace if part of a class, union or struct definition
try %[ exec -itersel -draft hm<a-x>B<a-x><a-k>\A\h*(class|struct|union|enum)<ret> a\;<esc> ] try %[ execute-keys -itersel -draft hm<a-x>B<a-x><a-k>\A\h*(class|struct|union|enum)<ret> a\;<esc> ]
] ]
def -hidden c-family-insert-on-newline %[ eval -draft %[ define-command -hidden c-family-insert-on-newline %[ evaluate-commands -draft %[
exec \; execute-keys \;
try %[ try %[
eval -draft %[ evaluate-commands -draft %[
# copy the commenting prefix # copy the commenting prefix
exec -save-regs '' k <a-x>1s^\h*(//+\h*)<ret> y execute-keys -save-regs '' k <a-x>1s^\h*(//+\h*)<ret> y
try %[ try %[
# if the previous comment isn't empty, create a new one # if the previous comment isn't empty, create a new one
exec <a-x><a-K>^\h*//+\h*$<ret> j<a-x>s^\h*<ret>P execute-keys <a-x><a-K>^\h*//+\h*$<ret> j<a-x>s^\h*<ret>P
] catch %[ ] catch %[
# if there is no text in the previous comment, remove it completely # if there is no text in the previous comment, remove it completely
exec d execute-keys d
] ]
] ]
] ]
try %[ try %[
# if the previous line isn't within a comment scope, break # if the previous line isn't within a comment scope, break
exec -draft k<a-x> <a-k>^(\h*/\*|\h+\*(?!/))<ret> execute-keys -draft k<a-x> <a-k>^(\h*/\*|\h+\*(?!/))<ret>
# find comment opening, validate it was not closed, and check its using star prefixes # find comment opening, validate it was not closed, and check its using star prefixes
exec -draft <a-?>/\*<ret><a-H> <a-K>\*/<ret> <a-k>\A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z<ret> execute-keys -draft <a-?>/\*<ret><a-H> <a-K>\*/<ret> <a-k>\A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z<ret>
try %[ try %[
# if the previous line is opening the comment, insert star preceeded by space # if the previous line is opening the comment, insert star preceeded by space
exec -draft k<a-x><a-k>^\h*/\*<ret> execute-keys -draft k<a-x><a-k>^\h*/\*<ret>
exec -draft i<space>*<space><esc> execute-keys -draft i<space>*<space><esc>
] catch %[ ] catch %[
try %[ try %[
# if the next line is a comment line insert a star # if the next line is a comment line insert a star
exec -draft j<a-x><a-k>^\h+\*<ret> execute-keys -draft j<a-x><a-k>^\h+\*<ret>
exec -draft i*<space><esc> execute-keys -draft i*<space><esc>
] catch %[ ] catch %[
try %[ try %[
# if the previous line is an empty comment line, close the comment scope # if the previous line is an empty comment line, close the comment scope
exec -draft k<a-x><a-k>^\h+\*\h+$<ret> <a-x>1s\*(\h*)<ret>c/<esc> execute-keys -draft k<a-x><a-k>^\h+\*\h+$<ret> <a-x>1s\*(\h*)<ret>c/<esc>
] catch %[ ] catch %[
# if the previous line is a non-empty comment line, add a star # if the previous line is a non-empty comment line, add a star
exec -draft i*<space><esc> execute-keys -draft i*<space><esc>
] ]
] ]
] ]
# trim trailing whitespace on the previous line # trim trailing whitespace on the previous line
try %[ exec -draft 1s(\h+)$<ret>d ] try %[ execute-keys -draft 1s(\h+)$<ret>d ]
# align the new star with the previous one # align the new star with the previous one
exec J<a-x>1s^[^*]*(\*)<ret>& execute-keys J<a-x>1s^[^*]*(\*)<ret>&
] ]
] ] ] ]
@ -161,7 +161,7 @@ add-highlighter shared/c/code regex %{\b-?(0x[0-9a-fA-F]+|\d+)[fdiu]?|'((\\.)?|[
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=c %{ printf %s\\n "hook global WinSetOption filetype=c %{
set window static_words '${keywords}:${attributes}:${types}:${values}' set-option window static_words '${keywords}:${attributes}:${types}:${values}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -192,7 +192,7 @@ add-highlighter shared/cpp/code regex %{\b-?(0x[0-9a-fA-F]+|\d+)[fdiu]?|'((\\.)?
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=cpp %{ printf %s\\n "hook global WinSetOption filetype=cpp %{
set window static_words '${keywords}:${attributes}:${types}:${values}' set-option window static_words '${keywords}:${attributes}:${types}:${values}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -231,7 +231,7 @@ add-highlighter shared/objc/code regex %{\b-?\d+[fdiu]?|'((\\.)?|[^'\\])'} 0:val
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=objc %{ printf %s\\n "hook global WinSetOption filetype=objc %{
set window static_words '${keywords}:${attributes}:${types}:${values}:${decorators}' set-option window static_words '${keywords}:${attributes}:${types}:${values}:${decorators}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -278,20 +278,20 @@ hook -group cpp-highlight global WinSetOption filetype=(?!cpp).* %[ remove-highl
hook -group objc-highlight global WinSetOption filetype=objc %[ add-highlighter window ref objc ] hook -group objc-highlight global WinSetOption filetype=objc %[ add-highlighter window ref objc ]
hook -group objc-highlight global WinSetOption filetype=(?!objc).* %[ remove-highlighter window/objc ] hook -group objc-highlight global WinSetOption filetype=(?!objc).* %[ remove-highlighter window/objc ]
decl -docstring %{control the type of include guard to be inserted in empty headers declare-option -docstring %{control the type of include guard to be inserted in empty headers
Can be one of the following: Can be one of the following:
ifdef: old style ifndef/define guard ifdef: old style ifndef/define guard
pragma: newer type of guard using "pragma once"} \ pragma: newer type of guard using "pragma once"} \
str c_include_guard_style "ifdef" str c_include_guard_style "ifdef"
def -hidden c-family-insert-include-guards %{ define-command -hidden c-family-insert-include-guards %{
%sh{ %sh{
case "${kak_opt_c_include_guard_style}" in case "${kak_opt_c_include_guard_style}" in
ifdef) ifdef)
echo 'exec ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>' echo 'execute-keys ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>'
;; ;;
pragma) pragma)
echo 'exec ggi#pragma<space>once<esc>' echo 'execute-keys ggi#pragma<space>once<esc>'
;; ;;
*);; *);;
esac esac
@ -300,10 +300,10 @@ def -hidden c-family-insert-include-guards %{
hook -group c-family-insert global BufNewFile .*\.(h|hh|hpp|hxx|H) c-family-insert-include-guards hook -group c-family-insert global BufNewFile .*\.(h|hh|hpp|hxx|H) c-family-insert-include-guards
decl -docstring "colon separated list of path in which header files will be looked for" \ declare-option -docstring "colon separated list of path in which header files will be looked for" \
str-list alt_dirs ".:.." str-list alt_dirs ".:.."
def c-family-alternative-file -docstring "Jump to the alternate file (header/implementation)" %{ %sh{ define-command c-family-alternative-file -docstring "Jump to the alternate file (header/implementation)" %{ %sh{
alt_dirs=$(printf %s\\n "${kak_opt_alt_dirs}" | tr ':' '\n') alt_dirs=$(printf %s\\n "${kak_opt_alt_dirs}" | tr ':' '\n')
file="${kak_buffile##*/}" file="${kak_buffile##*/}"
file_noext="${file%.*}" file_noext="${file%.*}"

View File

@ -1,102 +1,102 @@
## Line comments ## Line comments
decl -docstring "characters inserted at the beginning of a commented line" \ declare-option -docstring "characters inserted at the beginning of a commented line" \
str comment_line '#' str comment_line '#'
## Block comments ## Block comments
decl -docstring "colon separated tuple containing the characters inserted before/after a commented line" \ declare-option -docstring "colon separated tuple containing the characters inserted before/after a commented line" \
str-list comment_block str-list comment_block
## Default comments for all languages ## Default comments for all languages
hook global BufSetOption filetype=asciidoc %{ hook global BufSetOption filetype=asciidoc %{
set buffer comment_block '///:///' set-option buffer comment_block '///:///'
} }
hook global BufSetOption filetype=(c|cpp|go|java|javascript|objc|php|sass|scala|scss|swift) %{ hook global BufSetOption filetype=(c|cpp|go|java|javascript|objc|php|sass|scala|scss|swift) %{
set buffer comment_line '//' set-option buffer comment_line '//'
set buffer comment_block '/*:*/' set-option buffer comment_block '/*:*/'
} }
hook global BufSetOption filetype=(cabal|haskell|moon) %{ hook global BufSetOption filetype=(cabal|haskell|moon) %{
set buffer comment_line '--' set-option buffer comment_line '--'
set buffer comment_block '{-:-}' set-option buffer comment_block '{-:-}'
} }
hook global BufSetOption filetype=clojure %{ hook global BufSetOption filetype=clojure %{
set buffer comment_line '#_ ' set-option buffer comment_line '#_ '
set buffer comment_block '(comment :)' set-option buffer comment_block '(comment :)'
} }
hook global BufSetOption filetype=coffee %{ hook global BufSetOption filetype=coffee %{
set buffer comment_block '###:###' set-option buffer comment_block '###:###'
} }
hook global BufSetOption filetype=css %{ hook global BufSetOption filetype=css %{
set buffer comment_line '' set-option buffer comment_line ''
set buffer comment_block '/*:*/' set-option buffer comment_block '/*:*/'
} }
hook global BufSetOption filetype=d %{ hook global BufSetOption filetype=d %{
set buffer comment_line '//' set-option buffer comment_line '//'
set buffer comment_block '/+:+/' set-option buffer comment_block '/+:+/'
} }
hook global BufSetOption filetype=(gas|ini) %{ hook global BufSetOption filetype=(gas|ini) %{
set buffer comment_line ';' set-option buffer comment_line ';'
} }
hook global BufSetOption filetype=haml %{ hook global BufSetOption filetype=haml %{
set buffer comment_line '-#' set-option buffer comment_line '-#'
} }
hook global BufSetOption filetype=html %{ hook global BufSetOption filetype=html %{
set buffer comment_line '' set-option buffer comment_line ''
set buffer comment_block '<!--:-->' set-option buffer comment_block '<!--:-->'
} }
hook global BufSetOption filetype=latex %{ hook global BufSetOption filetype=latex %{
set buffer comment_line '%' set-option buffer comment_line '%'
} }
hook global BufSetOption filetype=lisp %{ hook global BufSetOption filetype=lisp %{
set buffer comment_line ';' set-option buffer comment_line ';'
set buffer comment_block '#|:|#' set-option buffer comment_block '#|:|#'
} }
hook global BufSetOption filetype=lua %{ hook global BufSetOption filetype=lua %{
set buffer comment_line '--' set-option buffer comment_line '--'
set buffer comment_block '--[[:]]' set-option buffer comment_block '--[[:]]'
} }
hook global BufSetOption filetype=markdown %{ hook global BufSetOption filetype=markdown %{
set buffer comment_line '' set-option buffer comment_line ''
set buffer comment_block '[//]: # (:)' set-option buffer comment_block '[//]: # (:)'
} }
hook global BufSetOption filetype=perl %{ hook global BufSetOption filetype=perl %{
set buffer comment_block '#[:]' set-option buffer comment_block '#[:]'
} }
hook global BufSetOption filetype=(pug|rust) %{ hook global BufSetOption filetype=(pug|rust) %{
set buffer comment_line '//' set-option buffer comment_line '//'
} }
hook global BufSetOption filetype=python %{ hook global BufSetOption filetype=python %{
set buffer comment_block "''':'''" set-option buffer comment_block "''':'''"
} }
hook global BufSetOption filetype=ragel %{ hook global BufSetOption filetype=ragel %{
set buffer comment_line '%%' set-option buffer comment_line '%%'
set buffer comment_block '%%{:}%%' set-option buffer comment_block '%%{:}%%'
} }
hook global BufSetOption filetype=ruby %{ hook global BufSetOption filetype=ruby %{
set buffer comment_block '^begin=:^=end' set-option buffer comment_block '^begin=:^=end'
} }
def comment-block -docstring '(un)comment selected lines using block comments' %{ define-command comment-block -docstring '(un)comment selected lines using block comments' %{
%sh{ %sh{
exec_proof() { exec_proof() {
## Replace the '<' sign that is interpreted differently in `exec` ## Replace the '<' sign that is interpreted differently in `execute-keys`
printf %s\\n "$@" | sed 's,<,<lt>,g' printf %s\\n "$@" | sed 's,<,<lt>,g'
} }
@ -108,25 +108,25 @@ def comment-block -docstring '(un)comment selected lines using block comments' %
exit exit
fi fi
printf %s\\n "eval -draft %{ try %{ printf %s\\n "evaluate-commands -draft %{ try %{
## The selection is empty ## The selection is empty
exec <a-K>\\A[\\h\\v\\n]*\\z<ret> execute-keys <a-K>\\A[\\h\\v\\n]*\\z<ret>
try %{ try %{
## The selection has already been commented ## The selection has already been commented
exec %{<a-K>\\A\\Q${opening}\\E.*\\Q${closing}\\E\\n*\\z<ret>} execute-keys %{<a-K>\\A\\Q${opening}\\E.*\\Q${closing}\\E\\n*\\z<ret>}
## Comment the selection ## Comment the selection
exec -draft %{a${closing}<esc>i${opening}} execute-keys -draft %{a${closing}<esc>i${opening}}
} catch %{ } catch %{
## Uncomment the commented selection ## Uncomment the commented selection
exec -draft %{s(\\A\\Q${opening}\\E)|(\\Q${closing}\\E\\n*\\z)<ret>d} execute-keys -draft %{s(\\A\\Q${opening}\\E)|(\\Q${closing}\\E\\n*\\z)<ret>d}
} }
} }" } }"
} }
} }
def comment-line -docstring '(un)comment selected lines using line comments' %{ define-command comment-line -docstring '(un)comment selected lines using line comments' %{
%sh{ %sh{
readonly opening="${kak_opt_comment_line}" readonly opening="${kak_opt_comment_line}"
readonly opening_escaped="\\Q${opening}\\E" readonly opening_escaped="\\Q${opening}\\E"
@ -136,23 +136,23 @@ def comment-line -docstring '(un)comment selected lines using line comments' %{
exit exit
fi fi
printf %s\\n "eval -draft %{ printf %s\\n "evaluate-commands -draft %{
## Select the content of the lines, without indentation ## Select the content of the lines, without indentation
exec <a-s>I<esc><a-l> execute-keys <a-s>I<esc><a-l>
try %{ try %{
## Theres no text on the line ## Theres no text on the line
exec <a-K>\\A[\\h\\v\\n]*\\z<ret> execute-keys <a-K>\\A[\\h\\v\\n]*\\z<ret>
try %{ try %{
## The line has already been commented ## The line has already been commented
exec %{<a-K>\\A${opening_escaped}<ret>} execute-keys %{<a-K>\\A${opening_escaped}<ret>}
## Comment the line ## Comment the line
exec -draft %{i${opening}} execute-keys -draft %{i${opening}}
} catch %{ } catch %{
## Uncomment the line ## Uncomment the line
exec -draft %{s\\A${opening_escaped}\\h*<ret>d} execute-keys -draft %{s\\A${opening_escaped}\\h*<ret>d}
} }
} }
}" }"

View File

@ -1,5 +1,5 @@
hook global BufCreate .*\.(diff|patch) %{ hook global BufCreate .*\.(diff|patch) %{
set buffer filetype diff set-option buffer filetype diff
} }
add-highlighter shared/ group diff add-highlighter shared/ group diff

View File

@ -1,33 +1,33 @@
decl -docstring "name of the client in which documentation is to be displayed" \ declare-option -docstring "name of the client in which documentation is to be displayed" \
str docsclient str docsclient
declare-option -hidden range-specs doc_render_ranges declare-option -hidden range-specs doc_render_ranges
define-command -hidden -params 4 doc-render-regex %{ define-command -hidden -params 4 doc-render-regex %{
eval -draft %{ try %{ evaluate-commands -draft %{ try %{
exec \%s %arg{1} <ret> execute-keys \%s %arg{1} <ret>
exec -draft s %arg{2} <ret> d execute-keys -draft s %arg{2} <ret> d
exec "%arg{3}" execute-keys "%arg{3}"
%sh{ %sh{
ranges=$(echo "$kak_selections_desc" | sed -e "s/:/|$4:/g; s/\$/|$4/") ranges=$(echo "$kak_selections_desc" | sed -e "s/:/|$4:/g; s/\$/|$4/")
echo "update-option buffer doc_render_ranges" echo "update-option buffer doc_render_ranges"
echo "set -add buffer doc_render_ranges '$ranges'" echo "set-option -add buffer doc_render_ranges '$ranges'"
} }
} } } }
} }
define-command -params 1 -hidden doc-render %{ define-command -params 1 -hidden doc-render %{
edit! -scratch *doc* edit! -scratch *doc*
exec "!cat %arg{1}<ret>gg" execute-keys "!cat %arg{1}<ret>gg"
# Join paragraphs together # Join paragraphs together
try %{ exec -draft \%S \n{2,}|(?<=\+)\n|^[^\n]+::\n <ret> <a-K>^-{2,}(\n|\z)<ret> S\n\z<ret> <a-k>\n<ret> <a-j> } try %{ execute-keys -draft \%S \n{2,}|(?<=\+)\n|^[^\n]+::\n <ret> <a-K>^-{2,}(\n|\z)<ret> S\n\z<ret> <a-k>\n<ret> <a-j> }
# Remove some line end markers # Remove some line end markers
try %{ exec -draft \%s \h*(\+|:{2,})$ <ret> d } try %{ execute-keys -draft \%s \h*(\+|:{2,})$ <ret> d }
# Setup the doc_render_ranges option # Setup the doc_render_ranges option
set buffer doc_render_ranges %val{timestamp} set-option buffer doc_render_ranges %val{timestamp}
doc-render-regex \B(?<!\\)\*[^\n]+?(?<!\\)\*\B \A|.\z 'H' default+b doc-render-regex \B(?<!\\)\*[^\n]+?(?<!\\)\*\B \A|.\z 'H' default+b
doc-render-regex \b(?<!\\)_[^\n]+?(?<!\\)_\b \A|.\z 'H' default+i doc-render-regex \b(?<!\\)_[^\n]+?(?<!\\)_\b \A|.\z 'H' default+i
doc-render-regex \B(?<!\\)`[^\n]+?(?<!\\)`\B \A|.\z 'H' mono doc-render-regex \B(?<!\\)`[^\n]+?(?<!\\)`\B \A|.\z 'H' mono
@ -37,14 +37,14 @@ define-command -params 1 -hidden doc-render %{
doc-render-regex <lt><lt>.*?<gt><gt> <lt><lt>.*,|<gt><gt> 'H' link doc-render-regex <lt><lt>.*?<gt><gt> <lt><lt>.*,|<gt><gt> 'H' link
# Remove escaping of * and ` # Remove escaping of * and `
try %{ exec -draft \%s \\((?=\*)|(?=`)) <ret> d } try %{ execute-keys -draft \%s \\((?=\*)|(?=`)) <ret> d }
set-option buffer readonly true set-option buffer readonly true
add-highlighter buffer ranges doc_render_ranges add-highlighter buffer ranges doc_render_ranges
add-highlighter buffer wrap -word -indent add-highlighter buffer wrap -word -indent
} }
def -params 1 \ define-command -params 1 \
-shell-candidates %{ -shell-candidates %{
find "${kak_runtime}/doc/" -type f -name "*.asciidoc" | while read l; do find "${kak_runtime}/doc/" -type f -name "*.asciidoc" | while read l; do
basename "${l%.*}" basename "${l%.*}"
@ -57,7 +57,7 @@ An optional keyword argument can be passed to the function, which will be automa
shift shift
if [ -f "${page}" ]; then if [ -f "${page}" ]; then
printf %s\\n "eval -try-client %opt{docsclient} doc-render ${page}" printf %s\\n "evaluate-commands -try-client %opt{docsclient} doc-render ${page}"
else else
printf %s\\n "echo -markup '{Error}No such doc file: ${page}'" printf %s\\n "echo -markup '{Error}No such doc file: ${page}'"
fi fi

View File

@ -1,7 +1,7 @@
decl -docstring "shell command to which the contents of the current buffer is piped" \ declare-option -docstring "shell command to which the contents of the current buffer is piped" \
str formatcmd str formatcmd
def format -docstring "Format the contents of the current buffer" %{ eval -draft %{ define-command format -docstring "Format the contents of the current buffer" %{ evaluate-commands -draft %{
%sh{ %sh{
if [ -n "${kak_opt_formatcmd}" ]; then if [ -n "${kak_opt_formatcmd}" ]; then
path_file_tmp=$(mktemp "${TMPDIR:-/tmp}"/kak-formatter-XXXXXX) path_file_tmp=$(mktemp "${TMPDIR:-/tmp}"/kak-formatter-XXXXXX)
@ -12,11 +12,11 @@ def format -docstring "Format the contents of the current buffer" %{ eval -draft
readonly path_file_out=\$(mktemp \"${TMPDIR:-/tmp}\"/kak-formatter-XXXXXX) readonly path_file_out=\$(mktemp \"${TMPDIR:-/tmp}\"/kak-formatter-XXXXXX)
if cat \"${path_file_tmp}\" | eval \"${kak_opt_formatcmd}\" > \"\${path_file_out}\"; then if cat \"${path_file_tmp}\" | eval \"${kak_opt_formatcmd}\" > \"\${path_file_out}\"; then
printf '%s\\n' \"exec \\%|cat<space>'\${path_file_out}'<ret>\" printf '%s\\n' \"execute-keys \\%|cat<space>'\${path_file_out}'<ret>\"
printf '%s\\n' \"%sh{ rm -f '\${path_file_out}' }\" printf '%s\\n' \"%sh{ rm -f '\${path_file_out}' }\"
else else
printf '%s\\n' \" printf '%s\\n' \"
eval -client '${kak_client}' echo -markup '{Error}formatter returned an error (\$?)' evaluate-commands -client '${kak_client}' echo -markup '{Error}formatter returned an error (\$?)'
\" \"
rm -f \"\${path_file_out}\" rm -f \"\${path_file_out}\"
fi fi
@ -25,7 +25,7 @@ def format -docstring "Format the contents of the current buffer" %{ eval -draft
} }
" "
else else
printf '%s\n' "eval -client '${kak_client}' echo -markup '{Error}formatcmd option not specified'" printf '%s\n' "evaluate-commands -client '${kak_client}' echo -markup '{Error}formatcmd option not specified'"
fi fi
} }
} } } }

View File

@ -1,10 +1,10 @@
decl -docstring "shell command run to search for subtext in a file/directory" \ declare-option -docstring "shell command run to search for subtext in a file/directory" \
str grepcmd 'grep -RHn' str grepcmd 'grep -RHn'
decl -docstring "name of the client in which utilities display information" \ declare-option -docstring "name of the client in which utilities display information" \
str toolsclient str toolsclient
decl -hidden int grep_current_line 0 declare-option -hidden int grep_current_line 0
def -params .. -file-completion \ define-command -params .. -file-completion \
-docstring %{grep [<arguments>]: grep utility wrapper -docstring %{grep [<arguments>]: grep utility wrapper
All the optional arguments are forwarded to the grep utility} \ All the optional arguments are forwarded to the grep utility} \
grep %{ %sh{ grep %{ %sh{
@ -16,10 +16,10 @@ All the optional arguments are forwarded to the grep utility} \
( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & ( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null &
fi fi
printf %s\\n "eval -try-client '$kak_opt_toolsclient' %{ printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
edit! -fifo ${output} -scroll *grep* edit! -fifo ${output} -scroll *grep*
set buffer filetype grep set-option buffer filetype grep
set buffer grep_current_line 0 set-option buffer grep_current_line 0
hook -group fifo buffer BufCloseFifo .* %{ hook -group fifo buffer BufCloseFifo .* %{
nop %sh{ rm -r $(dirname ${output}) } nop %sh{ rm -r $(dirname ${output}) }
remove-hooks buffer fifo remove-hooks buffer fifo
@ -43,38 +43,38 @@ hook global WinSetOption filetype=(?!grep).* %{
remove-hooks buffer grep-hooks remove-hooks buffer grep-hooks
} }
decl -docstring "name of the client in which all source code jumps will be executed" \ declare-option -docstring "name of the client in which all source code jumps will be executed" \
str jumpclient str jumpclient
def -hidden grep-jump %{ define-command -hidden grep-jump %{
eval -collapse-jumps %{ evaluate-commands -collapse-jumps %{
try %{ try %{
exec '<a-x>s^((?:\w:)?[^:]+):(\d+):(\d+)?<ret>' execute-keys '<a-x>s^((?:\w:)?[^:]+):(\d+):(\d+)?<ret>'
set buffer grep_current_line %val{cursor_line} set-option buffer grep_current_line %val{cursor_line}
eval -try-client %opt{jumpclient} edit -existing %reg{1} %reg{2} %reg{3} evaluate-commands -try-client %opt{jumpclient} edit -existing %reg{1} %reg{2} %reg{3}
try %{ focus %opt{jumpclient} } try %{ focus %opt{jumpclient} }
} }
} }
} }
def grep-next-match -docstring 'Jump to the next grep match' %{ define-command grep-next-match -docstring 'Jump to the next grep match' %{
eval -collapse-jumps -try-client %opt{jumpclient} %{ evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*grep*' buffer '*grep*'
# First jump to enf of buffer so that if grep_current_line == 0 # First jump to enf of buffer so that if grep_current_line == 0
# 0g<a-l> will be a no-op and we'll jump to the first result. # 0g<a-l> will be a no-op and we'll jump to the first result.
# Yeah, thats ugly... # Yeah, thats ugly...
exec "ge %opt{grep_current_line}g<a-l> /^[^:]+:\d+:<ret>" execute-keys "ge %opt{grep_current_line}g<a-l> /^[^:]+:\d+:<ret>"
grep-jump grep-jump
} }
try %{ eval -client %opt{toolsclient} %{ exec gg %opt{grep_current_line}g } } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys gg %opt{grep_current_line}g } }
} }
def grep-previous-match -docstring 'Jump to the previous grep match' %{ define-command grep-previous-match -docstring 'Jump to the previous grep match' %{
eval -collapse-jumps -try-client %opt{jumpclient} %{ evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*grep*' buffer '*grep*'
# See comment in grep-next-match # See comment in grep-next-match
exec "ge %opt{grep_current_line}g<a-h> <a-/>^[^:]+:\d+:<ret>" execute-keys "ge %opt{grep_current_line}g<a-h> <a-/>^[^:]+:\d+:<ret>"
grep-jump grep-jump
} }
try %{ eval -client %opt{toolsclient} %{ exec gg %opt{grep_current_line}g } } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys gg %opt{grep_current_line}g } }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate (.*/)?(kakrc|.*.kak) %{ hook global BufCreate (.*/)?(kakrc|.*.kak) %{
set buffer filetype kak set-option buffer filetype kak
} }
# Highlighters & Completion # Highlighters & Completion
@ -29,8 +29,9 @@ add-highlighter shared/ regions -default code kakrc \
keywords="edit write write-all kill quit write-quit write-all-quit map unmap alias unalias keywords="edit write write-all kill quit write-quit write-all-quit map unmap alias unalias
buffer buffer-next buffer-previous delete-buffer add-highlighter remove-highlighter buffer buffer-next buffer-previous delete-buffer add-highlighter remove-highlighter
hook remove-hooks define-command echo debug source try fail hook remove-hooks define-command echo debug source try fail
set-option unset-option update-option declare-option exec eval prompt menu on-key info set-option unset-option update-option declare-option execute-keys evaluate-commands
set-face rename-client set-register select change-directory rename-session colorscheme" prompt menu on-key info set-face rename-client set-register select change-directory
rename-session colorscheme"
attributes="global buffer window current attributes="global buffer window current
normal insert menu prompt goto view user object normal insert menu prompt goto view user object
number_lines show_matching show_whitespaces fill regex dynregex group flag_lines number_lines show_matching show_whitespaces fill regex dynregex group flag_lines
@ -42,8 +43,8 @@ add-highlighter shared/ regions -default code kakrc \
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf '%s\n' "hook global WinSetOption filetype=kak %{ printf '%s\n' "hook global WinSetOption filetype=kak %{
set window static_words '$(join "${keywords}:${attributes}:${types}:${values}" ':')' set-option window static_words '$(join "${keywords}:${attributes}:${types}:${values}" ':')'
set -- window extra_word_chars '-' set-option -- window extra_word_chars '-'
}" }"
# Highlight keywords (which are always surrounded by whitespace) # Highlight keywords (which are always surrounded by whitespace)
@ -63,16 +64,16 @@ add-highlighter shared/kakrc/shell ref sh
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden kak-indent-on-new-line %{ define-command -hidden kak-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*#\h* <ret> y jgh P } try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# cleanup trailing whitespaces from previous line # cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# indent after line ending with %[\W\S] # indent after line ending with %[\W\S]
try %{ exec -draft k <a-x> <a-k> \%[\W\S]$ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> \%[\W\S]$ <ret> j <a-gt> }
} }
} }
@ -84,8 +85,8 @@ hook -group kak-highlight global WinSetOption filetype=kak %{ add-highlighter wi
hook global WinSetOption filetype=kak %{ hook global WinSetOption filetype=kak %{
hook window InsertChar \n -group kak-indent kak-indent-on-new-line hook window InsertChar \n -group kak-indent kak-indent-on-new-line
# cleanup trailing whitespaces on current line insert end # cleanup trailing whitespaces on current line insert end
hook window InsertEnd .* -group kak-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } } hook window InsertEnd .* -group kak-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
set buffer extra_word_chars '-' set-option buffer extra_word_chars '-'
} }
hook -group kak-highlight global WinSetOption filetype=(?!kak).* %{ remove-highlighter window/kakrc } hook -group kak-highlight global WinSetOption filetype=(?!kak).* %{ remove-highlighter window/kakrc }

View File

@ -1,13 +1,13 @@
decl -docstring "shell command run to build the project" \ declare-option -docstring "shell command run to build the project" \
str makecmd make str makecmd make
decl -docstring "pattern that describes lines containing information about errors in the output of the `makecmd` command" \ declare-option -docstring "pattern that describes lines containing information about errors in the output of the `makecmd` command" \
str make_error_pattern " (?:fatal )?error:" str make_error_pattern " (?:fatal )?error:"
decl -docstring "name of the client in which utilities display information" \ declare-option -docstring "name of the client in which utilities display information" \
str toolsclient str toolsclient
decl -hidden int make_current_error_line declare-option -hidden int make_current_error_line
def -params .. \ define-command -params .. \
-docstring %{make [<arguments>]: make utility wrapper -docstring %{make [<arguments>]: make utility wrapper
All the optional arguments are forwarded to the make utility} \ All the optional arguments are forwarded to the make utility} \
make %{ %sh{ make %{ %sh{
@ -15,10 +15,10 @@ All the optional arguments are forwarded to the make utility} \
mkfifo ${output} mkfifo ${output}
( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & ( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null &
printf %s\\n "eval -try-client '$kak_opt_toolsclient' %{ printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
edit! -fifo ${output} -scroll *make* edit! -fifo ${output} -scroll *make*
set buffer filetype make set-option buffer filetype make
set buffer make_current_error_line 0 set-option buffer make_current_error_line 0
hook -group fifo buffer BufCloseFifo .* %{ hook -group fifo buffer BufCloseFifo .* %{
nop %sh{ rm -r $(dirname ${output}) } nop %sh{ rm -r $(dirname ${output}) }
remove-hooks buffer fifo remove-hooks buffer fifo
@ -43,39 +43,39 @@ hook global WinSetOption filetype=(?!make).* %{
remove-hooks buffer make-hooks remove-hooks buffer make-hooks
} }
decl -docstring "name of the client in which all source code jumps will be executed" \ declare-option -docstring "name of the client in which all source code jumps will be executed" \
str jumpclient str jumpclient
def -hidden make-jump %{ define-command -hidden make-jump %{
eval -collapse-jumps %{ evaluate-commands -collapse-jumps %{
try %{ try %{
exec gl<a-?> "Entering directory" <ret><a-:> execute-keys gl<a-?> "Entering directory" <ret><a-:>
# Try to parse the error into capture groups, failing on absolute paths # Try to parse the error into capture groups, failing on absolute paths
exec s "Entering directory '([^']+)'.*\n([^:/][^:]*):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l execute-keys s "Entering directory '([^']+)'.*\n([^:/][^:]*):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l
set buffer make_current_error_line %val{cursor_line} set-option buffer make_current_error_line %val{cursor_line}
eval -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -markup %{{Information}%reg{5}}; try %{ focus }" evaluate-commands -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -markup %{{Information}%reg{5}}; try %{ focus }"
} catch %{ } catch %{
exec <a-h><a-l> s "((?:\w:)?[^:]+):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l execute-keys <a-h><a-l> s "((?:\w:)?[^:]+):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l
set buffer make_current_error_line %val{cursor_line} set-option buffer make_current_error_line %val{cursor_line}
eval -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -markup %{{Information}%reg{4}}; try %{ focus }" evaluate-commands -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -markup %{{Information}%reg{4}}; try %{ focus }"
} }
} }
} }
def make-next-error -docstring 'Jump to the next make error' %{ define-command make-next-error -docstring 'Jump to the next make error' %{
eval -collapse-jumps -try-client %opt{jumpclient} %{ evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*make*' buffer '*make*'
exec "%opt{make_current_error_line}ggl" "/^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}<ret>" execute-keys "%opt{make_current_error_line}ggl" "/^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}<ret>"
make-jump make-jump
} }
try %{ eval -client %opt{toolsclient} %{ exec %opt{make_current_error_line}g } } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys %opt{make_current_error_line}g } }
} }
def make-previous-error -docstring 'Jump to the previous make error' %{ define-command make-previous-error -docstring 'Jump to the previous make error' %{
eval -collapse-jumps -try-client %opt{jumpclient} %{ evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*make*' buffer '*make*'
exec "%opt{make_current_error_line}g" "<a-/>^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}<ret>" execute-keys "%opt{make_current_error_line}g" "<a-/>^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}<ret>"
make-jump make-jump
} }
try %{ eval -client %opt{toolsclient} %{ exec %opt{make_current_error_line}g } } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys %opt{make_current_error_line}g } }
} }

View File

@ -2,7 +2,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*/?[mM]akefile %{ hook global BufCreate .*/?[mM]akefile %{
set buffer filetype makefile set-option buffer filetype makefile
} }
# Highlighters # Highlighters
@ -10,10 +10,10 @@ hook global BufCreate .*/?[mM]akefile %{
add-highlighter shared/ regions -default content makefile \ add-highlighter shared/ regions -default content makefile \
comment '#' '$' '' \ comment '#' '$' '' \
eval '\$\(' '\)' '\(' evaluate-commands '\$\(' '\)' '\('
add-highlighter shared/makefile/comment fill comment add-highlighter shared/makefile/comment fill comment
add-highlighter shared/makefile/eval fill value add-highlighter shared/makefile/evaluate-commands fill value
add-highlighter shared/makefile/content regex ^[\w.%-]+\h*:\s 0:variable add-highlighter shared/makefile/content regex ^[\w.%-]+\h*:\s 0:variable
add-highlighter shared/makefile/content regex [+?:]= 0:operator add-highlighter shared/makefile/content regex [+?:]= 0:operator
@ -24,7 +24,7 @@ add-highlighter shared/makefile/content regex [+?:]= 0:operator
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=makefile %{ printf %s\\n "hook global WinSetOption filetype=makefile %{
set window static_words '${keywords}' set-option window static_words '${keywords}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -34,16 +34,16 @@ add-highlighter shared/makefile/content regex [+?:]= 0:operator
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden makefile-indent-on-new-line %{ define-command -hidden makefile-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
## If the line above is a target indent with a tab ## If the line above is a target indent with a tab
try %{ exec -draft Z k<a-x> <a-k>^[^:]+:\s<ret> z i<tab> } try %{ execute-keys -draft Z k<a-x> <a-k>^[^:]+:\s<ret> z i<tab> }
# cleanup trailing white space son previous line # cleanup trailing white space son previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# indent after some keywords # indent after some keywords
try %{ exec -draft Z k<a-x> <a-k> ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b<ret> z <a-gt> } try %{ execute-keys -draft Z k<a-x> <a-k> ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b<ret> z <a-gt> }
} }
} }

View File

@ -1,7 +1,7 @@
decl -docstring "name of the client in which documentation is to be displayed" \ declare-option -docstring "name of the client in which documentation is to be displayed" \
str docsclient str docsclient
decl -hidden str manpage declare-option -hidden str manpage
hook -group man-highlight global WinSetOption filetype=man %{ hook -group man-highlight global WinSetOption filetype=man %{
add-highlighter window group man-highlight add-highlighter window group man-highlight
@ -27,7 +27,7 @@ hook global WinSetOption filetype=(?!man).* %{
remove-hooks window man-hooks remove-hooks window man-hooks
} }
def -hidden -params 1..2 man-impl %{ %sh{ define-command -hidden -params 1..2 man-impl %{ %sh{
manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX)
colout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) colout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX)
MANWIDTH=${kak_window_width} man "$@" > $manout 2>/dev/null MANWIDTH=${kak_window_width} man "$@" > $manout 2>/dev/null
@ -37,10 +37,10 @@ def -hidden -params 1..2 man-impl %{ %sh{
if [ "${retval}" -eq 0 ]; then if [ "${retval}" -eq 0 ]; then
printf %s\\n " printf %s\\n "
edit -scratch '*man*' edit -scratch '*man*'
exec '%|cat<space>${colout}<ret>gk' execute-keys '%|cat<space>${colout}<ret>gk'
nop %sh{rm ${colout}} nop %sh{rm ${colout}}
set buffer filetype man set-option buffer filetype man
set window manpage '$@' set-option window manpage '$@'
" "
else else
printf %s\\n "echo -markup %{{Error}man '$@' failed: see *debug* buffer for details}" printf %s\\n "echo -markup %{{Error}man '$@' failed: see *debug* buffer for details}"
@ -48,7 +48,7 @@ def -hidden -params 1..2 man-impl %{ %sh{
fi fi
} } } }
def -params ..1 \ define-command -params ..1 \
-shell-completion %{ -shell-completion %{
prefix=$(printf %s\\n "$1" | cut -c1-${kak_pos_in_token} 2>/dev/null) prefix=$(printf %s\\n "$1" | cut -c1-${kak_pos_in_token} 2>/dev/null)
for page in /usr/share/man/*/${prefix}*.[1-8]*; do for page in /usr/share/man/*/${prefix}*.[1-8]*; do
@ -75,5 +75,5 @@ The page can be a word, or a word directly followed by a section number between
;; ;;
esac esac
printf %s\\n "eval -collapse-jumps -try-client %opt{docsclient} man-impl $pagenum $subject" printf %s\\n "evaluate-commands -collapse-jumps -try-client %opt{docsclient} man-impl $pagenum $subject"
} } } }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](py) %{ hook global BufCreate .*[.](py) %{
set buffer filetype python set-option buffer filetype python
} }
# Highlighters & Completion # Highlighters & Completion
@ -42,7 +42,7 @@ add-highlighter shared/python/comment fill comment
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=python %{ printf %s\\n "hook global WinSetOption filetype=python %{
set window static_words '${values}:${meta}:${keywords}:${types}:${functions}' set-option window static_words '${values}:${meta}:${keywords}:${types}:${functions}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
@ -63,16 +63,16 @@ add-highlighter shared/python/comment fill comment
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden python-indent-on-new-line %{ define-command -hidden python-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*#\h* <ret> y jgh P } try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# cleanup trailing whitespaces from previous line # cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# indent after line ending with : # indent after line ending with :
try %{ exec -draft <space> k x <a-k> :$ <ret> j <a-gt> } try %{ execute-keys -draft <space> k x <a-k> :$ <ret> j <a-gt> }
} }
} }
@ -84,7 +84,7 @@ hook -group python-highlight global WinSetOption filetype=python %{ add-highligh
hook global WinSetOption filetype=python %{ hook global WinSetOption filetype=python %{
hook window InsertChar \n -group python-indent python-indent-on-new-line hook window InsertChar \n -group python-indent python-indent-on-new-line
# cleanup trailing whitespaces on current line insert end # cleanup trailing whitespaces on current line insert end
hook window InsertEnd .* -group python-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } } hook window InsertEnd .* -group python-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
} }
hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter window/python } hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter window/python }

View File

@ -1,5 +1,5 @@
hook global BufCreate .*\.(z|ba|c|k|mk)?sh(rc|_profile)? %{ hook global BufCreate .*\.(z|ba|c|k|mk)?sh(rc|_profile)? %{
set buffer filetype sh set-option buffer filetype sh
} }
add-highlighter shared/ regions -default code -match-capture sh \ add-highlighter shared/ regions -default code -match-capture sh \
@ -23,7 +23,7 @@ add-highlighter shared/sh/heredoc fill string
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "hook global WinSetOption filetype=sh %{ printf %s\\n "hook global WinSetOption filetype=sh %{
set window static_words '${keywords}' set-option window static_words '${keywords}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords

View File

@ -1,8 +1,8 @@
decl -docstring "remove backups once they've been restored" \ declare-option -docstring "remove backups once they've been restored" \
bool autorestore_purge_restored true bool autorestore_purge_restored true
## Insert the content of the backup file into the current buffer, if a suitable one is found ## Insert the content of the backup file into the current buffer, if a suitable one is found
def autorestore-restore-buffer -docstring "Restore the backup for the current file if it exists" %{ define-command autorestore-restore-buffer -docstring "Restore the backup for the current file if it exists" %{
%sh{ %sh{
buffer_basename="${kak_buffile##*/}" buffer_basename="${kak_buffile##*/}"
buffer_dirname=$(dirname "${kak_buffile}") buffer_dirname=$(dirname "${kak_buffile}")
@ -29,7 +29,7 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi
## Replace the content of the buffer with the content of the backup file ## Replace the content of the buffer with the content of the backup file
echo -debug Restoring file: ${newer} echo -debug Restoring file: ${newer}
exec -draft %{ %d!cat<space>\"${newer}\"<ret>d } execute-keys -draft %{ %d!cat<space>\"${newer}\"<ret>d }
## If the backup file has to be removed, issue the command once ## If the backup file has to be removed, issue the command once
## the current buffer has been saved ## the current buffer has been saved
@ -48,7 +48,7 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi
} }
## Remove all the backups that have been created for the current buffer ## Remove all the backups that have been created for the current buffer
def autorestore-purge-backups -docstring "Remove all the backups of the current buffer" %{ define-command autorestore-purge-backups -docstring "Remove all the backups of the current buffer" %{
%sh{ %sh{
[ ! -f "${kak_buffile}" ] && exit [ ! -f "${kak_buffile}" ] && exit
@ -64,7 +64,7 @@ def autorestore-purge-backups -docstring "Remove all the backups of the current
} }
## If for some reason, backup files need to be ignored ## If for some reason, backup files need to be ignored
def autorestore-disable -docstring "Disable automatic backup recovering" %{ define-command autorestore-disable -docstring "Disable automatic backup recovering" %{
remove-hooks global autorestore remove-hooks global autorestore
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](cabal) %{ hook global BufCreate .*[.](cabal) %{
set buffer filetype cabal set-option buffer filetype cabal
} }
# Highlighters # Highlighters
@ -24,35 +24,35 @@ add-highlighter shared/cabal/code regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*: 1:varia
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden cabal-filter-around-selections %{ define-command -hidden cabal-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden cabal-indent-on-new-line %[ define-command -hidden cabal-indent-on-new-line %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %[ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ] try %[ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ]
# preserve previous line indent # preserve previous line indent
try %[ exec -draft \; K <a-&> ] try %[ execute-keys -draft \; K <a-&> ]
# filter previous line # filter previous line
try %[ exec -draft k : cabal-filter-around-selections <ret> ] try %[ execute-keys -draft k : cabal-filter-around-selections <ret> ]
# indent after lines ending with { or : # indent after lines ending with { or :
try %[ exec -draft <space> k <a-x> <a-k> [:{]$ <ret> j <a-gt> ] try %[ execute-keys -draft <space> k <a-x> <a-k> [:{]$ <ret> j <a-gt> ]
] ]
] ]
def -hidden cabal-indent-on-opening-curly-brace %[ define-command -hidden cabal-indent-on-opening-curly-brace %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft h <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft h <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
] ]
def -hidden cabal-indent-on-closing-curly-brace %[ define-command -hidden cabal-indent-on-closing-curly-brace %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z<ret> 1<a-&> ] try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z<ret> 1<a-&> ]
] ]
] ]

View File

@ -1,29 +1,29 @@
decl -docstring "options to pass to the `clang` shell command" \ declare-option -docstring "options to pass to the `clang` shell command" \
str clang_options str clang_options
decl -hidden str clang_tmp_dir declare-option -hidden str clang_tmp_dir
decl -hidden completions clang_completions declare-option -hidden completions clang_completions
decl -hidden line-specs clang_flags declare-option -hidden line-specs clang_flags
decl -hidden line-specs clang_errors declare-option -hidden line-specs clang_errors
def -params ..1 \ define-command -params ..1 \
-docstring %{Parse the contents of the current buffer -docstring %{Parse the contents of the current buffer
The syntaxic errors detected during parsing are shown when auto-diagnostics are enabled} \ The syntaxic errors detected during parsing are shown when auto-diagnostics are enabled} \
clang-parse %{ clang-parse %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-clang.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-clang.XXXXXXXX)
mkfifo ${dir}/fifo mkfifo ${dir}/fifo
printf %s\\n "set buffer clang_tmp_dir ${dir}" printf %s\\n "set-option buffer clang_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
# end the previous %sh{} so that its output gets interpreted by kakoune # end the previous %sh{} so that its output gets interpreted by kakoune
# before launching the following as a background task. # before launching the following as a background task.
%sh{ %sh{
dir=${kak_opt_clang_tmp_dir} dir=${kak_opt_clang_tmp_dir}
printf %s\\n "eval -draft %{ printf %s\\n "evaluate-commands -draft %{
edit! -fifo ${dir}/fifo -debug *clang-output* edit! -fifo ${dir}/fifo -debug *clang-output*
set buffer filetype make set-option buffer filetype make
set buffer make_current_error_line 0 set-option buffer make_current_error_line 0
hook -group fifo buffer BufCloseFifo .* %{ hook -group fifo buffer BufCloseFifo .* %{
nop %sh{ rm -r ${dir} } nop %sh{ rm -r ${dir} }
remove-hooks buffer fifo remove-hooks buffer fifo
@ -75,11 +75,11 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are
print id "|" docstrings[id] "|" menu print id "|" docstrings[id] "|" menu
} }
}' | paste -s -d ':' - | sed -e "s/\\\\n/\\n/g; s/'/\\\\'/g") }' | paste -s -d ':' - | sed -e "s/\\\\n/\\n/g; s/'/\\\\'/g")
printf %s\\n "eval -client ${kak_client} echo 'clang completion done' printf %s\\n "evaluate-commands -client ${kak_client} echo 'clang completion done'
set 'buffer=${kak_buffile}' clang_completions '${header}:${compl}'" | kak -p ${kak_session} set-option 'buffer=${kak_buffile}' clang_completions '${header}:${compl}'" | kak -p ${kak_session}
else else
clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr
printf %s\\n "eval -client ${kak_client} echo 'clang parsing done'" | kak -p ${kak_session} printf %s\\n "evaluate-commands -client ${kak_client} echo 'clang parsing done'" | kak -p ${kak_session}
fi fi
flags=$(cat ${dir}/stderr | sed -rne " flags=$(cat ${dir}/stderr | sed -rne "
@ -95,30 +95,30 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are
sed -e "s|<stdin>|${kak_bufname}|g" < ${dir}/stderr > ${dir}/fifo sed -e "s|<stdin>|${kak_bufname}|g" < ${dir}/stderr > ${dir}/fifo
printf %s\\n "set 'buffer=${kak_buffile}' clang_flags %{${kak_timestamp}:${flags}} printf %s\\n "set-option 'buffer=${kak_buffile}' clang_flags %{${kak_timestamp}:${flags}}
set 'buffer=${kak_buffile}' clang_errors '${kak_timestamp}:${errors}'" | kak -p ${kak_session} set-option 'buffer=${kak_buffile}' clang_errors '${kak_timestamp}:${errors}'" | kak -p ${kak_session}
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &
} }
} }
def clang-complete -docstring "Complete the current selection" %{ clang-parse -complete } define-command clang-complete -docstring "Complete the current selection" %{ clang-parse -complete }
def -hidden clang-show-completion-info %[ try %[ define-command -hidden clang-show-completion-info %[ try %[
eval -draft %[ evaluate-commands -draft %[
exec <space>{( <a-k> ^\( <ret> b <a-k> \A\w+\z <ret> execute-keys <space>{( <a-k> ^\( <ret> b <a-k> \A\w+\z <ret>
%sh[ %sh[
desc=$(printf %s\\n "${kak_opt_clang_completions}" | sed -e "{ s/\([^\\]\):/\1\n/g }" | sed -ne "/^${kak_selection}|/ { s/^[^|]\+|//; s/|.*$//; s/\\\:/:/g; p }") desc=$(printf %s\\n "${kak_opt_clang_completions}" | sed -e "{ s/\([^\\]\):/\1\n/g }" | sed -ne "/^${kak_selection}|/ { s/^[^|]\+|//; s/|.*$//; s/\\\:/:/g; p }")
if [ -n "$desc" ]; then if [ -n "$desc" ]; then
printf %s\\n "eval -client $kak_client %{info -anchor ${kak_cursor_line}.${kak_cursor_column} -placement above %{${desc}}}" printf %s\\n "evaluate-commands -client $kak_client %{info -anchor ${kak_cursor_line}.${kak_cursor_column} -placement above %{${desc}}}"
fi fi
] ] ] ]
] ] ] ]
def clang-enable-autocomplete -docstring "Enable automatic clang completion" %{ define-command clang-enable-autocomplete -docstring "Enable automatic clang completion" %{
set window completers "option=clang_completions:%opt{completers}" set-option window completers "option=clang_completions:%opt{completers}"
hook window -group clang-autocomplete InsertIdle .* %{ hook window -group clang-autocomplete InsertIdle .* %{
try %{ try %{
exec -draft <a-h><a-k>(\.|->|::).\z<ret> execute-keys -draft <a-h><a-k>(\.|->|::).\z<ret>
echo 'completing...' echo 'completing...'
clang-complete clang-complete
} }
@ -127,13 +127,13 @@ def clang-enable-autocomplete -docstring "Enable automatic clang completion" %{
alias window complete clang-complete alias window complete clang-complete
} }
def clang-disable-autocomplete -docstring "Disable automatic clang completion" %{ define-command clang-disable-autocomplete -docstring "Disable automatic clang completion" %{
set window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed -e 's/option=clang_completions://g' } set-option window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed -e 's/option=clang_completions://g' }
remove-hooks window clang-autocomplete remove-hooks window clang-autocomplete
unalias window complete clang-complete unalias window complete clang-complete
} }
def -hidden clang-show-error-info %{ define-command -hidden clang-show-error-info %{
update-option buffer clang_errors # Ensure we are up to date with buffer changes update-option buffer clang_errors # Ensure we are up to date with buffer changes
%sh{ %sh{
desc=$(printf %s\\n "${kak_opt_clang_errors}" | desc=$(printf %s\\n "${kak_opt_clang_errors}" |
@ -144,7 +144,7 @@ def -hidden clang-show-error-info %{
fi fi
} } } }
def clang-enable-diagnostics -docstring %{Activate automatic error reporting and diagnostics define-command clang-enable-diagnostics -docstring %{Activate automatic error reporting and diagnostics
Information about the analysis are showned after the buffer has been parsed with the clang-parse function} \ Information about the analysis are showned after the buffer has been parsed with the clang-parse function} \
%{ %{
add-highlighter window flag_lines default clang_flags add-highlighter window flag_lines default clang_flags
@ -152,12 +152,12 @@ Information about the analysis are showned after the buffer has been parsed with
hook window -group clang-diagnostics WinSetOption ^clang_errors=.* %{ info; clang-show-error-info } hook window -group clang-diagnostics WinSetOption ^clang_errors=.* %{ info; clang-show-error-info }
} }
def clang-disable-diagnostics -docstring "Disable automatic error reporting and diagnostics" %{ define-command clang-disable-diagnostics -docstring "Disable automatic error reporting and diagnostics" %{
remove-highlighter window/hlflags_clang_flags remove-highlighter window/hlflags_clang_flags
remove-hooks window clang-diagnostics remove-hooks window clang-diagnostics
} }
def clang-diagnostics-next -docstring "Jump to the next line that contains an error" %{ define-command clang-diagnostics-next -docstring "Jump to the next line that contains an error" %{
update-option buffer clang_errors # Ensure we are up to date with buffer changes update-option buffer clang_errors # Ensure we are up to date with buffer changes
%sh{ %sh{
printf "%s\n" "${kak_opt_clang_errors}" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | ( printf "%s\n" "${kak_opt_clang_errors}" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | (
@ -170,7 +170,7 @@ def clang-diagnostics-next -docstring "Jump to the next line that contains an er
done done
line=${line-$first_line} line=${line-$first_line}
if [ -n "$line" ]; then if [ -n "$line" ]; then
printf %s\\n "exec ${line} g" printf %s\\n "execute-keys ${line} g"
else else
echo "echo -markup '{Error}no next clang diagnostic'" echo "echo -markup '{Error}no next clang diagnostic'"
fi fi

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](coffee) %{ hook global BufCreate .*[.](coffee) %{
set buffer filetype coffee set-option buffer filetype coffee
} }
# Highlighters # Highlighters
@ -45,24 +45,24 @@ add-highlighter shared/coffee/code regex \b(break|case|catch|class|const|continu
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden coffee-filter-around-selections %{ define-command -hidden coffee-filter-around-selections %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
exec <a-x> execute-keys <a-x>
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft s \h + $ <ret> d } try %{ execute-keys -draft s \h + $ <ret> d }
} }
} }
def -hidden coffee-indent-on-new-line %{ define-command -hidden coffee-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P } try %{ execute-keys -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : coffee-filter-around-selections <ret> } try %{ execute-keys -draft k : coffee-filter-around-selections <ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k <a-x> <a-k> ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ <ret> j <a-gt> }
} }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](feature|story) %{ hook global BufCreate .*[.](feature|story) %{
set buffer filetype cucumber set-option buffer filetype cucumber
} }
# Highlighters # Highlighters
@ -56,21 +56,21 @@ add-highlighter shared/cucumber/code regex \b(Feature|Business\h+Need|Ability|Ba
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden cucumber-filter-around-selections %{ define-command -hidden cucumber-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden cucumber-indent-on-new-line %{ define-command -hidden cucumber-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : cucumber-filter-around-selections <ret> } try %{ execute-keys -draft k : cucumber-filter-around-selections <ret> }
# indent after lines containing : # indent after lines containing :
try %{ exec -draft <space> k x <a-k> : <ret> j <a-gt> } try %{ execute-keys -draft <space> k x <a-k> : <ret> j <a-gt> }
} }
} }

View File

@ -7,7 +7,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*Dockerfile %{ hook global BufCreate .*Dockerfile %{
set buffer filetype dockerfile set-option buffer filetype dockerfile
} }
# Highlighters # Highlighters

View File

@ -1,9 +1,9 @@
# http://editorconfig.org/#file-format-details # http://editorconfig.org/#file-format-details
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
decl -hidden bool editorconfig_trim_trailing_whitespace false declare-option -hidden bool editorconfig_trim_trailing_whitespace false
def editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set formatting behavior according to editorconfig" %{ define-command editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set-option formatting behavior according to editorconfig" %{
remove-hooks buffer editorconfig-hooks remove-hooks buffer editorconfig-hooks
%sh{ %sh{
command -v editorconfig >/dev/null 2>&1 || { echo 'echo -markup "{Error}editorconfig could not be found"'; exit 1; } command -v editorconfig >/dev/null 2>&1 || { echo 'echo -markup "{Error}editorconfig could not be found"'; exit 1; }
@ -17,31 +17,31 @@ def editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set form
END { END {
if (indent_style == "tab") { if (indent_style == "tab") {
print "set buffer indentwidth 0" print "set-option buffer indentwidth 0"
print "set buffer aligntab true" print "set-option buffer aligntab true"
} }
if (indent_style == "space") { if (indent_style == "space") {
print "set buffer indentwidth " (indent_size == "tab" ? 4 : indent_size) print "set-option buffer indentwidth " (indent_size == "tab" ? 4 : indent_size)
print "set buffer aligntab false" print "set-option buffer aligntab false"
} }
if (indent_size || tab_width) { if (indent_size || tab_width) {
print "set buffer tabstop " (tab_width ? tab_width : indent_size) print "set-option buffer tabstop " (tab_width ? tab_width : indent_size)
} }
if (end_of_line == "lf" || end_of_line == "crlf") { if (end_of_line == "lf" || end_of_line == "crlf") {
print "set buffer eolformat " end_of_line print "set-option buffer eolformat " end_of_line
} }
if (charset == "utf-8-bom") { if (charset == "utf-8-bom") {
print "set buffer BOM utf8" print "set-option buffer BOM utf8"
} }
if (trim_trailing_whitespace == "true") { if (trim_trailing_whitespace == "true") {
print "set buffer editorconfig_trim_trailing_whitespace true" print "set-option buffer editorconfig_trim_trailing_whitespace true"
} }
} }
' '
} }
hook buffer BufWritePre %val{buffile} -group editorconfig-hooks %{ %sh{ hook buffer BufWritePre %val{buffile} -group editorconfig-hooks %{ %sh{
if [ ${kak_opt_editorconfig_trim_trailing_whitespace} = "true" ]; then if [ ${kak_opt_editorconfig_trim_trailing_whitespace} = "true" ]; then
printf %s\\n "try %{ exec -draft %{ %s\h+$<ret>d } }" printf %s\\n "try %{ execute-keys -draft %{ %s\h+$<ret>d } }"
fi fi
} } } }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](ex|exs) %{ hook global BufCreate .*[.](ex|exs) %{
set buffer filetype elixir set-option buffer filetype elixir
} }
@ -42,23 +42,23 @@ add-highlighter shared/elixir/code regex '\b\d+[\d_]*\b' 0:value
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden elixir-filter-around-selections %{ define-command -hidden elixir-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden elixir-indent-on-new-line %{ define-command -hidden elixir-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy -- comments prefix and following white spaces # copy -- comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# indent after line ending with: # indent after line ending with:
# try %{ exec -draft k x <a-k> (do|else|->)$ <ret> & } # try %{ execute-keys -draft k x <a-k> (do|else|->)$ <ret> & }
# filter previous line # filter previous line
try %{ exec -draft k : elixir-filter-around-selections <ret> } try %{ execute-keys -draft k : elixir-filter-around-selections <ret> }
# indent after lines ending with do or -> # indent after lines ending with do or ->
try %{ exec -draft \\; k x <a-k> ^.+(do|->)$ <ret> j <a-gt> } try %{ execute-keys -draft \\; k x <a-k> ^.+(do|->)$ <ret> j <a-gt> }
} }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](elm) %{ hook global BufCreate .*[.](elm) %{
set buffer filetype elm set-option buffer filetype elm
} }
# Highlighters # Highlighters
@ -29,25 +29,25 @@ add-highlighter shared/elm/code regex \b(Array|Bool|Char|Float|Int|String)\b 0:t
# http://elm-lang.org/docs/style-guide # http://elm-lang.org/docs/style-guide
def -hidden elm-filter-around-selections %{ define-command -hidden elm-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden elm-indent-after " define-command -hidden elm-indent-after "
exec -draft \\; k x <a-k> ^\\h*(if)|(case\\h+[\\w']+\\h+of|let|in|\\{\\h+\\w+|\\w+\\h+->|[=(])$ <ret> j <a-gt> execute-keys -draft \\; k x <a-k> ^\\h*(if)|(case\\h+[\\w']+\\h+of|let|in|\\{\\h+\\w+|\\w+\\h+->|[=(])$ <ret> j <a-gt>
" "
def -hidden elm-indent-on-new-line %{ define-command -hidden elm-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy -- comments prefix and following white spaces # copy -- comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# align to first clause # align to first clause
try %{ exec -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|let)\h+\K.* <ret> s \A|.\z <ret> & } try %{ execute-keys -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|let)\h+\K.* <ret> s \A|.\z <ret> & }
# filter previous line # filter previous line
try %{ exec -draft k : elm-filter-around-selections <ret> } try %{ execute-keys -draft k : elm-filter-around-selections <ret> }
# indent after lines beginning with condition or ending with expression or =( # indent after lines beginning with condition or ending with expression or =(
try %{ elm-indent-after } try %{ elm-indent-after }
} }

View File

@ -1,29 +1,29 @@
## Repository metadata files ## Repository metadata files
hook global BufCreate .*/metadata/mirrors\.conf %{ set buffer filetype paludis-mirrors-conf } hook global BufCreate .*/metadata/mirrors\.conf %{ set-option buffer filetype paludis-mirrors-conf }
hook global BufCreate .*/metadata/licence_groups.conf %{ set buffer filetype exheres-0-licence-groups } hook global BufCreate .*/metadata/licence_groups.conf %{ set-option buffer filetype exheres-0-licence-groups }
hook global BufCreate .*/metadata/options/descriptions/.*\.conf %{ set buffer filetype exheres-0-licence-groups } hook global BufCreate .*/metadata/options/descriptions/.*\.conf %{ set-option buffer filetype exheres-0-licence-groups }
hook global BufCreate .*/metadata/.*\.conf %{ set buffer filetype exheres-0-metadata } hook global BufCreate .*/metadata/.*\.conf %{ set-option buffer filetype exheres-0-metadata }
## News items ## News items
hook global BufCreate .*/metadata/news/.*/.*\.txt %{ set buffer filetype glep42 } hook global BufCreate .*/metadata/news/.*/.*\.txt %{ set-option buffer filetype glep42 }
## exheres-0, exlib ## exheres-0, exlib
hook global BufCreate .*\.(exheres-0|exlib) %{ set buffer filetype sh } hook global BufCreate .*\.(exheres-0|exlib) %{ set-option buffer filetype sh }
# Paludis configurations # Paludis configurations
hook global BufCreate .*/etc/paludis(-.*)?/bashrc %{ set buffer filetype sh } hook global BufCreate .*/etc/paludis(-.*)?/bashrc %{ set-option buffer filetype sh }
hook global BufCreate .*/etc/paludis(-.*)?/general(\.conf.d/.*.conf|\.conf) %{ set buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/general(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-key-value-conf }
hook global BufCreate .*/etc/paludis(-.*)?/licences(\.conf.d/.*.conf|\.conf) %{ set buffer filetype paludis-options-conf } hook global BufCreate .*/etc/paludis(-.*)?/licences(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-options-conf }
hook global BufCreate .*/etc/paludis(-.*)?/mirrors(\.conf.d/.*.conf|\.conf) %{ set buffer filetype paludis-mirrors-conf } hook global BufCreate .*/etc/paludis(-.*)?/mirrors(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-mirrors-conf }
hook global BufCreate .*/etc/paludis(-.*)?/options(\.conf.d/.*.conf|\.conf) %{ set buffer filetype paludis-options-conf } hook global BufCreate .*/etc/paludis(-.*)?/options(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-options-conf }
hook global BufCreate .*/etc/paludis(-.*)?/output(\.conf.d/.*.conf|\.conf) %{ set buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/output(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-key-value-conf }
hook global BufCreate .*/etc/paludis(-.*)?/package_(unmask|mask)(\.conf.d/.*.conf|\.conf) %{ set buffer filetype paludis-specs-conf } hook global BufCreate .*/etc/paludis(-.*)?/package_(unmask|mask)(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-specs-conf }
hook global BufCreate .*/etc/paludis(-.*)?/platforms(\.conf.d/.*.conf|\.conf) %{ set buffer filetype paludis-specs-conf } hook global BufCreate .*/etc/paludis(-.*)?/platforms(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-specs-conf }
hook global BufCreate .*/etc/paludis(-.*)?/repositories/.*\.conf %{ set buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/repositories/.*\.conf %{ set-option buffer filetype paludis-key-value-conf }
hook global BufCreate .*/etc/paludis(-.*)?/repository\.template %{ set buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/repository\.template %{ set-option buffer filetype paludis-key-value-conf }
hook global BufCreate .*/etc/paludis(-.*)?/repository_defaults\.conf %{ set buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/repository_defaults\.conf %{ set-option buffer filetype paludis-key-value-conf }
hook global BufCreate .*/etc/paludis(-.*)?/specpath\.conf %{ set buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/specpath\.conf %{ set-option buffer filetype paludis-key-value-conf }
hook global BufCreate .*/etc/paludis(-.*)?/suggestions(\.conf.d/.*.conf|\.conf) %{ set buffer filetype paludis-specs-conf } hook global BufCreate .*/etc/paludis(-.*)?/suggestions(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-specs-conf }
# Highlighters # Highlighters
## exheres-0 Repository metadata files ## exheres-0 Repository metadata files

View File

@ -1,4 +1,4 @@
decl -docstring "name of the client in which documentation is to be displayed" \ declare-option -docstring "name of the client in which documentation is to be displayed" \
str docsclient str docsclient
hook -group git-log-highlight global WinSetOption filetype=git-log %{ hook -group git-log-highlight global WinSetOption filetype=git-log %{
@ -17,13 +17,13 @@ hook -group git-status-highlight global WinSetOption filetype=git-status %{
hook -group git-status-highlight global WinSetOption filetype=(?!git-status).* %{ remove-highlighter window/git-status-highlight } hook -group git-status-highlight global WinSetOption filetype=(?!git-status).* %{ remove-highlighter window/git-status-highlight }
decl -hidden line-specs git_blame_flags declare-option -hidden line-specs git_blame_flags
decl -hidden line-specs git_diff_flags declare-option -hidden line-specs git_diff_flags
face GitBlame default,magenta set-face GitBlame default,magenta
face GitDiffFlags default,black set-face GitDiffFlags default,black
def -params 1.. \ define-command -params 1.. \
-docstring %sh{printf '%%{git [<arguments>]: git wrapping helper -docstring %sh{printf '%%{git [<arguments>]: git wrapping helper
All the optional arguments are forwarded to the git utility All the optional arguments are forwarded to the git utility
Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n-log\n-show\n-show-diff\n-status\n-update-diff}'} \ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n-log\n-show\n-show-diff\n-status\n-update-diff}'} \
@ -43,9 +43,9 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
mkfifo ${output} mkfifo ${output}
( git "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & ( git "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null &
printf %s "eval -try-client '$kak_opt_docsclient' %{ printf %s "evaluate-commands -try-client '$kak_opt_docsclient' %{
edit! -fifo ${output} *git* edit! -fifo ${output} *git*
set buffer filetype '${filetype}' set-option buffer filetype '${filetype}'
hook -group fifo buffer BufCloseFifo .* %{ hook -group fifo buffer BufCloseFifo .* %{
nop %sh{ rm -r $(dirname ${output}) } nop %sh{ rm -r $(dirname ${output}) }
remove-hooks buffer fifo remove-hooks buffer fifo
@ -55,9 +55,9 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
run_git_blame() { run_git_blame() {
( (
printf %s "eval -client '$kak_client' %{ printf %s "evaluate-commands -client '$kak_client' %{
try %{ add-highlighter window flag_lines GitBlame git_blame_flags } try %{ add-highlighter window flag_lines GitBlame git_blame_flags }
set buffer=$kak_bufname git_blame_flags '$kak_timestamp' set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp'
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
git blame "$@" --incremental ${kak_buffile} | awk ' git blame "$@" --incremental ${kak_buffile} | awk '
function send_flags(text, flag, i) { function send_flags(text, flag, i) {
@ -70,7 +70,7 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
flag=flag ":" line+i "|" text flag=flag ":" line+i "|" text
} }
cmd = "kak -p " ENVIRON["kak_session"] cmd = "kak -p " ENVIRON["kak_session"]
print "set -add buffer=" ENVIRON["kak_bufname"] " git_blame_flags %{" flag "}" | cmd print "set-option -add buffer=" ENVIRON["kak_bufname"] " git_blame_flags %{" flag "}" | cmd
close(cmd) close(cmd)
} }
/^([0-9a-f]{40}) ([0-9]+) ([0-9]+) ([0-9]+)/ { /^([0-9a-f]{40}) ([0-9]+) ([0-9]+) ([0-9]+)/ {
@ -107,7 +107,7 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
line++ line++
} }
/^\-/ { flags=flags ":" line "|{red}-" } /^\-/ { flags=flags ":" line "|{red}-" }
END { print "set buffer git_diff_flags ", flags } END { print "set-option buffer git_diff_flags ", flags }
' '
} }
@ -130,9 +130,9 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
printf %s "edit '$msgfile' printf %s "edit '$msgfile'
hook buffer BufWritePost '.*\Q$msgfile\E' %{ %sh{ hook buffer BufWritePost '.*\Q$msgfile\E' %{ %sh{
if git commit -F '$msgfile' --cleanup=strip $@ > /dev/null; then if git commit -F '$msgfile' --cleanup=strip $@ > /dev/null; then
printf %s 'eval -client $kak_client echo -markup %{{Information}Commit succeeded}; delete-buffer' printf %s 'evaluate-commands -client $kak_client echo -markup %{{Information}Commit succeeded}; delete-buffer'
else else
printf %s 'eval -client $kak_client echo -markup %{{Error}Commit failed}' printf %s 'evaluate-commands -client $kak_client echo -markup %{{Error}Commit failed}'
fi fi
} }" } }"
} }
@ -142,7 +142,7 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
blame) shift; run_git_blame "$@" ;; blame) shift; run_git_blame "$@" ;;
hide-blame) hide-blame)
printf %s "try %{ printf %s "try %{
set buffer=$kak_bufname git_blame_flags '' set-option buffer=$kak_bufname git_blame_flags ''
remove-highlighter window/hlflags_git_blame_flags remove-highlighter window/hlflags_git_blame_flags
}" }"
;; ;;

View File

@ -16,14 +16,14 @@
# Auto-completion # Auto-completion
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
decl -hidden str go_complete_tmp_dir declare-option -hidden str go_complete_tmp_dir
decl -hidden completions gocode_completions declare-option -hidden completions gocode_completions
def go-complete -docstring "Complete the current selection with gocode" %{ define-command go-complete -docstring "Complete the current selection with gocode" %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX)
printf %s\\n "set buffer go_complete_tmp_dir ${dir}" printf %s\\n "set-option buffer go_complete_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
%sh{ %sh{
dir=${kak_opt_go_complete_tmp_dir} dir=${kak_opt_go_complete_tmp_dir}
@ -34,24 +34,24 @@ def go-complete -docstring "Complete the current selection with gocode" %{
header="${kak_cursor_line}.$((${kak_cursor_column} - $column_offset))@${kak_timestamp}" header="${kak_cursor_line}.$((${kak_cursor_column} - $column_offset))@${kak_timestamp}"
compl=$(echo "${gocode_data}" | sed 1d | awk -F ",," '{print $2 "||" $1}' | paste -s -d: -) compl=$(echo "${gocode_data}" | sed 1d | awk -F ",," '{print $2 "||" $1}' | paste -s -d: -)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
set buffer=${kak_bufname} gocode_completions '${header}:${compl}' set-option buffer=${kak_bufname} gocode_completions '${header}:${compl}'
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &
} }
} }
def go-enable-autocomplete -docstring "Add gocode completion candidates to the completer" %{ define-command go-enable-autocomplete -docstring "Add gocode completion candidates to the completer" %{
set window completers "option=gocode_completions:%opt{completers}" set-option window completers "option=gocode_completions:%opt{completers}"
hook window -group go-autocomplete InsertIdle .* %{ try %{ hook window -group go-autocomplete InsertIdle .* %{ try %{
exec -draft <a-h><a-k>[\w\.].\z<ret> execute-keys -draft <a-h><a-k>[\w\.].\z<ret>
go-complete go-complete
} } } }
alias window complete go-complete alias window complete go-complete
} }
def go-disable-autocomplete -docstring "Disable gocode completion" %{ define-command go-disable-autocomplete -docstring "Disable gocode completion" %{
set window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed 's/option=gocode_completions://g' } set-option window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed 's/option=gocode_completions://g' }
remove-hooks window go-autocomplete remove-hooks window go-autocomplete
unalias window complete go-complete unalias window complete go-complete
} }
@ -59,14 +59,14 @@ def go-disable-autocomplete -docstring "Disable gocode completion" %{
# Auto-format # Auto-format
# ‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾
decl -hidden str go_format_tmp_dir declare-option -hidden str go_format_tmp_dir
def -params ..1 go-format \ define-command -params ..1 go-format \
-docstring "go-format [-use-goimports]: custom formatter for go files" %{ -docstring "go-format [-use-goimports]: custom formatter for go files" %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX)
printf %s\\n "set buffer go_format_tmp_dir ${dir}" printf %s\\n "set-option buffer go_format_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
%sh{ %sh{
dir=${kak_opt_go_format_tmp_dir} dir=${kak_opt_go_format_tmp_dir}
@ -90,14 +90,14 @@ def -params ..1 go-format \
# Documentation # Documentation
# ‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾
decl -hidden str go_doc_tmp_dir declare-option -hidden str go_doc_tmp_dir
# FIXME text escaping # FIXME text escaping
def -hidden -params 1..2 gogetdoc-cmd %{ define-command -hidden -params 1..2 gogetdoc-cmd %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX)
printf %s\\n "set buffer go_doc_tmp_dir ${dir}" printf %s\\n "set-option buffer go_doc_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
%sh{ %sh{
dir=${kak_opt_go_doc_tmp_dir} dir=${kak_opt_go_doc_tmp_dir}
@ -119,12 +119,12 @@ def -hidden -params 1..2 gogetdoc-cmd %{
case "$1" in case "$1" in
"info") "info")
if [ ${status} -eq 0 ]; then if [ ${status} -eq 0 ]; then
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
info -anchor ${kak_cursor_line}.${kak_cursor_column} %@${output}@ info -anchor ${kak_cursor_line}.${kak_cursor_column} %@${output}@
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
else else
msg=$(printf %s "${output}" | cut -d' ' -f2-) msg=$(printf %s "${output}" | cut -d' ' -f2-)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
echo '${msg}' echo '${msg}'
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
fi fi
@ -132,7 +132,7 @@ def -hidden -params 1..2 gogetdoc-cmd %{
"echo") "echo")
if [ ${status} -eq 0 ]; then if [ ${status} -eq 0 ]; then
signature=$(printf %s "${output}" | sed -n 3p) signature=$(printf %s "${output}" | sed -n 3p)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
echo '${signature}' echo '${signature}'
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
fi fi
@ -143,14 +143,14 @@ def -hidden -params 1..2 gogetdoc-cmd %{
file=$(printf %s "${pos}" | cut -d: -f1) file=$(printf %s "${pos}" | cut -d: -f1)
line=$(printf %s "${pos}" | cut -d: -f2) line=$(printf %s "${pos}" | cut -d: -f2)
col=$(printf %s "${pos}" | cut -d: -f3) col=$(printf %s "${pos}" | cut -d: -f3)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
eval -try-client '${kak_opt_jumpclient}' edit -existing ${file} ${line} ${col} evaluate-commands -try-client '${kak_opt_jumpclient}' edit -existing ${file} ${line} ${col}
try %{ focus '${kak_opt_jumpclient}' } try %{ focus '${kak_opt_jumpclient}' }
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
fi fi
;; ;;
*) *)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
echo -error %{unkown command '$1'} echo -error %{unkown command '$1'}
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
;; ;;
@ -160,19 +160,19 @@ def -hidden -params 1..2 gogetdoc-cmd %{
} }
} }
def go-doc-info -docstring "Show the documention of the symbol under the cursor" %{ define-command go-doc-info -docstring "Show the documention of the symbol under the cursor" %{
gogetdoc-cmd "info" gogetdoc-cmd "info"
} }
def go-print-signature -docstring "Print the signature of the symbol under the cursor" %{ define-command go-print-signature -docstring "Print the signature of the symbol under the cursor" %{
gogetdoc-cmd "echo" gogetdoc-cmd "echo"
} }
def go-jump -docstring "Jump to the symbol definition" %{ define-command go-jump -docstring "Jump to the symbol definition" %{
gogetdoc-cmd "jump" 1 gogetdoc-cmd "jump" 1
} }
def go-share-selection -docstring "Share the selection using the Go Playground" %{ %sh{ define-command go-share-selection -docstring "Share the selection using the Go Playground" %{ %sh{
snippet_id=$(printf %s\\n "${kak_selection}" | curl -s https://play.golang.org/share --data-binary @-) snippet_id=$(printf %s\\n "${kak_selection}" | curl -s https://play.golang.org/share --data-binary @-)
printf "echo https://play.golang.org/p/%s" ${snippet_id} printf "echo https://play.golang.org/p/%s" ${snippet_id}
} } } }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](haml) %{ hook global BufCreate .*[.](haml) %{
set buffer filetype haml set-option buffer filetype haml
} }
# Highlighters # Highlighters
@ -33,21 +33,21 @@ add-highlighter shared/haml/code regex ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden haml-filter-around-selections %{ define-command -hidden haml-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden haml-indent-on-new-line %{ define-command -hidden haml-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '/' comment prefix and following white spaces # copy '/' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : haml-filter-around-selections <ret> } try %{ execute-keys -draft k : haml-filter-around-selections <ret> }
# indent after lines beginning with : or - # indent after lines beginning with : or -
try %{ exec -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> }
} }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](hbs) %{ hook global BufCreate .*[.](hbs) %{
set buffer filetype hbs set-option buffer filetype hbs
} }
# Highlighters # Highlighters
@ -34,21 +34,21 @@ add-highlighter shared/hbs/block-expression regex ((\w|-)+)=(('|").*?('|")) 1:at
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden hbs-filter-around-selections %{ define-command -hidden hbs-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden hbs-indent-on-new-line %{ define-command -hidden hbs-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '/' comment prefix and following white spaces # copy '/' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K/\h* <ret> y j p } try %{ execute-keys -draft k <a-x> s ^\h*\K/\h* <ret> y j p }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : hbs-filter-around-selections <ret> } try %{ execute-keys -draft k : hbs-filter-around-selections <ret> }
# indent after lines beginning with : or - # indent after lines beginning with : or -
try %{ exec -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> }
} }
} }

View File

@ -14,7 +14,7 @@ hook global KakBegin .* %{
} }
} }
def -hidden -params 1.. iterm-new-split-impl %{ define-command -hidden -params 1.. iterm-new-split-impl %{
%sh{ %sh{
direction="$1" direction="$1"
shift shift
@ -33,15 +33,15 @@ def -hidden -params 1.. iterm-new-split-impl %{
} }
} }
def iterm-new-vertical -params .. -command-completion -docstring "Create a new vertical pane" %{ define-command iterm-new-vertical -params .. -command-completion -docstring "Create a new vertical pane" %{
iterm-new-split-impl 'vertically' %arg{@} iterm-new-split-impl 'vertically' %arg{@}
} }
def iterm-new-horizontal -params .. -command-completion -docstring "Create a new horizontal pane" %{ define-command iterm-new-horizontal -params .. -command-completion -docstring "Create a new horizontal pane" %{
iterm-new-split-impl 'horizontally' %arg{@} iterm-new-split-impl 'horizontally' %arg{@}
} }
def -params .. -command-completion \ define-command -params .. -command-completion \
-docstring %{iterm-new-tab [<arguments>]: create a new tab -docstring %{iterm-new-tab [<arguments>]: create a new tab
All optional arguments are forwarded to the new kak client} \ All optional arguments are forwarded to the new kak client} \
iterm-new-tab %{ iterm-new-tab %{
@ -60,7 +60,7 @@ All optional arguments are forwarded to the new kak client} \
} }
} }
def -params .. -command-completion \ define-command -params .. -command-completion \
-docstring %{iterm-new-window [<arguments>]: create a new window -docstring %{iterm-new-window [<arguments>]: create a new window
All optional arguments are forwarded to the new kak client} \ All optional arguments are forwarded to the new kak client} \
iterm-new-window %{ iterm-new-window %{
@ -69,7 +69,7 @@ All optional arguments are forwarded to the new kak client} \
sh_cmd="kak -c ${kak_session} ${kakoune_params}" sh_cmd="kak -c ${kak_session} ${kakoune_params}"
osascript \ osascript \
-e "tell application \"iTerm\"" \ -e "tell application \"iTerm\"" \
-e " set w to (create window with default profile)" \ -e " set-option w to (create window with default profile)" \
-e " tell current session of w" \ -e " tell current session of w" \
-e " write text \"export TMPDIR='${TMPDIR}'\"" \ -e " write text \"export TMPDIR='${TMPDIR}'\"" \
-e " write text \"exec ${sh_cmd}\"" \ -e " write text \"exec ${sh_cmd}\"" \
@ -78,7 +78,7 @@ All optional arguments are forwarded to the new kak client} \
} }
} }
def -params ..1 -client-completion \ define-command -params ..1 -client-completion \
-docstring %{iterm-focus [<client>]: focus the given client -docstring %{iterm-focus [<client>]: focus the given client
If no client is passed then the current one is used} \ If no client is passed then the current one is used} \
iterm-focus %{ iterm-focus %{

View File

@ -1,18 +1,18 @@
decl -hidden str jedi_tmp_dir declare-option -hidden str jedi_tmp_dir
decl -hidden completions jedi_completions declare-option -hidden completions jedi_completions
decl -docstring "colon separated list of path added to `python`'s $PYTHONPATH environment variable" \ declare-option -docstring "colon separated list of path added to `python`'s $PYTHONPATH environment variable" \
str-list jedi_python_path str-list jedi_python_path
def jedi-complete -docstring "Complete the current selection" %{ define-command jedi-complete -docstring "Complete the current selection" %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-jedi.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-jedi.XXXXXXXX)
mkfifo ${dir}/fifo mkfifo ${dir}/fifo
printf %s\\n "set buffer jedi_tmp_dir ${dir}" printf %s\\n "set-option buffer jedi_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
%sh{ %sh{
dir=${kak_opt_jedi_tmp_dir} dir=${kak_opt_jedi_tmp_dir}
printf %s\\n "eval -draft %{ edit! -fifo ${dir}/fifo *jedi-output* }" printf %s\\n "evaluate-commands -draft %{ edit! -fifo ${dir}/fifo *jedi-output* }"
( (
cd $(dirname ${kak_buffile}) cd $(dirname ${kak_buffile})
header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}"
@ -24,24 +24,24 @@ def jedi-complete -docstring "Complete the current selection" %{
print(':'.join([(str(c.name).replace("|", "\\|") + "|" + str(c.docstring()).replace("|", "\\|")).replace(":", "\\:") + "|" + str(c.name).replace("|", "\\|") for c in script.completions()]).replace("'", r"\\\\'")) print(':'.join([(str(c.name).replace("|", "\\|") + "|" + str(c.docstring()).replace("|", "\\|")).replace(":", "\\:") + "|" + str(c.name).replace("|", "\\|") for c in script.completions()]).replace("'", r"\\\\'"))
END END
) )
printf %s\\n "eval -client ${kak_client} 'echo completed; set %{buffer=${kak_buffile}} jedi_completions \'${header}:${compl}\''" | kak -p ${kak_session} printf %s\\n "evaluate-commands -client ${kak_client} 'echo completed; set-option %{buffer=${kak_buffile}} jedi_completions \'${header}:${compl}\''" | kak -p ${kak_session}
rm -r ${dir} rm -r ${dir}
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &
} }
} }
def jedi-enable-autocomplete -docstring "Add jedi completion candidates to the completer" %{ define-command jedi-enable-autocomplete -docstring "Add jedi completion candidates to the completer" %{
set window completers "option=jedi_completions:%opt{completers}" set-option window completers "option=jedi_completions:%opt{completers}"
hook window -group jedi-autocomplete InsertIdle .* %{ try %{ hook window -group jedi-autocomplete InsertIdle .* %{ try %{
exec -draft <a-h><a-k>\..\z<ret> execute-keys -draft <a-h><a-k>\..\z<ret>
echo 'completing...' echo 'completing...'
jedi-complete jedi-complete
} } } }
alias window complete jedi-complete alias window complete jedi-complete
} }
def jedi-disable-autocomplete -docstring "Disable jedi completion" %{ define-command jedi-disable-autocomplete -docstring "Disable jedi completion" %{
set window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed -e 's/option=jedi_completions://g' } set-option window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed -e 's/option=jedi_completions://g' }
remove-hooks window jedi-autocomplete remove-hooks window jedi-autocomplete
unalias window complete jedi-complete unalias window complete jedi-complete
} }

View File

@ -1,5 +1,5 @@
hook global BufCreate .*\.ks %{ hook global BufCreate .*\.ks %{
set buffer filetype kickstart set-option buffer filetype kickstart
} }
add-highlighter shared/ regions -default code kickstart \ add-highlighter shared/ regions -default code kickstart \

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.tex %{ hook global BufCreate .*\.tex %{
set buffer filetype latex set-option buffer filetype latex
} }
# Highlighters # Highlighters

View File

@ -7,10 +7,10 @@
## Only a few options are supported, in order to prevent the ## Only a few options are supported, in order to prevent the
## buffers from poking around the configuration too much ## buffers from poking around the configuration too much
decl -docstring "amount of lines that will be checked at the beginning and the end of the buffer" \ declare-option -docstring "amount of lines that will be checked at the beginning and the end of the buffer" \
int modelines 5 int modelines 5
def -hidden modeline-parse-impl %{ define-command -hidden modeline-parse-impl %{
%sh{ %sh{
# Translate a vim option into the corresponding kakoune one # Translate a vim option into the corresponding kakoune one
translate_opt_vim() { translate_opt_vim() {
@ -37,7 +37,7 @@ def -hidden modeline-parse-impl %{
*) printf %s\\n "echo -debug 'Unsupported vim variable: ${key}'";; *) printf %s\\n "echo -debug 'Unsupported vim variable: ${key}'";;
esac esac
[ -n "${tr}" ] && printf %s\\n "set buffer ${tr}" [ -n "${tr}" ] && printf %s\\n "set-option buffer ${tr}"
} }
# Pass a few whitelisted options to kakoune directly # Pass a few whitelisted options to kakoune directly
@ -51,7 +51,7 @@ def -hidden modeline-parse-impl %{
return;; return;;
esac esac
printf %s\\n "set buffer ${key} ${value}" printf %s\\n "set-option buffer ${key} ${value}"
} }
case "${kak_selection}" in case "${kak_selection}" in
@ -93,10 +93,10 @@ def -hidden modeline-parse-impl %{
# ref. options.txt (in vim `:help options`) : 2 forms of modelines: # ref. options.txt (in vim `:help options`) : 2 forms of modelines:
# [text]{white}{vi:|vim:|ex:}[white]{options} # [text]{white}{vi:|vim:|ex:}[white]{options}
# [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text] # [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
def modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{ define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{
try %{ eval -draft %{ try %{ evaluate-commands -draft %{
exec \%s\A|.\z<ret> %opt{modelines}k <a-x> %opt{modelines}X \ execute-keys \%s\A|.\z<ret> %opt{modelines}k <a-x> %opt{modelines}X \
s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+<ret> <a-x> s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+<ret> <a-x>
eval -draft -itersel modeline-parse-impl evaluate-commands -draft -itersel modeline-parse-impl
} } } }
} }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](moon) %{ hook global BufCreate .*[.](moon) %{
set buffer filetype moon set-option buffer filetype moon
} }
# Highlighters # Highlighters
@ -30,7 +30,7 @@ add-highlighter shared/moon/code regex \b(and|break|catch|class|continue|do|else
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def moon-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ %sh{ define-command moon-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ %sh{
case $kak_buffile in case $kak_buffile in
*spec/*_spec.moon) *spec/*_spec.moon)
altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//))
@ -55,37 +55,37 @@ def moon-alternative-file -docstring 'Jump to the alternate file (implementation
printf %s\\n "edit $altfile" printf %s\\n "edit $altfile"
}} }}
def -hidden moon-filter-around-selections %{ define-command -hidden moon-filter-around-selections %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
exec <a-x> execute-keys <a-x>
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft s \h + $ <ret> d } try %{ execute-keys -draft s \h + $ <ret> d }
} }
} }
def -hidden moon-indent-on-char %{ define-command -hidden moon-indent-on-char %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# align _else_ statements to start # align _else_ statements to start
try %{ exec -draft <a-x> <a-k> ^ \h * (else(if)?) $ <ret> <a-\;> <a-?> ^ \h * (if|unless|when) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (else(if)?) $ <ret> <a-\;> <a-?> ^ \h * (if|unless|when) <ret> s \A | \z <ret> \' <a-&> }
# align _when_ to _switch_ then indent # align _when_ to _switch_ then indent
try %{ exec -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-\;> <a-?> ^ \h * (switch) <ret> s \A | \z <ret> \' <a-&> \' <space> <gt> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-\;> <a-?> ^ \h * (switch) <ret> s \A | \z <ret> \' <a-&> \' <space> <gt> }
# align _catch_ and _finally_ to _try_ # align _catch_ and _finally_ to _try_
try %{ exec -draft <a-x> <a-k> ^ \h * (catch|finally) $ <ret> <a-\;> <a-?> ^ \h * (try) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (catch|finally) $ <ret> <a-\;> <a-?> ^ \h * (try) <ret> s \A | \z <ret> \' <a-&> }
} }
} }
def -hidden moon-indent-on-new-line %{ define-command -hidden moon-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy -- comment prefix and following white spaces # copy -- comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^ \h * \K -- \h * <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^ \h * \K -- \h * <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : moon-filter-around-selections <ret> } try %{ execute-keys -draft k : moon-filter-around-selections <ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k <a-x> <a-k> ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ <ret> j <a-gt> }
# deindent after return statements # deindent after return statements
try %{ exec -draft k <a-x> <a-k> ^ \h * (break|return) \b <ret> j <a-lt> } try %{ execute-keys -draft k <a-x> <a-k> ^ \h * (break|return) \b <ret> j <a-lt> }
} }
} }

View File

@ -2,7 +2,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](php) %{ hook global BufCreate .*[.](php) %{
set buffer filetype php set-option buffer filetype php
} }
# Highlighters # Highlighters
@ -32,28 +32,28 @@ add-highlighter shared/php/code regex \b(__halt_compiler|abstract|and|array|as|b
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden php-filter-around-selections %{ define-command -hidden php-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden php-indent-on-char %< define-command -hidden php-indent-on-char %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %/ exec -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> / try %/ execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> /
> >
> >
def -hidden php-indent-on-new-line %< define-command -hidden php-indent-on-new-line %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# copy // comments prefix and following white spaces # copy // comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : php-filter-around-selections <ret> } try %{ execute-keys -draft k : php-filter-around-selections <ret> }
# indent after lines beginning / ending with opener token # indent after lines beginning / ending with opener token
try %_ exec -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _ try %_ execute-keys -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
> >
> >

View File

@ -5,21 +5,21 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](pony) %{ hook global BufCreate .*[.](pony) %{
set buffer filetype pony set-option buffer filetype pony
} }
# Highlighters & Completion # Highlighters & Completion
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
addhl shared/ regions -default code pony \ add-highlighter shared/ regions -default code pony \
double_string '"""' '"""' '' \ double_string '"""' '"""' '' \
double_string '"' (?<!\\)(\\\\)*" '' \ double_string '"' (?<!\\)(\\\\)*" '' \
comment '/\*' '\*/' '' \ comment '/\*' '\*/' '' \
comment '//' '$' '' comment '//' '$' ''
addhl shared/pony/double_string fill string add-highlighter shared/pony/double_string fill string
# addhl shared/pony/single_string fill string # add-highlighter shared/pony/single_string fill string
addhl shared/pony/comment fill comment add-highlighter shared/pony/comment fill comment
%sh{ %sh{
@ -38,65 +38,65 @@ addhl shared/pony/comment fill comment
static_words="${values}:${meta}:${keywords}:${types_decl}:${capabilities}" static_words="${values}:${meta}:${keywords}:${types_decl}:${capabilities}"
static_words="${static_words}::${struct}" static_words="${static_words}::${struct}"
printf %s\\n "hook global WinSetOption filetype=pony %{ printf %s\\n "hook global WinSetOption filetype=pony %{
set window static_words '${static_words}' set-option window static_words '${static_words}'
}" | sed 's,|,:,g' }" | sed 's,|,:,g'
# Highlight keywords # Highlight keywords
printf %s " printf %s "
addhl shared/pony/code regex '\b(${values})\b' 0:value add-highlighter shared/pony/code regex '\b(${values})\b' 0:value
addhl shared/pony/code regex '\b(${meta})\b' 0:meta add-highlighter shared/pony/code regex '\b(${meta})\b' 0:meta
addhl shared/pony/code regex '\b(${func_decl})(\s+(${capabilities}))?(\s+\w+)\(' 1:type 3:builtin 4:builtin add-highlighter shared/pony/code regex '\b(${func_decl})(\s+(${capabilities}))?(\s+\w+)\(' 1:type 3:builtin 4:builtin
addhl shared/pony/code regex '\b(${func_decl})\b' 0:type add-highlighter shared/pony/code regex '\b(${func_decl})\b' 0:type
addhl shared/pony/code regex '=>' 0:type add-highlighter shared/pony/code regex '=>' 0:type
addhl shared/pony/code regex '\b(${keywords})\b' 0:keyword add-highlighter shared/pony/code regex '\b(${keywords})\b' 0:keyword
addhl shared/pony/code regex ';' 0:keyword add-highlighter shared/pony/code regex ';' 0:keyword
addhl shared/pony/code regex '^\s*|' 0:keyword add-highlighter shared/pony/code regex '^\s*|' 0:keyword
addhl shared/pony/code regex '\b(${struct})\b' 0:variable add-highlighter shared/pony/code regex '\b(${struct})\b' 0:variable
addhl shared/pony/code regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin add-highlighter shared/pony/code regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin
" "
# Highlight types and attributes # Highlight types and attributes
printf %s " printf %s "
addhl shared/pony/code regex '@[\w_]+\b' 0:attribute add-highlighter shared/pony/code regex '@[\w_]+\b' 0:attribute
" "
} }
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden pony-indent-on-new-line %{ define-command -hidden pony-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft <space> K <a-&> } try %{ execute-keys -draft <space> K <a-&> }
# cleanup trailing whitespaces from previous line # cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# copy '//' comment prefix and following white spaces # copy '//' comment prefix and following white spaces
# try %{ exec -draft k x s ^\h*//\h* <ret> y jgh P } # try %{ execute-keys -draft k x s ^\h*//\h* <ret> y jgh P }
# indent after line ending with : # indent after line ending with :
try %{ exec -draft <space> k x <a-k> (do|try|then|else|:|=>)$ <ret> j <a-gt> } try %{ execute-keys -draft <space> k x <a-k> (do|try|then|else|:|=>)$ <ret> j <a-gt> }
# else, end are always de-indented # else, end are always de-indented
try %{ exec -draft <space> k x <a-k> (else|end):$ <ret> k x s ^\h* <ret> y j x <a-k> ^<c-r>" <ret> J <a-lt> } try %{ execute-keys -draft <space> k x <a-k> (else|end):$ <ret> k x s ^\h* <ret> y j x <a-k> ^<c-r>" <ret> J <a-lt> }
} }
} }
# Initialization # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group pony-highlight global WinSetOption filetype=pony %{ addhl window ref pony } hook -group pony-highlight global WinSetOption filetype=pony %{ add-highlighter window ref pony }
hook global WinSetOption filetype=pony %{ hook global WinSetOption filetype=pony %{
hook window InsertChar \n -group pony-indent pony-indent-on-new-line hook window InsertChar \n -group pony-indent pony-indent-on-new-line
# cleanup trailing whitespaces on current line insert end # cleanup trailing whitespaces on current line insert end
hook window InsertEnd .* -group pony-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } } hook window InsertEnd .* -group pony-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
} }
hook global WinSetOption filetype=pony %{ hook global WinSetOption filetype=pony %{
set buffer tabstop 2 set-option buffer tabstop 2
set buffer indentwidth 2 set-option buffer indentwidth 2
} }
hook -group pony-highlight global WinSetOption filetype=(?!pony).* %{ rmhl pony } hook -group pony-highlight global WinSetOption filetype=(?!pony).* %{ remove-highlighter pony }
hook global WinSetOption filetype=(?!pony).* %{ hook global WinSetOption filetype=(?!pony).* %{
rmhooks window pony-indent remove-hooks window pony-indent
} }

View File

@ -9,7 +9,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](pug|jade) %{ hook global BufCreate .*[.](pug|jade) %{
set buffer filetype pug set-option buffer filetype pug
} }
# Highlighters # Highlighters
@ -44,21 +44,21 @@ add-highlighter shared/pug/code regex ((?:\.[A-Za-z][A-Za-z0-9_-]*
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden pug-filter-around-selections %{ define-command -hidden pug-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden pug-indent-on-new-line %{ define-command -hidden pug-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : pug-filter-around-selections <ret> } try %{ execute-keys -draft k : pug-filter-around-selections <ret> }
# copy '//', '|', '-' or '(!)=' prefix and following whitespace # copy '//', '|', '-' or '(!)=' prefix and following whitespace
try %{ exec -draft k <a-x> s ^\h*\K[/|!=-]{1,2}\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K[/|!=-]{1,2}\h* <ret> y gh j P }
# indent unless we copied something above # indent unless we copied something above
try %{ exec -draft <a-gt> <space> b s \S <ret> g l <a-lt> } try %{ execute-keys -draft <a-gt> <space> b s \S <ret> g l <a-lt> }
} }
} }

View File

@ -1,11 +1,11 @@
decl -hidden str racer_tmp_dir declare-option -hidden str racer_tmp_dir
decl -hidden completions racer_completions declare-option -hidden completions racer_completions
def racer-complete -docstring "Complete the current selection with racer" %{ define-command racer-complete -docstring "Complete the current selection with racer" %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-racer.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-racer.XXXXXXXX)
printf %s\\n "set buffer racer_tmp_dir ${dir}" printf %s\\n "set-option buffer racer_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks %{ write ${dir}/buf }" printf %s\\n "evaluate-commands -no-hooks %{ write ${dir}/buf }"
} }
%sh{ %sh{
dir=${kak_opt_racer_tmp_dir} dir=${kak_opt_racer_tmp_dir}
@ -44,25 +44,25 @@ def racer-complete -docstring "Complete the current selection with racer" %{
print candidate print candidate
}' }'
) )
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
set buffer=${kak_bufname} racer_completions %@${compl}@ set-option buffer=${kak_bufname} racer_completions %@${compl}@
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
rm -r ${dir} rm -r ${dir}
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &
} }
} }
def racer-enable-autocomplete -docstring "Add racer completion candidates to the completer" %{ define-command racer-enable-autocomplete -docstring "Add racer completion candidates to the completer" %{
set window completers "option=racer_completions:%opt{completers}" set-option window completers "option=racer_completions:%opt{completers}"
hook window -group racer-autocomplete InsertIdle .* %{ try %{ hook window -group racer-autocomplete InsertIdle .* %{ try %{
exec -draft <a-h><a-k>([\w\.]|::).\z<ret> execute-keys -draft <a-h><a-k>([\w\.]|::).\z<ret>
racer-complete racer-complete
} } } }
alias window complete racer-complete alias window complete racer-complete
} }
def racer-disable-autocomplete -docstring "Disable racer completion" %{ define-command racer-disable-autocomplete -docstring "Disable racer completion" %{
set window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed 's/option=racer_completions://g' } set-option window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed 's/option=racer_completions://g' }
rmhooks window racer-autocomplete remove-hooks window racer-autocomplete
unalias window complete racer-complete unalias window complete racer-complete
} }

View File

@ -7,7 +7,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](ragel|rl) %{ hook global BufCreate .*[.](ragel|rl) %{
set buffer filetype ragel set-option buffer filetype ragel
} }
# Highlighters # Highlighters
@ -29,29 +29,29 @@ add-highlighter shared/ragel/code regex \b(action|alnum|alpha|any|ascii|case|cnt
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden ragel-filter-around-selections %{ define-command -hidden ragel-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden ragel-indent-on-char %< define-command -hidden ragel-indent-on-char %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %< exec -draft <a-h> <a-k> ^\h+[]})]$ <ret> m s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+[]})]$ <ret> m s \A|.\z <ret> 1<a-&> >
try %< exec -draft <a-h> <a-k> ^\h+ [*]$ <ret> <a-?> [*]$ <ret> s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+ [*]$ <ret> <a-?> [*]$ <ret> s \A|.\z <ret> 1<a-&> >
> >
> >
def -hidden ragel-indent-on-new-line %< define-command -hidden ragel-indent-on-new-line %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# copy _#_ comment prefix and following white spaces # copy _#_ comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : ragel-filter-around-selections <ret> } try %{ execute-keys -draft k : ragel-filter-around-selections <ret> }
# indent after lines ending with opener token # indent after lines ending with opener token
try %< exec -draft k <a-x> <a-k> [[{(*]$ <ret> j <a-gt> > try %< execute-keys -draft k <a-x> <a-k> [[{(*]$ <ret> j <a-gt> >
> >
> >

View File

@ -1,7 +1,7 @@
# http://ranger.nongnu.org # http://ranger.nongnu.org
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
def ranger-open-on-edit-directory \ define-command ranger-open-on-edit-directory \
-docstring 'Start the ranger file system explorer when trying to edit a directory' %{ -docstring 'Start the ranger file system explorer when trying to edit a directory' %{
hook global RuntimeError "\d+:\d+: '\w+' (.*): is a directory" %{ %sh{ hook global RuntimeError "\d+:\d+: '\w+' (.*): is a directory" %{ %sh{
directory=$kak_hook_param_capture_1 directory=$kak_hook_param_capture_1
@ -9,7 +9,7 @@ def ranger-open-on-edit-directory \
}} }}
} }
def \ define-command \
-params .. -file-completion \ -params .. -file-completion \
-docstring %{ranger [<arguments>]: open the file system explorer to select buffers to open -docstring %{ranger [<arguments>]: open the file system explorer to select buffers to open
All the optional arguments are forwarded to the ranger utility} \ All the optional arguments are forwarded to the ranger utility} \
@ -19,7 +19,7 @@ All the optional arguments are forwarded to the ranger utility} \
ranger $@ --cmd " \ ranger $@ --cmd " \
map <return> eval \ map <return> eval \
fm.execute_console('shell \ fm.execute_console('shell \
echo eval -client $kak_client edit {file} | \ echo evaluate-commands -client $kak_client edit {file} | \
kak -p $kak_session; \ kak -p $kak_session; \
tmux select-pane -t $kak_client_env_TMUX_PANE'.format(file=fm.thisfile.path)) \ tmux select-pane -t $kak_client_env_TMUX_PANE'.format(file=fm.thisfile.path)) \
if fm.thisfile.is_file else fm.execute_console('move right=1')" if fm.thisfile.is_file else fm.execute_console('move right=1')"
@ -28,7 +28,7 @@ All the optional arguments are forwarded to the ranger utility} \
ranger $@ --cmd "'"'" \ ranger $@ --cmd "'"'" \
map <return> eval \ map <return> eval \
fm.execute_console('shell \ fm.execute_console('shell \
echo eval -client $kak_client edit {file} | \ echo evaluate-commands -client $kak_client edit {file} | \
kak -p $kak_session; \ kak -p $kak_session; \
xdotool windowactivate $kak_client_env_WINDOWID'.format(file=fm.thisfile.path)) \ xdotool windowactivate $kak_client_env_WINDOWID'.format(file=fm.thisfile.path)) \
if fm.thisfile.is_file else fm.execute_console('move right=1')"'"' < /dev/null > /dev/null 2>&1 & if fm.thisfile.is_file else fm.execute_console('move right=1')"'"' < /dev/null > /dev/null 2>&1 &

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](sass) %{ hook global BufCreate .*[.](sass) %{
set buffer filetype sass set-option buffer filetype sass
} }
# Highlighters # Highlighters
@ -29,21 +29,21 @@ add-highlighter shared/sass/code regex !important 0:keyword
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden sass-filter-around-selections %{ define-command -hidden sass-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
def -hidden sass-indent-on-new-line %{ define-command -hidden sass-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '/' comment prefix and following white spaces # copy '/' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : sass-filter-around-selections <ret> } try %{ execute-keys -draft k : sass-filter-around-selections <ret> }
# avoid indent after properties and comments # avoid indent after properties and comments
try %{ exec -draft k <a-x> <a-K> [:/] <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-K> [:/] <ret> j <a-gt> }
} }
} }

View File

@ -7,7 +7,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](scss) %{ hook global BufCreate .*[.](scss) %{
set buffer filetype scss set-option buffer filetype scss
} }
# Highlighters # Highlighters
@ -25,9 +25,9 @@ add-highlighter shared/scss/core regex @[A-Za-z][A-Za-z0-9_-]* 0:meta
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden scss-filter-around-selections css-filter-around-selections define-command -hidden scss-filter-around-selections css-filter-around-selections
def -hidden scss-indent-on-new-line css-indent-on-new-line define-command -hidden scss-indent-on-new-line css-indent-on-new-line
def -hidden scss-indent-on-closing-curly-brace css-indent-on-closing-curly-brace define-command -hidden scss-indent-on-closing-curly-brace css-indent-on-closing-curly-brace
# Initialization # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.taskpaper %{ hook global BufCreate .*\.taskpaper %{
set buffer filetype taskpaper set-option buffer filetype taskpaper
} }
# Highlighters # Highlighters
@ -22,14 +22,14 @@ add-highlighter shared/taskpaper regex (([a-z]+://\S+)|((mailto:)[\w+-]+@\S+)) 0
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
def -hidden taskpaper-indent-on-new-line %{ define-command -hidden taskpaper-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
## If the line above is a project indent with a tab ## If the line above is a project indent with a tab
try %{ exec -draft Z k<a-x> <a-k>^\h*([^:\n]+):<ret> z i<tab> } try %{ execute-keys -draft Z k<a-x> <a-k>^\h*([^:\n]+):<ret> z i<tab> }
# cleanup trailing white spaces on previous line # cleanup trailing white spaces on previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
} }
} }

View File

@ -22,7 +22,7 @@ hook global KakBegin .* %{
} }
} }
def -hidden -params 1..2 tmux-repl-impl %{ define-command -hidden -params 1..2 tmux-repl-impl %{
%sh{ %sh{
if [ -z "$TMUX" ]; then if [ -z "$TMUX" ]; then
echo "echo -markup '{Error}This command is only available in a tmux session'" echo "echo -markup '{Error}This command is only available in a tmux session'"
@ -37,19 +37,19 @@ def -hidden -params 1..2 tmux-repl-impl %{
} }
} }
def tmux-repl-vertical -params 0..1 -command-completion -docstring "Create a new vertical pane for repl interaction" %{ define-command tmux-repl-vertical -params 0..1 -command-completion -docstring "Create a new vertical pane for repl interaction" %{
tmux-repl-impl 'split-window -v' %arg{@} tmux-repl-impl 'split-window -v' %arg{@}
} }
def tmux-repl-horizontal -params 0..1 -command-completion -docstring "Create a new horizontal pane for repl interaction" %{ define-command tmux-repl-horizontal -params 0..1 -command-completion -docstring "Create a new horizontal pane for repl interaction" %{
tmux-repl-impl 'split-window -h' %arg{@} tmux-repl-impl 'split-window -h' %arg{@}
} }
def tmux-repl-window -params 0..1 -command-completion -docstring "Create a new window for repl interaction" %{ define-command tmux-repl-window -params 0..1 -command-completion -docstring "Create a new window for repl interaction" %{
tmux-repl-impl 'new-window' %arg{@} tmux-repl-impl 'new-window' %arg{@}
} }
def -hidden tmux-send-text -docstring "Send the selected text to the repl pane" %{ define-command -hidden tmux-send-text -docstring "Send the selected text to the repl pane" %{
nop %sh{ nop %sh{
tmux set-buffer -b kak_selection "${kak_selection}" tmux set-buffer -b kak_selection "${kak_selection}"
kak_orig_window=$(tmux display-message -p '#I') kak_orig_window=$(tmux display-message -p '#I')
@ -62,7 +62,7 @@ def -hidden tmux-send-text -docstring "Send the selected text to the repl pane"
} }
} }
def -hidden tmux-repl-disabled %{ %sh{ define-command -hidden tmux-repl-disabled %{ %sh{
VERSION_TMUX=$(tmux -V) VERSION_TMUX=$(tmux -V)
printf %s "echo -markup %{{Error}The version of tmux is too old: got ${VERSION_TMUX}, expected >= 2.x}" printf %s "echo -markup %{{Error}The version of tmux is too old: got ${VERSION_TMUX}, expected >= 2.x}"
} } } }

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate (.+/)?[Tt]upfile %{ hook global BufCreate (.+/)?[Tt]upfile %{
set buffer filetype tupfile set-option buffer filetype tupfile
} }
# Highlighters # Highlighters

View File

@ -5,7 +5,7 @@
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](ts)x? %{ hook global BufCreate .*[.](ts)x? %{
set buffer filetype typescript set-option buffer filetype typescript
} }
# Highlighters # Highlighters

View File

@ -1,18 +1,18 @@
# termcmd should already be set in x11.kak # termcmd should already be set-option in x11.kak
def -docstring %{x11-repl [<arguments>]: create a new window for repl interaction define-command -docstring %{x11-repl [<arguments>]: create a new window for repl interaction
All optional parameters are forwarded to the new window} \ All optional parameters are forwarded to the new window} \
-params .. \ -params .. \
-command-completion \ -command-completion \
x11-repl %{ %sh{ x11-repl %{ %sh{
if [ -z "${kak_opt_termcmd}" ]; then if [ -z "${kak_opt_termcmd}" ]; then
echo "echo -markup '{Error}termcmd option is not set'" echo "echo -markup '{Error}termcmd option is not set-option'"
exit exit
fi fi
if [ $# -eq 0 ]; then cmd="${SHELL:-sh}"; else cmd="$@"; fi if [ $# -eq 0 ]; then cmd="${SHELL:-sh}"; else cmd="$@"; fi
setsid ${kak_opt_termcmd} ${cmd} -t kak_repl_window < /dev/null > /dev/null 2>&1 & setsid ${kak_opt_termcmd} ${cmd} -t kak_repl_window < /dev/null > /dev/null 2>&1 &
}} }}
def x11-send-text -docstring "send the selected text to the repl window" %{ define-command x11-send-text -docstring "send the selected text to the repl window" %{
nop %sh{ nop %sh{
printf %s\\n "${kak_selection}" | xsel -i printf %s\\n "${kak_selection}" | xsel -i
wid=$(xdotool getactivewindow) wid=$(xdotool getactivewindow)

View File

@ -1669,9 +1669,9 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
} }
const CommandDesc exec_string_cmd = { const CommandDesc exec_string_cmd = {
"execute-keys",
"exec", "exec",
nullptr, "execute-keys <switches> <keys>: execute given keys as if entered by user",
"exec <switches> <keys>: execute given keys as if entered by user",
context_wrap_params, context_wrap_params,
CommandFlags::None, CommandFlags::None,
CommandHelper{}, CommandHelper{},
@ -1694,9 +1694,9 @@ const CommandDesc exec_string_cmd = {
}; };
const CommandDesc eval_string_cmd = { const CommandDesc eval_string_cmd = {
"evaluate-commands",
"eval", "eval",
nullptr, "evaluate-commands <switches> <commands>...: execute commands as if entered by user",
"eval <switches> <commands>...: execute commands as if entered by user",
context_wrap_params, context_wrap_params,
CommandFlags::None, CommandFlags::None,
CommandHelper{}, CommandHelper{},