diff options
| author | Alex Leferry 2 <alexherbo2@gmail.com> | 2019-03-18 19:56:34 +0100 |
|---|---|---|
| committer | Alex Leferry 2 <alexherbo2@gmail.com> | 2019-03-21 01:06:16 +0100 |
| commit | c0dccdd90dd615cf663d95fd94fbdbdf2a88b165 (patch) | |
| tree | cb48fb1b7fb74e6e3b98a62f6e2768686bb75c98 /rc/base/lua.kak | |
| parent | f87e844244d5ee81e9c1ceb04c354726002ae760 (diff) | |
Add categories in rc/
Closes #2783
Diffstat (limited to 'rc/base/lua.kak')
| -rw-r--r-- | rc/base/lua.kak | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/rc/base/lua.kak b/rc/base/lua.kak deleted file mode 100644 index 605148e0..00000000 --- a/rc/base/lua.kak +++ /dev/null @@ -1,103 +0,0 @@ -# http://lua.org -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -# Detection -# ‾‾‾‾‾‾‾‾‾ - -hook global BufCreate .*[.](lua) %{ - set-option buffer filetype lua -} - -# Highlighters -# ‾‾‾‾‾‾‾‾‾‾‾‾ - -add-highlighter shared/lua regions -add-highlighter shared/lua/code default-region group -add-highlighter shared/lua/raw_string region -match-capture '\[(=*)\[' '\](=*)\]' fill string -add-highlighter shared/lua/raw_comment region -match-capture '--\[(=*)\[' '\](=*)\]' fill comment -add-highlighter shared/lua/double_string region '"' (?<!\\)(?:\\\\)*" fill string -add-highlighter shared/lua/single_string region "'" (?<!\\)(?:\\\\)*' fill string -add-highlighter shared/lua/comment region '--' $ fill comment - -add-highlighter shared/lua/code/ regex \b(and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b 0:keyword - -# Commands -# ‾‾‾‾‾‾‾‾ - -define-command lua-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ evaluate-commands %sh{ - case $kak_buffile in - *spec/*_spec.lua) - altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) - [ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit - ;; - *.lua) - path=$kak_buffile - dirs=$(while [ $path ]; do printf %s\\n $path; path=${path%/*}; done | tail -n +2) - for dir in $dirs; do - altdir=$dir/spec - if [ -d $altdir ]; then - altfile=$altdir/$(realpath $kak_buffile --relative-to $dir | sed s+[^/]'*'/++';'s/.lua$/_spec.lua/) - break - fi - done - [ ! -d $altdir ] && echo "echo -markup '{Error}spec/ not found'" && exit - ;; - *) - echo "echo -markup '{Error}alternative file not found'" && exit - ;; - esac - printf %s\\n "edit $altfile" -}} - -define-command -hidden lua-indent-on-char %{ - evaluate-commands -no-hooks -draft -itersel %{ - # align middle and end structures to start and indent when necessary, elseif is already covered by else - try %{ execute-keys -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*(end)$<ret><a-\;><a-?>^\h*(for|function|if|while)<ret>s\A|\z<ret>)<a-&> } - } -} - -define-command -hidden lua-indent-on-new-line %{ - evaluate-commands -no-hooks -draft -itersel %{ - # preserve previous line indent - try %{ execute-keys -draft <space>K<a-&> } - # remove trailing white spaces from previous line - try %{ execute-keys -draft k<a-x>s\h+$<ret>d } - # indent after start structure - try %{ execute-keys -draft k<a-x><a-k>^\h*(else|elseif|for|function|if|while)\b<ret>j<a-gt> } - } -} - -define-command -hidden lua-insert-on-new-line %[ - evaluate-commands -no-hooks -draft -itersel %[ - # copy -- comment prefix and following white spaces - try %{ execute-keys -draft k<a-x>s^\h*\K--\h*<ret>yghjP } - # wisely add end structure - evaluate-commands -save-regs x %[ - try %{ execute-keys -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' } # Save previous line indent in register x - try %[ execute-keys -draft k<a-x> <a-k>^<c-r>x(for|function|if|while)<ret> J}iJ<a-x> <a-K>^<c-r>x(else|end|elseif)$<ret> # Validate previous line and that it is not closed yet - execute-keys -draft o<c-r>xend<esc> ] # auto insert end - ] - ] -] - -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group lua-highlight global WinSetOption filetype=lua %{ - add-highlighter window/lua ref lua - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lua } -} - -hook global WinSetOption filetype=lua %{ - hook window InsertChar .* -group lua-indent lua-indent-on-char - hook window InsertChar \n -group lua-indent lua-indent-on-new-line - hook window InsertChar \n -group lua-insert lua-insert-on-new-line - - alias window alt lua-alternative-file - - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window lua-.+ - unalias window alt lua-alternative-file - } -} |
