blob: a2c33bc363b9c4b8f67486bafda8f36a1d7dd35f [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: man
Bram Moolenaar7ceefb32020-05-01 16:07:38 +02003" Maintainer: Jason Franklin <vim@justemail.net>
Bram Moolenaar2cfb4a22020-05-07 18:56:00 +02004" Maintainer: SungHyun Nam <goweol@gmail.com>
Bram Moolenaard799daa2022-06-20 11:17:32 +01005" Autoload Split: Bram Moolenaar
Bram Moolenaar71badf92023-04-22 22:40:14 +01006" Last Change: 2023 Mar 21
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
8" To make the ":Man" command available before editing a manual page, source
9" this script from your startup vimrc file.
10
Bram Moolenaard799daa2022-06-20 11:17:32 +010011" If 'filetype' isn't "man", we must have been called to define ":Man" and not
12" to do the filetype plugin stuff.
Bram Moolenaar071d4272004-06-13 20:20:40 +000013if &filetype == "man"
14
15 " Only do this when not done yet for this buffer
16 if exists("b:did_ftplugin")
17 finish
18 endif
19 let b:did_ftplugin = 1
Bram Moolenaar91f84f62018-07-29 15:07:52 +020020endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
Bram Moolenaar91f84f62018-07-29 15:07:52 +020022let s:cpo_save = &cpo
23set cpo-=C
24
25if &filetype == "man"
Bram Moolenaarf269eab2022-10-03 18:04:35 +010026 " Allow hyphen, plus, colon, dot, and commercial at in manual page name.
Bram Moolenaar71badf92023-04-22 22:40:14 +010027 " Parentheses are not here but in dist#man#PreGetPage()
28 setlocal iskeyword=48-57,_,a-z,A-Z,-,+,:,.,@-@
Bram Moolenaar91f84f62018-07-29 15:07:52 +020029 let b:undo_ftplugin = "setlocal iskeyword<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000030
31 " Add mappings, unless the user didn't want this.
32 if !exists("no_plugin_maps") && !exists("no_man_maps")
33 if !hasmapto('<Plug>ManBS')
34 nmap <buffer> <LocalLeader>h <Plug>ManBS
Bram Moolenaar91f84f62018-07-29 15:07:52 +020035 let b:undo_ftplugin = b:undo_ftplugin
36 \ . '|silent! nunmap <buffer> <LocalLeader>h'
Bram Moolenaar071d4272004-06-13 20:20:40 +000037 endif
Bram Moolenaard2cec5b2006-03-28 21:08:56 +000038 nnoremap <buffer> <Plug>ManBS :%s/.\b//g<CR>:setl nomod<CR>''
Bram Moolenaar071d4272004-06-13 20:20:40 +000039
Bram Moolenaard799daa2022-06-20 11:17:32 +010040 nnoremap <buffer> <silent> <c-]> :call dist#man#PreGetPage(v:count)<CR>
41 nnoremap <buffer> <silent> <c-t> :call dist#man#PopPage()<CR>
Bram Moolenaard042dc82015-11-24 19:18:36 +010042 nnoremap <buffer> <silent> q :q<CR>
Bram Moolenaar91f84f62018-07-29 15:07:52 +020043
44 " Add undo commands for the maps
45 let b:undo_ftplugin = b:undo_ftplugin
46 \ . '|silent! nunmap <buffer> <Plug>ManBS'
47 \ . '|silent! nunmap <buffer> <c-]>'
48 \ . '|silent! nunmap <buffer> <c-t>'
49 \ . '|silent! nunmap <buffer> q'
Bram Moolenaard042dc82015-11-24 19:18:36 +010050 endif
51
52 if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
53 setlocal foldmethod=indent foldnestmax=1 foldenable
Bram Moolenaar91f84f62018-07-29 15:07:52 +020054 let b:undo_ftplugin = b:undo_ftplugin
55 \ . '|silent! setl fdm< fdn< fen<'
Bram Moolenaar071d4272004-06-13 20:20:40 +000056 endif
57
58endif
59
60if exists(":Man") != 2
Bram Moolenaard799daa2022-06-20 11:17:32 +010061 com -nargs=+ -complete=shellcmd Man call dist#man#GetPage(<q-mods>, <f-args>)
62 nmap <Leader>K :call dist#man#PreGetPage(0)<CR>
63 nmap <Plug>ManPreGetPage :call dist#man#PreGetPage(0)<CR>
Bram Moolenaar071d4272004-06-13 20:20:40 +000064endif
65
Bram Moolenaar91f84f62018-07-29 15:07:52 +020066let &cpo = s:cpo_save
67unlet s:cpo_save
68
Bram Moolenaarddf8d1c2016-06-20 11:22:54 +020069" vim: set sw=2 ts=8 noet: