ex: represent each keymap with its index in kmaps[]
[neatvi.git] / conf.h
blob04d71431e9dedc0522e621d203764da298f53683
1 /* neatvi configuration file */
3 /* map file names to file types */
4 static struct filetype {
5 char *ft; /* file type */
6 char *pat; /* file name pattern */
7 } filetypes[] = {
8 {"c", "\\.[hc]$"}, /* C */
9 {"roff", "\\.(ms|tr|roff|tmac|txt|[1-9])$"}, /* troff */
10 {"tex", "\\.tex$"}, /* tex */
11 {"msg", "letter$|mbox$|mail$"}, /* email */
12 {"mk", "Makefile$|makefile$|\\.mk$"}, /* makefile */
13 {"sh", "\\.sh$"}, /* shell script */
14 {"nm", "\\.nm$"}, /* neatmail */
17 /* syntax highlighting patterns */
18 static struct highlight {
19 char *ft; /* the filetype of this pattern */
20 int att[16]; /* attributes of the matched groups */
21 char *pat; /* regular expression */
22 int end; /* the group ending this pattern */
23 } highlights[] = {
24 {"c", {5}, "\\<(signed|unsigned|char|short|int|long|float|double|void|struct|enum|union|typedef)\\>"},
25 {"c", {5}, "\\<(static|extern|register)\\>"},
26 {"c", {4}, "\\<(return|for|while|if|else|do|sizeof|goto|switch|case|default|break|continue)\\>"},
27 {"c", {2 | SYN_IT}, "//.*$"},
28 {"c", {2 | SYN_IT}, "/\\*([^*]|\\*+[^*/])*\\*+/"},
29 {"c", {6}, "^#[ \t]*[a-zA-Z0-9_]+"},
30 {"c", {0, SYN_BD}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
31 {"c", {4}, "\"([^\"]|\\\\\")*\""},
32 {"c", {4}, "'([^\\]|\\\\.)'"},
33 {"c", {4}, "[-+]?\\<(0[xX][0-9a-fA-F]+|[0-9]+)\\>"},
35 {"roff", {4, 0, 5 | SYN_BD, 4 | SYN_BD, 5 | SYN_BD, 4 | SYN_BD},
36 "^[.'][ \t]*((SH.*)|(de) (.*)|([^ \t\\]{2,}))?.*$", 1},
37 {"roff", {2 | SYN_IT}, "\\\\\".*$"},
38 {"roff", {3}, "\\\\{1,2}[*$fgkmns]([^[(]|\\(..|\\[[^]]*\\])"},
39 {"roff", {3}, "\\\\([^[(*$fgkmns]|\\(..|\\[[^]]*\\])"},
40 {"roff", {3}, "\\$[^$]+\\$"},
42 {"tex", {4 | SYN_BD, 0, 3, 0, 5},
43 "\\\\[^[{ \t]+(\\[([^]]+)\\])?(\\{([^}]*)\\})?"},
44 {"tex", {3}, "\\$[^$]+\\$"},
45 {"tex", {2 | SYN_IT}, "%.*$"},
47 {"msg", {6 | SYN_BD}, "^From .*20..$"},
48 {"msg", {6 | SYN_BD, 4 | SYN_BD}, "^Subject: (.*)$"},
49 {"msg", {6 | SYN_BD, 2 | SYN_BD}, "^From: (.*)$"},
50 {"msg", {6 | SYN_BD, 5 | SYN_BD}, "^To: (.*)$"},
51 {"msg", {6 | SYN_BD, 5 | SYN_BD}, "^Cc: (.*)$"},
52 {"msg", {6 | SYN_BD}, "^[A-Z][-A-Za-z]+: .+$"},
53 {"msg", {2 | SYN_IT}, "^> .*$"},
55 {"mk", {0, 3}, "([A-Za-z_][A-Za-z0-9_]*)[ \t]*="},
56 {"mk", {3}, "\\$\\([a-zA-Z0-9_]+\\)"},
57 {"mk", {2 | SYN_IT}, "#.*$"},
58 {"mk", {0, SYN_BD}, "([A-Za-z_%.]+):"},
60 {"sh", {2 | SYN_IT}, "#.*$"},
61 {"sh", {4}, "\"([^\"]|\\\\\")*\""},
62 {"sh", {4}, "\'[^\']*\'"},
64 {"nm", {0, 12 | SYN_BD, 12 | SYN_BD, 2, 8 | SYN_BD},
65 "^([ROU])([0-9]+)\t([^\t]*)\t([^\t]*)"},
66 {"nm", {7}, "^[LJ].*$"},
67 {"nm", {0 | SYN_BD | SYN_BGMK(13)}, "^[HT].*$"},
68 {"nm", {0 | SYN_BD | SYN_BGMK(11)}, "^[MI].*$"},
69 {"nm", {0 | SYN_BD | SYN_BGMK(12)}, "^[N].*$"},
70 {"nm", {0 | SYN_BD | SYN_BGMK(10)}, "^[F].*$"},
71 {"nm", {7 | SYN_IT}, "^\t.*$"},
72 {"nm", {SYN_BD}, "^:.*$"},
75 /* how to hightlight text in the reverse direction */
76 #define SYN_REVDIR (SYN_BGMK(255))
78 /* right-to-left characters (used only in dircontexts[] and dirmarks[]) */
79 #define CR2L "ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىييپچژکگی‌‍؛،»«؟ًٌٍَُِّْ"
80 /* neutral characters (used only in dircontexts[] and dirmarks[]) */
81 #define CNEUT "-!\"#$%&'()*+,./:;<=>?@^_`{|}~ "
83 /* direction context patterns; specifies the direction of a whole line */
84 static struct dircontext {
85 int dir;
86 char *pat;
87 } dircontexts[] = {
88 {-1, "^[" CR2L "]"},
89 {+1, "^[a-zA-Z_0-9]"},
92 /* direction marks; the direction of a few words in a line */
93 static struct dirmark {
94 int ctx; /* the direction context for this mark; 0 means any */
95 int dir; /* the direction of the matched text */
96 int grp; /* the nested subgroup; 0 means no groups */
97 char *pat;
98 } dirmarks[] = {
99 {+0, +1, 1, "\\\\\\*\\[([^]]+)\\]"},
100 {+1, -1, 0, "[" CR2L "][" CNEUT CR2L "]*[" CR2L "]"},
101 {-1, +1, 0, "[a-zA-Z0-9_][^" CR2L "\\\\`$']*[a-zA-Z0-9_]"},
102 {+0, +1, 0, "\\$([^$]+)\\$"},
103 {+0, +1, 1, "\\\\[a-zA-Z0-9_]+\\{([^}]+)\\}"},
104 {-1, +1, 0, "\\\\[^ \t" CR2L "]+"},
107 /* character placeholders */
108 static struct placeholder {
109 char *s; /* the source character */
110 char *d; /* the placeholder */
111 int wid; /* the width of the placeholder */
112 } placeholders[] = {
113 {"‌", "-", 1},
114 {"‍", "-", 1},