diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-10-12 16:50:08 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-11-08 13:35:36 +0100 |
| commit | b1ec60061623601ca6185a16d77c6c6c62135e95 (patch) | |
| tree | b8ffce3d3141a297d9c3572bdd6165d002863b28 /config.def.h | |
| parent | 2d4408f975ea44ffabd7c3a6d43e4d9b5725c052 (diff) | |
| download | vis-b1ec60061623601ca6185a16d77c6c6c62135e95.tar.gz vis-b1ec60061623601ca6185a16d77c6c6c62135e95.tar.xz | |
vis: remove regex based syntax highlighting
Diffstat (limited to 'config.def.h')
| -rw-r--r-- | config.def.h | 622 |
1 files changed, 0 insertions, 622 deletions
diff --git a/config.def.h b/config.def.h index f47034b..7cd2e10 100644 --- a/config.def.h +++ b/config.def.h @@ -299,625 +299,3 @@ static KeyBinding vis_mode_replace[] = { { /* empty last element, array terminator */ }, }; -/* Color definitions for use in the sytax highlighting rules below. A fore - * or background color of -1 specifies the default terminal color. */ -enum { - COLOR_NOHILIT, - COLOR_SYNTAX0, - COLOR_SYNTAX1, - COLOR_SYNTAX2, - COLOR_SYNTAX3, - COLOR_SYNTAX4, - COLOR_SYNTAX5, - COLOR_SYNTAX6, - COLOR_SYNTAX7, - COLOR_SYNTAX8, - COLOR_SYNTAX9, - COLOR_SYNTAX_LAST, /* below are only aliases */ - COLOR_KEYWORD = COLOR_SYNTAX1, - COLOR_CONSTANT = COLOR_SYNTAX4, - COLOR_DATATYPE = COLOR_SYNTAX2, - COLOR_OPERATOR = COLOR_SYNTAX2, - COLOR_CONTROL = COLOR_SYNTAX3, - COLOR_PREPROCESSOR = COLOR_SYNTAX4, - COLOR_PRAGMA = COLOR_SYNTAX4, - COLOR_KEYWORD2 = COLOR_SYNTAX4, - COLOR_BRACKETS = COLOR_SYNTAX5, - COLOR_STRING = COLOR_SYNTAX6, - COLOR_LITERAL = COLOR_SYNTAX6, - COLOR_VARIABLE = COLOR_SYNTAX6, - COLOR_TARGET = COLOR_SYNTAX5, - COLOR_COMMENT = COLOR_SYNTAX7, - COLOR_IDENTIFIER = COLOR_SYNTAX8, - COLOR_TYPE = COLOR_SYNTAX9, - COLOR_WHITESPACE = COLOR_COMMENT, - COLOR_SPACES = COLOR_WHITESPACE, - COLOR_TABS = COLOR_WHITESPACE, - COLOR_EOL = COLOR_WHITESPACE, - COLOR_EOF = COLOR_WHITESPACE, -}; - -static const char *styles[] = { - [COLOR_NOHILIT] = "", - [COLOR_SYNTAX0] = "fore:red,bold", - [COLOR_SYNTAX1] = "fore:green,bold", - [COLOR_SYNTAX2] = "fore:green", - [COLOR_SYNTAX3] = "fore:magenta,bold", - [COLOR_SYNTAX4] = "fore:magenta", - [COLOR_SYNTAX5] = "fore:blue,bold", - [COLOR_SYNTAX6] = "fore:red", - [COLOR_SYNTAX7] = "fore:blue", - [COLOR_SYNTAX8] = "fore:cyan", - [COLOR_SYNTAX9] = "fore:yellow", - [COLOR_SYNTAX_LAST] = NULL, -}; - -/* Syntax color definitions per file type. Each rule consists of a regular - * expression, a color to apply in case of a match and boolean flag inidcating - * whether it is a multiline rule. - * - * The syntax rules where initially imported from the sandy editor, written by - * Rafael Garcia <rafael.garcia.gallego@gmail.com> - */ -#define B "\\b" -/* Use this if \b is not in your libc's regex implementation */ -// #define B "^| |\t|\\(|\\)|\\[|\\]|\\{|\\}|\\||$" - -/* common rules, used by multiple languages */ - -#define SYNTAX_MULTILINE_COMMENT { \ - "(/\\*([^*]|\\*+[^*/])*\\*+/|/\\*([^*]|\\*+[^*/])*$|^([^/]|/+[^/*])*\\*/)", \ - COLOR_COMMENT, \ - true, /* multiline */ \ -} - -#define SYNTAX_SINGLE_LINE_COMMENT { \ - "(//.*)", \ - COLOR_COMMENT, \ -} - -#define SYNTAX_LITERAL { \ - "('(\\\\.|.)')|"B"(0x[0-9A-Fa-f]+|[0-9]+)"B, \ - COLOR_LITERAL, \ -} - -#define SYNTAX_STRING { \ - "(\"(\\\\.|[^\"])*\")", \ - COLOR_STRING, \ - false, /* multiline */ \ -} - -#define SYNTAX_CONSTANT { \ - B"[A-Z_][0-9A-Z_]+"B, \ - COLOR_CONSTANT, \ -} - -#define SYNTAX_BRACKET { \ - "(\\(|\\)|\\{|\\}|\\[|\\])", \ - COLOR_BRACKETS, \ -} - -#define SYNTAX_C_PREPROCESSOR { \ - "(^#[\\t ]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)?)", \ - COLOR_PREPROCESSOR, \ -} - -#define SYNTAX_SPACES { "\xC2\xB7", COLOR_SPACES } -#define SYNTAX_TABS { "\xE2\x96\xB6", COLOR_TABS } -#define SYNTAX_TABS_FILL { " ", COLOR_TABS } -#define SYNTAX_EOL { "\xE2\x8F\x8E", COLOR_EOL } -#define SYNTAX_EOF { "~", COLOR_EOF } - -/* these rules are applied top to bottom, first match wins. Therefore more 'greedy' - * rules such as for comments should be the first entries. - * - * The array of syntax definition must be terminated with an empty element. - */ -static Syntax syntaxes[] = {{ - .name = "c", - .file = "\\.(c(pp|xx)?|h(pp|xx)?|cc)$", - .settings = (const char*[]){ - "set number", - "set autoindent", - "set show spaces=0 tabs=1 newlines=1", - NULL - }, - .styles = styles, - .symbols = { - SYNTAX_SPACES, - SYNTAX_TABS, - SYNTAX_TABS_FILL, - SYNTAX_EOL, - SYNTAX_EOF, - }, - .rules = { - SYNTAX_MULTILINE_COMMENT, - SYNTAX_SINGLE_LINE_COMMENT, - SYNTAX_LITERAL, - SYNTAX_STRING, - SYNTAX_CONSTANT, - SYNTAX_BRACKET, - { - "<[a-zA-Z0-9\\.\\-_/]+\\.(c(pp|xx)?|h(pp|xx)?|cc)>", - COLOR_STRING, - }, - SYNTAX_C_PREPROCESSOR, - { - B"(for|if|while|do|else|case|default|switch|try|throw|catch|operator|new|delete)"B, - COLOR_KEYWORD, - },{ - B"(float|double|bool|char|int|short|long|sizeof|enum|void|static|const|struct|union|" - "typedef|extern|(un)?signed|inline|((s?size)|((u_?)?int(8|16|32|64|ptr)))_t|class|" - "namespace|template|public|protected|private|typename|this|friend|virtual|using|" - "mutable|volatile|register|explicit)"B, - COLOR_DATATYPE, - },{ - B"(goto|continue|break|return)"B, - COLOR_CONTROL, - }} -},{ - .name = "sh", - .file = "\\.sh$", - .styles = styles, - .rules = {{ - "#.*$", - COLOR_COMMENT, - }, - SYNTAX_STRING, - { - "^[0-9A-Z_]+\\(\\)", - COLOR_CONSTANT, - },{ - "\\$[?!@#$?*-]", - COLOR_VARIABLE, - },{ - "\\$\\{[A-Za-z_][0-9A-Za-z_]+\\}", - COLOR_VARIABLE, - },{ - "\\$[A-Za-z_][0-9A-Za-z_]+", - COLOR_VARIABLE, - },{ - B"(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)"B, - COLOR_KEYWORD, - },{ - "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)", - COLOR_BRACKETS, - }} -},{ - .name = "makefile", - .file = "(Makefile[^/]*|\\.mk)$", - .styles = styles, - .rules = {{ - "#.*$", - COLOR_COMMENT, - },{ - "\\$+[{(][a-zA-Z0-9_-]+[})]", - COLOR_VARIABLE, - },{ - B"(if|ifeq|else|endif)"B, - COLOR_CONTROL, - },{ - "^[^ ]+:", - COLOR_TARGET, - },{ - "[:(+?=)]", - COLOR_BRACKETS, - }} -},{ - .name = "man", - .file = "\\.[1-9]x?$", - .styles = styles, - .rules = {{ - "\\.(BR?|I[PR]?).*$", - COLOR_SYNTAX0, - },{ - "\\.(S|T)H.*$", - COLOR_SYNTAX2, - },{ - "\\.(br|DS|RS|RE|PD)", - COLOR_SYNTAX3, - },{ - "(\\.(S|T)H|\\.TP)", - COLOR_SYNTAX4, - },{ - "\\.(BR?|I[PR]?|PP)", - COLOR_SYNTAX5, - },{ - "\\\\f[BIPR]", - COLOR_SYNTAX6, - }} -},{ - .name = "vala", - .file = "\\.(vapi|vala)$", - .styles = styles, - .rules = { - SYNTAX_MULTILINE_COMMENT, - SYNTAX_SINGLE_LINE_COMMENT, - SYNTAX_LITERAL, - SYNTAX_STRING, - SYNTAX_CONSTANT, - SYNTAX_BRACKET, - { - B"(for|if|while|do|else|case|default|switch|get|set|value|out|ref|enum)"B, - COLOR_KEYWORD, - },{ - B"(uint|uint8|uint16|uint32|uint64|bool|byte|ssize_t|size_t|char|double|string|float|int|long|short|this|base|transient|void|true|false|null|unowned|owned)"B, - COLOR_DATATYPE, - },{ - B"(try|catch|throw|finally|continue|break|return|new|sizeof|signal|delegate)"B, - COLOR_CONTROL, - },{ - B"(abstract|class|final|implements|import|instanceof|interface|using|private|public|static|strictfp|super|throws)"B, - COLOR_KEYWORD2, - }} -},{ - .name = "java", - .file = "\\.java$", - .styles = styles, - .rules = { - SYNTAX_MULTILINE_COMMENT, - SYNTAX_SINGLE_LINE_COMMENT, - SYNTAX_LITERAL, - SYNTAX_STRING, - SYNTAX_CONSTANT, - SYNTAX_BRACKET, - { - B"(for|if|while|do|else|case|default|switch)"B, - COLOR_KEYWORD, - },{ - B"(boolean|byte|char|double|float|int|long|short|transient|void|true|false|null)"B, - COLOR_DATATYPE, - },{ - B"(try|catch|throw|finally|continue|break|return|new)"B, - COLOR_CONTROL, - },{ - B"(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|this|super|synchronized|throws|volatile)"B, - COLOR_KEYWORD2, - }} -},{ - .name = "javascript", - .file = "\\.(js|json)$", - .styles = styles, - .rules = { - SYNTAX_SINGLE_LINE_COMMENT, - SYNTAX_LITERAL, - SYNTAX_STRING, - SYNTAX_BRACKET, - { - B"(true|false|null|undefined)"B, - COLOR_DATATYPE, - },{ - B"(NaN|Infinity)"B, - COLOR_LITERAL, - },{ - "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')", - COLOR_STRING, - },{ - B"(for|if|while|do|in|else|case|default|switch|try|throw|catch|operator|new|delete)"B, - COLOR_KEYWORD, - },{ - B"(continue|break|return)"B, - COLOR_CONTROL, - },{ - B"(case|class|const|debugger|default|enum|export|extends|finally|function|implements|import|instanceof|let|this|typeof|var|with|yield)"B, - COLOR_KEYWORD2, - }} -},{ - .name = "lua", - .file = "\\.lua$", - .settings = (const char*[]){ - "set number", - "set autoindent", - NULL - }, - .styles = styles, - .rules = {{ - "--\\[(=*)\\[([^]]*)\\](=*)\\]", - COLOR_COMMENT, - true, - },{ - "--.*$", - COLOR_COMMENT, - },{ - "(\\[(=*)\\[([^]]*)\\](=*)\\]|^([^][]*)\\](=*)\\])", - COLOR_STRING, - true, - }, - SYNTAX_STRING, - { - B"([0-9]*\\.)?[0-9]+([eE]([\\+-])?[0-9]+)?"B, - COLOR_LITERAL, - },{ - B"0x[0-9a-fA-F]+"B, - COLOR_LITERAL, - },{ - B"(false|nil|true)"B, - COLOR_CONSTANT, - },{ - "(\\.\\.\\.)", - COLOR_CONSTANT, - },{ - B"(break|do|else|elseif|end|for|function|if|in|local|repeat|return|then|until|while)"B, - COLOR_KEYWORD, - },{ - B"(and|not|or)"B, - COLOR_OPERATOR, - },{ - "(\\+|-|\\*|/|%|\\^|#|[=~<>]=|<|>|\\.\\.)", - COLOR_OPERATOR, - }, - SYNTAX_BRACKET, - } -},{ - .name = "ruby", - .file = "\\.rb$", - .styles = styles, - .rules = {{ - "(#[^{].*$|#$)", - COLOR_COMMENT, - },{ - "(\\$|@|@@)?"B"[A-Z]+[0-9A-Z_a-z]*", - COLOR_VARIABLE, - },{ - B"(__FILE__|__LINE__|BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)"B, - COLOR_KEYWORD, - },{ - "([ ]|^):[0-9A-Z_]+"B, - COLOR_SYNTAX2, - },{ - "(/([^/]|(\\/))*/[iomx]*|%r\\{([^}]|(\\}))*\\}[iomx]*)", - COLOR_SYNTAX3, - },{ - "(`[^`]*`|%x\\{[^}]*\\})", - COLOR_SYNTAX4, - },{ - "(\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!|\'([^\']|(\\\\\'))*\'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!)", - COLOR_SYNTAX5, - },{ - "#\\{[^}]*\\}", - COLOR_SYNTAX6, - }} -},{ - .name = "python", - .file = "\\.py$", - .styles = styles, - .rules = {{ - "(#.*$|#$)", - COLOR_COMMENT, - },{ - "(\"\"\".*\"\"\")", - COLOR_COMMENT, - true, /* multiline */ - },{ - B"(and|class|def|not|or|return|yield|is)"B, - COLOR_KEYWORD2, - },{ - B"(from|import|as)"B, - COLOR_KEYWORD, - },{ - B"(if|elif|else|while|for|in|try|with|except|in|break|continue|finally)"B, - COLOR_CONTROL, - },{ - B"(int|str|float|unicode|int|bool|chr|type|list|dict|tuple)", - COLOR_DATATYPE, - },{ - "(True|False|None)", - COLOR_LITERAL, - },{ - B"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B, - COLOR_LITERAL, - },{ - B"[0-9]+"B"|"B"0[xX][0-9a-fA-F]+"B"|"B"0[oO][0-7]+"B, - COLOR_LITERAL, - },{ - "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')", - COLOR_STRING, - false, /* multiline */ - },{ - "(__init__|__str__|__unicode__|__gt__|__lt__|__eq__|__enter__|__exit__|__next__|__getattr__|__getitem__|__setitem__|__call__|__contains__|__iter__|__bool__|__all__|__name__)", - COLOR_SYNTAX2, - }} -},{ - .name = "php", - .file = "\\.php$", - .styles = styles, - .rules = { - SYNTAX_MULTILINE_COMMENT, - SYNTAX_SINGLE_LINE_COMMENT, - SYNTAX_BRACKET, - { - "(#.*$|#$)", - COLOR_COMMENT, - },{ - "(\"\"\".*\"\"\")", - COLOR_COMMENT, - true, /* multiline */ - },{ - B"(class|interface|extends|implements|new|__construct|__destruct|use|namespace|return)"B, - COLOR_KEYWORD2, - },{ - B"(public|private|protected|const|parent|function|->)"B, - COLOR_KEYWORD, - },{ - B"(if|else|while|do|for|foreach|in|try|catch|finally|switch|case|default|break|continue|as|=>)"B, - COLOR_CONTROL, - },{ - B"(array|true|false|null)", - COLOR_DATATYPE, - },{ - B"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B, - COLOR_LITERAL, - },{ - B"[0-9]+"B"|"B"0[xX][0-9a-fA-F]+"B"|"B"0[oO][0-7]+"B, - COLOR_LITERAL, - },{ - "\\$[a-zA-Z0-9_\\-]+", - COLOR_VARIABLE, - },{ - "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')", - COLOR_STRING, - false, /* multiline */ - },{ - "(php|echo|print|var_dump|print_r)", - COLOR_SYNTAX2, - }} -},{ - .name = "haskell", - .file = "\\.hs$", - .styles = styles, - .rules = {{ - "\\{-#.*#-\\}", - COLOR_PRAGMA, - },{ - "---*([^-!#$%&\\*\\+./<=>\?@\\^|~].*)?$", - COLOR_COMMENT, - }, { - // These are allowed to be nested, but we can't express that - // with regular expressions - "\\{-.*-\\}", - COLOR_COMMENT, - true - }, - SYNTAX_STRING, - SYNTAX_C_PREPROCESSOR, - { - // as and hiding are only keywords when part of an import, but - // I don't want to highlight the whole import line. - // capture group coloring or similar would be nice - "(^import( qualified)?)|"B"(as|hiding|infix[lr]?)"B, - COLOR_KEYWORD2, - },{ - B"(module|class|data|deriving|instance|default|where|type|newtype)"B, - COLOR_KEYWORD, - },{ - B"(do|case|of|let|in|if|then|else)"B, - COLOR_CONTROL, - },{ - "('(\\\\.|.)')", - COLOR_LITERAL, - },{ - B"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B, - COLOR_LITERAL, - },{ - B"[0-9]+"B"|"B"0[xX][0-9a-fA-F]+"B"|"B"0[oO][0-7]+"B, - COLOR_LITERAL, - },{ - "("B"[A-Z][a-zA-Z0-9_']*\\.)*"B"[a-zA-Z][a-zA-Z0-9_']*"B, - COLOR_NOHILIT, - },{ - "("B"[A-Z][a-zA-Z0-9_']*\\.)?[-!#$%&\\*\\+/<=>\\?@\\\\^|~:.][-!#$%&\\*\\+/<=>\\?@\\\\^|~:.]*", - COLOR_OPERATOR, - },{ - "`("B"[A-Z][a-zA-Z0-9_']*\\.)?[a-z][a-zA-Z0-9_']*`", - COLOR_OPERATOR, - },{ - "\\(|\\)|\\[|\\]|,|;|_|\\{|\\}", - COLOR_BRACKETS, - }} -},{ - .name = "markdown", - .file = "\\.(md|mdwn)$", - .styles = styles, - .rules = {{ - "(^#{1,6}.*$)", //titles - COLOR_SYNTAX5, - },{ - "((\\* *){3,}|(_ *){3,}|(- *){3,})", // horizontal rules - COLOR_SYNTAX2, - },{ - "(\\*\\*.*\\*\\*)|(__.*__)", // super-bolds - COLOR_SYNTAX4, - },{ - "(\\*.*\\*)|(_.*_)", // bolds - COLOR_SYNTAX3, - },{ - "(\\[.*\\]\\(.*\\))", //links - COLOR_SYNTAX6, - },{ - "(^ *([-\\*\\+]|[0-9]+\\.))", //lists - COLOR_SYNTAX2, - },{ - "(^( {4,}|\t+).*$)", // code blocks - COLOR_SYNTAX7, - },{ - "(`+.*`+)", // inline code - COLOR_SYNTAX7, - },{ - "(^>+.*)", // quotes - COLOR_SYNTAX7, - }} -},{ - .name = "ledger", - .file = "\\.(journal|ledger)$", - .styles = styles, - .rules = { - { /* comment */ - "^[;#].*", - COLOR_COMMENT, - },{ /* value tag */ - "( |\t|^ )*; :([^ ][^:]*:)+[ \\t]*$", - COLOR_DATATYPE, - },{ /* typed tag */ - "( |\t|^ )*; [^:]+::.*", - COLOR_DATATYPE, - },{ /* tag */ - "( |\t|^ )*; [^:]+:.*", - COLOR_TYPE, - },{ /* metadata */ - "( |\t|^ )*;.*", - COLOR_CONSTANT, - },{ /* date */ - "^[0-9][^ \t]+", - COLOR_LITERAL, - },{ /* account */ - "^[ \t]+[a-zA-Z:'!*()%&]+", - COLOR_IDENTIFIER, - },{ /* amount */ - "( |\t)[^;]*", - COLOR_LITERAL, - },{ /* automated transaction */ - "^[=~].*", - COLOR_TYPE, - },{ /* directives */ - "^[!@]?(account|alias|assert|bucket|capture|check|comment|commodity|define|end|fixed|endfixed|include|payee|apply|tag|test|year|[AYNDCIiOobh])"B".*", - COLOR_DATATYPE, - }} -},{ - .name = "apl", - .file = "\\.apl$", - .settings = (const char*[]){ - "set number", - NULL - }, - .styles = styles, - .rules = {{ - "(⍝|#).*$", - COLOR_COMMENT, - },{ - "('([^']|'')*')|(\"([^\"]|\"\")*\")", - COLOR_STRING, - },{ - "^ *(∇|⍫)", - COLOR_SYNTAX9, - },{ - "(⎕[a-zA-Z]*)|[⍞χ⍺⍶⍵⍹]", - COLOR_KEYWORD, - },{ - "[∆⍙_a-zA-Z][∆⍙_¯a-zA-Z0-9]* *:", - COLOR_SYNTAX2, - },{ - "[∆⍙_a-zA-Z][∆⍙_¯a-zA-Z0-9]*", - COLOR_IDENTIFIER, - },{ - "¯?(([0-9]+(\\.[0-9]+)?)|\\.[0-9]+)([eE]¯?[0-9]+)?([jJ]¯?(([0-9]+(\\.[0-9]+)?)|\\.[0-9]+)([eE]¯?[0-9]+)?)?", - COLOR_CONSTANT, - },{ - "[][(){}]", - COLOR_BRACKETS, - },{ - "[←→◊]", - COLOR_SYNTAX3, - }} -},{ - /* empty last element, array terminator */ -}}; |
