mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
parent
cf52b881d9
commit
7a4d069bcc
@ -50,11 +50,11 @@ function! man#open_page(count, count1, mods, ...) abort
|
|||||||
return
|
return
|
||||||
endtry
|
endtry
|
||||||
call s:push_tag()
|
call s:push_tag()
|
||||||
let bufname = fnameescape('man://'.name.(empty(sect)?'':'('.sect.')'))
|
let bufname = 'man://'.name.(empty(sect)?'':'('.sect.')')
|
||||||
if a:mods !~# 'tab' && s:find_man()
|
if a:mods !~# 'tab' && s:find_man()
|
||||||
noautocmd execute 'silent edit' bufname
|
noautocmd execute 'silent edit' fnameescape(bufname)
|
||||||
else
|
else
|
||||||
noautocmd execute 'silent' a:mods 'split' bufname
|
noautocmd execute 'silent' a:mods 'split' fnameescape(bufname)
|
||||||
endif
|
endif
|
||||||
let b:man_sect = sect
|
let b:man_sect = sect
|
||||||
call s:read_page(path)
|
call s:read_page(path)
|
||||||
@ -81,7 +81,7 @@ function! s:read_page(path) abort
|
|||||||
let cmd = 'env MANPAGER=cat'.(empty($MANWIDTH) ? ' MANWIDTH='.winwidth(0) : '')
|
let cmd = 'env MANPAGER=cat'.(empty($MANWIDTH) ? ' MANWIDTH='.winwidth(0) : '')
|
||||||
let cmd .= ' '.s:man_cmd.' '.shellescape(a:path)
|
let cmd .= ' '.s:man_cmd.' '.shellescape(a:path)
|
||||||
silent put =system(cmd)
|
silent put =system(cmd)
|
||||||
" remove all the backspaced text
|
" Remove all backspaced characters.
|
||||||
execute 'silent keeppatterns keepjumps %substitute,.\b,,e'.(&gdefault?'':'g')
|
execute 'silent keeppatterns keepjumps %substitute,.\b,,e'.(&gdefault?'':'g')
|
||||||
while getline(1) =~# '^\s*$'
|
while getline(1) =~# '^\s*$'
|
||||||
silent keepjumps 1delete _
|
silent keepjumps 1delete _
|
||||||
@ -259,3 +259,22 @@ function! s:format_candidate(path, sect) abort
|
|||||||
return name.'('.sect.')'
|
return name.'('.sect.')'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! man#init_pager() abort
|
||||||
|
" Remove all backspaced characters.
|
||||||
|
execute 'silent keeppatterns keepjumps %substitute,.\b,,e'.(&gdefault?'':'g')
|
||||||
|
if getline(1) =~# '^\s*$'
|
||||||
|
silent keepjumps 1delete _
|
||||||
|
else
|
||||||
|
keepjumps 1
|
||||||
|
endif
|
||||||
|
" This is not perfect. See `man glDrawArraysInstanced`. Since the title is
|
||||||
|
" all caps it is impossible to tell what the original capitilization was.
|
||||||
|
let ref = tolower(matchstr(getline(1), '^\S\+'))
|
||||||
|
try
|
||||||
|
let b:man_sect = man#extract_sect_and_name_ref(ref)[0]
|
||||||
|
catch
|
||||||
|
let b:man_sect = ''
|
||||||
|
endtry
|
||||||
|
execute 'silent file man://'.fnameescape(ref)
|
||||||
|
endfunction
|
||||||
|
@ -1,31 +1,15 @@
|
|||||||
" Maintainer: Anmol Sethi <anmol@aubble.com>
|
" Maintainer: Anmol Sethi <anmol@aubble.com>
|
||||||
" Previous Maintainer: SungHyun Nam <goweol@gmail.com>
|
" Previous Maintainer: SungHyun Nam <goweol@gmail.com>
|
||||||
|
|
||||||
if exists('b:did_ftplugin') || &filetype !=# 'man'
|
if exists('b:did_ftplugin')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let b:did_ftplugin = 1
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
let s:pager = 0
|
let s:pager = !exists('b:man_sect')
|
||||||
|
|
||||||
if has('vim_starting')
|
if s:pager
|
||||||
let s:pager = 1
|
call man#init_pager()
|
||||||
" remove all those backspaces
|
|
||||||
execute 'silent keeppatterns keepjumps %substitute,.\b,,e'.(&gdefault?'':'g')
|
|
||||||
if getline(1) =~# '^\s*$'
|
|
||||||
silent keepjumps 1delete _
|
|
||||||
else
|
|
||||||
keepjumps 1
|
|
||||||
endif
|
|
||||||
" This is not perfect. See `man glDrawArraysInstanced`. Since the title is
|
|
||||||
" all caps it is impossible to tell what the original capitilization was.
|
|
||||||
let ref = tolower(matchstr(getline(1), '^\S\+'))
|
|
||||||
try
|
|
||||||
let b:man_sect = man#extract_sect_and_name_ref(ref)[0]
|
|
||||||
catch
|
|
||||||
let b:man_sect = ''
|
|
||||||
endtry
|
|
||||||
execute 'silent file man://'.fnameescape(ref)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
setlocal buftype=nofile
|
setlocal buftype=nofile
|
||||||
|
@ -18,6 +18,9 @@ highlight default link manOptionDesc Constant
|
|||||||
highlight default link manReference PreProc
|
highlight default link manReference PreProc
|
||||||
highlight default link manSubHeading Function
|
highlight default link manSubHeading Function
|
||||||
|
|
||||||
|
if !exists('b:man_sect')
|
||||||
|
call man#init_pager()
|
||||||
|
endif
|
||||||
if b:man_sect =~# '^[23]'
|
if b:man_sect =~# '^[23]'
|
||||||
syntax include @c $VIMRUNTIME/syntax/c.vim
|
syntax include @c $VIMRUNTIME/syntax/c.vim
|
||||||
syntax match manCFuncDefinition display '\<\h\w*\>\ze\(\s\|\n\)*(' contained
|
syntax match manCFuncDefinition display '\<\h\w*\>\ze\(\s\|\n\)*(' contained
|
||||||
|
Loading…
Reference in New Issue
Block a user