man.vim 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. " Vim filetype plugin file
  2. " Language: man
  3. " Maintainer: Jason Franklin <vim@justemail.net>
  4. " Maintainer: SungHyun Nam <goweol@gmail.com>
  5. " Autoload Split: Bram Moolenaar
  6. " Last Change: 2022 Sep 30
  7. " To make the ":Man" command available before editing a manual page, source
  8. " this script from your startup vimrc file.
  9. " If 'filetype' isn't "man", we must have been called to define ":Man" and not
  10. " to do the filetype plugin stuff.
  11. if &filetype == "man"
  12. " Only do this when not done yet for this buffer
  13. if exists("b:did_ftplugin")
  14. finish
  15. endif
  16. let b:did_ftplugin = 1
  17. endif
  18. let s:cpo_save = &cpo
  19. set cpo-=C
  20. if &filetype == "man"
  21. " Allow hyphen, plus, colon, dot, and commercial at in manual page name.
  22. " Allow parentheses for references.
  23. setlocal iskeyword=48-57,_,a-z,A-Z,-,+,:,.,@-@,(,)
  24. let b:undo_ftplugin = "setlocal iskeyword<"
  25. " Add mappings, unless the user didn't want this.
  26. if !exists("no_plugin_maps") && !exists("no_man_maps")
  27. if !hasmapto('<Plug>ManBS')
  28. nmap <buffer> <LocalLeader>h <Plug>ManBS
  29. let b:undo_ftplugin = b:undo_ftplugin
  30. \ . '|silent! nunmap <buffer> <LocalLeader>h'
  31. endif
  32. nnoremap <buffer> <Plug>ManBS :%s/.\b//g<CR>:setl nomod<CR>''
  33. nnoremap <buffer> <silent> <c-]> :call dist#man#PreGetPage(v:count)<CR>
  34. nnoremap <buffer> <silent> <c-t> :call dist#man#PopPage()<CR>
  35. nnoremap <buffer> <silent> q :q<CR>
  36. " Add undo commands for the maps
  37. let b:undo_ftplugin = b:undo_ftplugin
  38. \ . '|silent! nunmap <buffer> <Plug>ManBS'
  39. \ . '|silent! nunmap <buffer> <c-]>'
  40. \ . '|silent! nunmap <buffer> <c-t>'
  41. \ . '|silent! nunmap <buffer> q'
  42. endif
  43. if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
  44. setlocal foldmethod=indent foldnestmax=1 foldenable
  45. let b:undo_ftplugin = b:undo_ftplugin
  46. \ . '|silent! setl fdm< fdn< fen<'
  47. endif
  48. endif
  49. if exists(":Man") != 2
  50. com -nargs=+ -complete=shellcmd Man call dist#man#GetPage(<q-mods>, <f-args>)
  51. nmap <Leader>K :call dist#man#PreGetPage(0)<CR>
  52. nmap <Plug>ManPreGetPage :call dist#man#PreGetPage(0)<CR>
  53. endif
  54. let &cpo = s:cpo_save
  55. unlet s:cpo_save
  56. " vim: set sw=2 ts=8 noet: