Bram Moolenaar | 60cce2f | 2015-10-13 23:21:27 +0200 | [diff] [blame] | 1 | " Vim filetype plugin file |
Bram Moolenaar | 2c7f8c5 | 2020-04-20 19:52:53 +0200 | [diff] [blame] | 2 | " Language: systemd.unit(5) |
| 3 | " Keyword Lookup Support: Enno Nagel <enno.nagel+vim@gmail.com> |
Bram Moolenaar | 60cce2f | 2015-10-13 23:21:27 +0200 | [diff] [blame] | 4 | |
| 5 | if !exists('b:did_ftplugin') |
| 6 | " Looks a lot like dosini files. |
| 7 | runtime! ftplugin/dosini.vim |
| 8 | endif |
Bram Moolenaar | 2c7f8c5 | 2020-04-20 19:52:53 +0200 | [diff] [blame] | 9 | |
| 10 | if !has('unix') |
| 11 | finish |
| 12 | endif |
| 13 | |
| 14 | if !has('gui_running') |
| 15 | command! -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw! |
| 16 | elseif has('terminal') |
| 17 | command! -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>) |
| 18 | else |
| 19 | finish |
| 20 | endif |
| 21 | |
| 22 | if !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 |
| 32 | endif |
| 33 | |
| 34 | setlocal iskeyword+=- |
| 35 | setlocal keywordprg=:Sman |
| 36 | |
| 37 | if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin) |
| 38 | let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<' |
| 39 | else |
| 40 | let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<' |
| 41 | endif |