From 82201e8e77cbfbe79ad6be22e61f0d49861bf0de Mon Sep 17 00:00:00 2001 From: tdro Date: Fri, 25 Mar 2022 22:38:01 -0400 Subject: .vim/vimrc: Check doas and nftable files Add nftables syntax highlighting. --- .vim/syntax/nftables.vim | 32 ++++++++++++++++++++++++++++++++ .vim/vimrc | 6 +++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .vim/syntax/nftables.vim diff --git a/.vim/syntax/nftables.vim b/.vim/syntax/nftables.vim new file mode 100644 index 0000000..8a6bc90 --- /dev/null +++ b/.vim/syntax/nftables.vim @@ -0,0 +1,32 @@ +" https://github.com/nfnty/vim-nftables +" License: MIT Copyright (c) 2015 nfnty + +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 Statement +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 table tcp udp +syn keyword Statement drop reject log limit +syn keyword Type accept +syn keyword Constant prerouting input forward output postrouting +syn keyword Special snat dnat masquerade queue +syn keyword Keyword continue return goto +syn keyword Keyword define + +let b:current_syntax = 'nftables' diff --git a/.vim/vimrc b/.vim/vimrc index dd0883a..d48c16a 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -303,13 +303,15 @@ augroup AutoCommands autocmd FileType sql autocmd! BufWritePost exe 'Notify(''sqlint ' . expand('%') . ' 2>&1 && pg_format -i ' . expand('%') . ' 2>&1 && sqlfluff lint --exclude-rules L003,L016 --dialect postgres ' . expand('%') . ' 2>&1 && printf "SQL OK: ' . expand('%') . '"'')' | :e " Linting extension post write commands. + autocmd BufWritePost *.txt,*.md :only | :term ++rows=10 vale % autocmd BufWritePost $HOME/.config/chromexup/config.ini exe 'Notify(''chromexup 2>&1'')' autocmd BufWritePost rc.lua exe 'Notify(''awesome -k 2>&1'')' autocmd BufWritePost quotes,*.fortune exe 'Notify(''strfile ' . expand('%') . ''')' + autocmd BufWritePost *.doas exe 'Notify(''doas -C ' . expand('%') . ' 2>&1 && printf "doas OK: ' . expand('%') . '"'')' autocmd BufWritePost Xresources exe 'Notify(''xrdb ~/.config/X11/Xresources ' . '2>&1 && printf "Reloading Xresources: ' . expand('%') . '"'')' + autocmd BufWritePost *.nft exe 'Notify(''doas nft --check --file ' . expand('%') . ' 2>&1 && printf "nftables OK: ' . expand('%') . '"'')' autocmd BufWritePost *.desktop exe 'Notify(''desktop-file-validate ' . expand('%') . ' 2>&1 && printf "Deskop File OK: ' . expand('%') . '"'')' autocmd BufWritePost *.service exe 'Notify(''systemd-analyze verify --user ' . expand('%') . ' 2>&1 && printf "Systemd Service File OK: ' . expand('%') . '"'')' - autocmd BufWritePost *.txt,*.md :only | :term ++rows=10 vale % " File type function under cursor lookups. autocmd FileType go noremap df :exe ':term ++rows=10 go doc ' . expand('') @@ -340,6 +342,8 @@ augroup AutoCommands " Set file types. autocmd BufRead,BufNewFile *.nims set filetype=nim autocmd BufRead,BufNewFile *.rasi set filetype=css + autocmd BufRead,BufNewFile *.doas set filetype=conf + autocmd BufRead,BufNewFile *.nft set filetype=nftables " Clear notification on cursor movement. autocmd CursorMoved * silent! call popup_clear() -- cgit v1.2.3