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 char *def
; /* pattern for global definitions (for gd command) */
11 char *sec
; /* section start pattern (for [[ and ]] commands) */
13 {"c", "\\.[hc]$", "^([a-zA-Z_].*)?\\<%s\\>"},
14 {"roff", "\\.(ms|me|mom|tr|roff|tmac|txt|[1-9])$", "^\\.(de|nr|ds) +%s\\>"},
16 {"msg", "letter$|mbox$|mail$"},
17 {"mk", "Makefile$|makefile$|\\.mk$", "^%s:"},
18 {"sh", "\\.sh$", "^(function +)?%s(\\(\\))? *\\{", "^(function +)?[a-zA-Z_0-9]+(\\(\\))? *\\{"},
19 {"go", "\\.go$", "^(func|var|const|type)( +\\(.*\\))? +%s\\>", "^(func|type)\\>.*\\{$"},
20 {"py", "\\.py$", "^(def|class) +\\<%s\\>"},
23 {"diff", "\\.(patch|diff)$"},
27 /* colours used in highlights[] for programming languages */
28 #define CKWD (3 | SYN_BD) /* general keywords */
29 #define CCON (CKWD) /* control flow keywords */
30 #define CPRE (2 | SYN_BD) /* preprocessor directives */
31 #define CIMP (4 | SYN_BD) /* imported packages */
32 #define CTYP (3) /* built-in types and values */
33 #define CBIN (3) /* built-in functions */
34 #define CCMT (4 | SYN_IT) /* comments */
35 #define CDEF (4 | SYN_BD) /* top-level definition */
36 #define CFUN (SYN_BD) /* called functions */
37 #define CNUM 4 /* numerical constants */
38 #define CSTR 4 /* string literals */
39 #define CVAR 3 /* macros */
40 #define CIDN 0 /* identifiers */
42 /* syntax highlighting patterns */
43 static struct highlight
{
44 char *ft
; /* the filetype of this pattern */
45 int att
[16]; /* attributes of the matched groups */
46 char *pat
; /* regular expression */
47 int end
; /* the group ending this pattern */
50 {"---", {SYN_BGMK(0) | 7 | SYN_BD
, 2, 1}, "^(\".*\").*(\\[[wr]\\]).*$"},
51 {"---", {SYN_BGMK(0) | 7 | SYN_BD
, 2, 5, 7}, "^(\".*\").*=.*(L[0-9]+) +(C[0-9]+).*$"},
52 {"---", {SYN_BGMK(0) | 7}, "^(\".*\").*-.*(L[0-9]+) +(C[0-9]+).*$"},
53 {"---", {SYN_BGMK(0) | 2 | SYN_BD
}, "^.*$\n?"},
55 {"-ex", {SYN_BGMK(0) | 7 | SYN_BD
}, ":.*$"},
56 {"-ex", {SYN_BGMK(0) | 7 | SYN_BD
}, "\\[.*$"},
57 {"-ex", {SYN_BGMK(0) | 7}, ".*$\n?"},
60 {"c", {CTYP
}, "\\<(signed|unsigned|char|short|int|long|float|double|void|struct|enum|union|typedef)\\>"},
61 {"c", {CKWD
}, "\\<(static|extern|register)\\>"},
62 {"c", {CCON
}, "\\<(return|for|while|if|else|do|sizeof|goto|switch|case|default|break|continue)\\>"},
63 {"c", {CCMT
}, "//.*$"},
64 {"c", {CCMT
}, "/\\*([^*]|\\*+[^*/])*\\*+/"},
65 {"c", {CIMP
, CPRE
}, "^#([ \t]*include).*"},
66 {"c", {CIMP
, CPRE
}, "^#([ \t]*[a-zA-Z0-9_]+)"},
67 {"c", {0, CFUN
}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
68 {"c", {CSTR
}, "\"([^\"]|\\\\\")*\""},
69 {"c", {CNUM
}, "'([^\\]|\\\\.)'"},
70 {"c", {CNUM
}, "[-+]?\\<(0[xX][0-9a-fA-F]+|[0-9]+)\\>"},
71 {"c", {CCMT
}, "^\t*(/\\*.*|\t* \\*.*|\t* \\*\\//)$"},
72 {"c", {CIDN
}, "[a-zA-Z][a-zA-Z0-9_]*"},
75 {"roff", {0, CKWD
, CDEF
}, "^[.'][ \t]*(SH)(.*)$"},
76 {"roff", {0, CKWD
, CDEF
}, "^[.'][ \t]*de (.*)$"},
77 {"roff", {0, CFUN
, CSTR
}, "^[.']([^ \t\\]{2,})?(.*)$", 1},
78 {"roff", {CCMT
}, "\\\\\".*$"},
79 {"roff", {CFUN
}, "\\\\{1,2}[*$fgkmns]([^[(]|\\(..|\\[[^]]*\\])"},
80 {"roff", {CVAR
}, "\\\\([^[(*$fgkmns]|\\(..|\\[[^]]*\\])"},
81 {"roff", {CSTR
}, "\\$[^$]+\\$"},
84 {"tex", {0, CKWD
, 0, 0, CIMP
, 0, CFUN
},
85 "\\\\([^[{ \t]+)((\\[([^][]+)\\])|(\\{([^}]*)\\}))*"},
86 {"tex", {CSTR
}, "\\$[^$]+\\$"},
87 {"tex", {CCMT
}, "%.*$"},
90 {"msg", {6 | SYN_BD
}, "^From .*20..$"},
91 {"msg", {6 | SYN_BD
, 4 | SYN_BD
}, "^Subject: (.*)$"},
92 {"msg", {6 | SYN_BD
, 2 | SYN_BD
}, "^From: (.*)$"},
93 {"msg", {6 | SYN_BD
, 5 | SYN_BD
}, "^To: (.*)$"},
94 {"msg", {6 | SYN_BD
, 5 | SYN_BD
}, "^Cc: (.*)$"},
95 {"msg", {6 | SYN_BD
}, "^[A-Z][-A-Za-z]+: .+$"},
96 {"msg", {2 | SYN_IT
}, "^> .*$"},
99 {"mk", {0, CDEF
}, "([A-Za-z_][A-Za-z0-9_]*)[ \t]*="},
100 {"mk", {CVAR
}, "\\$\\([a-zA-Z0-9_]+\\)"},
101 {"mk", {CCMT
}, "#.*$"},
102 {"mk", {0, CFUN
}, "([A-Za-z_%.]+):"},
105 {"sh", {0, CKWD
, CDEF
}, "^(function +)?([a-zA-Z_0-9]+) *(\\(\\))? *\\{"},
106 {"sh", {CCON
}, "\\<(break|case|continue|do|done|elif|else|esac|fi|for|if|in|then|until|while|return)\\>"},
107 {"sh", {CSTR
}, "\"([^\"\\]|\\\\.)*\""},
108 {"sh", {CSTR
}, "'[^']*'"},
109 {"sh", {CSTR
}, "`([^`\\]|\\\\.)*`"},
110 {"sh", {CVAR
}, "\\$(\\{[^}]+\\}|[a-zA-Z_0-9]+|[!#$?*@-])"},
111 {"sh", {CVAR
}, "\\$\\([^()]+\\)"},
112 {"sh", {CFUN
}, "^\\. .*$"},
113 {"sh", {CCMT
}, "#.*$"},
116 {"go", {0, CKWD
, CIDN
, CDEF
}, "^\\<(func) (\\([^()]+\\) )?([a-zA-Z0-9_]+)\\>"},
117 {"go", {CKWD
}, "\\<(func|type|var|const|package)\\>"},
118 {"go", {CPRE
, CIMP
}, "^import[ \t]+([^ ]+)"},
119 {"go", {CKWD
}, "\\<(import|interface|struct)\\>"},
120 {"go", {CCON
}, "\\<(break|case|chan|continue|default|defer|else|fallthrough|for|go|goto|if|map|range|return|select|switch)\\>"},
121 {"go", {0, CBIN
}, "\\<(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)\\>\\("},
122 {"go", {CTYP
}, "\\<(true|false|iota|nil|int8|int16|int32|int64|int|uint8|uint16|uint32|uint64|uint|uintptr|float32|float64|complex128|complex64|bool|byte|rune|string|error)\\>"},
123 {"go", {CCMT
}, "//.*$"},
124 {"go", {CCMT
}, "/\\*([^*]|\\*+[^*/])*\\*+/"},
125 {"go", {0, CFUN
}, "([a-zA-Z][a-zA-Z0-9_]*)\\(", 1},
126 {"go", {CIDN
}, "[a-zA-Z][a-zA-Z0-9_]*"},
127 {"go", {CSTR
}, "\"([^\"]|\\\\\")*\""},
128 {"go", {CNUM
}, "'([^']|\\\\')*'"},
129 {"go", {CSTR
}, "`([^`]|\\\\`)*`"},
130 {"go", {CNUM
}, "[-+]?\\<(0[xX][0-9a-fA-F]+|[0-9.]+)\\>"},
133 {"bib", {0, SYN_BD
, SYN_BGMK(3) | SYN_BD
}, "^(%L) +(.*)$", 1},
134 {"bib", {0, SYN_BD
, 4 | SYN_BD
}, "^(%A) (.*)$", 1},
135 {"bib", {0, SYN_BD
, 5 | SYN_BD
}, "^(%T) (.*)$", 1},
136 {"bib", {0, SYN_BD
, 2 | SYN_BD
}, "^(%[JB]) (.*)$", 1},
137 {"bib", {0, SYN_BD
, 5 | SYN_BD
}, "^(%D) (.*)$", 1},
138 {"bib", {0, SYN_BD
, 7}, "^(%O) (.*)$", 1},
139 {"bib", {0, SYN_BD
, SYN_BD
}, "^(%[A-Z]) (.*)$", 1},
140 {"bib", {4}, "^#.*$", 1},
143 {"py", {CCMT
}, "#.*$"},
144 {"py", {CKWD
}, "\\<(class|def)\\>"},
145 {"py", {CKWD
}, "\\<(and|or|not|is|in)\\>"},
146 {"py", {0, 0, CPRE
, CIDN
, CPRE
, CIMP
}, "((from)[ \t]+([^ ]+)[ \t]+)?(import)[ \t]+([^ ]+)"},
147 {"py", {CKWD
}, "\\<(import|from|global|lambda|del)\\>"},
148 {"py", {CCON
}, "\\<(for|while|if|elif|else|pass|return|break|continue)\\>"},
149 {"py", {CCON
}, "\\<(try|except|as|raise|finally|with)\\>"},
150 {"py", {0, CFUN
}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
151 {"py", {CSTR
}, "[\"']([^\"']|\\\\\")*[\"']"},
152 {"py", {CIDN
}, "[a-zA-Z][a-zA-Z0-9_]*"},
154 /* neatmail listing */
155 {"nm", {0, 6 | SYN_BD
, 4 | SYN_BD
, 3, 5, SYN_BD
},
156 "^([ROU])([0-9]+)(@[^ ]*)? *\t([^\t]*)\t([^\t]*)"},
157 {"nm", {0 | SYN_BD
| SYN_BGMK(6)}, "^[N].*$"},
158 {"nm", {0 | SYN_BD
| SYN_BGMK(5)}, "^[A-Z][HA].*$"},
159 {"nm", {0 | SYN_BD
| SYN_BGMK(3)}, "^[A-Z][MB].*$"},
160 {"nm", {7}, "^[A-Z][LC].*$"},
161 {"nm", {0 | SYN_BD
| SYN_BGMK(7)}, "^[F].*$"},
162 {"nm", {7 | SYN_IT
}, "^\t.*$"},
163 {"nm", {SYN_BD
}, "^:.*$"},
166 {"diff", {1}, "^-.*$"},
167 {"diff", {2}, "^\\+.*$"},
168 {"diff", {6}, "^@.*$"},
169 {"diff", {SYN_BD
}, "^diff .*$"},
171 /* directory listing */
172 {"ls", {7, 3, SYN_FGMK(0) | SYN_BD
, 2, 6}, "^/?([-a-zA-Z0-9_.]+/)*([-a-zA-Z0-9_.]+)\\>(:[0-9]*:)?(.*)$"},
173 {"ls", {CCMT
}, "^#.*$"},
176 /* how to highlight current line (hll option) */
177 #define SYN_LINE (SYN_BGMK(11))
179 /* how to highlight text in the reverse direction */
180 #define SYN_REVDIR (SYN_BGMK(7))
182 /* define it as "\33[8l" to disable BiDi in vte-based terminals */
185 /* right-to-left characters (used only in dircontexts[] and dirmarks[]) */
186 #define CR2L "ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىييپچژکگی؛،»«؟ًٌٍَُِّْٔ"
187 /* neutral characters (used only in dircontexts[] and dirmarks[]) */
188 #define CNEUT "-!\"#$%&'()*+,./:;<=>?@^_`{|}~ "
190 /* direction context patterns; specifies the direction of a whole line */
191 static struct dircontext
{
196 {+1, "^[a-zA-Z_0-9]"},
199 /* direction marks; the direction of a few words in a line */
200 static struct dirmark
{
201 int ctx
; /* the direction context for this mark; 0 means any */
202 int dir
; /* the direction of the matched text */
203 int grp
; /* the nested subgroup; 0 means no groups */
206 {+0, +1, 1, "\\\\\\*\\[([^]]+)\\]"},
207 {+1, -1, 0, "[" CR2L
"][" CNEUT CR2L
"]*[" CR2L
"]"},
208 {-1, +1, 0, "[a-zA-Z0-9_][^" CR2L
"\\\\`$']*[a-zA-Z0-9_]"},
209 {+0, +1, 0, "\\$([^$]+)\\$"},
210 {+0, +1, 1, "\\\\[a-zA-Z0-9_]+\\{([^}]+)\\}"},
211 {-1, +1, 0, "\\\\[^ \t" CR2L
"]+"},
214 /* character placeholders */
215 static struct placeholder
{
216 char *s
; /* the source character */
217 char *d
; /* the placeholder */
218 int wid
; /* the width of the placeholder */
236 /* external commands */
237 #define ECMD "neatvi.sh"