initial version

This commit is contained in:
Balakrishnan Balasubramanian 2022-10-26 21:57:54 -04:00
commit 9c5d746ec4
4 changed files with 75 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# logrotate vim plugin
Syntax and help for logrotate config files

3
ftdetect/logrotate.vim Normal file
View File

@ -0,0 +1,3 @@
au BufNewFile,BufRead */logrotate.d/*,logrotate.conf setfiletype logrotate

32
ftplugin/logrotate.vim Normal file
View File

@ -0,0 +1,32 @@
vim9script
# Vim filetype plugin file
# Language: confini
#
if exists("b:did_ftplugin")
finish
endif
b:did_ftplugin = 1
def LogrotateHelp(msg: string = expand("<cword>"))
const searchcmd =<< trim END
COLUMNS=80 man logrotate 2>/dev/null |
gawk '/^CONFIGURATION FILE DIRECTIVES/,/^SCRIPTS/' | gawk '
/^ {7}%s/,/^[a-z]/ {
if(firstLineDone) {
if(/^ {7}[^ ]/ || /^[A-Z]/)
exit
}
firstLineDone = 1
print(substr($0, 8))
}'
END
printf(join(searchcmd, "\n"), expand("<cword>"))
->systemlist()
->popup_atcursor({ "padding": [0, 1, 1, 1] })
enddef
command -nargs=1 LogRt :call LogrotateHelp(<f-args>)
b:undo_ftplugin = "setlocal commentstring< formatoptions< keywordprg<"
setlocal commentstring=#\ %s formatoptions-=t formatoptions+=croql keywordprg=:LogRt

37
syntax/logrotate.vim Normal file
View File

@ -0,0 +1,37 @@
" Vim syntax file
" Language: logrotate
" Quit if a syntax file was already loaded
if exists("b:current_syntax")
finish
endif
runtime! syntax/conf.vim
" syn keyword logRotateTodo contained TODO FIXME XXX
syn keyword logRotateKeyword addextension allowhardlink compress compresscmd
\ compressext compressoptions copy copytruncate create createolddir
\ daily dateext dateformat datehourago dateyesterday delaycompress
\ endscript extension firstaction hourly ifempty include lastaction
\ mail mailfirst maillast maxage maxsize minage minsize missingok
\ monthly noallowhardlink nocompress nocopy nocopytruncate nocreate
\ nocreateolddir nodateext nodelaycompress nomail nomissingok
\ noolddir norenamecopy nosharedscripts noshred notifempty olddir
\ postrotate preremove prerotate renamecopy rotate sharedscripts
\ shred shredcycles size start su tabooext taboopat uncompresscmd
\ weekly yearly
" String
" syn region logRotateString start=+"+ skip=+\\\\\|\\"+ end=+"+ oneline
" syn region logRotateString start=+'+ skip=+\\\\\|\\'+ end=+'+ oneline
" syn match logRotateComment "^#.*" contains=logRotateTodo,logRotateString,@Spell
" syn match logRotateComment "\s#.*"ms=s+1 contains=logRotateTodo,logRotateString,@Spell
hi def link logRotateKeyword Keyword
" hi def link logRotateString String
" hi def link logRotateComment Comment
" hi def link logRotateTodo Todo
let b:current_syntax = 'logrotate'