[PATCH] syntax: add highlighting for TOML files
Vincent Yang <[email protected]> Sun, 22 Feb 2026 14:12:18 +0800
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <[email protected]> |
---
syntax/Makefile.am | 1 +
syntax/toml.nanorc | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
create mode 100644 syntax/toml.nanorc
diff --git a/syntax/Makefile.am b/syntax/Makefile.am
index 4d992f90..0ed86cf9 100644
--- a/syntax/Makefile.am
+++ b/syntax/Makefile.am
@@ -36,6 +36,7 @@ pkgdata_DATA = asm.nanorc \
tcl.nanorc \
tex.nanorc \
texinfo.nanorc \
+ toml.nanorc \
xml.nanorc \
yaml.nanorc
diff --git a/syntax/toml.nanorc b/syntax/toml.nanorc
new file mode 100644
index 00000000..35d5710b
--- /dev/null
+++ b/syntax/toml.nanorc
@@ -0,0 +1,33 @@
+## Syntax highlighting for TOML files.
+
+syntax toml "\.toml$" "Cargo\.lock$"
+magic "TOML"
+comment "#"
+
+# Data types (Values)
+color magenta "\<[0-9]+(\.[0-9]+)?\>"
+color brightgreen "\<(true|false)\>"
+color magenta "\<[0-9]{4}-[0-9]{2}-[0-9]{2}\>"
+
+# Strings
+color yellow ""(\\.|[^"])*"" "''(\\.|[^'])*''"
+color yellow start="\"\"\"" end="\"\"\""
+color yellow start="'''" end="'''"
+
+# Keys and Assignments
+color brightcyan "^[[:space:]]*[^= ]+"
+color brightwhite " = "
+
+# Arrays and Inline Tables (The delimiters)
+color brightwhite "\[|\]|\{|\}|,"
+
+# Table Headers (The [sections])
+color brightmagenta "^[[:space:]]*\[+[^]]+\]+"
+# This overpaints the brackets in the header to be white
+color brightwhite "^[[:space:]]*\[+|\]+[[:space:]]*$"
+
+# Comments
+color blue "^[[:space:]]*#.*"
+
+# Trailing whitespace
+color ,red "[[:space:]]+$"
--
2.43.0