vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

systemd.vim (1349B)


      1 " Vim filetype plugin file
      2 " Language:			systemd.unit(5)
      3 " Keyword Lookup Support:	Enno Nagel <enno.nagel+vim@gmail.com>
      4 " Latest Revision:		2024-10-02 (small fixes to &keywordprg)
      5 " 2026 Sep 01 by Vim Project: use correct terminal feature test
      6 
      7 if exists("b:did_ftplugin")
      8   finish
      9 endif
     10 " Looks a lot like dosini files.
     11 runtime! ftplugin/dosini.vim
     12 
     13 if has('unix') && executable('less') && has('terminal')
     14   command! -buffer -nargs=1 SystemdKeywordPrg silent exe 'term ++close ' s:KeywordLookup_systemd(<q-args>)
     15   function! s:KeywordLookup_systemd(keyword) abort
     16     let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')
     17     if len(matches) > 1
     18       let section = matches[1]
     19       return 'env LESS= MANPAGER="less --pattern=''(^|,)\\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
     20     else
     21       return 'env LESS= MANPAGER="less --pattern=''(^|,)\\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'
     22     endif
     23   endfunction
     24   setlocal iskeyword+=-
     25   setlocal keywordprg=:SystemdKeywordPrg
     26   if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)
     27     let b:undo_ftplugin = 'setlocal keywordprg< iskeyword< | sil! delc -buffer SystemdKeywordPrg'
     28   else
     29     let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer SystemdKeywordPrg'
     30   endif
     31 endif