neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

systemd.vim (1297B)


      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 
      6 if exists("b:did_ftplugin")
      7  finish
      8 endif
      9 " Looks a lot like dosini files.
     10 runtime! ftplugin/dosini.vim
     11 
     12 if has('unix') && executable('less') && exists(':terminal') == 2
     13  command! -buffer -nargs=1 SystemdKeywordPrg silent exe 'term ++close ' 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 'env LESS= MANPAGER="less --pattern=''(^|,)\\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section
     19    else
     20      return 'env LESS= MANPAGER="less --pattern=''(^|,)\\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'
     21    endif
     22  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< | sil! delc -buffer SystemdKeywordPrg'
     27  else
     28    let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer SystemdKeywordPrg'
     29  endif
     30 endif