runtime: configure keywordpg for some file types (#5566) · vim/vim@2f25e40

@@ -7,35 +7,30 @@ if !exists('b:did_ftplugin')

77

runtime! ftplugin/dosini.vim

88

endif

9910-

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

10+

if has('unix') && executable('less')

11+

if !has('gui_running')

12+

command -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!

13+

elseif has('terminal')

14+

command -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>)

15+

endif

16+

if exists(':Sman') == 2

17+

if !exists('*KeywordLookup_systemd')

18+

function KeywordLookup_systemd(keyword) abort

19+

let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')

20+

if len(matches) > 1

21+

let section = matches[1]

22+

return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd.' . section

23+

else

24+

return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'

25+

endif

26+

endfunction

27+

endif

28+

setlocal iskeyword+=-

29+

setlocal keywordprg=:Sman

30+

if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)

31+

let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<'

2832

else

29-

return 'LESS= MANPAGER="less --pattern=''(^|,)\s+' . a:keyword . '=$'' --hilite-search" man ' . 'systemd'

33+

let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword<'

3034

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<'

35+

endif

4136

endif