dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

netrwPlugin.vim (9838B)


      1 " netrwPlugin.vim: Handles file transfer and remote directory listing across a network
      2 "            PLUGIN SECTION
      3 " Date:		Feb 08, 2016
      4 " Maintainer:	Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
      5 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
      6 " Copyright:    Copyright (C) 1999-2013 Charles E. Campbell {{{1
      7 "               Permission is hereby granted to use and distribute this code,
      8 "               with or without modifications, provided that this copyright
      9 "               notice is copied with it. Like anything else that's free,
     10 "               netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided
     11 "               *as is* and comes with no warranty of any kind, either
     12 "               expressed or implied. By using this plugin, you agree that
     13 "               in no event will the copyright holder be liable for any damages
     14 "               resulting from the use of this software.
     15 "
     16 "  But be doers of the Word, and not only hearers, deluding your own selves {{{1
     17 "  (James 1:22 RSV)
     18 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     19 " Load Once: {{{1
     20 if &cp || exists("g:loaded_netrwPlugin")
     21  finish
     22 endif
     23 let g:loaded_netrwPlugin = "v168"
     24 let s:keepcpo = &cpo
     25 set cpo&vim
     26 "DechoRemOn
     27 
     28 " ---------------------------------------------------------------------
     29 " Public Interface: {{{1
     30 
     31 " Local Browsing Autocmds: {{{2
     32 augroup FileExplorer
     33  au!
     34  au BufLeave *  if &ft != "netrw"|let w:netrw_prvfile= expand("%:p")|endif
     35  au BufEnter *	sil call s:LocalBrowse(expand("<amatch>"))
     36  au VimEnter *	sil call s:VimEnter(expand("<amatch>"))
     37  if has("win32") || has("win95") || has("win64") || has("win16")
     38   au BufEnter .* sil call s:LocalBrowse(expand("<amatch>"))
     39  endif
     40 augroup END
     41 
     42 " Network Browsing Reading Writing: {{{2
     43 augroup Network
     44  au!
     45  au BufReadCmd   file://*											call netrw#FileUrlEdit(expand("<amatch>"))
     46  au BufReadCmd   ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://*	exe "sil doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "sil doau BufReadPost ".fnameescape(expand("<amatch>"))
     47  au FileReadCmd  ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://*	exe "sil doau FileReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(1,expand("<amatch>"))|exe "sil doau FileReadPost ".fnameescape(expand("<amatch>"))
     48  au BufWriteCmd  ftp://*,rcp://*,scp://*,http://*,file://*,dav://*,davs://*,rsync://*,sftp://*			exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
     49  au FileWriteCmd ftp://*,rcp://*,scp://*,http://*,file://*,dav://*,davs://*,rsync://*,sftp://*			exe "sil doau FileWritePre ".fnameescape(expand("<amatch>"))|exe "'[,']".'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau FileWritePost ".fnameescape(expand("<amatch>"))
     50  try
     51   au SourceCmd   ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://*	exe 'Nsource '.fnameescape(expand("<amatch>"))
     52  catch /^Vim\%((\a\+)\)\=:E216/
     53   au SourcePre   ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://*	exe 'Nsource '.fnameescape(expand("<amatch>"))
     54  endtry
     55 augroup END
     56 
     57 " Commands: :Nread, :Nwrite, :NetUserPass {{{2
     58 com! -count=1 -nargs=*	Nread		let s:svpos= winsaveview()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call winrestview(s:svpos)
     59 com! -range=% -nargs=*	Nwrite		let s:svpos= winsaveview()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call winrestview(s:svpos)
     60 com! -nargs=*		NetUserPass	call NetUserPass(<f-args>)
     61 com! -nargs=*	        Nsource		let s:svpos= winsaveview()<bar>call netrw#NetSource(<f-args>)<bar>call winrestview(s:svpos)
     62 com! -nargs=?		Ntree		call netrw#SetTreetop(1,<q-args>)
     63 
     64 " Commands: :Explore, :Sexplore, Hexplore, Vexplore, Lexplore {{{2
     65 com! -nargs=* -bar -bang -count=0 -complete=dir	Explore		call netrw#Explore(<count>,0,0+<bang>0,<q-args>)
     66 com! -nargs=* -bar -bang -count=0 -complete=dir	Sexplore	call netrw#Explore(<count>,1,0+<bang>0,<q-args>)
     67 com! -nargs=* -bar -bang -count=0 -complete=dir	Hexplore	call netrw#Explore(<count>,1,2+<bang>0,<q-args>)
     68 com! -nargs=* -bar -bang -count=0 -complete=dir	Vexplore	call netrw#Explore(<count>,1,4+<bang>0,<q-args>)
     69 com! -nargs=* -bar       -count=0 -complete=dir	Texplore	call netrw#Explore(<count>,0,6        ,<q-args>)
     70 com! -nargs=* -bar -bang			Nexplore	call netrw#Explore(-1,0,0,<q-args>)
     71 com! -nargs=* -bar -bang			Pexplore	call netrw#Explore(-2,0,0,<q-args>)
     72 com! -nargs=* -bar -bang -count=0 -complete=dir Lexplore	call netrw#Lexplore(<count>,<bang>0,<q-args>)
     73 
     74 " Commands: NetrwSettings {{{2
     75 com! -nargs=0	NetrwSettings	call netrwSettings#NetrwSettings()
     76 com! -bang	NetrwClean	call netrw#Clean(<bang>0)
     77 
     78 " Maps:
     79 if !exists("g:netrw_nogx")
     80  if maparg('gx','n') == ""
     81   if !hasmapto('<Plug>NetrwBrowseX')
     82    nmap <unique> gx <Plug>NetrwBrowseX
     83   endif
     84   nno <silent> <Plug>NetrwBrowseX :call netrw#BrowseX(netrw#GX(),netrw#CheckIfRemote(netrw#GX()))<cr>
     85  endif
     86  if maparg('gx','v') == ""
     87   if !hasmapto('<Plug>NetrwBrowseXVis')
     88    vmap <unique> gx <Plug>NetrwBrowseXVis
     89   endif
     90   vno <silent> <Plug>NetrwBrowseXVis :<c-u>call netrw#BrowseXVis()<cr>
     91  endif
     92 endif
     93 if exists("g:netrw_usetab") && g:netrw_usetab
     94  if maparg('<c-tab>','n') == ""
     95   nmap <unique> <c-tab> <Plug>NetrwShrink
     96  endif
     97  nno <silent> <Plug>NetrwShrink :call netrw#Shrink()<cr>
     98 endif
     99 
    100 " ---------------------------------------------------------------------
    101 " LocalBrowse: invokes netrw#LocalBrowseCheck() on directory buffers {{{2
    102 fun! s:LocalBrowse(dirname)
    103   " Unfortunate interaction -- only DechoMsg debugging calls can be safely used here.
    104   " Otherwise, the BufEnter event gets triggered when attempts to write to
    105   " the DBG buffer are made.
    106 
    107   if !exists("s:vimentered")
    108    " If s:vimentered doesn't exist, then the VimEnter event hasn't fired.  It will,
    109    " and so s:VimEnter() will then be calling this routine, but this time with s:vimentered defined.
    110 "   call Dfunc("s:LocalBrowse(dirname<".a:dirname.">)  (s:vimentered doesn't exist)")
    111 "   call Dret("s:LocalBrowse")
    112    return
    113   endif
    114 
    115 "  call Dfunc("s:LocalBrowse(dirname<".a:dirname.">)  (s:vimentered=".s:vimentered.")")
    116 
    117   if has("amiga")
    118    " The check against '' is made for the Amiga, where the empty
    119    " string is the current directory and not checking would break
    120    " things such as the help command.
    121 "   call Decho("(LocalBrowse) dirname<".a:dirname.">  (isdirectory, amiga)")
    122    if a:dirname != '' && isdirectory(a:dirname)
    123     sil! call netrw#LocalBrowseCheck(a:dirname)
    124     if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt
    125      exe w:netrw_bannercnt
    126     endif
    127    endif
    128 
    129   elseif isdirectory(a:dirname)
    130 "   call Decho("(LocalBrowse) dirname<".a:dirname."> ft=".&ft."  (isdirectory, not amiga)")
    131 "   call Dredir("LocalBrowse ft last set: ","verbose set ft")
    132    sil! call netrw#LocalBrowseCheck(a:dirname)
    133    if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt
    134     exe w:netrw_bannercnt
    135    endif
    136 
    137   else
    138    " not a directory, ignore it
    139 "   call Decho("(LocalBrowse) dirname<".a:dirname."> not a directory, ignoring...")
    140   endif
    141 
    142 "  call Dret("s:LocalBrowse")
    143 endfun
    144 
    145 " ---------------------------------------------------------------------
    146 " s:VimEnter: after all vim startup stuff is done, this function is called. {{{2
    147 "             Its purpose: to look over all windows and run s:LocalBrowse() on
    148 "             them, which checks if they're directories and will create a directory
    149 "             listing when appropriate.
    150 "             It also sets s:vimentered, letting s:LocalBrowse() know that s:VimEnter()
    151 "             has already been called.
    152 fun! s:VimEnter(dirname)
    153 "  call Dfunc("s:VimEnter(dirname<".a:dirname.">) expand(%)<".expand("%").">")
    154   let curwin       = winnr()
    155   let s:vimentered = 1
    156   windo call s:LocalBrowse(expand("%:p"))
    157   exe curwin."wincmd w"
    158 "  call Dret("s:VimEnter")
    159 endfun
    160 
    161 " ---------------------------------------------------------------------
    162 " NetrwStatusLine: {{{1
    163 fun! NetrwStatusLine()
    164 "  let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr("%")." Xline#".w:netrw_explore_line." line#".line(".")
    165   if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list")
    166    let &stl= s:netrw_explore_stl
    167    if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
    168    if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif
    169    return ""
    170   else
    171    return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
    172   endif
    173 endfun
    174 
    175 " ------------------------------------------------------------------------
    176 " NetUserPass: set username and password for subsequent ftp transfer {{{1
    177 "   Usage:  :call NetUserPass()			-- will prompt for userid and password
    178 "	    :call NetUserPass("uid")		-- will prompt for password
    179 "	    :call NetUserPass("uid","password") -- sets global userid and password
    180 fun! NetUserPass(...)
    181 
    182  " get/set userid
    183  if a:0 == 0
    184 "  call Dfunc("NetUserPass(a:0<".a:0.">)")
    185   if !exists("g:netrw_uid") || g:netrw_uid == ""
    186    " via prompt
    187    let g:netrw_uid= input('Enter username: ')
    188   endif
    189  else	" from command line
    190 "  call Dfunc("NetUserPass(a:1<".a:1.">) {")
    191   let g:netrw_uid= a:1
    192  endif
    193 
    194  " get password
    195  if a:0 <= 1 " via prompt
    196 "  call Decho("a:0=".a:0." case <=1:")
    197   let g:netrw_passwd= inputsecret("Enter Password: ")
    198  else " from command line
    199 "  call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
    200   let g:netrw_passwd=a:2
    201  endif
    202 "  call Dret("NetUserPass")
    203 endfun
    204 
    205 " ------------------------------------------------------------------------
    206 " Modelines And Restoration: {{{1
    207 let &cpo= s:keepcpo
    208 unlet s:keepcpo
    209 " vim:ts=8 fdm=marker