Skip to content

Commit 26095dd

Browse files
committed
Update
1 parent dec65ba commit 26095dd

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

ftplugin/nftables.vim

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
if polyglot#init#is_disabled(expand('<sfile>:p'), 'nftables', 'ftplugin/nftables.vim')
2+
finish
3+
endif
4+
5+
if exists('b:did_ftplugin')
6+
finish
7+
endif
8+
let b:did_ftplugin = 1
9+
10+
let s:save_cpo = &cpoptions
11+
set cpoptions&vim
12+
13+
setlocal smartindent nocindent
14+
setlocal commentstring=#%s
15+
setlocal formatoptions-=t formatoptions+=croqnlj
16+
17+
setlocal comments=b:#
18+
19+
setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
20+
setlocal textwidth=99
21+
22+
let b:undo_ftplugin = '
23+
\ setlocal formatoptions< comments< commentstring<
24+
\|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth<
25+
\'
26+
27+
let &cpoptions = s:save_cpo
28+
unlet s:save_cpo

indent/nftables.vim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if polyglot#init#is_disabled(expand('<sfile>:p'), 'nftables', 'indent/nftables.vim')
2+
finish
3+
endif
4+
5+
" Only load this indent file when no other was loaded.
6+
if exists('b:did_indent')
7+
finish
8+
endif
9+
let b:did_indent = 1
10+
11+
setlocal cindent
12+
setlocal cinoptions=L0,(0,Ws,J1,j1,+N
13+
setlocal cinkeys=0{,0},!^F,o,O,0[,0]
14+
" Don't think cinwords will actually do anything at all... never mind
15+
setlocal cinwords=table,chain
16+
17+
" Some preliminary settings
18+
setlocal nolisp " Make sure lisp indenting doesn't supersede us
19+
setlocal autoindent " indentexpr isn't much help otherwise
20+
" Also do indentkeys, otherwise # gets shoved to column 0 :-/
21+
setlocal indentkeys=0{,0},!^F,o,O,0[,0]

syntax/nftables.vim

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
if polyglot#init#is_disabled(expand('<sfile>:p'), 'nftables', 'syntax/nftables.vim')
2+
finish
3+
endif
4+
5+
if exists('b:current_syntax')
6+
finish
7+
endif
8+
9+
syn match nftablesSet /{.*}/ contains=nftablesSetEntry
10+
syn match nftablesSetEntry /[a-zA-Z0-9]\+/ contained
11+
hi def link nftablesSet Keyword
12+
hi def link nftablesSetEntry Operator
13+
14+
syn match nftablesNumber "\<[0-9A-Fa-f./:]\+\>" contains=nftablesMask,nftablesDelimiter
15+
syn match nftablesHex "\<0x[0-9A-Fa-f]\+\>"
16+
syn match nftablesDelimiter "[./:]" contained
17+
syn match nftablesMask "/[0-9.]\+" contained contains=nftablesDelimiter
18+
hi def link nftablesNumber Number
19+
hi def link nftablesHex Number
20+
hi def link nftablesDelimiter Operator
21+
hi def link nftablesMask Operator
22+
23+
syn region Comment start=/#/ end=/$/
24+
syn region String start=/"/ end=/"/
25+
syn keyword Function flush
26+
syn keyword Function table chain map
27+
syn keyword Statement type hook
28+
syn keyword Type ip ip6 inet arp bridge
29+
syn keyword Type filter nat route
30+
syn keyword Type ether vlan arp ip icmp igmp ip6 icmpv6 tcp udp udplite sctp dccp ah esp comp icmpx
31+
syn keyword Type ct
32+
syn keyword Type length protocol priority mark iif iifname iiftype oif oifname oiftype skuid skgid rtclassid
33+
syn keyword Constant prerouting input forward output postrouting
34+
35+
syn keyword Special snat dnat masquerade redirect
36+
syn keyword Special accept drop reject queue
37+
syn keyword Keyword continue return jump goto
38+
syn keyword Keyword counter log limit
39+
syn keyword Keyword define
40+
41+
let b:current_syntax = 'nftables'

0 commit comments

Comments
 (0)