summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-10-23 08:20:21 +1100
committerMaxime Coste <mawww@kakoune.org>2018-10-23 08:20:21 +1100
commit433e39566d930be3e20b0ecf3bc662ade03c44e3 (patch)
treeb4639754b2ee7bff2e00a4d73b9464abe6f0d92c
parente3668121f2109df8f313728238a2f15218a29dc4 (diff)
parent2999702b01f4cb43ceeb199cc2ca172ff4c5a4d3 (diff)
Merge remote-tracking branch 'lenormf/highlight-troff'
-rw-r--r--rc/extra/troff.kak29
1 files changed, 29 insertions, 0 deletions
diff --git a/rc/extra/troff.kak b/rc/extra/troff.kak
new file mode 100644
index 00000000..91755643
--- /dev/null
+++ b/rc/extra/troff.kak
@@ -0,0 +1,29 @@
+# Detection
+# ‾‾‾‾‾‾‾‾‾
+
+hook global BufCreate .*\.\d+ %{
+ set-option buffer filetype troff
+}
+
+# Highlighters
+# ‾‾‾‾‾‾‾‾‾‾‾‾
+
+add-highlighter shared/troff group
+add-highlighter shared/troff/ regex '\\f[A-Z]' 0:attribute
+add-highlighter shared/troff/ regex '\\fB(.+?)\\f[A-Z]' 1:+b
+add-highlighter shared/troff/ regex '\\fI(.+?)\\f[A-Z]' 1:+i
+
+add-highlighter shared/troff/ regex '^\.[a-zA-Z]{1,2}\b' 0:meta
+add-highlighter shared/troff/ regex '^\.TH\s+[^\n]+' 0:title
+add-highlighter shared/troff/ regex '^\.SH\s+[^\n]+' 0:header
+add-highlighter shared/troff/ regex '^\.IR\s+(\S+)' 1:+i
+add-highlighter shared/troff/ regex '^\.BR\s+(\S+)' 1:+b
+add-highlighter shared/troff/ regex '^\.I\s+([^\n]+)' 1:+i
+add-highlighter shared/troff/ regex '^\.B\s+([^\n]+)' 1:+b
+
+# Initialization
+# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
+
+hook -group troff-highlight global WinSetOption filetype=troff %{ add-highlighter window/troff ref troff }
+
+hook -group troff-highlight global WinSetOption filetype=(?!troff).* %{ remove-highlighter window/troff }