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 13:53:24 -04:00
|
|
|
b:undo_ftplugin = "setlocal comments< commentstring< formatoptions< omnifunc<"
|
2022-10-26 21:57:54 -04:00
|
|
|
|
2022-10-27 13:53:24 -04:00
|
|
|
var awkcmd: string
|
2022-10-26 21:57:54 -04:00
|
|
|
|
2022-10-27 13:53:24 -04:00
|
|
|
if exists("g:logrotate_awk")
|
|
|
|
awkcmd = g:logrotate_awk
|
|
|
|
else
|
|
|
|
awkcmd = "gawk"
|
|
|
|
endif
|
|
|
|
# Have to use gawk, default awk (mawk) does not support {0,7} syntax
|
2022-10-27 17:07:37 -04:00
|
|
|
if awkcmd != "disable" && executable(awkcmd)
|
2022-10-27 13:53:24 -04:00
|
|
|
def LogrotateHelp(word: string)
|
|
|
|
const searchcmd =<< trim eval END
|
2022-10-27 17:07:37 -04:00
|
|
|
echo "<=== man logrotate ===>"
|
2022-10-27 13:53:24 -04:00
|
|
|
COLUMNS=80 man logrotate 2>/dev/null |
|
|
|
|
{awkcmd} '/^CONFIGURATION FILE DIRECTIVES/,/^SCRIPTS/' | {awkcmd} '
|
2022-10-27 17:07:37 -04:00
|
|
|
/^ {{7}}{word}/,false {{
|
2022-10-27 13:53:24 -04:00
|
|
|
if(firstLineDone && /^ {{0,7}}[^ ]/ && !/endscript/) exit
|
|
|
|
firstLineDone = 1
|
|
|
|
print(substr($0, 8))
|
|
|
|
}}'
|
|
|
|
END
|
2022-10-27 17:07:37 -04:00
|
|
|
searchcmd
|
|
|
|
->join("\n")
|
2022-10-27 13:53:24 -04:00
|
|
|
->systemlist()
|
|
|
|
->popup_atcursor({ "padding": [0, 1, 1, 1] })
|
|
|
|
enddef
|
|
|
|
|
|
|
|
command -nargs=1 LogRotateHelpCmd :call LogrotateHelp(<f-args>)
|
|
|
|
setlocal keywordprg=:LogRotateHelpCmd
|
|
|
|
b:undo_ftplugin = b:undo_ftplugin .. " keywordprg<"
|
|
|
|
endif
|
2022-10-26 21:57:54 -04:00
|
|
|
|
2022-10-27 13:53:24 -04:00
|
|
|
setlocal omnifunc=syntaxcomplete#Complete
|
|
|
|
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
|