xref: /vim-8.2.3635/runtime/ftplugin/systemd.vim (revision beae4084)
1" Vim filetype plugin file
2" Language:			systemd.unit(5)
3" Keyword Lookup Support:	Enno Nagel <enno.nagel[email protected]>
4
5if !exists('b:did_ftplugin')
6  " Looks a lot like dosini files.
7  runtime! ftplugin/dosini.vim
8endif
9
10if !has('unix')
11  finish
12endif
13
14if !has('gui_running')
15  command! -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
16elseif has('terminal')
17  command! -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>)
18else
19  finish
20endif
21
22if !exists('*KeywordLookup_systemd')
23  function KeywordLookup_systemd(keyword) abort
24    let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')
25    if len(matches) > 1
26      let section = matches[1]
27      return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
28    else
29      return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'
30    endif
31  endfunction
32endif
33
34setlocal iskeyword+=-
35setlocal keywordprg=:Sman
36
37if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)
38  let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<'
39else
40  let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'
41endif
42