summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/netrw.vim1372
-rw-r--r--runtime/doc/change.txt5
-rw-r--r--runtime/doc/channel.txt11
-rw-r--r--runtime/doc/editing.txt4
-rw-r--r--runtime/doc/eval.txt48
-rw-r--r--runtime/doc/netbeans.txt4
-rw-r--r--runtime/doc/options.txt4
-rw-r--r--runtime/doc/os_dos.txt2
-rw-r--r--runtime/doc/pi_netrw.txt142
-rw-r--r--runtime/doc/starting.txt28
-rw-r--r--runtime/doc/tags13
-rw-r--r--runtime/doc/todo.txt34
-rw-r--r--runtime/doc/various.txt4
-rw-r--r--runtime/plugin/matchparen.vim3
-rw-r--r--runtime/plugin/netrwPlugin.vim10
-rw-r--r--runtime/syntax/sh.vim9
-rw-r--r--runtime/syntax/vim.vim57
-rw-r--r--runtime/tools/demoserver.py2
18 files changed, 1069 insertions, 683 deletions
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index 53668b15be..64c08e98fa 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -1,10 +1,10 @@
" netrw.vim: Handles file transfer and remote directory listing across
" AUTOLOAD SECTION
-" Date: Oct 23, 2015
-" Version: 154
+" Date: Feb 16, 2016
+" Version: 155 ASTRO-ONLY
" Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
-" Copyright: Copyright (C) 1999-2015 Charles E. Campbell {{{1
+" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
@@ -30,7 +30,7 @@ if v:version < 704 || !has("patch213")
let s:needpatch213= 1
finish
endif
-let g:loaded_netrw = "v154"
+let g:loaded_netrw = "v155"
if !exists("s:NOTE")
let s:NOTE = 0
let s:WARNING = 1
@@ -55,7 +55,7 @@ setl cpo&vim
" Usage: netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,"some message",error-number)
" netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,["message1","message2",...],error-number)
" (this function can optionally take a list of messages)
-" Oct 09, 2015 : max errnum currently is 102
+" Jan 19, 2016 : max errnum currently is 103
fun! netrw#ErrorMsg(level,msg,errnum)
" call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow)
@@ -77,7 +77,7 @@ fun! netrw#ErrorMsg(level,msg,errnum)
" (default) netrw creates a one-line window to show error/warning
" messages (reliably displayed)
- " record current window number for NetrwRestorePosn()'s benefit
+ " record current window number
let s:winBeforeErr= winnr()
" call Decho("s:winBeforeErr=".s:winBeforeErr,'~'.expand("<slnum>"))
@@ -416,18 +416,20 @@ if !exists("g:netrw_localmovecmd")
let g:netrw_localmovecmd= ""
endif
endif
-if exists("g:netrw_local_rmdir")
- let g:netrw_localrmdir= g:netrw_local_rmdir
- call netrw#ErrorMsg(s:NOTE,"g:netrw_local_rmdir is deprecated in favor of g:netrw_localrmdir",86)
-endif
-if has("win32") || has("win95") || has("win64") || has("win16")
- if g:netrw_cygwin
- call s:NetrwInit("g:netrw_localrmdir","rmdir")
- else
- let g:netrw_localrmdir= expand("$COMSPEC")." /c rmdir"
- endif
-else
- call s:NetrwInit("g:netrw_localrmdir","rmdir")
+if v:version < 704 || !has("patch1109")
+ if exists("g:netrw_local_rmdir")
+ let g:netrw_localrmdir= g:netrw_local_rmdir
+ call netrw#ErrorMsg(s:NOTE,"g:netrw_local_rmdir is deprecated in favor of g:netrw_localrmdir",86)
+ endif
+ if has("win32") || has("win95") || has("win64") || has("win16")
+ if g:netrw_cygwin
+ call s:NetrwInit("g:netrw_localrmdir","rmdir")
+ else
+ let g:netrw_localrmdir= expand("$COMSPEC")." /c rmdir"
+ endif
+ else
+ call s:NetrwInit("g:netrw_localrmdir","rmdir")
+ endif
endif
call s:NetrwInit("g:netrw_liststyle" , s:THINLIST)
" sanity checks
@@ -489,6 +491,7 @@ endif
call s:NetrwInit("g:netrw_special_syntax" , 0)
call s:NetrwInit("g:netrw_ssh_browse_reject", '^total\s\+\d\+$')
call s:NetrwInit("g:netrw_use_noswf" , 1)
+call s:NetrwInit("g:netrw_sizestyle" ,"b")
" Default values - t-w ---------- {{{3
call s:NetrwInit("g:netrw_timefmt","%c")
if !exists("g:netrw_xstrlen")
@@ -614,7 +617,7 @@ endif
" == 4: Vexplore style == 5: Vexplore!
" == 6: Texplore
fun! netrw#Explore(indx,dosplit,style,...)
-" call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." modifiable=".&modifiable." a:0=".a:0." win#".winnr()." buf#".bufnr("%"))
+" call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." modifiable=".&modifiable." a:0=".a:0." win#".winnr()." buf#".bufnr("%")." ft=".&ft)
" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>"))
if !exists("b:netrw_curdir")
let b:netrw_curdir= getcwd()
@@ -1165,7 +1168,8 @@ fun! netrw#Lexplore(count,rightside,...)
" call Decho("t:netrw_lexbufnr#".t:netrw_lexbufnr.": close down netrw window",'~'.expand("<slnum>"))
exe lexwinnr."wincmd w"
let g:netrw_winsize = -winwidth(0)
- let t:netrw_lexposn = netrw#SavePosn()
+ let t:netrw_lexposn = winsaveview()
+" call Decho("saving posn to t:netrw_lexposn<".string(t:netrw_lexposn).">",'~'.expand("<slnum>"))
" call Decho("saving t:netrw_lexposn",'~'.expand("<slnum>"))
close
if lexwinnr < curwin
@@ -1205,7 +1209,8 @@ fun! netrw#Lexplore(count,rightside,...)
let t:netrw_lexbufnr = bufnr("%")
if exists("t:netrw_lexposn")
" call Decho("restoring to t:netrw_lexposn",'~'.expand("<slnum>"))
- call netrw#RestorePosn(t:netrw_lexposn)
+" call Decho("restoring posn to t:netrw_lexposn<".string(t:netrw_lexposn).">",'~'.expand("<slnum>"))
+ call winrestview(t:netrw_lexposn)
unlet t:netrw_lexposn
endif
endif
@@ -1273,7 +1278,8 @@ endfun
fun! netrw#MakeTgt(dname)
" call Dfunc("netrw#MakeTgt(dname<".a:dname.">)")
" simplify the target (eg. /abc/def/../ghi -> /abc/ghi)
- let svpos = netrw#SavePosn()
+ let svpos = winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
let s:netrwmftgt_islocal= (a:dname !~ '^\a\{3,}://')
" call Decho("s:netrwmftgt_islocal=".s:netrwmftgt_islocal,'~'.expand("<slnum>"))
if s:netrwmftgt_islocal
@@ -1290,7 +1296,8 @@ fun! netrw#MakeTgt(dname)
if g:netrw_fastbrowse <= 1
call s:NetrwRefresh((b:netrw_curdir !~ '\a\{3,}://'),b:netrw_curdir)
endif
- call netrw#RestorePosn(svpos)
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))"
+ call winrestview(svpos)
" call Dret("netrw#MakeTgt")
endfun
@@ -1532,9 +1539,11 @@ endfun
" netrw#Nread: save position, call netrw#NetRead(), and restore position {{{2
fun! netrw#Nread(mode,fname)
" call Dfunc("netrw#Nread(mode=".a:mode." fname<".a:fname.">)")
- call netrw#SavePosn()
+ let svpos= winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
call netrw#NetRead(a:mode,a:fname)
- call netrw#RestorePosn()
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
+ call winrestview(svpos)
if exists("w:netrw_liststyle") && w:netrw_liststyle != s:TREELIST
if exists("w:netrw_bannercnt")
@@ -1552,8 +1561,8 @@ fun! s:NetrwOptionRestore(vt)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
if !exists("{a:vt}netrw_optionsave")
if exists("s:nbcd_curpos_{bufnr('%')}")
-" call Decho("restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)",'~'.expand("<slnum>"))
- NetrwKeepj call netrw#RestorePosn(s:nbcd_curpos_{bufnr('%')})
+" call Decho("restoring posn to s:nbcd_curpos_".bufnr('%')."<".string(s:nbcd_curpos_{bufnr('%')}).">",'~'.expand("<slnum>"))
+ NetrwKeepj call winrestview(s:nbcd_curpos_{bufnr('%')})
" call Decho("win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$"),'~'.expand("<slnum>"))
" call Decho("unlet s:nbcd_curpos_".bufnr('%'),'~'.expand("<slnum>"))
unlet s:nbcd_curpos_{bufnr('%')}
@@ -1629,8 +1638,10 @@ fun! s:NetrwOptionRestore(vt)
setl directory=
unlet {a:vt}netrw_swfkeep
elseif &l:swf != {a:vt}netrw_swfkeep
- " following line causes a Press ENTER in windows -- can't seem to work around it!!!
- sil! let &l:swf= {a:vt}netrw_swfkeep
+ if !g:netrw_use_noswf
+ " following line causes a Press ENTER in windows -- can't seem to work around it!!!
+ sil! let &l:swf= {a:vt}netrw_swfkeep
+ endif
unlet {a:vt}netrw_swfkeep
endif
endif
@@ -1646,8 +1657,8 @@ fun! s:NetrwOptionRestore(vt)
endif
if exists("{a:vt}netrw_regslash")|sil! let @/= {a:vt}netrw_regslash|unlet {a:vt}netrw_regslash|endif
if exists("s:nbcd_curpos_{bufnr('%')}")
-" call Decho("restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)",'~'.expand("<slnum>"))
- NetrwKeepj call netrw#RestorePosn(s:nbcd_curpos_{bufnr('%')})
+" call Decho("restoring posn to s:nbcd_curpos_".bufnr('%')."<".string(s:nbcd_curpos_{bufnr('%')}).">",'~'.expand("<slnum>"))
+ NetrwKeepj call winrestview(s:nbcd_curpos_{bufnr('%')})
" call Decho("unlet s:nbcd_curpos_".bufnr('%'),'~'.expand("<slnum>"))
if exists("s:nbcd_curpos_".bufnr('%'))
unlet s:nbcd_curpos_{bufnr('%')}
@@ -1729,11 +1740,11 @@ fun! s:NetrwOptionSave(vt)
let {a:vt}netrw_rokeep = &l:ro
let {a:vt}netrw_selkeep = &l:sel
let {a:vt}netrw_spellkeep = &l:spell
- if g:netrw_use_noswf
- let {a:vt}netrw_swfkeep = &l:swf
+ if !g:netrw_use_noswf
+ let {a:vt}netrw_swfkeep = &l:swf
endif
if has("clipboard")
- let {a:vt}netrw_starkeep = @*
+ let {a:vt}netrw_starkeep = @*
endif
let {a:vt}netrw_tskeep = &l:ts
let {a:vt}netrw_twkeep = &l:tw " textwidth
@@ -2664,7 +2675,9 @@ fun! netrw#NetSource(...)
" call Decho("exe so ".fnameescape(s:netrw_tmpfile),'~'.expand("<slnum>"))
exe "so ".fnameescape(s:netrw_tmpfile)
" call Decho("delete(".s:netrw_tmpfile.")",'~'.expand("<slnum>"))
- call delete(s:netrw_tmpfile)
+ if delete(s:netrw_tmpfile)
+ call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".s:netrw_tmpfile.">!",103)
+ endif
unlet s:netrw_tmpfile
else
call netrw#ErrorMsg(s:ERROR,"unable to source <".a:{i}.">!",48)
@@ -3504,7 +3517,11 @@ fun! s:NetrwBookHistSave()
let savefile= s:NetrwHome()."/.netrwhist"
1split
call s:NetrwEnew()
- setl cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 noswf
+ if g:netrw_use_noswf
+ setl cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 noswf
+ else
+ setl cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000
+ endif
setl nocin noai noci magic nospell nohid wig= noaw
setl ma noro write
if exists("+acd") | setl noacd | endif
@@ -3566,6 +3583,7 @@ fun! s:NetrwBrowse(islocal,dirname)
" This is useful when one edits a local file, then :e ., then :Rex
if a:islocal && !exists("w:netrw_rexfile") && bufname("#") != ""
let w:netrw_rexfile= bufname("#")
+" call Decho("setting w:netrw_rexfile<".w:netrw_rexfile."> win#".winnr())
endif
" s:NetrwBrowse : initialize history {{{3
@@ -3683,7 +3701,8 @@ fun! s:NetrwBrowse(islocal,dirname)
" get/set-up buffer {{{3
" call Decho("saving position across a buffer refresh",'~'.expand("<slnum>"))
- let svpos = netrw#SavePosn()
+ let svpos = winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
let reusing= s:NetrwGetBuffer(a:islocal,dirname)
" maintain markfile highlighting
@@ -3792,10 +3811,18 @@ fun! s:NetrwBrowse(islocal,dirname)
NetrwKeepj call s:NetrwCommands(a:islocal)
NetrwKeepj call s:PerformListing(a:islocal)
+ " restore option(s)
+ call s:NetrwOptionRestore("w:")
+" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>"))
+
" If there is a rexposn: restore position with rexposn
" Otherwise : set rexposn
if exists("s:rexposn_".bufnr("%"))
- NetrwKeepj call netrw#RestorePosn(s:rexposn_{bufnr('%')})
+" call Decho("restoring posn to s:rexposn_".bufnr('%')."<".string(s:rexposn_{bufnr('%')}).">",'~'.expand("<slnum>"))
+ NetrwKeepj call winrestview(s:rexposn_{bufnr('%')})
+ if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt
+ NetrwKeepj exe w:netrw_bannercnt
+ endif
else
NetrwKeepj call s:SetRexDir(a:islocal,b:netrw_curdir)
endif
@@ -3804,13 +3831,11 @@ fun! s:NetrwBrowse(islocal,dirname)
" call Decho("set up balloon help: l:bexpr=".&l:bexpr,'~'.expand("<slnum>"))
setl beval
endif
- call s:NetrwOptionRestore("w:")
-" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>"))
" restore position
if reusing
-" call Decho("reusing=".reusing.": restoring position across buffer refresh",'~'.expand("<slnum>"))
- call netrw#RestorePosn(svpos)
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
+ call winrestview(svpos)
endif
" The s:LocalBrowseRefresh() function is called by an autocmd
@@ -3828,7 +3853,19 @@ endfun
" differ from vim's. This function insures that netrw's idea of the current
" directory is used.
fun! s:NetrwFile(fname)
-" call Dfunc("s:NetrwFile(fname<".a:fname.">)")
+" call Dfunc("s:NetrwFile(fname<".a:fname.">) win#".winnr())
+" call Decho("g:netrw_keepdir =".(exists("g:netrw_keepdir")? g:netrw_keepdir : 'n/a'))
+" call Decho("g:netrw_cygwin =".(exists("g:netrw_cygwin")? g:netrw_cygwin : 'n/a'))
+" call Decho("g:netrw_liststyle=".(exists("g:netrw_liststyle")? g:netrw_liststyle : 'n/a'))
+" call Decho("w:netrw_liststyle=".(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'))
+
+ " clean up any leading treedepthstring
+ if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
+ let fname= substitute(a:fname,'^'.s:treedepthstring.'\+','','')
+" call Decho("clean up any leading treedepthstring: fname<".fname.">")
+ else
+ let fname= a:fname
+ endif
if g:netrw_keepdir
" vim's idea of the current directory possibly may differ from netrw's
@@ -3837,28 +3874,28 @@ fun! s:NetrwFile(fname)
endif
if !exists("g:netrw_cygwin") && (has("win32") || has("win95") || has("win64") || has("win16"))
- if a:fname =~ '^\' || a:fname =~ '^\a:\'
+ if fname =~ '^\' || fname =~ '^\a:\'
" windows, but full path given
- let ret= a:fname
-" call Decho("windows+full path: isdirectory(".a:fname.")",'~'.expand("<slnum>"))
+ let ret= fname
+" call Decho("windows+full path: isdirectory(".fname.")",'~'.expand("<slnum>"))
else
" windows, relative path given
- let ret= s:ComposePath(b:netrw_curdir,a:fname)
-" call Decho("windows+rltv path: isdirectory(".a:fname.")",'~'.expand("<slnum>"))
+ let ret= s:ComposePath(b:netrw_curdir,fname)
+" call Decho("windows+rltv path: isdirectory(".fname.")",'~'.expand("<slnum>"))
endif
- elseif a:fname =~ '^/'
+ elseif fname =~ '^/'
" not windows, full path given
- let ret= a:fname
-" call Decho("unix+full path: isdirectory(".a:fname.")",'~'.expand("<slnum>"))
+ let ret= fname
+" call Decho("unix+full path: isdirectory(".fname.")",'~'.expand("<slnum>"))
else
" not windows, relative path given
- let ret= s:ComposePath(b:netrw_curdir,a:fname)
-" call Decho("unix+rltv path: isdirectory(".a:fname.")",'~'.expand("<slnum>"))
+ let ret= s:ComposePath(b:netrw_curdir,fname)
+" call Decho("unix+rltv path: isdirectory(".fname.")",'~'.expand("<slnum>"))
endif
else
" vim and netrw agree on the current directory
- let ret= a:fname
+ let ret= fname
" call Decho("vim and netrw agree on current directory (g:netrw_keepdir=".g:netrw_keepdir.")",'~'.expand("<slnum>"))
endif
@@ -3872,23 +3909,29 @@ fun! s:NetrwFileInfo(islocal,fname)
" call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">) b:netrw_curdir<".b:netrw_curdir.">")
let ykeep= @@
if a:islocal
+ let lsopt= "-lsad"
+ if g:netrw_sizestyle =~ 'H'
+ let lsopt= "-lsadh"
+ elseif g:netrw_sizestyle =~ 'h'
+ let lsopt= "-lsadh --si"
+ endif
if (has("unix") || has("macunix")) && executable("/bin/ls")
if getline(".") == "../"
- echo system("/bin/ls -lsad ".s:ShellEscape(".."))
+ echo system("/bin/ls ".lsopt." ".s:ShellEscape(".."))
" call Decho("#1: echo system(/bin/ls -lsad ".s:ShellEscape(..).")",'~'.expand("<slnum>"))
elseif w:netrw_liststyle == s:TREELIST && getline(".") !~ '^'.s:treedepthstring
- echo system("/bin/ls -lsad ".s:ShellEscape(b:netrw_curdir))
+ echo system("/bin/ls ".lsopt." ".s:ShellEscape(b:netrw_curdir))
" call Decho("#2: echo system(/bin/ls -lsad ".s:ShellEscape(b:netrw_curdir).")",'~'.expand("<slnum>"))
elseif exists("b:netrw_curdir")
- echo system("/bin/ls -lsad ".s:ShellEscape(s:ComposePath(b:netrw_curdir,a:fname)))
+ echo system("/bin/ls ".lsopt." ".s:ShellEscape(s:ComposePath(b:netrw_curdir,a:fname)))
" call Decho("#3: echo system(/bin/ls -lsad ".s:ShellEscape(b:netrw_curdir.a:fname).")",'~'.expand("<slnum>"))
else
" call Decho('using ls '.a:fname." using cwd<".getcwd().">",'~'.expand("<slnum>"))
- echo system("/bin/ls -lsad ".s:ShellEscape(s:NetrwFile(a:fname)))
+ echo system("/bin/ls ".lsopt." ".s:ShellEscape(s:NetrwFile(a:fname)))
" call Decho("#5: echo system(/bin/ls -lsad ".s:ShellEscape(a:fname).")",'~'.expand("<slnum>"))
endif
else
@@ -3901,6 +3944,9 @@ fun! s:NetrwFileInfo(islocal,fname)
endif
let t = getftime(s:NetrwFile(fname))
let sz = getfsize(s:NetrwFile(fname))
+ if g:netrw_sizestyle =~ "[hH]"
+ let sz= s:NetrwHumanReadable(sz)
+ endif
echo a:fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(s:NetrwFile(fname)))
" call Decho("fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname)),'~'.expand("<slnum>"))
endif
@@ -4029,11 +4075,15 @@ fun! s:NetrwGetBuffer(islocal,dirname)
let w:netrw_treebufnr= bufnr("%")
" call Decho(" exe sil! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum),'~'.expand("<slnum>"))
exe 'sil! keepalt file NetrwTreeListing\ '.fnameescape(s:netrw_treelistnum)
- setl bt=nofile noswf
- nnoremap <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr>
- nnoremap <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr>
- nnoremap <silent> <buffer> [[ :sil call <SID>TreeListMove('[')<cr>
- nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']')<cr>
+ if g:netrw_use_noswf
+ setl nobl bt=nofile noswf
+ else
+ setl nobl bt=nofile
+ endif
+ nnoremap <silent> <buffer> [[ :sil call <SID>TreeListMove('[[')<cr>
+ nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']]')<cr>
+ nnoremap <silent> <buffer> [] :sil call <SID>TreeListMove('[]')<cr>
+ nnoremap <silent> <buffer> ][ :sil call <SID>TreeListMove('][')<cr>
" call Decho(" tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr,'~'.expand("<slnum>"))
else
" let v:errmsg = "" " Decho
@@ -4197,7 +4247,7 @@ fun! s:NetrwGetWord()
NetrwKeepj norm! 0
let dirname= substitute(getline('.'),'^\(\%(\S\+ \)*\S\+\).\{-}$','\1','e')
- elseif w:netrw_liststyle == s:TREELIST
+ elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
" call Decho("treelist handling",'~'.expand("<slnum>"))
let dirname= substitute(getline('.'),'^\('.s:treedepthstring.'\)*','','e')
let dirname= substitute(dirname,'\t -->.*$','','')
@@ -4286,7 +4336,8 @@ fun! s:NetrwListStyle(islocal)
let ykeep = @@
let fname = s:NetrwGetWord()
if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif
- let svpos = netrw#SavePosn()
+ let svpos = winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
let w:netrw_liststyle = (w:netrw_liststyle + 1) % s:MAXLIST
" call Decho("fname<".fname.">",'~'.expand("<slnum>"))
" call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle,'~'.expand("<slnum>"))
@@ -4307,7 +4358,7 @@ fun! s:NetrwListStyle(islocal)
" call Decho("use wide list",'~'.expand("<slnum>"))
let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
- elseif w:netrw_liststyle == s:TREELIST
+ elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
" call Decho("use tree list",'~'.expand("<slnum>"))
let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
@@ -4334,7 +4385,8 @@ fun! s:NetrwListStyle(islocal)
NetrwKeepj call s:NetrwCursor()
" restore position; keep cursor on the filename
- NetrwKeepj call netrw#RestorePosn(svpos)
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
+ NetrwKeepj call winrestview(svpos)
let @@= ykeep
" call Dret("NetrwListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : ""))
@@ -4350,7 +4402,8 @@ fun! s:NetrwBannerCtrl(islocal)
let g:netrw_banner= !g:netrw_banner
" refresh the listing
- let svpos= netrw#SavePosn()
+ let svpos= winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
" keep cursor on the filename
@@ -4385,7 +4438,8 @@ fun! s:NetrwBookmark(del,...)
if exists("s:netrwmarkfilelist_{curbufnr}")
" for every filename in the marked list
" call Decho("bookmark every filename in marked list",'~'.expand("<slnum>"))
- let svpos = netrw#SavePosn()
+ let svpos = winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
let islocal= expand("%") !~ '^\a\{3,}://'
for fname in s:netrwmarkfilelist_{curbufnr}
if a:del|call s:DeleteBookmark(fname)|else|call s:MakeBookmark(fname)|endif
@@ -4393,7 +4447,8 @@ fun! s:NetrwBookmark(del,...)
let curdir = exists("b:netrw_curdir")? b:netrw_curdir : getcwd()
call s:NetrwUnmarkList(curbufnr,curdir)
NetrwKeepj call s:NetrwRefresh(islocal,s:NetrwBrowseChgDir(islocal,'./'))
- NetrwKeepj call netrw#RestorePosn(svpos)
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
+ NetrwKeepj call winrestview(svpos)
else
let fname= s:NetrwGetWord()
if a:del|call s:DeleteBookmark(fname)|else|call s:MakeBookmark(fname)|endif
@@ -4528,9 +4583,9 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
" call Decho("saving options",'~'.expand("<slnum>"))
NetrwKeepj call s:NetrwOptionSave("s:")
NetrwKeepj call s:NetrwSafeOptions()
- let nbcd_curpos = netrw#SavePosn()
+ let nbcd_curpos = winsaveview()
+" call Decho("saving posn to nbcd_curpos<".string(nbcd_curpos).">",'~'.expand("<slnum>"))
let s:nbcd_curpos_{bufnr('%')} = nbcd_curpos
-" call Decho("setting s:nbcd_curpos_".bufnr('%')." to SavePosn",'~'.expand("<slnum>"))
if (has("win32") || has("win95") || has("win64") || has("win16"))
let dirname = substitute(b:netrw_curdir,'\\','/','ge')
else
@@ -4553,7 +4608,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
setl ma noro nowrap
NetrwKeepj call setline(line('.'),'" Quick Help: <F1>:help '.s:QuickHelp[g:netrw_quickhelp])
setl noma nomod nowrap
- NetrwKeepj call netrw#RestorePosn(nbcd_curpos)
+" call Decho("restoring posn to nbcd_curpos<".string(nbcd_curpos).">",'~'.expand("<slnum>"))
+ NetrwKeepj call winrestview(nbcd_curpos)
NetrwKeepj call s:NetrwOptionRestore("s:")
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
endif
@@ -4585,8 +4641,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
" call Decho('edit-a-file: case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">",'~'.expand("<slnum>"))
" save position for benefit of Rexplore
- let s:rexposn_{bufnr("%")}= netrw#SavePosn()
-" call Decho("edit-a-file: setting s:rexposn_".bufnr("%")."<".bufname("%")."> to SavePosn",'~'.expand("<slnum>"))
+ let s:rexposn_{bufnr("%")}= winsaveview()
+" call Decho("edit-a-file: saving posn to s:rexposn_".bufnr("%")."<".string(s:rexposn_{bufnr("%")}).">",'~'.expand("<slnum>"))
" call Decho("edit-a-file: win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> ft=".&ft,'~'.expand("<slnum>"))
" call Decho("edit-a-file: w:netrw_liststyle=".(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a')." w:netrw_treedict:".(exists("w:netrw_treedict")? "exists" : 'n/a')." newdir<".newdir.">",'~'.expand("<slnum>"))
@@ -4602,6 +4658,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
" call Decho("edit-a-file: dirname<".dirname.">",'~'.expand("<slnum>"))
" call Decho("edit-a-file: tree listing",'~'.expand("<slnum>"))
elseif newdir =~ '^\(/\|\a:\)'
+" call Decho("edit-a-file: handle an url or path starting with /: <".newdir.">")
let dirname= newdir
else
let dirname= s:ComposePath(dirname,newdir)
@@ -4609,8 +4666,9 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
" call Decho("edit-a-file: handling a file: dirname<".dirname."> (a:0=".a:0.")",'~'.expand("<slnum>"))
" this lets netrw#BrowseX avoid the edit
if a:0 < 1
-" call Decho("edit-a-file: set up windows for editing<".fnameescape(dirname)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist"),'~'.expand("<slnum>"))
+" call Decho("edit-a-file: (a:0=".a:0."<1) set up windows for editing<".fnameescape(dirname)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist"),'~'.expand("<slnum>"))
NetrwKeepj call s:NetrwOptionRestore("s:")
+ let curdir= b:netrw_curdir
if !exists("s:didsplit")
" call Decho("edit-a-file: s:didsplit does not exist; g:netrw_browse_split=".string(g:netrw_browse_split)." win#".winnr(),'~'.expand("<slnum>"))
if type(g:netrw_browse_split) == 3
@@ -4627,6 +4685,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
if !&ea
keepalt wincmd _
endif
+ call s:SetRexDir(a:islocal,b:netrw_curdir)
elseif g:netrw_browse_split == 2
" vertically splitting the window first
" call Decho("edit-a-file: vertically splitting window prior to edit",'~'.expand("<slnum>"))
@@ -4634,10 +4693,12 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
if !&ea
keepalt wincmd |
endif
+ call s:SetRexDir(a:islocal,b:netrw_curdir)
elseif g:netrw_browse_split == 3
" open file in new tab
" call Decho("edit-a-file: opening new tab prior to edit",'~'.expand("<slnum>"))
keepalt tabnew
+ call s:SetRexDir(a:islocal,b:netrw_curdir)
elseif g:netrw_browse_split == 4
" act like "P" (ie. open previous window)
" call Decho("edit-a-file: use previous window for edit",'~'.expand("<slnum>"))
@@ -4646,6 +4707,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
" call Dret("s:NetrwBrowseChgDir")
return
endif
+ call s:SetRexDir(a:islocal,b:netrw_curdir)
else
" handling a file, didn't split, so remove menu
" call Decho("edit-a-file: handling a file+didn't split, so remove menu",'~'.expand("<slnum>"))
@@ -4663,6 +4725,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
endif
exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd w"
endif
+ call s:SetRexDir(a:islocal,curdir)
endif
endif
@@ -4802,7 +4865,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
" call Decho("tree-list: w:netrw_treedict<".string(w:netrw_treedict).">",'~'.expand("<slnum>"))
" search treedict for tree dir as-is
-" call Decho("search treedict for tree dir as-is",'~'.expand("<slnum>"))
+" call Decho("tree-list: search treedict for tree dir as-is",'~'.expand("<slnum>"))
if has_key(w:netrw_treedict,treedir)
" call Decho('tree-list: ....searched for treedir<'.treedir.'> : found it!','~'.expand("<slnum>"))
let haskey= 1
@@ -4811,7 +4874,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
endif
" search treedict for treedir with a [/@] appended
-" call Decho("search treedict for treedir with a [/@] appended",'~'.expand("<slnum>"))
+" call Decho("tree-list: search treedict for treedir with a [/@] appended",'~'.expand("<slnum>"))
if !haskey && treedir !~ '[/@]$'
if has_key(w:netrw_treedict,treedir."/")
let treedir= treedir."/"
@@ -4823,7 +4886,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
endif
" search treedict for treedir with any trailing / elided
-" call Decho("search treedict for treedir with any trailing / elided",'~'.expand("<slnum>"))
+" call Decho("tree-list: search treedict for treedir with any trailing / elided",'~'.expand("<slnum>"))
if !haskey && treedir =~ '/$'
let treedir= substitute(treedir,'/$','','')
if has_key(w:netrw_treedict,treedir)
@@ -4967,14 +5030,15 @@ fun! netrw#BrowseX(fname,remote)
" call Dfunc("netrw#BrowseX(fname<".a:fname."> remote=".a:remote.")")
" if its really just a directory, then do a "gf" instead
- if a:fname =~ '/$'
+ if (a:remote == 0 && isdirectory(a:fname)) || (a:remote == 1 && fname =~ '/$' && fname !~ '^https\=:')
norm! gf
" call Dret("netrw#BrowseX : did gf instead")
endif
let ykeep = @@
- let screenposn = netrw#SavePosn()
+ let screenposn = winsaveview()
+" call Decho("saving posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>"))
" need to save and restore aw setting as gx can invoke this function from non-netrw buffers
let awkeep = &aw
@@ -4996,7 +5060,8 @@ fun! netrw#BrowseX(fname,remote)
endif
endfor
endif
- call netrw#RestorePosn(screenposn)
+" call Decho("restoring posn to screenposn<".string(screenposn).">,'~'.expand("<slnum>"))"
+ call winrestview(screenposn)
let @@= ykeep
let &aw= awkeep
" call Dret("netrw#BrowseX : coredump handler invoked")
@@ -5167,7 +5232,8 @@ fun! netrw#BrowseX(fname,remote)
exe "sil! NetrwKeepj norm! \<c-o>"
" redraw!
endif
- call netrw#RestorePosn(screenposn)
+" call Decho("restoring posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>"))
+ call winrestview(screenposn)
let @@ = ykeep
let &aw= awkeep
@@ -5310,6 +5376,32 @@ fun! s:NetrwForceChgDir(islocal,newdir)
endfun
" ---------------------------------------------------------------------
+" s:NetrwGlob: does glob() if local, remote listing otherwise {{{2
+fun! s:NetrwGlob(direntry,expr)
+" call Dfunc("s:NetrwGlob(direntry<".a:direntry."> expr<".a:expr.">)")
+ if netrw#CheckIfRemote()
+ keepalt 1sp
+ keepalt enew
+ let keep_liststyle = w:netrw_liststyle
+ let w:netrw_liststyle = s:THINLIST
+ if s:NetrwRemoteListing() == 0
+ keepj keepalt %s@/@@
+ let filelist= getline(1,$)
+ q!
+ else
+ " remote listing error -- leave treedict unchanged
+ let filelist= w:netrw_treedict[a:direntry]
+ endif
+ let w:netrw_liststyle= keep_liststyle
+ else
+ let filelist= glob(s:ComposePath(a:direntry,a:expr),0,1,1)
+ let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")')
+ endif
+" call Dret("s:NetrwGlob ".string(filelist))
+ return filelist
+endfun
+
+" ---------------------------------------------------------------------
" s:NetrwForceFile: (gf support) Force treatment as a file {{{2
fun! s:NetrwForceFile(islocal,newfile)
" call Dfunc("s:NetrwForceFile(islocal=".a:islocal." newdir<".a:newfile.">)")
@@ -5336,7 +5428,8 @@ endfun
fun! s:NetrwHide(islocal)
" call Dfunc("NetrwHide(islocal=".a:islocal.") g:netrw_hide=".g:netrw_hide)
let ykeep= @@
- let svpos= netrw#SavePosn()
+ let svpos= winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
if exists("s:netrwmarkfilelist_{bufnr('%')}")
" call Decho("((g:netrw_hide == 1)? "unhide" : "hide")." files in markfilelist<".string(s:netrwmarkfilelist_{bufnr("%")}).">",'~'.expand("<slnum>"))
@@ -5378,7 +5471,8 @@ fun! s:NetrwHide(islocal)
endif
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
- NetrwKeepj call netrw#RestorePosn(svpos)
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
+ NetrwKeepj call winrestview(svpos)
let @@= ykeep
" call Dret("NetrwHide")
endfun
@@ -5390,7 +5484,8 @@ fun! s:NetrwHideEdit(islocal)
let ykeep= @@
" save current cursor position
- let svpos= netrw#SavePosn()
+ let svpos= winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
" get new hiding list from user
call inputsave()
@@ -5403,7 +5498,8 @@ fun! s:NetrwHideEdit(islocal)
sil NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,"./"))
" restore cursor position
- call netrw#RestorePosn(svpos)
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
+ call winrestview(svpos)
let @@= ykeep
" call Dret("NetrwHideEdit")
@@ -5415,7 +5511,8 @@ fun! s:NetrwHidden(islocal)
" call Dfunc("s:NetrwHidden()")
let ykeep= @@
" save current position
- let svpos= netrw#SavePosn()
+ let svpos= winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
if g:netrw_list_hide =~ '\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+'
" remove pattern from hiding list
@@ -5428,7 +5525,8 @@ fun! s:NetrwHidden(islocal)
" refresh screen and return to saved position
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
- NetrwKeepj call netrw#RestorePosn(svpos)
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
+ NetrwKeepj call winrestview(svpos)
let @@= ykeep
" call Dret("s:NetrwHidden")
endfun
@@ -5540,10 +5638,10 @@ fun! s:NetrwServerEdit(islocal,fname)
if (islocal && isdirectory(s:NetrwFile(a:fname))) || (!islocal && a:fname =~ '/$')
" handle directories in the local window -- not in the remote vim server
- " user must have closed the NETRWSERVER window. Treat as a normal editing from netrw.
+ " user must have closed the NETRWSERVER window. Treat as normal editing from netrw.
" call Decho("handling directory in client window",'~'.expand("<slnum>"))
let g:netrw_browse_split= 0
- if exists("s:netrw_browse_split_".winnr())
+ if exists("s:netrw_browse_split") && exists("s:netrw_browse_split_".winnr())
let g:netrw_browse_split= s:netrw_browse_split_{winnr()}
unlet s:netrw_browse_split_{winnr()}
endif
@@ -5820,9 +5918,11 @@ fun! s:NetrwMakeDir(usrhost)
if v:shell_error == 0
" refresh listing
" call Decho("refresh listing",'~'.expand("<slnum>"))
- let svpos= netrw#SavePosn()
+ let svpos= winsaveview()
+" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./'))
- call netrw#RestorePosn(svpos)
+" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
+ call winrestview(svpos)
elseif !exists("g:netrw_quiet")
call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",26)
endif
@@ -5836,9 +5936,11 @@ fun! s:NetrwMakeDir(usrhost)
call s:NetrwExe("sil! !".mkdircmd." ".s:ShellEscape(newdirname,1))
if v:shell_error == 0
" refresh listing
- let svpos= netrw#SavePosn()
+ let svpos= winsaveview()