blob: 0f6d36c2d28cac6ec2543bf896e7abaa46e436e4 [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
6" Last Change: 2022 Jun 18
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 Moolenaar071d4272004-06-13 20:20:40 +000026 " allow dot and dash in manual page name.
27 setlocal iskeyword+=\.,-
Bram Moolenaar91f84f62018-07-29 15:07:52 +020028 let b:undo_ftplugin = "setlocal iskeyword<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000029
30 " Add mappings, unless the user didn't want this.
31 if !exists("no_plugin_maps") && !exists("no_man_maps")
32 if !hasmapto('<Plug>ManBS')
33 nmap <buffer> <LocalLeader>h <Plug>ManBS
Bram Moolenaar91f84f62018-07-29 15:07:52 +020034 let b:undo_ftplugin = b:undo_ftplugin
35 \ . '|silent! nunmap <buffer> <LocalLeader>h'
Bram Moolenaar071d4272004-06-13 20:20:40 +000036 endif
Bram Moolenaard2cec5b2006-03-28 21:08:56 +000037 nnoremap <buffer> <Plug>ManBS :%s/.\b//g<CR>:setl nomod<CR>''
Bram Moolenaar071d4272004-06-13 20:20:40 +000038
Bram Moolenaard799daa2022-06-20 11:17:32 +010039 nnoremap <buffer> <silent> <c-]> :call dist#man#PreGetPage(v:count)<CR>
40 nnoremap <buffer> <silent> <c-t> :call dist#man#PopPage()<CR>
Bram Moolenaard042dc82015-11-24 19:18:36 +010041 nnoremap <buffer> <silent> q :q<CR>
Bram Moolenaar91f84f62018-07-29 15:07:52 +020042
43 " Add undo commands for the maps
44 let b:undo_ftplugin = b:undo_ftplugin
45 \ . '|silent! nunmap <buffer> <Plug>ManBS'
46 \ . '|silent! nunmap <buffer> <c-]>'
47 \ . '|silent! nunmap <buffer> <c-t>'
48 \ . '|silent! nunmap <buffer> q'
Bram Moolenaard042dc82015-11-24 19:18:36 +010049 endif
50
51 if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
52 setlocal foldmethod=indent foldnestmax=1 foldenable
Bram Moolenaar91f84f62018-07-29 15:07:52 +020053 let b:undo_ftplugin = b:undo_ftplugin
54 \ . '|silent! setl fdm< fdn< fen<'
Bram Moolenaar071d4272004-06-13 20:20:40 +000055 endif
56
57endif
58
59if exists(":Man") != 2
Bram Moolenaard799daa2022-06-20 11:17:32 +010060 com -nargs=+ -complete=shellcmd Man call dist#man#GetPage(<q-mods>, <f-args>)
61 nmap <Leader>K :call dist#man#PreGetPage(0)<CR>
62 nmap <Plug>ManPreGetPage :call dist#man#PreGetPage(0)<CR>
Bram Moolenaar071d4272004-06-13 20:20:40 +000063endif
64
Bram Moolenaar91f84f62018-07-29 15:07:52 +020065let &cpo = s:cpo_save
66unlet s:cpo_save
67
Bram Moolenaarddf8d1c2016-06-20 11:22:54 +020068" vim: set sw=2 ts=8 noet: