cleanup and add FIXME

This commit is contained in:
Balakrishnan Balasubramanian 2022-10-27 17:07:37 -04:00
parent 23f344fb75
commit 714801b466
2 changed files with 9 additions and 3 deletions

View File

@ -17,18 +17,20 @@ else
awkcmd = "gawk" awkcmd = "gawk"
endif endif
# Have to use gawk, default awk (mawk) does not support {0,7} syntax # 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) def LogrotateHelp(word: string)
const searchcmd =<< trim eval END const searchcmd =<< trim eval END
echo "<=== man logrotate ===>"
COLUMNS=80 man logrotate 2>/dev/null | COLUMNS=80 man logrotate 2>/dev/null |
{awkcmd} '/^CONFIGURATION FILE DIRECTIVES/,/^SCRIPTS/' | {awkcmd} ' {awkcmd} '/^CONFIGURATION FILE DIRECTIVES/,/^SCRIPTS/' | {awkcmd} '
/^ {{7}}%s/,false {{ /^ {{7}}{word}/,false {{
if(firstLineDone && /^ {{0,7}}[^ ]/ && !/endscript/) exit if(firstLineDone && /^ {{0,7}}[^ ]/ && !/endscript/) exit
firstLineDone = 1 firstLineDone = 1
print(substr($0, 8)) print(substr($0, 8))
}}' }}'
END END
printf(join(searchcmd, "\n"), word) searchcmd
->join("\n")
->systemlist() ->systemlist()
->popup_atcursor({ "padding": [0, 1, 1, 1] }) ->popup_atcursor({ "padding": [0, 1, 1, 1] })
enddef enddef

View File

@ -8,6 +8,10 @@ endif
syntax include @logRotateSh syntax/sh.vim syntax include @logRotateSh syntax/sh.vim
unlet b:current_syntax 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="\<endscript\>" contains=@logRotateSh syntax region logRotateScript matchgroup=logRotateKeyword start="\s*\<\%(firstaction\|lastaction\|prerotate\|postrotate\|preremove\)\>" end="\<endscript\>" contains=@logRotateSh
" for comments, todo, string " for comments, todo, string