rc restructuredtext: only add language highlighters for actual code blocks in buffer
Analogous to markdown.kak.
This commit is contained in:
parent
907ad84f46
commit
9fc62609b1
|
@ -12,6 +12,15 @@ hook global WinSetOption filetype=restructuredtext %{
|
||||||
require-module restructuredtext
|
require-module restructuredtext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hook -group restructuredtext-load-languages global WinSetOption filetype=restructuredtext %{
|
||||||
|
restructuredtext-load-languages '%'
|
||||||
|
}
|
||||||
|
|
||||||
|
hook -group restructuredtext-load-languages global WinSetOption filetype=restructuredtext %{
|
||||||
|
hook -group restructuredtext-load-languages window NormalIdle .* %{restructuredtext-load-languages gtGbGl}
|
||||||
|
hook -group restructuredtext-load-languages window InsertIdle .* %{restructuredtext-load-languages gtGbGl}
|
||||||
|
}
|
||||||
|
|
||||||
hook -group restructuredtext-highlight global WinSetOption filetype=restructuredtext %{
|
hook -group restructuredtext-highlight global WinSetOption filetype=restructuredtext %{
|
||||||
add-highlighter window/restructuredtext ref restructuredtext
|
add-highlighter window/restructuredtext ref restructuredtext
|
||||||
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/restructuredtext }
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/restructuredtext }
|
||||||
|
@ -26,16 +35,6 @@ add-highlighter shared/restructuredtext regions
|
||||||
add-highlighter shared/restructuredtext/content default-region group
|
add-highlighter shared/restructuredtext/content default-region group
|
||||||
add-highlighter shared/restructuredtext/code region ::\h*\n ^(?=\S) fill meta
|
add-highlighter shared/restructuredtext/code region ::\h*\n ^(?=\S) fill meta
|
||||||
|
|
||||||
evaluate-commands %sh{
|
|
||||||
for ft in c cabal clojure coffee cpp css cucumber ddiff dockerfile \
|
|
||||||
fish gas go haml haskell html ini java javascript json \
|
|
||||||
julia kak kickstart latex lisp lua makefile moon objc \
|
|
||||||
perl pug python ragel ruby rust sass scala scss sh swift \
|
|
||||||
tupfile yaml; do
|
|
||||||
printf 'add-highlighter shared/restructuredtext/%s region %s %s ref %s\n' "$ft" "\.\.\h*code-block::\h*$ft\h*\n" '^(?=\S)' "$ft"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Setext-style header
|
# Setext-style header
|
||||||
# Valid header characters:
|
# Valid header characters:
|
||||||
# # ! " $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
|
# # ! " $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
|
||||||
|
@ -78,4 +77,16 @@ add-highlighter shared/restructuredtext/content/ regex [^*](\*\*([^\s*]|([^\s*][
|
||||||
add-highlighter shared/restructuredtext/content/ regex [^*](\*([^\s*]|([^\s*][^*]*[^\s*]))\*)[^*] 1:+i
|
add-highlighter shared/restructuredtext/content/ regex [^*](\*([^\s*]|([^\s*][^*]*[^\s*]))\*)[^*] 1:+i
|
||||||
add-highlighter shared/restructuredtext/content/ regex [^`](``([^\s`]|([^\s`][^`]*[^\s`]))``)[^`] 1:mono
|
add-highlighter shared/restructuredtext/content/ regex [^`](``([^\s`]|([^\s`][^`]*[^\s`]))``)[^`] 1:mono
|
||||||
|
|
||||||
|
define-command restructuredtext-load-languages -params 1 %{
|
||||||
|
evaluate-commands -draft %{ try %{
|
||||||
|
execute-keys "%arg{1}s^\.\.\h*code-block::\h*\K\w+<ret>"
|
||||||
|
evaluate-commands -itersel %{ try %{
|
||||||
|
require-module %val{selection}
|
||||||
|
add-highlighter "shared/restructuredtext/%val{selection}" region "\.\.\h*code-block::\h*%val{selection}\h*\n" '^(?=\S)' regions
|
||||||
|
add-highlighter "shared/restructuredtext/%val{selection}/" default-region fill meta
|
||||||
|
add-highlighter "shared/restructuredtext/%val{selection}/inner" region \A\.\.\h*code-block::[^\n]*\K '^(?=\S)' ref %val{selection}
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user