aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@users.noreply.github.com>2022-03-25 22:38:01 -0400
committertdro <tdro@users.noreply.github.com>2022-03-25 22:40:31 -0400
commit82201e8e77cbfbe79ad6be22e61f0d49861bf0de (patch)
treeb878ec706e162df9b8ae82a2a874919cb382445f
parentb4ef5c68aca627f73fd799f079f7aa7f13796b1b (diff)
downloaddotfiles-82201e8e77cbfbe79ad6be22e61f0d49861bf0de.tar.gz
dotfiles-82201e8e77cbfbe79ad6be22e61f0d49861bf0de.tar.bz2
dotfiles-82201e8e77cbfbe79ad6be22e61f0d49861bf0de.zip
.vim/vimrc: Check doas and nftable files
Add nftables syntax highlighting.
-rw-r--r--.vim/syntax/nftables.vim32
-rw-r--r--.vim/vimrc6
2 files changed, 37 insertions, 1 deletions
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 <buffer> 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 <buffer> <leader>df :exe ':term ++rows=10 go doc ' . expand('<cexpr>')<cr>
@@ -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()