blob: c0bc6302f28c29daf5b2bb31a9ef15df2bc0d45a [file] [log] [blame]
Bram Moolenaar60cce2f2015-10-13 23:21:27 +02001" Vim filetype plugin file
Bram Moolenaar2c7f8c52020-04-20 19:52:53 +02002" Language: systemd.unit(5)
3" Keyword Lookup Support: Enno Nagel <enno.nagel+vim@gmail.com>
Bram Moolenaar60cce2f2015-10-13 23:21:27 +02004
5if !exists('b:did_ftplugin')
6 " Looks a lot like dosini files.
7 runtime! ftplugin/dosini.vim
8endif
Bram Moolenaar2c7f8c52020-04-20 19:52:53 +02009
Enno2f25e402023-08-23 21:27:50 +020010if has('unix') && executable('less')
11 if !has('gui_running')
12 command -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
13 elseif has('terminal')
14 command -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>)
15 endif
16 if exists(':Sman') == 2
17 if !exists('*KeywordLookup_systemd')
18 function KeywordLookup_systemd(keyword) abort
19 let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')
20 if len(matches) > 1
21 let section = matches[1]
22 return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
23 else
24 return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'
25 endif
26 endfunction
Bram Moolenaar2c7f8c52020-04-20 19:52:53 +020027 endif
Enno2f25e402023-08-23 21:27:50 +020028 setlocal iskeyword+=-
29 setlocal keywordprg=:Sman
30 if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)
31 let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<'
32 else
33 let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
34 endif
35 endif
Bram Moolenaar2c7f8c52020-04-20 19:52:53 +020036endif