codekingpro/portable-devtools
114k
1" Vim filetype plugin file2" 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 6if exists("b:did_ftplugin")7 finish8endif9" Looks a lot like dosini files.10runtime! ftplugin/dosini.vim11 12if has('unix') && executable('less') && exists(':terminal') == 213 command! -buffer -nargs=1 SystemdKeywordPrg silent exe 'term ++close ' KeywordLookup_systemd(<q-args>)14 silent! function KeywordLookup_systemd(keyword) abort15 let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')16 if len(matches) > 117 let section = matches[1]18 return 'env LESS= MANPAGER="less --pattern=''(^|,)\\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section19 else20 return 'env LESS= MANPAGER="less --pattern=''(^|,)\\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'21 endif22 endfunction23 setlocal iskeyword+=-24 setlocal keywordprg=:SystemdKeywordPrg25 if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)26 let b:undo_ftplugin = 'setlocal keywordprg< iskeyword< | sil! delc -buffer SystemdKeywordPrg'27 else28 let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer SystemdKeywordPrg'29 endif30endif31 