Change rc files to use shared highlighters

This commit is contained in:
Maxime Coste 2013-12-03 22:15:59 +00:00
parent 45d5dbcc85
commit c9eb65b04c
6 changed files with 52 additions and 58 deletions

View File

@ -1,15 +1,14 @@
hook global BufCreate .*\.asciidoc %{ set buffer filetype asciidoc }
hook global WinSetOption filetype=asciidoc %{
addhl group asciidoc-highlight
addhl -group asciidoc-highlight regex (\A|\n\n)[^\n]+\n={2,}\h*\n\h*$ 0:blue
addhl -group asciidoc-highlight regex (\A|\n\n)[^\n]+\n-{2,}\h*\n\h*$ 0:cyan
addhl -group asciidoc-highlight regex ^\h+([-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*)*$ 0:yellow 1:cyan
addhl -group asciidoc-highlight regex ^([-=~]+)\n[^\n\h].*?\n\1$ 0:magenta
addhl -group asciidoc-highlight regex (?<!\w)\+[^\n]+?\+(?!\w) 0:green
addhl -group asciidoc-highlight regex (?<!\w)_[^\n]+?_(?!\w) 0:yellow
addhl -group asciidoc-highlight regex (?<!\w)\*[^\n]+?\*(?!\w) 0:red
}
defhl asciidoc
addhl -def-group asciidoc regex (\A|\n\n)[^\n]+\n={2,}\h*\n\h*$ 0:blue
addhl -def-group asciidoc regex (\A|\n\n)[^\n]+\n-{2,}\h*\n\h*$ 0:cyan
addhl -def-group asciidoc regex ^\h+([-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*)*$ 0:yellow 1:cyan
addhl -def-group asciidoc regex ^([-=~]+)\n[^\n\h].*?\n\1$ 0:magenta
addhl -def-group asciidoc regex (?<!\w)\+[^\n]+?\+(?!\w) 0:green
addhl -def-group asciidoc regex (?<!\w)_[^\n]+?_(?!\w) 0:yellow
addhl -def-group asciidoc regex (?<!\w)\*[^\n]+?\*(?!\w) 0:red
hook global WinSetOption filetype=(?!asciidoc).* %{ rmhl asciidoc-higlight }
hook global WinSetOption filetype=asciidoc %{ addhl ref asciidoc }
hook global WinSetOption filetype=(?!asciidoc).* %{ rmhl asciidoc }

View File

@ -37,15 +37,17 @@ def -hidden _cpp_indent_on_closing_curly_brace %[
try %[ exec -draft "hm<space><a-?>(class|struct)<ret><a-k>\`(class|struct)[^{}\n]+(\n)?\s*\{\'<ret><a-space>ma;<esc>" ]
]
defhl cpp
addhl -def-group cpp regex "\<(this|true|false|NULL|nullptr|)\>|\<-?\d+[fdiu]?|'((\\.)?|[^'\\])'" 0:value
addhl -def-group cpp regex "\<(void|int|char|unsigned|float|bool|size_t)\>" 0:type
addhl -def-group cpp regex "\<(while|for|if|else|do|switch|case|default|goto|break|continue|return|using|try|catch|throw|new|delete|and|or|not|operator|explicit)\>" 0:keyword
addhl -def-group cpp regex "\<(const|mutable|auto|namespace|inline|static|volatile|class|struct|enum|union|public|protected|private|template|typedef|virtual|friend|extern|typename|override|final)\>" 0:attribute
addhl -def-group cpp regex "^\h*?#.*?(?<!\\)$" 0:macro
addhl -def-group cpp regex "(?<!')\".*?(?<!\\)(\\\\)*\"" 0:string
addhl -def-group cpp regex "(//[^\n]*\n)|(/\*.*?(\*/|\'))" 0:comment
hook global WinSetOption filetype=cpp %[
addhl group cpp-highlight
addhl -group cpp-highlight regex "\<(this|true|false|NULL|nullptr|)\>|\<-?\d+[fdiu]?|'((\\.)?|[^'\\])'" 0:value
addhl -group cpp-highlight regex "\<(void|int|char|unsigned|float|bool|size_t)\>" 0:type
addhl -group cpp-highlight regex "\<(while|for|if|else|do|switch|case|default|goto|break|continue|return|using|try|catch|throw|new|delete|and|or|not|operator|explicit)\>" 0:keyword
addhl -group cpp-highlight regex "\<(const|mutable|auto|namespace|inline|static|volatile|class|struct|enum|union|public|protected|private|template|typedef|virtual|friend|extern|typename|override|final)\>" 0:attribute
addhl -group cpp-highlight regex "^\h*?#.*?(?<!\\)$" 0:macro
addhl -group cpp-highlight regex "(?<!')\".*?(?<!\\)(\\\\)*\"" 0:string
addhl -group cpp-highlight regex "(//[^\n]*\n)|(/\*.*?(\*/|\'))" 0:comment
addhl ref cpp
# cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -id cpp-hooks %{ try %{ exec -draft <a-x>s\h+$<ret>d } }
@ -56,7 +58,7 @@ hook global WinSetOption filetype=cpp %[
]
hook global WinSetOption filetype=(?!cpp).* %{
rmhl cpp-highlight
rmhl cpp
rmhooks window cpp-indent
rmhooks window cpp-hooks
}

View File

@ -2,17 +2,14 @@ hook global BufCreate (.*/)?(kakrc|.*.kak) %{
set buffer filetype kak
}
hook global WinSetOption filetype=kak %{
addhl group kak-highlight
addhl -group kak-highlight regex \<(hook|rmhooks|addhl|rmhl|add|exec|eval|source|runtime|def|decl|echo|edit|set)\> 0:keyword
addhl -group kak-highlight regex \<(default|black|red|green|yellow|blue|magenta|cyan|white)\> 0:value
addhl -group kak-highlight regex (?<=\<hook)\h+((global|buffer|window)|(\S+))\h+(\S+)\h+(\H+) 2:attribute 3:error 4:identifier 5:string
addhl -group kak-highlight regex (?<=\<set)\h+((global|buffer|window)|(\S+))\h+(\S+)\h+(\S+) 2:attribute 3:error 4:identifier 5:value
addhl -group kak-highlight regex (?<=\<regex)\h+(\S+) 1:string
addhl -group kak-highlight regex (?<!\\)(["'])(?:\\\1|.)*?\1 0:string
addhl -group kak-highlight regex (^|\h)\#[^\n]*\n 0:comment
}
defhl kakrc
addhl -def-group kakrc regex \<(hook|rmhooks|defhl|addhl|rmhl|add|exec|eval|source|runtime|def|decl|echo|edit|set)\> 0:keyword
addhl -def-group kakrc regex \<(default|black|red|green|yellow|blue|magenta|cyan|white)\> 0:value
addhl -def-group kakrc regex (?<=\<hook)\h+((global|buffer|window)|(\S+))\h+(\S+)\h+(\H+) 2:attribute 3:error 4:identifier 5:string
addhl -def-group kakrc regex (?<=\<set)\h+((global|buffer|window)|(\S+))\h+(\S+)\h+(\S+) 2:attribute 3:error 4:identifier 5:value
addhl -def-group kakrc regex (?<=\<regex)\h+(\S+) 1:string
addhl -def-group kakrc regex (?<!\\)(["'])(?:\\\1|.)*?\1 0:string
addhl -def-group kakrc regex (^|\h)\#[^\n]*\n 0:comment
hook global WinSetOption filetype=(?!kak).* %{
rmhl kak-highlight
}
hook global WinSetOption filetype=kak %{ addhl ref kakrc }
hook global WinSetOption filetype=(?!kak).* %{ rmhl kakrc }

View File

@ -1,12 +1,9 @@
hook global BufSetOption mimetype=message/rfc822 %{ set buffer filetype mail }
hook global WinSetOption filetype=mail %~
addhl group mail-highlight
addhl -group mail-highlight regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute
addhl -group mail-highlight regex <[^@>]+@.*?> 0:string
addhl -group mail-highlight regex ^>.*?$ 0:comment
~
defhl mail
addhl -def-group mail regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute
addhl -def-group mail regex <[^@>]+@.*?> 0:string
addhl -def-group mail regex ^>.*?$ 0:comment
hook global WinSetOption filetype=(?!mail).* %{
rmhl mail-highlight
}
hook global WinSetOption filetype=mail %{ addhl ref mail }
hook global WinSetOption filetype=(?!mail).* %{ rmhl mail }

View File

@ -15,12 +15,14 @@ def -shell-params make %{ %sh{
[[ -n "$kak_opt_toolsclient" ]] && echo "}"
}}
defhl make
addhl -def-group make regex "^([^:\n]+):(\d+):(\d+):\h+(?:((?:fatal )?error)|(warning)|(note)|(required from(?: here)?))?.*?$" 1:cyan 2:green 3:green 4:red 5:yellow 6:blue 7:yellow
hook global WinSetOption filetype=make %{
addhl group make-highlight
addhl -group make-highlight regex "^([^:\n]+):(\d+):(\d+):\h+(?:((?:fatal )?error)|(warning)|(note)|(required from(?: here)?))?.*?$" 1:cyan 2:green 3:green 4:red 5:yellow 6:blue 7:yellow
addhl ref make
hook buffer -id make-hooks NormalKey <c-m> errjump
}
hook global WinSetOption filetype=(?!make).* %{ rmhl make-highlight; rmhooks buffer make-hooks }
hook global WinSetOption filetype=(?!make).* %{ rmhl make; rmhooks buffer make-hooks }
def errjump %{ exec 'xs^([^:\n]+):(\d+)(?::(\d+))?:(.*?)$<ret><a-h><space>'; edit %reg{1} %reg{2} %reg{3}; echo %reg{4} }

View File

@ -6,17 +6,14 @@ hook global BufSetOption mimetype=text/x-shellscript %{
set buffer filetype sh
}
hook global WinSetOption filetype=sh %~
addhl group sh-highlight
addhl -group sh-highlight regex \<(if|then|fi|while|for|do|done|case|esac|echo|cd|shift|return|exit|local)\> 0:keyword
addhl -group sh-highlight regex [\[\]\(\)&|]{2} 0:operator
addhl -group sh-highlight regex (\w+)= 1:identifier
addhl -group sh-highlight regex ^\h*(\w+)\h*\(\) 1:identifier
addhl -group sh-highlight regex "(^|\h)#.*?$" 0:comment
addhl -group sh-highlight regex (["'])(?:\\\1|.)*?\1 0:string
addhl -group sh-highlight regex \$(\w+|\{.+?\}) 0:identifier
~
defhl sh
addhl -def-group sh regex \<(if|then|fi|while|for|do|done|case|esac|echo|cd|shift|return|exit|local)\> 0:keyword
addhl -def-group sh regex [\[\]\(\)&|]{2} 0:operator
addhl -def-group sh regex (\w+)= 1:identifier
addhl -def-group sh regex ^\h*(\w+)\h*\(\) 1:identifier
addhl -def-group sh regex "(^|\h)#.*?$" 0:comment
addhl -def-group sh regex (["'])(?:\\\1|.)*?\1 0:string
addhl -def-group sh regex \$(\w+|\{.+?\}) 0:identifier
hook global WinSetOption filetype=(?!sh).* %{
rmhl sh-highlight
}
hook global WinSetOption filetype=sh %{ addhl ref sh }
hook global WinSetOption filetype=(?!sh).* %{ rmhl sh }