From 9eb422ba89a60bc662659ac34456e8995e13d6f7 Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Thu, 27 Oct 2022 12:52:47 -0400 Subject: [PATCH] embed script has syntax highlight --- ftplugin/logrotate.vim | 10 +++++----- syntax/logrotate.vim | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ftplugin/logrotate.vim b/ftplugin/logrotate.vim index e197b4d..120a705 100644 --- a/ftplugin/logrotate.vim +++ b/ftplugin/logrotate.vim @@ -1,13 +1,13 @@ vim9script # Vim filetype plugin file -# Language: confini +# Language: logrotate # if exists("b:did_ftplugin") finish endif b:did_ftplugin = 1 -def LogrotateHelp(msg: string = expand("")) +def LogrotateHelp(word: string) const searchcmd =<< trim END COLUMNS=80 man logrotate 2>/dev/null | gawk '/^CONFIGURATION FILE DIRECTIVES/,/^SCRIPTS/' | gawk ' @@ -20,13 +20,13 @@ def LogrotateHelp(msg: string = expand("")) print(substr($0, 8)) }' END - printf(join(searchcmd, "\n"), expand("")) + printf(join(searchcmd, "\n"), word) ->systemlist() ->popup_atcursor({ "padding": [0, 1, 1, 1] }) enddef command -nargs=1 LogRt :call LogrotateHelp() -b:undo_ftplugin = "setlocal commentstring< formatoptions< keywordprg<" +b:undo_ftplugin = "setlocal comments< commentstring< formatoptions< keywordprg<" -setlocal commentstring=#\ %s formatoptions-=t formatoptions+=croql keywordprg=:LogRt +setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql keywordprg=:LogRt diff --git a/syntax/logrotate.vim b/syntax/logrotate.vim index 6be84ba..7819e2c 100644 --- a/syntax/logrotate.vim +++ b/syntax/logrotate.vim @@ -6,11 +6,10 @@ if exists("b:current_syntax") finish endif -syn region logRotateScript matchgroup=logRotateKeyword start="\s*\" end="\" contains=NONE -syn region logRotateScript matchgroup=logRotateKeyword start="\s*\" end="\" contains=NONE -syn region logRotateScript matchgroup=logRotateKeyword start="\s*\" end="\" contains=NONE -syn region logRotateScript matchgroup=logRotateKeyword start="\s*\" end="\" contains=NONE -syn region logRotateScript matchgroup=logRotateKeyword start="\s*\" end="\" contains=NONE +syn include @logRotateSh syntax/sh.vim +unlet b:current_syntax + +syn region logRotateScript matchgroup=logRotateKeyword start="\s*\<\%(firstaction\|lastaction\|prerotate\|postrotate\|preremove\)\>" end="\" contains=@logRotateSh runtime! syntax/conf.vim @@ -40,6 +39,6 @@ hi def link logRotateKeyword Keyword " hi def link logRotateComment Comment " hi def link logRotateTodo Todo -hi def link logRotateScript Function +" hi def link logRotateScript Function let b:current_syntax = 'logrotate'