summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/hi.c54
-rw-r--r--bin/man1/hi.13
2 files changed, 39 insertions, 18 deletions
diff --git a/bin/hi.c b/bin/hi.c
index 604e3895..e11193d9 100644
--- a/bin/hi.c
+++ b/bin/hi.c
@@ -49,29 +49,27 @@ struct Syntax {
 };
 
 #define WB "(^|[^[:alnum:]_]|\n)"
+#define SQ_PATTERN "'([^']|\\\\')*'"
+#define DQ_PATTERN "\"([^\"]|\\\\\")*\""
 #define TODO_PATTERN "FIXME|TODO|XXX"
 
 static const struct Syntax CSyntax[] = {
-	{ Keyword, .subexp = 2,
-		.pattern = WB"(auto|extern|register|static|(_T|t)hread_local)"WB },
-	{ Keyword, .subexp = 2,
-		.pattern = WB"(const|inline|restrict|volatile)"WB },
-	{ Keyword, .subexp = 2,
-		.pattern = WB"((_A|a)lignas|_Atomic|(_N|n)oreturn)"WB },
-	{ Keyword, .subexp = 2,
-		.pattern = WB"(enum|struct|typedef|union)"WB },
-	{ Keyword, .subexp = 2,
-		.pattern = WB"(case|default|do|else|for|if|switch|while)"WB },
-	{ Keyword, .subexp = 2,
-		.pattern = WB"(break|continue|goto|return)"WB },
+	{ Keyword, .subexp = 2, .pattern =
+		WB "("
+		"(_A|a)lignas|_Atomic|(_N|n)oreturn|(_T|t)hread_local|auto|break|case"
+		"|const|continue|default|do|else|enum|extern|for|goto|if|inline"
+		"|register|restrict|return|static|struct|switch|typedef|union|volatile"
+		"|while"
+		")" WB
+	},
 	{ Macro,
 		.pattern = "^#(.|\\\\\n)*" },
 	{ String, .subexp = 1,
 		.pattern = "^#include (<[^>]*>)" },
 	{ String,
-		.pattern = "[LUu]?'([^']|\\\\')*'" },
+		.pattern = "[LUu]?" SQ_PATTERN },
 	{ String,
-		.pattern = "([LU]|u8?)?\"([^\"]|\\\\\")*\"" },
+		.pattern = "([LU]|u8?)?" DQ_PATTERN },
 	{ Escape, .parent = String,
 		.pattern = "\\\\([\"'?\\abfnrtv]|[0-7]{1,3}|x[0-9A-Fa-f]+)" },
 	{ Escape, .parent = String,
@@ -95,7 +93,7 @@ static const struct Syntax CSyntax[] = {
 
 static const struct Syntax MakeSyntax[] = {
 	{ Keyword, .subexp = 2,
-		.pattern = WB"(\\.(PHONY|PRECIOUS|SUFFIXES))"WB },
+		.pattern = WB "(\\.(PHONY|PRECIOUS|SUFFIXES))" WB },
 	{ Macro,
 		.pattern = "^ *-?include" },
 	{ String, .subexp = 1,
@@ -103,9 +101,9 @@ static const struct Syntax MakeSyntax[] = {
 	{ Normal,
 		.pattern = "^\t.*" },
 	{ String,
-		.pattern = "'([^']|\\\\')*'" },
+		.pattern = SQ_PATTERN },
 	{ String,
-		.pattern = "\"([^\"]|\\\\\")*\"" },
+		.pattern = DQ_PATTERN },
 	{ Interp,
 		.pattern = "\\$[^$]" },
 	// These Interp patterns handle one level of nesting with the same
@@ -122,6 +120,27 @@ static const struct Syntax MakeSyntax[] = {
 		.pattern = TODO_PATTERN },
 };
 
+static const struct Syntax MdocSyntax[] = {
+	{ Keyword, .subexp = 2, .pattern =
+		WB "("
+		"%[ABCDIJNOPQRTUV]|A[cdnopqrt]|B[cdfkloqtx]|Br[coq]|Bsx|C[dm]"
+		"|D[1bcdloqtvx]|E[cdfklmnorsvx]|F[acdlnortx]|Hf|I[cnt]|L[bikp]|M[st]"
+		"|N[dmosx]|O[copstx]|P[acfopq]|Q[cloq]|R[esv]|S[chmoqstxy]|T[an]|U[dx]"
+		"|V[at]|X[cor]"
+		")" WB
+	},
+	{ String,
+		.pattern = DQ_PATTERN },
+	{ Normal,
+		.pattern = "^[^.].*" },
+	{ String,
+		.pattern = "\\\\(.|\\(.{2}|\\[[^]]*\\])" },
+	{ Comment,
+		.pattern = "^\\.\\\\\".*" },
+	{ Todo, .parent = Comment,
+		.pattern = TODO_PATTERN },
+};
+
 static const struct Language {
 	const char *name;
 	const char *pattern;
@@ -130,6 +149,7 @@ static const struct Language {
 } Languages[] = {
 	{ "c", "\\.[ch]$", CSyntax, ARRAY_LEN(CSyntax) },
 	{ "make", "Makefile$|\\.mk$", MakeSyntax, ARRAY_LEN(MakeSyntax) },
+	{ "mdoc", "\\.[1-9]$", MdocSyntax, ARRAY_LEN(MdocSyntax) },
 };
 
 static regex_t compile(const char *pattern, int flags) {
diff --git a/bin/man1/hi.1 b/bin/man1/hi.1
index a40e3674..c00874dd 100644
--- a/bin/man1/hi.1
+++ b/bin/man1/hi.1
@@ -47,7 +47,8 @@ may be inferred from its name.
 .Pp
 The following languages are supported:
 .Cm c ,
-.Cm make .
+.Cm make ,
+.Cm mdoc .
 .
 .Pp
 The output formats are as follows:
/init.vim?id=6c151707fab104b1bec3e3893980fe468cbedef2&follow=1'>Remove scroll bindings from nvim configJune McEnroe 2016-08-17Highlight Search with black foregroundJune McEnroe 2016-08-15Remove gruvboxJune McEnroe 2016-08-04Remove march from SSH configJune McEnroe 2016-08-01Disable tab indicators in iTermJune McEnroe 2016-07-30Color PreProc DarkGreenJune McEnroe 2016-07-29Color Structure and Typedef in grayJune McEnroe 2016-07-27Color comments DarkBlue and LightBlueJune McEnroe 2016-07-27Color macros in yellowJune McEnroe 2016-07-26Colorscheme colors and schemesJune McEnroe 2016-07-26Add ''subtle'' colorschemeJune McEnroe I'm just trying this out. 2016-07-26Add htoprcJune McEnroe 2016-07-24Add may and refactor ssh configJune McEnroe 2016-07-18Disable cursorlineJune McEnroe 2016-07-18Use hard constrast gruvbox darkJune McEnroe 2016-07-15Remove vim configurationJune McEnroe 2016-07-15Add readline to README configurations listJune McEnroe 2016-07-15Add vendor script to READMEJune McEnroe 2016-07-15Pull latest pathogen and gruvboxJune McEnroe