vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

man.vim (2744B)


      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:	2024 Jun 06 (disabled the q mapping, #8210)
      7 " 		2024 Jul 06 (use nnoremap, #15130)
      8 " 		2024 Aug 23 (improve the <Plug>ManBS mapping, #15547, #15556)
      9 " 		2025 Mar 09 (improve :Man completion for man-db, #16843)
     10 
     11 " To make the ":Man" command available before editing a manual page, source
     12 " this script from your startup vimrc file.
     13 
     14 " If 'filetype' isn't "man", we must have been called to define ":Man" and not
     15 " to do the filetype plugin stuff.
     16 if &filetype == "man"
     17 
     18   " Only do this when not done yet for this buffer
     19   if exists("b:did_ftplugin")
     20     finish
     21   endif
     22   let b:did_ftplugin = 1
     23 endif
     24 
     25 let s:cpo_save = &cpo
     26 set cpo-=C
     27 
     28 if !exists('g:ft_man_implementation')
     29   if executable('mandb') > 0
     30     let g:ft_man_implementation = 'man-db'
     31   else
     32     let g:ft_man_implementation = ''
     33   endif
     34 endif
     35 
     36 if &filetype == "man"
     37   " Allow hyphen, plus, colon, dot, and commercial at in manual page name.
     38   " Parentheses are not here but in dist#man#PreGetPage()
     39   setlocal iskeyword=48-57,_,a-z,A-Z,-,+,:,.,@-@
     40   let b:undo_ftplugin = "setlocal iskeyword<"
     41 
     42   " Add mappings, unless the user didn't want this.
     43   if !exists("no_plugin_maps") && !exists("no_man_maps")
     44     if !hasmapto('<Plug>ManBS')
     45       nmap <buffer> <LocalLeader>h <Plug>ManBS
     46       let b:undo_ftplugin = b:undo_ftplugin
     47 	    \ . '|silent! nunmap <buffer> <LocalLeader>h'
     48     endif
     49 
     50     nnoremap <buffer> <silent> <Plug>ManBS :setl ma<Bar>%s/.\b//g
     51 	\ <Bar>setl noma<CR>`'
     52 
     53     nnoremap <buffer> <silent> <c-]> :call dist#man#PreGetPage(v:count)<CR>
     54     nnoremap <buffer> <silent> <c-t> :call dist#man#PopPage()<CR>
     55 
     56     " Add undo commands for the maps
     57     let b:undo_ftplugin = b:undo_ftplugin
     58 	  \ . '|silent! nunmap <buffer> <Plug>ManBS'
     59 	  \ . '|silent! nunmap <buffer> <c-]>'
     60 	  \ . '|silent! nunmap <buffer> <c-t>'
     61   endif
     62 
     63   if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
     64     setlocal foldmethod=indent foldnestmax=1 foldenable
     65     let b:undo_ftplugin = b:undo_ftplugin
     66 	  \ . '|silent! setl fdm< fdn< fen<'
     67   endif
     68 
     69 endif
     70 
     71 if exists(":Man") != 2
     72   if g:ft_man_implementation ==# 'man-db'
     73     com -nargs=+ -complete=customlist,dist#man#ManDbComplete Man call dist#man#GetPage(<q-mods>, <f-args>)
     74   else
     75     com -nargs=+ -complete=shellcmd Man call dist#man#GetPage(<q-mods>, <f-args>)
     76   endif
     77   nnoremap <Leader>K :call dist#man#PreGetPage(0)<CR>
     78   nnoremap <Plug>ManPreGetPage :call dist#man#PreGetPage(0)<CR>
     79 endif
     80 
     81 if exists(":ManReload") != 2
     82   com ManReload call dist#man#Reload()
     83 endif
     84 
     85 let &cpo = s:cpo_save
     86 unlet s:cpo_save
     87 
     88 " vim: set sw=2 ts=8 noet: