syn: nested and overlapping highlighting regions
[neatvi.git] / conf.h
blob52309f044608f5fa4b799f1ea6c9e60d4274c7cb
1 /* neatvi configuration file */
3 /* the alternate keymap (^F and ^E in insert mode to switch) */
4 #define KMAPALT "fa"
6 /* right-to-left characters (used only in dircontexts[] and dirmarks[]) */
7 #define CR2L "ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىييپچژکگی‌‍؛،»«؟ًٌٍَُِّْ"
8 /* neutral characters (used only in dircontexts[] and dirmarks[]) */
9 #define CNEUT "-!\"#$%&'()*+,./:;<=>?@^_`{|}~ "
11 /* direction context patterns; specifies the direction of a whole line */
12 static struct dircontext {
13 int dir;
14 char *pat;
15 } dircontexts[] = {
16 {-1, "^[" CR2L "]"},
17 {+1, "^[a-zA-Z_0-9]"},
20 /* direction marks; the direction of a few words in a line */
21 static struct dirmark {
22 int ctx; /* the direction context for this mark; 0 means any */
23 int dir; /* the direction of the matched text */
24 int grp; /* the nested subgroup; 0 means no groups */
25 char *pat;
26 } dirmarks[] = {
27 {+0, +1, 1, "\\\\\\*\\[([^]]+)\\]"},
28 {+1, -1, 0, "[" CR2L "][" CNEUT CR2L "]*[" CR2L "]"},
29 {-1, +1, 0, "[a-zA-Z0-9_][^" CR2L "\\\\`$']*[a-zA-Z0-9_]"},
30 {+0, +1, 0, "\\$([^$]+)\\$"},
31 {+0, +1, 1, "\\\\[a-zA-Z0-9_]+\\{([^}]+)\\}"},
32 {-1, +1, 0, "\\\\[^ \t" CR2L "]+"},
35 /* character placeholders */
36 static struct placeholder {
37 char *s; /* the source character */
38 char *d; /* the placeholder */
39 int wid; /* the width of the placeholder */
40 } placeholders[] = {
41 {"‌", "-", 1},
42 {"‍", "-", 1},
43 {"ْ", "ـْ", 1},
44 {"ٌ", "ـٌ", 1},
45 {"ٍ", "ـٍ", 1},
46 {"ً", "ـً", 1},
47 {"ُ", "ـُ", 1},
48 {"ِ", "ـِ", 1},
49 {"َ", "ـَ", 1},
50 {"ّ", "ـّ", 1},
53 /* map file names to file types */
54 static struct filetype {
55 char *ft; /* file type */
56 char *pat; /* file name pattern */
57 } filetypes[] = {
58 {"c", "\\.[hc]$"},
59 {"tr", "\\.(ms|tr|roff|tmac)$"},
62 /* syntax highlighting patterns */
63 static struct highlight {
64 char *ft; /* the filetype of this pattern */
65 int att[16]; /* attributes of the matched groups */
66 char *pat; /* regular expression */
67 int end; /* the group ending this pattern */
68 } highlights[] = {
69 {"c", {5}, "\\<(signed|unsigned|char|short|int|long|float|double|void|struct|enum|union|typedef)\\>"},
70 {"c", {5}, "\\<(static|extern|register)\\>"},
71 {"c", {4}, "\\<(return|for|while|if|else|do|sizeof|goto|switch|case|default|break|continue)\\>"},
72 {"c", {2 | SYN_IT}, "//.*$"},
73 {"c", {2 | SYN_IT}, "/\\*([^*]|\\*[^/])*\\*/"},
74 {"c", {6}, "^#[ \t]*[a-zA-Z0-9_]+"},
75 {"c", {0, SYN_BD}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
76 {"c", {4}, "\"([^\"]|\\\\\")*\""},
77 {"c", {4}, "'([^\\]|\\\\.)'"},
79 {"tr", {4, 0, 5 | SYN_BD, 4 | SYN_BD, 5 | SYN_BD, 4 | SYN_BD},
80 "^[.'][ \t]*((SH.*)|(de) (.*)|([^ \t\\]{2,}))?.*$", 1},
81 {"tr", {2 | SYN_IT}, "\\\\\".*$"},
82 {"tr", {3}, "\\\\{1,2}[*$fgkmns]([^[(]|\\(..|\\[[^]]*\\])"},
83 {"tr", {3}, "\\\\([^[(*$fgkmns]|\\(..|\\[[^]]*\\])"},
84 {"tr", {3}, "\\$[^$]+\\$"},
87 /* how to hightlight text in the reverse direction */
88 #define SYN_REVDIR (SYN_BGMK(7))