]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime: configure keywordpg for some file types (#5566)
authorEnno <Konfekt@users.noreply.github.com>
Wed, 23 Aug 2023 19:27:50 +0000 (21:27 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Aug 2023 19:27:50 +0000 (21:27 +0200)
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/ftplugin/gpg.vim
runtime/ftplugin/modconf.vim
runtime/ftplugin/muttrc.vim
runtime/ftplugin/readline.vim
runtime/ftplugin/sh.vim
runtime/ftplugin/sshconfig.vim
runtime/ftplugin/sudoers.vim
runtime/ftplugin/systemd.vim
runtime/ftplugin/udevrules.vim

index 3f890e58f67b2451ec25c169783767826a00fe13..9e00daed6a54d12495fc759ee39705307d9b8728 100644 (file)
@@ -15,5 +15,22 @@ let b:undo_ftplugin = "setl com< cms< fo<"
 
 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
 unlet s:cpo_save
+
index c8e76b538b22729f13cb82281be7a2e159505379..09ad54b64ab25a7c5f7f675f1ef4b141f5a01f21 100644 (file)
@@ -16,5 +16,21 @@ let b:undo_ftplugin = "setl com< cms< inc< fo<"
 setlocal comments=:# commentstring=#\ %s include=^\\s*include
 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
 unlet s:cpo_save
index c8ad0f2ec5c1099a01dcd71af88c24b4dcc59c92..bd01367158da4807c4fd9468e433b5bf0658cd14 100644 (file)
@@ -18,5 +18,21 @@ setlocal formatoptions-=t formatoptions+=croql
 
 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
 unlet s:cpo_save
index 524eeb736add0ce1929975e430f3889c140b3ea5..c81d0f2f65dadf5f24111bf5abd91450a6f8b3af 100644 (file)
@@ -30,6 +30,22 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
   let b:undo_ftplugin ..= " | unlet! b:browsefilter"
 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
 unlet s:cpo_save
 
index b6fdb8f3e2eb585338ffab3bedd21b440016eb62..7106bf91556abfc9d70423929358686b647c0618 100644 (file)
@@ -41,6 +41,19 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
   let b:undo_ftplugin ..= " | unlet! b:browsefilter"
 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.
 let &cpo = s:save_cpo
 unlet s:save_cpo
index d933ce052788947eb2263186b95686d2f352dbda..214e4928a0c126aec782bd559eb25704dc45af00 100644 (file)
@@ -1,7 +1,7 @@
 " Vim filetype plugin file
-" Language:             OpenSSH client configuration file
-" Previous Maintainer:  Nikolai Weibull <now@bitwi.se>
-" Latest Revision:      2008-07-09
+" Language:         OpenSSH client configuration file
+" Previous Maintainer:       Nikolai Weibull <now@bitwi.se>
+" Latest Revision:  2008-07-09
 
 if exists("b:did_ftplugin")
   finish
@@ -11,9 +11,24 @@ let b:did_ftplugin = 1
 let s:cpo_save = &cpo
 set cpo&vim
 
-let b:undo_ftplugin = "setl com< cms< fo<"
-
 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
 unlet s:cpo_save
index 38dbf559ee7c7fe6224c7b640715ac8fa77eedc8..65cf2d82039be58f307d8766d38b9d378dd2bf3d 100644 (file)
@@ -15,5 +15,21 @@ let b:undo_ftplugin = "setl com< cms< fo<"
 
 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
 unlet s:cpo_save
index 4c5c9a1dc166191cd2aa17dd62e7ba3e1ad6ce13..c0bc6302f28c29daf5b2bb31a9ef15df2bc0d45a 100644 (file)
@@ -7,35 +7,30 @@ if !exists('b:did_ftplugin')
   runtime! ftplugin/dosini.vim
 endif
 
-if !has('unix')
-  finish
-endif
-
-if !has('gui_running')
-  command! -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
-elseif has('terminal')
-  command! -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>)
-else
-  finish
-endif
-
-if !exists('*KeywordLookup_systemd')
-  function KeywordLookup_systemd(keyword) abort
-    let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')
-    if len(matches) > 1
-      let section = matches[1]
-      return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
+if has('unix') && executable('less')
+  if !has('gui_running')
+    command -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
+  elseif has('terminal')
+    command -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>)
+  endif
+  if exists(':Sman') == 2
+    if !exists('*KeywordLookup_systemd')
+      function KeywordLookup_systemd(keyword) abort
+        let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')
+        if len(matches) > 1
+          let section = matches[1]
+          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
+      endfunction
+    endif
+    setlocal iskeyword+=-
+    setlocal keywordprg=:Sman
+    if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)
+      let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<'
     else
-      return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'
+      let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
     endif
-  endfunction
-endif
-
-setlocal iskeyword+=-
-setlocal keywordprg=:Sman
-
-if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)
-  let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<'
-else
-  let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
+  endif
 endif
index 6404f6c85e4c4637239435de479d923208b6d798..bde9c5dfa0d9459049f8b2fe7ce541ef6f1d67f0 100644 (file)
@@ -15,5 +15,21 @@ let b:undo_ftplugin = "setl com< cms< fo<"
 
 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
 unlet s:cpo_save