Skip to content

Instantly share code, notes, and snippets.

@marcsello
Last active January 17, 2024 13:38
Show Gist options
  • Save marcsello/978fae392e37822ffd053a87fb2128e8 to your computer and use it in GitHub Desktop.
Save marcsello/978fae392e37822ffd053a87fb2128e8 to your computer and use it in GitHub Desktop.
A bit more moderate YAML highlighting for GNU nano
# Original: https://ourcodeworld.com/articles/read/796/how-to-enable-syntax-highlighting-for-yaml-yml-files-in-gnu-nano
# Modified by Marcsello
# Supports `YAML` files
syntax "YAML" "\.ya?ml$"
header "^(---|===)" "%YAML"
## Keys
color brightblue "^\s*[\$A-Za-z0-9_-]+\:"
color brightmagenta "^\s*@[\$A-Za-z0-9_-]+\:"
## Values
#color ":\s.+$"
## Booleans
icolor brightcyan " (y|yes|n|no|true|false|on|off)$"
## Numbers
color green " [[:digit:]]+(\.[[:digit:]]+)?$"
## Arrays
color red "\[" "\]" ":\s+[|>]"
## Object in array
color brightblue "^\s*- .*:"
## Reserved
color green "(^| )!!(binary|bool|float|int|map|null|omap|seq|set|str) "
## Comments
color white "#.*$"
## Errors
color ,red ":\w.+$"
color ,red ":'.+$"
color ,red ":".+$"
color ,red "\s+$"
## Non closed quote
color ,red "['\"][^['\"]]*$"
## Closed quotes
color yellow "['\"].*['\"]"
## Equal sign
color brightwhite ":( |$)"
## One element per line Arrays
color red "^\s*- "
## Section divider
color brightwhite "^---$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment