blob: 44e70bc224718abf33d6a28b687e048987db8eab [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>
Konfektf86568f2024-09-19 19:34:40 +02004" Latest Revision: 2024-09-19 (simplify keywordprg #15696)
Bram Moolenaar60cce2f2015-10-13 23:21:27 +02005
Enno5036e692023-10-18 11:38:19 +02006if exists("b:did_ftplugin")
7 finish
Bram Moolenaar60cce2f2015-10-13 23:21:27 +02008endif
Enno5036e692023-10-18 11:38:19 +02009" Looks a lot like dosini files.
10runtime! ftplugin/dosini.vim
Bram Moolenaar2c7f8c52020-04-20 19:52:53 +020011
Konfektf86568f2024-09-19 19:34:40 +020012if has('unix') && executable('less') && exists(':terminal') == 2
13 command -buffer -nargs=1 SystemdKeywordPrg silent exe 'term ' . KeywordLookup_systemd(<q-args>)
14 silent! function KeywordLookup_systemd(keyword) abort
15 let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')
16 if len(matches) > 1
17 let section = matches[1]
18 return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
Enno2f25e402023-08-23 21:27:50 +020019 else
Konfektf86568f2024-09-19 19:34:40 +020020 return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'
Enno2f25e402023-08-23 21:27:50 +020021 endif
Konfektf86568f2024-09-19 19:34:40 +020022 endfunction
23 setlocal iskeyword+=-
24 setlocal keywordprg=:SystemdKeywordPrg
25 if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)
26 let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<'
27 else
28 let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer SystemdKeywordPrg'
Enno2f25e402023-08-23 21:27:50 +020029 endif
Bram Moolenaar2c7f8c52020-04-20 19:52:53 +020030endif