aboutsummaryrefslogtreecommitdiff
path: root/runtime/ftplugin/systemd.vim
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
commit931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch)
treed8c1843a95da5ea0bb4acc09f7e37843d9995c86 /runtime/ftplugin/systemd.vim
parent142d9041391780ac15b89886a54015fdc5c73995 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-userreg.tar.gz
rneovim-userreg.tar.bz2
rneovim-userreg.zip
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'runtime/ftplugin/systemd.vim')
-rw-r--r--runtime/ftplugin/systemd.vim54
1 files changed, 25 insertions, 29 deletions
diff --git a/runtime/ftplugin/systemd.vim b/runtime/ftplugin/systemd.vim
index 4c5c9a1dc1..8bcacdd381 100644
--- a/runtime/ftplugin/systemd.vim
+++ b/runtime/ftplugin/systemd.vim
@@ -1,41 +1,37 @@
" Vim filetype plugin file
" Language: systemd.unit(5)
" Keyword Lookup Support: Enno Nagel <enno.nagel+vim@gmail.com>
+" Latest Revision: 2023-10-07
if !exists('b:did_ftplugin')
" Looks a lot like dosini files.
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 SystemdKeywordPrg silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
+ elseif has('terminal')
+ command -buffer -nargs=1 SystemdKeywordPrg silent exe 'term ' . KeywordLookup_systemd(<q-args>)
+ endif
+ if exists(':SystemdKeywordPrg') == 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=:SystemdKeywordPrg
+ 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< | sil! delc -buffer SystemdKeywordPrg'
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