mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-25 10:32:19 +03:00
Merge remote-tracking branch 'alexherbo2/lua-rc'
This commit is contained in:
commit
4c7e6bdca0
@ -11,7 +11,7 @@ hook global BufSetOption mimetype=text/x-lua %{
|
|||||||
}
|
}
|
||||||
|
|
||||||
hook global BufCreate .*[.](lua) %{
|
hook global BufCreate .*[.](lua) %{
|
||||||
set buffer filetype lua
|
set buffer mimetype text/x-lua
|
||||||
}
|
}
|
||||||
|
|
||||||
# Highlighters
|
# Highlighters
|
||||||
@ -32,6 +32,31 @@ addhl -group /lua/code regex \<(and|break|do|else|elseif|end|false|for|function|
|
|||||||
# Commands
|
# Commands
|
||||||
# ‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
def lua-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ %sh{
|
||||||
|
case $kak_buffile in
|
||||||
|
*spec/*_spec.lua)
|
||||||
|
altfile=$(eval echo $(echo $kak_buffile | sed -e s+spec/+'*'/+';'s/_spec//))
|
||||||
|
[ ! -f $altfile ] && echo "echo -color Error 'implementation file not found'" && exit
|
||||||
|
;;
|
||||||
|
*.lua)
|
||||||
|
path=$kak_buffile
|
||||||
|
dirs=$(while [ $path ]; do echo $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 -e s+[^/]'*'/++';'s/.lua$/_spec.lua/)
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ ! -d $altdir ] && echo "echo -color Error 'spec/ not found'" && exit
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "echo -color Error 'alternative file not found'" && exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "edit $altfile"
|
||||||
|
}}
|
||||||
|
|
||||||
def -hidden _lua_filter_around_selections %{
|
def -hidden _lua_filter_around_selections %{
|
||||||
eval -draft -itersel %{
|
eval -draft -itersel %{
|
||||||
exec <a-x>
|
exec <a-x>
|
||||||
@ -77,6 +102,8 @@ hook global WinSetOption filetype=lua %{
|
|||||||
hook window InsertChar .* -group lua-indent _lua_indent_on_char
|
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-indent _lua_indent_on_new_line
|
||||||
|
|
||||||
|
alias window alt lua-alternative-file
|
||||||
|
|
||||||
set window comment_line_chars '--'
|
set window comment_line_chars '--'
|
||||||
set window comment_selection_chars '\Q--[[:]]'
|
set window comment_selection_chars '\Q--[[:]]'
|
||||||
}
|
}
|
||||||
@ -85,4 +112,6 @@ hook global WinSetOption filetype=(?!lua).* %{
|
|||||||
rmhl lua
|
rmhl lua
|
||||||
rmhooks window lua-indent
|
rmhooks window lua-indent
|
||||||
rmhooks window lua-hooks
|
rmhooks window lua-hooks
|
||||||
|
|
||||||
|
unalias window alt lua-alternative-file
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user