blob: 45c2bb239a9767c1db2e4d753d55264ce955cb1d [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)
John M Devin5d1c5512024-08-23 18:34:41 +02008" 2024 Aug 23 (improve the <Plug>ManBS mapping, #15547, #15556)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10" To make the ":Man" command available before editing a manual page, source
11" this script from your startup vimrc file.
12
Bram Moolenaard799daa2022-06-20 11:17:32 +010013" If 'filetype' isn't "man", we must have been called to define ":Man" and not
14" to do the filetype plugin stuff.
Bram Moolenaar071d4272004-06-13 20:20:40 +000015if &filetype == "man"
16
17 " Only do this when not done yet for this buffer
18 if exists("b:did_ftplugin")
19 finish
20 endif
21 let b:did_ftplugin = 1
Bram Moolenaar91f84f62018-07-29 15:07:52 +020022endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000023
Bram Moolenaar91f84f62018-07-29 15:07:52 +020024let s:cpo_save = &cpo
25set cpo-=C
26
27if &filetype == "man"
Bram Moolenaarf269eab2022-10-03 18:04:35 +010028 " Allow hyphen, plus, colon, dot, and commercial at in manual page name.
Bram Moolenaar71badf92023-04-22 22:40:14 +010029 " Parentheses are not here but in dist#man#PreGetPage()
30 setlocal iskeyword=48-57,_,a-z,A-Z,-,+,:,.,@-@
Bram Moolenaar91f84f62018-07-29 15:07:52 +020031 let b:undo_ftplugin = "setlocal iskeyword<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
33 " Add mappings, unless the user didn't want this.
34 if !exists("no_plugin_maps") && !exists("no_man_maps")
35 if !hasmapto('<Plug>ManBS')
36 nmap <buffer> <LocalLeader>h <Plug>ManBS
Bram Moolenaar91f84f62018-07-29 15:07:52 +020037 let b:undo_ftplugin = b:undo_ftplugin
38 \ . '|silent! nunmap <buffer> <LocalLeader>h'
Bram Moolenaar071d4272004-06-13 20:20:40 +000039 endif
John M Devin5d1c5512024-08-23 18:34:41 +020040
41 nnoremap <buffer> <silent> <Plug>ManBS :setl ma<Bar>%s/.\b//g
42 \ <Bar>setl noma<CR>`'
Bram Moolenaar071d4272004-06-13 20:20:40 +000043
Bram Moolenaard799daa2022-06-20 11:17:32 +010044 nnoremap <buffer> <silent> <c-]> :call dist#man#PreGetPage(v:count)<CR>
45 nnoremap <buffer> <silent> <c-t> :call dist#man#PopPage()<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>'
Bram Moolenaard042dc82015-11-24 19:18:36 +010052 endif
53
54 if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
55 setlocal foldmethod=indent foldnestmax=1 foldenable
Bram Moolenaar91f84f62018-07-29 15:07:52 +020056 let b:undo_ftplugin = b:undo_ftplugin
57 \ . '|silent! setl fdm< fdn< fen<'
Bram Moolenaar071d4272004-06-13 20:20:40 +000058 endif
59
60endif
61
62if exists(":Man") != 2
Bram Moolenaard799daa2022-06-20 11:17:32 +010063 com -nargs=+ -complete=shellcmd Man call dist#man#GetPage(<q-mods>, <f-args>)
Ivan Shapovalovf21ca6d2024-07-06 16:16:40 +020064 nnoremap <Leader>K :call dist#man#PreGetPage(0)<CR>
65 nnoremap <Plug>ManPreGetPage :call dist#man#PreGetPage(0)<CR>
Bram Moolenaar071d4272004-06-13 20:20:40 +000066endif
67
Bram Moolenaar91f84f62018-07-29 15:07:52 +020068let &cpo = s:cpo_save
69unlet s:cpo_save
70
Bram Moolenaarddf8d1c2016-06-20 11:22:54 +020071" vim: set sw=2 ts=8 noet: