5353 lines · 199.1 KB · Text
RawDownload
" netrw.vim: Handles file transfer and remote directory listing across"            AUTOLOAD SECTION" Date:		May 05, 2007" Version:	109" Maintainer:	Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim" Copyright:    Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{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,"               netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided"               *as is* and comes with no warranty of any kind, either"               expressed or implied. By using this plugin, you agree that"               in no event will the copyright holder be liable for any damages"               resulting from the use of this software."               of this software." COMBAK: worked with tmpfile s:GetTempname() in NetRead() NetWrite()"         !!NEEDS DEBUGGING && TESTING!!!"redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()""  But be doers of the Word, and not only hearers, deluding your own selves {{{1"  (James 1:22 RSV)" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" Load Once: {{{1if &cp || exists("g:loaded_netrw")  finishendifif !exists("s:NOTE") let s:NOTE    = 0 let s:WARNING = 1 let s:ERROR   = 2endiflet g:loaded_netrw = "v109"if v:version < 700 call netrw#ErrorMsg(s:WARNING,"you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw",1) finishendiflet s:keepcpo= &cposetlocal cpo&vim"DechoTabOn"call Decho("doing autoload/netrw.vim version ".g:loaded_netrw) " ======================"  Netrw Variables: {{{1" ====================== " ---------------------------------------------------------------------"  Netrw Constants: {{{2if !exists("g:NETRW_BOOKMARKMAX") let g:NETRW_BOOKMARKMAX= 0endifif !exists("g:NETRW_DIRHIST_CNT") let g:NETRW_DIRHIST_CNT= 0endifif !exists("s:LONGLIST") let s:THINLIST = 0 let s:LONGLIST = 1 let s:WIDELIST = 2 let s:TREELIST = 3 let s:MAXLIST  = 4endif " ---------------------------------------------------------------------" Default values for netrw's global protocol variables {{{2if !exists("g:netrw_dav_cmd")  let g:netrw_dav_cmd	= "cadaver"endifif !exists("g:netrw_fetch_cmd") if executable("fetch")  let g:netrw_fetch_cmd	= "fetch -o" else  let g:netrw_fetch_cmd	= "" endifendifif !exists("g:netrw_ftp_cmd")  let g:netrw_ftp_cmd	= "ftp"endifif !exists("g:netrw_http_cmd") if executable("curl")  let g:netrw_http_cmd	= "curl -o" elseif executable("wget")  let g:netrw_http_cmd	= "wget -q -O" elseif executable("fetch")  let g:netrw_http_cmd	= "fetch -o" else  let g:netrw_http_cmd	= "" endifendifif !exists("g:netrw_rcp_cmd")  let g:netrw_rcp_cmd	= "rcp"endifif !exists("g:netrw_rsync_cmd")  let g:netrw_rsync_cmd	= "rsync"endifif !exists("g:netrw_scp_cmd")  let g:netrw_scp_cmd	= "scp -q"endifif !exists("g:netrw_sftp_cmd")  let g:netrw_sftp_cmd	= "sftp"endifif !exists("g:netrw_ssh_cmd") let g:netrw_ssh_cmd= "ssh"endif if (has("win32") || has("win95") || has("win64") || has("win16"))  \ && exists("g:netrw_use_nt_rcp")  \ && g:netrw_use_nt_rcp  \ && executable( $SystemRoot .'/system32/rcp.exe') let s:netrw_has_nt_rcp = 1 let s:netrw_rcpmode    = '-b'else let s:netrw_has_nt_rcp = 0 let s:netrw_rcpmode    = ''endif " ---------------------------------------------------------------------" Default values for netrw's global variables {{{2" Default values - a-c ---------- {{{3if !exists("g:netrw_alto") let g:netrw_alto= &sbendifif !exists("g:netrw_altv") let g:netrw_altv= &sprendifif !exists("g:netrw_browse_split") let g:netrw_browse_split= 0endifif !exists("g:netrw_chgwin") let g:netrw_chgwin    = -1endifif !exists("g:netrw_cygwin") if has("win32") || has("win95") || has("win64") || has("win16")  if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'   let g:netrw_cygwin= 1  else   let g:netrw_cygwin= 0  endif else  let g:netrw_cygwin= 0 endifelse let g:netrw_cygwin= 0endif" Default values - d-f ---------- {{{3if !exists("g:NETRW_DIRHIST_CNT") let g:NETRW_DIRHIST_CNT= 0endifif !exists("g:netrw_dirhistmax") let g:netrw_dirhistmax= 10endifif !exists("g:netrw_ftp_browse_reject") let g:netrw_ftp_browse_reject='^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$'endifif !exists("g:netrw_ftp_list_cmd") if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)  let g:netrw_ftp_list_cmd     = "ls -lF"  let g:netrw_ftp_timelist_cmd = "ls -tlF"  let g:netrw_ftp_sizelist_cmd = "ls -slF" else  let g:netrw_ftp_list_cmd     = "dir"  let g:netrw_ftp_timelist_cmd = "dir"  let g:netrw_ftp_sizelist_cmd = "dir" endifendifif !exists("g:netrw_ftpmode") let g:netrw_ftpmode= "binary"endif" Default values - h-lh ---------- {{{3if !exists("g:netrw_hide") let g:netrw_hide= 1endifif !exists("g:netrw_ignorenetrc") if &shell =~ '\c\<\%(cmd\|4nt\)\.exe$'  let g:netrw_ignorenetrc= 1 else  let g:netrw_ignorenetrc= 0 endifendifif !exists("g:netrw_keepdir") let g:netrw_keepdir= 1endifif !exists("g:netrw_list_cmd") if g:netrw_scp_cmd =~ '^pscp' && executable("pscp")  " provide a 'pscp' listing command  if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable("c:\\private.ppk")   let g:netrw_scp_cmd ="pscp -i C:\\private.ppk"  endif  let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:" elseif executable(g:netrw_ssh_cmd)  " provide a default listing command  let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa" else"  call Decho(g:netrw_ssh_cmd." is not executable")  let g:netrw_list_cmd= "" endifendifif !exists("g:netrw_list_hide") let g:netrw_list_hide= ""endif" Default values - lh-lz ---------- {{{3if !exists("g:netrw_local_mkdir") let g:netrw_local_mkdir= "mkdir"endifif !exists("g:netrw_local_rmdir") let g:netrw_local_rmdir= "rmdir"endifif !exists("g:netrw_liststyle") let g:netrw_liststyle= s:THINLISTendifif g:netrw_liststyle < 0 || g:netrw_liststyle >= s:MAXLIST " sanity check let g:netrw_liststyle= s:THINLISTendifif g:netrw_liststyle == s:LONGLIST && g:netrw_scp_cmd !~ '^pscp' let g:netrw_list_cmd= g:netrw_list_cmd." -l"endif" Default values - m-r ---------- {{{3if !exists("g:netrw_maxfilenamelen") let g:netrw_maxfilenamelen= 32endifif !exists("g:netrw_menu") let g:netrw_menu= 1endifif !exists("g:netrw_mkdir_cmd") let g:netrw_mkdir_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME mkdir"endifif !exists("g:netrw_scpport") let g:netrw_scpport= "-P"endifif !exists("g:netrw_sshport") let g:netrw_sshport= "-p"endifif !exists("g:netrw_rename_cmd") let g:netrw_rename_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME mv"endifif !exists("g:netrw_rm_cmd") let g:netrw_rm_cmd    = g:netrw_ssh_cmd." USEPORT HOSTNAME rm"endifif !exists("g:netrw_rmdir_cmd") let g:netrw_rmdir_cmd = g:netrw_ssh_cmd." USEPORT HOSTNAME rmdir"endifif !exists("g:netrw_rmf_cmd") let g:netrw_rmf_cmd    = g:netrw_ssh_cmd." USEPORT HOSTNAME rm -f"endif" Default values - s ---------- {{{3if exists("g:netrw_silent") && g:netrw_silent != 0 let g:netrw_silentxfer= "silent "else let g:netrw_silentxfer= ""endifif !exists("g:netrw_fastbrowse") let g:netrw_fastbrowse= 1endifif !exists("g:netrw_shq") if exists("&shq") && &shq != ""  let g:netrw_shq= &shq elseif has("win32") || has("win95") || has("win64") || has("win16")  if g:netrw_cygwin   let g:netrw_shq= "'"  else   let g:netrw_shq= '"'  endif else  let g:netrw_shq= "'" endif" call Decho("g:netrw_shq<".g:netrw_shq.">")endifif !exists("g:netrw_sort_by") " alternatives: date size let g:netrw_sort_by= "name"endifif !exists("g:netrw_sort_direction") " alternative: reverse  (z y x ...) let g:netrw_sort_direction= "normal"endifif !exists("g:netrw_sort_sequence") let g:netrw_sort_sequence= '[\/]$,\.h$,\.c$,\.cpp$,\.[a-np-z]$,*,\.info$,\.swp$,\.o$\.obj$,\.bak$'endifif !exists("g:netrw_ssh_browse_reject")  let g:netrw_ssh_browse_reject='^total\s\+\d\+$'endifif !has("patch192") if !exists("g:netrw_use_noswf")  let g:netrw_use_noswf= 1 endifelse  let g:netrw_use_noswf= 0endif" Default values - t-w ---------- {{{3if !exists("g:netrw_timefmt") let g:netrw_timefmt= "%c"endifif !exists("g:NetrwTopLvlMenu") let g:NetrwTopLvlMenu= "Netrw."endifif !exists("g:netrw_use_errorwindow") let g:netrw_use_errorwindow= 1endifif !exists("g:netrw_win95ftp") let g:netrw_win95ftp= 1endifif !exists("g:netrw_winsize") let g:netrw_winsize= ""endif" ---------------------------------------------------------------------" Default values for netrw's script variables: {{{2if !exists("s:netrw_cd_escape")  let s:netrw_cd_escape="[]#*$%'\" ?`!&();<>\\"endifif !exists("g:netrw_fname_escape") let g:netrw_fname_escape= ' ?&;'endifif !exists("g:netrw_tmpfile_escape") let g:netrw_tmpfile_escape= ' ?&;'endifif !exists("s:netrw_glob_escape")  let s:netrw_glob_escape= '[]*?`{~$'endif " BufEnter event ignored by decho when following variable is true"  Has a side effect that doau BufReadPost doesn't work, so"  files read by network transfer aren't appropriately highlighted."let g:decho_bufenter = 1	"Decho " =============================="  Netrw Utility Functions: {{{1" ============================== " ------------------------------------------------------------------------" NetSavePosn: saves position of cursor on screen {{{2fun! netrw#NetSavePosn()"  call Dfunc("netrw#NetSavePosn()")  " Save current line and column  let w:netrw_winnr= winnr()  let w:netrw_line = line(".")  let w:netrw_col  = virtcol(".")   " Save top-of-screen line  norm! H0  let w:netrw_hline= line(".")   call netrw#NetRestorePosn()"  call Dret("netrw#NetSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline)endfun " ------------------------------------------------------------------------" NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{2fun! netrw#NetRestorePosn()"  call Dfunc("netrw#NetRestorePosn() winnr=".(exists("w:netrw_winnr")? w:netrw_winnr : -1)." line=".(exists("w:netrw_line")? w:netrw_line : -1)." col=".(exists("w:netrw_col")? w:netrw_col : -1)." hline=".(exists("w:netrw_hline")? w:netrw_hline : -1))  let eikeep= &ei  set ei=all  if expand("%") == "NetrwMessage"   exe s:winBeforeErr."wincmd w"  endif   " restore window  if exists("w:netrw_winnr")"   call Decho("restore window: exe silent! ".w:netrw_winnr."wincmd w")   exe "silent! ".w:netrw_winnr."wincmd w"  endif  if v:shell_error == 0   " as suggested by Bram M: redraw on no error   " allows protocol error messages to remain visible   redraw!  endif   " restore top-of-screen line  if exists("w:netrw_hline")"   call Decho("restore topofscreen: exe norm! ".w:netrw_hline."G0z")   exe "norm! ".w:netrw_hline."G0z\<CR>"  endif   " restore position  if exists("w:netrw_line") && exists("w:netrw_col")"   call Decho("restore posn: exe norm! ".w:netrw_line."G0".w:netrw_col."|")   exe "norm! ".w:netrw_line."G0".w:netrw_col."\<bar>"  endif   let &ei= eikeep"  call Dret("netrw#NetRestorePosn")endfun " ===============================" NetOptionSave: save options and set to "standard" form {{{2"DechoTabOnfun! s:NetOptionSave()"  call Dfunc("s:NetOptionSave() win#".winnr()." buf#".bufnr("."))  if !exists("w:netrw_optionsave")   let w:netrw_optionsave= 1  else"   call Dret("s:NetOptionSave : netoptionsave=".w:netrw_optionsave)   return  endif   " Save current settings and current directory  let s:yykeep          = @@  if exists("&l:acd")   let w:netrw_acdkeep  = &l:acd  endif  let w:netrw_aikeep    = &l:ai  let w:netrw_awkeep    = &l:aw  let w:netrw_cikeep    = &l:ci  let w:netrw_cinkeep   = &l:cin  let w:netrw_cinokeep  = &l:cino  let w:netrw_comkeep   = &l:com  let w:netrw_cpokeep   = &l:cpo  if g:netrw_keepdir   let w:netrw_dirkeep  = getcwd()  endif  let w:netrw_fokeep    = &l:fo           " formatoptions  let w:netrw_gdkeep    = &l:gd           " gdefault  let w:netrw_hidkeep   = &l:hidden  let w:netrw_magickeep = &l:magic  let w:netrw_repkeep   = &l:report  let w:netrw_spellkeep = &l:spell  let w:netrw_twkeep    = &l:tw           " textwidth  let w:netrw_wigkeep   = &l:wig          " wildignore  if has("win32") && !has("win95")   let w:netrw_swfkeep= &l:swf            " swapfile  endif  call s:NetrwSafeOptions()  if &go =~ 'a' | silent! let w:netrw_regstar = @* | endif  silent! let w:netrw_regslash= @/ "  call Dret("s:NetOptionSave")"  call Dret("s:NetOptionSave : win#".winnr()." buf#".bufnr("."))endfun " ------------------------------------------------------------------------" NetOptionRestore: restore options {{{2fun! s:NetOptionRestore()"  call Dfunc("s:NetOptionRestore() win#".winnr()." buf#".bufnr("."))  if !exists("w:netrw_optionsave")"   call Dret("s:NetOptionRestore : w:netrw_optionsave doesn't exist")   return  endif  unlet w:netrw_optionsave   if exists("&acd")   if exists("w:netrw_acdkeep") |let &l:acd    = w:netrw_acdkeep     |unlet w:netrw_acdkeep  |endif  endif  if exists("w:netrw_aikeep")   |let &l:ai     = w:netrw_aikeep      |unlet w:netrw_aikeep   |endif  if exists("w:netrw_awkeep")   |let &l:aw     = w:netrw_awkeep      |unlet w:netrw_awkeep   |endif  if exists("w:netrw_cikeep")   |let &l:ci     = w:netrw_cikeep      |unlet w:netrw_cikeep   |endif  if exists("w:netrw_cinkeep")  |let &l:cin    = w:netrw_cinkeep     |unlet w:netrw_cinkeep  |endif  if exists("w:netrw_cinokeep") |let &l:cino   = w:netrw_cinokeep    |unlet w:netrw_cinokeep |endif  if exists("w:netrw_comkeep")  |let &l:com    = w:netrw_comkeep     |unlet w:netrw_comkeep  |endif  if exists("w:netrw_cpokeep")  |let &l:cpo    = w:netrw_cpokeep     |unlet w:netrw_cpokeep  |endif  if exists("w:netrw_dirkeep")  |exe "lcd ".w:netrw_dirkeep          |unlet w:netrw_dirkeep  |endif  if exists("w:netrw_fokeep")   |let &l:fo     = w:netrw_fokeep      |unlet w:netrw_fokeep   |endif  if exists("w:netrw_gdkeep")   |let &l:gd     = w:netrw_gdkeep      |unlet w:netrw_gdkeep   |endif  if exists("w:netrw_hidkeep")  |let &l:hidden = w:netrw_hidkeep     |unlet w:netrw_hidkeep  |endif  if exists("w:netrw_magic")    |let &l:magic  = w:netrw_magic       |unlet w:netrw_magic    |endif  if exists("w:netrw_repkeep")  |let &l:report = w:netrw_repkeep     |unlet w:netrw_repkeep  |endif  if exists("w:netrw_spellkeep")|let &l:spell  = w:netrw_spellkeep   |unlet w:netrw_spellkeep|endif  if exists("w:netrw_twkeep")   |let &l:tw     = w:netrw_twkeep      |unlet w:netrw_twkeep   |endif  if exists("w:netrw_wigkeep")  |let &l:wig    = w:netrw_wigkeep     |unlet w:netrw_wigkeep  |endif  if exists("s:yykeep")         |let  @@       = s:yykeep            |unlet s:yykeep         |endif  if exists("w:netrw_swfkeep")   if &directory == ""    " user hasn't specified a swapfile directory;    " netrw will temporarily set the swapfile directory    " to the current directory as returned by getcwd().    let &l:directory   = getcwd()    silent! let &l:swf = w:netrw_swfkeep    setlocal directory=    unlet w:netrw_swfkeep   elseif &l:swf != w:netrw_swfkeep    " following line causes a Press ENTER in windows -- can't seem to work around it!!! (COMBAK)    silent! let &l:swf= w:netrw_swfkeep    unlet w:netrw_swfkeep   endif  endif  if exists("w:netrw_regstar") |silent! let @*= w:netrw_regstar |unlet w:netrw_regstar |endif  if exists("w:netrw_regslash")|silent! let @/= w:netrw_regslash|unlet w:netrw_regslash|endif "  call Dret("s:NetOptionRestore : win#".winnr()." buf#".bufnr("."))endfun " ---------------------------------------------------------------------" NetrwSafeOptions: sets options to help netrw do its job {{{2fun! s:NetrwSafeOptions()"  call Dfunc("s:NetrwSafeOptions()")  setlocal cino=  setlocal com=  setlocal cpo-=aA  if exists("&acd")   setlocal noacd nocin noai noci magic nospell nohid wig= noaw   setlocal fo=nroql2  else   setlocal nocin noai noci magic nospell nohid wig= noaw   setlocal fo=nroql2  endif  setlocal tw=0  setlocal report=10000  if g:netrw_use_noswf && has("win32") && !has("win95")   setlocal noswf  endif"  call Dret("s:NetrwSafeOptions")endfun

Lines 1–500 of 5353.