tconf.h: syntax highlighting for mails - neatvi - [fork] simple vi-type editor with UTF-8 support
(HTM) git clone git://src.adamsgaard.dk/neatvi
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit e7a96b18114c4757ad98d73c59292c3eb8bc6785
(DIR) parent f8c38eeb1bb1287f403745c15f9aa99f200ddf4f
(HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Wed, 21 Oct 2015 23:17:25 +0330
conf.h: syntax highlighting for mails
Diffstat:
M conf.h | 107 ++++++++++++++++++-------------
1 file changed, 64 insertions(+), 43 deletions(-)
---
(DIR) diff --git a/conf.h b/conf.h
t@@ -1,8 +1,72 @@
/* neatvi configuration file */
+/* map file names to file types */
+static struct filetype {
+ char *ft; /* file type */
+ char *pat; /* file name pattern */
+} filetypes[] = {
+ {"c", "\\.[hc]$"},
+ {"roff", "\\.(ms|tr|roff|tmac|txt)$"},
+ {"tex", "\\.tex$"},
+ {"msg", "letter|mbox|mail"},
+ {"mk", "Makefile|makefile|\\.mk$"},
+ {"sh", "\\.sh$"},
+};
+
+/* syntax highlighting patterns */
+static struct highlight {
+ char *ft; /* the filetype of this pattern */
+ int att[16]; /* attributes of the matched groups */
+ char *pat; /* regular expression */
+ int end; /* the group ending this pattern */
+} highlights[] = {
+ {"c", {5}, "\\<(signed|unsigned|char|short|int|long|float|double|void|struct|enum|union|typedef)\\>"},
+ {"c", {5}, "\\<(static|extern|register)\\>"},
+ {"c", {4}, "\\<(return|for|while|if|else|do|sizeof|goto|switch|case|default|break|continue)\\>"},
+ {"c", {2 | SYN_IT}, "//.*$"},
+ {"c", {2 | SYN_IT}, "/\\*([^*]|\\*[^/])*\\*/"},
+ {"c", {6}, "^#[ \t]*[a-zA-Z0-9_]+"},
+ {"c", {0, SYN_BD}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
+ {"c", {4}, "\"([^\"]|\\\\\")*\""},
+ {"c", {4}, "'([^\\]|\\\\.)'"},
+ {"c", {4}, "[-+]?\\<(0[xX][0-9a-fA-F]+|[0-9]+)\\>"},
+
+ {"roff", {4, 0, 5 | SYN_BD, 4 | SYN_BD, 5 | SYN_BD, 4 | SYN_BD},
+ "^[.'][ \t]*((SH.*)|(de) (.*)|([^ \t\\]{2,}))?.*$", 1},
+ {"roff", {2 | SYN_IT}, "\\\\\".*$"},
+ {"roff", {3}, "\\\\{1,2}[*$fgkmns]([^[(]|\\(..|\\[[^]]*\\])"},
+ {"roff", {3}, "\\\\([^[(*$fgkmns]|\\(..|\\[[^]]*\\])"},
+ {"roff", {3}, "\\$[^$]+\\$"},
+
+ {"tex", {4 | SYN_BD, 0, 3, 0, 5},
+ "\\\\[^[{ \t]+(\\[([^]]+)\\])?(\\{([^}]*)\\})?"},
+ {"tex", {3}, "\\$[^$]+\\$"},
+ {"tex", {2 | SYN_IT}, "%.*$"},
+
+ {"msg", {6 | SYN_BD}, "^From .*20..$"},
+ {"msg", {6 | SYN_BD, 4 | SYN_BD}, "^Subject: (.*)$"},
+ {"msg", {6 | SYN_BD, 2 | SYN_BD}, "^From: (.*)$"},
+ {"msg", {6 | SYN_BD, 5 | SYN_BD}, "^To: (.*)$"},
+ {"msg", {6 | SYN_BD, 5 | SYN_BD}, "^Cc: (.*)$"},
+ {"msg", {6 | SYN_BD}, "^[A-Z][-A-Za-z]+: .+$"},
+ {"msg", {2 | SYN_IT}, "^> .*$"},
+
+ {"mk", {0, 3}, "([A-Za-z_][A-Za-z0-9_]*)[ \t]*="},
+ {"mk", {3}, "\\$\\([a-zA-Z0-9_]+\\)"},
+ {"mk", {2 | SYN_IT}, "#.*$"},
+ {"mk", {0, SYN_BD}, "([A-Za-z_%.]+):"},
+
+ {"sh", {2 | SYN_IT}, "#.*$"},
+ {"sh", {4}, "\"([^\"]|\\\\\")*\""},
+ {"sh", {4}, "\'[^\']*\'"},
+};
+
/* the alternate keymap (^F and ^E in insert mode to switch) */
#define KMAPALT "fa"
+/* how to hightlight text in the reverse direction */
+#define SYN_REVDIR (SYN_BGMK(255))
+
/* right-to-left characters (used only in dircontexts[] and dirmarks[]) */
#define CR2L "ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىييپچژکگی؛،»«؟ًٌٍَُِّْ"
/* neutral characters (used only in dircontexts[] and dirmarks[]) */
t@@ -49,46 +113,3 @@ static struct placeholder {
{"َ", "ـَ", 1},
{"ّ", "ـّ", 1},
};
-
-/* map file names to file types */
-static struct filetype {
- char *ft; /* file type */
- char *pat; /* file name pattern */
-} filetypes[] = {
- {"c", "\\.[hc]$"},
- {"tr", "\\.(ms|tr|roff|tmac)$"},
- {"tex", "\\.tex$"},
-};
-
-/* syntax highlighting patterns */
-static struct highlight {
- char *ft; /* the filetype of this pattern */
- int att[16]; /* attributes of the matched groups */
- char *pat; /* regular expression */
- int end; /* the group ending this pattern */
-} highlights[] = {
- {"c", {5}, "\\<(signed|unsigned|char|short|int|long|float|double|void|struct|enum|union|typedef)\\>"},
- {"c", {5}, "\\<(static|extern|register)\\>"},
- {"c", {4}, "\\<(return|for|while|if|else|do|sizeof|goto|switch|case|default|break|continue)\\>"},
- {"c", {2 | SYN_IT}, "//.*$"},
- {"c", {2 | SYN_IT}, "/\\*([^*]|\\*[^/])*\\*/"},
- {"c", {6}, "^#[ \t]*[a-zA-Z0-9_]+"},
- {"c", {0, SYN_BD}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
- {"c", {4}, "\"([^\"]|\\\\\")*\""},
- {"c", {4}, "'([^\\]|\\\\.)'"},
-
- {"tr", {4, 0, 5 | SYN_BD, 4 | SYN_BD, 5 | SYN_BD, 4 | SYN_BD},
- "^[.'][ \t]*((SH.*)|(de) (.*)|([^ \t\\]{2,}))?.*$", 1},
- {"tr", {2 | SYN_IT}, "\\\\\".*$"},
- {"tr", {3}, "\\\\{1,2}[*$fgkmns]([^[(]|\\(..|\\[[^]]*\\])"},
- {"tr", {3}, "\\\\([^[(*$fgkmns]|\\(..|\\[[^]]*\\])"},
- {"tr", {3}, "\\$[^$]+\\$"},
-
- {"tex", {4 | SYN_BD, 0, 3, 0, 5},
- "\\\\[^[{ \t]+(\\[([^]]+)\\])?(\\{([^}]*)\\})?"},
- {"tex", {3}, "\\$[^$]+\\$"},
- {"tex", {2 | SYN_IT}, "%.*$"},
-};
-
-/* how to hightlight text in the reverse direction */
-#define SYN_REVDIR (SYN_BGMK(7))