2017-11-23 02:52:23 +01:00
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](rst) %{
|
|
|
|
set-option buffer filetype restructuredtext
|
|
|
|
}
|
|
|
|
|
2019-04-12 00:54:58 +02:00
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global WinSetOption filetype=restructuredtext %{
|
2019-03-13 06:24:33 +01:00
|
|
|
require-module restructuredtext
|
|
|
|
}
|
|
|
|
|
2022-08-13 23:00:03 +02:00
|
|
|
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}
|
|
|
|
}
|
|
|
|
|
2019-04-12 00:54:58 +02:00
|
|
|
hook -group restructuredtext-highlight global WinSetOption filetype=restructuredtext %{
|
|
|
|
add-highlighter window/restructuredtext ref restructuredtext
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/restructuredtext }
|
|
|
|
}
|
|
|
|
|
2019-03-13 06:24:33 +01:00
|
|
|
provide-module restructuredtext %{
|
|
|
|
|
2017-11-23 02:52:23 +01:00
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/restructuredtext regions
|
|
|
|
add-highlighter shared/restructuredtext/content default-region group
|
2020-10-26 18:41:10 +01:00
|
|
|
add-highlighter shared/restructuredtext/code region ::\h*\n ^(?=\S) fill meta
|
2017-11-23 02:52:23 +01:00
|
|
|
|
|
|
|
# Setext-style header
|
|
|
|
# Valid header characters:
|
|
|
|
# # ! " $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(#{3,}\n)?[^\n]+\n(#{3,})$ 0:title
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(!{3,}\n)?[^\n]+\n(!{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)("{3,}\n)?[^\n]+\n("{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\${3,}\n)?[^\n]+\n(\${3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(%{3,}\n)?[^\n]+\n(%{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(&{3,}\n)?[^\n]+\n(&{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)('{3,}\n)?[^\n]+\n('{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\({3,}\n)?[^\n]+\n(\({3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\){3,}\n)?[^\n]+\n(\){3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\*{3,}\n)?[^\n]+\n(\*{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\+{3,}\n)?[^\n]+\n(\+{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(,{3,}\n)?[^\n]+\n(,{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(-{3,}\n)?[^\n]+\n(-{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\.{3,}\n)?[^\n]+\n(\.{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(/{3,}\n)?[^\n]+\n(/{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(:{3,}\n)?[^\n]+\n(:{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\;{3,}\n)?[^\n]+\n(\;{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(<{3,}\n)?[^\n]+\n(<{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(={3,}\n)?[^\n]+\n(={3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(>{3,}\n)?[^\n]+\n(>{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\?{3,}\n)?[^\n]+\n(\?{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(@{3,}\n)?[^\n]+\n(@{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\[{3,}\n)?[^\n]+\n(\[{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\\{3,}\n)?[^\n]+\n(\\{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\]{3,}\n)?[^\n]+\n(\]{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\^{3,}\n)?[^\n]+\n(\^{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(_{3,}\n)?[^\n]+\n(_{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(`{3,}\n)?[^\n]+\n(`{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\{{3,}\n)?[^\n]+\n(\{{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\|{3,}\n)?[^\n]+\n(\|{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\}{3,}\n)?[^\n]+\n(\}{3,})$ 0:header
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(~{3,}\n)?[^\n]+\n(~{3,})$ 0:header
|
2017-11-23 02:52:23 +01:00
|
|
|
|
|
|
|
# Inline markup
|
2020-05-15 10:56:38 +02:00
|
|
|
add-highlighter shared/restructuredtext/content/ regex [^*](\*\*([^\s*]|([^\s*][^*]*[^\s*]))\*\*)[^*] 1:+b
|
|
|
|
add-highlighter shared/restructuredtext/content/ regex [^*](\*([^\s*]|([^\s*][^*]*[^\s*]))\*)[^*] 1:+i
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/restructuredtext/content/ regex [^`](``([^\s`]|([^\s`][^`]*[^\s`]))``)[^`] 1:mono
|
2017-11-23 02:52:23 +01:00
|
|
|
|
2022-08-13 23:00:03 +02:00
|
|
|
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}
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2019-03-13 06:24:33 +01:00
|
|
|
}
|