Merge remote-tracking branch 'greenfork/improve-ruby-hooks'

This commit is contained in:
Maxime Coste 2021-06-15 20:47:26 +10:00
commit 682426bf7b
13 changed files with 49 additions and 2 deletions

View File

@ -156,7 +156,6 @@ define-command -hidden ruby-indent-on-char %{
try %{ execute-keys -draft <a-x> <a-k> ^ \h * (elsif) $ <ret> <a-a> i <a-semicolon> <a-?> ^ \h * (if) <ret> <a-S> 1<a-&> }
try %{ execute-keys -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-a> i <a-semicolon> <a-?> ^ \h * (case) <ret> <a-S> 1<a-&> }
try %{ execute-keys -draft <a-x> <a-k> ^ \h * (rescue) $ <ret> <a-a> i <a-semicolon> <a-?> ^ \h * (begin|def) <ret> <a-S> 1<a-&> }
try %{ execute-keys -draft <a-x> <a-k> ^ \h * (end) $ <ret> <a-a> i <a-semicolon> <a-?> ^ \h * (begin|case|class|def|for|if|module|unless|until|while) <ret> <a-S> 1<a-&> }
}
}
@ -174,7 +173,7 @@ define-command -hidden ruby-indent-on-new-line %{
define-command -hidden ruby-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> y j <a-x><semicolon> P }
try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y jgi P }
# wisely add end structure
evaluate-commands -save-regs x %[
try %{ execute-keys -draft k <a-x> s ^ \h + <ret> \" x y } catch %{ reg x '' }

View File

@ -0,0 +1 @@
c<ret>elsif<ret>else

View File

@ -0,0 +1 @@
if%( )

View File

@ -0,0 +1,4 @@
if
elsif
else
end

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/ruby.kak"
set buffer filetype ruby

View File

@ -0,0 +1 @@
c<ret><esc><a-o>jo# comment3<ret>comment4<esc><a-o>jo# indented<ret>indented2<esc><a-o>jodef f<ret># comment<ret>comment2<esc>j<a-o>jodef f<ret># comment<esc>hhhi<ret>

View File

@ -0,0 +1 @@
# Comment%( ) comment2

View File

@ -0,0 +1,18 @@
# Comment
# comment2
# comment3
# comment4
# indented
# indented2
def f
# comment
# comment2
end
def f
# comm
# ent
end

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/ruby.kak"
set buffer filetype ruby

View File

@ -0,0 +1 @@
c<space><space>end

View File

@ -0,0 +1,6 @@
class MyClass
def method
%( )
expression
end

View File

@ -0,0 +1,6 @@
class MyClass
def method
end
expression
end

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/ruby.kak"
set buffer filetype ruby