diff --git a/ftplugin/logrotate.vim b/ftplugin/logrotate.vim index f20d654..3edfd79 100644 --- a/ftplugin/logrotate.vim +++ b/ftplugin/logrotate.vim @@ -17,18 +17,20 @@ else awkcmd = "gawk" endif # Have to use gawk, default awk (mawk) does not support {0,7} syntax -if executable(awkcmd) +if awkcmd != "disable" && executable(awkcmd) def LogrotateHelp(word: string) const searchcmd =<< trim eval END + echo "<=== man logrotate ===>" COLUMNS=80 man logrotate 2>/dev/null | {awkcmd} '/^CONFIGURATION FILE DIRECTIVES/,/^SCRIPTS/' | {awkcmd} ' - /^ {{7}}%s/,false {{ + /^ {{7}}{word}/,false {{ if(firstLineDone && /^ {{0,7}}[^ ]/ && !/endscript/) exit firstLineDone = 1 print(substr($0, 8)) }}' END - printf(join(searchcmd, "\n"), word) + searchcmd + ->join("\n") ->systemlist() ->popup_atcursor({ "padding": [0, 1, 1, 1] }) enddef diff --git a/syntax/logrotate.vim b/syntax/logrotate.vim index 756adbd..cf12f40 100644 --- a/syntax/logrotate.vim +++ b/syntax/logrotate.vim @@ -8,6 +8,10 @@ endif syntax include @logRotateSh syntax/sh.vim unlet b:current_syntax +" FIXME: +" Whitespace is not required in actual config, +" But vim syntax region does not work if start pattern is also a keyword +" Hence added \s* below syntax region logRotateScript matchgroup=logRotateKeyword start="\s*\<\%(firstaction\|lastaction\|prerotate\|postrotate\|preremove\)\>" end="\" contains=@logRotateSh " for comments, todo, string