aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/man.vim87
-rw-r--r--runtime/autoload/netrw.vim36
-rw-r--r--runtime/autoload/provider/pythonx.vim4
-rw-r--r--runtime/autoload/spellfile.vim7
4 files changed, 55 insertions, 79 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim
index a9256638e1..e4c0080ae9 100644
--- a/runtime/autoload/man.vim
+++ b/runtime/autoload/man.vim
@@ -1,4 +1,4 @@
-" Maintainer: Anmol Sethi <anmol@aubble.com>
+" Maintainer: Anmol Sethi <hi@nhooyr.io>
if exists('s:loaded_man')
finish
@@ -64,33 +64,20 @@ function! man#open_page(count, count1, mods, ...) abort
return
endtry
- call s:push_tag()
- let bufname = 'man://'.name.(empty(sect)?'':'('.sect.')')
-
+ let [l:buf, l:save_tfu] = [bufnr(), &tagfunc]
try
- set eventignore+=BufReadCmd
+ set tagfunc=man#goto_tag
+ let l:target = l:name . '(' . l:sect . ')'
if a:mods !~# 'tab' && s:find_man()
- execute 'silent keepalt edit' fnameescape(bufname)
+ execute 'silent keepalt tag' l:target
else
- execute 'silent keepalt' a:mods 'split' fnameescape(bufname)
+ execute 'silent keepalt' a:mods 'stag' l:target
endif
finally
- set eventignore-=BufReadCmd
- endtry
-
- try
- let page = s:get_page(path)
- catch
- if a:mods =~# 'tab' || !s:find_man()
- " a new window was opened
- close
- endif
- call s:error(v:exception)
- return
+ call setbufvar(l:buf, '&tagfunc', l:save_tfu)
endtry
let b:man_sect = sect
- call s:put_page(page)
endfunction
function! man#read_page(ref) abort
@@ -152,7 +139,7 @@ function! s:get_page(path) abort
" Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065).
" Soft-wrap: ftplugin/man.vim sets wrap/breakindent/….
" Hard-wrap: driven by `man`.
- let manwidth = !get(g:,'man_hardwrap') ? 999 : (empty($MANWIDTH) ? winwidth(0) : $MANWIDTH)
+ let manwidth = !get(g:,'man_hardwrap', 1) ? 999 : (empty($MANWIDTH) ? winwidth(0) : $MANWIDTH)
" Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db).
" http://comments.gmane.org/gmane.editors.vim.devel/29085
" Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces.
@@ -163,6 +150,9 @@ endfunction
function! s:put_page(page) abort
setlocal modifiable
setlocal noreadonly
+ setlocal noswapfile
+ " git-ls-files(1) is all one keyword/tag-target
+ setlocal iskeyword+=(,)
silent keepjumps %delete _
silent put =a:page
while getline(1) =~# '^\s*$'
@@ -254,24 +244,6 @@ function! s:verify_exists(sect, name) abort
return s:extract_sect_and_name_path(path) + [path]
endfunction
-let s:tag_stack = []
-
-function! s:push_tag() abort
- let s:tag_stack += [{
- \ 'buf': bufnr('%'),
- \ 'lnum': line('.'),
- \ 'col': col('.'),
- \ }]
-endfunction
-
-function! man#pop_tag() abort
- if !empty(s:tag_stack)
- let tag = remove(s:tag_stack, -1)
- execute 'silent' tag['buf'].'buffer'
- call cursor(tag['lnum'], tag['col'])
- endif
-endfunction
-
" extracts the name and sect out of 'path/name.sect'
function! s:extract_sect_and_name_path(path) abort
let tail = fnamemodify(a:path, ':t')
@@ -356,14 +328,18 @@ function! man#complete(arg_lead, cmd_line, cursor_pos) abort
return s:complete(sect, sect, name)
endfunction
-function! s:complete(sect, psect, name) abort
+function! s:get_paths(sect, name) abort
try
let mandirs = join(split(s:system(['man', s:find_arg]), ':\|\n'), ',')
catch
call s:error(v:exception)
return
endtry
- let pages = globpath(mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1)
+ return globpath(mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1)
+endfunction
+
+function! s:complete(sect, psect, name) abort
+ let pages = s:get_paths(a:sect, a:name)
" We remove duplicates in case the same manpage in different languages was found.
return uniq(sort(map(pages, 's:format_candidate(v:val, a:psect)'), 'i'))
endfunction
@@ -383,6 +359,10 @@ function! s:format_candidate(path, psect) abort
endfunction
function! man#init_pager() abort
+ " https://github.com/neovim/neovim/issues/6828
+ let og_modifiable = &modifiable
+ setlocal modifiable
+
if getline(1) =~# '^\s*$'
silent keepjumps 1delete _
else
@@ -400,6 +380,31 @@ function! man#init_pager() abort
if -1 == match(bufname('%'), 'man:\/\/') " Avoid duplicate buffers, E95.
execute 'silent file man://'.tolower(fnameescape(ref))
endif
+
+ let &l:modifiable = og_modifiable
+endfunction
+
+function! man#goto_tag(pattern, flags, info) abort
+ let [l:sect, l:name] = man#extract_sect_and_name_ref(a:pattern)
+
+ let l:paths = s:get_paths(l:sect, l:name)
+ let l:structured = []
+
+ for l:path in l:paths
+ let l:n = s:extract_sect_and_name_path(l:path)[1]
+ let l:structured += [{ 'name': l:n, 'path': l:path }]
+ endfor
+
+ " sort by relevance - exact matches first, then the previous order
+ call sort(l:structured, { a, b -> a.name ==? l:name ? -1 : b.name ==? l:name ? 1 : 0 })
+
+ return map(l:structured, {
+ \ _, entry -> {
+ \ 'name': entry.name,
+ \ 'filename': 'man://' . entry.path,
+ \ 'cmd': '1'
+ \ }
+ \ })
endfunction
call s:init()
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index a5b47e06d5..9b1266c4ca 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -688,10 +688,6 @@ fun! netrw#Explore(indx,dosplit,style,...)
endif
" save registers
- if has("clipboard")
- sil! let keepregstar = @*
- sil! let keepregplus = @+
- endif
sil! let keepregslash= @/
" if dosplit
@@ -915,10 +911,6 @@ fun! netrw#Explore(indx,dosplit,style,...)
" call Decho("..case Nexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand("<slnum>"))
if !exists("w:netrw_explore_list") " sanity check
NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40)
- if has("clipboard")
- sil! let @* = keepregstar
- sil! let @+ = keepregplus
- endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore")
return
@@ -940,10 +932,6 @@ fun! netrw#Explore(indx,dosplit,style,...)
" call Decho("case Pexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand("<slnum>"))
if !exists("w:netrw_explore_list") " sanity check
NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41)
- if has("clipboard")
- sil! let @* = keepregstar
- sil! let @+ = keepregplus
- endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore")
return
@@ -995,10 +983,6 @@ fun! netrw#Explore(indx,dosplit,style,...)
catch /^Vim\%((\a\+)\)\=:E480/
keepalt call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45)
if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
- if has("clipboard")
- sil! let @* = keepregstar
- sil! let @+ = keepregplus
- endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : no files matched pattern")
return
@@ -1031,10 +1015,6 @@ fun! netrw#Explore(indx,dosplit,style,...)
if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/')
keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"no files matched",42)
- if has("clipboard")
- sil! let @* = keepregstar
- sil! let @+ = keepregplus
- endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : no files matched")
return
@@ -1079,10 +1059,6 @@ fun! netrw#Explore(indx,dosplit,style,...)
if !exists("g:netrw_quiet")
keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44)
endif
- if has("clipboard")
- sil! let @* = keepregstar
- sil! let @+ = keepregplus
- endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : missing +path_extra")
return
@@ -1152,10 +1128,6 @@ fun! netrw#Explore(indx,dosplit,style,...)
" there's no danger of a late FocusGained event on initialization.
" Consequently, set s:netrw_events to 2.
let s:netrw_events= 2
- if has("clipboard")
- sil! let @* = keepregstar
- sil! let @+ = keepregplus
- endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : @/<".@/.">")
endfun
@@ -9559,10 +9531,6 @@ fun! s:NetrwWideListing()
let newcolstart = w:netrw_bannercnt + fpc
let newcolend = newcolstart + fpc - 1
" call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]",'~'.expand("<slnum>"))
- if has("clipboard")
- sil! let keepregstar = @*
- sil! let keepregplus = @+
- endif
while line("$") >= newcolstart
if newcolend > line("$") | let newcolend= line("$") | endif
let newcolqty= newcolend - newcolstart
@@ -9575,10 +9543,6 @@ fun! s:NetrwWideListing()
exe "sil! NetrwKeepj ".newcolstart.','.newcolend.'d _'
exe 'sil! NetrwKeepj '.w:netrw_bannercnt
endwhile
- if has("clipboard")
- sil! let @*= keepregstar
- sil! let @+= keepregplus
- endif
exe "sil! NetrwKeepj ".w:netrw_bannercnt.',$s/\s\+$//e'
NetrwKeepj call histdel("/",-1)
exe 'nno <buffer> <silent> w :call search(''^.\\|\s\s\zs\S'',''W'')'."\<cr>"
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index aec18c0508..23e7ff8f64 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -29,8 +29,8 @@ endfunction
function! s:get_python_candidates(major_version) abort
return {
\ 2: ['python2', 'python2.7', 'python2.6', 'python'],
- \ 3: ['python3', 'python3.7', 'python3.6', 'python3.5', 'python3.4', 'python3.3',
- \ 'python']
+ \ 3: ['python3', 'python3.8', 'python3.7', 'python3.6', 'python3.5',
+ \ 'python3.4', 'python3.3', 'python']
\ }[a:major_version]
endfunction
diff --git a/runtime/autoload/spellfile.vim b/runtime/autoload/spellfile.vim
index c0ef51cdfe..d098902305 100644
--- a/runtime/autoload/spellfile.vim
+++ b/runtime/autoload/spellfile.vim
@@ -13,6 +13,13 @@ let s:spellfile_URL = '' " Start with nothing so that s:donedict is reset.
" This function is used for the spellfile plugin.
function! spellfile#LoadFile(lang)
+ " Check for sandbox/modeline. #11359
+ try
+ :!
+ catch /\<E12\>/
+ throw 'Cannot download spellfile in sandbox/modeline. Try ":set spell" from the cmdline.'
+ endtry
+
" If the netrw plugin isn't loaded we silently skip everything.
if !exists(":Nread")
if &verbose