vim-logrotate/ftplugin/logrotate.vim

33 lines
896 B
VimL
Raw Normal View History

2022-10-26 21:57:54 -04:00
vim9script
# Vim filetype plugin file
2022-10-27 12:52:47 -04:00
# Language: logrotate
2022-10-26 21:57:54 -04:00
#
if exists("b:did_ftplugin")
finish
endif
b:did_ftplugin = 1
2022-10-27 12:52:47 -04:00
def LogrotateHelp(word: string)
2022-10-26 21:57:54 -04:00
const searchcmd =<< trim END
COLUMNS=80 man logrotate 2>/dev/null |
gawk '/^CONFIGURATION FILE DIRECTIVES/,/^SCRIPTS/' | gawk '
/^ {7}%s/,/^[a-z]/ {
if(firstLineDone) {
2022-10-27 11:05:01 -04:00
if(/^ {0,7}[^ ]/ && !/endscript/)
2022-10-26 21:57:54 -04:00
exit
}
firstLineDone = 1
print(substr($0, 8))
}'
END
2022-10-27 12:52:47 -04:00
printf(join(searchcmd, "\n"), word)
2022-10-26 21:57:54 -04:00
->systemlist()
->popup_atcursor({ "padding": [0, 1, 1, 1] })
enddef
command -nargs=1 LogRt :call LogrotateHelp(<f-args>)
2022-10-27 12:52:47 -04:00
b:undo_ftplugin = "setlocal comments< commentstring< formatoptions< keywordprg<"
2022-10-26 21:57:54 -04:00
2022-10-27 12:52:47 -04:00
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql keywordprg=:LogRt