forked from aligrudi/neatvi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf.h
211 lines (188 loc) · 7.84 KB
/
conf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* neatvi configuration file */
/* access mode of new files */
#define MKFILE_MODE 0600
/* map file names to file types */
static struct filetype {
char *ft; /* file type */
char *pat; /* file name pattern */
char *def; /* pattern for gd */
char *sec; /* section start pattern */
} filetypes[] = {
{"c", "\\.[hc]$", "^([a-zA-Z_].*)?\\<%s\\>"},
{"roff", "\\.(ms|me|mom|tr|roff|tmac|txt|[1-9])$", "^\\.(de|nr|ds) +%s\\>"},
{"tex", "\\.tex$"},
{"msg", "letter$|mbox$|mail$"},
{"mk", "Makefile$|makefile$|\\.mk$", "^%s:"},
{"sh", "\\.sh$", "^(function +)%s *\\{"},
{"go", "\\.go$", "^(func|var|const|type)( +\\(.*\\))? +%s\\>", "^(func|type)\\>.*\\{$"},
{"py", "\\.py$", "^(def|class) +\\<%s\\>"},
{"bib", "bib$"},
{"nm", "\\.nm$"},
{"diff", "\\.(patch|diff)$"},
{"ls", "ls$"},
};
/* 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[] = {
/* status bar */
{"---", {SYN_BGMK(7) | 8 | SYN_BD, 4, 1}, "^(\".*\").*(\\[[wr]\\]).*$"},
{"---", {SYN_BGMK(7) | 8 | SYN_BD, 4, 4}, "^(\".*\").*=.*(L[0-9]+) +(C[0-9]+).*$"},
{"---", {SYN_BGMK(6) | 8 | SYN_BD, 4, 4}, "^(\".*\").*-.*(L[0-9]+) +(C[0-9]+).*$"},
{"---", {SYN_BGMK(7) | 8 | SYN_BD}, "^.*$"},
/* C */
{"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]+)\\>"},
/* troff */
{"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 */
{"tex", {4 | SYN_BD, 0, 3, 0, 5},
"\\\\[^[{ \t]+(\\[([^]]+)\\])?(\\{([^}]*)\\})?"},
{"tex", {3}, "\\$[^$]+\\$"},
{"tex", {2 | SYN_IT}, "%.*$"},
/* mail */
{"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}, "^> .*$"},
/* makefile */
{"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_%.]+):"},
/* shell script */
{"sh", {5 | SYN_BD}, "\\<(break|case|continue|do|done|elif|else|esac|fi|for|if|in|then|until|while|return)\\>"},
{"sh", {4}, "\"([^\"\\]|\\\\.)*\""},
{"sh", {4}, "'[^']*'"},
{"sh", {3}, "`([^`\\]|\\\\.)*`"},
{"sh", {1}, "\\$(\\{[^}]+\\}|[a-zA-Z_0-9]+|[!#$?*@-])"},
{"sh", {0, SYN_BD}, "^([a-zA-Z_][a-zA-Z_0-9]* *\\(\\)) *\\{"},
{"sh", {SYN_BD}, "^\\. .*$"},
{"sh", {2 | SYN_IT}, "#.*$"},
/* go */
{"go", {0, 3 | SYN_BD, 0, 29 | SYN_BD}, "^\\<(func) (\\([^()]+\\) )?([a-zA-Z0-9_]+)\\>"},
{"go", {3 | SYN_BD}, "^\\<(func|type|var|const|package)\\>"},
{"go", {3 | SYN_BD}, "\\<(func|type|var|const|package)\\>"},
{"go", {3 | SYN_BD}, "\\<(import|interface|struct)\\>"},
{"go", {3 | SYN_BD}, "\\<(break|case|chan|continue|default|defer|else|fallthrough|for|go|goto|if|map|range|return|select|switch)\\>"},
{"go", {0, 8 | SYN_BD}, "\\<(append|copy|delete|len|cap|make|new|complex|real|imag|close|panic|recover|print|println|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|uintptr|float32|float64|complex128|complex64|bool|byte|rune|string|error)\\>\\("},
{"go", {8 | SYN_BD}, "\\<(true|false|iota|nil|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|uintptr|float32|float64|complex128|complex64|bool|byte|rune|string|error)\\>"},
{"go", {6 | SYN_IT}, "//.*$"},
{"go", {6 | SYN_IT}, "/\\*([^*]|\\*+[^*/])*\\*+/"},
{"go", {0, SYN_BD}, "([a-zA-Z][a-zA-Z0-9_]*)\\(", 1},
{"go", {8}, "[a-zA-Z][a-zA-Z0-9_]*"},
{"go", {4}, "\"([^\"]|\\\\\")*\""},
{"go", {4}, "'([^']|\\\\')*'"},
{"go", {4}, "`([^`]|\\\\`)*`"},
{"go", {4}, "[-+]?\\<(0[xX][0-9a-fA-F]+|[0-9]+)\\>"},
/* refer */
{"bib", {0, 8 | SYN_BD, SYN_BGMK(11) | SYN_BD}, "^(%L) +(.*)$", 1},
{"bib", {0, 8 | SYN_BD, 12 | SYN_BD}, "^(%A) (.*)$", 1},
{"bib", {0, 8 | SYN_BD, 5 | SYN_BD}, "^(%T) (.*)$", 1},
{"bib", {0, 8 | SYN_BD, 2 | SYN_BD}, "^(%[JB]) (.*)$", 1},
{"bib", {0, 8 | SYN_BD, 5 | SYN_BD}, "^(%D) (.*)$", 1},
{"bib", {0, 8 | SYN_BD, 7}, "^(%O) (.*)$", 1},
{"bib", {0, 8 | SYN_BD, 8 | SYN_BD}, "^(%[A-Z]) (.*)$", 1},
{"bib", {25}, "^#.*$", 1},
/* python */
{"py", {2}, "#.*$"},
{"py", {5}, "\\<(class|def)\\>"},
{"py", {5}, "\\<(and|or|not|is|in)\\>"},
{"py", {5}, "\\<(import|from|global|lambda|del)\\>"},
{"py", {5}, "\\<(for|while|if|elif|else|pass|return|break|continue)\\>"},
{"py", {5}, "\\<(try|except|as|raise|finally|with)\\>"},
{"py", {0, 0 | SYN_BD}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
{"py", {4}, "[\"']([^\"']|\\\\\")*[\"']"},
/* neatmail listing */
{"nm", {0 | SYN_BGMK(15), 6 | SYN_BD, 12 | SYN_BD, 3, 5, 8 | SYN_BD},
"^([ROU])([0-9]+)(@[^ ]*)? *\t([^\t]*)\t([^\t]*)"},
{"nm", {0 | SYN_BD | SYN_BGMK(6)}, "^[N].*$"},
{"nm", {0 | SYN_BD | SYN_BGMK(13)}, "^[A-Z][HT].*$"},
{"nm", {0 | SYN_BD | SYN_BGMK(11)}, "^[A-Z][MI].*$"},
{"nm", {7 | SYN_BGMK(15)}, "^[A-Z][LJ].*$"},
{"nm", {0 | SYN_BD | SYN_BGMK(7)}, "^[F].*$"},
{"nm", {7 | SYN_IT}, "^\t.*$"},
{"nm", {SYN_BD}, "^:.*$"},
/* diff */
{"diff", {1}, "^-.*$"},
{"diff", {2}, "^\\+.*$"},
{"diff", {6}, "^@.*$"},
{"diff", {SYN_BD}, "^diff .*$"},
/* directory listing */
{"ls", {7, 3, SYN_FGMK(0) | SYN_BD, 2, 8}, "^/?([-a-zA-Z0-9_.]+/)*([-a-zA-Z0-9_.]+)\\>(:[0-9]*:)?(.*)$"},
{"ls", {12}, "^#.*$"},
};
/* how to highlight current line (hll option) */
#define SYN_LINE (SYN_BGMK(11))
/* how to highlight text in the reverse direction */
#define SYN_REVDIR (SYN_BGMK(7))
/* define it as "\33[8l" to disable BiDi in vte-based terminals */
#define LNPREF ""
/* right-to-left characters (used only in dircontexts[] and dirmarks[]) */
#define CR2L "ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىييپچژکگی؛،»«؟ًٌٍَُِّْٔ"
/* neutral characters (used only in dircontexts[] and dirmarks[]) */
#define CNEUT "-!\"#$%&'()*+,./:;<=>?@^_`{|}~ "
/* direction context patterns; specifies the direction of a whole line */
static struct dircontext {
int dir;
char *pat;
} dircontexts[] = {
{-1, "^[" CR2L "]"},
{+1, "^[a-zA-Z_0-9]"},
};
/* direction marks; the direction of a few words in a line */
static struct dirmark {
int ctx; /* the direction context for this mark; 0 means any */
int dir; /* the direction of the matched text */
int grp; /* the nested subgroup; 0 means no groups */
char *pat;
} dirmarks[] = {
{+0, +1, 1, "\\\\\\*\\[([^]]+)\\]"},
{+1, -1, 0, "[" CR2L "][" CNEUT CR2L "]*[" CR2L "]"},
{-1, +1, 0, "[a-zA-Z0-9_][^" CR2L "\\\\`$']*[a-zA-Z0-9_]"},
{+0, +1, 0, "\\$([^$]+)\\$"},
{+0, +1, 1, "\\\\[a-zA-Z0-9_]+\\{([^}]+)\\}"},
{-1, +1, 0, "\\\\[^ \t" CR2L "]+"},
};
/* character placeholders */
static struct placeholder {
char *s; /* the source character */
char *d; /* the placeholder */
int wid; /* the width of the placeholder */
} placeholders[] = {
{"", "-", 1},
{"", "-", 1},
{"ً", "ـً", 1},
{"ٌ", "ـٌ", 1},
{"ٍ", "ـٍ", 1},
{"َ", "ـَ", 1},
{"ُ", "ـُ", 1},
{"ِ", "ـِ", 1},
{"ّ", "ـّ", 1},
{"ْ", "ـْ", 1},
{"ٓ", "ـٓ", 1},
{"ٔ", "ـٔ", 1},
{"ٕ", "ـٕ", 1},
{"ٰ", "ـٰ", 1},
};
/* external commands */
#define ECMD "neatvi.sh"