Mercurial > vim
annotate runtime/plugin/netrwPlugin.vim @ 5891:7965cb6a435a v7.4.288
updated for version 7.4.288
Problem: When 'spellfile' is set the screen is not redrawn.
Solution: Redraw when updating the spelling info. (Christian Brabandt)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 13 May 2014 14:03:40 +0200 |
parents | 657ade71d395 |
children | 16d26051085a |
rev | line source |
---|---|
534 | 1 " netrwPlugin.vim: Handles file transfer and remote directory listing across a network |
1118 | 2 " PLUGIN SECTION |
5734 | 3 " Date: Jan 22, 2014 |
4339 | 4 " Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> |
534 | 5 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim |
5618 | 6 " Copyright: Copyright (C) 1999-2013 Charles E. Campbell {{{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 | |
5734 | 23 let g:loaded_netrwPlugin = "v151" |
2034 | 24 if v:version < 702 |
5618 | 25 echohl WarningMsg |
26 echo "***warning*** you need vim version 7.2 for this version of netrw" | |
27 echohl None | |
28 finish | |
29 endif | |
30 if v:version < 703 || (v:version == 703 && !has("patch465")) | |
31 echohl WarningMsg | |
32 echo "***warning*** this version of netrw needs vim 7.3.465 or later" | |
33 echohl Normal | |
553 | 34 finish |
35 endif | |
2034 | 36 let s:keepcpo = &cpo |
534 | 37 set cpo&vim |
5618 | 38 "DechoRemOn |
534 | 39 |
40 " --------------------------------------------------------------------- | |
41 " Public Interface: {{{1 | |
42 | |
5618 | 43 " Local Browsing Autocmds: {{{2 |
534 | 44 augroup FileExplorer |
45 au! | |
5734 | 46 au BufLeave * if &ft != "netrw"|let w:netrw_prvfile= expand("%:p")|endif |
5618 | 47 au BufEnter * sil call s:LocalBrowse(expand("<amatch>")) |
48 au VimEnter * sil call s:VimEnter(expand("<amatch>")) | |
1118 | 49 if has("win32") || has("win95") || has("win64") || has("win16") |
5618 | 50 au BufEnter .* sil call s:LocalBrowse(expand("<amatch>")) |
1118 | 51 endif |
534 | 52 augroup END |
53 | |
54 " Network Browsing Reading Writing: {{{2 | |
55 augroup Network | |
56 au! | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
57 au BufReadCmd file://* call netrw#FileUrlRead(expand("<amatch>")) |
4339 | 58 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>")) |
59 au FileReadCmd ftp://*,rcp://*,scp://*,http://*,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>")) | |
5618 | 60 au BufWriteCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>")) |
61 au FileWriteCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileWritePre ".fnameescape(expand("<amatch>"))|exe "'[,']".'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau FileWritePost ".fnameescape(expand("<amatch>")) | |
1118 | 62 try |
3153 | 63 au SourceCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) |
1118 | 64 catch /^Vim\%((\a\+)\)\=:E216/ |
3153 | 65 au SourcePre ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) |
1118 | 66 endtry |
534 | 67 augroup END |
68 | |
69 " Commands: :Nread, :Nwrite, :NetUserPass {{{2 | |
5734 | 70 com! -count=1 -nargs=* Nread call netrw#SavePosn()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call netrw#RestorePosn() |
71 com! -range=% -nargs=* Nwrite call netrw#SavePosn()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call netrw#RestorePosn() | |
534 | 72 com! -nargs=* NetUserPass call NetUserPass(<f-args>) |
5734 | 73 com! -nargs=* Nsource call netrw#SavePosn()<bar>call netrw#NetSource(<f-args>)<bar>call netrw#RestorePosn() |
74 com! -nargs=? Ntree call netrw#SetTreetop(<q-args>) | |
534 | 75 |
5618 | 76 " Commands: :Explore, :Sexplore, Hexplore, Vexplore, Lexplore {{{2 |
1118 | 77 com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>) |
78 com! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>,1,0+<bang>0,<q-args>) | |
79 com! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>,1,2+<bang>0,<q-args>) | |
80 com! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>,1,4+<bang>0,<q-args>) | |
81 com! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>,0,6 ,<q-args>) | |
82 com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>) | |
83 com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>) | |
5618 | 84 com! -nargs=* -bar -complete=dir Lexplore call netrw#Lexplore(<q-args>) |
534 | 85 |
86 " Commands: NetrwSettings {{{2 | |
1618 | 87 com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings() |
5734 | 88 com! -bang NetrwClean call netrw#Clean(<bang>0) |
534 | 89 |
649 | 90 " Maps: |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
91 if !exists("g:netrw_nogx") && maparg('gx','n') == "" |
1118 | 92 if !hasmapto('<Plug>NetrwBrowseX') |
93 nmap <unique> gx <Plug>NetrwBrowseX | |
94 endif | |
5618 | 95 nno <silent> <Plug>NetrwBrowseX :call netrw#NetrwBrowseX(expand("<cfile>"),0)<cr> |
649 | 96 endif |
97 | |
534 | 98 " --------------------------------------------------------------------- |
5618 | 99 " LocalBrowse: invokes netrw#LocalBrowseCheck() on directory buffers {{{2 |
534 | 100 fun! s:LocalBrowse(dirname) |
5618 | 101 " Unfortunate interaction -- only DechoMsg debugging calls can be safely used here. |
102 " Otherwise, the BufEnter event gets triggered when attempts to write to | |
534 | 103 " the DBG buffer are made. |
5618 | 104 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
105 if !exists("s:vimentered") |
5618 | 106 " If s:vimentered doesn't exist, then the VimEnter event hasn't fired. It will, |
107 " and so s:VimEnter() will then be calling this routine, but this time with s:vimentered defined. | |
108 " call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered doesn't exist)") | |
109 " call Dret("s:LocalBrowse") | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
110 return |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
111 endif |
5618 | 112 |
113 " call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered=".s:vimentered.")") | |
114 | |
1118 | 115 if has("amiga") |
116 " The check against '' is made for the Amiga, where the empty | |
117 " string is the current directory and not checking would break | |
118 " things such as the help command. | |
5618 | 119 " call Decho("(LocalBrowse) dirname<".a:dirname."> (isdirectory, amiga)") |
1118 | 120 if a:dirname != '' && isdirectory(a:dirname) |
2751 | 121 sil! call netrw#LocalBrowseCheck(a:dirname) |
5734 | 122 if exists("w:netrw_bannercnt") |
123 exe w:netrw_bannercnt | |
124 endif | |
1118 | 125 endif |
5618 | 126 |
1118 | 127 elseif isdirectory(a:dirname) |
5734 | 128 " call Decho("(LocalBrowse) dirname<".a:dirname."> ft=".&ft." (isdirectory, not amiga)") |
129 " call Dredir("LocalBrowse ft last set: ","verbose set ft") | |
2751 | 130 sil! call netrw#LocalBrowseCheck(a:dirname) |
5734 | 131 if exists("w:netrw_bannercnt") |
132 exe w:netrw_bannercnt | |
133 endif | |
5618 | 134 |
135 else | |
136 " not a directory, ignore it | |
137 " call Decho("(LocalBrowse) dirname<".a:dirname."> not a directory, ignoring...") | |
534 | 138 endif |
5618 | 139 |
140 " call Dret("s:LocalBrowse") | |
534 | 141 endfun |
142 | |
143 " --------------------------------------------------------------------- | |
5618 | 144 " s:VimEnter: after all vim startup stuff is done, this function is called. {{{2 |
145 " Its purpose: to look over all windows and run s:LocalBrowse() on | |
146 " them, which checks if they're directories and will create a directory | |
147 " listing when appropriate. | |
148 " It also sets s:vimentered, letting s:LocalBrowse() know that s:VimEnter() | |
149 " has already been called. | |
2152 | 150 fun! s:VimEnter(dirname) |
5618 | 151 " call Dfunc("s:VimEnter(dirname<".a:dirname.">) expand(%)<".expand("%").">") |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
152 let curwin = winnr() |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
153 let s:vimentered = 1 |
5618 | 154 windo call s:LocalBrowse(expand("%:p")) |
2426 | 155 exe curwin."wincmd w" |
5618 | 156 " call Dret("s:VimEnter") |
2152 | 157 endfun |
158 | |
159 " --------------------------------------------------------------------- | |
534 | 160 " NetrwStatusLine: {{{1 |
161 fun! NetrwStatusLine() | |
755 | 162 " let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr("%")." Xline#".w:netrw_explore_line." line#".line(".") |
163 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 | 164 let &stl= s:netrw_explore_stl |
165 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif | |
166 if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif | |
167 return "" | |
168 else | |
169 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen | |
170 endif | |
171 endfun | |
172 | |
173 " ------------------------------------------------------------------------ | |
174 " NetUserPass: set username and password for subsequent ftp transfer {{{1 | |
175 " Usage: :call NetUserPass() -- will prompt for userid and password | |
176 " :call NetUserPass("uid") -- will prompt for password | |
177 " :call NetUserPass("uid","password") -- sets global userid and password | |
178 fun! NetUserPass(...) | |
179 | |
180 " get/set userid | |
181 if a:0 == 0 | |
182 " call Dfunc("NetUserPass(a:0<".a:0.">)") | |
183 if !exists("g:netrw_uid") || g:netrw_uid == "" | |
184 " via prompt | |
185 let g:netrw_uid= input('Enter username: ') | |
186 endif | |
187 else " from command line | |
188 " call Dfunc("NetUserPass(a:1<".a:1.">) {") | |
189 let g:netrw_uid= a:1 | |
190 endif | |
191 | |
192 " get password | |
193 if a:0 <= 1 " via prompt | |
194 " call Decho("a:0=".a:0." case <=1:") | |
195 let g:netrw_passwd= inputsecret("Enter Password: ") | |
196 else " from command line | |
197 " call Decho("a:0=".a:0." case >1: a:2<".a:2.">") | |
198 let g:netrw_passwd=a:2 | |
199 endif | |
200 " call Dret("NetUserPass") | |
201 endfun | |
202 | |
203 " ------------------------------------------------------------------------ | |
204 " Modelines And Restoration: {{{1 | |
205 let &cpo= s:keepcpo | |
206 unlet s:keepcpo | |
207 " vim:ts=8 fdm=marker |