Package: nano
Version: 2.4.2-1
Severity: wishlist

Dear maintainer,

it would be good to have syntax highlighting for nftables rulesets in the nano 
editor.

Ruleset files tend to be big and complex to read, more or less like source code.
They include comments, variables, and some special words.

nftables its a fairly new thing, so there are no other syntax highlighting for 
other editors yet.

The attached syntax works for me.

thanks, best regards.
syntax "nftables" "\.(nft|nftables)$"
header "^#!.*((nft|nftables))"

# Strings and others
color yellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"

# Objects and operations
color green 
"\<(table|chain|ruleset|set|map|vmap|type|hook|priority|policy)\>[[:space:]]"
color green "\<(include|define)\>[[:space:]]"
color red "[[:space:]]\<(flush|add|remove|replace|delete)\>[[:space:]]"

# Families
color yellow "[[:space:]]\<(ip|ip6|inet|arp|bridge)\>[[:space:]]"

# Terminal statements
color red "\<(drop|reject)\>"
color brightblue "\<(accept|snat|dnat|continue|return|goto)\>"

# Basic variable names
color brightred "\$[[:alpha:]_][[:alnum:]_.]*"

# Comments
color cyan "(^|[[:space:]])#.*$"

# Trailing whitespace
color ,green "[[:space:]]+$"

Reply via email to