rc kakrc: add kak=kakrc highlighter alias for markdown/restructuredtext
Filetypes markdown and restructuredtext reuse highlighters from other filetypes to highlight code blocks. For example, to highlight a code block of language foo they essentially do require-module foo add-highlighter [...] ref foo This works great if the module name matches the shared highlighter. This is the case almost all scripts in rc/filetype*. The only exception is kakrc.kak: the highlighter is named "kakrc" (just like the filetype) but the module is named "kak". This requires weird hacks in markdown/restructuredtext. Ideally we could remove this inconsistency by renaming both the filetype and the highlighter to "kak" but that's a breaking change. Until we do that, let's add an alias so we can treat filetypes uniformly. This helps the following commits, which otherwise would need to add ugly extra code for kakrc highlighters. The following commit will generalize this approach, allowing users to add arbitrary aliases.
This commit is contained in:
parent
1a8f379a43
commit
647e568d3b
|
@ -90,6 +90,8 @@ add-highlighter shared/kakrc/double_string/escape regex '""' 0:default+b
|
||||||
add-highlighter shared/kakrc/single_string/fill fill string
|
add-highlighter shared/kakrc/single_string/fill fill string
|
||||||
add-highlighter shared/kakrc/single_string/escape regex "''" 0:default+b
|
add-highlighter shared/kakrc/single_string/escape regex "''" 0:default+b
|
||||||
|
|
||||||
|
add-highlighter shared/kak ref kakrc
|
||||||
|
|
||||||
# Commands
|
# Commands
|
||||||
# ‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,12 @@ evaluate-commands %sh{
|
||||||
ruby rust sass scala scss sh swift toml tupfile typescript yaml sql
|
ruby rust sass scala scss sh swift toml tupfile typescript yaml sql
|
||||||
"
|
"
|
||||||
for lang in ${languages}; do
|
for lang in ${languages}; do
|
||||||
[ "${lang}" = kak ] && ref=kakrc || ref="${lang}"
|
|
||||||
printf 'add-highlighter shared/markdown/%s region -match-capture ^(\h*)```\h*(%s\\b|\\{[.=]?%s\\}) ^(\h*)``` regions\n' "${lang}" "${lang}" "${lang}"
|
printf 'add-highlighter shared/markdown/%s region -match-capture ^(\h*)```\h*(%s\\b|\\{[.=]?%s\\}) ^(\h*)``` regions\n' "${lang}" "${lang}" "${lang}"
|
||||||
printf 'add-highlighter shared/markdown/%s/ default-region fill meta\n' "${lang}"
|
printf 'add-highlighter shared/markdown/%s/ default-region fill meta\n' "${lang}"
|
||||||
printf 'add-highlighter shared/markdown/%s/inner region \A\h*```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${ref}"
|
printf 'add-highlighter shared/markdown/%s/inner region \A\h*```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${lang}"
|
||||||
printf 'add-highlighter shared/markdown/listblock/%s region -match-capture ^(\h*)```\h*(%s\\b|\\{[.=]?%s\\}) ^(\h*)``` regions\n' "${lang}" "${lang}" "${lang}"
|
printf 'add-highlighter shared/markdown/listblock/%s region -match-capture ^(\h*)```\h*(%s\\b|\\{[.=]?%s\\}) ^(\h*)``` regions\n' "${lang}" "${lang}" "${lang}"
|
||||||
printf 'add-highlighter shared/markdown/listblock/%s/ default-region fill meta\n' "${lang}"
|
printf 'add-highlighter shared/markdown/listblock/%s/ default-region fill meta\n' "${lang}"
|
||||||
printf 'add-highlighter shared/markdown/listblock/%s/inner region \A\h*```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${ref}"
|
printf 'add-highlighter shared/markdown/listblock/%s/inner region \A\h*```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${lang}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,7 @@ evaluate-commands %sh{
|
||||||
julia kak kickstart latex lisp lua makefile moon objc \
|
julia kak kickstart latex lisp lua makefile moon objc \
|
||||||
perl pug python ragel ruby rust sass scala scss sh swift \
|
perl pug python ragel ruby rust sass scala scss sh swift \
|
||||||
tupfile yaml; do
|
tupfile yaml; do
|
||||||
if [ "$ft" = kak ]; then ref="kakrc"; else ref="$ft"; fi
|
printf 'add-highlighter shared/restructuredtext/%s region %s %s ref %s\n' "$ft" "\.\.\h*code-block::\h*$ft\h*\n" '^(?=\S)' "$ft"
|
||||||
printf 'add-highlighter shared/restructuredtext/%s region %s %s ref %s\n' "$ft" "\.\.\h*code-block::\h*$ft\h*\n" '^(?=\S)' "$ref"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user