From c9eb65b04c140daa0688b0d80947c41391a083e6 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 3 Dec 2013 22:15:59 +0000 Subject: [PATCH] Change rc files to use shared highlighters --- src/rc/asciidoc.kak | 21 ++++++++++----------- src/rc/cpp.kak | 20 +++++++++++--------- src/rc/kakrc.kak | 23 ++++++++++------------- src/rc/mail.kak | 15 ++++++--------- src/rc/make.kak | 8 +++++--- src/rc/sh.kak | 23 ++++++++++------------- 6 files changed, 52 insertions(+), 58 deletions(-) diff --git a/src/rc/asciidoc.kak b/src/rc/asciidoc.kak index cfec02b1..4a9becfc 100644 --- a/src/rc/asciidoc.kak +++ b/src/rc/asciidoc.kak @@ -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 (?(class|struct)\`(class|struct)[^{}\n]+(\n)?\s*\{\'ma;" ] ] +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*?#.*?(?|\<-?\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*?#.*?(?s\h+$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 } diff --git a/src/rc/kakrc.kak b/src/rc/kakrc.kak index fe8ffb96..9d1026b1 100644 --- a/src/rc/kakrc.kak +++ b/src/rc/kakrc.kak @@ -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 (?<=\ 0:keyword +addhl -def-group kakrc regex \<(default|black|red|green|yellow|blue|magenta|cyan|white)\> 0:value +addhl -def-group kakrc 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 } diff --git a/src/rc/make.kak b/src/rc/make.kak index f7df1439..cd2fd220 100644 --- a/src/rc/make.kak +++ b/src/rc/make.kak @@ -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 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+))?:(.*?)$'; edit %reg{1} %reg{2} %reg{3}; echo %reg{4} } diff --git a/src/rc/sh.kak b/src/rc/sh.kak index f2240f9b..af3eb26d 100644 --- a/src/rc/sh.kak +++ b/src/rc/sh.kak @@ -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 }