Mercurial > vim
comparison runtime/autoload/netrw.vim @ 523:a7ae7e043e43
updated for version 7.0146
author | vimboss |
---|---|
date | Tue, 13 Sep 2005 21:20:47 +0000 |
parents | d50452846776 |
children | 7052f11a3dc9 |
comparison
equal
deleted
inserted
replaced
522:530b30703db6 | 523:a7ae7e043e43 |
---|---|
1 " netrw.vim: Handles file transfer and remote directory listing across a network | 1 " netrw.vim: Handles file transfer and remote directory listing across a network |
2 " AUTOLOAD PORTION | 2 " AUTOLOAD PORTION |
3 " Date: Sep 09, 2005 | 3 " Date: Sep 12, 2005 |
4 " Version: 69 | 4 " Version: 70 |
5 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz> | 5 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz> |
6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim | 6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim |
7 " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 | 7 " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 |
8 " Permission is hereby granted to use and distribute this code, | 8 " Permission is hereby granted to use and distribute this code, |
9 " with or without modifications, provided that this copyright | 9 " with or without modifications, provided that this copyright |
24 endif | 24 endif |
25 if v:version < 700 | 25 if v:version < 700 |
26 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None | 26 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None |
27 finish | 27 finish |
28 endif | 28 endif |
29 let g:loaded_netrw = "v69" | 29 let g:loaded_netrw = "v70" |
30 let s:keepcpo = &cpo | 30 let s:keepcpo = &cpo |
31 set cpo&vim | 31 set cpo&vim |
32 " call Decho("doing autoload/netrw.vim") | 32 " call Decho("doing autoload/netrw.vim") |
33 | 33 |
34 " --------------------------------------------------------------------- | 34 " --------------------------------------------------------------------- |
1141 silent call netrw#NetRead(method."://".user.machine."/".path) | 1141 silent call netrw#NetRead(method."://".user.machine."/".path) |
1142 exe "silent doau BufReadPost ".fname | 1142 exe "silent doau BufReadPost ".fname |
1143 keepjumps 1d | 1143 keepjumps 1d |
1144 | 1144 |
1145 " save certain window-oriented variables into buffer-oriented variables | 1145 " save certain window-oriented variables into buffer-oriented variables |
1146 call s:BufWinVars() | 1146 call s:SetBufWinVars() |
1147 call s:NetOptionRestore() | 1147 call s:NetOptionRestore() |
1148 setlocal nomod | 1148 setlocal nomod |
1149 | 1149 |
1150 " call Dret("NetBrowse : file<".fname.">") | 1150 " call Dret("NetBrowse : file<".fname.">") |
1151 return | 1151 return |
2235 endfun | 2235 endfun |
2236 | 2236 |
2237 " --------------------------------------------------------------------- | 2237 " --------------------------------------------------------------------- |
2238 " NetObtain: obtain file under cursor (for remote browsing support) {{{2 | 2238 " NetObtain: obtain file under cursor (for remote browsing support) {{{2 |
2239 fun! s:NetObtain() | 2239 fun! s:NetObtain() |
2240 if !exists("s:netrw_users_stl") | |
2241 let s:netrw_users_stl= &stl | |
2242 endif | |
2243 let fname= expand("<cWORD>") | 2240 let fname= expand("<cWORD>") |
2244 exe 'set stl=%f\ %h%m%r%=Obtaining\ '.escape(fname,' ') | 2241 |
2245 redraw! | 2242 " NetrwStatusLine support - for obtaining support |
2243 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.fname) | |
2246 | 2244 |
2247 " call Dfunc("NetObtain() method=".w:netrw_method) | 2245 " call Dfunc("NetObtain() method=".w:netrw_method) |
2248 if exists("w:netrw_method") && w:netrw_method =~ '[235]' | 2246 if exists("w:netrw_method") && w:netrw_method =~ '[235]' |
2249 if executable("ftp") | 2247 if executable("ftp") |
2250 let curdir = expand("%") | 2248 let curdir = expand("%") |
2318 else | 2316 else |
2319 if !exists("g:netrw_quiet") | 2317 if !exists("g:netrw_quiet") |
2320 echohl Error | echo "***netrw*** this system doesn't support ftp" | echohl None | 2318 echohl Error | echo "***netrw*** this system doesn't support ftp" | echohl None |
2321 call inputsave()|call input("Press <cr> to continue")|call inputrestore() | 2319 call inputsave()|call input("Press <cr> to continue")|call inputrestore() |
2322 endif | 2320 endif |
2321 let &stl = s:netrw_users_stl | |
2322 let &laststatus = s:netrw_users_ls | |
2323 " call Dret("NetObtain") | 2323 " call Dret("NetObtain") |
2324 return | 2324 return |
2325 endif | 2325 endif |
2326 | 2326 |
2327 "......................................... | 2327 "......................................... |
2341 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(fname,' ?&')." ." | 2341 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(fname,' ?&')." ." |
2342 endif | 2342 endif |
2343 endif | 2343 endif |
2344 | 2344 |
2345 " restore status line | 2345 " restore status line |
2346 let &stl= s:netrw_users_stl | 2346 let &stl = s:netrw_users_stl |
2347 let &laststatus = s:netrw_users_ls | |
2347 redraw! | 2348 redraw! |
2348 | 2349 |
2349 " call Dret("NetObtain") | 2350 " call Dret("NetObtain") |
2350 endfun | 2351 endfun |
2351 | 2352 |
2609 | 2610 |
2610 " record previous current directory | 2611 " record previous current directory |
2611 let w:netrw_prvdir= b:netrw_curdir | 2612 let w:netrw_prvdir= b:netrw_curdir |
2612 | 2613 |
2613 " save certain window-oriented variables into buffer-oriented variables | 2614 " save certain window-oriented variables into buffer-oriented variables |
2614 call s:BufWinVars() | 2615 call s:SetBufWinVars() |
2615 call s:NetOptionRestore() | 2616 call s:NetOptionRestore() |
2616 setlocal noma nomod nonu bh=hide nobl | 2617 setlocal noma nomod nonu bh=hide nobl |
2617 | 2618 |
2618 " call Dret("DirBrowse : file<".expand("%:p")."> bufname<".bufname("%").">") | 2619 " call Dret("DirBrowse : file<".expand("%:p")."> bufname<".bufname("%").">") |
2619 endfun | 2620 endfun |
3040 " call Dret("Explore") | 3041 " call Dret("Explore") |
3041 return | 3042 return |
3042 endif | 3043 endif |
3043 endif | 3044 endif |
3044 | 3045 |
3045 " NetrwStatusLine support | 3046 " NetrwStatusLine support - for exploring support |
3046 let w:netrw_explore_indx= indx | 3047 let w:netrw_explore_indx= indx |
3047 if !exists("s:netrw_users_stl") | |
3048 let s:netrw_users_stl= &stl | |
3049 endif | |
3050 set stl=%f\ %h%m%r%=%{NetrwStatusLine()} | |
3051 " call Decho("explorelist<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen) | 3048 " call Decho("explorelist<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen) |
3052 | 3049 |
3053 " sanity check | 3050 " sanity check |
3054 if indx >= w:netrw_explore_listlen || indx < 0 | 3051 if indx >= w:netrw_explore_listlen || indx < 0 |
3055 let indx= (indx < 0)? 0 : ( w:netrw_explore_listlen - 1 ) | 3052 let indx= (indx < 0)? 0 : ( w:netrw_explore_listlen - 1 ) |
3058 " call Dret("Explore") | 3055 " call Dret("Explore") |
3059 return | 3056 return |
3060 endif | 3057 endif |
3061 | 3058 |
3062 exe "let dirfile= w:netrw_explore_list[".indx."]" | 3059 exe "let dirfile= w:netrw_explore_list[".indx."]" |
3063 " call Decho("dirfile<".dirfile."> indx=".indx) | 3060 " call Decho("dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">") |
3064 let newdir= substitute(dirfile,'/[^/]*$','','e') | 3061 let newdir= substitute(dirfile,'/[^/]*$','','e') |
3065 " call Decho("newdir<".newdir.">") | 3062 " call Decho("newdir<".newdir.">") |
3063 | |
3066 " call Decho("calling LocalBrowse(newdir<".newdir.">)") | 3064 " call Decho("calling LocalBrowse(newdir<".newdir.">)") |
3067 call s:LocalBrowse(newdir) | 3065 call s:LocalBrowse(newdir) |
3068 call search(substitute(dirfile,"^.*/","",""),"W") | 3066 if w:netrw_longlist == 0 || w:netrw_longlist == 1 |
3067 call search('^'.substitute(dirfile,"^.*/","","").'\>',"W") | |
3068 else | |
3069 call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w") | |
3070 endif | |
3069 let w:netrw_explore_mtchcnt = indx + 1 | 3071 let w:netrw_explore_mtchcnt = indx + 1 |
3070 let w:netrw_explore_bufnr = bufnr(".") | 3072 let w:netrw_explore_bufnr = bufnr(".") |
3071 let w:netrw_explore_line = line(".") | 3073 let w:netrw_explore_line = line(".") |
3074 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}') | |
3072 " call Decho("explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line) | 3075 " call Decho("explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line) |
3073 | 3076 |
3074 else | 3077 else |
3075 if !exists("g:netrw_quiet") | 3078 if !exists("g:netrw_quiet") |
3076 echohl WarningMsg | echo "***netrw*** your vim needs the +path_extra feature for Exploring with **!" | echohl None | echohl None | 3079 echohl WarningMsg | echo "***netrw*** your vim needs the +path_extra feature for Exploring with **!" | echohl None | echohl None |
3086 | 3089 |
3087 " call Dret("Explore") | 3090 " call Dret("Explore") |
3088 endfun | 3091 endfun |
3089 | 3092 |
3090 " --------------------------------------------------------------------- | 3093 " --------------------------------------------------------------------- |
3094 " SetupNetrwStatusLine: {{{2 | |
3095 fun! s:SetupNetrwStatusLine(statline) | |
3096 " call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)") | |
3097 | |
3098 if !exists("s:netrw_setup_statline") | |
3099 let s:netrw_setup_statline= 1 | |
3100 " call Decho("do first-time status line setup") | |
3101 | |
3102 if !exists("s:netrw_users_stl") | |
3103 let s:netrw_users_stl= &stl | |
3104 endif | |
3105 if !exists("s:netrw_users_ls") | |
3106 let s:netrw_users_ls= &laststatus | |
3107 endif | |
3108 | |
3109 " set up User9 highlighting as needed | |
3110 let keepa= @a | |
3111 redir @a | |
3112 try | |
3113 hi User9 | |
3114 catch /^Vim\%((\a\+)\)\=:E411/ | |
3115 if &bg == "dark" | |
3116 hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue | |
3117 else | |
3118 hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue | |
3119 endif | |
3120 endtry | |
3121 redir END | |
3122 let @a= keepa | |
3123 endif | |
3124 | |
3125 " set up status line (may use User9 highlighting) | |
3126 " insure that windows have a statusline | |
3127 " make sure statusline is displayed | |
3128 let &stl=a:statline | |
3129 set laststatus=2 | |
3130 " call Decho("stl=".&stl) | |
3131 redraw! | |
3132 | |
3133 " call Dret("SetupNetrwStatusLine : stl=".&stl) | |
3134 endfun | |
3135 | |
3136 " --------------------------------------------------------------------- | |
3091 " NetrwStatusLine: {{{2 | 3137 " NetrwStatusLine: {{{2 |
3092 fun! NetrwStatusLine() | 3138 fun! NetrwStatusLine() |
3093 " let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr(".")." Xline#".w:netrw_explore_line." line#".line(".") | 3139 |
3140 " vvv NetrwStatusLine() debugging vvv | |
3141 " let g:stlmsg="" | |
3142 " if !exists("w:netrw_explore_bufnr") | |
3143 " let g:stlmsg="!X<explore_bufnr>" | |
3144 " elseif w:netrw_explore_bufnr != bufnr(".") | |
3145 " let g:stlmsg="explore_bufnr!=".bufnr(".") | |
3146 " endif | |
3147 " if !exists("w:netrw_explore_line") | |
3148 " let g:stlmsg=" !X<explore_line>" | |
3149 " elseif w:netrw_explore_line != line(".") | |
3150 " let g:stlmsg=" explore_line!={line(.)<".line(".").">" | |
3151 " endif | |
3152 " if !exists("w:netrw_explore_list") | |
3153 " let g:stlmsg=" !X<explore_list>" | |
3154 " endif | |
3155 " ^^^ NetrwStatusLine() debugging ^^^ | |
3156 | |
3094 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") | 3157 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") |
3095 " restore user's status line | 3158 " restore user's status line |
3096 let &stl= s:netrw_users_stl | 3159 let &stl = s:netrw_users_stl |
3160 let &laststatus = s:netrw_users_ls | |
3097 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif | 3161 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif |
3098 if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif | 3162 if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif |
3099 return "" | 3163 return "" |
3100 else | 3164 else |
3101 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen | 3165 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen |
3589 if exists("s:explore_list") |let w:netrw_explore_list = s:explore_list |unlet s:explore_list |endif | 3653 if exists("s:explore_list") |let w:netrw_explore_list = s:explore_list |unlet s:explore_list |endif |
3590 " call Dret("CopyWinVars") | 3654 " call Dret("CopyWinVars") |
3591 endfun | 3655 endfun |
3592 | 3656 |
3593 " --------------------------------------------------------------------- | 3657 " --------------------------------------------------------------------- |
3594 " BufWinVars: (used by NetBrowse() and LocalBrowse()) {{{1 | 3658 " SetBufWinVars: (used by NetBrowse() and LocalBrowse()) {{{1 |
3595 " To allow separate windows to have their own activities, such as | 3659 " To allow separate windows to have their own activities, such as |
3596 " Explore **/pattern, several variables have been made window-oriented. | 3660 " Explore **/pattern, several variables have been made window-oriented. |
3597 " However, when the user splits a browser window (ex: ctrl-w s), these | 3661 " However, when the user splits a browser window (ex: ctrl-w s), these |
3598 " variables are not inherited by the new window. BufWinVars() and | 3662 " variables are not inherited by the new window. SetBufWinVars() and |
3599 " UseBufWinVars() get around that. | 3663 " UseBufWinVars() get around that. |
3600 fun! s:BufWinVars() | 3664 fun! s:SetBufWinVars() |
3601 " call Dfunc("BufWinVars()") | 3665 " call Dfunc("SetBufWinVars()") |
3602 if exists("w:netrw_longlist") |let b:netrw_longlist = w:netrw_longlist |endif | 3666 if exists("w:netrw_longlist") |let b:netrw_longlist = w:netrw_longlist |endif |
3603 if exists("w:netrw_bannercnt") |let b:netrw_bannercnt = w:netrw_bannercnt |endif | 3667 if exists("w:netrw_bannercnt") |let b:netrw_bannercnt = w:netrw_bannercnt |endif |
3604 if exists("w:netrw_method") |let b:netrw_method = w:netrw_method |endif | 3668 if exists("w:netrw_method") |let b:netrw_method = w:netrw_method |endif |
3605 if exists("w:netrw_prvdir") |let b:netrw_prvdir = w:netrw_prvdir |endif | 3669 if exists("w:netrw_prvdir") |let b:netrw_prvdir = w:netrw_prvdir |endif |
3606 if exists("w:netrw_explore_indx") |let b:netrw_explore_indx = w:netrw_explore_indx |endif | 3670 if exists("w:netrw_explore_indx") |let b:netrw_explore_indx = w:netrw_explore_indx |endif |
3607 if exists("w:netrw_explore_listlen")|let b:netrw_explore_listlen = w:netrw_explore_listlen|endif | 3671 if exists("w:netrw_explore_listlen")|let b:netrw_explore_listlen = w:netrw_explore_listlen|endif |
3608 if exists("w:netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt = w:netrw_explore_mtchcnt|endif | 3672 if exists("w:netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt = w:netrw_explore_mtchcnt|endif |
3609 if exists("w:netrw_explore_bufnr") |let b:netrw_explore_bufnr = w:netrw_explore_bufnr |endif | 3673 if exists("w:netrw_explore_bufnr") |let b:netrw_explore_bufnr = w:netrw_explore_bufnr |endif |
3610 if exists("w:netrw_explore_line") |let b:netrw_explore_line = w:netrw_explore_line |endif | 3674 if exists("w:netrw_explore_line") |let b:netrw_explore_line = w:netrw_explore_line |endif |
3611 if exists("w:netrw_explore_list") |let b:netrw_explore_list = w:netrw_explore_list |endif | 3675 if exists("w:netrw_explore_list") |let b:netrw_explore_list = w:netrw_explore_list |endif |
3612 " call Dret("BufWinVars") | 3676 " call Dret("SetBufWinVars") |
3613 endfun | 3677 endfun |
3614 | 3678 |
3615 " --------------------------------------------------------------------- | 3679 " --------------------------------------------------------------------- |
3616 " UseBufWinVars: (used by NetBrowse() and LocalBrowse() {{{1 | 3680 " UseBufWinVars: (used by NetBrowse() and LocalBrowse() {{{1 |
3617 " Matching function to BufferWinVars() | 3681 " Matching function to BufferWinVars() |