blob: 1b1d242029a7da9d930f9f4e8399afc86d7eca00 [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>
Konfektf416a222024-10-02 19:28:44 +02004" Latest Revision: 2024-10-02 (small fixes to &keywordprg)
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
Konfektf416a222024-10-02 19:28:44 +020013 command! -buffer -nargs=1 SystemdKeywordPrg silent exe 'term ++close ' KeywordLookup_systemd(<q-args>)
Konfektf86568f2024-09-19 19:34:40 +020014 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]
Konfektf416a222024-10-02 19:28:44 +020018 return 'env LESS= MANPAGER="less --pattern=''(^|,)\\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
Enno2f25e402023-08-23 21:27:50 +020019 else
Konfektf416a222024-10-02 19:28:44 +020020 return 'env 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)
Konfektf416a222024-10-02 19:28:44 +020026 let b:undo_ftplugin = 'setlocal keywordprg< iskeyword< | sil! delc -buffer SystemdKeywordPrg'
Konfektf86568f2024-09-19 19:34:40 +020027 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