mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
parent
f5d1f0bf03
commit
d1a2523f6c
@ -1,7 +1,7 @@
|
||||
" netrw.vim: Handles file transfer and remote directory listing across
|
||||
" AUTOLOAD SECTION
|
||||
" Date: Jan 07, 2020
|
||||
" Version: 168
|
||||
" Date: Sep 18, 2020
|
||||
" Version: 170
|
||||
" Maintainer: Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
|
||||
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
|
||||
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
|
||||
@ -43,7 +43,7 @@ if exists("s:needspatches")
|
||||
endfor
|
||||
endif
|
||||
|
||||
let g:loaded_netrw = "v168"
|
||||
let g:loaded_netrw = "v170"
|
||||
if !exists("s:NOTE")
|
||||
let s:NOTE = 0
|
||||
let s:WARNING = 1
|
||||
@ -86,7 +86,16 @@ fun! netrw#ErrorMsg(level,msg,errnum)
|
||||
endif
|
||||
" call Decho("level=".level,'~'.expand("<slnum>"))
|
||||
|
||||
if g:netrw_use_errorwindow
|
||||
if g:netrw_use_errorwindow == 2 && (v:version > 802 || (v:version == 802 && has("patch486")))
|
||||
" use popup window
|
||||
if type(a:msg) == 3
|
||||
let msg = [level]+a:msg
|
||||
else
|
||||
let msg= level.a:msg
|
||||
endif
|
||||
let s:popuperr_id = popup_beval(msg,{})
|
||||
let s:popuperr_text= ""
|
||||
elseif g:netrw_use_errorwindow
|
||||
" (default) netrw creates a one-line window to show error/warning
|
||||
" messages (reliably displayed)
|
||||
|
||||
@ -203,7 +212,11 @@ let g:netrw_localrmdiropt = ""
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Default values for netrw's global protocol variables {{{2
|
||||
call s:NetrwInit("g:netrw_use_errorwindow",1)
|
||||
if (v:version > 802 || (v:version == 802 && has("patch486"))) && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on") && has("mouse")
|
||||
call s:NetrwInit("g:netrw_use_errorwindow",2)
|
||||
else
|
||||
call s:NetrwInit("g:netrw_use_errorwindow",1)
|
||||
endif
|
||||
|
||||
if !exists("g:netrw_dav_cmd")
|
||||
if executable("cadaver")
|
||||
@ -559,6 +572,7 @@ call s:NetrwInit("s:netrw_posn",'{}')
|
||||
if v:version >= 700 && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on")
|
||||
" call Decho("installed beval events",'~'.expand("<slnum>"))
|
||||
let &l:bexpr = "netrw#BalloonHelp()"
|
||||
" call Decho("&l:bexpr<".&l:bexpr."> buf#".bufnr())
|
||||
au FileType netrw setl beval
|
||||
au WinLeave * if &ft == "netrw" && exists("s:initbeval")|let &beval= s:initbeval|endif
|
||||
au VimEnter * let s:initbeval= &beval
|
||||
@ -591,7 +605,18 @@ if v:version >= 700 && has("balloon_eval") && has("syntax") && exists("g:syntax_
|
||||
if &ft != "netrw"
|
||||
return ""
|
||||
endif
|
||||
if !exists("w:netrw_bannercnt") || v:beval_lnum >= w:netrw_bannercnt || (exists("g:netrw_nobeval") && g:netrw_nobeval)
|
||||
if exists("s:popuperr_id") && popup_getpos(s:popuperr_id) != {}
|
||||
" popup error window is still showing
|
||||
" s:pouperr_id and s:popuperr_text are set up in netrw#ErrorMsg()
|
||||
if exists("s:popuperr_text") && s:popuperr_text != "" && v:beval_text != s:popuperr_text
|
||||
" text under mouse hasn't changed; only close window when it changes
|
||||
call popup_close(s:popuperr_id)
|
||||
unlet s:popuperr_text
|
||||
else
|
||||
let s:popuperr_text= v:beval_text
|
||||
endif
|
||||
let mesg= ""
|
||||
elseif !exists("w:netrw_bannercnt") || v:beval_lnum >= w:netrw_bannercnt || (exists("g:netrw_nobeval") && g:netrw_nobeval)
|
||||
let mesg= ""
|
||||
elseif v:beval_text == "Netrw" || v:beval_text == "Directory" || v:beval_text == "Listing"
|
||||
let mesg = "i: thin-long-wide-tree gh: quick hide/unhide of dot-files qf: quick file info %:open new file"
|
||||
@ -1212,6 +1237,10 @@ fun! netrw#Lexplore(count,rightside,...)
|
||||
setlocal winfixwidth
|
||||
let g:netrw_altv = keep_altv
|
||||
let t:netrw_lexbufnr = bufnr("%")
|
||||
" done to prevent build-up of hidden buffers due to quitting and re-invocation of :Lexplore.
|
||||
" Since the intended use of :Lexplore is to have an always-present explorer window, the extra
|
||||
" effort to mis-use :Lex is warranted.
|
||||
set bh=wipe
|
||||
" call Decho("let t:netrw_lexbufnr=".t:netrw_lexbufnr)
|
||||
" call Decho("t:netrw_lexposn".(exists("t:netrw_lexposn")? string(t:netrw_lexposn) : " n/a"))
|
||||
if exists("t:netrw_lexposn")
|
||||
@ -1864,7 +1893,7 @@ fun! s:NetrwRestoreSetting(keepvar,setting)
|
||||
if type(a:setting) == 0
|
||||
exe "let ".a:setting."= ".keepvarval
|
||||
elseif type(a:setting) == 1
|
||||
exe "let ".a:setting."= '".keepvarval."'"
|
||||
exe "let ".a:setting."= '".substitute(keepvarval,"'","''","g")."'"
|
||||
else
|
||||
call netrw#ErrorMsg(s:ERROR,"(s:NetrwRestoreSetting) doesn't know how to restore ".a:keepvar." with a setting of type#".type(a:setting),105)
|
||||
endif
|
||||
@ -3596,6 +3625,8 @@ fun! s:NetrwBookHistSave()
|
||||
let savefile= s:NetrwHome()."/.netrwhist"
|
||||
" call Decho("savefile<".savefile.">",'~'.expand("<slnum>"))
|
||||
1split
|
||||
|
||||
" setting up a new buffer which will become .netrwhist
|
||||
call s:NetrwEnew()
|
||||
" call Decho("case g:netrw_use_noswf=".g:netrw_use_noswf.(exists("+acd")? " +acd" : " -acd"),'~'.expand("<slnum>"))
|
||||
if g:netrw_use_noswf
|
||||
@ -4678,7 +4709,7 @@ endfun
|
||||
" "new directory name" is actually a file,
|
||||
" NetrwBrowseChgDir() edits the file.
|
||||
fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
" call Dfunc("s:NetrwBrowseChgDir(islocal=".a:islocal."> newdir<".a:newdir.">) a:0=".a:0." curpos<".string(getpos("."))."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "").">")
|
||||
" call Dfunc("s:NetrwBrowseChgDir(islocal=".a:islocal."> newdir<".a:newdir.">) a:0=".a:0." win#".winnr()." curpos<".string(getpos("."))."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "").">")
|
||||
" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>"))
|
||||
|
||||
let ykeep= @@
|
||||
@ -4707,13 +4738,14 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
let newdir = a:newdir
|
||||
let dolockout = 0
|
||||
let dorestore = 1
|
||||
" call Decho("win#".winnr(),'~'.expand("<slnum>"))
|
||||
" call Decho("dirname<".dirname.">",'~'.expand("<slnum>"))
|
||||
" call Decho("newdir<".newdir.">",'~'.expand("<slnum>"))
|
||||
|
||||
" ignore <cr>s when done in the banner
|
||||
" call Decho('(s:NetrwBrowseChgDir) ignore [return]s when done in banner (g:netrw_banner='.g:netrw_banner.")",'~'.expand("<slnum>"))
|
||||
if g:netrw_banner
|
||||
" call Decho("w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'n/a')." line(.)#".line('.')." line($)#".line("#"),'~'.expand("<slnum>"))
|
||||
" call Decho("win#".winnr()." w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'n/a')." line(.)#".line('.')." line($)#".line("#"),'~'.expand("<slnum>"))
|
||||
if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt && line("$") >= w:netrw_bannercnt
|
||||
if getline(".") =~# 'Quick Help'
|
||||
" call Decho("#1: quickhelp=".g:netrw_quickhelp." ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
|
||||
@ -4750,7 +4782,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
" ------------------------------
|
||||
" NetrwBrowseChgDir: edit a file {{{3
|
||||
" ------------------------------
|
||||
" call Decho('(s:NetrwBrowseChgDir) edit-a-file: case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">",'~'.expand("<slnum>"))
|
||||
" call Decho('edit-a-file: case "handling a file": win#'.winnr().' newdir<'.newdir.'> !~ dirpat<'.dirpat.">",'~'.expand("<slnum>"))
|
||||
|
||||
" save position for benefit of Rexplore
|
||||
let s:rexposn_{bufnr("%")}= winsaveview()
|
||||
@ -4785,7 +4817,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
NetrwKeepj call s:NetrwOptionsRestore("s:")
|
||||
let curdir= b:netrw_curdir
|
||||
if !exists("s:didsplit")
|
||||
" call Decho("edit-a-file: s:didsplit does not exist; g:netrw_browse_split=".string(g:netrw_browse_split)." win#".winnr(),'~'.expand("<slnum>"))
|
||||
" " call Decho("edit-a-file: s:didsplit does not exist; g:netrw_browse_split=".string(g:netrw_browse_split)." win#".winnr()." g:netrw_chgwin=".g:netrw_chgwin",'~'.expand("<slnum>"))
|
||||
if type(g:netrw_browse_split) == 3
|
||||
" open file in server
|
||||
" Note that g:netrw_browse_split is a List: [servername,tabnr,winnr]
|
||||
@ -4793,22 +4825,27 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
call s:NetrwServerEdit(a:islocal,dirname)
|
||||
" call Dret("s:NetrwBrowseChgDir")
|
||||
return
|
||||
|
||||
elseif g:netrw_browse_split == 1
|
||||
" horizontally splitting the window first
|
||||
" call Decho("edit-a-file: horizontally splitting window prior to edit",'~'.expand("<slnum>"))
|
||||
keepalt new
|
||||
let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize
|
||||
exe "keepalt ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s"
|
||||
if !&ea
|
||||
keepalt wincmd _
|
||||
endif
|
||||
call s:SetRexDir(a:islocal,curdir)
|
||||
|
||||
elseif g:netrw_browse_split == 2
|
||||
" vertically splitting the window first
|
||||
" call Decho("edit-a-file: vertically splitting window prior to edit",'~'.expand("<slnum>"))
|
||||
keepalt rightb vert new
|
||||
let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize
|
||||
exe "keepalt ".(g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s"
|
||||
if !&ea
|
||||
keepalt wincmd |
|
||||
endif
|
||||
call s:SetRexDir(a:islocal,curdir)
|
||||
|
||||
elseif g:netrw_browse_split == 3
|
||||
" open file in new tab
|
||||
" call Decho("edit-a-file: opening new tab prior to edit",'~'.expand("<slnum>"))
|
||||
@ -4817,6 +4854,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
let b:netrw_curdir= getcwd()
|
||||
endif
|
||||
call s:SetRexDir(a:islocal,curdir)
|
||||
|
||||
elseif g:netrw_browse_split == 4
|
||||
" act like "P" (ie. open previous window)
|
||||
" call Decho("edit-a-file: use previous window for edit",'~'.expand("<slnum>"))
|
||||
@ -4826,13 +4864,14 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
return
|
||||
endif
|
||||
call s:SetRexDir(a:islocal,curdir)
|
||||
|
||||
else
|
||||
" handling a file, didn't split, so remove menu
|
||||
" call Decho("edit-a-file: handling a file+didn't split, so remove menu",'~'.expand("<slnum>"))
|
||||
call s:NetrwMenu(0)
|
||||
" optional change to window
|
||||
if g:netrw_chgwin >= 1
|
||||
" call Decho("edit-a-file: changing window to #".g:netrw_chgwin,'~'.expand("<slnum>"))
|
||||
" call Decho("edit-a-file: changing window to #".g:netrw_chgwin.": (due to g:netrw_chgwin)",'~'.expand("<slnum>"))
|
||||
if winnr("$")+1 == g:netrw_chgwin
|
||||
" if g:netrw_chgwin is set to one more than the last window, then
|
||||
" vertically split the last window to make that window available.
|
||||
@ -4845,19 +4884,26 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
endif
|
||||
call s:SetRexDir(a:islocal,curdir)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
" the point where netrw actually edits the (local) file
|
||||
" if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will
|
||||
" no keepalt to support :e # to return to a directory listing
|
||||
if !&mod
|
||||
" if e the new file would fail due to &mod, then don't change any of the flags
|
||||
let dolockout= 1
|
||||
endif
|
||||
if a:islocal
|
||||
" call Decho("edit-a-file: edit local file: exe e! ".fnameescape(dirname),'~'.expand("<slnum>"))
|
||||
" some like c-^ to return to the last edited file
|
||||
" others like c-^ to return to the netrw buffer
|
||||
" Apr 30, 2020: used to have e! here. That can cause loss of a modified file,
|
||||
" so emit error E37 instead.
|
||||
if exists("g:netrw_altfile") && g:netrw_altfile
|
||||
exe "NetrwKeepj keepalt e! ".fnameescape(dirname)
|
||||
exe "NetrwKeepj keepalt e ".fnameescape(dirname)
|
||||
else
|
||||
exe "NetrwKeepj e! ".fnameescape(dirname)
|
||||
exe "NetrwKeepj e ".fnameescape(dirname)
|
||||
endif
|
||||
" call Decho("edit-a-file: after e! ".dirname.": hidden=".&hidden." bufhidden<".&bufhidden."> mod=".&mod,'~'.expand("<slnum>"))
|
||||
call s:NetrwCursor()
|
||||
@ -4868,7 +4914,6 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
||||
else
|
||||
" call Decho("edit-a-file: remote file: NetrwBrowse will edit it",'~'.expand("<slnum>"))
|
||||
endif
|
||||
let dolockout= 1
|
||||
|
||||
" handle g:Netrw_funcref -- call external-to-netrw functions
|
||||
" This code will handle g:Netrw_funcref as an individual function reference
|
||||
@ -5332,16 +5377,6 @@ fun! netrw#BrowseX(fname,remote)
|
||||
endif
|
||||
let ret= v:shell_error
|
||||
|
||||
elseif has("unix") && executable("kfmclient") && s:CheckIfKde()
|
||||
" call Decho("(netrw#BrowseX) unix and kfmclient",'~'.expand("<slnum>"))
|
||||
call s:NetrwExe("sil !kfmclient exec ".s:ShellEscape(fname,1)." ".redir)
|
||||
let ret= v:shell_error
|
||||
|
||||
elseif has("unix") && executable("exo-open") && executable("xdg-open") && executable("setsid")
|
||||
" call Decho("(netrw#BrowseX) unix, exo-open, xdg-open",'~'.expand("<slnum>"))
|
||||
call s:NetrwExe("sil !setsid xdg-open ".s:ShellEscape(fname,1).redir)
|
||||
let ret= v:shell_error
|
||||
|
||||
elseif has("unix") && $DESKTOP_SESSION == "mate" && executable("atril")
|
||||
" call Decho("(netrw#BrowseX) unix and atril",'~'.expand("<slnum>"))
|
||||
if a:fname =~ '^https\=://'
|
||||
@ -5356,9 +5391,19 @@ fun! netrw#BrowseX(fname,remote)
|
||||
endif
|
||||
let ret= v:shell_error
|
||||
|
||||
elseif has("unix") && executable("kfmclient") && s:CheckIfKde()
|
||||
" call Decho("(netrw#BrowseX) unix and kfmclient",'~'.expand("<slnum>"))
|
||||
call s:NetrwExe("sil !kfmclient exec ".s:ShellEscape(fname,1)." ".redir)
|
||||
let ret= v:shell_error
|
||||
|
||||
elseif has("unix") && executable("exo-open") && executable("xdg-open") && executable("setsid")
|
||||
" call Decho("(netrw#BrowseX) unix, exo-open, xdg-open",'~'.expand("<slnum>"))
|
||||
call s:NetrwExe("sil !setsid xdg-open ".s:ShellEscape(fname,1).redir.'&')
|
||||
let ret= v:shell_error
|
||||
|
||||
elseif has("unix") && executable("xdg-open")
|
||||
" call Decho("(netrw#BrowseX) unix and xdg-open",'~'.expand("<slnum>"))
|
||||
call s:NetrwExe("sil !xdg-open ".s:ShellEscape(fname,1).redir)
|
||||
call s:NetrwExe("sil !xdg-open ".s:ShellEscape(fname,1).redir.'&')
|
||||
let ret= v:shell_error
|
||||
|
||||
elseif has("macunix") && executable("open")
|
||||
@ -6053,10 +6098,10 @@ fun! s:NetrwListHide()
|
||||
" Duplicate characters don't matter.
|
||||
" Remove all such characters from the '/~@#...890' string.
|
||||
" Use the first character left as a separator character.
|
||||
" call Decho("find a character not in the hide string to use as a separator")
|
||||
" call Decho("find a character not in the hide string to use as a separator",'~'.expand("<slnum>"))
|
||||
let listhide= g:netrw_list_hide
|
||||
let sep = strpart(substitute('~@#$%^&*{};:,<.>?|1234567890','['.escape(listhide,'-]^\').']','','ge'),1,1)
|
||||
" call Decho("sep=".sep," (sep not in hide string)'~'.expand("<slnum>"))
|
||||
" call Decho("sep<".sep."> (sep not in hide string)",'~'.expand("<slnum>"))
|
||||
|
||||
while listhide != ""
|
||||
if listhide =~ ','
|
||||
@ -6066,7 +6111,7 @@ fun! s:NetrwListHide()
|
||||
let hide = listhide
|
||||
let listhide = ""
|
||||
endif
|
||||
" call Decho("..extracted from listhide: hide<".hide."> g:netrw_sort_by<".g:netrw_sort_by.'>','~'.expand("<slnum>"))
|
||||
" call Decho("..extracted pattern from listhide: hide<".hide."> g:netrw_sort_by<".g:netrw_sort_by.'>','~'.expand("<slnum>"))
|
||||
if g:netrw_sort_by =~ '^[ts]'
|
||||
if hide =~ '^\^'
|
||||
" call Decho("..modify hide to handle a \"^...\" pattern",'~'.expand("<slnum>"))
|
||||
@ -6078,7 +6123,7 @@ fun! s:NetrwListHide()
|
||||
endif
|
||||
|
||||
" Prune the list by hiding any files which match
|
||||
" call Decho("..prune the list by hiding any files which ",((g:netrw_hide == 1)? "" : "don't")." match hide<".hide.">")
|
||||
" call Decho("..prune the list by hiding any files which ".((g:netrw_hide == 1)? "" : "don't")."match hide<".hide.">")
|
||||
if g:netrw_hide == 1
|
||||
" call Decho("..hiding<".hide.">",'~'.expand("<slnum>"))
|
||||
exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$g'.sep.hide.sep.'d'
|
||||
@ -9161,6 +9206,7 @@ endfun
|
||||
" (full path directory with trailing slash returned)
|
||||
fun! s:NetrwTreeDir(islocal)
|
||||
" call Dfunc("s:NetrwTreeDir(islocal=".a:islocal.") getline(".line(".").")"."<".getline('.')."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> ft=".&ft)
|
||||
" call Decho("Determine tree directory given current cursor position")
|
||||
" call Decho("g:netrw_keepdir =".(exists("g:netrw_keepdir")? g:netrw_keepdir : 'n/a'),'~'.expand("<slnum>"))
|
||||
" call Decho("w:netrw_liststyle=".(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'),'~'.expand("<slnum>"))
|
||||
" call Decho("w:netrw_treetop =".(exists("w:netrw_treetop")? w:netrw_treetop : 'n/a'),'~'.expand("<slnum>"))
|
||||
@ -9266,7 +9312,6 @@ fun! s:NetrwTreeDisplay(dir,depth)
|
||||
call setline(line("$")+1,a:depth.shortdir.'/')
|
||||
endif
|
||||
" call Decho("setline#".line("$")." shortdir<".a:depth.shortdir.">",'~'.expand("<slnum>"))
|
||||
|
||||
" append a / to dir if its missing one
|
||||
let dir= a:dir
|
||||
|
||||
@ -9280,7 +9325,7 @@ fun! s:NetrwTreeDisplay(dir,depth)
|
||||
let listhide= split(g:netrw_list_hide,',')
|
||||
" call Decho("listhide=".string(listhide))
|
||||
for pat in listhide
|
||||
call filter(w:netrw_treedict[dir],'v:val !~ "'.pat.'"')
|
||||
call filter(w:netrw_treedict[dir],'v:val !~ "'.escape(pat,'\\').'"')
|
||||
endfor
|
||||
|
||||
elseif g:netrw_hide == 2
|
||||
@ -9418,6 +9463,7 @@ fun! s:NetrwTreeListing(dirname)
|
||||
" call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>"))
|
||||
|
||||
" display from treetop on down
|
||||
" call Decho("(s:NetrwTreeListing) w:netrw_treetop<".w:netrw_treetop.">")
|
||||
NetrwKeepj call s:NetrwTreeDisplay(w:netrw_treetop,"")
|
||||
" call Decho("s:NetrwTreeDisplay) setl noma nomod ro",'~'.expand("<slnum>"))
|
||||
|
||||
@ -9678,7 +9724,7 @@ fun! s:PerformListing(islocal)
|
||||
|
||||
" Hiding... -or- Showing... {{{3
|
||||
if g:netrw_banner
|
||||
" call Decho("--handle hiding/showing (g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">)",'~'.expand("<slnum>"))
|
||||
" call Decho("--handle hiding/showing in banner (g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">)",'~'.expand("<slnum>"))
|
||||
if g:netrw_list_hide != "" && g:netrw_hide
|
||||
if g:netrw_hide == 1
|
||||
NetrwKeepj put ='\" Hiding: '.g:netrw_list_hide
|
||||
@ -9731,7 +9777,7 @@ fun! s:PerformListing(islocal)
|
||||
" call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>"))
|
||||
|
||||
if !g:netrw_banner || line("$") >= w:netrw_bannercnt
|
||||
" call Decho("manipulate directory listing (hide)",'~'.expand("<slnum>"))
|
||||
" call Decho("manipulate directory listing (support hide)",'~'.expand("<slnum>"))
|
||||
" call Decho("g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">",'~'.expand("<slnum>"))
|
||||
if g:netrw_hide && g:netrw_list_hide != ""
|
||||
NetrwKeepj call s:NetrwListHide()
|
||||
@ -11744,7 +11790,7 @@ endfun
|
||||
" ---------------------------------------------------------------------
|
||||
" s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2
|
||||
fun! s:NetrwEnew(...)
|
||||
" call Dfunc("s:NetrwEnew() a:0=".a:0." bufnr($)=".bufnr("$")." expand(%)<".expand("%").">")
|
||||
" call Dfunc("s:NetrwEnew() a:0=".a:0." win#".winnr()." winnr($)=".winnr("$")." bufnr($)=".bufnr("$")." expand(%)<".expand("%").">")
|
||||
" call Decho("curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>"))
|
||||
|
||||
" grab a function-local-variable copy of buffer variables
|
||||
@ -11811,6 +11857,9 @@ fun! s:NetrwEnew(...)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if v:version >= 700 && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on")
|
||||
let &l:bexpr = "netrw#BalloonHelp()"
|
||||
endif
|
||||
|
||||
" call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#")."> bh=".&bh." win#".winnr()." winnr($)#".winnr("$"))
|
||||
endfun
|
||||
@ -11870,6 +11919,7 @@ endfun
|
||||
" -1=failed
|
||||
fun! s:NetrwLcd(newdir)
|
||||
" call Dfunc("s:NetrwLcd(newdir<".a:newdir.">)")
|
||||
" call Decho("changing local directory",'~'.expand("<slnum>"))
|
||||
|
||||
let err472= 0
|
||||
try
|
||||
@ -11905,6 +11955,8 @@ fun! s:NetrwLcd(newdir)
|
||||
return -1
|
||||
endif
|
||||
|
||||
" call Decho("getcwd <".getcwd().">")
|
||||
" call Decho("b:netrw_curdir<".b:netrw_curdir.">")
|
||||
" call Dret("s:NetrwLcd 0")
|
||||
return 0
|
||||
endfun
|
||||
|
@ -1,8 +1,8 @@
|
||||
" netrwFileHandlers: contains various extension-based file handlers for
|
||||
" netrw's browsers' x command ("eXecute launcher")
|
||||
" Author: Charles E. Campbell
|
||||
" Date: May 03, 2013
|
||||
" Version: 11b ASTRO-ONLY
|
||||
" Date: Sep 18, 2020
|
||||
" Version: 11
|
||||
" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1
|
||||
" Permission is hereby granted to use and distribute this code,
|
||||
" with or without modifications, provided that this copyright
|
||||
@ -20,7 +20,7 @@
|
||||
if exists("g:loaded_netrwFileHandlers") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_netrwFileHandlers= "v11b"
|
||||
let g:loaded_netrwFileHandlers= "v11"
|
||||
if v:version < 702
|
||||
echohl WarningMsg
|
||||
echo "***warning*** this version of netrwFileHandlers needs vim 7.2"
|
||||
|
@ -758,7 +758,7 @@ three lines: >
|
||||
<
|
||||
|
||||
Visual Mode and Range *v_:*
|
||||
|
||||
*:star-visual-range*
|
||||
{Visual}: Starts a command-line with the Visual selected lines as a
|
||||
range. The code `:'<,'>` is used for this range, which makes
|
||||
it possible to select a similar line from the command-line
|
||||
@ -830,34 +830,37 @@ it, no matter how many backslashes.
|
||||
\\# \#
|
||||
Also see |`=|.
|
||||
|
||||
*:<cword>* *<cword>* *:<cWORD>* *<cWORD>*
|
||||
*:<cexpr>* *<cexpr>* *:<cfile>* *<cfile>*
|
||||
*:<afile>* *<afile>* *:<abuf>* *<abuf>*
|
||||
*:<amatch>* *<amatch>*
|
||||
*:<sfile>* *<sfile>* *:<slnum>* *<slnum>*
|
||||
*:<sflnum>* *<sflnum>* *E499* *E500*
|
||||
*E499* *E500*
|
||||
Note: these are typed literally, they are not special keys!
|
||||
*:<cword>* *<cword>*
|
||||
<cword> is replaced with the word under the cursor (like |star|)
|
||||
*:<cWORD>* *<cWORD>*
|
||||
<cWORD> is replaced with the WORD under the cursor (see |WORD|)
|
||||
*:<cexpr>* *<cexpr>*
|
||||
<cexpr> is replaced with the word under the cursor, including more
|
||||
to form a C expression. E.g., when the cursor is on "arg"
|
||||
of "ptr->arg" then the result is "ptr->arg"; when the
|
||||
cursor is on "]" of "list[idx]" then the result is
|
||||
"list[idx]". This is used for |v:beval_text|.
|
||||
*:<cfile>* *<cfile>*
|
||||
<cfile> is replaced with the path name under the cursor (like what
|
||||
|gf| uses)
|
||||
*:<afile>* *<afile>*
|
||||
<afile> When executing autocommands, is replaced with the file name
|
||||
of the buffer being manipulated, or the file for a read or
|
||||
write. *E495*
|
||||
*:<abuf>* *<abuf>*
|
||||
<abuf> When executing autocommands, is replaced with the currently
|
||||
effective buffer number (for ":r file" and ":so file" it is
|
||||
the current buffer, the file being read/sourced is not in a
|
||||
buffer). *E496*
|
||||
*:<amatch>* *<amatch>*
|
||||
<amatch> When executing autocommands, is replaced with the match for
|
||||
which this autocommand was executed. *E497*
|
||||
It differs from <afile> only when the file name isn't used
|
||||
to match with (for FileType, Syntax and SpellFileMissing
|
||||
events).
|
||||
*:<sfile>* *<sfile>*
|
||||
<sfile> When executing a ":source" command, is replaced with the
|
||||
file name of the sourced file. *E498*
|
||||
When executing a function, is replaced with:
|
||||
@ -866,10 +869,12 @@ Note: these are typed literally, they are not special keys!
|
||||
"function {function-name1}[{lnum}]..{function-name2}[{lnum}]"
|
||||
Note that filename-modifiers are useless when <sfile> is
|
||||
used inside a function.
|
||||
*:<slnum>* *<slnum>*
|
||||
<slnum> When executing a ":source" command, is replaced with the
|
||||
line number. *E842*
|
||||
When executing a function it's the line number relative to
|
||||
the start of the function.
|
||||
*:<sflnum>* *<sflnum>*
|
||||
<sflnum> When executing a script, is replaced with the line number.
|
||||
It differs from <slnum> in that <sflnum> is replaced with
|
||||
the script line number in any situation. *E961*
|
||||
|
@ -4638,7 +4638,7 @@ getmarklist([{expr}]) *getmarklist()*
|
||||
local marks defined in buffer {expr}. For the use of {expr},
|
||||
see |bufname()|.
|
||||
|
||||
Each item in the retuned List is a |Dict| with the following:
|
||||
Each item in the returned List is a |Dict| with the following:
|
||||
name - name of the mark prefixed by "'"
|
||||
pos - a |List| with the position of the mark:
|
||||
[bufnum, lnum, col, off]
|
||||
|
@ -1768,6 +1768,7 @@ a Append text after the cursor [count] times. If the
|
||||
|
||||
*A*
|
||||
A Append text at the end of the line [count] times.
|
||||
For using "A" in Visual block mode see |v_b_A|.
|
||||
|
||||
<insert> or *i* *insert* *<Insert>*
|
||||
i Insert text before the cursor [count] times.
|
||||
@ -1780,6 +1781,7 @@ I Insert text before the first non-blank in the line
|
||||
When the 'H' flag is present in 'cpoptions' and the
|
||||
line only contains blanks, insert start just before
|
||||
the last blank.
|
||||
For using "I" in Visual block mode see |v_b_I|.
|
||||
|
||||
*gI*
|
||||
gI Insert text in column 1 [count] times.
|
||||
|
@ -1428,7 +1428,7 @@ The valid escape sequences are
|
||||
<bang> (See the '-bang' attribute) Expands to a ! if the
|
||||
command was executed with a ! modifier, otherwise
|
||||
expands to nothing.
|
||||
*<mods>* *:command-modifiers*
|
||||
*<mods>* *<q-mods>* *:command-modifiers*
|
||||
<mods> The command modifiers, if specified. Otherwise, expands to
|
||||
nothing. Supported modifiers are |:aboveleft|, |:belowright|,
|
||||
|:botright|, |:browse|, |:confirm|, |:hide|, |:keepalt|,
|
||||
|
@ -2093,7 +2093,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
'emoji' 'emo' boolean (default: on)
|
||||
global
|
||||
When on all Unicode emoji characters are considered to be full width.
|
||||
|
||||
This excludes "text emoji" characters, which are normally displayed as
|
||||
single width. Unfortunately there is no good specification for this
|
||||
and it has been determined on trial-and-error basis.
|
||||
|
||||
*'encoding'* *'enc'* *E543*
|
||||
'encoding' 'enc'
|
||||
@ -5903,8 +5905,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
N N Printer page number. (Only works in the 'printheader' option.)
|
||||
l N Line number.
|
||||
L N Number of lines in buffer.
|
||||
c N Column number.
|
||||
v N Virtual column number.
|
||||
c N Column number (byte index).
|
||||
v N Virtual column number (screen column).
|
||||
V N Virtual column number as -{num}. Not displayed if equal to 'c'.
|
||||
p N Percentage through file in lines as in |CTRL-G|.
|
||||
P S Percentage through file of displayed window. This is like the
|
||||
|
@ -437,9 +437,13 @@ settings are described below, in |netrw-browser-options|, and in
|
||||
*g:netrw_silent* =0 : transfers done normally
|
||||
=1 : transfers done silently
|
||||
|
||||
*g:netrw_use_errorwindow* =1 : messages from netrw will use a separate one
|
||||
*g:netrw_use_errorwindow* =2: messages from netrw will use a popup window
|
||||
Move the mouse and pause to remove the popup window.
|
||||
(default value if popup windows are availble)
|
||||
=1 : messages from netrw will use a separate one
|
||||
line window. This window provides reliable
|
||||
delivery of messages. (default)
|
||||
delivery of messages.
|
||||
(default value if popup windows are not availble)
|
||||
=0 : messages from netrw will use echoerr ;
|
||||
messages don't always seem to show up this
|
||||
way, but one doesn't have to quit the window.
|
||||
@ -725,6 +729,8 @@ just as easily as if they were local files! >
|
||||
See |netrw-activate| for more on how to encourage your vim to use plugins
|
||||
such as netrw.
|
||||
|
||||
For password-free use of scp:, see |netrw-ssh-hack|.
|
||||
|
||||
|
||||
==============================================================================
|
||||
7. Ex Commands *netrw-ex* {{{1
|
||||
@ -1063,7 +1069,7 @@ QUICK HELP *netrw-quickhelp* {{{2
|
||||
Reverse sorting order.........................|netrw-r|
|
||||
|
||||
|
||||
*netrw-quickmap* *netrw-quickmaps*
|
||||
*netrw-quickmap* *netrw-quickmaps*
|
||||
QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2
|
||||
>
|
||||
--- ----------------- ----
|
||||
@ -1080,7 +1086,7 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2
|
||||
a Cycles between normal display, |netrw-a|
|
||||
hiding (suppress display of files matching g:netrw_list_hide)
|
||||
and showing (display only files which match g:netrw_list_hide)
|
||||
c Make browsing directory the current directory |netrw-c|
|
||||
cd Make browsing directory the current directory |netrw-cd|
|
||||
C Setting the editing window |netrw-C|
|
||||
d Make a directory |netrw-d|
|
||||
D Attempt to remove the file(s)/directory(ies) |netrw-D|
|
||||
@ -2098,7 +2104,7 @@ the two directories the same, use the "cd" map (type cd). That map will
|
||||
set Vim's notion of the current directory to netrw's current browsing
|
||||
directory.
|
||||
|
||||
*netrw-c* : This map's name has been changed from "c" to cd (see |netrw-cd|).
|
||||
|netrw-cd|: This map's name was changed from "c" to cd (see |netrw-cd|).
|
||||
This change was done to allow for |netrw-cb| and |netrw-cB| maps.
|
||||
|
||||
Associated setting variable: |g:netrw_keepdir|
|
||||
@ -2752,7 +2758,7 @@ your browsing preferences. (see also: |netrw-settings|)
|
||||
=0 keep the current directory the same as the
|
||||
browsing directory.
|
||||
The current browsing directory is contained in
|
||||
b:netrw_curdir (also see |netrw-c|)
|
||||
b:netrw_curdir (also see |netrw-cd|)
|
||||
|
||||
*g:netrw_keepj* ="keepj" (default) netrw attempts to keep the
|
||||
|:jumps| table unaffected.
|
||||
@ -3053,7 +3059,7 @@ your browsing preferences. (see also: |netrw-settings|)
|
||||
(see |netrw-c-tab|).
|
||||
|
||||
*g:netrw_xstrlen* Controls how netrw computes string lengths,
|
||||
including multibyte characters' string
|
||||
including multi-byte characters' string
|
||||
length. (thanks to N Weibull, T Mechelynck)
|
||||
=0: uses Vim's built-in strlen()
|
||||
=1: number of codepoints (Latin a + combining
|
||||
@ -3123,7 +3129,8 @@ a file using the local browser (by putting the cursor on it) and pressing
|
||||
|
||||
Related topics:
|
||||
* To see what the current directory is, use |:pwd|
|
||||
* To make the currently browsed directory the current directory, see |netrw-c|
|
||||
* To make the currently browsed directory the current directory, see
|
||||
|netrw-cd|
|
||||
* To automatically make the currently browsed directory the current
|
||||
directory, see |g:netrw_keepdir|.
|
||||
|
||||
@ -3798,9 +3805,15 @@ netrw:
|
||||
or
|
||||
http://vim.sourceforge.net/scripts/script.php?script_id=120
|
||||
|
||||
Decho.vim is provided as a "vimball"; see |vimball-intro|.
|
||||
Decho.vim is provided as a "vimball"; see |vimball-intro|. You
|
||||
should edit the Decho.vba.gz file and source it in: >
|
||||
|
||||
2. Edit the <netrw.vim> file by typing: >
|
||||
vim Decho.vba.gz
|
||||
:so %
|
||||
:q
|
||||
<
|
||||
2. To turn on debug tracing in netrw, then edit the <netrw.vim>
|
||||
file by typing: >
|
||||
|
||||
vim netrw.vim
|
||||
:DechoOn
|
||||
@ -3822,14 +3835,34 @@ netrw:
|
||||
read/write your file over the network in a separate tab or
|
||||
server vim window.
|
||||
|
||||
To save the file, use >
|
||||
Change the netrw.vimrc file to include the Decho plugin: >
|
||||
|
||||
set nocp
|
||||
so $HOME/.vim/plugin/Decho.vim
|
||||
so $HOME/.vim/plugin/netrwPlugin.vim
|
||||
<
|
||||
You should continue to run vim with >
|
||||
|
||||
vim -u netrw.vimrc --noplugins -i NONE [some path here]
|
||||
<
|
||||
to avoid entanglements with options and other plugins.
|
||||
|
||||
To save the file: under linux, the output will be in a separate
|
||||
remote server window; in it, just save the file with >
|
||||
|
||||
:w! DBG
|
||||
|
||||
< Under a vim that doesn't support clientserver, your debugging
|
||||
output will appear in another tab: >
|
||||
|
||||
:tabnext
|
||||
:set bt=
|
||||
:w! DBG
|
||||
<
|
||||
Furthermore, it'd be helpful if you would type >
|
||||
|
||||
< Furthermore, it'd be helpful if you would type >
|
||||
:Dsep <command>
|
||||
|
||||
< where <command> is the command you're about to type next,
|
||||
thereby making it easier to associate which part of the
|
||||
debugging trace is due to which command.
|
||||
@ -3837,17 +3870,34 @@ netrw:
|
||||
Please send that information to <netrw.vim>'s maintainer along
|
||||
with the o/s you're using and the vim version that you're using
|
||||
(see |:version|) (remove the embedded NOSPAM first) >
|
||||
|
||||
NcampObell@SdrPchip.AorgM-NOSPAM
|
||||
<
|
||||
==============================================================================
|
||||
12. History *netrw-history* {{{1
|
||||
|
||||
v170: Mar 11, 2020 * (reported by Reiner Herrmann) netrw+tree
|
||||
would not hide with the ^\..* pattern
|
||||
correctly.
|
||||
* (Marcin Szamotulski) NetrwOptionRestore
|
||||
did not restore options correctly that
|
||||
had a single quote in the option string.
|
||||
Apr 13, 2020 * implemented error handling via popup
|
||||
windows (see |popup_beval()|)
|
||||
Apr 30, 2020 * (reported by Manatsu Takahashi) while
|
||||
using Lexplore, a modified file could
|
||||
be overwritten. Sol'n: will not overwrite,
|
||||
but will emit an |E37| (although one cannot
|
||||
add an ! to override)
|
||||
Jun 07, 2020 * (reported by Jo Totland) repeatedly invoking
|
||||
:Lexplore and quitting it left unused
|
||||
hidden buffers. Netrw will now set netrw
|
||||
buffers created by :Lexplore to |bh|=wipe.
|
||||
v169: Dec 20, 2019 * (reported by amkarthik) that netrw's x
|
||||
(|netrw-x|) would throw an error when
|
||||
attempting to open a local directory.
|
||||
v168: Dec 12, 2019 * scp timeout error message not reported,
|
||||
hopefully now fixed (Shane Xb Qian)
|
||||
|
||||
v167: Nov 29, 2019 * netrw does a save&restore on @* and @+.
|
||||
That causes problems with the clipboard.
|
||||
Now restores occurs only if @* or @+ have
|
||||
@ -4305,4 +4355,4 @@ netrw:
|
||||
|
||||
==============================================================================
|
||||
Modelines: {{{1
|
||||
vim:tw=78:ts=8:noet:ft=help:norl:fdm=marker
|
||||
vim:tw=78:ts=8:ft=help:noet:norl:fdm=marker
|
||||
|
@ -4,9 +4,9 @@
|
||||
" Contributors: Edwin Fine <efine145_nospam01 at usa dot net>
|
||||
" Pawel 'kTT' Salata <rockplayer.pl@gmail.com>
|
||||
" Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
|
||||
" Last Update: 2013-Jul-21
|
||||
" Last Update: 2020-Jun-11
|
||||
" License: Vim license
|
||||
" URL: https://github.com/hcs42/vim-erlang
|
||||
" URL: https://github.com/vim-erlang/vim-erlang-runtime
|
||||
|
||||
" Note About Usage:
|
||||
" This indentation script works best with the Erlang syntax file created by
|
||||
@ -56,7 +56,8 @@ endfunction
|
||||
" Line tokenizer library {{{1
|
||||
" ======================
|
||||
|
||||
" Indtokens are "indentation tokens".
|
||||
" Indtokens are "indentation tokens". See their exact format in the
|
||||
" documentaiton of the s:GetTokensFromLine function.
|
||||
|
||||
" Purpose:
|
||||
" Calculate the new virtual column after the given segment of a line.
|
||||
@ -119,9 +120,10 @@ endfunction
|
||||
" Returns:
|
||||
" indtokens = [indtoken]
|
||||
" indtoken = [token, vcol, col]
|
||||
" token = string (examples: 'begin', '<variable>', '}')
|
||||
" vcol = integer (the virtual column of the first character of the token)
|
||||
" col = integer
|
||||
" token = string (examples: 'begin', '<quoted_atom>', '}')
|
||||
" vcol = integer (the virtual column of the first character of the token;
|
||||
" counting starts from 0)
|
||||
" col = integer (counting starts from 0)
|
||||
function! s:GetTokensFromLine(line, string_continuation, atom_continuation,
|
||||
\tabstop)
|
||||
|
||||
@ -386,9 +388,12 @@ endfunction
|
||||
" lnum: integer
|
||||
" direction: 'up' | 'down'
|
||||
" Returns:
|
||||
" result: [] -- the result is an empty list if we hit the beginning or end
|
||||
" of the file
|
||||
" | indtoken
|
||||
" result: [[], 0, 0]
|
||||
" -- the result is an empty list if we hit the beginning or end of
|
||||
" the file
|
||||
" | [indtoken, lnum, i]
|
||||
" -- the content, lnum and token index of the next (or previous)
|
||||
" indtoken
|
||||
function! s:FindIndToken(lnum, dir)
|
||||
let lnum = a:lnum
|
||||
while 1
|
||||
@ -396,9 +401,12 @@ function! s:FindIndToken(lnum, dir)
|
||||
let [lnum, indtokens] = s:TokenizeLine(lnum, a:dir)
|
||||
if lnum ==# 0
|
||||
" We hit the beginning or end of the file
|
||||
return []
|
||||
return [[], 0, 0]
|
||||
elseif !empty(indtokens)
|
||||
return indtokens[a:dir ==# 'up' ? -1 : 0]
|
||||
" We found a non-empty line. If we were moving up, we return the last
|
||||
" token of this line. Otherwise we return the first token if this line.
|
||||
let i = (a:dir ==# 'up' ? len(indtokens) - 1 : 0)
|
||||
return [indtokens[i], lnum, i]
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
@ -417,7 +425,7 @@ function! s:PrevIndToken(lnum, i)
|
||||
|
||||
" If the current line has a previous token, return that
|
||||
if a:i > 0
|
||||
return s:all_tokens[a:lnum][a:i - 1]
|
||||
return [s:all_tokens[a:lnum][a:i - 1], a:lnum, a:i - 1]
|
||||
else
|
||||
return s:FindIndToken(a:lnum, 'up')
|
||||
endif
|
||||
@ -437,7 +445,7 @@ function! s:NextIndToken(lnum, i)
|
||||
|
||||
" If the current line has a next token, return that
|
||||
if len(s:all_tokens[a:lnum]) > a:i + 1
|
||||
return s:all_tokens[a:lnum][a:i + 1]
|
||||
return [s:all_tokens[a:lnum][a:i + 1], a:lnum, a:i + 1]
|
||||
else
|
||||
return s:FindIndToken(a:lnum, 'down')
|
||||
endif
|
||||
@ -518,7 +526,9 @@ endfunction
|
||||
" ok. % IsLineAtomContinuation = false
|
||||
function! s:IsLineAtomContinuation(lnum)
|
||||
if has('syntax_items')
|
||||
return synIDattr(synID(a:lnum, 1, 0), 'name') =~# '^erlangQuotedAtom'
|
||||
let syn_name = synIDattr(synID(a:lnum, 1, 0), 'name')
|
||||
return syn_name =~# '^erlangQuotedAtom' ||
|
||||
\ syn_name =~# '^erlangQuotedRecord'
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
@ -535,7 +545,7 @@ endfunction
|
||||
" is_standalone: bool
|
||||
function! s:IsCatchStandalone(lnum, i)
|
||||
call s:Log(' IsCatchStandalone called: lnum=' . a:lnum . ', i=' . a:i)
|
||||
let prev_indtoken = s:PrevIndToken(a:lnum, a:i)
|
||||
let [prev_indtoken, _, _] = s:PrevIndToken(a:lnum, a:i)
|
||||
|
||||
" If we hit the beginning of the file, it is not a catch in a try block
|
||||
if prev_indtoken == []
|
||||
@ -544,7 +554,7 @@ function! s:IsCatchStandalone(lnum, i)
|
||||
|
||||
let prev_token = prev_indtoken[0]
|
||||
|
||||
if prev_token =~# '[A-Z_@0-9]'
|
||||
if prev_token =~# '^[A-Z_@0-9]'
|
||||
let is_standalone = 0
|
||||
elseif prev_token =~# '[a-z]'
|
||||
if index(['after', 'and', 'andalso', 'band', 'begin', 'bnot', 'bor', 'bsl',
|
||||
@ -659,11 +669,14 @@ endfunction
|
||||
" stack: [token]
|
||||
" token: string
|
||||
" stored_vcol: integer
|
||||
" lnum: the line number of the "end of clause" mark (or 0 if we hit the
|
||||
" beginning of the file)
|
||||
" i: the index of the "end of clause" token within its own line
|
||||
" Returns:
|
||||
" result: [should_return, indent]
|
||||
" should_return: bool -- if true, the caller should return `indent` to Vim
|
||||
" indent -- integer
|
||||
function! s:BeginningOfClauseFound(stack, token, stored_vcol)
|
||||
function! s:BeginningOfClauseFound(stack, token, stored_vcol, lnum, i)
|
||||
if !empty(a:stack) && a:stack[0] ==# 'when'
|
||||
call s:Log(' BeginningOfClauseFound: "when" found in stack')
|
||||
call s:Pop(a:stack)
|
||||
@ -681,13 +694,45 @@ function! s:BeginningOfClauseFound(stack, token, stored_vcol)
|
||||
return [1, a:stored_vcol + shiftwidth()]
|
||||
elseif a:stack[0] ==# ';'
|
||||
call s:Pop(a:stack)
|
||||
if empty(a:stack)
|
||||
call s:Log(' Stack is ["->", ";"], so LTI is in a function head ' .
|
||||
\'-> return')
|
||||
return [0, a:stored_vcol]
|
||||
else
|
||||
|
||||
if !empty(a:stack)
|
||||
return [1, s:UnexpectedToken(a:token, a:stack)]
|
||||
endif
|
||||
|
||||
if a:lnum ==# 0
|
||||
" Set lnum and i to be NextIndToken-friendly
|
||||
let lnum = 1
|
||||
let i = -1
|
||||
else
|
||||
let lnum = a:lnum
|
||||
let i = a:i
|
||||
endif
|
||||
|
||||
" Are we after a "-spec func() ...;" clause?
|
||||
let [next1_indtoken, next1_lnum, next1_i] = s:NextIndToken(lnum, i)
|
||||
if !empty(next1_indtoken) && next1_indtoken[0] =~# '-'
|
||||
let [next2_indtoken, next2_lnum, next2_i] =
|
||||
\s:NextIndToken(next1_lnum, next1_i)
|
||||
if !empty(next2_indtoken) && next2_indtoken[0] =~# 'spec'
|
||||
let [next3_indtoken, next3_lnum, next3_i] =
|
||||
\s:NextIndToken(next2_lnum, next2_i)
|
||||
if !empty(next3_indtoken)
|
||||
let [next4_indtoken, next4_lnum, next4_i] =
|
||||
\s:NextIndToken(next3_lnum, next3_i)
|
||||
if !empty(next4_indtoken)
|
||||
" Yes, we are.
|
||||
call s:Log(' Stack is ["->", ";"], so LTI is in a "-spec" ' .
|
||||
\'attribute -> return')
|
||||
return [1, next4_indtoken[1]]
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
call s:Log(' Stack is ["->", ";"], so LTI is in a function head ' .
|
||||
\'-> return')
|
||||
return [1, a:stored_vcol]
|
||||
|
||||
else
|
||||
return [1, s:UnexpectedToken(a:token, a:stack)]
|
||||
endif
|
||||
@ -714,7 +759,7 @@ function! s:SearchEndPair(lnum, curr_col)
|
||||
return s:SearchPair(
|
||||
\ a:lnum, a:curr_col,
|
||||
\ '\C\<\%(case\|try\|begin\|receive\|if\)\>\|' .
|
||||
\ '\<fun\>\%(\s\|\n\|%.*$\)*(',
|
||||
\ '\<fun\>\%(\s\|\n\|%.*$\|[A-Z_@][a-zA-Z_@]*\)*(',
|
||||
\ '',
|
||||
\ '\<end\>')
|
||||
endfunction
|
||||
@ -756,7 +801,7 @@ function! s:ErlangCalcIndent2(lnum, stack)
|
||||
" Hit the start of the file
|
||||
if lnum ==# 0
|
||||
let [ret, res] = s:BeginningOfClauseFound(stack, 'beginning_of_file',
|
||||
\stored_vcol)
|
||||
\stored_vcol, 0, 0)
|
||||
if ret | return res | endif
|
||||
|
||||
return 0
|
||||
@ -775,7 +820,8 @@ function! s:ErlangCalcIndent2(lnum, stack)
|
||||
endif
|
||||
|
||||
if token ==# '<end_of_clause>'
|
||||
let [ret, res] = s:BeginningOfClauseFound(stack, token, stored_vcol)
|
||||
let [ret, res] = s:BeginningOfClauseFound(stack, token, stored_vcol,
|
||||
\lnum, i)
|
||||
if ret | return res | endif
|
||||
|
||||
if stored_vcol ==# -1
|
||||
@ -787,7 +833,7 @@ function! s:ErlangCalcIndent2(lnum, stack)
|
||||
endif
|
||||
|
||||
elseif stack == ['prev_term_plus']
|
||||
if token =~# '[a-zA-Z_@]' ||
|
||||
if token =~# '[a-zA-Z_@#]' ||
|
||||
\ token ==# '<string>' || token ==# '<string_start>' ||
|
||||
\ token ==# '<quoted_atom>' || token ==# '<quoted_atom_start>'
|
||||
call s:Log(' previous token found: curr_vcol + plus = ' .
|
||||
@ -917,9 +963,18 @@ function! s:ErlangCalcIndent2(lnum, stack)
|
||||
if ret | return res | endif
|
||||
|
||||
elseif token ==# 'fun'
|
||||
let next_indtoken = s:NextIndToken(lnum, i)
|
||||
let [next_indtoken, next_lnum, next_i] = s:NextIndToken(lnum, i)
|
||||
call s:Log(' Next indtoken = ' . string(next_indtoken))
|
||||
|
||||
if !empty(next_indtoken) && next_indtoken[0] =~# '^[A-Z_@]'
|
||||
" The "fun" is followed by a variable, so we might have a named fun:
|
||||
" "fun Fun() -> ok end". Thus we take the next token to decide
|
||||
" whether this is a function definition ("fun()") or just a function
|
||||
" reference ("fun Mod:Fun").
|
||||
let [next_indtoken, _, _] = s:NextIndToken(next_lnum, next_i)
|
||||
call s:Log(' Next indtoken = ' . string(next_indtoken))
|
||||
endif
|
||||
|
||||
if !empty(next_indtoken) && next_indtoken[0] ==# '('
|
||||
" We have an anonymous function definition
|
||||
" (e.g. "fun () -> ok end")
|
||||
@ -1327,6 +1382,26 @@ function! ErlangIndent()
|
||||
return -1
|
||||
endif
|
||||
|
||||
" If the line starts with the comment, and so is the previous non-blank line
|
||||
if currline =~# '^\s*%'
|
||||
let lnum = prevnonblank(v:lnum - 1)
|
||||
if lnum ==# 0
|
||||
call s:Log('First non-empty line of the file -> return 0.')
|
||||
return 0
|
||||
else
|
||||
let ml = matchlist(getline(lnum), '^\(\s*\)%')
|
||||
" If the previous line also starts with a comment, then return the same
|
||||
" indentation that line has. Otherwise exit from this special "if" and
|
||||
" don't care that the current line is a comment.
|
||||
if !empty(ml)
|
||||
let new_col = s:CalcVCol(ml[1], 0, len(ml[1]) - 1, 0, &tabstop)
|
||||
call s:Log('Comment line after another comment line -> ' .
|
||||
\'use same indent: ' . new_col)
|
||||
return new_col
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let ml = matchlist(currline,
|
||||
\'^\(\s*\)\(\%(end\|of\|catch\|after\)\>\|[)\]}]\|>>\)')
|
||||
|
||||
@ -1381,6 +1456,24 @@ function! ErlangIndent()
|
||||
|
||||
endfunction
|
||||
|
||||
" ErlangShowTokensInLine functions {{{1
|
||||
" ================================
|
||||
|
||||
" These functions are useful during development.
|
||||
|
||||
function! ErlangShowTokensInLine(line)
|
||||
echo "Line: " . a:line
|
||||
let indtokens = s:GetTokensFromLine(a:line, 0, 0, &tabstop)
|
||||
echo "Tokens:"
|
||||
for it in indtokens
|
||||
echo it
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ErlangShowTokensInCurrentLine()
|
||||
return ErlangShowTokensInLine(getline('.'))
|
||||
endfunction
|
||||
|
||||
" Cleanup {{{1
|
||||
" =======
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
if &cp || exists("g:loaded_netrwPlugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_netrwPlugin = "v168"
|
||||
let g:loaded_netrwPlugin = "v170"
|
||||
let s:keepcpo = &cpo
|
||||
set cpo&vim
|
||||
"DechoRemOn
|
||||
|
@ -2,7 +2,7 @@
|
||||
" Language: Erlang (http://www.erlang.org)
|
||||
" Maintainer: Csaba Hoch <csaba.hoch@gmail.com>
|
||||
" Contributor: Adam Rutkowski <hq@mtod.org>
|
||||
" Last Update: 2019-Jun-18
|
||||
" Last Update: 2020-May-26
|
||||
" License: Vim license
|
||||
" URL: https://github.com/vim-erlang/vim-erlang-runtime
|
||||
|
||||
@ -44,7 +44,7 @@ setlocal iskeyword+=$,@-@
|
||||
|
||||
" Comments
|
||||
syn match erlangComment '%.*$' contains=erlangCommentAnnotation,erlangTodo
|
||||
syn match erlangCommentAnnotation ' \@<=@\%(clear\|docfile\|end\|headerfile\|todo\|TODO\|type\|author\|copyright\|doc\|reference\|see\|since\|title\|version\|deprecated\|hidden\|private\|equiv\|spec\|throws\)' contained
|
||||
syn match erlangCommentAnnotation ' \@<=@\%(clear\|docfile\|end\|headerfile\|todo\|TODO\|type\|author\|copyright\|doc\|reference\|see\|since\|title\|version\|deprecated\|hidden\|param\|private\|equiv\|spec\|throws\)' contained
|
||||
syn match erlangCommentAnnotation /`[^']*'/ contained
|
||||
syn keyword erlangTodo TODO FIXME XXX contained
|
||||
|
||||
@ -92,7 +92,7 @@ syn match erlangBitType '\%(\/\%(\s\|\n\|%.*\n\)*\)\@<=\%(integer\|float\|binary
|
||||
|
||||
" Constants and Directives
|
||||
syn match erlangUnknownAttribute '^\s*-\%(\s\|\n\|%.*\n\)*\l[[:alnum:]_@]*' contains=erlangComment
|
||||
syn match erlangAttribute '^\s*-\%(\s\|\n\|%.*\n\)*\%(behaviou\=r\|compile\|export\(_type\)\=\|file\|import\|module\|author\|copyright\|doc\|vsn\|on_load\)\>' contains=erlangComment
|
||||
syn match erlangAttribute '^\s*-\%(\s\|\n\|%.*\n\)*\%(behaviou\=r\|compile\|export\(_type\)\=\|file\|import\|module\|author\|copyright\|doc\|vsn\|on_load\|optional_callbacks\)\>' contains=erlangComment
|
||||
syn match erlangInclude '^\s*-\%(\s\|\n\|%.*\n\)*\%(include\|include_lib\)\>' contains=erlangComment
|
||||
syn match erlangRecordDef '^\s*-\%(\s\|\n\|%.*\n\)*record\>' contains=erlangComment
|
||||
syn match erlangDefine '^\s*-\%(\s\|\n\|%.*\n\)*\%(define\|undef\)\>' contains=erlangComment
|
||||
|
@ -105,7 +105,7 @@ if !exists("did_drchip_netrwlist_syntax")
|
||||
|
||||
" special syntax highlighting (see :he g:netrw_special_syntax)
|
||||
hi default link netrwCoreDump WarningMsg
|
||||
hi default link netrwData DiffChange
|
||||
hi default link netrwData Folded
|
||||
hi default link netrwHdr netrwPlain
|
||||
hi default link netrwLex netrwPlain
|
||||
hi default link netrwLib DiffChange
|
||||
|
Loading…
Reference in New Issue
Block a user