updated for version 7.0146
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
" Vim completion script
|
||||
" Language: C
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2005 Sep 10
|
||||
" Last Change: 2005 Sep 13
|
||||
|
||||
|
||||
" This function is used for the 'occultfunc' option.
|
||||
" This function is used for the 'omnifunc' option.
|
||||
function! ccomplete#Complete(findstart, base)
|
||||
if a:findstart
|
||||
" Locate the start of the item, including "." and "->".
|
||||
@ -38,12 +38,12 @@ function! ccomplete#Complete(findstart, base)
|
||||
" 2. in tags file(s) (like with ":tag")
|
||||
" 3. in current file (like with "gD")
|
||||
let res = []
|
||||
if searchdecl(items[0]) == 0
|
||||
if searchdecl(items[0], 0, 1) == 0
|
||||
" Found, now figure out the type.
|
||||
" TODO: join previous line if it makes sense
|
||||
let line = getline('.')
|
||||
let col = col('.')
|
||||
let res = ccomplete#Nextitem(strpart(line, 0, col), items[1:])
|
||||
let res = s:Nextitem(strpart(line, 0, col), items[1:])
|
||||
endif
|
||||
|
||||
if len(res) == 0
|
||||
@ -54,7 +54,7 @@ function! ccomplete#Complete(findstart, base)
|
||||
for i in range(len(diclist))
|
||||
" New ctags has the "typename" field.
|
||||
if has_key(diclist[i], 'typename')
|
||||
call extend(res, ccomplete#StructMembers(diclist[i]['typename'], items[1:]))
|
||||
call extend(res, s:StructMembers(diclist[i]['typename'], items[1:]))
|
||||
endif
|
||||
|
||||
" For a variable use the command, which must be a search pattern that
|
||||
@ -63,7 +63,7 @@ function! ccomplete#Complete(findstart, base)
|
||||
let line = diclist[i]['cmd']
|
||||
if line[0] == '/' && line[1] == '^'
|
||||
let col = match(line, items[0])
|
||||
call extend(res, ccomplete#Nextitem(strpart(line, 2, col - 2), items[1:])
|
||||
call extend(res, s:Nextitem(strpart(line, 2, col - 2), items[1:]))
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
@ -74,19 +74,30 @@ function! ccomplete#Complete(findstart, base)
|
||||
" TODO: join previous line if it makes sense
|
||||
let line = getline('.')
|
||||
let col = col('.')
|
||||
let res = ccomplete#Nextitem(strpart(line, 0, col), items[1:])
|
||||
let res = s:Nextitem(strpart(line, 0, col), items[1:])
|
||||
endif
|
||||
|
||||
" If the one and only match was what's already there and it is a composite
|
||||
" type, add a "." or "->".
|
||||
if len(res) == 1 && res[0]['match'] == items[-1] && len(s:SearchMembers(res, [''])) > 0
|
||||
" If there is a '*' before the name use "->".
|
||||
if match(res[0]['tagline'], '\*\s*' . res[0]['match']) > 0
|
||||
let res[0]['match'] .= '->'
|
||||
else
|
||||
let res[0]['match'] .= '.'
|
||||
endif
|
||||
endif
|
||||
|
||||
" The basetext is up to the last "." or "->" and won't be changed. The
|
||||
" matching members are concatenated to this.
|
||||
let basetext = matchstr(a:base, '.*\(\.\|->\)')
|
||||
return map(res, 'basetext . v:val')
|
||||
return map(res, 'basetext . v:val["match"]')
|
||||
endfunc
|
||||
|
||||
" Find composing type in "lead" and match items[0] with it.
|
||||
" Repeat this recursively for items[1], if it's there.
|
||||
" Return the list of matches.
|
||||
function! ccomplete#Nextitem(lead, items)
|
||||
function! s:Nextitem(lead, items)
|
||||
|
||||
" Use the text up to the variable name and split it in tokens.
|
||||
let tokens = split(a:lead, '\s\+\|\<')
|
||||
@ -97,7 +108,7 @@ function! ccomplete#Nextitem(lead, items)
|
||||
|
||||
" Recognize "struct foobar" and "union foobar".
|
||||
if (tokens[tidx] == 'struct' || tokens[tidx] == 'union') && tidx + 1 < len(tokens)
|
||||
let res = ccomplete#StructMembers(tokens[tidx] . ':' . tokens[tidx + 1], a:items)
|
||||
let res = s:StructMembers(tokens[tidx] . ':' . tokens[tidx + 1], a:items)
|
||||
break
|
||||
endif
|
||||
|
||||
@ -108,20 +119,42 @@ function! ccomplete#Nextitem(lead, items)
|
||||
|
||||
" Use the tags file to find out if this is a typedef.
|
||||
let diclist = taglist('^' . tokens[tidx] . '$')
|
||||
for i in range(len(diclist))
|
||||
for tagidx in range(len(diclist))
|
||||
" New ctags has the "typename" field.
|
||||
if has_key(diclist[i], 'typename')
|
||||
call extend(res, ccomplete#StructMembers(diclist[i]['typename'], a:items))
|
||||
if has_key(diclist[tagidx], 'typename')
|
||||
call extend(res, s:StructMembers(diclist[tagidx]['typename'], a:items))
|
||||
continue
|
||||
endif
|
||||
|
||||
" For old ctags we only recognize "typedef struct foobar" in the tags
|
||||
" file command.
|
||||
let cmd = diclist[i]['cmd']
|
||||
let ci = matchend(cmd, 'typedef\s\+struct\s\+')
|
||||
if ci > 1
|
||||
let name = matchstr(cmd, '\w*', ci)
|
||||
call extend(res, ccomplete#StructMembers('struct:' . name, a:items))
|
||||
" Only handle typedefs here.
|
||||
if diclist[tagidx]['kind'] != 't'
|
||||
continue
|
||||
endif
|
||||
|
||||
" For old ctags we recognize "typedef struct aaa" and
|
||||
" "typedef union bbb" in the tags file command.
|
||||
let cmd = diclist[tagidx]['cmd']
|
||||
let ei = matchend(cmd, 'typedef\s\+')
|
||||
if ei > 1
|
||||
let cmdtokens = split(strpart(cmd, ei), '\s\+\|\<')
|
||||
if len(cmdtokens) > 1
|
||||
if cmdtokens[0] == 'struct' || cmdtokens[0] == 'union'
|
||||
let name = ''
|
||||
" Use the first identifier after the "struct" or "union"
|
||||
for ti in range(len(cmdtokens) - 1)
|
||||
if cmdtokens[ti] =~ '^\w'
|
||||
let name = cmdtokens[ti]
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if name != ''
|
||||
call extend(res, s:StructMembers(cmdtokens[0] . ':' . name, a:items))
|
||||
endif
|
||||
else
|
||||
" Could be "typedef other_T some_T".
|
||||
call extend(res, s:Nextitem(cmdtokens[0], a:items))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(res) > 0
|
||||
@ -133,12 +166,13 @@ function! ccomplete#Nextitem(lead, items)
|
||||
endfunction
|
||||
|
||||
|
||||
" Return a list with resulting matches
|
||||
function! ccomplete#StructMembers(typename, items)
|
||||
" Return a list with resulting matches.
|
||||
" Each match is a dictionary with "match" and "tagline" entries.
|
||||
function! s:StructMembers(typename, items)
|
||||
" Todo: What about local structures?
|
||||
let fnames = join(map(tagfiles(), 'escape(v:val, " \\")'))
|
||||
if fnames == ''
|
||||
return [[], []]
|
||||
return []
|
||||
endif
|
||||
|
||||
let typename = a:typename
|
||||
@ -153,45 +187,49 @@ function! ccomplete#StructMembers(typename, items)
|
||||
let typename = substitute(typename, ':[^:]*::', ':', '')
|
||||
endwhile
|
||||
|
||||
let members = []
|
||||
let taglines = []
|
||||
let matches = []
|
||||
for l in qflist
|
||||
let memb = matchstr(l['text'], '[^\t]*')
|
||||
if memb =~ '^' . a:items[0]
|
||||
call add(members, memb)
|
||||
call add(taglines, l['text'])
|
||||
call add(matches, {'match': memb, 'tagline': l['text']})
|
||||
endif
|
||||
endfor
|
||||
|
||||
if len(members) > 0
|
||||
if len(matches) > 0
|
||||
" No further items, return the result.
|
||||
if len(a:items) == 1
|
||||
return members
|
||||
return matches
|
||||
endif
|
||||
|
||||
" More items following. For each of the possible members find the
|
||||
" matching following members.
|
||||
let res = []
|
||||
for i in range(len(members))
|
||||
let line = taglines[i]
|
||||
let e = matchend(line, '\ttypename:')
|
||||
if e > 0
|
||||
" Use typename field
|
||||
let name = matchstr(line, '[^\t]*', e)
|
||||
call extend(res, ccomplete#StructMembers(name, a:items[1:]))
|
||||
else
|
||||
let s = match(line, '\t\zs/^')
|
||||
if s > 0
|
||||
let e = match(line, members[i], s)
|
||||
if e > 0
|
||||
call extend(res, ccomplete#Nextitem(strpart(line, s, e - s), a:items[1:]))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return res
|
||||
return s:SearchMembers(matches, a:items[1:])
|
||||
endif
|
||||
|
||||
" Failed to find anything.
|
||||
return []
|
||||
endfunction
|
||||
|
||||
" For matching members, find matches for following items.
|
||||
function! s:SearchMembers(matches, items)
|
||||
let res = []
|
||||
for i in range(len(a:matches))
|
||||
let line = a:matches[i]['tagline']
|
||||
let e = matchend(line, '\ttypename:')
|
||||
if e > 0
|
||||
" Use typename field
|
||||
let name = matchstr(line, '[^\t]*', e)
|
||||
call extend(res, s:StructMembers(name, a:items))
|
||||
else
|
||||
" Use the search command (the declaration itself).
|
||||
let s = match(line, '\t\zs/^')
|
||||
if s > 0
|
||||
let e = match(line, a:matches[i]['match'], s)
|
||||
if e > 0
|
||||
call extend(res, s:Nextitem(strpart(line, s, e - s), a:items))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return res
|
||||
endfunc
|
||||
|
||||
243
runtime/autoload/htmlcomplete.vim
Normal file
243
runtime/autoload/htmlcomplete.vim
Normal file
@ -0,0 +1,243 @@
|
||||
" Vim completion script
|
||||
" Language: XHTML 1.0 Strict
|
||||
" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
|
||||
" Last Change: 2005 Sep 13
|
||||
|
||||
function! htmlcomplete#CompleteTags(findstart, base)
|
||||
if a:findstart
|
||||
" locate the start of the word
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
while start >= 0 && line[start - 1] !~ '<'
|
||||
let start -= 1
|
||||
endwhile
|
||||
let g:st = start
|
||||
return start
|
||||
else
|
||||
" Set attribute groups
|
||||
let g:coreattrs = ["id", "class", "style", "title"]
|
||||
let g:i18n = ["lang", "xml:lang", "dir"]
|
||||
let g:events = ["onclick", "ondblclick", "onmousedown", "onmouseup", "onmousemove",
|
||||
\ "onmouseout", "onkeypress", "onkeydown", "onkeyup"]
|
||||
let g:focus = ["accesskey", "tabindex", "onfocus", "onblur"]
|
||||
let g:coregroup = g:coreattrs
|
||||
let g:coregroup = extend(g:coregroup, g:i18n)
|
||||
let g:coregroup = extend(g:coregroup, g:events)
|
||||
" find tags matching with "a:base"
|
||||
let res = []
|
||||
" If a:base contains > it means we are already outside of tag and we
|
||||
" should abandon action
|
||||
if a:base =~ '>'
|
||||
return []
|
||||
endif
|
||||
" If a:base contains white space it is attribute.
|
||||
" It could be also value of attribute...
|
||||
" Possible situations where any prediction would be difficult:
|
||||
" 1. Events attributes
|
||||
if a:base =~ '\s'
|
||||
" Sort out style, class, and on* cases
|
||||
" Perfect solution for style would be switching for CSS completion. Is
|
||||
" it possible?
|
||||
" Also retrieving class names from current file and linked
|
||||
" stylesheets.
|
||||
if a:base =~ "\\(on[a-z]*\\|style\\|class\\)\\s*=\\s*[\"']"
|
||||
let stripbase = matchstr(a:base, ".*\\(on[a-z]*\\|style\\|class\\)\\s*=\\s*[\"']\\zs.*")
|
||||
" Now we have a:base stripped from all chars up to style/class.
|
||||
" It may fail with some strange style value combinations.
|
||||
if stripbase !~ "[\"']"
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
" We have to get first word to offer
|
||||
" proper attributes.
|
||||
let tag = split(a:base)[0]
|
||||
" Get last word, it should be attr name
|
||||
let attr = matchstr(a:base, '.*\s\zs.*')
|
||||
" If attr contains =\s*[\"'] we catched value of attribute
|
||||
if attr =~ "=\s*[\"']"
|
||||
" Let do attribute specific completion
|
||||
let attrname = matchstr(attr, '.*\ze\s*=')
|
||||
let entered_value = matchstr(attr, ".*=\\s*[\"']\\zs.*")
|
||||
let values = []
|
||||
if attrname == 'media'
|
||||
let values = ["screen", "tty", "tv", "projection", "handheld", "print", "braille", "aural", "all"]
|
||||
elseif attrname == 'xml:space'
|
||||
let values = ["preserve"]
|
||||
elseif attrname == 'shape'
|
||||
if a:base =~ '^a\>'
|
||||
let values = ["rect"]
|
||||
else
|
||||
let values = ["rect", "circle", "poly", "default"]
|
||||
endif
|
||||
elseif attrname == 'valuetype'
|
||||
let values = ["data", "ref", "object"]
|
||||
elseif attrname == 'method'
|
||||
let values = ["get", "post"]
|
||||
elseif attrname == 'frame'
|
||||
let values = ["void", "above", "below", "hsides", "lhs", "rhs", "vsides", "box", "border"]
|
||||
elseif attrname == 'rules'
|
||||
let values = ["none", "groups", "rows", "all"]
|
||||
elseif attrname == 'align'
|
||||
let values = ["left", "center", "right", "justify", "char"]
|
||||
elseif attrname == 'valign'
|
||||
let values = ["top", "middle", "bottom", "baseline"]
|
||||
elseif attrname == 'scope'
|
||||
let values = ["row", "col", "rowgroup", "colgroup"]
|
||||
elseif attrname == 'href'
|
||||
" Now we are looking for local anchors defined by name or id
|
||||
if entered_value =~ '^#'
|
||||
let file = join(getline(1, line('$')), ' ')
|
||||
" Split it be sure there will be one id/name element in
|
||||
" item, it will be also first word [a-zA-Z0-9_-] in element
|
||||
let oneelement = split(file, "\\(meta \\)\\@<!\\(name\\|id\\)\\s*=\\s*[\"']")
|
||||
for i in oneelement
|
||||
let values += ['#'.matchstr(i, "^[a-zA-Z][a-zA-Z0-9%_-]*")]
|
||||
endfor
|
||||
endif
|
||||
elseif attrname == 'type'
|
||||
if a:base =~ '^input'
|
||||
let values = ["input-text", "password", "checkbox", "radio", "submit", "reset", "input-file", "hidden", "input-image", "input-button"]
|
||||
elseif a:base =~ '^button'
|
||||
let values = ["button", "submit", "reset"]
|
||||
endif
|
||||
else
|
||||
return []
|
||||
endif
|
||||
|
||||
if len(values) == 0
|
||||
return []
|
||||
endif
|
||||
|
||||
" We need special version of sbase
|
||||
let attrbase = matchstr(a:base, ".*[\"']")
|
||||
|
||||
for m in values
|
||||
if m =~ '^' . entered_value
|
||||
call add(res, attrbase . m . '" ')
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
" Shorten a:base to not include last word
|
||||
let sbase = matchstr(a:base, '.*\ze\s.*')
|
||||
if tag =~ '^\(abbr\|acronym\|b\|bdo\|big\|caption\|cite\|code\|dd\|dfn\|div\|dl\|dt\|em\|fieldset\|h\d\|kbd\|li\|noscript\|ol\|p\|samp\|small\|span\|strong\|sub\|sup\|tt\|ul\|var\)$'
|
||||
let attrs = g:coregroup
|
||||
elseif tag == 'a'
|
||||
let tagspec = ["charset", "type", "name", "href", "hreflang", "rel", "rev", "shape", "coords"]
|
||||
let attrs = extend(tagspec, g:coregroup)
|
||||
let attrs = extend(attrs, g:focus)
|
||||
elseif tag == 'area'
|
||||
let attrs = g:coregroup
|
||||
elseif tag == 'base'
|
||||
let attrs = ["href", "id"]
|
||||
elseif tag == 'blockquote'
|
||||
let attrs = g:coregroup
|
||||
let attrs = extend(attrs, ["cite"])
|
||||
elseif tag == 'body'
|
||||
let attrs = g:coregroup
|
||||
let attrs = extend(attrs, ["onload", "onunload"])
|
||||
elseif tag == 'br'
|
||||
let attrs = g:coreattrs
|
||||
elseif tag == 'button'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, g:focus)
|
||||
let attrs = extend(attrs, ["name", "value", "type"])
|
||||
elseif tag == '^\(col\|colgroup\)$'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["span", "width", "align", "char", "charoff", "valign"])
|
||||
elseif tag =~ '^\(del\|ins\)$'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["cite", "datetime"])
|
||||
elseif tag == 'form'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["action", "method", "enctype", "onsubmit", "onreset", "accept", "accept-charset"])
|
||||
elseif tag == 'head'
|
||||
let attrs = g:i18n
|
||||
let attrs = extend(attrs, ["id", "profile"])
|
||||
elseif tag == 'html'
|
||||
let attrs = g:i18n
|
||||
let attrs = extend(attrs, ["id", "xmlns"])
|
||||
elseif tag == 'img'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["src", "alt", "longdesc", "height", "width", "usemap", "ismap"])
|
||||
elseif tag == 'input'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, g:focus)
|
||||
let attrs = extend(attrs, ["type", "name", "value", "checked", "disabled", "readonly", "size", "maxlength", "src", "alt", "usemap", "onselect", "onchange", "accept"])
|
||||
elseif tag == 'label'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["for", "accesskey", "onfocus", "onblur"])
|
||||
elseif tag == 'legend'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["accesskey"])
|
||||
elseif tag == 'link'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["charset", "href", "hreflang", "type", "rel", "rev", "media"])
|
||||
elseif tag == 'map'
|
||||
let attrs = g:i18n
|
||||
let attrs = extend(attrs, g:events)
|
||||
let attrs = extend(attrs, ["id", "class", "style", "title", "name"])
|
||||
elseif tag == 'meta'
|
||||
let attrs = g:i18n
|
||||
let attrs = extend(attrs, ["id", "http-equiv", "content", "scheme", "name"])
|
||||
elseif tag == 'title'
|
||||
let attrs = g:i18n
|
||||
let attrs = extend(attrs, ["id"])
|
||||
elseif tag == 'object'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["declare", "classid", "codebase", "data", "type", "codetype", "archive", "standby", "height", "width", "usemap", "name", "tabindex"])
|
||||
elseif tag == 'optgroup'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["disbled", "label"])
|
||||
elseif tag == 'option'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["disbled", "selected", "value", "label"])
|
||||
elseif tag == 'param'
|
||||
let attrs = ["id", "name", "value", "valuetype", "type"]
|
||||
elseif tag == 'pre'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["xml:space"])
|
||||
elseif tag == 'q'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["cite"])
|
||||
elseif tag == 'script'
|
||||
let attrs = ["id", "charset", "type", "src", "defer", "xml:space"]
|
||||
elseif tag == 'select'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["name", "size", "multiple", "disabled", "tabindex", "onfocus", "onblur", "onchange"])
|
||||
elseif tag == 'style'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["id", "type", "media", "title", "xml:space"])
|
||||
elseif tag == 'table'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["summary", "width", "border", "frame", "rules" "cellspacing", "cellpadding"])
|
||||
elseif tag =~ '^\(thead\|tfoot\|tbody\|tr\)$'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["align", "char", "charoff", "valign"])
|
||||
elseif tag == 'textarea'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, g:focus)
|
||||
let attrs = extend(attrs, ["name", "rows", "cols", "disabled", "readonly", "onselect", "onchange"])
|
||||
elseif tag =~ '^\(th\|td\)$'
|
||||
let attrs = g:coreattrs
|
||||
let attrs = extend(attrs, ["abbr", "headers", "scope", "rowspan", "colspan", "align", "char", "charoff", "valign"])
|
||||
endif
|
||||
|
||||
for m in sort(attrs)
|
||||
if m =~ '^' . attr
|
||||
if m =~ '^\(ismap\|defer\|declare\|nohref\|checked\|disabled\|selected\|readonly\)$'
|
||||
call add(res, sbase.' '.m)
|
||||
else
|
||||
call add(res, sbase.' '.m.'="')
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return res
|
||||
endif
|
||||
for m in split("a abbr acronym address area b base bdo big blockquote body br button caption cite code col colgroup dd del dfn div dl dt em fieldset form head h1 h2 h3 h4 h5 h6 hr html i img input ins kbd label legend li link map meta noscript object ol optgroup option p param pre q samp script select small span strong style sub sup table tbody td textarea tfoot th thead title tr tt ul var")
|
||||
if m =~ '^' . a:base
|
||||
call add(res, m)
|
||||
endif
|
||||
endfor
|
||||
return res
|
||||
endif
|
||||
endfunction
|
||||
@ -1,7 +1,7 @@
|
||||
" netrw.vim: Handles file transfer and remote directory listing across a network
|
||||
" AUTOLOAD PORTION
|
||||
" Date: Sep 09, 2005
|
||||
" Version: 69
|
||||
" Date: Sep 12, 2005
|
||||
" Version: 70
|
||||
" Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
|
||||
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
|
||||
" Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
|
||||
@ -26,7 +26,7 @@ if v:version < 700
|
||||
echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None
|
||||
finish
|
||||
endif
|
||||
let g:loaded_netrw = "v69"
|
||||
let g:loaded_netrw = "v70"
|
||||
let s:keepcpo = &cpo
|
||||
set cpo&vim
|
||||
" call Decho("doing autoload/netrw.vim")
|
||||
@ -1143,7 +1143,7 @@ fun! s:NetBrowse(dirname)
|
||||
keepjumps 1d
|
||||
|
||||
" save certain window-oriented variables into buffer-oriented variables
|
||||
call s:BufWinVars()
|
||||
call s:SetBufWinVars()
|
||||
call s:NetOptionRestore()
|
||||
setlocal nomod
|
||||
|
||||
@ -2237,12 +2237,10 @@ endfun
|
||||
" ---------------------------------------------------------------------
|
||||
" NetObtain: obtain file under cursor (for remote browsing support) {{{2
|
||||
fun! s:NetObtain()
|
||||
if !exists("s:netrw_users_stl")
|
||||
let s:netrw_users_stl= &stl
|
||||
endif
|
||||
let fname= expand("<cWORD>")
|
||||
exe 'set stl=%f\ %h%m%r%=Obtaining\ '.escape(fname,' ')
|
||||
redraw!
|
||||
|
||||
" NetrwStatusLine support - for obtaining support
|
||||
call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.fname)
|
||||
|
||||
" call Dfunc("NetObtain() method=".w:netrw_method)
|
||||
if exists("w:netrw_method") && w:netrw_method =~ '[235]'
|
||||
@ -2320,6 +2318,8 @@ fun! s:NetObtain()
|
||||
echohl Error | echo "***netrw*** this system doesn't support ftp" | echohl None
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
endif
|
||||
let &stl = s:netrw_users_stl
|
||||
let &laststatus = s:netrw_users_ls
|
||||
" call Dret("NetObtain")
|
||||
return
|
||||
endif
|
||||
@ -2343,7 +2343,8 @@ fun! s:NetObtain()
|
||||
endif
|
||||
|
||||
" restore status line
|
||||
let &stl= s:netrw_users_stl
|
||||
let &stl = s:netrw_users_stl
|
||||
let &laststatus = s:netrw_users_ls
|
||||
redraw!
|
||||
|
||||
" call Dret("NetObtain")
|
||||
@ -2611,7 +2612,7 @@ fun! netrw#DirBrowse(dirname)
|
||||
let w:netrw_prvdir= b:netrw_curdir
|
||||
|
||||
" save certain window-oriented variables into buffer-oriented variables
|
||||
call s:BufWinVars()
|
||||
call s:SetBufWinVars()
|
||||
call s:NetOptionRestore()
|
||||
setlocal noma nomod nonu bh=hide nobl
|
||||
|
||||
@ -3042,12 +3043,8 @@ fun! netrw#Explore(indx,dosplit,style,...)
|
||||
endif
|
||||
endif
|
||||
|
||||
" NetrwStatusLine support
|
||||
" NetrwStatusLine support - for exploring support
|
||||
let w:netrw_explore_indx= indx
|
||||
if !exists("s:netrw_users_stl")
|
||||
let s:netrw_users_stl= &stl
|
||||
endif
|
||||
set stl=%f\ %h%m%r%=%{NetrwStatusLine()}
|
||||
" call Decho("explorelist<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen)
|
||||
|
||||
" sanity check
|
||||
@ -3060,15 +3057,21 @@ fun! netrw#Explore(indx,dosplit,style,...)
|
||||
endif
|
||||
|
||||
exe "let dirfile= w:netrw_explore_list[".indx."]"
|
||||
" call Decho("dirfile<".dirfile."> indx=".indx)
|
||||
" call Decho("dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">")
|
||||
let newdir= substitute(dirfile,'/[^/]*$','','e')
|
||||
" call Decho("newdir<".newdir.">")
|
||||
|
||||
" call Decho("calling LocalBrowse(newdir<".newdir.">)")
|
||||
call s:LocalBrowse(newdir)
|
||||
call search(substitute(dirfile,"^.*/","",""),"W")
|
||||
if w:netrw_longlist == 0 || w:netrw_longlist == 1
|
||||
call search('^'.substitute(dirfile,"^.*/","","").'\>',"W")
|
||||
else
|
||||
call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w")
|
||||
endif
|
||||
let w:netrw_explore_mtchcnt = indx + 1
|
||||
let w:netrw_explore_bufnr = bufnr(".")
|
||||
let w:netrw_explore_line = line(".")
|
||||
call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}')
|
||||
" call Decho("explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line)
|
||||
|
||||
else
|
||||
@ -3087,13 +3090,74 @@ fun! netrw#Explore(indx,dosplit,style,...)
|
||||
" call Dret("Explore")
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" SetupNetrwStatusLine: {{{2
|
||||
fun! s:SetupNetrwStatusLine(statline)
|
||||
" call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)")
|
||||
|
||||
if !exists("s:netrw_setup_statline")
|
||||
let s:netrw_setup_statline= 1
|
||||
" call Decho("do first-time status line setup")
|
||||
|
||||
if !exists("s:netrw_users_stl")
|
||||
let s:netrw_users_stl= &stl
|
||||
endif
|
||||
if !exists("s:netrw_users_ls")
|
||||
let s:netrw_users_ls= &laststatus
|
||||
endif
|
||||
|
||||
" set up User9 highlighting as needed
|
||||
let keepa= @a
|
||||
redir @a
|
||||
try
|
||||
hi User9
|
||||
catch /^Vim\%((\a\+)\)\=:E411/
|
||||
if &bg == "dark"
|
||||
hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue
|
||||
else
|
||||
hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue
|
||||
endif
|
||||
endtry
|
||||
redir END
|
||||
let @a= keepa
|
||||
endif
|
||||
|
||||
" set up status line (may use User9 highlighting)
|
||||
" insure that windows have a statusline
|
||||
" make sure statusline is displayed
|
||||
let &stl=a:statline
|
||||
set laststatus=2
|
||||
" call Decho("stl=".&stl)
|
||||
redraw!
|
||||
|
||||
" call Dret("SetupNetrwStatusLine : stl=".&stl)
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" NetrwStatusLine: {{{2
|
||||
fun! NetrwStatusLine()
|
||||
" let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr(".")." Xline#".w:netrw_explore_line." line#".line(".")
|
||||
|
||||
" vvv NetrwStatusLine() debugging vvv
|
||||
" let g:stlmsg=""
|
||||
" if !exists("w:netrw_explore_bufnr")
|
||||
" let g:stlmsg="!X<explore_bufnr>"
|
||||
" elseif w:netrw_explore_bufnr != bufnr(".")
|
||||
" let g:stlmsg="explore_bufnr!=".bufnr(".")
|
||||
" endif
|
||||
" if !exists("w:netrw_explore_line")
|
||||
" let g:stlmsg=" !X<explore_line>"
|
||||
" elseif w:netrw_explore_line != line(".")
|
||||
" let g:stlmsg=" explore_line!={line(.)<".line(".").">"
|
||||
" endif
|
||||
" if !exists("w:netrw_explore_list")
|
||||
" let g:stlmsg=" !X<explore_list>"
|
||||
" endif
|
||||
" ^^^ NetrwStatusLine() debugging ^^^
|
||||
|
||||
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")
|
||||
" restore user's status line
|
||||
let &stl= s:netrw_users_stl
|
||||
let &stl = s:netrw_users_stl
|
||||
let &laststatus = s:netrw_users_ls
|
||||
if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
|
||||
if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif
|
||||
return ""
|
||||
@ -3591,14 +3655,14 @@ fun! s:CopyWinVars()
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" BufWinVars: (used by NetBrowse() and LocalBrowse()) {{{1
|
||||
" SetBufWinVars: (used by NetBrowse() and LocalBrowse()) {{{1
|
||||
" To allow separate windows to have their own activities, such as
|
||||
" Explore **/pattern, several variables have been made window-oriented.
|
||||
" However, when the user splits a browser window (ex: ctrl-w s), these
|
||||
" variables are not inherited by the new window. BufWinVars() and
|
||||
" variables are not inherited by the new window. SetBufWinVars() and
|
||||
" UseBufWinVars() get around that.
|
||||
fun! s:BufWinVars()
|
||||
" call Dfunc("BufWinVars()")
|
||||
fun! s:SetBufWinVars()
|
||||
" call Dfunc("SetBufWinVars()")
|
||||
if exists("w:netrw_longlist") |let b:netrw_longlist = w:netrw_longlist |endif
|
||||
if exists("w:netrw_bannercnt") |let b:netrw_bannercnt = w:netrw_bannercnt |endif
|
||||
if exists("w:netrw_method") |let b:netrw_method = w:netrw_method |endif
|
||||
@ -3609,7 +3673,7 @@ fun! s:BufWinVars()
|
||||
if exists("w:netrw_explore_bufnr") |let b:netrw_explore_bufnr = w:netrw_explore_bufnr |endif
|
||||
if exists("w:netrw_explore_line") |let b:netrw_explore_line = w:netrw_explore_line |endif
|
||||
if exists("w:netrw_explore_list") |let b:netrw_explore_list = w:netrw_explore_list |endif
|
||||
" call Dret("BufWinVars")
|
||||
" call Dret("SetBufWinVars")
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user