aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
authorAnmol Sethi <anmol@aubble.com>2016-11-19 01:08:23 -0500
committerAnmol Sethi <anmol@aubble.com>2016-11-19 13:41:04 -0500
commit7a4d069bccd3d19741d50d64052e386ac4e7cfc8 (patch)
treefd997dd66777e7a5cc3f9c53459d9725fa6c3dd3 /runtime/autoload
parentcf52b881d987a5e5175b0df2304832c58ba065f7 (diff)
downloadrneovim-7a4d069bccd3d19741d50d64052e386ac4e7cfc8.tar.gz
rneovim-7a4d069bccd3d19741d50d64052e386ac4e7cfc8.tar.bz2
rneovim-7a4d069bccd3d19741d50d64052e386ac4e7cfc8.zip
man.vim: do not assume ftplugin is sourced before syntax
Fixes #5574
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/man.vim27
1 files changed, 23 insertions, 4 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim
index 5c44e8c98a..563180c79b 100644
--- a/runtime/autoload/man.vim
+++ b/runtime/autoload/man.vim
@@ -50,11 +50,11 @@ function! man#open_page(count, count1, mods, ...) abort
return
endtry
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()
- noautocmd execute 'silent edit' bufname
+ noautocmd execute 'silent edit' fnameescape(bufname)
else
- noautocmd execute 'silent' a:mods 'split' bufname
+ noautocmd execute 'silent' a:mods 'split' fnameescape(bufname)
endif
let b:man_sect = sect
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 .= ' '.s:man_cmd.' '.shellescape(a:path)
silent put =system(cmd)
- " remove all the backspaced text
+ " Remove all backspaced characters.
execute 'silent keeppatterns keepjumps %substitute,.\b,,e'.(&gdefault?'':'g')
while getline(1) =~# '^\s*$'
silent keepjumps 1delete _
@@ -259,3 +259,22 @@ function! s:format_candidate(path, sect) abort
return name.'('.sect.')'
endif
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