aboutsummaryrefslogtreecommitdiff
path: root/runtime/ftplugin/systemd.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/ftplugin/systemd.vim')
-rw-r--r--runtime/ftplugin/systemd.vim53
1 files changed, 24 insertions, 29 deletions
diff --git a/runtime/ftplugin/systemd.vim b/runtime/ftplugin/systemd.vim
index 4c5c9a1dc1..c0bc6302f2 100644
--- a/runtime/ftplugin/systemd.vim
+++ b/runtime/ftplugin/systemd.vim
@@ -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