Mercurial > vim
annotate runtime/plugin/netrwPlugin.vim @ 2420:6de9efd58dc0 vim73
Updated runtime files. New netrw plugin version.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 27 Jul 2010 22:50:36 +0200 |
parents | b9e314fe473f |
children | e52d87a2bb3e |
rev | line source |
---|---|
534 | 1 " netrwPlugin.vim: Handles file transfer and remote directory listing across a network |
1118 | 2 " PLUGIN SECTION |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
3 " Date: Jul 27, 2010 |
1118 | 4 " Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> |
534 | 5 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim |
1698 | 6 " Copyright: Copyright (C) 1999-2008 Charles E. Campbell, Jr. {{{1 |
534 | 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 | |
1118 | 20 if &cp || exists("g:loaded_netrwPlugin") |
534 | 21 finish |
22 endif | |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
23 let g:loaded_netrwPlugin = "v139" |
2034 | 24 if v:version < 702 |
25 echohl WarningMsg | echo "***netrw*** you need vim version 7.2 for this version of netrw" | echohl None | |
553 | 26 finish |
27 endif | |
2034 | 28 let s:keepcpo = &cpo |
534 | 29 set cpo&vim |
30 | |
31 " --------------------------------------------------------------------- | |
32 " Public Interface: {{{1 | |
33 | |
34 " Local Browsing: {{{2 | |
35 augroup FileExplorer | |
36 au! | |
649 | 37 au BufEnter * silent! call s:LocalBrowse(expand("<amatch>")) |
2152 | 38 au VimEnter * silent! call s:VimEnter(expand("<amatch>")) |
1118 | 39 if has("win32") || has("win95") || has("win64") || has("win16") |
40 au BufEnter .* silent! call s:LocalBrowse(expand("<amatch>")) | |
41 endif | |
534 | 42 augroup END |
43 | |
44 " Network Browsing Reading Writing: {{{2 | |
45 augroup Network | |
46 au! | |
47 if has("win32") || has("win95") || has("win64") || has("win16") | |
1698 | 48 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>"))) |
534 | 49 else |
1698 | 50 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>"))) |
51 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>"))) | |
534 | 52 endif |
2034 | 53 au BufReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(expand("<amatch>")) |
54 au FileReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau FileReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(1,expand("<amatch>"))|exe "silent doau FileReadPost ".fnameescape(expand("<amatch>")) | |
1698 | 55 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>")) |
56 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>")) | |
1118 | 57 try |
1698 | 58 au SourceCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) |
1118 | 59 catch /^Vim\%((\a\+)\)\=:E216/ |
1698 | 60 au SourcePre ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) |
1118 | 61 endtry |
534 | 62 augroup END |
63 | |
64 " Commands: :Nread, :Nwrite, :NetUserPass {{{2 | |
1618 | 65 com! -count=1 -nargs=* Nread call netrw#NetrwSavePosn()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call netrw#NetrwRestorePosn() |
66 com! -range=% -nargs=* Nwrite call netrw#NetrwSavePosn()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call netrw#NetrwRestorePosn() | |
534 | 67 com! -nargs=* NetUserPass call NetUserPass(<f-args>) |
1618 | 68 com! -nargs=* Nsource call netrw#NetrwSavePosn()<bar>call netrw#NetSource(<f-args>)<bar>call netrw#NetrwRestorePosn() |
534 | 69 |
70 " Commands: :Explore, :Sexplore, Hexplore, Vexplore {{{2 | |
1118 | 71 com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>) |
72 com! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>,1,0+<bang>0,<q-args>) | |
73 com! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>,1,2+<bang>0,<q-args>) | |
74 com! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>,1,4+<bang>0,<q-args>) | |
75 com! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>,0,6 ,<q-args>) | |
76 com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>) | |
77 com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>) | |
534 | 78 |
79 " Commands: NetrwSettings {{{2 | |
1618 | 80 com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings() |
81 com! -bang NetrwClean call netrw#NetrwClean(<bang>0) | |
534 | 82 |
649 | 83 " Maps: |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
84 if !exists("g:netrw_nogx") && maparg('gx','n') == "" |
1118 | 85 if !hasmapto('<Plug>NetrwBrowseX') |
86 nmap <unique> gx <Plug>NetrwBrowseX | |
87 endif | |
1618 | 88 nno <silent> <Plug>NetrwBrowseX :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<cr> |
649 | 89 endif |
90 | |
534 | 91 " --------------------------------------------------------------------- |
92 " LocalBrowse: {{{2 | |
93 fun! s:LocalBrowse(dirname) | |
94 " unfortunate interaction -- debugging calls can't be used here; | |
95 " the BufEnter event causes triggering when attempts to write to | |
96 " the DBG buffer are made. | |
1118 | 97 " echomsg "dirname<".a:dirname.">" |
98 if has("amiga") | |
99 " The check against '' is made for the Amiga, where the empty | |
100 " string is the current directory and not checking would break | |
101 " things such as the help command. | |
102 if a:dirname != '' && isdirectory(a:dirname) | |
103 silent! call netrw#LocalBrowseCheck(a:dirname) | |
104 endif | |
105 elseif isdirectory(a:dirname) | |
106 " echomsg "dirname<".dirname."> isdir" | |
107 silent! call netrw#LocalBrowseCheck(a:dirname) | |
534 | 108 endif |
109 " not a directory, ignore it | |
110 endfun | |
111 | |
112 " --------------------------------------------------------------------- | |
2152 | 113 " s:VimEnter: {{{2 |
114 fun! s:VimEnter(dirname) | |
115 windo if a:dirname != expand("%")|call s:LocalBrowse(expand("%:p"))|endif | |
116 1wincmd w | |
117 endfun | |
118 | |
119 " --------------------------------------------------------------------- | |
534 | 120 " NetrwStatusLine: {{{1 |
121 fun! NetrwStatusLine() | |
755 | 122 " let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr("%")." Xline#".w:netrw_explore_line." line#".line(".") |
123 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") | |
534 | 124 let &stl= s:netrw_explore_stl |
125 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif | |
126 if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif | |
127 return "" | |
128 else | |
129 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen | |
130 endif | |
131 endfun | |
132 | |
133 " ------------------------------------------------------------------------ | |
134 " NetUserPass: set username and password for subsequent ftp transfer {{{1 | |
135 " Usage: :call NetUserPass() -- will prompt for userid and password | |
136 " :call NetUserPass("uid") -- will prompt for password | |
137 " :call NetUserPass("uid","password") -- sets global userid and password | |
138 fun! NetUserPass(...) | |
139 | |
140 " get/set userid | |
141 if a:0 == 0 | |
142 " call Dfunc("NetUserPass(a:0<".a:0.">)") | |
143 if !exists("g:netrw_uid") || g:netrw_uid == "" | |
144 " via prompt | |
145 let g:netrw_uid= input('Enter username: ') | |
146 endif | |
147 else " from command line | |
148 " call Dfunc("NetUserPass(a:1<".a:1.">) {") | |
149 let g:netrw_uid= a:1 | |
150 endif | |
151 | |
152 " get password | |
153 if a:0 <= 1 " via prompt | |
154 " call Decho("a:0=".a:0." case <=1:") | |
155 let g:netrw_passwd= inputsecret("Enter Password: ") | |
156 else " from command line | |
157 " call Decho("a:0=".a:0." case >1: a:2<".a:2.">") | |
158 let g:netrw_passwd=a:2 | |
159 endif | |
160 " call Dret("NetUserPass") | |
161 endfun | |
162 | |
163 " ------------------------------------------------------------------------ | |
164 " Modelines And Restoration: {{{1 | |
165 let &cpo= s:keepcpo | |
166 unlet s:keepcpo | |
167 " vim:ts=8 fdm=marker |