summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2021-06-09 21:00:49 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2021-06-09 21:00:49 +0200
commit26095dda91c169bf5e7f657d4ff52da1baab3e4c (patch)
treeba99d44bd4871bc9bff63bd3c0740becd7b585f1
parentdec65bafcafe295aeb5744f8a34ff5a1fd2cb1ef (diff)
downloadvim-polyglot-26095dda91c169bf5e7f657d4ff52da1baab3e4c.tar.gz
vim-polyglot-26095dda91c169bf5e7f657d4ff52da1baab3e4c.zip
Update
-rw-r--r--ftplugin/nftables.vim28
-rw-r--r--indent/nftables.vim21
-rw-r--r--syntax/nftables.vim41
3 files changed, 90 insertions, 0 deletions
diff --git a/ftplugin/nftables.vim b/ftplugin/nftables.vim
new file mode 100644
index 00000000..c9294881
--- /dev/null
+++ b/ftplugin/nftables.vim
@@ -0,0 +1,28 @@
+if polyglot#init#is_disabled(expand('<sfile>:p'), 'nftables', 'ftplugin/nftables.vim')
+ finish
+endif
+
+if exists('b:did_ftplugin')
+ finish
+endif
+let b:did_ftplugin = 1
+
+let s:save_cpo = &cpoptions
+set cpoptions&vim
+
+setlocal smartindent nocindent
+setlocal commentstring=#%s
+setlocal formatoptions-=t formatoptions+=croqnlj
+
+setlocal comments=b:#
+
+setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
+setlocal textwidth=99
+
+let b:undo_ftplugin = '
+ \ setlocal formatoptions< comments< commentstring<
+ \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth<
+ \'
+
+let &cpoptions = s:save_cpo
+unlet s:save_cpo
diff --git a/indent/nftables.vim b/indent/nftables.vim
new file mode 100644
index 00000000..1a3e5876
--- /dev/null
+++ b/indent/nftables.vim
@@ -0,0 +1,21 @@
+if polyglot#init#is_disabled(expand('<sfile>:p'), 'nftables', 'indent/nftables.vim')
+ finish
+endif
+
+" Only load this indent file when no other was loaded.
+if exists('b:did_indent')
+ finish
+endif
+let b:did_indent = 1
+
+setlocal cindent
+setlocal cinoptions=L0,(0,Ws,J1,j1,+N
+setlocal cinkeys=0{,0},!^F,o,O,0[,0]
+" Don't think cinwords will actually do anything at all... never mind
+setlocal cinwords=table,chain
+
+" Some preliminary settings
+setlocal nolisp " Make sure lisp indenting doesn't supersede us
+setlocal autoindent " indentexpr isn't much help otherwise
+" Also do indentkeys, otherwise # gets shoved to column 0 :-/
+setlocal indentkeys=0{,0},!^F,o,O,0[,0]
diff --git a/syntax/nftables.vim b/syntax/nftables.vim
new file mode 100644
index 00000000..c73e5c31
--- /dev/null
+++ b/syntax/nftables.vim
@@ -0,0 +1,41 @@
+if polyglot#init#is_disabled(expand('<sfile>:p'), 'nftables', 'syntax/nftables.vim')
+ finish
+endif
+
+if exists('b:current_syntax')
+ finish
+endif
+
+syn match nftablesSet /{.*}/ contains=nftablesSetEntry
+syn match nftablesSetEntry /[a-zA-Z0-9]\+/ contained
+hi def link nftablesSet Keyword
+hi def link nftablesSetEntry Operator
+
+syn match nftablesNumber "\<[0-9A-Fa-f./:]\+\>" contains=nftablesMask,nftablesDelimiter
+syn match nftablesHex "\<0x[0-9A-Fa-f]\+\>"
+syn match nftablesDelimiter "[./:]" contained
+syn match nftablesMask "/[0-9.]\+" contained contains=nftablesDelimiter
+hi def link nftablesNumber Number
+hi def link nftablesHex Number
+hi def link nftablesDelimiter Operator
+hi def link nftablesMask Operator
+
+syn region Comment start=/#/ end=/$/
+syn region String start=/"/ end=/"/
+syn keyword Function flush
+syn keyword Function table chain map
+syn keyword Statement type hook
+syn keyword Type ip ip6 inet arp bridge
+syn keyword Type filter nat route
+syn keyword Type ether vlan arp ip icmp igmp ip6 icmpv6 tcp udp udplite sctp dccp ah esp comp icmpx
+syn keyword Type ct
+syn keyword Type length protocol priority mark iif iifname iiftype oif oifname oiftype skuid skgid rtclassid
+syn keyword Constant prerouting input forward output postrouting
+
+syn keyword Special snat dnat masquerade redirect
+syn keyword Special accept drop reject queue
+syn keyword Keyword continue return jump goto
+syn keyword Keyword counter log limit
+syn keyword Keyword define
+
+let b:current_syntax = 'nftables'