|
Karsten Hopp |
cf9f5a |
" netrwPlugin.vim: Handles file transfer and remote directory listing across a network
|
|
Karsten Hopp |
cf9f5a |
" PLUGIN SECTION
|
|
Karsten Hopp |
cf9f5a |
" Date: Aug 10, 2008
|
|
Karsten Hopp |
cf9f5a |
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
|
|
Karsten Hopp |
cf9f5a |
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
|
|
Karsten Hopp |
cf9f5a |
" Copyright: Copyright (C) 1999-2008 Charles E. Campbell, Jr. {{{1
|
|
Karsten Hopp |
cf9f5a |
" Permission is hereby granted to use and distribute this code,
|
|
Karsten Hopp |
cf9f5a |
" with or without modifications, provided that this copyright
|
|
Karsten Hopp |
cf9f5a |
" notice is copied with it. Like anything else that's free,
|
|
Karsten Hopp |
cf9f5a |
" netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided
|
|
Karsten Hopp |
cf9f5a |
" *as is* and comes with no warranty of any kind, either
|
|
Karsten Hopp |
cf9f5a |
" expressed or implied. By using this plugin, you agree that
|
|
Karsten Hopp |
cf9f5a |
" in no event will the copyright holder be liable for any damages
|
|
Karsten Hopp |
cf9f5a |
" resulting from the use of this software.
|
|
Karsten Hopp |
cf9f5a |
"
|
|
Karsten Hopp |
cf9f5a |
" But be doers of the Word, and not only hearers, deluding your own selves {{{1
|
|
Karsten Hopp |
cf9f5a |
" (James 1:22 RSV)
|
|
Karsten Hopp |
cf9f5a |
" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
|
Karsten Hopp |
cf9f5a |
" Load Once: {{{1
|
|
Karsten Hopp |
cf9f5a |
if &cp || exists("g:loaded_netrwPlugin")
|
|
Karsten Hopp |
cf9f5a |
finish
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
let g:loaded_netrwPlugin = "v134"
|
|
Karsten Hopp |
cf9f5a |
if v:version < 702
|
|
Karsten Hopp |
cf9f5a |
echohl WarningMsg | echo "***netrw*** you need vim version 7.2 for this version of netrw" | echohl None
|
|
Karsten Hopp |
cf9f5a |
finish
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
let s:keepcpo = &cpo
|
|
Karsten Hopp |
cf9f5a |
set cpo&vim
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" ---------------------------------------------------------------------
|
|
Karsten Hopp |
cf9f5a |
" Public Interface: {{{1
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" Local Browsing: {{{2
|
|
Karsten Hopp |
cf9f5a |
augroup FileExplorer
|
|
Karsten Hopp |
cf9f5a |
au!
|
|
Karsten Hopp |
cf9f5a |
au BufEnter * silent! call s:LocalBrowse(expand("<amatch>"))
|
|
Karsten Hopp |
cf9f5a |
if has("win32") || has("win95") || has("win64") || has("win16")
|
|
Karsten Hopp |
cf9f5a |
au BufEnter .* silent! call s:LocalBrowse(expand("<amatch>"))
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
augroup END
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" Network Browsing Reading Writing: {{{2
|
|
Karsten Hopp |
cf9f5a |
augroup Network
|
|
Karsten Hopp |
cf9f5a |
au!
|
|
Karsten Hopp |
cf9f5a |
if has("win32") || has("win95") || has("win64") || has("win16")
|
|
Karsten Hopp |
cf9f5a |
au BufReadCmd file://* exe "silent doau BufReadPre ".fnameescape(netrw#RFC2396(expand("<amatch>")))|exe 'e '.fnameescape(substitute(netrw#RFC2396(expand("<amatch>")),'file://\(.*\)','\1',""))|exe "bwipe ".fnameescape(expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(netrw#RFC2396(expand("<amatch>")))
|
|
Karsten Hopp |
cf9f5a |
else
|
|
Karsten Hopp |
cf9f5a |
au BufReadCmd file://* exe "silent doau BufReadPre ".fnameescape(netrw#RFC2396(expand("<amatch>")))|exe 'e '.fnameescape(substitute(netrw#RFC2396(expand("<amatch>")),'file://\(.*\)','\1',""))|exe "bwipe ".fnameescape(expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(netrw#RFC2396(expand("<amatch>")))
|
|
Karsten Hopp |
cf9f5a |
au BufReadCmd file://localhost/* exe "silent doau BufReadPre ".fnameescape(netrw#RFC2396(expand("<amatch>")))|exe 'e '.fnameescape(substitute(netrw#RFC2396(expand("<amatch>")),'file://localhost/\(.*\)','\1',""))|exe "bwipe ".fnameescape(substitute(expand("<amatch>"),'file://\(\k\+@\)\=','',''))|exe "silent doau BufReadPost ".fnameescape(netrw#RFC2396(expand("<amatch>")))
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
au BufReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau BufReadPre ".fnameescape(expand("<amatch>"))|exe '2Nread '.fnameescape(expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(expand("<amatch>"))
|
|
Karsten Hopp |
cf9f5a |
au FileReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau FileReadPre ".fnameescape(expand("<amatch>"))|exe 'Nread '.fnameescape(expand("<amatch>"))|exe "silent doau FileReadPost ".fnameescape(expand("<amatch>"))
|
|
Karsten Hopp |
cf9f5a |
au BufWriteCmd ftp://*,rcp://*,scp://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "silent doau BufWritePost ".fnameescape(expand("<amatch>"))
|
|
Karsten Hopp |
cf9f5a |
au FileWriteCmd ftp://*,rcp://*,scp://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau FileWritePre ".fnameescape(expand("<amatch>"))|exe "'[,']".'Nwrite '.fnameescape(expand("<amatch>"))|exe "silent doau FileWritePost ".fnameescape(expand("<amatch>"))
|
|
Karsten Hopp |
cf9f5a |
try
|
|
Karsten Hopp |
cf9f5a |
au SourceCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>"))
|
|
Karsten Hopp |
cf9f5a |
catch /^Vim\%((\a\+)\)\=:E216/
|
|
Karsten Hopp |
cf9f5a |
au SourcePre ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>"))
|
|
Karsten Hopp |
cf9f5a |
endtry
|
|
Karsten Hopp |
cf9f5a |
augroup END
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" Commands: :Nread, :Nwrite, :NetUserPass {{{2
|
|
Karsten Hopp |
cf9f5a |
com! -count=1 -nargs=* Nread call netrw#NetrwSavePosn()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call netrw#NetrwRestorePosn()
|
|
Karsten Hopp |
cf9f5a |
com! -range=% -nargs=* Nwrite call netrw#NetrwSavePosn()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call netrw#NetrwRestorePosn()
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* NetUserPass call NetUserPass(<f-args>)
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* Nsource call netrw#NetrwSavePosn()<bar>call netrw#NetSource(<f-args>)<bar>call netrw#NetrwRestorePosn()
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" Commands: :Explore, :Sexplore, Hexplore, Vexplore {{{2
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>)
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>,1,0+<bang>0,<q-args>)
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>,1,2+<bang>0,<q-args>)
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>,1,4+<bang>0,<q-args>)
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>,0,6 ,<q-args>)
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>)
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>)
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" Commands: NetrwSettings {{{2
|
|
Karsten Hopp |
cf9f5a |
com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings()
|
|
Karsten Hopp |
cf9f5a |
com! -bang NetrwClean call netrw#NetrwClean(<bang>0)
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" Maps:
|
|
Karsten Hopp |
cf9f5a |
if !exists("g:netrw_nogx") && maparg('g','n') == ""
|
|
Karsten Hopp |
cf9f5a |
if !hasmapto('<Plug>NetrwBrowseX')
|
|
Karsten Hopp |
cf9f5a |
nmap <unique> gx <Plug>NetrwBrowseX
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
nno <silent> <Plug>NetrwBrowseX :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<cr>
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" ---------------------------------------------------------------------
|
|
Karsten Hopp |
cf9f5a |
" LocalBrowse: {{{2
|
|
Karsten Hopp |
cf9f5a |
fun! s:LocalBrowse(dirname)
|
|
Karsten Hopp |
cf9f5a |
" unfortunate interaction -- debugging calls can't be used here;
|
|
Karsten Hopp |
cf9f5a |
" the BufEnter event causes triggering when attempts to write to
|
|
Karsten Hopp |
cf9f5a |
" the DBG buffer are made.
|
|
Karsten Hopp |
cf9f5a |
" echomsg "dirname<".a:dirname.">"
|
|
Karsten Hopp |
cf9f5a |
if has("amiga")
|
|
Karsten Hopp |
cf9f5a |
" The check against '' is made for the Amiga, where the empty
|
|
Karsten Hopp |
cf9f5a |
" string is the current directory and not checking would break
|
|
Karsten Hopp |
cf9f5a |
" things such as the help command.
|
|
Karsten Hopp |
cf9f5a |
if a:dirname != '' && isdirectory(a:dirname)
|
|
Karsten Hopp |
cf9f5a |
silent! call netrw#LocalBrowseCheck(a:dirname)
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
elseif isdirectory(a:dirname)
|
|
Karsten Hopp |
cf9f5a |
" echomsg "dirname<".dirname."> isdir"
|
|
Karsten Hopp |
cf9f5a |
silent! call netrw#LocalBrowseCheck(a:dirname)
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
" not a directory, ignore it
|
|
Karsten Hopp |
cf9f5a |
endfun
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" ---------------------------------------------------------------------
|
|
Karsten Hopp |
cf9f5a |
" NetrwStatusLine: {{{1
|
|
Karsten Hopp |
cf9f5a |
fun! NetrwStatusLine()
|
|
Karsten Hopp |
cf9f5a |
" let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr("%")." Xline#".w:netrw_explore_line." line#".line(".")
|
|
Karsten Hopp |
cf9f5a |
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")
|
|
Karsten Hopp |
cf9f5a |
let &stl= s:netrw_explore_stl
|
|
Karsten Hopp |
cf9f5a |
if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
|
|
Karsten Hopp |
cf9f5a |
if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif
|
|
Karsten Hopp |
cf9f5a |
return ""
|
|
Karsten Hopp |
cf9f5a |
else
|
|
Karsten Hopp |
cf9f5a |
return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
endfun
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" ------------------------------------------------------------------------
|
|
Karsten Hopp |
cf9f5a |
" NetUserPass: set username and password for subsequent ftp transfer {{{1
|
|
Karsten Hopp |
cf9f5a |
" Usage: :call NetUserPass() -- will prompt for userid and password
|
|
Karsten Hopp |
cf9f5a |
" :call NetUserPass("uid") -- will prompt for password
|
|
Karsten Hopp |
cf9f5a |
" :call NetUserPass("uid","password") -- sets global userid and password
|
|
Karsten Hopp |
cf9f5a |
fun! NetUserPass(...)
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" get/set userid
|
|
Karsten Hopp |
cf9f5a |
if a:0 == 0
|
|
Karsten Hopp |
cf9f5a |
" call Dfunc("NetUserPass(a:0<".a:0.">)")
|
|
Karsten Hopp |
cf9f5a |
if !exists("g:netrw_uid") || g:netrw_uid == ""
|
|
Karsten Hopp |
cf9f5a |
" via prompt
|
|
Karsten Hopp |
cf9f5a |
let g:netrw_uid= input('Enter username: ')
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
else " from command line
|
|
Karsten Hopp |
cf9f5a |
" call Dfunc("NetUserPass(a:1<".a:1.">) {")
|
|
Karsten Hopp |
cf9f5a |
let g:netrw_uid= a:1
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" get password
|
|
Karsten Hopp |
cf9f5a |
if a:0 <= 1 " via prompt
|
|
Karsten Hopp |
cf9f5a |
" call Decho("a:0=".a:0." case <=1:")
|
|
Karsten Hopp |
cf9f5a |
let g:netrw_passwd= inputsecret("Enter Password: ")
|
|
Karsten Hopp |
cf9f5a |
else " from command line
|
|
Karsten Hopp |
cf9f5a |
" call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
|
|
Karsten Hopp |
cf9f5a |
let g:netrw_passwd=a:2
|
|
Karsten Hopp |
cf9f5a |
endif
|
|
Karsten Hopp |
cf9f5a |
" call Dret("NetUserPass")
|
|
Karsten Hopp |
cf9f5a |
endfun
|
|
Karsten Hopp |
cf9f5a |
|
|
Karsten Hopp |
cf9f5a |
" ------------------------------------------------------------------------
|
|
Karsten Hopp |
cf9f5a |
" Modelines And Restoration: {{{1
|
|
Karsten Hopp |
cf9f5a |
let &cpo= s:keepcpo
|
|
Karsten Hopp |
cf9f5a |
unlet s:keepcpo
|
|
Karsten Hopp |
cf9f5a |
" vim:ts=8 fdm=marker
|