mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-23 23:34:12 +03:00
Improve latex support.
Auto insert "\end{[word]}" for "\begin{[word]}".
This commit is contained in:
parent
e0d2602e6a
commit
705712f13b
@ -18,6 +18,7 @@ hook global WinSetOption filetype=latex %(
|
||||
hook window InsertChar \} -group latex-indent %{ latex-indent-closing-brace }
|
||||
hook window ModeChange pop:insert:.* -group latex-indent %{ latex-trim-indent }
|
||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks latex-indent }
|
||||
hook window InsertChar \n -group latex-insert latex-insert-on-new-line
|
||||
)
|
||||
|
||||
hook -group latex-highlight global WinSetOption filetype=latex %{
|
||||
@ -93,4 +94,22 @@ define-command -hidden latex-indent-closing-brace %(
|
||||
)
|
||||
)
|
||||
|
||||
define-command -hidden latex-insert-on-new-line %(
|
||||
evaluate-commands -no-hooks -draft -itersel %(
|
||||
# Wisely add "\end{...}".
|
||||
evaluate-commands -save-regs xz %(
|
||||
# Save previous line indent in register x.
|
||||
try %( execute-keys -draft k<a-x>s^\h+<ret>"xy ) catch %( reg x '' )
|
||||
# Save item of begin in register z.
|
||||
try %( execute-keys -draft k<a-x>s\{.*\}<ret>"zy ) catch %( reg z '' )
|
||||
try %(
|
||||
# Validate previous line and that it is not closed yet.
|
||||
execute-keys -draft k<a-x> <a-k>^<c-r>x\h*\\begin\{.*\}<ret> J}iJ<a-x> <a-K>^<c-r>x(\\end\<c-r>z<backspace>\})<ret>
|
||||
# Auto insert "\end{...}".
|
||||
execute-keys -draft o<c-r>x\end<c-r>z<esc>
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
~
|
||||
|
Loading…
Reference in New Issue
Block a user