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