updated for version 7.1a
This commit is contained in:
109
runtime/autoload/adacomplete.vim
Normal file
109
runtime/autoload/adacomplete.vim
Normal file
@ -0,0 +1,109 @@
|
||||
"------------------------------------------------------------------------------
|
||||
" Description: Vim Ada omnicompletion file
|
||||
" Language: Ada (2005)
|
||||
" $Id$
|
||||
" Maintainer: Martin Krischik
|
||||
" $Author$
|
||||
" $Date$
|
||||
" Version: 4.2
|
||||
" $Revision$
|
||||
" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/adacomplete.vim $
|
||||
" History: 24.05.2006 MK Unified Headers
|
||||
" 26.05.2006 MK improved search for begin of word.
|
||||
" 16.07.2006 MK Ada-Mode as vim-ball
|
||||
" 15.10.2006 MK Bram's suggestion for runtime integration
|
||||
" 05.11.2006 MK Bram suggested not to use include protection for
|
||||
" autoload
|
||||
" 05.11.2006 MK Bram suggested agaist using setlocal omnifunc
|
||||
" 05.11.2006 MK Bram suggested to save on spaces
|
||||
" Help Page: ft-ada-omni
|
||||
"------------------------------------------------------------------------------
|
||||
|
||||
if version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
" Section: adacomplete#Complete () {{{1
|
||||
"
|
||||
" This function is used for the 'omnifunc' option.
|
||||
"
|
||||
function! adacomplete#Complete (findstart, base)
|
||||
if a:findstart == 1
|
||||
return ada#User_Complete (a:findstart, a:base)
|
||||
else
|
||||
"
|
||||
" look up matches
|
||||
"
|
||||
if exists ("g:ada_omni_with_keywords")
|
||||
call ada#User_Complete (a:findstart, a:base)
|
||||
endif
|
||||
"
|
||||
" search tag file for matches
|
||||
"
|
||||
let l:Pattern = '^' . a:base . '.*$'
|
||||
let l:Tag_List = taglist (l:Pattern)
|
||||
"
|
||||
" add symbols
|
||||
"
|
||||
for Tag_Item in l:Tag_List
|
||||
if l:Tag_Item['kind'] == ''
|
||||
"
|
||||
" Tag created by gnat xref
|
||||
"
|
||||
let l:Match_Item = {
|
||||
\ 'word': l:Tag_Item['name'],
|
||||
\ 'menu': l:Tag_Item['filename'],
|
||||
\ 'info': "Symbol from file " . l:Tag_Item['filename'] . " line " . l:Tag_Item['cmd'],
|
||||
\ 'kind': 's',
|
||||
\ 'icase': 1}
|
||||
else
|
||||
"
|
||||
" Tag created by ctags
|
||||
"
|
||||
let l:Info = 'Symbol : ' . l:Tag_Item['name'] . "\n"
|
||||
let l:Info .= 'Of type : ' . g:ada#Ctags_Kinds[l:Tag_Item['kind']][1] . "\n"
|
||||
let l:Info .= 'Defined in File : ' . l:Tag_Item['filename'] . "\n"
|
||||
|
||||
if has_key( l:Tag_Item, 'package')
|
||||
let l:Info .= 'Package : ' . l:Tag_Item['package'] . "\n"
|
||||
let l:Menu = l:Tag_Item['package']
|
||||
elseif has_key( l:Tag_Item, 'separate')
|
||||
let l:Info .= 'Separate from Package : ' . l:Tag_Item['separate'] . "\n"
|
||||
let l:Menu = l:Tag_Item['separate']
|
||||
elseif has_key( l:Tag_Item, 'packspec')
|
||||
let l:Info .= 'Package Specification : ' . l:Tag_Item['packspec'] . "\n"
|
||||
let l:Menu = l:Tag_Item['packspec']
|
||||
elseif has_key( l:Tag_Item, 'type')
|
||||
let l:Info .= 'Datetype : ' . l:Tag_Item['type'] . "\n"
|
||||
let l:Menu = l:Tag_Item['type']
|
||||
else
|
||||
let l:Menu = l:Tag_Item['filename']
|
||||
endif
|
||||
|
||||
let l:Match_Item = {
|
||||
\ 'word': l:Tag_Item['name'],
|
||||
\ 'menu': l:Menu,
|
||||
\ 'info': l:Info,
|
||||
\ 'kind': l:Tag_Item['kind'],
|
||||
\ 'icase': 1}
|
||||
endif
|
||||
if complete_add (l:Match_Item) == 0
|
||||
return []
|
||||
endif
|
||||
if complete_check ()
|
||||
return []
|
||||
endif
|
||||
endfor
|
||||
return []
|
||||
endif
|
||||
endfunction adacomplete#Complete
|
||||
|
||||
finish " 1}}}
|
||||
|
||||
"------------------------------------------------------------------------------
|
||||
" Copyright (C) 2006 Martin Krischik
|
||||
"
|
||||
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
||||
"------------------------------------------------------------------------------
|
||||
" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
||||
" vim: foldmethod=marker
|
||||
@ -1,430 +1,430 @@
|
||||
" Vim completion script
|
||||
" Language: CSS 2.1
|
||||
" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
|
||||
" Last Change: 2006 Apr 30
|
||||
" Last Change: 2007 Mar 11
|
||||
|
||||
function! csscomplete#CompleteCSS(findstart, base)
|
||||
|
||||
if a:findstart
|
||||
" We need whole line to proper checking
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
let compl_begin = col('.') - 2
|
||||
while start >= 0 && line[start - 1] =~ '\(\k\|-\)'
|
||||
while start >= 0 && line[start - 1] =~ '\%(\k\|-\)'
|
||||
let start -= 1
|
||||
endwhile
|
||||
let b:compl_context = getline('.')[0:compl_begin]
|
||||
return start
|
||||
endif
|
||||
|
||||
" There are few chars important for context:
|
||||
" ^ ; : { } /* */
|
||||
" Where ^ is start of line and /* */ are comment borders
|
||||
" Depending on their relative position to cursor we will know what should
|
||||
" be completed.
|
||||
" 1. if nearest are ^ or { or ; current word is property
|
||||
" 2. if : it is value (with exception of pseudo things)
|
||||
" 3. if } we are outside of css definitions
|
||||
" 4. for comments ignoring is be the easiest but assume they are the same
|
||||
" as 1.
|
||||
" 5. if @ complete at-rule
|
||||
" 6. if ! complete important
|
||||
if exists("b:compl_context")
|
||||
let line = b:compl_context
|
||||
unlet! b:compl_context
|
||||
else
|
||||
" There are few chars important for context:
|
||||
" ^ ; : { } /* */
|
||||
" Where ^ is start of line and /* */ are comment borders
|
||||
" Depending on their relative position to cursor we will now what should
|
||||
" be completed.
|
||||
" 1. if nearest are ^ or { or ; current word is property
|
||||
" 2. if : it is value (with exception of pseudo things)
|
||||
" 3. if } we are outside of css definitions
|
||||
" 4. for comments ignoring is be the easiest but assume they are the same
|
||||
" as 1.
|
||||
" 5. if @ complete at-rule
|
||||
" 6. if ! complete important
|
||||
if exists("b:compl_context")
|
||||
let line = b:compl_context
|
||||
unlet! b:compl_context
|
||||
else
|
||||
let line = a:base
|
||||
endif
|
||||
let line = a:base
|
||||
endif
|
||||
|
||||
let res = []
|
||||
let res2 = []
|
||||
let borders = {}
|
||||
let res = []
|
||||
let res2 = []
|
||||
let borders = {}
|
||||
|
||||
" We need the last occurrence of char so reverse line
|
||||
let revline = join(reverse(split(line, '.\zs')), '')
|
||||
" Check last occurrence of sequence
|
||||
|
||||
let openbrace = stridx(revline, '{')
|
||||
let closebrace = stridx(revline, '}')
|
||||
let colon = stridx(revline, ':')
|
||||
let semicolon = stridx(revline, ';')
|
||||
let opencomm = stridx(revline, '*/') " Line was reversed
|
||||
let closecomm = stridx(revline, '/*') " Line was reversed
|
||||
let style = stridx(revline, '=\s*elyts') " Line was reversed
|
||||
let atrule = stridx(revline, '@')
|
||||
let exclam = stridx(revline, '!')
|
||||
let openbrace = strridx(line, '{')
|
||||
let closebrace = strridx(line, '}')
|
||||
let colon = strridx(line, ':')
|
||||
let semicolon = strridx(line, ';')
|
||||
let opencomm = strridx(line, '/*')
|
||||
let closecomm = strridx(line, '*/')
|
||||
let style = strridx(line, 'style\s*=')
|
||||
let atrule = strridx(line, '@')
|
||||
let exclam = strridx(line, '!')
|
||||
|
||||
if openbrace > -1
|
||||
let borders[openbrace] = "openbrace"
|
||||
endif
|
||||
if closebrace > -1
|
||||
let borders[closebrace] = "closebrace"
|
||||
endif
|
||||
if colon > -1
|
||||
let borders[colon] = "colon"
|
||||
endif
|
||||
if semicolon > -1
|
||||
let borders[semicolon] = "semicolon"
|
||||
endif
|
||||
if opencomm > -1
|
||||
let borders[opencomm] = "opencomm"
|
||||
endif
|
||||
if closecomm > -1
|
||||
let borders[closecomm] = "closecomm"
|
||||
endif
|
||||
if style > -1
|
||||
let borders[style] = "style"
|
||||
endif
|
||||
if atrule > -1
|
||||
let borders[atrule] = "atrule"
|
||||
endif
|
||||
if exclam > -1
|
||||
let borders[exclam] = "exclam"
|
||||
endif
|
||||
if openbrace > -1
|
||||
let borders[openbrace] = "openbrace"
|
||||
endif
|
||||
if closebrace > -1
|
||||
let borders[closebrace] = "closebrace"
|
||||
endif
|
||||
if colon > -1
|
||||
let borders[colon] = "colon"
|
||||
endif
|
||||
if semicolon > -1
|
||||
let borders[semicolon] = "semicolon"
|
||||
endif
|
||||
if opencomm > -1
|
||||
let borders[opencomm] = "opencomm"
|
||||
endif
|
||||
if closecomm > -1
|
||||
let borders[closecomm] = "closecomm"
|
||||
endif
|
||||
if style > -1
|
||||
let borders[style] = "style"
|
||||
endif
|
||||
if atrule > -1
|
||||
let borders[atrule] = "atrule"
|
||||
endif
|
||||
if exclam > -1
|
||||
let borders[exclam] = "exclam"
|
||||
endif
|
||||
|
||||
|
||||
if len(borders) == 0 || borders[min(keys(borders))] =~ '^\(openbrace\|semicolon\|opencomm\|closecomm\|style\)$'
|
||||
" Complete properties
|
||||
if len(borders) == 0 || borders[max(keys(borders))] =~ '^\%(openbrace\|semicolon\|opencomm\|closecomm\|style\)$'
|
||||
" Complete properties
|
||||
|
||||
let values = split("azimuth background background-attachment background-color background-image background-position background-repeat border bottom border-collapse border-color border-spacing border-style border-top border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width border-bottom-width border-left-width border-width caption-side clear clip color content counter-increment counter-reset cue cue-after cue-before cursor display direction elevation empty-cells float font font-family font-size font-style font-variant font-weight height left letter-spacing line-height list-style list-style-image list-style-position list-style-type margin margin-right margin-left margin-top margin-bottom max-height max-width min-height min-width orphans outline outline-color outline-style outline-width overflow padding padding-top padding-right padding-bottom padding-left page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position quotes right richness speak speak-header speak-numeral speak-punctuation speech-rate stress table-layout text-align text-decoration text-indent text-transform top unicode-bidi vertical-align visibility voice-family volume white-space width widows word-spacing z-index")
|
||||
let values = split("azimuth background background-attachment background-color background-image background-position background-repeat border bottom border-collapse border-color border-spacing border-style border-top border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width border-bottom-width border-left-width border-width caption-side clear clip color content counter-increment counter-reset cue cue-after cue-before cursor display direction elevation empty-cells float font font-family font-size font-style font-variant font-weight height left letter-spacing line-height list-style list-style-image list-style-position list-style-type margin margin-right margin-left margin-top margin-bottom max-height max-width min-height min-width orphans outline outline-color outline-style outline-width overflow padding padding-top padding-right padding-bottom padding-left page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position quotes right richness speak speak-header speak-numeral speak-punctuation speech-rate stress table-layout text-align text-decoration text-indent text-transform top unicode-bidi vertical-align visibility voice-family volume white-space width widows word-spacing z-index")
|
||||
|
||||
let entered_property = matchstr(line, '.\{-}\zs[a-zA-Z-]*$')
|
||||
let entered_property = matchstr(line, '.\{-}\zs[a-zA-Z-]*$')
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_property
|
||||
call add(res, m . ':')
|
||||
elseif m =~? entered_property
|
||||
call add(res2, m . ':')
|
||||
endif
|
||||
endfor
|
||||
for m in values
|
||||
if m =~? '^'.entered_property
|
||||
call add(res, m . ':')
|
||||
elseif m =~? entered_property
|
||||
call add(res2, m . ':')
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
return res + res2
|
||||
|
||||
elseif borders[min(keys(borders))] == 'colon'
|
||||
" Get name of property
|
||||
let prop = tolower(matchstr(line, '\zs[a-zA-Z-]*\ze\s*:[^:]\{-}$'))
|
||||
elseif borders[max(keys(borders))] == 'colon'
|
||||
" Get name of property
|
||||
let prop = tolower(matchstr(line, '\zs[a-zA-Z-]*\ze\s*:[^:]\{-}$'))
|
||||
|
||||
if prop == 'azimuth'
|
||||
let values = ["left-side", "far-left", "left", "center-left", "center", "center-right", "right", "far-right", "right-side", "behind", "leftwards", "rightwards"]
|
||||
elseif prop == 'background-attachment'
|
||||
let values = ["scroll", "fixed"]
|
||||
elseif prop == 'background-color'
|
||||
let values = ["transparent", "rgb(", "#"]
|
||||
elseif prop == 'background-image'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'background-position'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\([a-zA-Z]\+\)\?$'
|
||||
let values = ["top", "center", "bottom"]
|
||||
elseif vals =~ '^[a-zA-Z]\+\s\+\([a-zA-Z]\+\)\?$'
|
||||
let values = ["left", "center", "right"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'background-repeat'
|
||||
let values = ["repeat", "repeat-x", "repeat-y", "no-repeat"]
|
||||
elseif prop == 'background'
|
||||
let values = ["url(", "scroll", "fixed", "transparent", "rgb(", "#", "none", "top", "center", "bottom" , "left", "right", "repeat", "repeat-x", "repeat-y", "no-repeat"]
|
||||
elseif prop == 'border-collapse'
|
||||
let values = ["collapse", "separate"]
|
||||
elseif prop == 'border-color'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
elseif prop == 'border-spacing'
|
||||
return []
|
||||
elseif prop == 'border-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop =~ 'border-\(top\|right\|bottom\|left\)$'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\([a-zA-Z0-9.]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\([a-zA-Z(]\+\)\?$'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop =~ 'border-\(top\|right\|bottom\|left\)-color'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
elseif prop =~ 'border-\(top\|right\|bottom\|left\)-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop =~ 'border-\(top\|right\|bottom\|left\)-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'border-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'border'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\([a-zA-Z0-9.]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\([a-zA-Z(]\+\)\?$'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'bottom'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'caption-side'
|
||||
let values = ["top", "bottom"]
|
||||
elseif prop == 'clear'
|
||||
let values = ["none", "left", "right", "both"]
|
||||
elseif prop == 'clip'
|
||||
let values = ["auto", "rect("]
|
||||
elseif prop == 'color'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif prop == 'content'
|
||||
let values = ["normal", "attr(", "open-quote", "close-quote", "no-open-quote", "no-close-quote"]
|
||||
elseif prop =~ 'counter-\(increment\|reset\)$'
|
||||
let values = ["none"]
|
||||
elseif prop =~ '^\(cue-after\|cue-before\|cue\)$'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'cursor'
|
||||
let values = ["url(", "auto", "crosshair", "default", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help", "progress"]
|
||||
elseif prop == 'direction'
|
||||
let values = ["ltr", "rtl"]
|
||||
elseif prop == 'display'
|
||||
let values = ["inline", "block", "list-item", "run-in", "inline-block", "table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", "table-row", "table-column-group", "table-column", "table-cell", "table-caption", "none"]
|
||||
elseif prop == 'elevation'
|
||||
let values = ["below", "level", "above", "higher", "lower"]
|
||||
elseif prop == 'empty-cells'
|
||||
let values = ["show", "hide"]
|
||||
elseif prop == 'float'
|
||||
let values = ["left", "right", "none"]
|
||||
elseif prop == 'font-family'
|
||||
let values = ["sans-serif", "serif", "monospace", "cursive", "fantasy"]
|
||||
elseif prop == 'font-size'
|
||||
let values = ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller"]
|
||||
elseif prop == 'font-style'
|
||||
let values = ["normal", "italic", "oblique"]
|
||||
elseif prop == 'font-variant'
|
||||
let values = ["normal", "small-caps"]
|
||||
elseif prop == 'font-weight'
|
||||
let values = ["normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"]
|
||||
elseif prop == 'font'
|
||||
let values = ["normal", "italic", "oblique", "small-caps", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900", "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller", "sans-serif", "serif", "monospace", "cursive", "fantasy", "caption", "icon", "menu", "message-box", "small-caption", "status-bar"]
|
||||
elseif prop =~ '^\(height\|width\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop =~ '^\(left\|rigth\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'letter-spacing'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'line-height'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'list-style-image'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'list-style-position'
|
||||
let values = ["inside", "outside"]
|
||||
elseif prop == 'list-style-type'
|
||||
let values = ["disc", "circle", "square", "decimal", "decimal-leading-zero", "lower-roman", "upper-roman", "lower-latin", "upper-latin", "none"]
|
||||
elseif prop == 'list-style'
|
||||
return []
|
||||
elseif prop == 'margin'
|
||||
let values = ["auto"]
|
||||
elseif prop =~ 'margin-\(right\|left\|top\|bottom\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'max-height'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'max-width'
|
||||
let values = ["none"]
|
||||
elseif prop == 'min-height'
|
||||
let values = ["none"]
|
||||
elseif prop == 'min-width'
|
||||
let values = ["none"]
|
||||
elseif prop == 'orphans'
|
||||
return []
|
||||
elseif prop == 'outline-color'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif prop == 'outline-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop == 'outline-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'outline'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\([a-zA-Z0-9,()#]\+\)\?$'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+\([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+[a-zA-Z]\+\s\+\([a-zA-Z(]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'overflow'
|
||||
let values = ["visible", "hidden", "scroll", "auto"]
|
||||
elseif prop == 'padding'
|
||||
return []
|
||||
elseif prop =~ 'padding-\(top\|right\|bottom\|left\)$'
|
||||
return []
|
||||
elseif prop =~ 'page-break-\(after\|before\)$'
|
||||
let values = ["auto", "always", "avoid", "left", "right"]
|
||||
elseif prop == 'page-break-inside'
|
||||
let values = ["auto", "avoid"]
|
||||
elseif prop =~ 'pause-\(after\|before\)$'
|
||||
return []
|
||||
elseif prop == 'pause'
|
||||
return []
|
||||
elseif prop == 'pitch-range'
|
||||
return []
|
||||
elseif prop == 'pitch'
|
||||
let values = ["x-low", "low", "medium", "high", "x-high"]
|
||||
elseif prop == 'play-during'
|
||||
let values = ["url(", "mix", "repeat", "auto", "none"]
|
||||
elseif prop == 'position'
|
||||
let values = ["static", "relative", "absolute", "fixed"]
|
||||
elseif prop == 'quotes'
|
||||
let values = ["none"]
|
||||
elseif prop == 'richness'
|
||||
return []
|
||||
elseif prop == 'speak-header'
|
||||
let values = ["once", "always"]
|
||||
elseif prop == 'speak-numeral'
|
||||
let values = ["digits", "continuous"]
|
||||
elseif prop == 'speak-punctuation'
|
||||
let values = ["code", "none"]
|
||||
elseif prop == 'speak'
|
||||
let values = ["normal", "none", "spell-out"]
|
||||
elseif prop == 'speech-rate'
|
||||
let values = ["x-slow", "slow", "medium", "fast", "x-fast", "faster", "slower"]
|
||||
elseif prop == 'stress'
|
||||
return []
|
||||
elseif prop == 'table-layout'
|
||||
let values = ["auto", "fixed"]
|
||||
elseif prop == 'text-align'
|
||||
let values = ["left", "right", "center", "justify"]
|
||||
elseif prop == 'text-decoration'
|
||||
let values = ["none", "underline", "overline", "line-through", "blink"]
|
||||
elseif prop == 'text-indent'
|
||||
return []
|
||||
elseif prop == 'text-transform'
|
||||
let values = ["capitalize", "uppercase", "lowercase", "none"]
|
||||
elseif prop == 'top'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'unicode-bidi'
|
||||
let values = ["normal", "embed", "bidi-override"]
|
||||
elseif prop == 'vertical-align'
|
||||
let values = ["baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom"]
|
||||
elseif prop == 'visibility'
|
||||
let values = ["visible", "hidden", "collapse"]
|
||||
elseif prop == 'voice-family'
|
||||
return []
|
||||
elseif prop == 'volume'
|
||||
let values = ["silent", "x-soft", "soft", "medium", "loud", "x-loud"]
|
||||
elseif prop == 'white-space'
|
||||
let values = ["normal", "pre", "nowrap", "pre-wrap", "pre-line"]
|
||||
elseif prop == 'widows'
|
||||
return []
|
||||
elseif prop == 'word-spacing'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'z-index'
|
||||
let values = ["auto"]
|
||||
if prop == 'azimuth'
|
||||
let values = ["left-side", "far-left", "left", "center-left", "center", "center-right", "right", "far-right", "right-side", "behind", "leftwards", "rightwards"]
|
||||
elseif prop == 'background-attachment'
|
||||
let values = ["scroll", "fixed"]
|
||||
elseif prop == 'background-color'
|
||||
let values = ["transparent", "rgb(", "#"]
|
||||
elseif prop == 'background-image'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'background-position'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["top", "center", "bottom"]
|
||||
elseif vals =~ '^[a-zA-Z]\+\s\+\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["left", "center", "right"]
|
||||
else
|
||||
" If no property match it is possible we are outside of {} and
|
||||
" trying to complete pseudo-(class|element)
|
||||
let element = tolower(matchstr(line, '\zs[a-zA-Z1-6]*\ze:[^:[:space:]]\{-}$'))
|
||||
if ",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," =~ ','.element.','
|
||||
let values = ["first-child", "link", "visited", "hover", "active", "focus", "lang", "first-line", "first-letter", "before", "after"]
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'background-repeat'
|
||||
let values = ["repeat", "repeat-x", "repeat-y", "no-repeat"]
|
||||
elseif prop == 'background'
|
||||
let values = ["url(", "scroll", "fixed", "transparent", "rgb(", "#", "none", "top", "center", "bottom" , "left", "right", "repeat", "repeat-x", "repeat-y", "no-repeat"]
|
||||
elseif prop == 'border-collapse'
|
||||
let values = ["collapse", "separate"]
|
||||
elseif prop == 'border-color'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
elseif prop == 'border-spacing'
|
||||
return []
|
||||
elseif prop == 'border-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop =~ 'border-\%(top\|right\|bottom\|left\)$'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\%([a-zA-Z0-9.]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop =~ 'border-\%(top\|right\|bottom\|left\)-color'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
elseif prop =~ 'border-\%(top\|right\|bottom\|left\)-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop =~ 'border-\%(top\|right\|bottom\|left\)-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'border-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'border'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\%([a-zA-Z0-9.]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'bottom'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'caption-side'
|
||||
let values = ["top", "bottom"]
|
||||
elseif prop == 'clear'
|
||||
let values = ["none", "left", "right", "both"]
|
||||
elseif prop == 'clip'
|
||||
let values = ["auto", "rect("]
|
||||
elseif prop == 'color'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif prop == 'content'
|
||||
let values = ["normal", "attr(", "open-quote", "close-quote", "no-open-quote", "no-close-quote"]
|
||||
elseif prop =~ 'counter-\%(increment\|reset\)$'
|
||||
let values = ["none"]
|
||||
elseif prop =~ '^\%(cue-after\|cue-before\|cue\)$'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'cursor'
|
||||
let values = ["url(", "auto", "crosshair", "default", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help", "progress"]
|
||||
elseif prop == 'direction'
|
||||
let values = ["ltr", "rtl"]
|
||||
elseif prop == 'display'
|
||||
let values = ["inline", "block", "list-item", "run-in", "inline-block", "table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", "table-row", "table-column-group", "table-column", "table-cell", "table-caption", "none"]
|
||||
elseif prop == 'elevation'
|
||||
let values = ["below", "level", "above", "higher", "lower"]
|
||||
elseif prop == 'empty-cells'
|
||||
let values = ["show", "hide"]
|
||||
elseif prop == 'float'
|
||||
let values = ["left", "right", "none"]
|
||||
elseif prop == 'font-family'
|
||||
let values = ["sans-serif", "serif", "monospace", "cursive", "fantasy"]
|
||||
elseif prop == 'font-size'
|
||||
let values = ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller"]
|
||||
elseif prop == 'font-style'
|
||||
let values = ["normal", "italic", "oblique"]
|
||||
elseif prop == 'font-variant'
|
||||
let values = ["normal", "small-caps"]
|
||||
elseif prop == 'font-weight'
|
||||
let values = ["normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"]
|
||||
elseif prop == 'font'
|
||||
let values = ["normal", "italic", "oblique", "small-caps", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900", "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller", "sans-serif", "serif", "monospace", "cursive", "fantasy", "caption", "icon", "menu", "message-box", "small-caption", "status-bar"]
|
||||
elseif prop =~ '^\%(height\|width\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop =~ '^\%(left\|rigth\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'letter-spacing'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'line-height'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'list-style-image'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'list-style-position'
|
||||
let values = ["inside", "outside"]
|
||||
elseif prop == 'list-style-type'
|
||||
let values = ["disc", "circle", "square", "decimal", "decimal-leading-zero", "lower-roman", "upper-roman", "lower-latin", "upper-latin", "none"]
|
||||
elseif prop == 'list-style'
|
||||
return []
|
||||
elseif prop == 'margin'
|
||||
let values = ["auto"]
|
||||
elseif prop =~ 'margin-\%(right\|left\|top\|bottom\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'max-height'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'max-width'
|
||||
let values = ["none"]
|
||||
elseif prop == 'min-height'
|
||||
let values = ["none"]
|
||||
elseif prop == 'min-width'
|
||||
let values = ["none"]
|
||||
elseif prop == 'orphans'
|
||||
return []
|
||||
elseif prop == 'outline-color'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif prop == 'outline-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop == 'outline-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'outline'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\%([a-zA-Z0-9,()#]\+\)\?$'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'overflow'
|
||||
let values = ["visible", "hidden", "scroll", "auto"]
|
||||
elseif prop == 'padding'
|
||||
return []
|
||||
elseif prop =~ 'padding-\%(top\|right\|bottom\|left\)$'
|
||||
return []
|
||||
elseif prop =~ 'page-break-\%(after\|before\)$'
|
||||
let values = ["auto", "always", "avoid", "left", "right"]
|
||||
elseif prop == 'page-break-inside'
|
||||
let values = ["auto", "avoid"]
|
||||
elseif prop =~ 'pause-\%(after\|before\)$'
|
||||
return []
|
||||
elseif prop == 'pause'
|
||||
return []
|
||||
elseif prop == 'pitch-range'
|
||||
return []
|
||||
elseif prop == 'pitch'
|
||||
let values = ["x-low", "low", "medium", "high", "x-high"]
|
||||
elseif prop == 'play-during'
|
||||
let values = ["url(", "mix", "repeat", "auto", "none"]
|
||||
elseif prop == 'position'
|
||||
let values = ["static", "relative", "absolute", "fixed"]
|
||||
elseif prop == 'quotes'
|
||||
let values = ["none"]
|
||||
elseif prop == 'richness'
|
||||
return []
|
||||
elseif prop == 'speak-header'
|
||||
let values = ["once", "always"]
|
||||
elseif prop == 'speak-numeral'
|
||||
let values = ["digits", "continuous"]
|
||||
elseif prop == 'speak-punctuation'
|
||||
let values = ["code", "none"]
|
||||
elseif prop == 'speak'
|
||||
let values = ["normal", "none", "spell-out"]
|
||||
elseif prop == 'speech-rate'
|
||||
let values = ["x-slow", "slow", "medium", "fast", "x-fast", "faster", "slower"]
|
||||
elseif prop == 'stress'
|
||||
return []
|
||||
elseif prop == 'table-layout'
|
||||
let values = ["auto", "fixed"]
|
||||
elseif prop == 'text-align'
|
||||
let values = ["left", "right", "center", "justify"]
|
||||
elseif prop == 'text-decoration'
|
||||
let values = ["none", "underline", "overline", "line-through", "blink"]
|
||||
elseif prop == 'text-indent'
|
||||
return []
|
||||
elseif prop == 'text-transform'
|
||||
let values = ["capitalize", "uppercase", "lowercase", "none"]
|
||||
elseif prop == 'top'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'unicode-bidi'
|
||||
let values = ["normal", "embed", "bidi-override"]
|
||||
elseif prop == 'vertical-align'
|
||||
let values = ["baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom"]
|
||||
elseif prop == 'visibility'
|
||||
let values = ["visible", "hidden", "collapse"]
|
||||
elseif prop == 'voice-family'
|
||||
return []
|
||||
elseif prop == 'volume'
|
||||
let values = ["silent", "x-soft", "soft", "medium", "loud", "x-loud"]
|
||||
elseif prop == 'white-space'
|
||||
let values = ["normal", "pre", "nowrap", "pre-wrap", "pre-line"]
|
||||
elseif prop == 'widows'
|
||||
return []
|
||||
elseif prop == 'word-spacing'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'z-index'
|
||||
let values = ["auto"]
|
||||
else
|
||||
" If no property match it is possible we are outside of {} and
|
||||
" trying to complete pseudo-(class|element)
|
||||
let element = tolower(matchstr(line, '\zs[a-zA-Z1-6]*\ze:[^:[:space:]]\{-}$'))
|
||||
if stridx(',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,', ','.element.',') > -1
|
||||
let values = ["first-child", "link", "visited", "hover", "active", "focus", "lang", "first-line", "first-letter", "before", "after"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" Complete values
|
||||
let entered_value = matchstr(line, '.\{-}\zs[a-zA-Z0-9#,.(_-]*$')
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_value
|
||||
call add(res, m)
|
||||
elseif m =~? entered_value
|
||||
call add(res2, m)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
|
||||
elseif borders[max(keys(borders))] == 'closebrace'
|
||||
|
||||
return []
|
||||
|
||||
elseif borders[max(keys(borders))] == 'exclam'
|
||||
|
||||
" Complete values
|
||||
let entered_imp = matchstr(line, '.\{-}!\s*\zs[a-zA-Z ]*$')
|
||||
|
||||
let values = ["important"]
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_imp
|
||||
call add(res, m)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res
|
||||
|
||||
elseif borders[max(keys(borders))] == 'atrule'
|
||||
|
||||
let afterat = matchstr(line, '.*@\zs.*')
|
||||
|
||||
if afterat =~ '\s'
|
||||
|
||||
let atrulename = matchstr(line, '.*@\zs[a-zA-Z-]\+\ze')
|
||||
|
||||
if atrulename == 'media'
|
||||
let values = ["screen", "tty", "tv", "projection", "handheld", "print", "braille", "aural", "all"]
|
||||
|
||||
let atruleafterbase = matchstr(line, '.*@media\s\+\ze.*$')
|
||||
let entered_atruleafter = matchstr(line, '.*@media\s\+\zs.*$')
|
||||
|
||||
elseif atrulename == 'import'
|
||||
let atruleafterbase = matchstr(line, '.*@import\s\+\ze.*$')
|
||||
let entered_atruleafter = matchstr(line, '.*@import\s\+\zs.*$')
|
||||
|
||||
if entered_atruleafter =~ "^[\"']"
|
||||
let filestart = matchstr(entered_atruleafter, '^.\zs.*')
|
||||
let files = split(glob(filestart.'*'), '\n')
|
||||
let values = map(copy(files), '"\"".v:val')
|
||||
|
||||
elseif entered_atruleafter =~ "^url("
|
||||
let filestart = matchstr(entered_atruleafter, "^url([\"']\\?\\zs.*")
|
||||
let files = split(glob(filestart.'*'), '\n')
|
||||
let values = map(copy(files), '"url(".v:val')
|
||||
|
||||
else
|
||||
return []
|
||||
let values = ['"', 'url(']
|
||||
|
||||
endif
|
||||
|
||||
else
|
||||
return []
|
||||
|
||||
endif
|
||||
|
||||
" Complete values
|
||||
let entered_value = matchstr(line, '.\{-}\zs[a-zA-Z0-9#,.(_-]*$')
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_value
|
||||
if m =~? '^'.entered_atruleafter
|
||||
call add(res, m)
|
||||
elseif m =~? entered_value
|
||||
elseif m =~? entered_atruleafter
|
||||
call add(res2, m)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
|
||||
elseif borders[min(keys(borders))] == 'closebrace'
|
||||
endif
|
||||
|
||||
return []
|
||||
let values = ["charset", "page", "media", "import", "font-face"]
|
||||
|
||||
elseif borders[min(keys(borders))] == 'exclam'
|
||||
|
||||
" Complete values
|
||||
let entered_imp = matchstr(line, '.\{-}!\s*\zs[a-zA-Z ]*$')
|
||||
|
||||
let values = ["important"]
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_imp
|
||||
call add(res, m)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res
|
||||
|
||||
elseif borders[min(keys(borders))] == 'atrule'
|
||||
|
||||
let afterat = matchstr(line, '.*@\zs.*')
|
||||
|
||||
if afterat =~ '\s'
|
||||
|
||||
let atrulename = matchstr(line, '.*@\zs[a-zA-Z-]\+\ze')
|
||||
|
||||
if atrulename == 'media'
|
||||
let values = ["screen", "tty", "tv", "projection", "handheld", "print", "braille", "aural", "all"]
|
||||
|
||||
let atruleafterbase = matchstr(line, '.*@media\s\+\ze.*$')
|
||||
let entered_atruleafter = matchstr(line, '.*@media\s\+\zs.*$')
|
||||
|
||||
elseif atrulename == 'import'
|
||||
let atruleafterbase = matchstr(line, '.*@import\s\+\ze.*$')
|
||||
let entered_atruleafter = matchstr(line, '.*@import\s\+\zs.*$')
|
||||
|
||||
if entered_atruleafter =~ "^[\"']"
|
||||
let filestart = matchstr(entered_atruleafter, '^.\zs.*')
|
||||
let files = split(glob(filestart.'*'), '\n')
|
||||
let values = map(copy(files), '"\"".v:val')
|
||||
|
||||
elseif entered_atruleafter =~ "^url("
|
||||
let filestart = matchstr(entered_atruleafter, "^url([\"']\\?\\zs.*")
|
||||
let files = split(glob(filestart.'*'), '\n')
|
||||
let values = map(copy(files), '"url(".v:val')
|
||||
|
||||
else
|
||||
let values = ['"', 'url(']
|
||||
|
||||
endif
|
||||
|
||||
else
|
||||
return []
|
||||
|
||||
endif
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_atruleafter
|
||||
call add(res, m)
|
||||
elseif m =~? entered_atruleafter
|
||||
call add(res2, m)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
let entered_atrule = matchstr(line, '.*@\zs[a-zA-Z-]*$')
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_atrule
|
||||
call add(res, m .' ')
|
||||
elseif m =~? entered_atrule
|
||||
call add(res2, m .' ')
|
||||
endif
|
||||
endfor
|
||||
|
||||
let values = ["charset", "page", "media", "import", "font-face"]
|
||||
return res + res2
|
||||
|
||||
let entered_atrule = matchstr(line, '.*@\zs[a-zA-Z-]*$')
|
||||
endif
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_atrule
|
||||
call add(res, m .' ')
|
||||
elseif m =~? entered_atrule
|
||||
call add(res2, m .' ')
|
||||
endif
|
||||
endfor
|
||||
return []
|
||||
|
||||
return res + res2
|
||||
|
||||
endif
|
||||
|
||||
return []
|
||||
|
||||
endif
|
||||
endfunction
|
||||
|
||||
75
runtime/autoload/decada.vim
Normal file
75
runtime/autoload/decada.vim
Normal file
@ -0,0 +1,75 @@
|
||||
"------------------------------------------------------------------------------
|
||||
" Description: Vim Ada/Dec Ada compiler file
|
||||
" Language: Ada (Dec Ada)
|
||||
" $Id$
|
||||
" Copyright: Copyright (C) 2006 Martin Krischik
|
||||
" Maintainer: Martin Krischik
|
||||
" $Author$
|
||||
" $Date$
|
||||
" Version: 4.2
|
||||
" $Revision$
|
||||
" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/decada.vim $
|
||||
" History: 21.07.2006 MK New Dec Ada
|
||||
" 15.10.2006 MK Bram's suggestion for runtime integration
|
||||
" 05.11.2006 MK Bram suggested not to use include protection for
|
||||
" autoload
|
||||
" 05.11.2006 MK Bram suggested to save on spaces
|
||||
" Help Page: compiler-decada
|
||||
"------------------------------------------------------------------------------
|
||||
|
||||
if version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
function decada#Unit_Name () dict " {{{1
|
||||
" Convert filename into acs unit:
|
||||
" 1: remove the file extenstion.
|
||||
" 2: replace all double '_' or '-' with an dot (which denotes a separate)
|
||||
" 3: remove a trailing '_' (wich denotes a specification)
|
||||
return substitute (substitute (expand ("%:t:r"), '__\|-', ".", "g"), '_$', "", '')
|
||||
endfunction decada#Unit_Name " }}}1
|
||||
|
||||
function decada#Make () dict " {{{1
|
||||
let l:make_prg = substitute (g:self.Make_Command, '%<', self.Unit_Name(), '')
|
||||
let &errorformat = g:self.Error_Format
|
||||
let &makeprg = l:make_prg
|
||||
wall
|
||||
make
|
||||
copen
|
||||
set wrap
|
||||
wincmd W
|
||||
endfunction decada#Build " }}}1
|
||||
|
||||
function decada#Set_Session (...) dict " {{{1
|
||||
if a:0 > 0
|
||||
call ada#Switch_Session (a:1)
|
||||
elseif argc() == 0 && strlen (v:servername) > 0
|
||||
call ada#Switch_Session (
|
||||
\ expand('~')[0:-2] . ".vimfiles.session]" .
|
||||
\ v:servername . ".vim")
|
||||
endif
|
||||
return
|
||||
endfunction decada#Set_Session " }}}1
|
||||
|
||||
function decada#New () " }}}1
|
||||
let Retval = {
|
||||
\ 'Make' : function ('decada#Make'),
|
||||
\ 'Unit_Name' : function ('decada#Unit_Name'),
|
||||
\ 'Set_Session' : function ('decada#Set_Session'),
|
||||
\ 'Project_Dir' : '',
|
||||
\ 'Make_Command' : 'ACS COMPILE /Wait /Log /NoPreLoad /Optimize=Development /Debug %<',
|
||||
\ 'Error_Format' : '%+A%%ADAC-%t-%m,%C %#%m,%Zat line number %l in file %f,' .
|
||||
\ '%+I%%ada-I-%m,%C %#%m,%Zat line number %l in file %f'}
|
||||
|
||||
return Retval
|
||||
endfunction decada#New " }}}1
|
||||
|
||||
finish " 1}}}
|
||||
|
||||
"------------------------------------------------------------------------------
|
||||
" Copyright (C) 2006 Martin Krischik
|
||||
"
|
||||
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
||||
"------------------------------------------------------------------------------
|
||||
" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
||||
" vim: foldmethod=marker
|
||||
501
runtime/autoload/getscript.vim
Normal file
501
runtime/autoload/getscript.vim
Normal file
@ -0,0 +1,501 @@
|
||||
" ---------------------------------------------------------------------
|
||||
" getscript.vim
|
||||
" Author: Charles E. Campbell, Jr.
|
||||
" Date: Nov 27, 2006
|
||||
" Version: 23
|
||||
" Installing: :help glvs-install
|
||||
" Usage: :help glvs
|
||||
"
|
||||
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
|
||||
" ---------------------------------------------------------------------
|
||||
" Initialization: {{{1
|
||||
" if you're sourcing this file, surely you can't be
|
||||
" expecting vim to be in its vi-compatible mode
|
||||
if &cp
|
||||
echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
|
||||
finish
|
||||
endif
|
||||
let s:keepfo = &fo
|
||||
let s:keepcpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if exists("g:loaded_getscript")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_getscript= "v23"
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Global Variables: {{{1
|
||||
" allow user to change the command for obtaining scripts (does fetch work?)
|
||||
if !exists("g:GetLatestVimScripts_wget")
|
||||
if executable("wget")
|
||||
let g:GetLatestVimScripts_wget= "wget"
|
||||
elseif executable("curl")
|
||||
let g:GetLatestVimScripts_wget= "curl"
|
||||
else
|
||||
let g:GetLatestVimScripts_wget = 'echo "GetLatestVimScripts needs wget or curl"'
|
||||
let g:GetLatestVimScripts_options = ""
|
||||
endif
|
||||
endif
|
||||
|
||||
" options that wget and curl require:
|
||||
if !exists("g:GetLatestVimScripts_options")
|
||||
if g:GetLatestVimScripts_wget == "wget"
|
||||
let g:GetLatestVimScripts_options= "-q -O"
|
||||
elseif g:GetLatestVimScripts_wget == "curl"
|
||||
let g:GetLatestVimScripts_options= "-s -O"
|
||||
else
|
||||
let g:GetLatestVimScripts_options= ""
|
||||
endif
|
||||
endif
|
||||
|
||||
" by default, allow autoinstall lines to work
|
||||
if !exists("g:GetLatestVimScripts_allowautoinstall")
|
||||
let g:GetLatestVimScripts_allowautoinstall= 1
|
||||
endif
|
||||
|
||||
"" For debugging:
|
||||
"let g:GetLatestVimScripts_wget = "echo"
|
||||
"let g:GetLatestVimScripts_options = "options"
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Check If AutoInstall Capable: {{{1
|
||||
let s:autoinstall= ""
|
||||
if g:GetLatestVimScripts_allowautoinstall
|
||||
|
||||
if (has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")) && &shell != "bash"
|
||||
" windows (but not cygwin/bash)
|
||||
let s:dotvim= "vimfiles"
|
||||
if !exists("g:GetLatestVimScripts_mv")
|
||||
let g:GetLatestVimScripts_mv= "ren"
|
||||
endif
|
||||
|
||||
else
|
||||
" unix
|
||||
let s:dotvim= ".vim"
|
||||
if !exists("g:GetLatestVimScripts_mv")
|
||||
let g:GetLatestVimScripts_mv= "mv"
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists('$HOME') && isdirectory(expand("$HOME")."/".s:dotvim)
|
||||
let s:autoinstall= $HOME."/".s:dotvim
|
||||
endif
|
||||
" call Decho("s:autoinstall<".s:autoinstall.">")
|
||||
"else "Decho
|
||||
" call Decho("g:GetLatestVimScripts_allowautoinstall=".g:GetLatestVimScripts_allowautoinstall.": :AutoInstall: disabled")
|
||||
endif
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Public Interface: {{{1
|
||||
com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
|
||||
com! -nargs=0 GetScript call getscript#GetLatestVimScripts()
|
||||
silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts()
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" GetOneScript: (Get Latest Vim Script) this function operates {{{1
|
||||
" on the current line, interpreting two numbers and text as
|
||||
" ScriptID, SourceID, and Filename.
|
||||
" It downloads any scripts that have newer versions from vim.sf.net.
|
||||
fun! s:GetOneScript(...)
|
||||
" call Dfunc("GetOneScript()")
|
||||
|
||||
" set options to allow progress to be shown on screen
|
||||
let t_ti= &t_ti
|
||||
let t_te= &t_te
|
||||
let rs = &rs
|
||||
set t_ti= t_te= nors
|
||||
|
||||
" put current line on top-of-screen and interpret it into
|
||||
" a script identifer : used to obtain webpage
|
||||
" source identifier : used to identify current version
|
||||
" and an associated comment: used to report on what's being considered
|
||||
if a:0 >= 3
|
||||
let scriptid = a:1
|
||||
let srcid = a:2
|
||||
let fname = a:3
|
||||
let cmmnt = ""
|
||||
" call Decho("scriptid<".scriptid.">")
|
||||
" call Decho("srcid <".srcid.">")
|
||||
" call Decho("fname <".fname.">")
|
||||
else
|
||||
let curline = getline(".")
|
||||
if curline =~ '^\s*#'
|
||||
" call Dret("GetOneScript : skipping a pure comment line")
|
||||
return
|
||||
endif
|
||||
let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(.\{-}\)\(\s*#.*\)\=$'
|
||||
try
|
||||
let scriptid = substitute(curline,parsepat,'\1','e')
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
let scriptid= 0
|
||||
endtry
|
||||
try
|
||||
let srcid = substitute(curline,parsepat,'\2','e')
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
let srcid= 0
|
||||
endtry
|
||||
try
|
||||
let fname= substitute(curline,parsepat,'\3','e')
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
let fname= ""
|
||||
endtry
|
||||
try
|
||||
let cmmnt= substitute(curline,parsepat,'\4','e')
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
let cmmnt= ""
|
||||
endtry
|
||||
" call Decho("curline <".curline.">")
|
||||
" call Decho("parsepat<".parsepat.">")
|
||||
" call Decho("scriptid<".scriptid.">")
|
||||
" call Decho("srcid <".srcid.">")
|
||||
" call Decho("fname <".fname.">")
|
||||
endif
|
||||
|
||||
if scriptid == 0 || srcid == 0
|
||||
" When looking for :AutoInstall: lines, skip scripts that
|
||||
" have 0 0 scriptname
|
||||
" call Dret("GetOneScript : skipping a scriptid==srcid==0 line")
|
||||
return
|
||||
endif
|
||||
|
||||
let doautoinstall= 0
|
||||
if fname =~ ":AutoInstall:"
|
||||
" call Decho("fname<".fname."> has :AutoInstall:...")
|
||||
let aicmmnt= substitute(fname,'\s\+:AutoInstall:\s\+',' ','')
|
||||
" call Decho("aicmmnt<".aicmmnt."> s:autoinstall=".s:autoinstall)
|
||||
if s:autoinstall != ""
|
||||
let doautoinstall = g:GetLatestVimScripts_allowautoinstall
|
||||
endif
|
||||
else
|
||||
let aicmmnt= fname
|
||||
endif
|
||||
" call Decho("aicmmnt<".aicmmnt.">: doautoinstall=".doautoinstall)
|
||||
|
||||
exe "norm z\<CR>"
|
||||
redraw!
|
||||
" call Decho('considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid)
|
||||
echomsg 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid
|
||||
|
||||
" grab a copy of the plugin's vim.sf.net webpage
|
||||
let scriptaddr = 'http://vim.sf.net/script.php?script_id='.scriptid
|
||||
let tmpfile = tempname()
|
||||
let v:errmsg = ""
|
||||
|
||||
" make three tries at downloading the description
|
||||
let itry= 1
|
||||
while itry <= 3
|
||||
" call Decho("try#".itry." to download description of <".aicmmnt."> with addr=".scriptaddr)
|
||||
if has("win32") || has("win16") || has("win95")
|
||||
" call Decho("silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile.' "'.scriptaddr.'"')
|
||||
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile.' "'.scriptaddr.'"'
|
||||
else
|
||||
" call Decho("silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile." '".scriptaddr."'")
|
||||
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile." '".scriptaddr."'"
|
||||
endif
|
||||
if itry == 1
|
||||
exe "silent vsplit ".tmpfile
|
||||
else
|
||||
silent! e %
|
||||
endif
|
||||
|
||||
" find the latest source-id in the plugin's webpage
|
||||
silent! 1
|
||||
let findpkg= search('Click on the package to download','W')
|
||||
if findpkg > 0
|
||||
break
|
||||
endif
|
||||
let itry= itry + 1
|
||||
endwhile
|
||||
" call Decho(" --- end downloading tries while loop --- itry=".itry)
|
||||
|
||||
" testing: did finding /Click on the package.../ fail?
|
||||
if findpkg == 0 || itry >= 4
|
||||
silent q!
|
||||
call delete(tmpfile)
|
||||
" restore options
|
||||
let &t_ti = t_ti
|
||||
let &t_te = t_te
|
||||
let &rs = rs
|
||||
let s:downerrors = s:downerrors + 1
|
||||
" call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">")
|
||||
echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">"
|
||||
" call Dret("GetOneScript : srch for /Click on the package/ failed")
|
||||
return
|
||||
endif
|
||||
" call Decho('found "Click on the package to download"')
|
||||
|
||||
let findsrcid= search('src_id=','W')
|
||||
if findsrcid == 0
|
||||
silent q!
|
||||
call delete(tmpfile)
|
||||
" restore options
|
||||
let &t_ti = t_ti
|
||||
let &t_te = t_te
|
||||
let &rs = rs
|
||||
let s:downerrors = s:downerrors + 1
|
||||
" call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">")
|
||||
echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">"
|
||||
" call Dret("GetOneScript : srch for /src_id/ failed")
|
||||
return
|
||||
endif
|
||||
" call Decho('found "src_id=" in description page')
|
||||
|
||||
let srcidpat = '^\s*<td class.*src_id=\(\d\+\)">\([^<]\+\)<.*$'
|
||||
let latestsrcid= substitute(getline("."),srcidpat,'\1','')
|
||||
let fname = substitute(getline("."),srcidpat,'\2','')
|
||||
" call Decho("srcidpat<".srcidpat."> latestsrcid<".latestsrcid."> fname<".fname.">")
|
||||
silent q!
|
||||
call delete(tmpfile)
|
||||
|
||||
" convert the strings-of-numbers into numbers
|
||||
let srcid = srcid + 0
|
||||
let latestsrcid = latestsrcid + 0
|
||||
" call Decho("srcid=".srcid." latestsrcid=".latestsrcid." fname<".fname.">")
|
||||
|
||||
" has the plugin's most-recent srcid increased, which indicates
|
||||
" that it has been updated
|
||||
if latestsrcid > srcid
|
||||
let s:downloads= s:downloads + 1
|
||||
if fname == bufname("%")
|
||||
" GetLatestVimScript has to be careful about downloading itself
|
||||
let fname= "NEW_".fname
|
||||
endif
|
||||
|
||||
" the plugin has been updated since we last obtained it, so download a new copy
|
||||
" call Decho("...downloading new <".fname.">")
|
||||
echomsg "...downloading new <".fname.">"
|
||||
if has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")
|
||||
" call Decho("windows: silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".fname.' "'.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.'"')
|
||||
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".fname.' "'.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.'"'
|
||||
else
|
||||
" call Decho("unix: silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".fname." '".'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid."'")
|
||||
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".fname." '".'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid."'"
|
||||
endif
|
||||
|
||||
" AutoInstall: only if doautoinstall is so indicating
|
||||
if doautoinstall
|
||||
" call Decho("attempting to do autoinstall: getcwd<".getcwd()."> filereadable(".fname.")=".filereadable(fname))
|
||||
if filereadable(fname)
|
||||
" call Decho("move <".fname."> to ".s:autoinstall)
|
||||
" call Decho("DISABLED for testing")
|
||||
exe "silent !".g:GetLatestVimScripts_mv." ".fname." ".s:autoinstall
|
||||
let curdir= escape(substitute(getcwd(),'\','/','ge'),"|[]*'\" #")
|
||||
exe "cd ".s:autoinstall
|
||||
if fname =~ '\.bz2$'
|
||||
" call Decho("attempt to bunzip2 ".fname)
|
||||
exe "silent !bunzip2 ".fname
|
||||
let fname= substitute(fname,'\.bz2$','','')
|
||||
elseif fname =~ '\.gz$'
|
||||
" call Decho("attempt to gunzip ".fname)
|
||||
exe "silent !gunzip ".fname
|
||||
let fname= substitute(fname,'\.gz$','','')
|
||||
endif
|
||||
if fname =~ '\.zip$'
|
||||
" call Decho("attempt to unzip ".fname)
|
||||
exe "silent !unzip -o".fname
|
||||
elseif fname =~ '\.tar$'
|
||||
" call Decho("attempt to untar ".fname)
|
||||
exe "silent !tar -xvf ".fname
|
||||
elseif fname =~ '\.vba$'
|
||||
" call Decho("attempt to handle a vimball: ".fname)
|
||||
1split
|
||||
exe "e ".fname
|
||||
so %
|
||||
q
|
||||
endif
|
||||
if fname =~ '.vim$'
|
||||
" call Decho("attempt to simply move ".fname." to plugin")
|
||||
exe "silent !".g:GetLatestVimScripts_mv." ".fname." plugin"
|
||||
endif
|
||||
let docdir= substitute(&rtp,',.*','','e')."/doc"
|
||||
" call Decho("helptags docdir<".docdir.">")
|
||||
exe "helptags ".docdir
|
||||
exe "cd ".curdir
|
||||
endif
|
||||
endif
|
||||
|
||||
" update the data in the <GetLatestVimScripts.dat> file
|
||||
let modline=scriptid." ".latestsrcid." ".fname.cmmnt
|
||||
call setline(line("."),modline)
|
||||
" call Decho("modline<".modline."> (updated GetLatestVimScripts.dat file)")
|
||||
endif
|
||||
|
||||
" restore options
|
||||
let &t_ti= t_ti
|
||||
let &t_te= t_te
|
||||
let &rs = rs
|
||||
|
||||
" call Dret("GetOneScript")
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" GetLatestVimScripts: this function gets the latest versions of {{{1
|
||||
" scripts based on the list in
|
||||
" (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat
|
||||
fun! getscript#GetLatestVimScripts()
|
||||
" call Dfunc("GetLatestVimScripts() autoinstall<".s:autoinstall.">")
|
||||
|
||||
" insure that wget is executable
|
||||
if executable(g:GetLatestVimScripts_wget) != 1
|
||||
echoerr "GetLatestVimScripts needs ".g:GetLatestVimScripts_wget." which apparently is not available on your system"
|
||||
" call Dret("GetLatestVimScripts : wget not executable/availble")
|
||||
return
|
||||
endif
|
||||
|
||||
" Find the .../GetLatest subdirectory under the runtimepath
|
||||
for datadir in split(&rtp,',') + ['']
|
||||
if isdirectory(datadir."/GetLatest")
|
||||
" call Decho("found directory<".datadir.">")
|
||||
let datadir= datadir . "/GetLatest"
|
||||
break
|
||||
endif
|
||||
if filereadable(datadir."GetLatestVimScripts.dat")
|
||||
" call Decho("found ".datadir."/GetLatestVimScripts.dat")
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
" Sanity checks: readability and writability
|
||||
if datadir == ""
|
||||
echoerr 'Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install'
|
||||
" call Dret("GetLatestVimScripts : unable to find a GetLatest subdirectory")
|
||||
return
|
||||
endif
|
||||
|
||||
if filewritable(datadir) != 2
|
||||
echoerr "(getLatestVimScripts) Your ".datadir." isn't writable"
|
||||
" call Dret("GetLatestVimScripts : non-writable directory<".datadir.">")
|
||||
return
|
||||
endif
|
||||
let datafile= datadir."/GetLatestVimScripts.dat"
|
||||
if !filereadable(datafile)
|
||||
echoerr "Your data file<".datafile."> isn't readable"
|
||||
" call Dret("GetLatestVimScripts : non-readable datafile<".datafile.">")
|
||||
return
|
||||
endif
|
||||
if !filewritable(datafile)
|
||||
echoerr "Your data file<".datafile."> isn't writable"
|
||||
" call Dret("GetLatestVimScripts : non-writable datafile<".datafile.">")
|
||||
return
|
||||
endif
|
||||
" call Decho("datadir <".datadir.">")
|
||||
" call Decho("datafile <".datafile.">")
|
||||
|
||||
" don't let any events interfere (like winmanager's, taglist's, etc)
|
||||
let eikeep= &ei
|
||||
set ei=all
|
||||
|
||||
" record current directory, change to datadir, open split window with
|
||||
" datafile
|
||||
let origdir= getcwd()
|
||||
exe "cd ".escape(substitute(datadir,'\','/','ge'),"|[]*'\" #")
|
||||
split
|
||||
exe "e ".escape(substitute(datafile,'\','/','ge'),"|[]*'\" #")
|
||||
res 1000
|
||||
let s:downloads = 0
|
||||
let s:downerrors= 0
|
||||
|
||||
" Check on dependencies mentioned in plugins
|
||||
" call Decho(" ")
|
||||
" call Decho("searching plugins for GetLatestVimScripts dependencies")
|
||||
let lastline = line("$")
|
||||
let plugins = globpath(&rtp,"plugin/*.vim")
|
||||
let foundscript = 0
|
||||
|
||||
" call Decho("plugins<".plugins."> lastline#".lastline)
|
||||
while plugins != ""
|
||||
let plugin = substitute(plugins,'\n.*$','','e')
|
||||
let plugins= (plugins =~ '\n')? substitute(plugins,'^.\{-}\n\(.*\)$','\1','e') : ""
|
||||
$
|
||||
" call Decho(".dependency checking<".plugin."> line$=".line("$"))
|
||||
exe "silent r ".plugin
|
||||
while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0
|
||||
let newscript= substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e')
|
||||
let llp1 = lastline+1
|
||||
|
||||
if newscript !~ '^"'
|
||||
" found a "GetLatestVimScripts: # #" line in the script; check if its already in the datafile
|
||||
let curline = line(".")
|
||||
let noai_script = substitute(newscript,'\s*:AutoInstall:\s*','','e')
|
||||
exe llp1
|
||||
let srchline = search('\<'.noai_script.'\>','bW')
|
||||
" call Decho("..newscript<".newscript."> noai_script<".noai_script."> srch=".srchline." lastline=".lastline)
|
||||
|
||||
if srchline == 0
|
||||
" found a new script to permanently include in the datafile
|
||||
let keep_rega = @a
|
||||
let @a = substitute(getline(curline),'^"\s\+GetLatestVimScripts:\s\+','','')
|
||||
exe lastline."put a"
|
||||
echomsg "Appending <".@a."> to ".datafile." for ".newscript
|
||||
" call Decho("..APPEND (".noai_script.")<".@a."> to GetLatestVimScripts.dat")
|
||||
let @a = keep_rega
|
||||
let lastline = llp1
|
||||
let curline = curline + 1
|
||||
let foundscript = foundscript + 1
|
||||
" else " Decho
|
||||
" call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")")
|
||||
endif
|
||||
|
||||
let curline = curline + 1
|
||||
exe curline
|
||||
endif
|
||||
|
||||
endwhile
|
||||
let llp1= lastline + 1
|
||||
" call Decho(".deleting lines: ".llp1.",$d")
|
||||
exe "silent! ".llp1.",$d"
|
||||
endwhile
|
||||
|
||||
if foundscript == 0
|
||||
set nomod
|
||||
endif
|
||||
|
||||
" Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat
|
||||
set lz
|
||||
" call Decho(" --- end of dependency checking loop --- ")
|
||||
" call Decho("call GetOneScript on lines at end of datafile<".datafile.">")
|
||||
1
|
||||
/^-----/,$g/^\s*\d/call <SID>GetOneScript()
|
||||
|
||||
" Final report (an echomsg)
|
||||
try
|
||||
silent! ?^-------?
|
||||
catch /^Vim\%((\a\+)\)\=:E114/
|
||||
" call Dret("GetLatestVimScripts : nothing done!")
|
||||
return
|
||||
endtry
|
||||
exe "norm! kz\<CR>"
|
||||
redraw!
|
||||
let s:msg = ""
|
||||
if s:downloads == 1
|
||||
let s:msg = "Downloaded one updated script to <".datadir.">"
|
||||
elseif s:downloads == 2
|
||||
let s:msg= "Downloaded two updated scripts to <".datadir.">"
|
||||
elseif s:downloads > 1
|
||||
let s:msg= "Downloaded ".s:downloads." updated scripts to <".datadir.">"
|
||||
else
|
||||
let s:msg= "Everything was already current"
|
||||
endif
|
||||
if s:downerrors > 0
|
||||
let s:msg= s:msg." (".s:downerrors." downloading errors)"
|
||||
endif
|
||||
echomsg s:msg
|
||||
" save the file
|
||||
if &mod
|
||||
silent! w!
|
||||
endif
|
||||
q
|
||||
|
||||
" restore events and current directory
|
||||
exe "cd ".escape(substitute(origdir,'\','/','ge'),"|[]*'\" #")
|
||||
let &ei= eikeep
|
||||
set nolz
|
||||
" call Dret("GetLatestVimScripts : did ".s:downloads." downloads")
|
||||
endfun
|
||||
" ---------------------------------------------------------------------
|
||||
|
||||
" Restore Options: {{{1
|
||||
let &fo = s:keepfo
|
||||
let &cpo= s:keepcpo
|
||||
|
||||
" vim: ts=8 sts=2 fdm=marker nowrap
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,34 @@
|
||||
"pythoncomplete.vim - Omni Completion for python
|
||||
" Maintainer: Aaron Griffin <aaronmgriffin@gmail.com>
|
||||
" Version: 0.5
|
||||
" Last Updated: 19 April 2006
|
||||
"
|
||||
" Yeah, I skipped a version number - 0.4 was never public.
|
||||
" It was a bugfix version on top of 0.3. This is a complete
|
||||
" rewrite.
|
||||
" Version: 0.7
|
||||
" Last Updated: 19 Oct 2006
|
||||
"
|
||||
" Changes
|
||||
" TODO:
|
||||
" User defined docstrings aren't handled right...
|
||||
" 'info' item output can use some formatting work
|
||||
" Add an "unsafe eval" mode, to allow for return type evaluation
|
||||
" Complete basic syntax along with import statements
|
||||
" i.e. "import url<c-x,c-o>"
|
||||
" Continue parsing on invalid line??
|
||||
"
|
||||
" v 0.7
|
||||
" * Fixed function list sorting (_ and __ at the bottom)
|
||||
" * Removed newline removal from docs. It appears vim handles these better in
|
||||
" recent patches
|
||||
"
|
||||
" v 0.6:
|
||||
" * Fixed argument completion
|
||||
" * Removed the 'kind' completions, as they are better indicated
|
||||
" with real syntax
|
||||
" * Added tuple assignment parsing (whoops, that was forgotten)
|
||||
" * Fixed import handling when flattening scope
|
||||
"
|
||||
" v 0.5:
|
||||
" Yeah, I skipped a version number - 0.4 was never public.
|
||||
" It was a bugfix version on top of 0.3. This is a complete
|
||||
" rewrite.
|
||||
"
|
||||
|
||||
if !has('python')
|
||||
echo "Error: Required vim compiled with +python"
|
||||
@ -28,7 +46,7 @@ function! pythoncomplete#Complete(findstart, base)
|
||||
if c =~ '\w'
|
||||
continue
|
||||
elseif ! c =~ '\.'
|
||||
idx = -1
|
||||
let idx = -1
|
||||
break
|
||||
else
|
||||
break
|
||||
@ -45,7 +63,7 @@ function! pythoncomplete#Complete(findstart, base)
|
||||
while idx > 0
|
||||
let idx -= 1
|
||||
let c = line[idx]
|
||||
if c =~ '\w' || c =~ '\.'
|
||||
if c =~ '\w' || c =~ '\.' || c == '('
|
||||
let cword = c . cword
|
||||
continue
|
||||
elseif strlen(cword) > 0 || idx == 0
|
||||
@ -73,7 +91,24 @@ def vimcomplete(context,match):
|
||||
try:
|
||||
import vim
|
||||
def complsort(x,y):
|
||||
return x['abbr'] > y['abbr']
|
||||
try:
|
||||
xa = x['abbr']
|
||||
ya = y['abbr']
|
||||
if xa[0] == '_':
|
||||
if xa[1] == '_' and ya[0:2] == '__':
|
||||
return xa > ya
|
||||
elif ya[0:2] == '__':
|
||||
return -1
|
||||
elif y[0] == '_':
|
||||
return xa > ya
|
||||
else:
|
||||
return 1
|
||||
elif ya[0] == '_':
|
||||
return -1
|
||||
else:
|
||||
return xa > ya
|
||||
except:
|
||||
return 0
|
||||
cmpl = Completer()
|
||||
cmpl.evalsource('\n'.join(vim.current.buffer),vim.eval("line('.')"))
|
||||
all = cmpl.get_completions(context,match)
|
||||
@ -86,7 +121,7 @@ def vimcomplete(context,match):
|
||||
dictstr += '"icase":0},'
|
||||
if dictstr[-1] == ',': dictstr = dictstr[:-1]
|
||||
dictstr += ']'
|
||||
dbg("dict: %s" % dictstr)
|
||||
#dbg("dict: %s" % dictstr)
|
||||
vim.command("silent let g:pythoncomplete_completions = %s" % dictstr)
|
||||
#dbg("Completion dict:\n%s" % all)
|
||||
except vim.error:
|
||||
@ -108,11 +143,7 @@ class Completer(object):
|
||||
except: dbg("locals: %s, %s [%s]" % (sys.exc_info()[0],sys.exc_info()[1],l))
|
||||
|
||||
def _cleanstr(self,doc):
|
||||
return doc.replace('"',' ')\
|
||||
.replace("'",' ')\
|
||||
.replace('\n',' ')\
|
||||
.replace('\r',' ')\
|
||||
.replace('
|
||||
return doc.replace('"',' ').replace("'",' ')
|
||||
|
||||
def get_arguments(self,func_obj):
|
||||
def _ctor(obj):
|
||||
@ -128,23 +159,23 @@ class Completer(object):
|
||||
elif type(func_obj) == types.MethodType: func_obj = func_obj.im_func
|
||||
else: arg_offset = 0
|
||||
|
||||
|
||||
arg_text=''
|
||||
if type(func_obj) in [types.FunctionType, types.LambdaType]:
|
||||
try:
|
||||
cd = func_obj.func_code
|
||||
real_args = cd.co_varnames[arg_offset:cd.co_argcount]
|
||||
real_args = cd.co_varnames[arg_offset:cd.co_argcount]
|
||||
defaults = func_obj.func_defaults or []
|
||||
defaults = func_obj.func_defaults or ''
|
||||
defaults = map(lambda name: "=%s" % name, defaults)
|
||||
defaults = [""] * (len(real_args)-len(defaults)) + defaults
|
||||
items = map(lambda a,d: a+d, real_args, defaults)
|
||||
if func_obj.func_code.co_flags & 0x4:
|
||||
items.append("...")
|
||||
if func_obj.func_code.co_flags & 0x8:
|
||||
items.append("***")
|
||||
items.append("***")
|
||||
arg_text = (','.join(items)) + ')'
|
||||
|
||||
except:
|
||||
except:
|
||||
dbg("arg completion: %s: %s" % (sys.exc_info()[0],sys.exc_info()[1]))
|
||||
pass
|
||||
if len(arg_text) == 0:
|
||||
# The doc string sometimes contains the function signature
|
||||
@ -160,6 +191,7 @@ class Completer(object):
|
||||
ridx = sigline.find(')')
|
||||
if lidx > 0 and ridx > 0:
|
||||
arg_text = sigline[lidx+1:ridx] + ')'
|
||||
if len(arg_text) == 0: arg_text = ')'
|
||||
return arg_text
|
||||
|
||||
def get_completions(self,context,match):
|
||||
@ -172,12 +204,11 @@ class Completer(object):
|
||||
all = {}
|
||||
ridx = stmt.rfind('.')
|
||||
if len(stmt) > 0 and stmt[-1] == '(':
|
||||
if len(stmt) > 0 and stmt[-1] == '(':
|
||||
result = eval(_sanitize(stmt[:-1]), self.compldict)
|
||||
doc = result.__doc__
|
||||
if doc == None: doc = ''
|
||||
if doc == None: doc = ''
|
||||
args = self.get_arguments(res)
|
||||
args = self.get_arguments(result)
|
||||
return [{'word':self._cleanstr(args),'info':self._cleanstr(doc)}]
|
||||
elif ridx == -1:
|
||||
match = stmt
|
||||
all = self.compldict
|
||||
@ -206,22 +237,18 @@ class Completer(object):
|
||||
if doc == None or doc == '': doc = maindoc
|
||||
|
||||
wrd = m[len(match):]
|
||||
wrd = m[len(match):]
|
||||
c = {'word':wrd, 'abbr':m, 'info':self._cleanstr(doc)}
|
||||
if "function" in typestr:
|
||||
c['word'] += '('
|
||||
c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
|
||||
c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
|
||||
elif "method" in typestr:
|
||||
c['word'] += '('
|
||||
c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
|
||||
c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
|
||||
elif "module" in typestr:
|
||||
c['word'] += '.'
|
||||
c['word'] += '.'
|
||||
elif "class" in typestr:
|
||||
c['word'] += '('
|
||||
c['abbr'] += '('
|
||||
c['abbr'] += '('
|
||||
completions.append(c)
|
||||
except:
|
||||
i = sys.exc_info()
|
||||
@ -277,10 +304,13 @@ class Scope(object):
|
||||
# we need to start with this, to fix up broken completions
|
||||
# hopefully this name is unique enough...
|
||||
str = '"""'+self.docstr+'"""\n'
|
||||
for l in self.locals:
|
||||
if l.startswith('import'): str += l+'\n'
|
||||
str += 'class _PyCmplNoType:\n def __getattr__(self,name):\n return None\n'
|
||||
for sub in self.subscopes:
|
||||
str += sub.get_code()
|
||||
str += sub.get_code()
|
||||
for l in self.locals:
|
||||
if not l.startswith('import'): str += l+'\n'
|
||||
|
||||
return str
|
||||
|
||||
@ -420,6 +450,8 @@ class PyParser:
|
||||
tokentype, token, indent = self.next()
|
||||
if tokentype == tokenize.STRING or token == 'str':
|
||||
return '""'
|
||||
elif token == '(' or token == 'tuple':
|
||||
return '()'
|
||||
elif token == '[' or token == 'list':
|
||||
return '[]'
|
||||
elif token == '{' or token == 'dict':
|
||||
@ -494,9 +526,9 @@ class PyParser:
|
||||
freshscope=True
|
||||
while True:
|
||||
tokentype, token, indent = self.next()
|
||||
tokentype, token, indent = self.next()
|
||||
#dbg( 'main: token=[%s] indent=[%s]' % (token,indent))
|
||||
|
||||
|
||||
if tokentype == DEDENT or token == "pass":
|
||||
self.scope = self.scope.pop(indent)
|
||||
elif token == 'def':
|
||||
func = self._parsefunction(indent)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,8 @@
|
||||
" Vim completion script
|
||||
" Language: All languages, uses existing syntax highlighting rules
|
||||
" Maintainer: David Fishburn <fishburn@ianywhere.com>
|
||||
" Version: 2.0
|
||||
" Last Change: Fri May 05 2006 10:34:57 PM
|
||||
" Version: 3.0
|
||||
" Last Change: Wed Nov 08 2006 10:46:46 AM
|
||||
" Usage: For detailed help, ":help ft-syntax-omni"
|
||||
|
||||
" Set completion with CTRL-X CTRL-O to autoloaded function.
|
||||
@ -19,13 +19,31 @@ endif
|
||||
if exists('g:loaded_syntax_completion')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntax_completion = 20
|
||||
let g:loaded_syntax_completion = 30
|
||||
|
||||
" Set ignorecase to the ftplugin standard
|
||||
" This is the default setting, but if you define a buffer local
|
||||
" variable you can override this on a per filetype.
|
||||
if !exists('g:omni_syntax_ignorecase')
|
||||
let g:omni_syntax_ignorecase = &ignorecase
|
||||
endif
|
||||
|
||||
" Indicates whether we should use the iskeyword option to determine
|
||||
" how to split words.
|
||||
" This is the default setting, but if you define a buffer local
|
||||
" variable you can override this on a per filetype.
|
||||
if !exists('g:omni_syntax_use_iskeyword')
|
||||
let g:omni_syntax_use_iskeyword = 1
|
||||
endif
|
||||
|
||||
" Only display items in the completion window that are at least
|
||||
" this many characters in length.
|
||||
" This is the default setting, but if you define a buffer local
|
||||
" variable you can override this on a per filetype.
|
||||
if !exists('g:omni_syntax_minimum_length')
|
||||
let g:omni_syntax_minimum_length = 0
|
||||
endif
|
||||
|
||||
" This script will build a completion list based on the syntax
|
||||
" elements defined by the files in $VIMRUNTIME/syntax.
|
||||
let s:syn_remove_words = 'match,matchgroup=,contains,'.
|
||||
@ -38,21 +56,28 @@ let s:prepended = ''
|
||||
" This function is used for the 'omnifunc' option.
|
||||
function! syntaxcomplete#Complete(findstart, base)
|
||||
|
||||
" Only display items in the completion window that are at least
|
||||
" this many characters in length
|
||||
if !exists('b:omni_syntax_ignorecase')
|
||||
if exists('g:omni_syntax_ignorecase')
|
||||
let b:omni_syntax_ignorecase = g:omni_syntax_ignorecase
|
||||
else
|
||||
let b:omni_syntax_ignorecase = &ignorecase
|
||||
endif
|
||||
endif
|
||||
|
||||
if a:findstart
|
||||
" Locate the start of the item, including "."
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
let lastword = -1
|
||||
while start > 0
|
||||
if line[start - 1] =~ '\w'
|
||||
" if line[start - 1] =~ '\S'
|
||||
" let start -= 1
|
||||
" elseif line[start - 1] =~ '\.'
|
||||
if line[start - 1] =~ '\k'
|
||||
let start -= 1
|
||||
elseif line[start - 1] =~ '\.'
|
||||
" The user must be specifying a column name
|
||||
if lastword == -1
|
||||
let lastword = start
|
||||
endif
|
||||
let start -= 1
|
||||
let b:sql_compl_type = 'column'
|
||||
let lastword = a:findstart
|
||||
else
|
||||
break
|
||||
endif
|
||||
@ -64,11 +89,12 @@ function! syntaxcomplete#Complete(findstart, base)
|
||||
let s:prepended = ''
|
||||
return start
|
||||
endif
|
||||
let s:prepended = strpart(line, start, lastword - start)
|
||||
return lastword
|
||||
let s:prepended = strpart(line, start, (col('.') - 1) - start)
|
||||
return start
|
||||
endif
|
||||
|
||||
let base = s:prepended . a:base
|
||||
" let base = s:prepended . a:base
|
||||
let base = s:prepended
|
||||
|
||||
let filetype = substitute(&filetype, '\.', '_', 'g')
|
||||
let list_idx = index(s:cache_name, filetype, 0, &ignorecase)
|
||||
@ -82,11 +108,16 @@ function! syntaxcomplete#Complete(findstart, base)
|
||||
|
||||
" Return list of matches.
|
||||
|
||||
if base =~ '\w'
|
||||
let compstr = join(compl_list, ' ')
|
||||
let expr = (g:omni_syntax_ignorecase==0?'\C':'').'\<\%('.base.'\)\@!\w\+\s*'
|
||||
let compstr = substitute(compstr, expr, '', 'g')
|
||||
let compl_list = split(compstr, '\s\+')
|
||||
if base != ''
|
||||
" let compstr = join(compl_list, ' ')
|
||||
" let expr = (b:omni_syntax_ignorecase==0?'\C':'').'\<\%('.base.'\)\@!\w\+\s*'
|
||||
" let compstr = substitute(compstr, expr, '', 'g')
|
||||
" let compl_list = split(compstr, '\s\+')
|
||||
|
||||
" Filter the list based on the first few characters the user
|
||||
" entered
|
||||
let expr = 'v:val '.(g:omni_syntax_ignorecase==1?'=~?':'=~#')." '^".escape(base, '\\/.*$^~[]').".*'"
|
||||
let compl_list = filter(deepcopy(compl_list), expr)
|
||||
endif
|
||||
|
||||
return compl_list
|
||||
@ -100,6 +131,26 @@ function! OmniSyntaxList()
|
||||
" let use_dictionary = a:1
|
||||
" endif
|
||||
|
||||
" Only display items in the completion window that are at least
|
||||
" this many characters in length
|
||||
if !exists('b:omni_syntax_use_iskeyword')
|
||||
if exists('g:omni_syntax_use_iskeyword')
|
||||
let b:omni_syntax_use_iskeyword = g:omni_syntax_use_iskeyword
|
||||
else
|
||||
let b:omni_syntax_use_iskeyword = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
" Only display items in the completion window that are at least
|
||||
" this many characters in length
|
||||
if !exists('b:omni_syntax_minimum_length')
|
||||
if exists('g:omni_syntax_minimum_length')
|
||||
let b:omni_syntax_minimum_length = g:omni_syntax_minimum_length
|
||||
else
|
||||
let b:omni_syntax_minimum_length = 0
|
||||
endif
|
||||
endif
|
||||
|
||||
let saveL = @l
|
||||
|
||||
" Loop through all the syntax groupnames, and build a
|
||||
@ -294,14 +345,32 @@ function! s:SyntaxCSyntaxGroupItems( group_name, syntax_full )
|
||||
\ , "", 'g'
|
||||
\ )
|
||||
|
||||
" There are a number of items which have non-word characters in
|
||||
" them, *'T_F1'*. vim.vim is one such file.
|
||||
" This will replace non-word characters with spaces.
|
||||
let syn_list = substitute( syn_list, '[^0-9A-Za-z_ ]', ' ', 'g' )
|
||||
if b:omni_syntax_use_iskeyword == 0
|
||||
" There are a number of items which have non-word characters in
|
||||
" them, *'T_F1'*. vim.vim is one such file.
|
||||
" This will replace non-word characters with spaces.
|
||||
let syn_list = substitute( syn_list, '[^0-9A-Za-z_ ]', ' ', 'g' )
|
||||
else
|
||||
let accept_chars = ','.&iskeyword.','
|
||||
" Remove all character ranges
|
||||
let accept_chars = substitute(accept_chars, ',[^,]\+-[^,]\+,', ',', 'g')
|
||||
" Remove all numeric specifications
|
||||
let accept_chars = substitute(accept_chars, ',\d\{-},', ',', 'g')
|
||||
" Remove all commas
|
||||
let accept_chars = substitute(accept_chars, ',', '', 'g')
|
||||
" Escape special regex characters
|
||||
let accept_chars = escape(accept_chars, '\\/.*$^~[]' )
|
||||
" Remove all characters that are not acceptable
|
||||
let syn_list = substitute( syn_list, '[^0-9A-Za-z_ '.accept_chars.']', ' ', 'g' )
|
||||
endif
|
||||
|
||||
if b:omni_syntax_minimum_length > 0
|
||||
" If the user specified a minimum length, enforce it
|
||||
let syn_list = substitute(' '.syn_list.' ', ' \S\{,'.b:omni_syntax_minimum_length.'}\ze ', ' ', 'g')
|
||||
endif
|
||||
else
|
||||
let syn_list = ''
|
||||
endif
|
||||
|
||||
return syn_list
|
||||
endfunction
|
||||
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
" Vim completion script
|
||||
" Language: XML
|
||||
" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
|
||||
" Last Change: 2006 Apr 30
|
||||
" Last Change: 2006 Jul 18
|
||||
" Version: 1.8
|
||||
"
|
||||
" Changelog:
|
||||
" 1.8 - 2006 Jul 18
|
||||
" - allow for closing of xml tags even when data file isn't available
|
||||
|
||||
" This function will create Dictionary with users namespace strings and values
|
||||
" canonical (system) names of data files. Names should be lowercase,
|
||||
@ -80,7 +85,7 @@ function! xmlcomplete#CompleteTags(findstart, base)
|
||||
let context_line = getline(curline-i)
|
||||
if context_line =~ '<[^>]*$'
|
||||
" Yep, this is this line
|
||||
let context_lines = getline(curline-i, curline)
|
||||
let context_lines = getline(curline-i, curline-1) + [b:compl_context]
|
||||
let b:compl_context = join(context_lines, ' ')
|
||||
break
|
||||
elseif context_line =~ '>[^<]*$' || i == curline
|
||||
@ -106,10 +111,6 @@ function! xmlcomplete#CompleteTags(findstart, base)
|
||||
return start
|
||||
|
||||
else
|
||||
" There is no connection of namespace and data file. Abandon action
|
||||
if !exists("g:xmldata_connection") || g:xmldata_connection == {}
|
||||
return []
|
||||
endif
|
||||
" Initialize base return lists
|
||||
let res = []
|
||||
let res2 = []
|
||||
@ -119,6 +120,17 @@ function! xmlcomplete#CompleteTags(findstart, base)
|
||||
endif
|
||||
let context = matchstr(b:compl_context, '^<\zs.*')
|
||||
unlet! b:compl_context
|
||||
" There is no connection of namespace and data file.
|
||||
if !exists("g:xmldata_connection") || g:xmldata_connection == {}
|
||||
" There is still possibility we may do something - eg. close tag
|
||||
let b:unaryTagsStack = "base meta link hr br param img area input col"
|
||||
if context =~ '^\/'
|
||||
let opentag = xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
|
||||
return [opentag.">"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" Make entities completion
|
||||
if exists("b:entitiescompl")
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
" zip.vim: Handles browsing zipfiles
|
||||
" AUTOLOAD PORTION
|
||||
" Date: May 01, 2006
|
||||
" Version: 9
|
||||
" Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
|
||||
" License: Vim License (see vim's :help license)
|
||||
" Date: Sep 29, 2006
|
||||
" Version: 12
|
||||
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
|
||||
" License: Vim License (see vim's :help license)
|
||||
" Copyright: Copyright (C) 2005 Charles E. Campbell, Jr. {{{1
|
||||
" Permission is hereby granted to use and distribute this code,
|
||||
" with or without modifications, provided that this copyright
|
||||
@ -15,15 +15,28 @@
|
||||
" of this software.
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Initialization: {{{1
|
||||
" Load Once: {{{1
|
||||
let s:keepcpo= &cpo
|
||||
set cpo&vim
|
||||
if exists("g:loaded_zip")
|
||||
if &cp || exists("g:loaded_zip") || v:version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
let g:loaded_zip = "v9"
|
||||
let g:loaded_zip = "v12"
|
||||
let s:zipfile_escape = ' ?&;\'
|
||||
let s:ERROR = 2
|
||||
let s:WARNING = 1
|
||||
let s:NOTE = 0
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Global Values: {{{1
|
||||
if !exists("g:zip_shq")
|
||||
if has("unix")
|
||||
let g:zip_shq= "'"
|
||||
else
|
||||
let g:zip_shq= '"'
|
||||
endif
|
||||
endif
|
||||
|
||||
" ----------------
|
||||
" Functions: {{{1
|
||||
@ -38,8 +51,9 @@ fun! zip#Browse(zipfile)
|
||||
|
||||
" sanity checks
|
||||
if !executable("unzip")
|
||||
redraw!
|
||||
echohl Error | echo "***error*** (zip#Browse) unzip not available on your system"
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
let &report= repkeep
|
||||
" call Dret("zip#Browse")
|
||||
return
|
||||
@ -47,8 +61,9 @@ fun! zip#Browse(zipfile)
|
||||
if !filereadable(a:zipfile)
|
||||
if a:zipfile !~# '^\a\+://'
|
||||
" if its an url, don't complain, let url-handlers such as vim do its thing
|
||||
redraw!
|
||||
echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
endif
|
||||
let &report= repkeep
|
||||
" call Dret("zip#Browse : file<".a:zipfile."> not readable")
|
||||
@ -75,11 +90,12 @@ fun! zip#Browse(zipfile)
|
||||
0d
|
||||
$
|
||||
|
||||
" call Decho("exe silent r! unzip -l '".a:zipfile."'")
|
||||
exe "silent r! unzip -l '".a:zipfile."'"
|
||||
" call Decho("exe silent r! unzip -l ".s:QuoteFileDir(a:zipfile))
|
||||
exe "silent r! unzip -l ".s:QuoteFileDir(a:zipfile)
|
||||
if v:shell_error != 0
|
||||
redraw!
|
||||
echohl WarningMsg | echo "***warning*** (zip#Browse) ".a:zipfile." is not a zip file" | echohl None
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
silent %d
|
||||
let eikeep= &ei
|
||||
set ei=BufReadCmd,FileReadCmd
|
||||
@ -121,8 +137,9 @@ fun! s:ZipBrowseSelect()
|
||||
return
|
||||
endif
|
||||
if fname =~ '/$'
|
||||
redraw!
|
||||
echohl Error | echo "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
let &report= repkeep
|
||||
" call Dret("ZipBrowseSelect")
|
||||
return
|
||||
@ -131,7 +148,7 @@ fun! s:ZipBrowseSelect()
|
||||
" call Decho("fname<".fname.">")
|
||||
|
||||
" get zipfile to the new-window
|
||||
let zipfile= substitute(w:zipfile,'.zip$','','e')
|
||||
let zipfile = w:zipfile
|
||||
let curfile= expand("%")
|
||||
" call Decho("zipfile<".zipfile.">")
|
||||
" call Decho("curfile<".curfile.">")
|
||||
@ -160,12 +177,15 @@ fun! zip#Read(fname,mode)
|
||||
else
|
||||
let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
|
||||
let fname = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
|
||||
|
||||
" TODO Needs to predicated to using InfoZIP's unzip on Windows
|
||||
let fname = substitute(fname, '[', '[[]', 'g')
|
||||
endif
|
||||
" call Decho("zipfile<".zipfile.">")
|
||||
" call Decho("fname <".fname.">")
|
||||
|
||||
" call Decho("exe r! unzip -p '".zipfile."' '".fname."'")
|
||||
exe "silent r! unzip -p '".zipfile."' '".fname."'"
|
||||
" call Decho("exe r! unzip -p ".s:QuoteFileDir(zipfile)." ".s:QuoteFileDir(fname))
|
||||
exe "silent r! unzip -p ".s:QuoteFileDir(zipfile)." ".s:QuoteFileDir(fname)
|
||||
|
||||
" cleanup
|
||||
0d
|
||||
@ -184,15 +204,17 @@ fun! zip#Write(fname)
|
||||
|
||||
" sanity checks
|
||||
if !executable("zip")
|
||||
redraw!
|
||||
echohl Error | echo "***error*** (zip#Write) sorry, your system doesn't appear to have the zip pgm" | echohl None
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
let &report= repkeep
|
||||
" call Dret("zip#Write")
|
||||
return
|
||||
endif
|
||||
if !exists("*mkdir")
|
||||
redraw!
|
||||
echohl Error | echo "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
let &report= repkeep
|
||||
" call Dret("zip#Write")
|
||||
return
|
||||
@ -208,15 +230,11 @@ fun! zip#Write(fname)
|
||||
call mkdir(tmpdir,"p")
|
||||
|
||||
" attempt to change to the indicated directory
|
||||
try
|
||||
exe "cd ".escape(tmpdir,' \')
|
||||
catch /^Vim\%((\a\+)\)\=:E344/
|
||||
echohl Error | echo "***error*** (zip#Write) cannot cd to temporary directory" | Echohl None
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory")
|
||||
let &report= repkeep
|
||||
" call Dret("zip#Write")
|
||||
return
|
||||
endtry
|
||||
endif
|
||||
" call Decho("current directory now: ".getcwd())
|
||||
|
||||
" place temporary files under .../_ZIPVIM_/
|
||||
@ -255,21 +273,27 @@ fun! zip#Write(fname)
|
||||
let zipfile = substitute(system("cygpath ".zipfile),'\n','','e')
|
||||
endif
|
||||
|
||||
" call Decho("zip -u '".zipfile.".zip' '".fname."'")
|
||||
call system("zip -u '".zipfile.".zip' '".fname."'")
|
||||
" TODO Needs to predicated to using InfoZIP's unzip
|
||||
if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
|
||||
let fname = substitute(fname, '[', '[[]', 'g')
|
||||
endif
|
||||
|
||||
" call Decho("zip -u ".s:QuoteFileDir(zipfile)." ".s:QuoteFileDir(fname))
|
||||
call system("zip -u ".s:QuoteFileDir(zipfile)." ".s:QuoteFileDir(fname))
|
||||
if v:shell_error != 0
|
||||
redraw!
|
||||
echohl Error | echo "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None
|
||||
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
|
||||
elseif s:zipfile_{winnr()} =~ '^\a\+://'
|
||||
" support writing zipfiles across a network
|
||||
let netzipfile= s:zipfile_{winnr()}
|
||||
" call Decho("handle writing <".zipfile.".zip> across network as <".netzipfile.">")
|
||||
" call Decho("handle writing <".zipfile."> across network as <".netzipfile.">")
|
||||
1split|enew
|
||||
let binkeep= &binary
|
||||
let eikeep = &ei
|
||||
set binary ei=all
|
||||
exe "e! ".zipfile.".zip"
|
||||
exe "e! ".zipfile
|
||||
call netrw#NetWrite(netzipfile)
|
||||
let &ei = eikeep
|
||||
let &binary = binkeep
|
||||
@ -280,25 +304,61 @@ fun! zip#Write(fname)
|
||||
" cleanup and restore current directory
|
||||
cd ..
|
||||
call s:Rmdir("_ZIPVIM_")
|
||||
exe "cd ".escape(curdir,' \')
|
||||
call s:ChgDir(curdir,s:WARNING,"(zip#Write) unable to return to ".curdir."!")
|
||||
call s:Rmdir(tmpdir)
|
||||
setlocal nomod
|
||||
|
||||
let &report= repkeep
|
||||
" call Dret("zip#Write")
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" QuoteFileDir: {{{2
|
||||
fun! s:QuoteFileDir(fname)
|
||||
" call Dfunc("QuoteFileDir(fname<".a:fname.">)")
|
||||
" call Dret("QuoteFileDir")
|
||||
return g:zip_shq.a:fname.g:zip_shq
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" ChgDir: {{{2
|
||||
fun! s:ChgDir(newdir,errlvl,errmsg)
|
||||
" call Dfunc("ChgDir(newdir<".a:newdir."> errlvl=".a:errlvl." errmsg<".a:errmsg.">)")
|
||||
|
||||
if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
|
||||
let newdir= escape(a:newdir,' ')
|
||||
else
|
||||
let newdir= escape(a:newdir,'\ ')
|
||||
endif
|
||||
|
||||
try
|
||||
exe "cd ".newdir
|
||||
catch /^Vim\%((\a\+)\)\=:E344/
|
||||
redraw!
|
||||
if a:errlvl == s:NOTE
|
||||
echo "***note*** ".a:errmsg
|
||||
elseif a:errlvl == s:WARNING
|
||||
echohl WarningMsg | echo "***warning*** ".a:errmsg | echohl NONE
|
||||
elseif a:errlvl == s:ERROR
|
||||
echohl Error | echo "***error*** ".a:errmsg | echohl NONE
|
||||
endif
|
||||
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" call Dret("ChgDir 1")
|
||||
return 1
|
||||
endtry
|
||||
|
||||
" call Dret("ChgDir 0")
|
||||
return 0
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Rmdir: {{{2
|
||||
fun! s:Rmdir(fname)
|
||||
" call Dfunc("Rmdir(fname<".a:fname.">)")
|
||||
if has("unix")
|
||||
call system("/bin/rm -rf ".a:fname)
|
||||
elseif has("win32") || has("win95") || has("win64") || has("win16")
|
||||
if &shell =~? "sh$"
|
||||
call system("/bin/rm -rf ".a:fname)
|
||||
else
|
||||
call system("del /S ".a:fname)
|
||||
endif
|
||||
if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
|
||||
call system("rmdir /S/Q ".s:QuoteFileDir(a:fname))
|
||||
else
|
||||
call system("/bin/rm -rf ".s:QuoteFileDir(a:fname))
|
||||
endif
|
||||
" call Dret("Rmdir")
|
||||
endfun
|
||||
@ -307,4 +367,4 @@ endfun
|
||||
" Modelines And Restoration: {{{1
|
||||
let &cpo= s:keepcpo
|
||||
unlet s:keepcpo
|
||||
" vim:ts=8 fdm=marker
|
||||
" vim:ts=8 fdm=marker
|
||||
|
||||
Reference in New Issue
Block a user