dist: Add vim syntax highlighting file

Closes #139.
This commit is contained in:
fox.cpp 2019-09-21 20:09:34 +03:00
parent 2d0740d82b
commit b292159dcf
No known key found for this signature in database
GPG key ID: E76D97CCEDE90B6C
4 changed files with 132 additions and 0 deletions

8
dist/README.md vendored
View file

@ -1,5 +1,8 @@
# Distribution files for maddy
**Disclaimer:** Most of the files here are maintained in a "best-effort" way.
That is, they may break or become outdated from time to time. Caveat emptor.
## systemd unit
`maddy.service` launches using default config path (/etc/maddy/maddy.conf).
@ -26,3 +29,8 @@ See https://github.com/foxcpp/maddy/wiki/fail2ban-configuration for details.
## logrotate configuration
Meant for logs rotation when logging to file is used.
## vim ftdetect/ftplugin/syntax files
Minimal supplement to make configuration files more readable and help you see
typos in directive names.

1
dist/vim/ftdetect/maddy-conf.vim vendored Normal file
View file

@ -0,0 +1 @@
au BufNewFile,BufRead /etc/maddy/*,maddy.conf setf maddy-conf

8
dist/vim/ftplugin/maddy-conf.vim vendored Normal file
View file

@ -0,0 +1,8 @@
setlocal commentstring=#\ %s
" That is convention for maddy configs. Period.
" - fox.cpp (maddy developer)
setlocal expandtab
setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4

115
dist/vim/syntax/maddy-conf.vim vendored Normal file
View file

@ -0,0 +1,115 @@
" vim: noexpandtab ts=4 sw=4
if exists("b:current_syntax")
finish
endif
" Lexer-defined rules
syn match maddyComment "#.*"
syn region maddyString start=+"+ skip=+\\\\\|\\"+ end=+"+ oneline
syn region maddyBlock start="{" end="}" transparent fold
hi def link maddyComment Comment
hi def link maddyString String
" Parser-defined rules
syn match maddyMacroName "[a-z0-9_]" contained containedin=maddyMacro
syn match maddyMacro "$(.\{-})" contains=maddyMacroName
syn match maddyMacroDefSign "=" contained
syn match maddyMacroDef "\^$([a-z0-9_]\{-})\s=\s.\+" contains=maddyMacro,maddyMacroDefSign
hi def link maddyMacroName Identifier
hi def link maddyMacro Special
hi def link maddyMacroDefSign Special
" config.Map values
syn keyword maddyBool yes no
syn match maddyInt '\<\d\+\>'
syn match maddyInt '\<[-+]\d\+\>'
syn match maddyFloat '\<[-+]\d\+\.\d*\<'
hi def link maddyBool Boolean
hi def link maddyInt Number
hi def link maddyFloat Float
" Module values
" grep --no-file -E 'Register.*\(".+", ' **.go | sed -E 's/.+Register.*\("([^"]+)", .+/\1/' | sort -u
syn keyword maddyModule
\ dummy
\ extauth
\ imap
\ pam
\ queue
\ remote
\ replace_rcpt
\ replace_sender
\ require_matching_ehlo
\ require_matching_rdns
\ require_mx_record
\ shadow
\ smtp
\ sql
\ submission
\ test_check
\ test_modifier
\ verify_dkim
syn keyword maddyDispatchDir
\ check
\ modify
\ default_source
\ source
\ default_destination
\ destination
\ reject
\ deliver_to
" grep --no-file -E 'cfg..+\(".+", ' **.go | sed -E 's/.+cfg..+\("([^"]+)", .+/\1/' | sort -u
syn keyword maddyModDir
\ appendlimit
\ auth
\ auth_domains
\ auth_perdomain
\ autogenerated_msg_domain
\ bounce
\ broken_sig_action
\ debug
\ defer_sender_reject
\ driver
\ dsn
\ fail_action
\ fsstore
\ helper
\ hostname
\ insecure_auth
\ io_debug
\ junk_mailbox
\ location
\ max_message_size
\ max_parallelism
\ max_recipients
\ max_tries
\ mtasts_cache
\ no_sig_action
\ read_timeout
\ require_tls
\ sqlite3_busy_timeout
\ sqlite3_cache_size
\ sqlite3_exclusive_lock
\ storage
\ storage_perdomain
\ submission
\ target
\ tls
\ use_helper
\ write_timeout
hi def link maddyModDir Identifier
hi def link maddyModule Identifier
hi def link maddyDispatchDir Identifier
let b:current_syntax = "maddy"