Add documentation

This commit is contained in:
Balakrishnan Balasubramanian 2022-12-30 23:11:32 -05:00
parent 28a044cad4
commit 97993040d3
5 changed files with 70 additions and 6 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tags

View File

@ -1,3 +1,14 @@
# logrotate vim plugin
# vim-logrotate
Syntax and help for logrotate config files
Syntax and help for logrotate config files in /etc/logrotate.d/*
# Install
mkdir -p ~/.vim/pack/gitpacks/start/
git clone https://github.com/balki/vim-logrotate
vim +":helptags ALL" +"qa"
# Requirements
1. Vim installation that includes patch-8.2.4770. (Works in Ubuntu 22.10)
2. [gawk](https://www.gnu.org/software/gawk/manual/gawk.html) installed. See `g:logrotate_awk` config option to use a different awk

52
doc/vim-logrotate.txt Normal file
View File

@ -0,0 +1,52 @@
*vim-logrotate.txt* Syntax and help plugin for logrotate files
*vim-logrotate*
==============================================================================
CONTENTS *vim-logrotate-contents*
Features |vim-logrotate-features|
LogRotateHelp |:LogRotateHelp|
g:logrotate_awk |g:logrotate_awk|
==============================================================================
Features *vim-logrotate-features*
1. Detect and enable syntax-highlighting for logrotate files
2. Sets 'omnifunc' to complete logrotate directives
3. Sets 'keywordprg' to show help for logrotate directives
:LogRotateHelp {directive} *:LogRotateHelp*
Shows the help for the directive in a popup window at cursor. Help text is
extracted from the logrotate manual page (man logrotate).
`:LogRotateHelp` is only enabled if
1. Vim installation includes patch-8.2.4770
2. An "awk" command is available that supports ranges in regular expression.
(like "\d{1,4}"). Set |g:logrotate_awk| to use a different awk command.
'keywordprg' is set so |K| works on directives. A different mapping can be set
as shown below >
nmap <silent><leader>k :exe ':LogRotateHelp ' .. expand("<cword>")<CR>
<
g:logrotate_awk *g:logrotate_awk*
Type: |String|
Default: "gawk"
Set a different awk command to parse man page.
E.g. "goawk" (https://github.com/benhoyt/goawk)
Set to "disable" to disable help feature
Example: >
let g:logrotate_awk = "goawk"
<
vim: ft=help tw=78 et ts=2 sw=2 sts=2 norl

View File

@ -18,10 +18,10 @@ else
awkcmd = "gawk"
endif
if awkcmd != "disable" && executable(awkcmd)
if has("patch-8.2.4770") && awkcmd != "disable" && executable(awkcmd)
command -nargs=1 LogRotateHelpCmd :call g:logrotate#LogrotateHelp(awkcmd, <f-args>)
setlocal keywordprg=:LogRotateHelpCmd
command -nargs=1 LogRotateHelp :call g:logrotate#LogrotateHelp(awkcmd, <f-args>)
setlocal keywordprg=:LogRotateHelp
b:undo_ftplugin = b:undo_ftplugin .. " keywordprg<"
endif

View File

@ -17,7 +17,7 @@ syntax region logRotateScript matchgroup=logRotateKeyword start="\s*\<\%(firstac
" for comments, todo, string
runtime! syntax/conf.vim
syntax keyword logRotateKeyword addextension allowhardlink compress compresscmd
syntax keyword logRotateKeyword addextension allowhardlink compress compresscmd
\ compressext compressoptions copy copytruncate create createolddir
\ daily dateext dateformat datehourago dateyesterday delaycompress
\ endscript extension firstaction hourly ifempty include lastaction