diff options
author | Anmol Sethi <anmol@aubble.com> | 2016-12-26 18:26:00 -0500 |
---|---|---|
committer | Anmol Sethi <anmol@aubble.com> | 2016-12-26 18:27:16 -0500 |
commit | 7f9a95e5ead507a307269dcc72976ba6575d21e6 (patch) | |
tree | feaa8fee93f66b5fa6d647d8d1d72a2ba110f421 | |
parent | 4431975210b58c6b0403ee50172bad3c8729bbb2 (diff) | |
download | rneovim-7f9a95e5ead507a307269dcc72976ba6575d21e6.tar.gz rneovim-7f9a95e5ead507a307269dcc72976ba6575d21e6.tar.bz2 rneovim-7f9a95e5ead507a307269dcc72976ba6575d21e6.zip |
man.vim: when completing a fpage, always show section
-rw-r--r-- | runtime/autoload/man.vim | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 563180c79b..77b76d383c 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -215,6 +215,7 @@ function! man#complete(arg_lead, cmd_line, cursor_pos) abort let tmp = split(a:arg_lead, '(') let name = tmp[0] let sect = tolower(get(tmp, 1, '')) + return s:complete(sect, '', name) elseif args[1] !~# '^[^()]\+$' " cursor (|) is at ':Man 3() |' or ':Man (3|' or ':Man 3() pri|' " or ':Man 3() pri |' @@ -242,18 +243,22 @@ function! man#complete(arg_lead, cmd_line, cursor_pos) abort let name = a:arg_lead let sect = tolower(args[1]) endif + return s:complete(sect, sect, name) +endfunction + +function! s:complete(sect, psect, name) abort " We remove duplicates incase the same manpage in different languages was found. - return uniq(sort(map(globpath(s:mandirs,'man?/'.name.'*.'.sect.'*', 0, 1), 's:format_candidate(v:val, sect)'), 'i')) + return uniq(sort(map(globpath(s:mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1), 's:format_candidate(v:val, a:psect)'), 'i')) endfunction -function! s:format_candidate(path, sect) abort +function! s:format_candidate(path, psect) abort if a:path =~# '\.\%(pdf\|in\)$' " invalid extensions return endif let [sect, name] = s:extract_sect_and_name_path(a:path) - if sect ==# a:sect + if sect ==# a:psect return name - elseif sect =~# a:sect.'.\+$' + elseif sect =~# a:psect.'.\+$' " We include the section if the user provided section is a prefix " of the actual section. return name.'('.sect.')' |