vim-patch:2f25e40b1f54

runtime: configure keywordpg for some file types (vim/vim#5566)

2f25e40b1f

Co-authored-by: Enno <Konfekt@users.noreply.github.com>
This commit is contained in:
Christian Clason 2023-08-24 09:08:24 +09:00
parent 327e3fab9e
commit e2c10dea19
9 changed files with 155 additions and 35 deletions

View File

@ -15,5 +15,22 @@ let b:undo_ftplugin = "setl com< cms< fo<"
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s+--' . <q-args> . '\b'' --hilite-search" man ' . 'gpg' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
\ silent exe ':term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s+--' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'gpg'
endif
if exists(':Sman') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
endif
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@ -16,5 +16,21 @@ let b:undo_ftplugin = "setl com< cms< inc< fo<"
setlocal comments=:# commentstring=#\ %s include=^\\s*include setlocal comments=:# commentstring=#\ %s include=^\\s*include
setlocal formatoptions-=t formatoptions+=croql setlocal formatoptions-=t formatoptions+=croql
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s{,8}' . <q-args> . '\b'' --hilite-search" man ' . 'modprobe.d' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
\ silent exe ':term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s{,8}' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'modprobe.d'
endif
if exists(':Sman') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
endif
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@ -18,5 +18,21 @@ setlocal formatoptions-=t formatoptions+=croql
let &l:include = '^\s*source\>' let &l:include = '^\s*source\>'
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s+' . <q-args> . '\b'' --hilite-search" man ' . 'muttrc' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
\ silent exe 'term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s+' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'muttrc'
endif
if exists(':Sman') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
endif
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@ -30,6 +30,22 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:undo_ftplugin ..= " | unlet! b:browsefilter" let b:undo_ftplugin ..= " | unlet! b:browsefilter"
endif endif
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s+' . <q-args> . '\b'' --hilite-search" man ' . '3 readline' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
\ silent exe 'term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s+' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . '3 readline'
endif
if exists(':Sman') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
endif
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@ -41,6 +41,19 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:undo_ftplugin ..= " | unlet! b:browsefilter" let b:undo_ftplugin ..= " | unlet! b:browsefilter"
endif endif
if (exists('b:is_bash') && (b:is_bash == 1)) ||
\ (exists('b:is_sh') && (b:is_sh == 1))
if !has('gui_running') && executable('less')
command! -buffer -nargs=1 Help silent exe '!bash -c "{ help "<args>" 2>/dev/null || man "<args>"; } | LESS= less"' | redraw!
elseif has('terminal')
command! -buffer -nargs=1 Help silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""'
else
command! -buffer -nargs=1 Help echo system('bash -c "help <args>" 2>/dev/null || man "<args>"')
endif
setlocal keywordprg=:Help
let b:undo_ftplugin .= '| setlocal keywordprg<'
endif
" Restore the saved compatibility options. " Restore the saved compatibility options.
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo

View File

@ -1,7 +1,7 @@
" Vim filetype plugin file " Vim filetype plugin file
" Language: OpenSSH client configuration file " Language: OpenSSH client configuration file
" Previous Maintainer: Nikolai Weibull <now@bitwi.se> " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2008-07-09 " Latest Revision: 2008-07-09
if exists("b:did_ftplugin") if exists("b:did_ftplugin")
finish finish
@ -11,9 +11,24 @@ let b:did_ftplugin = 1
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
let b:undo_ftplugin = "setl com< cms< fo<"
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
let b:undo_ftplugin = 'setlocal com< cms< fo<'
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s+' . <q-args> . '$'' --hilite-search" man ' . 'ssh_config' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
\ silent exe 'term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s+' . <q-args> . '$', '\') . ''' --hilite-search" man ' . 'ssh_config'
endif
if exists(':Sman') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
endif
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@ -15,5 +15,21 @@ let b:undo_ftplugin = "setl com< cms< fo<"
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''\b' . <q-args> . '\b'' --hilite-search" man ' . 'sudoers' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
\ silent exe ':term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('\b' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'sudoers'
endif
if exists(':Sman') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
endif
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@ -7,35 +7,30 @@ if !exists('b:did_ftplugin')
runtime! ftplugin/dosini.vim runtime! ftplugin/dosini.vim
endif endif
if !has('unix') if has('unix') && executable('less')
finish if !has('gui_running')
endif command -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
elseif has('terminal')
if !has('gui_running') command -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>)
command! -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw! endif
elseif has('terminal') if exists(':Sman') == 2
command! -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>) if !exists('*KeywordLookup_systemd')
else function KeywordLookup_systemd(keyword) abort
finish let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')
endif if len(matches) > 1
let section = matches[1]
if !exists('*KeywordLookup_systemd') return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
function KeywordLookup_systemd(keyword) abort else
let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$') return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'
if len(matches) > 1 endif
let section = matches[1] endfunction
return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
else
return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'
endif endif
endfunction setlocal iskeyword+=-
endif setlocal keywordprg=:Sman
if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)
setlocal iskeyword+=- let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<'
setlocal keywordprg=:Sman else
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin) endif
let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<' endif
else
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
endif endif

View File

@ -15,5 +15,21 @@ let b:undo_ftplugin = "setl com< cms< fo<"
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s{,8}' . <q-args> . '\b'' --hilite-search" man ' . 'udev' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
\ silent exe ':term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s{,8}' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'udev'
endif
if exists(':Sman') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
endif
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save