blob: f0723ef7bfea0a779809db557f694c029b473f28 [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
Christian Brabandt6dcd7f12024-06-06 19:06:38 +02006" Last Change: 2024 Jun 06 (disabled the q mapping, #8210)
Ivan Shapovalov84ca1382024-07-06 16:56:02 +02007" 2024 Jul 06 (use nnoremap, #15130)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
9" To make the ":Man" command available before editing a manual page, source
10" this script from your startup vimrc file.
11
Bram Moolenaard799daa2022-06-20 11:17:32 +010012" If 'filetype' isn't "man", we must have been called to define ":Man" and not
13" to do the filetype plugin stuff.
Bram Moolenaar071d4272004-06-13 20:20:40 +000014if &filetype == "man"
15
16 " Only do this when not done yet for this buffer
17 if exists("b:did_ftplugin")
18 finish
19 endif
20 let b:did_ftplugin = 1
Bram Moolenaar91f84f62018-07-29 15:07:52 +020021endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000022
Bram Moolenaar91f84f62018-07-29 15:07:52 +020023let s:cpo_save = &cpo
24set cpo-=C
25
26if &filetype == "man"
Bram Moolenaarf269eab2022-10-03 18:04:35 +010027 " Allow hyphen, plus, colon, dot, and commercial at in manual page name.
Bram Moolenaar71badf92023-04-22 22:40:14 +010028 " Parentheses are not here but in dist#man#PreGetPage()
29 setlocal iskeyword=48-57,_,a-z,A-Z,-,+,:,.,@-@
Bram Moolenaar91f84f62018-07-29 15:07:52 +020030 let b:undo_ftplugin = "setlocal iskeyword<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000031
32 " Add mappings, unless the user didn't want this.
33 if !exists("no_plugin_maps") && !exists("no_man_maps")
34 if !hasmapto('<Plug>ManBS')
35 nmap <buffer> <LocalLeader>h <Plug>ManBS
Bram Moolenaar91f84f62018-07-29 15:07:52 +020036 let b:undo_ftplugin = b:undo_ftplugin
37 \ . '|silent! nunmap <buffer> <LocalLeader>h'
Bram Moolenaar071d4272004-06-13 20:20:40 +000038 endif
Bram Moolenaard2cec5b2006-03-28 21:08:56 +000039 nnoremap <buffer> <Plug>ManBS :%s/.\b//g<CR>:setl nomod<CR>''
Bram Moolenaar071d4272004-06-13 20:20:40 +000040
Bram Moolenaard799daa2022-06-20 11:17:32 +010041 nnoremap <buffer> <silent> <c-]> :call dist#man#PreGetPage(v:count)<CR>
42 nnoremap <buffer> <silent> <c-t> :call dist#man#PopPage()<CR>
Christian Brabandt6dcd7f12024-06-06 19:06:38 +020043 " Disabled, since this hides the ability to record a macro or use the
44 " command line window
45 " nnoremap <buffer> <silent> q :q<CR>
Bram Moolenaar91f84f62018-07-29 15:07:52 +020046
47 " Add undo commands for the maps
48 let b:undo_ftplugin = b:undo_ftplugin
49 \ . '|silent! nunmap <buffer> <Plug>ManBS'
50 \ . '|silent! nunmap <buffer> <c-]>'
51 \ . '|silent! nunmap <buffer> <c-t>'
Christian Brabandt6dcd7f12024-06-06 19:06:38 +020052 "\ . '|silent! nunmap <buffer> q'
Bram Moolenaard042dc82015-11-24 19:18:36 +010053 endif
54
55 if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
56 setlocal foldmethod=indent foldnestmax=1 foldenable
Bram Moolenaar91f84f62018-07-29 15:07:52 +020057 let b:undo_ftplugin = b:undo_ftplugin
58 \ . '|silent! setl fdm< fdn< fen<'
Bram Moolenaar071d4272004-06-13 20:20:40 +000059 endif
60
61endif
62
63if exists(":Man") != 2
Bram Moolenaard799daa2022-06-20 11:17:32 +010064 com -nargs=+ -complete=shellcmd Man call dist#man#GetPage(<q-mods>, <f-args>)
Ivan Shapovalovf21ca6d2024-07-06 16:16:40 +020065 nnoremap <Leader>K :call dist#man#PreGetPage(0)<CR>
66 nnoremap <Plug>ManPreGetPage :call dist#man#PreGetPage(0)<CR>
Bram Moolenaar071d4272004-06-13 20:20:40 +000067endif
68
Bram Moolenaar91f84f62018-07-29 15:07:52 +020069let &cpo = s:cpo_save
70unlet s:cpo_save
71
Bram Moolenaarddf8d1c2016-06-20 11:22:54 +020072" vim: set sw=2 ts=8 noet: