vim-scripts-20180807ubuntu1/0000755000000000000000000000000013332536306012463 5ustar vim-scripts-20180807ubuntu1/LICENSE.EnhancedCommentify0000644000000000000000000000237413332536300017227 0ustar Copyright (c) 2008 Meikel Brandmeyer, Frankfurt am Main All rights reserved. Redistribution and use in source and binary form are permitted provided that the following conditions are met: 1. Redistribition of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. vim-scripts-20180807ubuntu1/after/0000755000000000000000000000000013332536306013564 5ustar vim-scripts-20180807ubuntu1/after/ftplugin/0000755000000000000000000000000013332536306015414 5ustar vim-scripts-20180807ubuntu1/after/ftplugin/actionscript_snippets.vim0000644000000000000000000000034613332536306022563 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet dm duplicateMovieClip(".st."target".et.", ".st."newName".et.", ".st."depth".et.");" vim-scripts-20180807ubuntu1/after/ftplugin/aspvbs_snippets.vim0000644000000000000000000000137413332536305021360 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet rr Response.Redirect(".st."to".et.")".st.et."" exec "Snippet app Application(\"".st.et."\")".st.et."" exec "Snippet forin For ".st."var".et." in ".st."array".et."".st.et."Next".st.et."" exec "Snippet ifelse If ".st."condition".et." Then".st.et."Else".st.et."End if".st.et."" exec "Snippet rw Response.Write ".st.et."" exec "Snippet sess Session(\"".st.et."\")".st.et."" exec "Snippet rf Request.Form(\"".st.et."\")".st.et."" exec "Snippet rq Request.QueryString(\"".st.et."\")".st.et."" exec "Snippet while While ".st."NOT".et." ".st."condition".et."".st.et."Wend".st.et."" vim-scripts-20180807ubuntu1/after/ftplugin/c.vim0000644000000000000000000000007713332536306016357 0ustar " OmniCppComplete initialization call omni#cpp#complete#Init() vim-scripts-20180807ubuntu1/after/ftplugin/c_snippets.vim0000644000000000000000000000577713332536305020317 0ustar if !exists('loaded_snippet') || &cp finish endif function! Count(haystack, needle) let counter = 0 let index = match(a:haystack, a:needle) while index > -1 let counter = counter + 1 let index = match(a:haystack, a:needle, index+1) endwhile return counter endfunction function! CArgList(count) " This returns a list of empty tags to be used as " argument list placeholders for the call to printf let st = g:snip_start_tag let et = g:snip_end_tag if a:count == 0 return "" else return repeat(', '.st.et, a:count) endif endfunction function! CMacroName(filename) let name = a:filename let name = substitute(name, '\.','_','g') let name = substitute(name, '\(.\)','\u\1','g') return name endfunction let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet do do{".st.et."} while (".st.et.");".st.et exec "Snippet readfile std::vector v;if(FILE* fp = fopen(\"".st."filename".et."\", \"r\")){uint8_t buf[1024];while(size_t len = fread(buf, 1, sizeof(buf), fp))v.insert(v.end(), buf, buf + len);fclose(fp);}".st.et exec "Snippet beginend ".st."v".et.".begin(), ".st."v".et.".end()".st.et exec "Snippet once #ifndef ``CMacroName(expand('%'))``_#define ``CMacroName(expand('%'))``_".st.et."#endif /* ``CMacroName(expand('%'))``_ */" "exec "Snippet once #ifndef _".st."file:substitute(expand('%'),'\\(.\\)','\\u\\1','g')".et."_#define _".st."file".et."_".st.et."#endif /* _".st."file".et."_ */".st.et exec "Snippet class class ".st."name".et."{public:".st."name".et." (".st."arguments".et.");virtual ~".st."name".et."();private:".st.et."};".st.et " TODO This is a good one but I can't quite work out the syntax yet exec "Snippet printf printf(\"".st."\"%s\"".et."\\n\"".st."\"%s\":CArgList(Count(@z, '%[^%]'))".et.");".st.et exec "Snippet vector std::vector<".st."char".et."> v".st.et.";" exec "Snippet struct struct ".st."name".et."{".st.et."};".st.et exec "Snippet template template ".st.et " TODO this one as well. Wish I knew more C " Snippet namespace namespace ${1:${TM_FILENAME/(.*?)\\..*/\\L$1/}}\n{\n\t$0\n};.st.et exec "Snippet namespace namespace ".st.":substitute(expand('%'),'.','\\l&', 'g')".et."{".st.et."};".st.et exec "Snippet map std::map<".st."key".et.", ".st."value".et."> map".st.et.";".st.et exec "Snippet mark #if 0".st.et."#endif".st.et exec "Snippet if if(".st.et."){".st.et."}".st.et exec "Snippet main int main (int argc, char const* argv[]){".st.et."return 0;}".st.et exec "Snippet Inc #include <".st.et.">".st.et exec "Snippet inc #include \"".st.et.".h\"".st.et exec "Snippet for for( ".st.et." ".st."i".et." = ".st.et."; ".st."i".et." < ".st."count".et."; ".st."i".et." += ".st.et."){".st.et."}".st.et vim-scripts-20180807ubuntu1/after/ftplugin/cpp.vim0000644000000000000000000000007713332536305016716 0ustar " OmniCppComplete initialization call omni#cpp#complete#Init() vim-scripts-20180807ubuntu1/after/ftplugin/css_snippets.vim0000644000000000000000000000277413332536306020660 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet visibility ".st.et.";".st.et exec "Snippet list list-style-image: url(".st.et.");".st.et exec "Snippet text text-shadow: rgb(".st.et.", ".st.et.", ".st.et.", ".st.et." ".st.et." ".st.et.";".st.et exec "Snippet overflow overflow: ".st.et.";".st.et exec "Snippet white white-space: ".st.et.";".st.et exec "Snippet clear cursor: url(".st.et.");".st.et exec "Snippet margin padding-top: ".st.et.";".st.et exec "Snippet background background #".st.et." url(".st.et.") ".st.et." ".st.et." top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x% y%/x-pos y-pos')".et.";".st.et exec "Snippet word word-spaceing: ".st.et.";".st.et exec "Snippet z z-index: ".st.et.";".st.et exec "Snippet vertical vertical-align: ".st.et.";".st.et exec "Snippet marker marker-offset: ".st.et.";".st.et exec "Snippet cursor cursor: ".st.et.";".st.et exec "Snippet border border-right: ".st.et."px ".st.et." #".st.et.";".st.et exec "Snippet display display: block;".st.et exec "Snippet padding padding: ".st.et." ".st.et.";".st.et exec "Snippet letter letter-spacing: ".st.et."em;".st.et exec "Snippet color color: rgb(".st.et.", ".st.et.", ".st.et.");".st.et exec "Snippet font font-weight: ".st.et.";".st.et exec "Snippet position position: ".st.et.";".st.et exec "Snippet direction direction: ".st.et.";".st.et exec "Snippet float float: ".st.et.";".st.et vim-scripts-20180807ubuntu1/after/ftplugin/django_model_snippets.vim0000644000000000000000000000543013332536305022501 0ustar if !exists('loaded_snippet') || &cp finish endif function! Count(haystack, needle) let counter = 0 let index = match(a:haystack, a:needle) while index > -1 let counter = counter + 1 let index = match(a:haystack, a:needle, index+1) endwhile return counter endfunction function! DjangoArgList(count) " This needs to be Python specific as print expects a " tuple and an empty tuple looks like this (,) so we'll need to make a " special case for it let st = g:snip_start_tag let et = g:snip_end_tag if a:count == 0 return "()" else return '('.repeat(st.et.', ', a:count).')' endif endfunction let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet mmodel class ".st.et."(models.Model):\"\"\"".st.et."\"\"\"".st.et." = ".st.et."class Admin:passdef __str__(self):return \"".st."s".et."\" % ".st."s:DjangoArgList(Count(@z, '%[^%]'))".et."".st.et exec "Snippet mauto models.AutoField(".st.et.")".st.et exec "Snippet mbool models.BooleanField()".st.et exec "Snippet mchar models.CharField(maxlength=".st."50".et.st.et.")".st.et exec "Snippet mcsi models.CommaSeparatedIntegerField(maxlength=".st."50".et.st.et.")".st.et exec "Snippet mdate models.DateField(".st.et.")".st.et exec "Snippet mdatet models.DateTimeField(".st.et.")".st.et exec "Snippet memail models.EmailField(".st.et.")".st.et exec "Snippet mfile models.FileField(upload_to=\"".st.et."\"".st.et.")".st.et exec "Snippet mfilep models.FilePathField(path=\"".st.et."\"".st.et.")".st.et exec "Snippet mfloat models.FloatField(max_digits=".st.et.", decimal_places=".st.et.")".st.et exec "Snippet mimage models.ImageField(".st.et.")".st.et exec "Snippet mint models.IntegerField(".st.et.")".st.et exec "Snippet mipadd models.IPAddressField(".st.et.")".st.et exec "Snippet mnull models.NullBooleanField()".st.et exec "Snippet mphone models.PhoneNumberField(".st.et.")".st.et exec "Snippet mpint models.PositiveIntegerField(".st.et.")".st.et exec "Snippet mspint models.PositiveSmallIntegerField(".st.et.")".st.et exec "Snippet mslug models.SlugField(".st.et.")".st.et exec "Snippet msint models.SmallIntegerField(".st.et.")".st.et exec "Snippet mtext models.TextField(".st.et.")".st.et exec "Snippet mtime models.TimeField(".st.et.")".st.et exec "Snippet murl models.URLField(verify_exists=".st."True".et.st.et.")".st.et exec "Snippet muss models.USStateField(".st.et.")".st.et exec "Snippet mxml models.XMLField(schema_path=\"".st.et."\"".st.et.")".st.et exec "Snippet mfor models.ForeignKey(".st.et.")".st.et exec "Snippet mm2o models.ForeignKey(".st.et.")".st.et exec "Snippet mm2m models.ManyToManyField(".st.et.")".st.et exec "Snippet mo2o models.OneToOneField(".st.et.")".st.et exec "Snippet mman models.Manager()".st.et vim-scripts-20180807ubuntu1/after/ftplugin/django_template_snippets.vim0000644000000000000000000000361013332536305023212 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet {{ {% templatetag openvariable %}".st.et exec "Snippet }} {% templatetag closevariable %}".st.et exec "Snippet {% {% templatetag openblock %}".st.et exec "Snippet %} {% templatetag closeblock %}".st.et exec "Snippet now {% now \"".st.et."\" %}".st.et exec "Snippet firstof {% firstof ".st.et." %}".st.et exec "Snippet ifequal {% ifequal ".st.et." ".st.et." %}".st.et."{% endifequal %}".st.et exec "Snippet ifchanged {% ifchanged %}".st.et."{% endifchanged %}".st.et exec "Snippet regroup {% regroup ".st.et." by ".st.et." as ".st.et." %}".st.et exec "Snippet extends {% extends \"".st.et."\" %}".st.et exec "Snippet filter {% filter ".st.et." %}".st.et."{% endfilter %}".st.et exec "Snippet block {% block ".st.et." %}".st.et."{% endblock %}".st.et exec "Snippet cycle {% cycle ".st.et." as ".st.et." %}".st.et exec "Snippet if {% if ".st.et." %}".st.et."{% endif %}".st.et exec "Snippet debug {% debug %}".st.et exec "Snippet ifnotequal {% ifnotequal ".st.et." ".st.et." %}".st.et."{% endifnotequal %}".st.et exec "Snippet include {% include ".st.et." %}".st.et exec "Snippet comment {% comment %}".st.et."{% endcomment %}".st.et exec "Snippet for {% for ".st.et." in ".st.et." %}".st.et."{% endfor %}".st.et exec "Snippet ssi {% ssi ".st.et." ".st.et." %}".st.et exec "Snippet widthratio {% widthratio ".st.et." ".st.et." ".st.et." %}".st.et exec "Snippet load {% load ".st.et." %}".st.et " Field snippet contributed by Alex Pounds exec "Snippet field

{{ form.".st."fieldname".et." }}{% if form.".st."fieldname".et.".errors %}*** {{ form.".st."fieldname".et.".errors|join:\", \" }} {% endif %}

".st.et vim-scripts-20180807ubuntu1/after/ftplugin/f-script_snippets.vim0000644000000000000000000000107013332536305021602 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet tbd to:".st.et." by:".st.et." do:[ ".st.et." |".st.et."].".st.et exec "Snippet it ifTrue:[".st.et."].".st.et exec "Snippet ift ifFalse:[".st.et."] ifTrue:[".st.et."].".st.et exec "Snippet itf ifTrue:[".st.et."] ifFalse:[".st.et."].".st.et exec "Snippet td to:".st.et." do:[".st.et." ".st.et." |".st.et."].".st.et exec "Snippet if ifFalse:[".st.et."].".st.et vim-scripts-20180807ubuntu1/after/ftplugin/haskell_snippets.vim0000644000000000000000000000027613332536305021505 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet mod module: ".st.et." where".st.et vim-scripts-20180807ubuntu1/after/ftplugin/html_snippets.vim0000644000000000000000000001175313332536305021030 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim function! SelectDoctype() let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim let dt = inputlist(['Select doctype:', \ '1. HTML 4.01', \ '2. HTML 4.01 Transitional', \ '3. HTML 4.01 Frameset', \ '4. XHTML 1.0 Frameset', \ '5. XHTML Strict', \ '6. XHTML Transitional', \ '7. XHTML Frameset']) let dts = {1: "\n".st.et, \ 2: "\n".st.et, \ 3: "\n".st.et, \ 4: "\n".st.et, \ 5: "\n".st.et, \ 6: "\n".st.et, \ 7: "\n".st.et} return dts[dt] endfunction exec "Snippet doct ``SelectDoctype()``" exec "Snippet doctype \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">".st.et exec "Snippet doc4s \"http://www.w3.org/TR/html4/strict.dtd\">".st.et exec "Snippet doc4t \"http://www.w3.org/TR/html4/loose.dtd\">".st.et exec "Snippet doc4f \"http://www.w3.org/TR/html4/frameset.dtd\">".st.et exec "Snippet docxs \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">".st.et exec "Snippet docxt \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">".st.et exec "Snippet docxf \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">".st.et exec "Snippet head ".st.et."".st.et."".st.et exec "Snippet script ".st.et exec "Snippet title ".st.et."" exec "Snippet body ".st.et."".st.et exec "Snippet scriptsrc ".st.et exec "Snippet textarea ".st.et exec "Snippet meta ".st.et exec "Snippet movie classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\"codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">value=\"".st.et."\" />width=\"".st.et."\" height=\"".st.et."\"controller=\"".st.et."\" autoplay=\"".st.et."\"scale=\"tofit\" cache=\"true\"pluginspage=\"http://www.apple.com/quicktime/download/\"/>".st.et exec "Snippet div
".st.et."
".st.et exec "Snippet mailto ".st.et."".st.et exec "Snippet table
".st.et."
".st.et."
" exec "Snippet link " exec "Snippet form
".st.et."

".st.et exec "Snippet ref ".st.et."".st.et exec "Snippet h1

".st.et."

".st.et exec "Snippet input ".st.et exec "Snippet style ".st.et exec "Snippet base ".st.et vim-scripts-20180807ubuntu1/after/ftplugin/java_snippets.vim0000644000000000000000000001026313332536305021000 0ustar if !exists('loaded_snippet') || &cp finish endif function! UpFirst() return substitute(@z,'.','\u&','') endfunction function! JavaTestFileName(type) let filepath = expand('%:p') let filepath = substitute(filepath, '/','.','g') let filepath = substitute(filepath, '^.\(:\\\)\?','','') let filepath = substitute(filepath, '\','.','g') let filepath = substitute(filepath, ' ','','g') let filepath = substitute(filepath, '.*test.','','') if a:type == 1 let filepath = substitute(filepath, '.[A-Za-z]*.java','','g') elseif a:type == 2 let filepath = substitute(filepath, 'Tests.java','','') elseif a:type == 3 let filepath = substitute(filepath, '.*\.\([A-Za-z]*\).java','\1','g') elseif a:type == 4 let filepath = substitute(filepath, 'Tests.java','','') let filepath = substitute(filepath, '.*\.\([A-Za-z]*\).java','\1','g') elseif a:type == 5 let filepath = substitute(filepath, 'Tests.java','','') let filepath = substitute(filepath, '.*\.\([A-Za-z]*\).java','\1','g') let filepath = substitute(filepath, '.','\l&','') endif return filepath endfunction let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet method // {{{ ".st."method".et."/** * ".st.et." */public ".st."return".et." ".st."method".et."() {".st.et."}// }}}".st.et exec "Snippet jps private static final ".st."string".et." ".st.et." = \"".st.et."\";".st.et exec "Snippet jtc try {".st.et."} catch (".st.et." e) {".st.et."} finally {".st.et."}".st.et exec "Snippet jlog /** Logger for this class and subclasses. */protected final Log log = LogFactory.getLog(getClass());".st.et exec "Snippet jpv private ".st."string".et." ".st.et.";".st.et exec "Snippet bean // {{{ set".st."fieldName:UpFirst()".et."/** * Setter for ".st."fieldName".et.". * @param new".st."fieldName:UpFirst()".et." new value for ".st."fieldName".et." */public void set".st."fieldName:UpFirst()".et."(".st."String".et." new".st."fieldName:UpFirst()".et.") {".st."fieldName".et." = new".st."fieldName:UpFirst()".et.";}// }}}// {{{ get".st."fieldName:UpFirst()".et."/** * Getter for ".st."fieldName".et.". * @return ".st."fieldName".et." */public ".st."String".et." get".st."fieldName:UpFirst()".et."() {return ".st."fieldName".et.";}// }}}".st.et exec "Snippet jwh while (".st.et.") { // ".st.et."".st.et."}".st.et exec "Snippet sout System.out.println(\"".st.et."\");".st.et exec "Snippet jtest package ".st."j:JavaTestFileName(1)".et."import junit.framework.TestCase;import ".st."j:JavaTestFileName(2)".et.";/** * ".st."j:JavaTestFileName(3)".et." * * @author ".st.et." * @since ".st.et." */public class ".st."j:JavaTestFileName(3)".et." extends TestCase {private ".st."j:JavaTestFileName(4)".et." ".st."j:JavaTestFileName(5)".et.";public ".st."j:JavaTestFileName(4)".et." get".st."j:JavaTestFileName(4)".et."() { return this.".st."j:JavaTestFileName(5)".et."; }public void set".st."j:JavaTestFileName(4)".et."(".st."j:JavaTestFileName(4)".et." ".st."j:JavaTestFileName(5)".et.") { this.".st."j:JavaTestFileName(5)".et." = ".st."j:JavaTestFileName(5)".et."; }public void test".st.et."() {".st.et."}}".st.et exec "Snippet jif if (".st.et.") { // ".st.et."".st.et."}".st.et exec "Snippet jelse if (".st.et.") { // ".st.et."".st.et."} else { // ".st.et."".st.et."}".st.et exec "Snippet jpm /** * ".st.et." * * @param ".st.et." ".st.et." * ".st.et." ".st.et." */private ".st."void".et." ".st.et."(".st."String".et." ".st.et.") {".st.et."}".st.et exec "Snippet main public main static void main(String[] ars) {".st."\"System.exit(0)\"".et.";}".st.et exec "Snippet jpum /** * ".st.et." * * @param ".st.et." ".st.et." *".st.et." ".st.et." */public ".st."void".et." ".st.et."(".st."String".et." ".st.et.") {".st.et."}".st.et exec "Snippet jcout ".st.et vim-scripts-20180807ubuntu1/after/ftplugin/javascript_snippets.vim0000644000000000000000000000056313332536306022230 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet proto ".st."className".et.".prototype.".st."methodName".et." = function(".st.et."){".st.et."};".st.et exec "Snippet fun function ".st."functionName".et." (".st.et."){".st.et."}".st.et vim-scripts-20180807ubuntu1/after/ftplugin/latex_snippets.vim0000644000000000000000000000112213332536306021167 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet sub \\subsection{".st."name".et."}\\label{sub:".st."name:substitute(@z,'.','\\l&','g')".et."}".st.et exec "Snippet $$ \\[".st.et."\\]".st.et exec "Snippet ssub \\subsubsection{".st."name".et."}\\label{ssub:".st."name:substitute(@z,'.','\\l&','g')".et."}".st.et exec "Snippet itd \\item[".st."desc".et."] ".st.et exec "Snippet sec \\section{".st."name".et."}\\label{sec:".st."name:substitute(@z,'.','\\l&','g')".et."}".st.et vim-scripts-20180807ubuntu1/after/ftplugin/logo_snippets.vim0000644000000000000000000000033513332536305021016 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet to to ".st."name".et." ".st."argument".et."".st.et."end".st.et vim-scripts-20180807ubuntu1/after/ftplugin/markdown_snippets.vim0000644000000000000000000000040413332536305021675 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet img ![".st."altText".et."](".st."SRC".et.")".st.et exec "Snippet link [".st."desc".et."](".st."HREF".et.")".st.et vim-scripts-20180807ubuntu1/after/ftplugin/movable_type_snippets.vim0000644000000000000000000000076413332536306022553 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet cat <$MTCategoryDescription$>".st.et exec "Snippet blog <$MTBlogName$>".st.et exec "Snippet archive <$MTArchiveFile$>".st.et exec "Snippet cal ".st.et."".st.et exec "Snippet entry <$MTEntryMore$>".st.et exec "Snippet entries ".st.et."".st.et vim-scripts-20180807ubuntu1/after/ftplugin/objc_snippets.vim0000644000000000000000000000575013332536306021002 0ustar if !exists('loaded_snippet') || &cp finish endif function! UpFirst() return substitute(@z,'.','\u&','') endfunction function! Count(haystack, needle) let counter = 0 let index = match(a:haystack, a:needle) while index > -1 let counter = counter + 1 let index = match(a:haystack, a:needle, index+1) endwhile return counter endfunction function! ObjCArgList(count) let st = g:snip_start_tag let et = g:snip_end_tag if a:count == 0 return st.et else return st.et.repeat(', '.st.et, a:count) endif endfunction let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet cat @interface ".st."NSObject".et." (".st."Category".et.")@end@implementation ".st."NSObject".et." (".st."Category".et.")".st.et."@end".st.et exec "Snippet delacc - (id)delegate;- (void)setDelegate:(id)delegate;".st.et exec "Snippet ibo IBOutlet ".st."NSSomeClass".et." *".st."someClass".et.";".st.et exec "Snippet dict NSMutableDictionary *".st."dict".et." = [NSMutableDictionary dictionary];".st.et exec "Snippet Imp #import <".st.et.".h>".st.et exec "Snippet objc @interface ".st."class".et." : ".st."NSObject".et."{}@end@implementation ".st."class".et."- (id)init{self = [super init]; if (self != nil){".st.et."}return self;}@end".st.et exec "Snippet imp #import \"".st.et.".h\"".st.et exec "Snippet bez NSBezierPath *".st."path".et." = [NSBezierPath bezierPath];".st.et exec "Snippet acc - (".st."\"unsigned int\"".et.")".st."thing".et."{return ".st."fThing".et.";}- (void)set".st."thing:UpFirst()".et.":(".st."\"unsigned int\"".et.")new".st."thing:UpFirst()".et."{".st."fThing".et." = new".st."thing:UpFirst()".et.";}".st.et exec "Snippet format [NSString stringWithFormat:@\"".st.et."\", ".st.et."]".st.et exec "Snippet focus [self lockFocus];".st.et."[self unlockFocus];".st.et exec "Snippet setprefs [[NSUserDefaults standardUserDefaults] setObject:".st."object".et." forKey:".st."key".et."];".st.et exec "Snippet log NSLog(@\"%s".st."s".et."\", ".st."s:ObjCArgList(Count(@z, '%[^%]'))".et.");".st.et exec "Snippet gsave [NSGraphicsContext saveGraphicsState];".st.et."[NSGraphicsContext restoreGraphicsState];".st.et exec "Snippet forarray for(unsigned int index = 0; index < [".st."array".et." count]; index += 1){".st."id".et."object = [".st."array".et." objectAtIndex:index];".st.et."}".st.et exec "Snippet classi @interface ".st."ClassName".et." : ".st."NSObject".et."{".st.et."}".st.et."@end".st.et exec "Snippet array NSMutableArray *".st."array".et." = [NSMutableArray array];".st.et exec "Snippet getprefs [[NSUserDefaults standardUserDefaults] objectForKey:];".st.et exec "Snippet cati @interface ".st."NSObject".et." (".st."Category".et.")".st.et."@end".st.et vim-scripts-20180807ubuntu1/after/ftplugin/ocaml_snippets.vim0000644000000000000000000000252513332536305021154 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet Queue Queue.fold ".st.et." ".st."base".et." ".st."q".et."".st.et exec "Snippet Nativeint Nativeint.abs ".st."ni".et.st.et exec "Snippet Printexc Printexc.print ".st."fn".et." ".st."x".et.st.et exec "Snippet Sys Sys.Signal_ignore".st.et exec "Snippet Hashtbl Hashtbl.iter ".st.et." ".st."h".et.st.et exec "Snippet Array Array.map ".st.et." ".st."arr".et.st.et exec "Snippet Printf Printf.fprintf ".st."buf".et." \"".st."format".et."\" ".st."args".et.st.et exec "Snippet Stream Stream.iter ".st.et." ".st."stream".et.st.et exec "Snippet Buffer Buffer.add_channel ".st."buf".et." ".st."ic".et." ".st."len".et.st.et exec "Snippet Int32 Int32.abs ".st."i32".et.st.et exec "Snippet List List.rev_map ".st.et." ".st."lst".et.st.et exec "Snippet Scanf Scanf.bscaf ".st."sbuf".et." \"".st."format".et."\" ".st."f".et.st.et exec "Snippet Int64 Int64.abs ".st."i64".et.st.et exec "Snippet Map Map.Make ".st.et exec "Snippet String String.iter ".st.et." ".st."str".et.st.et exec "Snippet Genlex Genlex.make_lexer ".st."\"tok_lst\"".et." ".st."\"char_stream\"".et.st.et exec "Snippet for for ".st."i}".et." = ".st.et." to ".st.et." do".st.et."done".st.et exec "Snippet Stack Stack.iter ".st.et." ".st."stk".et.st.et vim-scripts-20180807ubuntu1/after/ftplugin/perl_snippets.vim0000644000000000000000000000324113332536306021020 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet sub sub ".st."FunctionName".et." {".st.et."}".st.et exec "Snippet class package ".st."ClassName".et.";".st.et.st."ParentClass".et.st.et.";sub new {my \$class = shift;\$class = ref \$class if ref \$class;my $self = bless {}, \$class;\$self;}1;".st.et exec "Snippet xfore ".st."expression".et." foreach @".st."array".et.";".st.et exec "Snippet xwhile ".st."expression".et." while ".st."condition".et.";".st.et exec "Snippet xunless ".st."expression".et." unless ".st."condition".et.";".st.et exec "Snippet slurp my $".st."var".et.";{ local $/ = undef; local *FILE; open FILE, \"<".st."file".et.">\"; $".st."var".et." = ; close FILE }".st.et exec "Snippet if if (".st.et.") {".st.et."}".st.et exec "Snippet unless unless (".st.et.") {".st.et."}".st.et exec "Snippet ifee if (".st.et.") {".st.et."} elsif (".st.et.") {".st.et."} else {".st.et."}".st.et exec "Snippet ife if (".st.et.") {".st.et."} else {".st.et."}".st.et exec "Snippet for for (my \$".st."var".et." = 0; \$".st."var".et." < ".st."expression".et."; \$".st."var".et."++) {".st.et."}".st.et exec "Snippet fore foreach my \$".st."var".et." (@".st."array".et.") {".st.et."}".st.et exec "Snippet eval eval {".st.et."};if ($@) {".st.et."}".st.et exec "Snippet while while (".st.et.") {".st.et."}".st.et exec "Snippet xif ".st."expression".et." if ".st."condition".et.";".st.et vim-scripts-20180807ubuntu1/after/ftplugin/php_snippets.vim0000644000000000000000000000443713332536306020655 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet elseif elseif ( ".st."condition".et." ){".st.et."}".st.et exec "Snippet do do{".st.et."} while ( ".st.et." );".st.et exec "Snippet reql require_once( '".st."file".et."' );".st.et exec "Snippet if? $".st."retVal".et." = ( ".st."condition".et." ) ? ".st."a".et." : ".st."b".et." ;".st.et exec "Snippet phpp ".st.et."?>" exec "Snippet switch switch ( ".st."variable".et." ){case '".st."value".et."':".st.et."break;".st.et."default:".st.et."break;}".st.et exec "Snippet class #doc#classname:".st."ClassName".et."#scope:".st."PUBLIC".et."##/docclass ".st."ClassName".et." ".st."extendsAnotherClass".et."{#internal variables#Constructorfunction __construct ( ".st."argument".et."){".st.et."}###}###".st.et exec "Snippet incll include_once( '".st."file".et."' );".st.et exec "Snippet incl include( '".st."file".et."' );".st.et exec "Snippet foreach foreach( $".st."variable".et." as $".st."key".et." => $".st."value".et." ){".st.et."}".st.et exec "Snippet ifelse if ( ".st."condition".et." ){".st.et."}else{".st.et."}".st.et exec "Snippet $_ $_REQUEST['".st."variable".et."']".st.et exec "Snippet case case '".st."variable".et."':".st.et."break;".st.et exec "Snippet print print \"".st."string".et."\"".st.et.";".st.et."".st.et exec "Snippet function ".st."public".et."function ".st."FunctionName".et." (".st.et."){".st.et."}".st.et exec "Snippet if if ( ".st."condition".et." ){".st.et."}".st.et exec "Snippet else else{".st.et."}".st.et exec "Snippet array $".st."arrayName".et." = array( '".st.et."',".st.et." );".st.et exec "Snippet -globals $GLOBALS['".st."variable".et."']".st.et.st."something".et.st.et.";".st.et exec "Snippet req require( '".st."file".et."' );".st.et exec "Snippet for for ( $".st."i".et."=".st.et."; $".st."i".et." < ".st.et."; $".st."i".et."++ ){ ".st.et."}".st.et exec "Snippet while while ( ".st.et." ){".st.et."}".st.et vim-scripts-20180807ubuntu1/after/ftplugin/phpdoc_snippets.vim0000644000000000000000000000364213332536305021337 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet doc_d /*** ".st."undocumentedConstant".et."**/define(".st.et.", ".st.et.");".st.et."".st.et exec "Snippet doc_vp /*** ".st."undocumentedClassVariable".et."** @var ".st."string".et.st.et."**/".st.et."" exec "Snippet doc_f /*** ".st."undocumentedFunction".et."** @return ".st."void".et."* @author ".st.et."**/".st.et."function ".st.et."(".st.et."){".st.et."}".st.et exec "Snippet doc_s /*** ".st."undocumentedFunction".et."** @return ".st."void".et."* @author ".st.et."**/".st.et."function ".st.et."(".st.et.");".st.et exec "Snippet doc_h /*** ".st.et."** @author ".st.et."* @version $Id$* @copyright ".st.et.", ".st.et."* @package ".st."default".et."**//*** Define DocBlock**/".st.et exec "Snippet doc_fp /*** ".st."undocumentedFunction".et."** @return ".st."void".et."* @author ".st.et."**/".st.et."" exec "Snippet doc_i /*** ".st."undocumentedClass".et."** @package ".st."default".et."* @author ".st.et."**/interface ".st.et."{".st.et."} // END interface ".st.et."".st.et exec "Snippet doc_fp /*** ".st."undocumentedConstant".et.st.et."**/".st.et."".st.et exec "Snippet doc_v /*** ".st."undocumentedClassVariable".et."** @var ".st."string".et."**/ $".st.et.";".st.et."".st.et exec "Snippet doc_cp /*** ".st."undocumentedClass".et."** @package ".st."default".et."* @author ".st.et."**/".st.et exec "Snippet doc_c /*** ".st."undocumentedClass".et."** @package ".st."default".et."* @author ".st.et."**/".st."class".et."class ".st."a".et."{".st.et."} // END ".st."class".et."class ".st."a".et."".st.et vim-scripts-20180807ubuntu1/after/ftplugin/propel_snippets.vim0000644000000000000000000000157613332536306021370 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet ".st.et exec "Snippet ".st.et."".st.et exec "Snippet ".st.et exec "Snippet ".st.et exec "Snippet

".st.et exec "Snippet \"/>".st.et vim-scripts-20180807ubuntu1/after/ftplugin/python_snippets.vim0000644000000000000000000001523713332536306021407 0ustar if !exists('loaded_snippet') || &cp finish endif " Given a string containing a list of arguments (e.g. "one, two = 'test'"), " this function cleans it up by removing useless whitespace and commas. function! PyCleanupArgs(text) if a:text == 'args' return '' endif let text = substitute(a:text, '\(\w\)\s\(\w\)', '\1,\2', 'g') return join(split(text, '\s*,\s*'), ', ') endfunction " Given a string containing a list of arguments (e.g. "one = 'test', *args, " **kwargs"), this function returns a string containing only the variable " names, separated by spaces, e.g. "one two". function! PyGetVarnamesFromArgs(text) let text = substitute(a:text, 'self,*\s*', '', '') let text = substitute(text, '\*\*\?\k\+', '', 'g') let text = substitute(text, '=.\{-},', '', 'g') let text = substitute(text, '=.\{-}$', '', 'g') let text = substitute(text, '\s*,\s*', ' ', 'g') if text == ' ' return '' endif return text endfunction " Returns the current indent as a string. function! PyGetIndentString() if &expandtab let tabs = indent('.') / &shiftwidth let tabstr = repeat(' ', &shiftwidth) else let tabs = indent('.') / &tabstop let tabstr = '\t' endif return repeat(tabstr, tabs) endfunction " Given a string containing a list of arguments (e.g. "one = 'test', *args, " **kwargs"), this function returns them formatted correctly for the " docstring. function! PyGetDocstringFromArgs(text) let text = PyGetVarnamesFromArgs(a:text) if a:text == 'args' || text == '' return '' endif let indent = PyGetIndentString() let st = g:snip_start_tag let et = g:snip_end_tag let docvars = map(split(text), 'v:val." -- ".st.et') return '\n'.indent.join(docvars, '\n'.indent).'\n'.indent endfunction " Given a string containing a list of arguments (e.g. "one = 'test', *args, " **kwargs"), this function returns them formatted as a variable assignment in " the form "self._ONE = ONE", as used in class constructors. function! PyGetVariableInitializationFromVars(text) let text = PyGetVarnamesFromArgs(a:text) if a:text == 'args' || text == '' return '' endif let indent = PyGetIndentString() let st = g:snip_start_tag let et = g:snip_end_tag let assert_vars = map(split(text), '"assert ".v:val." ".st.et') let assign_vars = map(split(text), '"self._".v:val." = ".v:val') let assertions = join(assert_vars, '\n'.indent) let assignments = join(assign_vars, '\n'.indent) return assertions.'\n'.indent.assignments.'\n'.indent endfunction " Given a string containing a list of arguments (e.g. "one = 'test', *args, " **kwargs"), this function returns them with the default arguments removed. function! PyStripDefaultValue(text) return substitute(a:text, '=.*', '', 'g') endfunction " Returns the number of occurences of needle in haystack. function! Count(haystack, needle) let counter = 0 let index = match(a:haystack, a:needle) while index > -1 let counter = counter + 1 let index = match(a:haystack, a:needle, index+1) endwhile return counter endfunction " Returns replacement if the given subject matches the given match. " Returns the subject otherwise. function! PyReplace(subject, match, replacement) if a:subject == a:match return a:replacement endif return a:subject endfunction " Returns the % operator with a tuple containing n elements appended, where n " is the given number. function! PyHashArgList(count) if a:count == 0 return '' endif let st = g:snip_start_tag let et = g:snip_end_tag return ' % ('.st.et.repeat(', '.st.et, a:count - 1).')' endfunction let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim " Note to users: The following method of defininf snippets is to allow for " changes to the default tags. " Feel free to define your own as so: " Snippet mysnip This is the expansion text.<{}> " There is no need to use exec if you are happy to hardcode your own start and " end tags " Properties, setters and getters. exec "Snippet prop ".st."attribute".et." = property(get_".st."attribute".et.", set_".st."attribute".et.st.et.")".st.et exec "Snippet get def get_".st."name".et."(self):return self._".st."name".et."".st.et exec "Snippet set def set_".st."name".et."(self, ".st."value".et."): \self._".st."name".et." = ".st."value:PyStripDefaultValue(@z)".et." \".st.et " Functions and methods. exec "Snippet def def ".st."fname".et."(".st."args:PyCleanupArgs(@z)".et."): \\"\"\" \".st.et." \".st."args:PyGetDocstringFromArgs(@z)".et."\"\"\" \".st."pass".et." \".st.et exec "Snippet cm ".st."class".et." = classmethod(".st."class".et.")".st.et " Class definition. exec "Snippet cl class ".st."ClassName".et."(".st."object".et."): \\"\"\" \This class represents ".st.et." \\"\"\" \ \def __init__(self, ".st."args:PyCleanupArgs(@z)".et."): \\"\"\" \Constructor. \".st."args:PyGetDocstringFromArgs(@z)".et."\"\"\" \".st."args:PyGetVariableInitializationFromVars(@z)".et.st.et " Keywords exec "Snippet for for ".st."variable".et." in ".st."ensemble".et.":".st."pass".et."".st.et exec "Snippet pf print '".st."s".et."'".st."s:PyHashArgList(Count(@z, '%[^%]'))".et."".st.et exec "Snippet im import ".st."module".et."".st.et exec "Snippet from from ".st."module".et." import ".st.'name:PyReplace(@z, "name", "*")'.et."".st.et exec "Snippet % '".st."s".et."'".st."s:PyHashArgList(Count(@z, '%[^%]'))".et.st.et exec "Snippet ass assert ".st."expression".et.st.et " From Kib2 exec "Snippet bc \"\"\"".st.et."\"\"\"".st.et " Try, except, finally. exec "Snippet trye try: \".st.et." \except Exception, e: \".st.et." \".st.et exec "Snippet tryf try: \".st.et." \finally: \".st.et." \".st.et exec "Snippet tryef try: \".st.et." \except Exception, e: \".st.et." \finally: \".st.et." \".st.et " Other multi statement templates " From Panos exec "Snippet ifn if __name__ == '".st."main".et."':".st.et exec "Snippet ifmain if __name__ == '__main__':".st.et " Shebang exec "Snippet sb #!/usr/bin/env python# -*- coding: ".st."encoding".et." -*-".st.et exec "Snippet sbu #!/usr/bin/env python# -*- coding: UTF-8 -*-".st.et " From Kib2 exec "Snippet sbl1 #!/usr/bin/env python# -*- coding: Latin-1 -*-".st.et " Unit tests. exec "Snippet unittest if __name__ == '__main__': \import unittest \ \class ".st."ClassName".et."Test(unittest.TestCase): \def setUp(self): \".st."pass".et." \ \def runTest(self): \".st.et vim-scripts-20180807ubuntu1/after/ftplugin/rails_snippets.vim0000644000000000000000000001023713332536306021173 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet mrnt rename_table \"".st."oldTableName".et."\", \"".st."newTableName".et."\"".st.et exec "Snippet rfu render :file => \"".st."filepath".et."\", :use_full_path => ".st."false".et.st.et exec "Snippet rns render :nothing => ".st."true".et.", :status => ".st.et.st.et exec "Snippet ri render :inline => \"".st.et."\")>\"".st.et exec "Snippet rt render :text => \"".st.et."\"".st.et exec "Snippet mcc t.column \"".st."title".et."\", :".st."string".et.st.et exec "Snippet rpl render :partial => \"".st."item".et."\", :locals => { :".st."name".et." => \"".st."value".et."\"".st.et." }".st.et exec "Snippet rea redirect_to :action => \"".st."index".et."\"".st.et exec "Snippet rtlt render :text => \"".st.et."\", :layout => ".st."true".et.st.et exec "Snippet ft <%= form_tag :action => \"".st."update".et."\" %>".st.et exec "Snippet forin <% for ".st."item".et." in ".st.et." %><%= ".st."item".et.".".st."name".et." %><% end %>".st.et exec "Snippet lia <%= link_to \"".st.et."\", :action => \"".st."index".et."\" %>".st.et exec "Snippet rl render :layout => \"".st."layoutname".et."\"".st.et exec "Snippet ra render :action => \"".st."action".et."\"".st.et exec "Snippet mrnc rename_column \"".st."table".et."\", \"".st."oldColumnName".et."\", \"".st."newColumnName".et."\"".st.et exec "Snippet mac add_column \"".st."table".et."\", \"".st."column".et."\", :".st."string".et.st.et exec "Snippet rpc render :partial => \"".st."item".et."\", :collection => ".st."items".et.st.et exec "Snippet rec redirect_to :controller => \"".st."items".et."\"".st.et exec "Snippet rn render :nothing => ".st."true".et.st.et exec "Snippet lic <%= link_to \"".st.et."\", :controller => \"".st.et."\" %>".st.et exec "Snippet rpo render :partial => \"".st."item".et."\", :object => ".st."object".et.st.et exec "Snippet rts render :text => \"".st.et."\", :status => ".st.et exec "Snippet rcea render_component :action => \"".st."index".et."\"".st.et exec "Snippet recai redirect_to :controller => \"".st."items".et."\", :action => \"".st."show".et."\", :id => ".st.et exec "Snippet mcdt create_table \"".st."table".et."\" do |t|".st.et."end".st.et exec "Snippet ral render :action => \"".st."action".et."\", :layout => \"".st."layoutname".et."\"".st.et exec "Snippet rit render :inline => \"".st.et."\", :type => ".st.et exec "Snippet rceca render_component :controller => \"".st."items".et."\", :action => \"".st."index".et."\"".st.et exec "Snippet licai <%= link_to \"".st.et."\", :controller => \"".st."items".et."\", :action => \"".st."edit".et."\", :id => ".st.et." %>".st.et exec "Snippet verify verify :only => [:".st.et."], :method => :post, :render => {:status => 500, :text => \"use HTTP-POST\"}".st.et exec "Snippet mdt drop_table \"".st."table".et."\"".st.et exec "Snippet rp render :partial => \"".st."item".et."\"".st.et exec "Snippet rcec render_component :controller => \"".st."items".et."\"".st.et exec "Snippet mrc remove_column \"".st."table".et."\", \"".st."column".et."\"".st.et exec "Snippet mct create_table \"".st."table".et."\" do |t|".st.et."end".st.et exec "Snippet flash flash[:".st."notice".et."] = \"".st.et."\"".st.et exec "Snippet rf render :file => \"".st."filepath".et."\"".st.et exec "Snippet lica <%= link_to \"".st.et."\", :controller => \"".st."items".et."\", :action => \"".st."index".et."\" %>".st.et exec "Snippet liai <%= link_to \"".st.et."\", :action => \"".st."edit".et."\", :id => ".st.et." %>".st.et exec "Snippet reai redirect_to :action => \"".st."show".et."\", :id => ".st.et exec "Snippet logi logger.info \"".st.et."\"".st.et exec "Snippet marc add_column \"".st."table".et."\", \"".st."column".et."\", :".st."string".et."".st.et."".st.et exec "Snippet rps render :partial => \"".st."item".et."\", :status => ".st.et exec "Snippet ril render :inline => \"".st.et."\", :locals => { ".st.et." => \"".st."value".et."\"".st.et." }".st.et exec "Snippet rtl render :text => \"".st.et."\", :layout => \"".st.et."\"".st.et exec "Snippet reca redirect_to :controller => \"".st."items".et."\", :action => \"".st."list".et."\"".st.et vim-scripts-20180807ubuntu1/after/ftplugin/ruby_snippets.vim0000644000000000000000000000462013332536305021040 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet do do".st.et."end".st.et exec "Snippet class class ".st."className".et."".st.et."end".st.et exec "Snippet begin begin".st.et."rescue ".st."Exception".et." => ".st."e".et."".st.et."end".st.et exec "Snippet each_with_index0 each_with_index do |".st."element".et.", ".st."index".et."|".st."element".et.".".st.et."end".st.et exec "Snippet collect collect { |".st."element".et."| ".st."element".et.".".st.et." }".st.et exec "Snippet forin for ".st."element".et." in ".st."collection".et."".st."element".et.".".st.et."end".st.et exec "Snippet doo do |".st."object".et."|".st.et."end".st.et exec "Snippet : :".st."key".et." => \"".st."value".et."\"".st.et."".st.et exec "Snippet def def ".st."methodName".et."".st.et."end".st.et exec "Snippet case case ".st."object".et."when ".st."condition".et."".st.et."end".st.et exec "Snippet collecto collect do |".st."element".et."|".st."element".et.".".st.et."end".st.et exec "Snippet each each { |".st."element".et."| ".st."element".et.".".st.et." }".st.et exec "Snippet each_with_index each_with_index { |".st."element".et.", ".st."idx".et."| ".st."element".et.".".st.et." }".st.et exec "Snippet if if ".st."condition".et."".st.et."end".st.et exec "Snippet eacho each do |".st."element".et."|".st."element".et.".".st.et."end".st.et exec "Snippet unless unless ".st."condition".et."".st.et."end".st.et exec "Snippet ife if ".st."condition".et."".st.et."else".st.et."end".st.et exec "Snippet when when ".st."condition".et."".st.et exec "Snippet selecto select do |".st."element".et."|".st."element".et.".".st.et."end".st.et exec "Snippet injecto inject(".st."object".et.") do |".st."injection".et.", ".st."element".et."| ".st.et."end".st.et exec "Snippet reject { |".st."element".et."| ".st."element".et.".".st.et." }".st.et exec "Snippet rejecto reject do |".st."element".et."| ".st."element".et.".".st.et."end".st.et exec "Snippet inject inject(".st."object".et.") { |".st."injection".et.", ".st."element".et."| ".st.et." }".st.et exec "Snippet select select { |".st."element".et."| ".st."element".et.".".st.et." }".st.et vim-scripts-20180807ubuntu1/after/ftplugin/sh_snippets.vim0000644000000000000000000000075013332536305020471 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim "Snippet !env #!/usr/bin/env ${1:${TM_SCOPE/(?:source|.*)\\.(\\w+).*/$1/}} exec "Snippet if if [[ ".st."condition".et." ]]; then".st.et."fi".st.et exec "Snippet elif elif [[ ".st."condition".et." ]]; then".st.et exec "Snippet for for (( ".st."i".et." = ".st.et."; ".st."i".et." ".st.et."; ".st."i".et.st.et." )); do".st.et."done".st.et vim-scripts-20180807ubuntu1/after/ftplugin/slate_snippets.vim0000644000000000000000000000207213332536305021166 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet do do: [| :".st."each".et."| ".st.et."]".st.et exec "Snippet proto define: #".st."NewName".et." &parents: {".st."parents".et."} &slots: {".st."slotSpecs".et."}.".st.et exec "Snippet ifte ".st."condition".et." ifTrue: [".st.et.":then] ifFalse: [".st.et.":else]".st.et exec "Snippet collect collect: [| :".st."each".et."| ".st.et."]".st.et exec "Snippet if ".st."condition".et." ifTrue: [".st.et.":then]".st.et exec "Snippet until [".st."condition".et."] whileFalse: [".st.et.":body]".st.et exec "Snippet reject reject: [| :".st."each".et."| ".st.et."]".st.et exec "Snippet dowith doWithIndex: [| :".st."each".et." :".st."index".et." | ".st.et."]".st.et exec "Snippet select select: [| :".st."each".et."| ".st.et."]".st.et exec "Snippet while [".st."condition".et."] whileTrue: [".st.et.":body]".st.et exec "Snippet inject inject: ".st."object".et." [| :".st."injection".et.", :".st."each".et."| ".st.et."]".st.et vim-scripts-20180807ubuntu1/after/ftplugin/smarty_snippets.vim0000644000000000000000000000470413332536305021401 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet {cycle {cycle values=\"#SELSTART#".st."foo".et.",".st."bar".et."#SELEND#\" name=\"default\" print=true advance=true delimiter=\",\" assign=varname }".st.et exec "Snippet |regex_replace |regex_replace:\"".st."regex".et."\":\"".st.et."\"".st.et exec "Snippet {counter {counter name=\"#INSERTION#\" start=1 skip=1 direction=\"up\" print=trueassign=\"foo\" }{counter}".st.et exec "Snippet {eval {eval var=\"#SELSTART#{template_format}#SELEND#\" assign=varname} ".st.et "Snippet |date_format |date_format:"${1:strftime() formatting}" <{}> exec "Snippet |truncate |truncate:".st.et.":".st.et.":".st."false".et."" exec "Snippet {if {if ".st."varname".et.st.et."\"".st."foo".et."\"}{* $varname can also be a php call *}".st.et."{/if}".st.et "Snippet |string_format |string_format:"${1:sprintf formatting}" <{}> exec "Snippet {assign {assign var=".st.et." value=\"".st.et."\"}".st.et exec "Snippet {foreach {foreach from=".st."varname".et." item=i [key=k name=\"\"] }".st.et."{/foreach}".st.et exec "Snippet {capture {capture name=#INSERTION#}#SELECT#{/capture}".st.et exec "Snippet |wordwrap |wordwrap:".st.et.":\"".st.et."\":".st.et exec "Snippet |spacify |spacify:\"".st.et."\"".st.et." " exec "Snippet |default |default:\"".st.et."\"".st.et exec "Snippet {debug {debug output=\"#SELSTART#".st.et."#SELEND#\" }".st.et exec "Snippet |replace |replace:\"".st."needle".et."\":\"".st.et."\"".st.et exec "Snippet {include {include file=\"".st.et."\" [assign=varname foo=\"bar\"] }".st.et exec "Snippet |escape |escape:\"".st.et."\"".st.et exec "Snippet {strip {strip}".st.et."{/strip}".st.et exec "Snippet {math {math equation=\"".st.et."\" assign=".st.et." ".st.et."}".st.et exec "Snippet {config_load {config_load file=\"#INSERTION#\" [section=\"\" scope=\"local|parent|global\"] }".st.et exec "Snippet |cat |cat:\"".st.et."\"".st.et exec "Snippet {insert {insert name=\"insert_".st.et."\" [assign=varname script=\"foo.php\" foo=\"bar\"] }".st.et exec "Snippet {fetch {fetch file=\"#SELSTART#http:// or file#SELEND#\" assign=varname}".st.et exec "Snippet {literal {literal}".st.et."{/literal}".st.et exec "Snippet {include_php {include_php file=\"".st.et."\" [once=true]}".st.et exec "Snippet |strip |strip:[\"".st.et."\"]".st.et vim-scripts-20180807ubuntu1/after/ftplugin/symfony_snippets.vim0000644000000000000000000000305113332536305021560 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet image_tag image_tag('".st."imageName".et."'".st.et.")".st.et exec "Snippet get public function get".st.et." (){return $this->".st.et.";}".st.et exec "Snippet link_to link_to('".st."linkName".et."', '".st."moduleName".et."/".st."actionName".et.st.et."')".st.et exec "Snippet sexecute public function execute(){".st.et."}".st.et exec "Snippet set public function set".st.et." ($".st.et."){$this->".st.et." = ".st.et.";}".st.et exec "Snippet execute /*** ".st."className".et."**/public function execute(){".st.et."}".st.et exec "Snippet tforeach ".st.et."".st.et exec "Snippet getparam $this->getRequestParameter('".st."id".et."')".st.et exec "Snippet div ".st.et."".st.et exec "Snippet tif ".st.et."".st.et exec "Snippet setget public function set".st."var".et." (".st."arg".et."){$this->".st."arg".et." = ".st."arg".et.";}public function get".st."var".et." (){return $this->".st."var".et.";}".st.et exec "Snippet echo ".st.et exec "Snippet tfor ".st.et."".st.et vim-scripts-20180807ubuntu1/after/ftplugin/tcl_snippets.vim0000644000000000000000000000131113332536306020634 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet switch switch ".st.et." -- $".st."var".et." {".st."match".et." {".st.et."}default{".st.et."}}".st.et exec "Snippet foreach foreach ".st."var".et." $".st."list".et." {".st.et."}".st.et exec "Snippet proc proc ".st."name".et." {".st."args".et."} {".st.et."}".st.et exec "Snippet if if {".st."condition".et."} {".st.et."}".st.et exec "Snippet for for {".st."i".et." {".st.et."} {".st.et."} {".st.et."}".st.et exec "Snippet while while {".st."condition".et."} {".st.et."}".st.et vim-scripts-20180807ubuntu1/after/ftplugin/template_toolkit_snippets.vim0000644000000000000000000000111213332536306023431 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet wrap [% WRAPPER ".st."template".et." %]".st.et."[% END %]".st.et exec "Snippet if [% IF ".st."condition".et." %]".st.et."[% ELSE %]".st.et."[% END %]".st.et exec "Snippet unl [% UNLESS ".st."condition".et." %]".st.et."[% END %]".st.et exec "Snippet inc [% INCLUDE ".st."template".et." %]".st.et exec "Snippet for [% FOR ".st."var".et." IN ".st."set".et." %]".st.et."[% END %]".st.et vim-scripts-20180807ubuntu1/after/ftplugin/tex_snippets.vim0000644000000000000000000000112113332536306020651 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet sub \\subsection{".st."name".et."}\\label{sub:".st."name:substitute(@z,'.','\\l&','g')".et."}".st.et exec "Snippet $$ \\[".st.et."\\]".st.et exec "Snippet ssub \\subsubsection{".st."name".et."}\\label{ssub:".st."name:substitute(@z,'.','\\l&','g')".et."}".st.et exec "Snippet itd \\item[".st."desc".et."] ".st.et exec "Snippet sec \\section{".st."name".et."}\\label{sec:".st."name:substitute(@z,'.','\\l&','g')".et."".st.et vim-scripts-20180807ubuntu1/after/ftplugin/xhtml_snippets.vim0000644000000000000000000001024513332536306021214 0ustar if !exists('loaded_snippet') || &cp finish endif let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet doctype \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">".st.et exec "Snippet aref ".st.et."".st.et exec "Snippet head ".st.et."".st.et exec "Snippet script ".st.et exec "Snippet html lang=\"".st."en".et."\">".st.et."" exec "Snippet h3

".st.et."

".st.et exec "Snippet h4

".st.et."

".st.et exec "Snippet h5
".st.et."
".st.et exec "Snippet h6
".st.et."
".st.et exec "Snippet fieldset
".st.et."
".st.et exec "Snippet noscript ".st.et exec "Snippet ul
    ".st.et."
".st.et exec "Snippet xml ".st.et exec "Snippet body ".st.et."".st.et exec "Snippet legend ".st.et."".st.et exec "Snippet title ".st."PageTitle".et."".st.et exec "Snippet scriptsrc ".st.et exec "Snippet img \"".st.et."\"".st.et exec "Snippet option ".st.et exec "Snippet optgroup ".st.et."".st.et exec "Snippet meta ".st.et exec "Snippet td ".st.et."".st.et exec "Snippet dt
".st.et."
".st.et."
".st.et exec "Snippet tfoot ".st.et."".st.et exec "Snippet div
".st.et."
".st.et exec "Snippet ol
    ".st.et."
".st.et exec "Snippet txtarea ".st.et exec "Snippet mailto ".st.et."".st.et exec "Snippet table ".st.et."
".st.et exec "Snippet hint ".st.et."".st.et exec "Snippet link ".st.et exec "Snippet form
".st.et."".st.et exec "Snippet tr ".st.et."".st.et exec "Snippet label ".st.et exec "Snippet image \"".st.et."\"".st.et exec "Snippet input ".st.et exec "Snippet select ".st.et exec "Snippet style ".st.et exec "Snippet divheader

".st."CompanyName".et."

".st.et exec "Snippet base ".st.et vim-scripts-20180807ubuntu1/autoload/0000755000000000000000000000000013332536306014273 5ustar vim-scripts-20180807ubuntu1/autoload/Align.vim0000644000000000000000000011473713332536306016057 0ustar " Align: tool to align multiple fields based on one or more separators " Author: Charles E. Campbell " Date: Mar 12, 2013 " Version: 37 " GetLatestVimScripts: 294 1 :AutoInstall: Align.vim " GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim " Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, " Align.vim is provided *as is* and comes with no warranty " of any kind, either expressed or implied. By using this " plugin, you agree that in no event will the copyright " holder be liable for any damages resulting from the use " of this software. " " Romans 1:16,17a : For I am not ashamed of the gospel of Christ, for it is {{{1 " the power of God for salvation for everyone who believes; for the Jew first, " and also for the Greek. For in it is revealed God's righteousness from " faith to faith. "redraw!|call DechoSep()|call inputsave()|call input("Press to continue")|call inputrestore() " --------------------------------------------------------------------- " Load Once: {{{1 if exists("g:loaded_Align") || &cp finish endif let g:loaded_Align = "v37" if v:version < 700 echohl WarningMsg echo "***warning*** this version of Align needs vim 7.0" echohl Normal finish endif let s:keepcpo= &cpo set cpo&vim "DechoTabOn " --------------------------------------------------------------------- " Debugging Support: {{{1 "if !exists("g:loaded_Decho") | runtime plugin/Decho.vim | endif " --------------------------------------------------------------------- " Options: {{{1 if !exists("g:Align_xstrlen") if exists("g:drawit_xstrlen") let g:Align_xstrlen= g:drawit_xstrlen elseif exists("g:netrw_xstrlen") let g:Align_xstrlen= g:netrw_xstrlen elseif &enc == "latin1" || !has("multi_byte") let g:Align_xstrlen= 0 else let g:Align_xstrlen= 1 endif endif " --------------------------------------------------------------------- " Align#AlignCtrl: enter alignment patterns here {{{1 " " Styles = all alignment-break patterns are equivalent " C cycle through alignment-break pattern(s) " l left-justified alignment " r right-justified alignment " c center alignment " - skip separator, treat as part of field " : treat rest of line as field " + repeat previous [lrc] style " < left justify separators " > right justify separators " | center separators " " Builds = s:AlignPat s:AlignCtrl s:AlignPatQty " C s:AlignPat s:AlignCtrl s:AlignPatQty " p s:AlignPrePad " P s:AlignPostPad " w s:AlignLeadKeep " W s:AlignLeadKeep " I s:AlignLeadKeep " l s:AlignStyle " r s:AlignStyle " - s:AlignStyle " + s:AlignStyle " : s:AlignStyle " c s:AlignStyle " g s:AlignGPat " v s:AlignVPat " < s:AlignSep " > s:AlignSep " | s:AlignSep fun! Align#AlignCtrl(...) " call Dfunc("Align#AlignCtrl(...) a:0=".a:0) " save options that may be changed later call s:SaveUserOptions() " turn ignorecase off setlocal noic " clear visual mode so that old visual-mode selections don't " get applied to new invocations of Align(). if v:version < 602 if !exists("s:Align_gavemsg") let s:Align_gavemsg= 1 echomsg "Align needs at least Vim version 6.2 to clear visual-mode selection" endif elseif exists("s:dovisclear") " call Decho("clearing visual mode a:0=".a:0." a:1<".a:1.">") let clearvmode= visualmode(1) endif " set up a list akin to an argument list if a:0 > 0 let A= s:QArgSplitter(a:1) else let A=[0] endif if A[0] > 0 let style = A[1] " Check for bad separator patterns (zero-length matches) " (but zero-length patterns for g/v is ok) if style !~# '[gv]' let ipat= 2 while ipat <= A[0] if "" =~ A[ipat] echoerr "(AlignCtrl) separator<".A[ipat]."> matches zero-length string" call s:RestoreUserOptions() " call Dret("Align#AlignCtrl") return endif let ipat= ipat + 1 endwhile endif endif " call Decho("(AlignCtrl) passed bad-separator pattern check (no zero-length matches)") " call Decho("(AlignCtrl) A[0]=".A[0]) if !exists("s:AlignStyle") let s:AlignStyle= 'l' endif if !exists("s:AlignPrePad") let s:AlignPrePad= 0 endif if !exists("s:AlignPostPad") let s:AlignPostPad= 0 endif if !exists("s:AlignLeadKeep") let s:AlignLeadKeep= 'w' endif if A[0] == 0 " ---------------------- " List current selection " ---------------------- if !exists("s:AlignPatQty") let s:AlignPatQty= 0 endif echo "AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep " call Decho("(AlignCtrl) AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep) if exists("s:AlignGPat") && !exists("s:AlignVPat") echo "AlignGPat<".s:AlignGPat.">" elseif !exists("s:AlignGPat") && exists("s:AlignVPat") echo "AlignVPat<".s:AlignVPat.">" elseif exists("s:AlignGPat") && exists("s:AlignVPat") echo "AlignGPat<".s:AlignGPat."> AlignVPat<".s:AlignVPat.">" endif let ipat= 1 while ipat <= s:AlignPatQty echo "Pat".ipat."<".s:AlignPat_{ipat}.">" " call Decho("(AlignCtrl) Pat".ipat."<".s:AlignPat_{ipat}.">") let ipat= ipat + 1 endwhile else " ---------------------------------- " Process alignment control settings " ---------------------------------- " call Decho("process the alignctrl settings") " call Decho("style<".style.">") if style ==? "default" " Default: preserve initial leading whitespace, left-justified, " alignment on '=', one space padding on both sides if exists("s:AlignCtrlStackQty") " clear AlignCtrl stack while s:AlignCtrlStackQty > 0 call Align#AlignPop() endwhile unlet s:AlignCtrlStackQty endif " Set AlignCtrl to its default value call Align#AlignCtrl("Ilp1P1=<",'=') call Align#AlignCtrl("g") call Align#AlignCtrl("v") let s:dovisclear = 1 call s:RestoreUserOptions() " call Dret("Align#AlignCtrl") return endif if style =~# 'm' " map support: Do an AlignPush now and the next call to Align() " will do an AlignPop at exit " call Decho("style case m: do AlignPush") call Align#AlignPush() let s:DoAlignPop= 1 endif " = : record a list of alignment patterns that are equivalent if style =~# "=" || (A[0] >= 2 && style !~# "C" && s:AlignCtrl =~# '=') " call Decho("style case =: record list of equiv alignment patterns") let s:AlignCtrl = '=' if A[0] >= 2 let s:AlignPatQty= 1 let s:AlignPat_1 = A[2] let ipat = 3 while ipat <= A[0] let s:AlignPat_1 = s:AlignPat_1.'\|'.A[ipat] let ipat = ipat + 1 endwhile let s:AlignPat_1= '\('.s:AlignPat_1.'\)' " call Decho("AlignCtrl<".s:AlignCtrl."> AlignPat<".s:AlignPat_1.">") endif "c : cycle through alignment pattern(s) elseif style =~# 'C' || (A[0] >= 2 && s:AlignCtrl =~# '=') " call Decho("style case C: cycle through alignment pattern(s)") let s:AlignCtrl = 'C' if A[0] >= 2 let s:AlignPatQty= A[0] - 1 let ipat = 1 while ipat < A[0] let s:AlignPat_{ipat}= A[ipat+1] " call Decho("AlignCtrl<".s:AlignCtrl."> AlignQty=".s:AlignPatQty." AlignPat_".ipat."<".s:AlignPat_{ipat}.">") let ipat= ipat + 1 endwhile endif endif if style =~# 'p' let s:AlignPrePad= substitute(style,'^.*p\(\d\+\).*$','\1','') " call Decho("style case p".s:AlignPrePad.": pre-separator padding") if s:AlignPrePad == "" echoerr "(AlignCtrl) 'p' needs to be followed by a numeric argument'" call s:RestoreUserOptions() " call Dret("Align#AlignCtrl") return endif endif if style =~# 'P' let s:AlignPostPad= substitute(style,'^.*P\(\d\+\).*$','\1','') " call Decho("style case P".s:AlignPostPad.": post-separator padding") if s:AlignPostPad == "" echoerr "(AlignCtrl) 'P' needs to be followed by a numeric argument'" call s:RestoreUserOptions() " call Dret("Align#AlignCtrl") return endif endif if style =~# 'w' " call Decho("style case w: ignore leading whitespace") let s:AlignLeadKeep= 'w' elseif style =~# 'W' " call Decho("style case W: keep leading whitespace") let s:AlignLeadKeep= 'W' elseif style =~# 'I' " call Decho("style case I: retain initial leading whitespace") let s:AlignLeadKeep= 'I' endif if style =~# 'g' " first list item is a "g" selector pattern " call Decho("style case g: global selector pattern") if A[0] < 2 if exists("s:AlignVPat") unlet s:AlignVPat " call Decho("unlet s:AlignGPat") endif else let s:AlignGPat= A[2] " call Decho("s:AlignGPat<".s:AlignGPat.">") endif elseif style =~# 'v' " first list item is a "v" selector pattern " call Decho("style case v: global selector anti-pattern") if A[0] < 2 if exists("s:AlignGPat") unlet s:AlignGPat " call Decho("unlet s:AlignVPat") endif else let s:AlignVPat= A[2] " call Decho("s:AlignVPat<".s:AlignVPat.">") endif endif "[-lrc+:] : set up s:AlignStyle if style =~# '[-lrc+:*]' " call Decho("style case [-lrc+:]: field justification") let s:AlignStyle= substitute(style,'[^-lrc:+*]','','g') " call Decho("AlignStyle<".s:AlignStyle.">") endif "[<>|] : set up s:AlignSep if style =~# '[<>|]' " call Decho("style case [-lrc+:]: separator justification") let s:AlignSep= substitute(style,'[^<>|]','','g') " call Decho("AlignSep ".s:AlignSep) endif endif " sanity if !exists("s:AlignCtrl") let s:AlignCtrl= '=' endif " restore options and return call s:RestoreUserOptions() " call Dret("Align#AlignCtrl ".s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle) return s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle endfun " --------------------------------------------------------------------- " s:MakeSpace: returns a string with spacecnt blanks {{{1 fun! s:MakeSpace(spacecnt) " call Dfunc("MakeSpace(spacecnt=".a:spacecnt.")") let str = "" let spacecnt = a:spacecnt while spacecnt > 0 let str = str . " " let spacecnt = spacecnt - 1 endwhile " call Dret("MakeSpace <".str.">") return str endfun " --------------------------------------------------------------------- " Align#Align: align selected text based on alignment pattern(s) {{{1 fun! Align#Align(hasctrl,...) range " call Dfunc("Align#Align(hasctrl=".a:hasctrl.",...) a:0=".a:0) " sanity checks if string(a:hasctrl) != "0" && string(a:hasctrl) != "1" echohl Error|echo 'usage: Align#Align(hasctrl<'.a:hasctrl.'> (should be 0 or 1),"separator(s)" (you have '.a:0.') )'|echohl None " call Dret("Align#Align") return endif if exists("s:AlignStyle") && s:AlignStyle == ":" echohl Error |echo '(Align#Align) your AlignStyle is ":", which implies "do-no-alignment"!'|echohl None " call Dret("Align#Align") return endif " save user options call s:SaveUserOptions() " set up a list akin to an argument list if a:0 > 0 let A= s:QArgSplitter(a:1) else let A=[0] endif " if :Align! was used, then the first argument is (should be!) an AlignCtrl string " Note that any alignment control set this way will be temporary. let hasctrl= a:hasctrl " call Decho("hasctrl=".hasctrl) if a:hasctrl && A[0] >= 1 " call Decho("Align! : using A[1]<".A[1]."> for AlignCtrl") if A[1] =~ '[gv]' let hasctrl= hasctrl + 1 call Align#AlignCtrl('m') call Align#AlignCtrl(A[1],A[2]) " call Decho("Align! : also using A[2]<".A[2]."> for AlignCtrl") elseif A[1] !~ 'm' call Align#AlignCtrl(A[1]."m") else call Align#AlignCtrl(A[1]) endif endif " Check for bad separator patterns (zero-length matches) let ipat= 1 + hasctrl while ipat <= A[0] if "" =~ A[ipat] echoerr "(Align) separator<".A[ipat]."> matches zero-length string" call s:RestoreUserOptions() " call Dret("Align#Align") return endif let ipat= ipat + 1 endwhile " record current search pattern for subsequent restoration " (these are all global-only options) set noic report=10000 nohls if A[0] > hasctrl " Align will accept a list of separator regexps " call Decho("A[0]=".A[0].": accepting list of separator regexp") if s:AlignCtrl =~# "=" "= : consider all separators to be equivalent " call Decho("AlignCtrl: record list of equivalent alignment patterns") let s:AlignCtrl = '=' let s:AlignPat_1 = A[1 + hasctrl] let s:AlignPatQty= 1 let ipat = 2 + hasctrl while ipat <= A[0] let s:AlignPat_1 = s:AlignPat_1.'\|'.A[ipat] let ipat = ipat + 1 endwhile let s:AlignPat_1= '\('.s:AlignPat_1.'\)' " call Decho("AlignCtrl<".s:AlignCtrl."> AlignPat<".s:AlignPat_1.">") elseif s:AlignCtrl =~# 'C' "c : cycle through alignment pattern(s) " call Decho("AlignCtrl: cycle through alignment pattern(s)") let s:AlignCtrl = 'C' let s:AlignPatQty= A[0] - hasctrl let ipat = 1 while ipat <= s:AlignPatQty let s:AlignPat_{ipat}= A[(ipat + hasctrl)] " call Decho("AlignCtrl<".s:AlignCtrl."> AlignQty=".s:AlignPatQty." AlignPat_".ipat."<".s:AlignPat_{ipat}.">") let ipat= ipat + 1 endwhile endif endif " Initialize so that begline " is greater than the line's string length -> ragged right. " Have to be careful about visualmode() -- it returns the last visual " mode used whether or not it was used currently. let begcol = virtcol("'<")-1 let endcol = virtcol("'>")-1 if begcol > endcol let begcol = virtcol("'>")-1 let endcol = virtcol("'<")-1 endif " call Decho("begcol=".begcol." endcol=".endcol) let begline = a:firstline let endline = a:lastline if begline > endline let begline = a:lastline let endline = a:firstline endif " Expand range to cover align-able lines when the given range is only the current line. " Look for the first line above the current line that matches the first separator pattern, and " look for the last line below the current line that matches the first separator pattern. if begline == endline " call Decho("case begline == endline") if !exists("s:AlignPat_{1}") echohl Error|echo "(Align) no separators specified!"|echohl None call s:RestoreUserOptions() " call Dret("Align#Align") return endif let seppat = s:AlignPat_{1} let begline= search('^\%(\%('.seppat.'\)\@!.\)*$',"bnW") if begline == 0|let begline= 1|else|let begline= begline + 1|endif let endline= search('^\%(\%('.seppat.'\)\@!.\)*$',"nW") if endline == 0|let endline= line("$")|else|let endline= endline - 1|endif " call Decho("begline=".begline." endline=".endline." curline#".line(".")) endif " call Decho("begline=".begline." endline=".endline) let fieldcnt = 0 if (begline == line("'>") && endline == line("'<")) || (begline == line("'<") && endline == line("'>")) let vmode= visualmode() " call Decho("vmode=".vmode) if vmode == "\" let ragged = ( col("'>") > s:Strlen(getline("'>")) || col("'<") > s:Strlen(getline("'<")) ) else let ragged= 1 endif else let ragged= 1 endif if ragged let begcol= 0 endif " call Decho("lines[".begline.",".endline."] col[".begcol.",".endcol."] ragged=".ragged." AlignCtrl<".s:AlignCtrl.">") " record initial whitespace if s:AlignLeadKeep == 'W' let wskeep = map(getline(begline,endline),"substitute(v:val,'^\\(\\s*\\).\\{-}$','\\1','')") endif " Align needs these options setl et set paste " convert selected range of lines to use spaces instead of tabs " but if first line's initial white spaces are to be retained " then use 'em if begcol <= 0 && s:AlignLeadKeep == 'I' " retain first leading whitespace for all subsequent lines let bgntxt= substitute(getline(begline),'^\(\s*\).\{-}$','\1','') " exception: retain first leading whitespace predicated on g and v patterns " if such a selected line exists if exists("s:AlignGPat") let firstgline= search(s:AlignGPat,"cnW",endline) if firstgline > 0 let bgntxt= substitute(getline(firstgline),'^\(\s*\).\{-}$','\1','') endif elseif exists("s:AlignVPat") let firstvline= search(s:AlignVPat,"cnW",endline) if firstvline > 0 let bgntxt= substitute('^\%(\%('.getline(firstvline).')\@!\)*$','^\(\s*\).\{-}$','\1','') endif endif " call Decho("retaining 1st leading whitespace: bgntxt<".bgntxt.">") let &l:et= s:keep_et endif exe begline.",".endline."ret" " record transformed to spaces leading whitespace if s:AlignLeadKeep == 'W' let wsblanks = map(getline(begline,endline),"substitute(v:val,'^\\(\\s*\\).\\{-}$','\\1','')") endif " Execute two passes " First pass: collect alignment data (max field sizes) " Second pass: perform alignment let pass= 1 while pass <= 2 " call Decho(" ") " call Decho("---- Pass ".pass.": ----") let curline= begline while curline <= endline " Process each line let txt = getline(curline) " call Decho(" ") " call Decho("Pass".pass.": Line ".curline." <".txt.">") " AlignGPat support: allows a selector pattern (akin to g/selector/cmd ) if exists("s:AlignGPat") " call Decho("Pass".pass.": AlignGPat<".s:AlignGPat.">") if match(txt,s:AlignGPat) == -1 " call Decho("Pass".pass.": skipping") let curline= curline + 1 continue endif endif " AlignVPat support: allows a selector pattern (akin to v/selector/cmd ) if exists("s:AlignVPat") " call Decho("Pass".pass.": AlignVPat<".s:AlignVPat.">") if match(txt,s:AlignVPat) != -1 " call Decho("Pass".pass.": skipping") let curline= curline + 1 continue endif endif " Always skip blank lines if match(txt,'^\s*$') != -1 " call Decho("Pass".pass.": skipping") let curline= curline + 1 continue endif " Extract visual-block selected text (init bgntxt, endtxt) let txtlen= s:Strlen(txt) if begcol > 0 " Record text to left of selected area let bgntxt= strpart(txt,0,begcol) " call Decho("Pass".pass.": record text to left: bgntxt<".bgntxt.">") elseif s:AlignLeadKeep == 'W' let bgntxt= substitute(txt,'^\(\s*\).\{-}$','\1','') " call Decho("Pass".pass.": retaining all leading ws: bgntxt<".bgntxt.">") elseif s:AlignLeadKeep == 'w' || !exists("bgntxt") " No beginning text let bgntxt= "" " call Decho("Pass".pass.": no beginning text") endif if ragged let endtxt= "" else " Elide any text lying outside selected columnar region let endtxt= strpart(txt,endcol+1,txtlen-endcol) let txt = strpart(txt,begcol,endcol-begcol+1) endif " call Decho(" ") " call Decho("Pass".pass.": bgntxt<".bgntxt.">") " call Decho("Pass".pass.": txt<". txt .">") " call Decho("Pass".pass.": endtxt<".endtxt.">") if !exists("s:AlignPat_{1}") echohl Error|echo "(Align) no separators specified!"|echohl None call s:RestoreUserOptions() " call Dret("Align#Align") return endif " Initialize for both passes let seppat = s:AlignPat_{1} let ifield = 1 let ipat = 1 let bgnfield = 0 let endfield = 0 let alignstyle = s:AlignStyle let doend = 1 let newtxt = "" let alignprepad = s:AlignPrePad let alignpostpad= s:AlignPostPad let alignsep = s:AlignSep let alignophold = " " let alignop = 'l' " call Decho("Pass".pass.": initial alignstyle<".alignstyle."> seppat<".seppat.">") " Process each field on the line while doend > 0 " C-style: cycle through pattern(s) if s:AlignCtrl == 'C' && doend == 1 let seppat = s:AlignPat_{ipat} " call Decho("Pass".pass.": processing field: AlignCtrl=".s:AlignCtrl." ipat=".ipat." seppat<".seppat.">") let ipat = ipat + 1 if ipat > s:AlignPatQty let ipat = 1 endif endif " cyclic alignment/justification operator handling let alignophold = alignop let alignop = strpart(alignstyle,0,1) if alignop == '+' || doend == 2 let alignop= alignophold else let alignstyle = strpart(alignstyle,1).strpart(alignstyle,0,1) let alignopnxt = strpart(alignstyle,0,1) if alignop == ':' let seppat = '$' let doend = 2 " call Decho("Pass".pass.": alignop<:> case: setting seppat<$> doend==2") endif endif " cyclic separator alignment specification handling let alignsepop= strpart(alignsep,0,1) let alignsep = strpart(alignsep,1).alignsepop " ------------------------------------------------------ " mark end-of-field and the subsequent end-of-separator. " ------------------------------------------------------ let endfield = match(txt,seppat,bgnfield) let sepfield = matchend(txt,seppat,bgnfield) let skipfield= sepfield " call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop) " Mark eof: Extend field if alignop is '*' and AlignSkip() is true. if alignop == '*' && exists("g:AlignSkip") && type(g:AlignSkip) == 2 " call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop) " a '*' acts like a '-' while the g:AlignSkip function reference is true except that alignop doesn't advance while g:AlignSkip(curline,endfield) && endfield != -1 let endfield = match(txt,seppat,skipfield) let sepfield = matchend(txt,seppat,skipfield) let skipfield = sepfield " call Decho("Pass".pass.": extend field: endfield<".strpart(txt,bgnfield,endfield-bgnfield)."> alignop<".alignop."> alignstyle<".alignstyle.">") endwhile let alignop = strpart(alignstyle,0,1) let alignstyle= strpart(alignstyle,1).strpart(alignstyle,0,1) " call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop." (after *)") endif " Mark eof: Extend field if alignop is '-' while alignop == '-' && endfield != -1 let endfield = match(txt,seppat,skipfield) let sepfield = matchend(txt,seppat,skipfield) let skipfield = sepfield let alignop = strpart(alignstyle,0,1) let alignstyle= strpart(alignstyle,1).strpart(alignstyle,0,1) " call Decho("Pass".pass.": extend field: endfield<".strpart(txt,bgnfield,endfield-bgnfield)."> alignop<".alignop."> alignstyle<".alignstyle.">") endwhile let seplen= sepfield - endfield " call Decho("Pass".pass.": seplen=[sepfield=".sepfield."] - [endfield=".endfield."]=".seplen) if endfield != -1 if pass == 1 " --------------------------------------------------------------------- " Pass 1: Update FieldSize to max " call Decho("Pass".pass.": before lead/trail remove: field<".strpart(txt,bgnfield,endfield-bgnfield).">") let field = substitute(strpart(txt,bgnfield,endfield-bgnfield),'^\s*\(.\{-}\)\s*$','\1','') if s:AlignLeadKeep == 'W' let field = bgntxt.field let bgntxt= "" endif let fieldlen= s:Strlen(field) if !exists("FieldSize_{ifield}") let FieldSize_{ifield}= fieldlen " call Decho("Pass".pass.": set FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field."> (init)") elseif fieldlen > FieldSize_{ifield} let FieldSize_{ifield}= fieldlen " call Decho("Pass".pass.": set FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field."> (fieldlen>FieldSize_".ifield.")") endif if !exists("SepSize_{ifield}") let SepSize_{ifield}= seplen " call Decho("Pass".pass.": set SepSize_{".ifield."}=".SepSize_{ifield}." <".field."> (init)") elseif seplen > SepSize_{ifield} let SepSize_{ifield}= seplen " call Decho("Pass".pass.": set SepSize_{".ifield."}=".SepSize_{ifield}." <".field."> (seplen>SepSize_".ifield.")") endif else " --------------------------------------------------------------------- " Pass 2: Perform Alignment let prepad = strpart(alignprepad,0,1) let postpad = strpart(alignpostpad,0,1) let alignprepad = strpart(alignprepad,1).strpart(alignprepad,0,1) let alignpostpad = strpart(alignpostpad,1).strpart(alignpostpad,0,1) let field = substitute(strpart(txt,bgnfield,endfield-bgnfield),'^\s*\(.\{-}\)\s*$','\1','') " call Decho("Pass".pass.": alignprepad <".alignprepad."> prepad =".prepad) " call Decho("Pass".pass.": alignpostpad<".alignpostpad."> postpad=".postpad) if s:AlignLeadKeep == 'W' let field = bgntxt.field let bgntxt= "" endif if doend == 2 let prepad = 0 let postpad= 0 endif let fieldlen = s:Strlen(field) let sep = s:MakeSpace(prepad).strpart(txt,endfield,sepfield-endfield).s:MakeSpace(postpad) " call Decho("Pass".pass.": sep<".sep."> (after prepad, sepfield-endfield,postpad)") if seplen < SepSize_{ifield} if alignsepop == "<" " left-justify separators let sep = sep.s:MakeSpace(SepSize_{ifield}-seplen) " call Decho("Pass".pass.": sep<".sep."> (left-justified)") elseif alignsepop == ">" " right-justify separators let sep = s:MakeSpace(SepSize_{ifield}-seplen).sep " call Decho("Pass".pass.": sep<".sep."> (right-justified)") else " center-justify separators let sepleft = (SepSize_{ifield} - seplen)/2 let sepright = SepSize_{ifield} - seplen - sepleft let sep = s:MakeSpace(sepleft).sep.s:MakeSpace(sepright) " call Decho("Pass".pass.": sep<".sep."> (center-justified)") endif endif let spaces = FieldSize_{ifield} - fieldlen " call Decho("Pass".pass.": spaces=[FieldSize_".ifield."=".FieldSize_{ifield}."] - [fieldlen=".fieldlen."]=".spaces) " call Decho("Pass".pass.": Field #".ifield."<".field."> spaces=".spaces." be[".bgnfield.",".endfield."] pad=".prepad.','.postpad." FS_".ifield."<".FieldSize_{ifield}."> sep<".sep."> ragged=".ragged." doend=".doend." alignop<".alignop.">") " Perform alignment according to alignment style justification if spaces > 0 if alignop == 'c' " center the field let spaceleft = spaces/2 let spaceright= FieldSize_{ifield} - spaceleft - fieldlen let newtxt = newtxt.s:MakeSpace(spaceleft).field.s:MakeSpace(spaceright).sep elseif alignop == 'r' " right justify the field let newtxt= newtxt.s:MakeSpace(spaces).field.sep elseif ragged && doend == 2 " left justify rightmost field (no trailing blanks needed) let newtxt= newtxt.field else " left justfiy the field let newtxt= newtxt.field.s:MakeSpace(spaces).sep endif elseif ragged && doend == 2 " field at maximum field size and no trailing blanks needed let newtxt= newtxt.field else " field is at maximum field size already let newtxt= newtxt.field.sep endif " call Decho("Pass".pass.": newtxt<".newtxt.">") endif " pass 1/2 " bgnfield indexes to end of separator at right of current field " Update field counter let bgnfield= sepfield let ifield = ifield + 1 if doend == 2 let doend= 0 endif " handle end-of-text as end-of-field elseif doend == 1 let seppat = '$' let doend = 2 else let doend = 0 endif " endfield != -1 endwhile " doend loop (as well as regularly separated fields) if pass == 2 " Write altered line to buffer " call Decho("Pass".pass.": bgntxt<".bgntxt."> curline=".curline) " call Decho("Pass".pass.": newtxt<".newtxt.">") " call Decho("Pass".pass.": endtxt<".endtxt.">") keepj call setline(curline,bgntxt.newtxt.endtxt) endif " call Decho("Pass".pass.": line#".curline."<".getline(".")."> (end-of-while)") let curline = curline + 1 endwhile " curline loop let pass= pass + 1 endwhile " pass loop " call Decho("end of two pass loop") " call Decho("ENDWHILE: cursor at (".line(".").",".col(".").") curline#".curline) " restore original leading whitespace if s:AlignLeadKeep == 'W' let iline= begline let i = 0 " call Decho("restore original leading whitespace") while iline <= endline " call Decho("exe ".iline."s/^".wsblanks[i]."/".wskeep[i]."/") exe "keepj ".iline."s/^".wsblanks[i]."/".wskeep[i]."/" let iline= iline + 1 let i = i + 1 endwhile endif if exists("s:DoAlignPop") " AlignCtrl Map support call Align#AlignPop() unlet s:DoAlignPop endif " restore user options and return call s:RestoreUserOptions() " call Dret("Align#Align") return endfun " --------------------------------------------------------------------- " Align#AlignPush: this command/function pushes an alignment control string onto a stack {{{1 fun! Align#AlignPush() " call Dfunc("Align#AlignPush()") " initialize the stack if !exists("s:AlignCtrlStackQty") let s:AlignCtrlStackQty= 1 else let s:AlignCtrlStackQty= s:AlignCtrlStackQty + 1 endif " construct an AlignCtrlStack entry if !exists("s:AlignSep") let s:AlignSep= '' endif let s:AlignCtrlStack_{s:AlignCtrlStackQty}= s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle.s:AlignSep " call Decho("AlignPush: AlignCtrlStack_".s:AlignCtrlStackQty."<".s:AlignCtrlStack_{s:AlignCtrlStackQty}.">") " push [GV] patterns onto their own stack if exists("s:AlignGPat") let s:AlignGPat_{s:AlignCtrlStackQty}= s:AlignGPat else let s:AlignGPat_{s:AlignCtrlStackQty}= "" endif if exists("s:AlignVPat") let s:AlignVPat_{s:AlignCtrlStackQty}= s:AlignVPat else let s:AlignVPat_{s:AlignCtrlStackQty}= "" endif " call Dret("Align#AlignPush") endfun " --------------------------------------------------------------------- " Align#AlignPop: this command/function pops an alignment pattern from a stack {{{1 " and into the AlignCtrl variables. fun! Align#AlignPop() " call Dfunc("Align#AlignPop()") " sanity checks if !exists("s:AlignCtrlStackQty") echoerr "(AlignPop) AlignPush needs to be used prior to AlignPop" " call Dret("Align#AlignPop <> : AlignPush needs to have been called first") return "" endif if s:AlignCtrlStackQty <= 0 unlet s:AlignCtrlStackQty echoerr "(AlignPop) AlignPush needs to be used prior to AlignPop" " call Dret("Align#AlignPop <> : AlignPop needs to have been called first") return "" endif " pop top of AlignCtrlStack and pass value to AlignCtrl let retval=s:AlignCtrlStack_{s:AlignCtrlStackQty} unlet s:AlignCtrlStack_{s:AlignCtrlStackQty} call Align#AlignCtrl(retval) " pop G pattern stack if s:AlignGPat_{s:AlignCtrlStackQty} != "" call Align#AlignCtrl('g',s:AlignGPat_{s:AlignCtrlStackQty}) else call Align#AlignCtrl('g') endif unlet s:AlignGPat_{s:AlignCtrlStackQty} " pop V pattern stack if s:AlignVPat_{s:AlignCtrlStackQty} != "" call Align#AlignCtrl('v',s:AlignVPat_{s:AlignCtrlStackQty}) else call Align#AlignCtrl('v') endif unlet s:AlignVPat_{s:AlignCtrlStackQty} let s:AlignCtrlStackQty= s:AlignCtrlStackQty - 1 " call Dret("Align#AlignPop <".retval."> : AlignCtrlStackQty=".s:AlignCtrlStackQty) return retval endfun " --------------------------------------------------------------------- " Align#AlignReplaceQuotedSpaces: {{{1 fun! Align#AlignReplaceQuotedSpaces() " call Dfunc("Align#AlignReplaceQuotedSpaces()") let l:line = getline(line(".")) let l:linelen = s:Strlen(l:line) let l:startingPos = 0 let l:startQuotePos = 0 let l:endQuotePos = 0 let l:spacePos = 0 let l:quoteRe = '\\\@, is needed. {{{1 " However, doesn't split at all, so this function returns a list " of arguments which has been: " * split at whitespace " * unless inside "..."s. One may escape characters with a backslash inside double quotes. " along with a leading length-of-list. " " Examples: %Align "\"" will align on "s " %Align " " will align on spaces " " The resulting list: qarglist[0] corresponds to a:0 " qarglist[i] corresponds to a:{i} fun! s:QArgSplitter(qarg) " call Dfunc("s:QArgSplitter(qarg<".a:qarg.">)") if a:qarg =~ '".*"' " handle "..." args, which may include whitespace let qarglist = [] let args = a:qarg " call Decho("handle quoted arguments: args<".args.">") while args != "" let iarg = 0 let arglen = strlen(args) " call Decho(".args[".iarg."]<".args[iarg]."> arglen=".arglen) " find index to first not-escaped '"' " call Decho("find index to first not-escaped \"") while args[iarg] != '"' && iarg < arglen if args[iarg] == '\' let args= strpart(args,1) endif let iarg= iarg + 1 endwhile " call Decho(".args<".args."> iarg=".iarg." arglen=".arglen) if iarg > 0 " handle left of quote or remaining section " call Decho(".handle left of quote or remaining section") if args[iarg] == '"' let qarglist= qarglist + split(strpart(args,0,iarg-1)) else let qarglist= qarglist + split(strpart(args,0,iarg)) endif let args = strpart(args,iarg) let arglen = strlen(args) elseif iarg < arglen && args[0] == '"' " handle "quoted" section " call Decho(".handle quoted section") let iarg= 1 while args[iarg] != '"' && iarg < arglen if args[iarg] == '\' let args= strpart(args,1) endif let iarg= iarg + 1 endwhile " call Decho(".args<".args."> iarg=".iarg." arglen=".arglen) if args[iarg] == '"' call add(qarglist,strpart(args,1,iarg-1)) let args= strpart(args,iarg+1) else let qarglist = qarglist + split(args) let args = "" endif endif " call Decho(".qarglist".string(qarglist)." iarg=".iarg." args<".args.">") endwhile " call Decho("end of loop (handling quoted arguments)") else " split at all whitespace " call Decho("split at all whitespace") let qarglist= split(a:qarg,"[ \t]") endif let qarglistlen= len(qarglist) let qarglist = insert(qarglist,qarglistlen) " call Dret("s:QArgSplitter ".string(qarglist)) return qarglist endfun " --------------------------------------------------------------------- " s:Strlen: this function returns the length of a string, even if its {{{1 " using two-byte etc characters. " Currently, its only used if g:Align_xstrlen is set to a " nonzero value. Solution from Nicolai Weibull, vim docs " (:help strlen()), Tony Mechelynck, and my own invention. fun! s:Strlen(x) " call Dfunc("s:Strlen(x<".a:x."> g:Align_xstrlen=".g:Align_xstrlen) if type(g:Align_xstrlen) == 1 " allow user to specify a function to compute the string length exe "let ret= ".g:Align_xstrlen."('".substitute(a:x,"'","''","g")."')" elseif g:Align_xstrlen == 1 " number of codepoints (Latin a + combining circumflex is two codepoints) " (comment from TM, solution from NW) let ret= strlen(substitute(a:x,'.','c','g')) elseif g:Align_xstrlen == 2 " number of spacing codepoints (Latin a + combining circumflex is one spacing " codepoint; a hard tab is one; wide and narrow CJK are one each; etc.) " (comment from TM, solution from TM) let ret=strlen(substitute(a:x, '.\Z', 'x', 'g')) elseif g:Align_xstrlen == 3 " virtual length (counting, for instance, tabs as anything between 1 and " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately " preceded by lam, one otherwise, etc.) " (comment from TM, solution from me) let modkeep= &l:mod exe "norm! o\" call setline(line("."),a:x) let ret= virtcol("$") - 1 d keepj norm! k let &l:mod= modkeep else " at least give a decent default if v:version >= 703 let ret= strdisplaywidth(a:x) else let ret= strlen(a:x) endif endif " call Dret("s:Strlen ".ret) return ret endfun " --------------------------------------------------------------------- " s:SaveUserOptions: {{{1 fun! s:SaveUserOptions() " call Dfunc("s:SaveUserOptions() s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a')) if !exists("s:saved_user_options") let s:saved_user_options = 1 let s:keep_search = @/ let s:keep_et = &l:et let s:keep_hls = &hls let s:keep_ic = &ic let s:keep_paste = &paste let s:keep_report = &report else let s:saved_user_options = s:saved_user_options + 1 endif " call Dret("s:SaveUserOptions : s:saved_user_options=".s:saved_user_options) endfun " --------------------------------------------------------------------- " s:RestoreUserOptions: {{{1 fun! s:RestoreUserOptions() " call Dfunc("s:RestoreUserOptions() s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a')) if exists("s:saved_user_options") && s:saved_user_options == 1 let @/ = s:keep_search let &l:et = s:keep_et let &hls = s:keep_hls let &ic = s:keep_ic let &paste = s:keep_paste let &report = s:keep_report unlet s:keep_search unlet s:keep_et unlet s:keep_hls unlet s:keep_ic unlet s:keep_paste unlet s:keep_report unlet s:saved_user_options elseif exists("s:saved_user_options") let s:saved_user_options= s:saved_user_options - 1 endif " call Dret("s:RestoreUserOptions : s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a')) endfun " --------------------------------------------------------------------- " Set up default values: {{{1 "call Decho("-- Begin AlignCtrl Initialization --") call Align#AlignCtrl("default") "call Decho("-- End AlignCtrl Initialization --") " --------------------------------------------------------------------- " Restore: {{{1 let &cpo= s:keepcpo unlet s:keepcpo " vim: ts=4 fdm=marker vim-scripts-20180807ubuntu1/autoload/AlignMaps.vim0000644000000000000000000003023413332536306016665 0ustar " AlignMaps.vim : support functions for AlignMaps " Author: Charles E. Campbell " Date: Mar 12, 2013 " Version: 43 " Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, " Align.vim is provided *as is* and comes with no warranty " of any kind, either expressed or implied. By using this " plugin, you agree that in no event will the copyright " holder be liable for any damages resulting from the use "redraw!|call DechoSep()|call inputsave()|call input("Press to continue")|call inputrestore() " --------------------------------------------------------------------- " Load Once: {{{1 if &cp || exists("g:loaded_AlignMaps") finish endif let g:loaded_AlignMaps= "v43" let s:keepcpo = &cpo set cpo&vim "DechoTabOn " ===================================================================== " Functions: {{{1 " --------------------------------------------------------------------- " AlignMaps#WrapperStart: {{{2 fun! AlignMaps#WrapperStart(vis) range " call Dfunc("AlignMaps#WrapperStart(vis=".a:vis.")") if a:vis keepj norm! ' endif if line("'y") == 0 || line("'z") == 0 || !exists("s:alignmaps_wrapcnt") || s:alignmaps_wrapcnt <= 0 " call Decho("wrapper initialization") let s:alignmaps_wrapcnt = 1 let s:alignmaps_keepgd = &gdefault let s:alignmaps_keepsearch = @/ let s:alignmaps_keepch = &ch let s:alignmaps_keepmy = SaveMark("'y") let s:alignmaps_keepmz = SaveMark("'z") let s:alignmaps_posn = SaveWinPosn(0) " set up fencepost blank lines put ='' keepj norm! mz'a put! ='' ky let s:alignmaps_zline = line("'z") exe "keepj 'y,'zs/@/\177/ge" else " call Decho("embedded wrapper") let s:alignmaps_wrapcnt = s:alignmaps_wrapcnt + 1 keepj norm! 'yjma'zk endif " change some settings to align-standard values set nogd set ch=2 AlignPush keepj norm! 'zk " call Dret("AlignMaps#WrapperStart : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z")) endfun " --------------------------------------------------------------------- " AlignMaps#WrapperEnd: {{{2 fun! AlignMaps#WrapperEnd() range " call Dfunc("AlignMaps#WrapperEnd() alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z")) " remove trailing white space introduced by whatever in the modification zone keepj 'y,'zs/ \+$//e " restore AlignCtrl settings AlignPop let s:alignmaps_wrapcnt= s:alignmaps_wrapcnt - 1 if s:alignmaps_wrapcnt <= 0 " initial wrapper ending exe "keepj 'y,'zs/\177/@/ge" " if the 'z line hasn't moved, then go ahead and restore window position let zstationary= s:alignmaps_zline == line("'z") " remove fencepost blank lines. " restore 'a keepj norm! 'yjmakdd'zdd " restore original 'y, 'z, and window positioning call RestoreMark(s:alignmaps_keepmy) call RestoreMark(s:alignmaps_keepmz) if zstationary > 0 call RestoreWinPosn(s:alignmaps_posn) " call Decho("restored window positioning") endif " restoration of options let &gd= s:alignmaps_keepgd let &ch= s:alignmaps_keepch let @/ = s:alignmaps_keepsearch " remove script variables unlet s:alignmaps_keepch unlet s:alignmaps_keepsearch unlet s:alignmaps_keepmy unlet s:alignmaps_keepmz unlet s:alignmaps_keepgd unlet s:alignmaps_posn endif " call Dret("AlignMaps#WrapperEnd : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z")) endfun " --------------------------------------------------------------------- " AlignMaps#MakeMap: make both a normal-mode and a visual mode map for mapname {{{2 fun! AlignMaps#MakeMap(mapname) if exists("g:maplocalleader") let maplead= g:maplocalleader elseif exists("g:mapleader") let maplead= g:mapleader else let maplead= '\' endif exe "nmap ".maplead.a:mapname." AM_".a:mapname exe "vmap ".maplead.a:mapname.' :call AlignMaps#Vis("'.a:mapname.'")'."" endfun " --------------------------------------------------------------------- " AlignMaps#StdAlign: some semi-standard align calls {{{2 fun! AlignMaps#StdAlign(mode) range " call Dfunc("AlignMaps#StdAlign(mode=".a:mode.")") if a:mode == 1 " align on @ " call Decho("align on @") AlignCtrl mIp1P1=l @ 'a,.Align elseif a:mode == 2 " align on @, retaining all initial white space on each line " call Decho("align on @, retaining all initial white space on each line") AlignCtrl mWp1P1=l @ 'a,.Align elseif a:mode == 3 " like mode 2, but ignore /* */-style comments " call Decho("like mode 2, but ignore /* */-style comments") AlignCtrl v ^\s*/[/*] AlignCtrl mWp1P1=l @ 'a,.Align else echoerr "(AlignMaps) AlignMaps#StdAlign doesn't support mode#".a:mode endif " call Dret("AlignMaps#StdAlign") endfun " --------------------------------------------------------------------- " AlignMaps#CharJoiner: joins lines which end in the given character (spaces {{{2 " at end are ignored) fun! AlignMaps#CharJoiner(chr) " call Dfunc("AlignMaps#CharJoiner(chr=".a:chr.")") let aline = line("'a") let rep = line(".") - aline while rep > 0 keepj norm! 'a while match(getline(aline),a:chr . "\s*$") != -1 && rep >= 0 " while = at end-of-line, delete it and join with next keepj norm! 'a$ j! let rep = rep - 1 endwhile " update rep(eat) count let rep = rep - 1 if rep <= 0 " terminate loop if at end-of-block break endif " prepare for next line keepj norm! jma let aline = line("'a") endwhile " call Dret("AlignMaps#CharJoiner") endfun " --------------------------------------------------------------------- " AlignMaps#Equals: supports \t= and \T= {{{2 fun! AlignMaps#Equals() range " call Dfunc("AlignMaps#Equals()") keepj 'a,'zs/\s\+\([.*/+\-%|&\~^]\==\)/ \1/e keepj 'a,'zs@ \+\([.*/+\-%|&\~^]\)=@\1=@ge keepj 'a,'zs/==/\="\\"/ge keepj 'a,'zs/\([!<>:]\)=/\=submatch(1)."\"/ge keepj norm g'zk AlignCtrl mIp1P1=l = AlignCtrl g = keepj 'a,'z-1Align keepj 'a,'z-1s@\([.*/%|&\~^!=]\)\( \+\)=@\2\1=@ge keepj 'a,'z-1s@[^+\-]\zs\([+\-]\)\( \+\)=@\2\1=@ge keepj 'a,'z-1s/\( \+\);/;\1/ge if &ft == "c" || &ft == "cpp" " call Decho("exception for ".&ft) keepj 'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e keepj 'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e if exists("g:mapleader") exe "keepj norm 'zk" call AlignMaps#StdAlign(1) else exe "keepj norm 'zk" call AlignMaps#StdAlign(1) endif keepj 'y,'zs/^\(\s*\) @/\1/e endif keepj 'a,'z-1s/\%x0f/=/ge keepj 'y,'zs/ @//eg " call Dret("AlignMaps#Equals") endfun " --------------------------------------------------------------------- " AlignMaps#Afnc: useful for splitting one-line function beginnings {{{2 " into one line per argument format fun! AlignMaps#Afnc() " call Dfunc("AlignMaps#Afnc()") " keep display quiet let chkeep = &l:ch let gdkeep = &l:gd let wwkeep = &l:ww let vekeep = &l:ve setlocal ch=2 nogd ve= ww=b,s,<,>,[,] " will use marks y,z ; save current values let mykeep = SaveMark("'y") let mzkeep = SaveMark("'z") " Find beginning of function -- be careful to skip over comments let cmmntid = synIDtrans(hlID("Comment")) let stringid = synIDtrans(hlID("String")) exe "keepj norm! ]]" while search(")","bW") != 0 " call Decho("line=".line(".")." col=".col(".")) let parenid= synIDtrans(synID(line("."),col("."),1)) if parenid != cmmntid && parenid != stringid break endif endwhile keepj norm! %my keepj s/(\s*\(\S\)/(\r \1/e exe "keepj norm! `y%" keepj s/)\s*\(\/[*/]\)/)\r\1/e exe "keepj norm! `y%mz" keepj 'y,'zs/\s\+$//e keepj 'y,'zs/^\s\+//e keepj 'y+1,'zs/^/ / " insert newline after every comma only one parenthesis deep exe "sil! keepj norm! `y\h" let parens = 1 let cmmnt = 0 let cmmntline= -1 while parens >= 1 exe 'keepj norm! ma "ay`a ' " call Decho("parens=".parens." cmmnt=".cmmnt." cmmntline=".cmmntline." line(.)=".line(".")." @a<".@a."> line<".getline(".").">") if @a == "(" let parens= parens + 1 elseif @a == ")" let parens= parens - 1 " comment bypass: /* ... */ or //... elseif cmmnt == 0 && @a == '/' let cmmnt= 1 elseif cmmnt == 1 if @a == '/' let cmmnt = 2 " //... let cmmntline= line(".") elseif @a == '*' let cmmnt= 3 " /*... else let cmmnt= 0 endif elseif cmmnt == 2 && line(".") != cmmntline let cmmnt = 0 let cmmntline= -1 elseif cmmnt == 3 && @a == '*' let cmmnt= 4 elseif cmmnt == 4 if @a == '/' let cmmnt= 0 " ...*/ elseif @a != '*' let cmmnt= 3 endif elseif @a == "," && parens == 1 && cmmnt == 0 exe "keepj norm! i\\" endif endwhile sil! keepj norm! `y%mz% sil! keepj 'y,'zg/^\s*$/d " perform substitutes to mark fields for Align sil! keepj 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e sil! keepj 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg sil! keepj 'y+1,'zv/^\//s/\* \+/*/ge sil! keepj 'y+1,'zv/^\//s/\w\zs\s*\*/ */ge " func " ws <- declaration -> <-ptr -> <-var-> <-[array][] -> <-glop-> <-end-> sil! keepj 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e sil! keepj 'y+1,'z+1g/^\s*\/[*/]/norm! kJ sil! keepj 'y+1,'z+1s%/[*/]%@&@%ge sil! keepj 'y+1,'z+1s%*/%@&%ge AlignCtrl mIp0P0=l @ sil! keepj 'y+1,'zAlign sil! keepj 'y,'zs%@\(/[*/]\)@%\t\1 %e sil! keepj 'y,'zs%@\*/% */%e sil! keepj 'y,'zs/@\([,)]\)/\1/ sil! keepj 'y,'zs/@/ / AlignCtrl mIlrp0P0= # @ sil! keepj 'y+1,'zAlign sil! keepj 'y+1,'zs/#/ / sil! keepj 'y+1,'zs/@// sil! keepj 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e " Restore call RestoreMark(mykeep) call RestoreMark(mzkeep) let &l:ch= chkeep let &l:gd= gdkeep let &l:ww= wwkeep let &l:ve= vekeep " call Dret("AlignMaps#Afnc") endfun " --------------------------------------------------------------------- " AlignMaps#FixMultiDec: converts a type arg,arg,arg; line to multiple lines {{{2 fun! AlignMaps#FixMultiDec() " call Dfunc("AlignMaps#FixMultiDec()") " save register x let xkeep = @x let curline = getline(".") " call Decho("curline<".curline.">") let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+[(*]*\h.*$','\1','') " call Decho("@x<".@x.">") " transform line exe 'keepj s/,/;\r'.@x.' /ge' "restore register x let @x= xkeep " call Dret("AlignMaps#FixMultiDec : my=".line("'y")." mz=".line("'z")) endfun " --------------------------------------------------------------------- " AlignMaps#AlignMapsClean: this function removes the AlignMaps plugin {{{2 fun! AlignMaps#AlignMapsClean() " call Dfunc("AlignMaps#AlignMapsClean()") for home in split(&rtp,',') + [''] " call Decho("considering home<".home.">") if isdirectory(home) if filereadable(home."/autoload/AlignMaps.vim") " call Decho("deleting ".home."/autoload/AlignMaps.vim") call delete(home."/autoload/AlignMaps.vim") endif if filereadable(home."/plugin/AlignMapsPlugin.vim") " call Decho("deleting ".home."/plugin/AlignMapsPlugin.vim") call delete(home."/plugin/AlignMapsPlugin.vim") endif endif endfor " call Dret("AlignMaps#AlignMapsClean") endfun " --------------------------------------------------------------------- " AlignMaps#Vis: interfaces with visual maps {{{2 fun! AlignMaps#Vis(plugmap) range " call Dfunc("AlignMaps#VisCall(plugmap<".a:plugmap.">) ".a:firstline.",".a:lastline) let amark= SaveMark("a") exe a:firstline ka exe a:lastline if exists("g:maplocalleader") let maplead= g:maplocalleader elseif exists("g:mapleader") let maplead= g:mapleader else let maplead= '\' endif " call Decho("exe norm ".maplead.a:plugmap) exe " norm ".maplead.a:plugmap call RestoreMark(amark) " call Dret("AlignMaps#VisCall") endfun " --------------------------------------------------------------------- " Restore: {{{1 let &cpo= s:keepcpo unlet s:keepcpo " vim: ts=4 fdm=marker vim-scripts-20180807ubuntu1/autoload/deb.vim0000644000000000000000000001606513332536306015552 0ustar " Vim autoload file for browsing debian package. " copyright (C) 2007-2008, arno renevier " Distributed under the GNU General Public License (version 2 or above) " Last Change: 2008 april 1 " " Inspired by autoload/tar.vim by Charles E Campbell " " Latest version of that file can be found at " http://www.fdn.fr/~arenevier/vim/autoload/deb.vim " It should also be available at " http://www.vim.org/scripts/script.php?script_id=1970 if &cp || exists("g:loaded_deb") || v:version < 700 finish endif let g:loaded_deb= "v1.4" fun! deb#read(debfile, member) " checks if ar and tar are installed if !s:hascmd("ar") || !s:hascmd("tar") return endif let l:target = a:member let l:archmember = s:dataFileName(a:debfile) " default archive member to extract if l:archmember == "" echohl WarningMsg | echo "***error*** (deb#read) no valid data file found in debian archive" return elseif l:archmember == "data.tar.gz" let l:unpcmp = "tar zxfO " elseif l:archmember == "data.tar.bz2" let l:unpcmp = "tar jxfO " elseif l:archmember == "data.tar.lzma" if !s:hascmd("lzma") return endif let l:unpcmp = "lzma -d | tar xfO " elseif l:archmember == "data.tar" let l:unpcmp = "tar xfO " endif if a:member =~ '^\* ' " information control file let l:archmember = "control.tar.gz" let l:target = substitute(l:target, "^\* ", "", "") let l:unpcmp = "tar zxfO " elseif a:member =~ ' -> ' " symbolic link let l:target = split(a:member,' -> ')[0] let l:linkname = split(a:member,' -> ')[1] if l:linkname =~ "^\/" " direct symlink: path is already absolute let l:target = ".".l:linkname else " transform relative path to absolute path " first, get basename for target let l:target = substitute(l:target, "\/[^/]*$", "", "") " while it begins with ../ while l:linkname =~ "^\.\.\/" " removes one level of ../ in linkname let l:linkname = substitute(l:linkname, "^\.\.\/", "", "") " go one directory up in target let l:target = substitute(l:target, "\/[^/]*$", "", "") endwhile let l:target = l:target."/".l:linkname endif endif " we may preprocess some files (such as man pages, or changelogs) let l:preproccmd = "" " " unzip man pages " if l:target =~ "\.\/usr\/share\/man\/.*\.gz$" " try to fail gracefully if a command is not available if !s:hascmd("gzip") return elseif !s:hascmd("nroff") let l:preproccmd = "| gzip -cd" elseif !s:hascmd("col") let l:preproccmd = "| gzip -cd | nroff -mandoc" else let l:preproccmd = "| gzip -cd | nroff -mandoc | col -b" endif " " unzip other .gz files " elseif l:target =~ '.*\.gz$' if !s:hascmd("gzip") return endif let l:preproccmd = "| gzip -cd" endif " read content exe "silent r! ar p " . s:QuoteFile(a:debfile) . " " . s:QuoteFile(l:archmember) . " | " . l:unpcmp . " - " . s:QuoteFile(l:target) . l:preproccmd " error will be treated in calling function if v:shell_error != 0 return endif exe "file deb:".l:target 0d setlocal nomodifiable nomodified readonly endfun fun! deb#browse(file) " checks if necessary utils are installed if !s:hascmd("dpkg") || !s:hascmd("ar") || !s:hascmd("tar") return endif " checks if file is readable if !filereadable(a:file) return endif if a:file =~ "'" echohl WarningMsg | echo "***error*** (deb#Browse) filename cannot contain quote character (" . a:file . ")" return endif let keepmagic = &magic set magic " set filetype to "deb" set ft=deb setlocal modifiable noreadonly " set header exe "$put ='".'\"'." deb.vim version ".g:loaded_deb."'" exe "$put ='".'\"'." Browsing debian package ".a:file."'" $put='' " package info "exe "silent read! dpkg -I ".a:file "$put='' " display information control files let l:infopos = line(".") exe "silent read! ar p " . s:QuoteFile(a:file) . " control.tar.gz | tar zt" $put='' " display data files let l:listpos = line(".") exe "silent read! dpkg -c ". s:QuoteFile(a:file) " format information control list " removes '* ./' line exe (l:infopos + 1). 'd' " add a star before each line exe "silent " . (l:infopos + 1). ',' . (l:listpos - 2) . 's/^/\* /' " format data list exe "silent " . l:listpos . ',$s/^.*\s\(\.\/\(\S\|\).*\)$/\1/' if v:shell_error != 0 echohl WarningMsg | echo "***warning*** (deb#Browse) error when listing content of " . a:file let &magic = keepmagic return endif 0d setlocal nomodifiable readonly noremap :call DebBrowseSelect() let &magic = keepmagic endfun fun! s:DebBrowseSelect() let l:fname= getline(".") " sanity check if (l:fname !~ '^\.\/') && (l:fname !~ '^\* \.\/') return endif if l:fname =~ "'" echohl WarningMsg | echo "***error*** (DebBrowseSelect) filename cannot contain quote character (" . l:fname . ")" return endif " do nothing on directories " TODO: find a way to detect symlinks to directories, to be able not to " open them if (l:fname =~ '\/$') return endif " need to get it now since a new window will open let l:curfile= expand("%") " open new window new wincmd _ call deb#read(l:curfile, l:fname) if v:shell_error != 0 echohl WarningMsg | echo "***warning*** (DebBrowseSelect) error when reading " . l:fname return endif filetype detect " zipped files, are unziped in deb#read, but filetype may not " automatically work. if l:fname =~ "\.\/usr\/share\/man\/.*\.gz$" set filetype=man elseif l:fname =~ "\.\/usr\/share\/doc\/.*\/changelog.Debian.gz$" set filetype=debchangelog endif endfun " return data file name for debian package. This can be either data.tar.gz, " data.tar.bz2 or data.tar.lzma fun s:dataFileName(deb) for fn in ["data.tar.gz", "data.tar.bz2", "data.tar.lzma", "data.tar"] " [0:-2] is to remove trailing null character from command output if (system("ar t " . "'" . a:deb . "'" . " " . fn))[0:-2] == fn return fn endif endfor return "" " no debian data format in this archive endfun fun s:QuoteFile(file) " we need to escape %, #, <, and > " see :help cmdline-specialk return "'" . substitute(a:file, '\([%#<>]\)', '\\\1', 'g') . "'" endfun " return 1 if cmd exists " display error message and return 0 otherwise fun s:hascmd(cmd) if executable(a:cmd) return 1 else echohl Error | echo "***error*** " . a:cmd . " not available on your system" return 0 else endfu vim-scripts-20180807ubuntu1/autoload/omni/0000755000000000000000000000000013332536306015235 5ustar vim-scripts-20180807ubuntu1/autoload/omni/common/0000755000000000000000000000000013332536306016525 5ustar vim-scripts-20180807ubuntu1/autoload/omni/common/debug.vim0000644000000000000000000000173013332536306020331 0ustar " Description: Omni completion debug functions " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 let s:CACHE_DEBUG_TRACE = [] " Start debug, clear the debug file function! omni#common#debug#Start() let s:CACHE_DEBUG_TRACE = [] call extend(s:CACHE_DEBUG_TRACE, ['============ Debug Start ============']) call writefile(s:CACHE_DEBUG_TRACE, "Omni.dbg") endfunc " End debug, write to debug file function! omni#common#debug#End() call extend(s:CACHE_DEBUG_TRACE, ["============= Debug End ============="]) call extend(s:CACHE_DEBUG_TRACE, [""]) call writefile(s:CACHE_DEBUG_TRACE, "Omni.dbg") endfunc " Debug trace function function! omni#common#debug#Trace(szFuncName, ...) let szTrace = a:szFuncName let paramNum = a:0 if paramNum>0 let szTrace .= ':' endif for i in range(paramNum) let szTrace = szTrace .' ('. string(eval('a:'.string(i+1))).')' endfor call extend(s:CACHE_DEBUG_TRACE, [szTrace]) endfunc vim-scripts-20180807ubuntu1/autoload/omni/common/utils.vim0000644000000000000000000000367013332536306020410 0ustar " Description: Omni completion utils " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 " For sort numbers in list function! omni#common#utils#CompareNumber(i1, i2) let num1 = eval(a:i1) let num2 = eval(a:i2) return num1 == num2 ? 0 : num1 > num2 ? 1 : -1 endfunc " TagList function calling the vim taglist() with try catch " The only throwed exception is 'TagList:UserInterrupt' " We also force the noignorecase option to avoid linear search when calling " taglist() function! omni#common#utils#TagList(szTagQuery) let result = [] let bUserIgnoreCase = &ignorecase " Forcing noignorecase search => binary search can be used in taglist() " if tags in the tag file are sorted if bUserIgnoreCase set noignorecase endif try let result = taglist(a:szTagQuery) catch /^Vim:Interrupt$/ " Restoring user's setting if bUserIgnoreCase set ignorecase endif throw 'TagList:UserInterrupt' catch "Note: it seems that ctags can generate corrupted files, in this case "taglist() will fail to read the tagfile and an exception from "has_add() is thrown endtry " Restoring user's setting if bUserIgnoreCase set ignorecase endif return result endfunc " Same as TagList but don't throw exception function! omni#common#utils#TagListNoThrow(szTagQuery) let result = [] try let result = omni#common#utils#TagList(a:szTagQuery) catch endtry return result endfunc " Get the word under the cursor function! omni#common#utils#GetWordUnderCursor() let szLine = getline('.') let startPos = getpos('.')[2]-1 let startPos = (startPos < 0)? 0 : startPos if szLine[startPos] =~ '\w' let startPos = searchpos('\<\w\+', 'cbn', line('.'))[1] - 1 endif let startPos = (startPos < 0)? 0 : startPos let szResult = matchstr(szLine, '\w\+', startPos) return szResult endfunc vim-scripts-20180807ubuntu1/autoload/omni/cpp/0000755000000000000000000000000013332536306016017 5ustar vim-scripts-20180807ubuntu1/autoload/omni/cpp/complete.vim0000644000000000000000000005035613332536306020355 0ustar " Description: Omni completion script for cpp files " Maintainer: Vissale NEANG " Last Change: 27 sept. 2007 if v:version < 700 echohl WarningMsg echomsg "omni#cpp#complete.vim: Please install vim 7.0 or higher for omni-completion" echohl None finish endif call omni#cpp#settings#Init() let s:OmniCpp_ShowScopeInAbbr = g:OmniCpp_ShowScopeInAbbr let s:OmniCpp_ShowPrototypeInAbbr = g:OmniCpp_ShowPrototypeInAbbr let s:OmniCpp_ShowAccess = g:OmniCpp_ShowAccess let s:szCurrentWorkingDir = getcwd() " Cache data let s:CACHE_TAG_POPUP_ITEMS = {} let s:CACHE_TAG_FILES = {} let s:CACHE_TAG_ENV = '' let s:CACHE_OVERLOADED_FUNCTIONS = {} " Has preview window? let s:hasPreviewWindow = match(&completeopt, 'preview')>=0 let s:hasPreviewWindowOld = s:hasPreviewWindow " Popup item list let s:popupItemResultList = [] " May complete indicator let s:bMayComplete = 0 " Init mappings function! omni#cpp#complete#Init() call omni#cpp#settings#Init() set omnifunc=omni#cpp#complete#Main inoremap omni#cpp#maycomplete#Complete() inoremap . omni#cpp#maycomplete#Dot() inoremap > omni#cpp#maycomplete#Arrow() inoremap : omni#cpp#maycomplete#Scope() endfunc " Find the start position of the completion function! s:FindStartPositionOfCompletion() " Locate the start of the item, including ".", "->" and "[...]". let line = getline('.') let start = col('.') - 1 let lastword = -1 while start > 0 if line[start - 1] =~ '\w' let start -= 1 elseif line[start - 1] =~ '\.' " Searching for dot '.' if lastword == -1 let lastword = start endif let start -= 1 elseif start > 1 && line[start - 2] == '-' && line[start - 1] == '>' " Searching for '->' if lastword == -1 let lastword = start endif let start -= 2 elseif start > 1 && line[start - 2] == ':' && line[start - 1] == ':' " Searching for '::' for namespaces and class if lastword == -1 let lastword = start endif let start -= 2 elseif line[start - 1] == ']' " Skip over [...]. let n = 0 let start -= 1 while start > 0 let start -= 1 if line[start] == '[' if n == 0 break endif let n -= 1 elseif line[start] == ']' " nested [] let n += 1 endif endwhile else break endif endwhile if lastword==-1 " For completion on the current scope let lastword = start endif return lastword endfunc " Returns if szKey1.szKey2 is in the cache " @return " - 0 = key not found " - 1 = szKey1.szKey2 found " - 2 = szKey1.[part of szKey2] found function! s:IsCached(cache, szKey1, szKey2) " Searching key in the result cache let szResultKey = a:szKey1 . a:szKey2 let result = [0, szResultKey] if a:szKey2 != '' let szKey = a:szKey2 while len(szKey)>0 if has_key(a:cache, a:szKey1 . szKey) let result[1] = a:szKey1 . szKey if szKey != a:szKey2 let result[0] = 2 else let result[0] = 1 endif break endif let szKey = szKey[:-2] endwhile else if has_key(a:cache, szResultKey) let result[0] = 1 endif endif return result endfunc " Extend a tag item to a popup item function! s:ExtendTagItemToPopupItem(tagItem, szTypeName) let tagItem = a:tagItem " Add the access let szItemMenu = '' let accessChar = {'public': '+','protected': '#','private': '-'} if g:OmniCpp_ShowAccess if has_key(tagItem, 'access') && has_key(accessChar, tagItem.access) let szItemMenu = szItemMenu.accessChar[tagItem.access] else let szItemMenu = szItemMenu." " endif endif " Formating optional menu string we extract the scope information let szName = substitute(tagItem.name, '.*::', '', 'g') let szItemWord = szName let szAbbr = szName if !g:OmniCpp_ShowScopeInAbbr let szScopeOfTag = omni#cpp#utils#ExtractScope(tagItem) let szItemMenu = szItemMenu.' '.szScopeOfTag[2:] let szItemMenu = substitute(szItemMenu, '\s\+$', '', 'g') else let szAbbr = tagItem.name endif if g:OmniCpp_ShowAccess let szItemMenu = substitute(szItemMenu, '^\s\+$', '', 'g') else let szItemMenu = substitute(szItemMenu, '\(^\s\+\)\|\(\s\+$\)', '', 'g') endif " Formating information for the preview window if index(['f', 'p'], tagItem.kind[0])>=0 let szItemWord .= '(' if g:OmniCpp_ShowPrototypeInAbbr && has_key(tagItem, 'signature') let szAbbr .= tagItem.signature else let szAbbr .= '(' endif endif let szItemInfo = '' if s:hasPreviewWindow let szItemInfo = omni#cpp#utils#GetPreviewWindowStringFromTagItem(tagItem) endif " If a function is a ctor we add a new key in the tagItem if index(['f', 'p'], tagItem.kind[0])>=0 if match(szName, '^\~') < 0 && a:szTypeName =~ '\C\<'.szName.'$' " It's a ctor let tagItem['ctor'] = 1 elseif has_key(tagItem, 'access') && tagItem.access == 'friend' " Friend function let tagItem['friendfunc'] = 1 endif endif " Extending the tag item to a popup item let tagItem['word'] = szItemWord let tagItem['abbr'] = szAbbr let tagItem['menu'] = szItemMenu let tagItem['info'] = szItemInfo let tagItem['dup'] = (s:hasPreviewWindow && index(['f', 'p', 'm'], tagItem.kind[0])>=0) return tagItem endfunc " Get tag popup item list function! s:TagPopupList(szTypeName, szBase) let result = [] " Searching key in the result cache let cacheResult = s:IsCached(s:CACHE_TAG_POPUP_ITEMS, a:szTypeName, a:szBase) " Building the tag query, we don't forget dtors when a:szBase=='' if a:szTypeName!='' " Scope search let szTagQuery = '^' . a:szTypeName . '::' . a:szBase . '\~\?\w\+$' else " Global search let szTagQuery = '^' . a:szBase . '\w\+$' endif " If the result is already in the cache we return it if cacheResult[0] let result = s:CACHE_TAG_POPUP_ITEMS[ cacheResult[1] ] if cacheResult[0] == 2 let result = filter(copy(result), 'v:val.name =~ szTagQuery' ) endif return result endif try " Getting tags let result = omni#common#utils#TagList(szTagQuery) " We extend tag items to popup items call map(result, 's:ExtendTagItemToPopupItem(v:val, a:szTypeName)') " We store the result in a cache if cacheResult[1] != '' let s:CACHE_TAG_POPUP_ITEMS[ cacheResult[1] ] = result endif catch /^TagList:UserInterrupt$/ endtry return result endfunc " Find complete matches for a completion on the global scope function! s:SearchGlobalMembers(szBase) if a:szBase != '' let tagPopupList = s:TagPopupList('', a:szBase) let tagPopupList = filter(copy(tagPopupList), g:omni#cpp#utils#szFilterGlobalScope) call extend(s:popupItemResultList, tagPopupList) endif endfunc " Search class, struct, union members " @param resolvedTagItem: a resolved tag item " @param szBase: string base " @return list of tag items extended to popup items function! s:SearchMembers(resolvedTagItem, szBase) let result = [] if a:resolvedTagItem == {} return result endif " Get type info without the starting '::' let szTagName = omni#cpp#utils#ExtractTypeInfoFromTag(a:resolvedTagItem)[2:] " Unnamed type case. A tag item representing an unnamed type is a variable " ('v') a member ('m') or a typedef ('t') if index(['v', 't', 'm'], a:resolvedTagItem.kind[0])>=0 && has_key(a:resolvedTagItem, 'typeref') " We remove the 'struct:' or 'class:' etc... let szTagName = substitute(a:resolvedTagItem.typeref, '^\w\+:', '', 'g') endif return copy(s:TagPopupList(szTagName, a:szBase)) endfunc " Return if the tag env has changed function! s:HasTagEnvChanged() if s:CACHE_TAG_ENV == &tags return 0 else let s:CACHE_TAG_ENV = &tags return 1 endif endfunc " Return if a tag file has changed in tagfiles() function! s:HasATagFileOrTagEnvChanged() if s:HasTagEnvChanged() let s:CACHE_TAG_FILES = {} return 1 endif let result = 0 for tagFile in tagfiles() if tagFile == "" continue endif if has_key(s:CACHE_TAG_FILES, tagFile) let currentFiletime = getftime(tagFile) if currentFiletime > s:CACHE_TAG_FILES[tagFile] " The file has changed, updating the cache let s:CACHE_TAG_FILES[tagFile] = currentFiletime let result = 1 endif else " We store the time of the file let s:CACHE_TAG_FILES[tagFile] = getftime(tagFile) let result = 1 endif endfor return result endfunc " Initialization call s:HasATagFileOrTagEnvChanged() " Filter same function signatures of base classes function! s:FilterOverloadedFunctions(tagPopupList) let result = [] for tagPopupItem in a:tagPopupList if has_key(tagPopupItem, 'kind') && index(['f', 'p'], tagPopupItem.kind[0])>=0 && has_key(tagPopupItem, 'signature') if !has_key(s:CACHE_OVERLOADED_FUNCTIONS, tagPopupItem.word . tagPopupItem.signature) let s:CACHE_OVERLOADED_FUNCTIONS[tagPopupItem.word . tagPopupItem.signature] = 1 call extend(result, [tagPopupItem]) endif else call extend(result, [tagPopupItem]) endif endfor return result endfunc " Access filter function! s:GetAccessFilter(szFilter, szAccessFilter) let szFilter = a:szFilter if g:OmniCpp_DisplayMode == 0 if a:szAccessFilter == 'public' " We only get public members let szFilter .= "&& v:val.access == 'public'" elseif a:szAccessFilter == 'protected' " We get public and protected members let szFilter .= "&& v:val.access != 'private'" endif endif return szFilter endfunc " Filter class members in the popup menu after a completion with -> or . function! s:FilterClassMembers(tagPopupList, szAccessFilter) let szFilter = "(!has_key(v:val, 'friendfunc') && !has_key(v:val, 'ctor') && has_key(v:val, 'kind') && index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access'))" call filter(a:tagPopupList, s:GetAccessFilter(szFilter, a:szAccessFilter)) call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) endfunc " Filter class scope members in the popup menu after a completion with :: " We only display attribute and functions members that " have an access information. We also display nested " class, struct, union, and enums, typedefs function! s:FilterClassScopeMembers(tagPopupList, szAccessFilter) let szFilter = "!has_key(v:val, 'friendfunc') && has_key(v:val, 'kind') && (index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access'))" let szFilter = s:GetAccessFilter(szFilter, a:szAccessFilter) let szFilter .= "|| index(['c','e','g','s','t','u'], v:val.kind[0])>=0" call filter(a:tagPopupList, szFilter) call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) endfunc " Filter static class members in the popup menu function! s:FilterStaticClassMembers(tagPopupList, szAccessFilter) let szFilter = "!has_key(v:val, 'friendfunc') && has_key(v:val, 'kind') && (index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access') && match(v:val.cmd, '\\Cstatic')!=-1)" let szFilter = s:GetAccessFilter(szFilter, a:szAccessFilter) let szFilter = szFilter . "|| index(['c','e','g','n','s','t','u','v'], v:val.kind[0])>=0" call filter(a:tagPopupList, szFilter) call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) endfunc " Filter scope members in the popup menu function! s:FilterNamespaceScopeMembers(tagPopupList) call extend(s:popupItemResultList, a:tagPopupList) endfunc " Init data at the start of completion function! s:InitComplete() " Reset the popup item list let s:popupItemResultList = [] let s:CACHE_OVERLOADED_FUNCTIONS = {} " Reset includes cache when the current working directory has changed let szCurrentWorkingDir = getcwd() if s:szCurrentWorkingDir != szCurrentWorkingDir let s:szCurrentWorkingDir = szCurrentWorkingDir let g:omni#cpp#includes#CACHE_INCLUDES = {} let g:omni#cpp#includes#CACHE_FILE_TIME = {} endif " Has preview window ? let s:hasPreviewWindow = match(&completeopt, 'preview')>=0 let bResetCache = 0 " Reset tag env or tag files dependent caches if s:HasATagFileOrTagEnvChanged() let bResetCache = 1 endif if (s:OmniCpp_ShowScopeInAbbr != g:OmniCpp_ShowScopeInAbbr) \|| (s:OmniCpp_ShowPrototypeInAbbr != g:OmniCpp_ShowPrototypeInAbbr) \|| (s:OmniCpp_ShowAccess != g:OmniCpp_ShowAccess) let s:OmniCpp_ShowScopeInAbbr = g:OmniCpp_ShowScopeInAbbr let s:OmniCpp_ShowPrototypeInAbbr = g:OmniCpp_ShowPrototypeInAbbr let s:OmniCpp_ShowAccess = g:OmniCpp_ShowAccess let bResetCache = 1 endif if s:hasPreviewWindow != s:hasPreviewWindowOld let s:hasPreviewWindowOld = s:hasPreviewWindow let bResetCache = 1 endif if bResetCache let g:omni#cpp#namespaces#CacheResolve = {} let s:CACHE_TAG_POPUP_ITEMS = {} let g:omni#cpp#utils#CACHE_TAG_INHERITS = {} call garbagecollect() endif " Check for updates for szIncludeName in keys(g:omni#cpp#includes#CACHE_INCLUDES) let fTime = getftime(szIncludeName) let bNeedUpdate = 0 if has_key(g:omni#cpp#includes#CACHE_FILE_TIME, szIncludeName) if fTime != g:omni#cpp#includes#CACHE_FILE_TIME[szIncludeName] let bNeedUpdate = 1 endif else let g:omni#cpp#includes#CACHE_FILE_TIME[szIncludeName] = fTime let bNeedUpdate = 1 endif if bNeedUpdate " We have to update include list and namespace map of this file call omni#cpp#includes#GetList(szIncludeName, 1) call omni#cpp#namespaces#GetMapFromBuffer(szIncludeName, 1) endif endfor let s:bDoNotComplete = 0 endfunc " This function is used for the 'omnifunc' option. function! omni#cpp#complete#Main(findstart, base) if a:findstart "call omni#common#debug#Start() call s:InitComplete() " Note: if s:bMayComplete==1 g:omni#cpp#items#data is build by MayComplete functions if !s:bMayComplete " If the cursor is in a comment we go out if omni#cpp#utils#IsCursorInCommentOrString() " Returning -1 is not enough we have to set a variable to let " the second call of omni#cpp#complete knows that the " cursor was in a comment " Why is there a second call when the first call returns -1 ? let s:bDoNotComplete = 1 return -1 endif " We get items here (whend a:findstart==1) because GetItemsToComplete() " depends on the cursor position. " When a:findstart==0 the cursor position is modified let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction()) endif " Get contexts stack let s:contextStack = omni#cpp#namespaces#GetContexts() " Reinit of may complete indicator let s:bMayComplete = 0 return s:FindStartPositionOfCompletion() endif " If the cursor is in a comment we return an empty result if s:bDoNotComplete let s:bDoNotComplete = 0 return [] endif if len(g:omni#cpp#items#data)==0 " A) CURRENT_SCOPE_COMPLETION_MODE " 1) Displaying data of each context let szAccessFilter = 'all' for szCurrentContext in s:contextStack if szCurrentContext == '::' continue endif let resolvedTagItem = omni#cpp#utils#GetResolvedTagItem(s:contextStack, omni#cpp#utils#CreateTypeInfo(szCurrentContext)) if resolvedTagItem != {} " We don't search base classes because bases classes are " already in the context stack let tagPopupList = s:SearchMembers(resolvedTagItem, a:base) if index(['c','s'], resolvedTagItem.kind[0])>=0 " It's a class or struct call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) let szAccessFilter = 'protected' else " It's a namespace or union, we display all members call s:FilterNamespaceScopeMembers(tagPopupList) endif endif endfor " 2) Displaying global scope members if g:OmniCpp_GlobalScopeSearch call s:SearchGlobalMembers(a:base) endif else let typeInfo = omni#cpp#items#ResolveItemsTypeInfo(s:contextStack, g:omni#cpp#items#data) if typeInfo != {} if g:omni#cpp#items#data[-1].kind == 'itemScope' " B) SCOPE_COMPLETION_MODE if omni#cpp#utils#GetTypeInfoString(typeInfo)=='' call s:SearchGlobalMembers(a:base) else for resolvedTagItem in omni#cpp#utils#GetResolvedTags(s:contextStack, typeInfo) let tagPopupList = s:SearchMembers(resolvedTagItem, a:base) if index(['c','s'], resolvedTagItem.kind[0])>=0 let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(resolvedTagItem) if g:OmniCpp_DisplayMode==0 " We want to complete a class or struct " If this class is a base class so we display all class members if index(s:contextStack, szTypeInfo)<0 let szAccessFilter = 'public' call s:FilterStaticClassMembers(tagPopupList, szAccessFilter) else let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) endif else if index(s:contextStack, szTypeInfo)<0 let szAccessFilter = 'public' else let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' endif call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) endif else " We want to complete a namespace call s:FilterNamespaceScopeMembers(tagPopupList) endif endfor endif else " C) CLASS_MEMBERS_COMPLETION_MODE for resolvedTagItem in omni#cpp#utils#GetResolvedTags(s:contextStack, typeInfo) let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(resolvedTagItem) if index(s:contextStack, szTypeInfo)<0 let szAccessFilter = 'public' else let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' endif call s:FilterClassMembers(s:SearchMembers(resolvedTagItem, a:base), szAccessFilter) endfor endif endif endif "call omni#common#debug#End() return s:popupItemResultList endfunc vim-scripts-20180807ubuntu1/autoload/omni/cpp/includes.vim0000644000000000000000000001056013332536306020344 0ustar " Description: Omni completion script for cpp files " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 let g:omni#cpp#includes#CACHE_INCLUDES = {} let g:omni#cpp#includes#CACHE_FILE_TIME = {} let s:rePreprocIncludePart = '\C#\s*include\s*' let s:reIncludeFilePart = '\(<\|"\)\(\f\|\s\)\+\(>\|"\)' let s:rePreprocIncludeFile = s:rePreprocIncludePart . s:reIncludeFilePart " Get the include list of a file function! omni#cpp#includes#GetList(...) if a:0 > 0 return s:GetIncludeListFromFile(a:1, (a:0 > 1)? a:2 : 0 ) else return s:GetIncludeListFromCurrentBuffer() endif endfunc " Get the include list from the current buffer function! s:GetIncludeListFromCurrentBuffer() let listIncludes = [] let originalPos = getpos('.') call setpos('.', [0, 1, 1, 0]) let curPos = [1,1] let alreadyInclude = {} while curPos != [0,0] let curPos = searchpos('\C\(^'.s:rePreprocIncludeFile.'\)', 'W') if curPos != [0,0] let szLine = getline('.') let startPos = curPos[1] let endPos = matchend(szLine, s:reIncludeFilePart, startPos-1) if endPos!=-1 let szInclusion = szLine[startPos-1:endPos-1] let szIncludeFile = substitute(szInclusion, '\('.s:rePreprocIncludePart.'\)\|[<>""]', '', 'g') let szResolvedInclude = omni#cpp#utils#ResolveFilePath(szIncludeFile) " Protection over self inclusion if szResolvedInclude != '' && szResolvedInclude != omni#cpp#utils#ResolveFilePath(getreg('%')) let includePos = curPos if !has_key(alreadyInclude, szResolvedInclude) call extend(listIncludes, [{'pos' : includePos, 'include' : szResolvedInclude}]) let alreadyInclude[szResolvedInclude] = 1 endif endif endif endif endwhile call setpos('.', originalPos) return listIncludes endfunc " Get the include list from a file function! s:GetIncludeListFromFile(szFilePath, bUpdate) let listIncludes = [] if a:szFilePath == '' return listIncludes endif if !a:bUpdate && has_key(g:omni#cpp#includes#CACHE_INCLUDES, a:szFilePath) return copy(g:omni#cpp#includes#CACHE_INCLUDES[a:szFilePath]) endif let g:omni#cpp#includes#CACHE_FILE_TIME[a:szFilePath] = getftime(a:szFilePath) let szFixedPath = escape(a:szFilePath, g:omni#cpp#utils#szEscapedCharacters) execute 'silent! lvimgrep /\C\(^'.s:rePreprocIncludeFile.'\)/gj '.szFixedPath let listQuickFix = getloclist(0) let alreadyInclude = {} for qf in listQuickFix let szLine = qf.text let startPos = qf.col let endPos = matchend(szLine, s:reIncludeFilePart, startPos-1) if endPos!=-1 let szInclusion = szLine[startPos-1:endPos-1] let szIncludeFile = substitute(szInclusion, '\('.s:rePreprocIncludePart.'\)\|[<>""]', '', 'g') let szResolvedInclude = omni#cpp#utils#ResolveFilePath(szIncludeFile) " Protection over self inclusion if szResolvedInclude != '' && szResolvedInclude != a:szFilePath let includePos = [qf.lnum, qf.col] if !has_key(alreadyInclude, szResolvedInclude) call extend(listIncludes, [{'pos' : includePos, 'include' : szResolvedInclude}]) let alreadyInclude[szResolvedInclude] = 1 endif endif endif endfor let g:omni#cpp#includes#CACHE_INCLUDES[a:szFilePath] = listIncludes return copy(listIncludes) endfunc " For debug purpose function! omni#cpp#includes#Display() let szPathBuffer = omni#cpp#utils#ResolveFilePath(getreg('%')) call s:DisplayIncludeTree(szPathBuffer, 0) endfunc " For debug purpose function! s:DisplayIncludeTree(szFilePath, indent, ...) let includeGuard = {} if a:0 >0 let includeGuard = a:1 endif let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) if has_key(includeGuard, szFilePath) return else let includeGuard[szFilePath] = 1 endif let szIndent = repeat(' ', a:indent) echo szIndent . a:szFilePath let incList = omni#cpp#includes#GetList(a:szFilePath) for inc in incList call s:DisplayIncludeTree(inc.include, a:indent+1, includeGuard) endfor endfunc vim-scripts-20180807ubuntu1/autoload/omni/cpp/items.vim0000644000000000000000000005520513332536306017664 0ustar " Description: Omni completion script for cpp files " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 " Build the item list of an instruction " An item is an instruction between a -> or . or ->* or .* " We can sort an item in different kinds: " eg: ((MyClass1*)(pObject))->_memberOfClass1.get() ->show() " | cast | | member | | method | | method | " @return a list of item " an item is a dictionnary where keys are: " tokens = list of token " kind = itemVariable|itemCast|itemCppCast|itemTemplate|itemFunction|itemUnknown|itemThis|itemScope function! omni#cpp#items#Get(tokens, ...) let bGetWordUnderCursor = (a:0>0)? a:1 : 0 let result = [] let itemsDelimiters = ['->', '.', '->*', '.*'] let tokens = reverse(omni#cpp#utils#BuildParenthesisGroups(a:tokens)) " fsm states: " 0 = initial state " TODO: add description of fsm states let state=(bGetWordUnderCursor)? 1 : 0 let item = {'tokens' : [], 'kind' : 'itemUnknown'} let parenGroup=-1 for token in tokens if state==0 if index(itemsDelimiters, token.value)>=0 let item = {'tokens' : [], 'kind' : 'itemUnknown'} let state = 1 elseif token.value=='::' let state = 9 let item.kind = 'itemScope' " Maybe end of tokens elseif token.kind =='cppOperatorPunctuator' " If it's a cppOperatorPunctuator and the current token is not " a itemsDelimiters or '::' we can exit let state=-1 break endif elseif state==1 call insert(item.tokens, token) if token.kind=='cppWord' " It's an attribute member or a variable let item.kind = 'itemVariable' let state = 2 " Maybe end of tokens elseif token.value=='this' let item.kind = 'itemThis' let state = 2 " Maybe end of tokens elseif token.value==')' let parenGroup = token.group let state = 3 elseif token.value==']' let parenGroup = token.group let state = 4 elseif token.kind == 'cppDigit' let state = -1 break endif elseif state==2 if index(itemsDelimiters, token.value)>=0 call insert(result, item) let item = {'tokens' : [], 'kind' : 'itemUnknown'} let state = 1 elseif token.value == '::' call insert(item.tokens, token) " We have to get namespace or classscope let state = 8 " Maybe end of tokens else call insert(result, item) let state=-1 break endif elseif state==3 call insert(item.tokens, token) if token.value=='(' && token.group == parenGroup let state = 5 " Maybe end of tokens endif elseif state==4 call insert(item.tokens, token) if token.value=='[' && token.group == parenGroup let state = 1 endif elseif state==5 if token.kind=='cppWord' " It's a function or method let item.kind = 'itemFunction' call insert(item.tokens, token) let state = 2 " Maybe end of tokens elseif token.value == '>' " Maybe a cpp cast or template let item.kind = 'itemTemplate' call insert(item.tokens, token) let parenGroup = token.group let state = 6 else " Perhaps it's a C cast eg: ((void*)(pData)) or a variable eg:(*pData) let item.kind = omni#cpp#utils#GetCastType(item.tokens) let state=-1 call insert(result, item) break endif elseif state==6 call insert(item.tokens, token) if token.value == '<' && token.group == parenGroup " Maybe a cpp cast or template let state = 7 endif elseif state==7 call insert(item.tokens, token) if token.kind=='cppKeyword' " It's a cpp cast let item.kind = omni#cpp#utils#GetCastType(item.tokens) let state=-1 call insert(result, item) break else " Template ? let state=-1 call insert(result, item) break endif elseif state==8 if token.kind=='cppWord' call insert(item.tokens, token) let state = 2 " Maybe end of tokens else let state=-1 call insert(result, item) break endif elseif state==9 if token.kind == 'cppWord' call insert(item.tokens, token) let state = 10 " Maybe end of tokens else let state=-1 call insert(result, item) break endif elseif state==10 if token.value == '::' call insert(item.tokens, token) let state = 9 " Maybe end of tokens else let state=-1 call insert(result, item) break endif endif endfor if index([2, 5, 8, 9, 10], state)>=0 if state==5 let item.kind = omni#cpp#utils#GetCastType(item.tokens) endif call insert(result, item) endif return result endfunc " Resolve type information of items " @param namespaces: list of namespaces used in the file " @param szCurrentClassScope: the current class scope, only used for the first " item to detect if this item is a class member (attribute, method) " @param items: list of item, can be an empty list @see GetItemsToComplete function! omni#cpp#items#ResolveItemsTypeInfo(contextStack, items) " Note: kind = itemVariable|cCast|cppCast|template|function|itemUnknown|this " For the first item, if it's a variable we try to detect the type of the " variable with the function searchdecl. If it fails, thanks to the " current class scope, we try to detect if the variable is an attribute " member. " If the kind of the item is a function, we have to first check if the " function is a method of the class, if it fails we try to get a match in " the global namespace. After that we get the returned type of the " function. " It the kind is a C cast or C++ cast, there is no problem, it's the " easiest case. We just extract the type of the cast. let szCurrentContext = '' let typeInfo = {} " Note: We search the decl only for the first item let bSearchDecl = 1 for item in a:items let curItem = item if index(['itemVariable', 'itemFunction'], curItem.kind)>=0 " Note: a variable can be : MyNs::MyClass::_var or _var or (*pVar) " or _var[0][0] let szSymbol = s:GetSymbol(curItem.tokens) " If we have MyNamespace::myVar " We add MyNamespace in the context stack set szSymbol to myVar if match(szSymbol, '::\w\+$') >= 0 let szCurrentContext = substitute(szSymbol, '::\w\+$', '', 'g') let szSymbol = matchstr(szSymbol, '\w\+$') endif let tmpContextStack = a:contextStack if szCurrentContext != '' let tmpContextStack = [szCurrentContext] + a:contextStack endif if curItem.kind == 'itemVariable' let typeInfo = s:GetTypeInfoOfVariable(tmpContextStack, szSymbol, bSearchDecl) else let typeInfo = s:GetTypeInfoOfReturnedType(tmpContextStack, szSymbol) endif elseif curItem.kind == 'itemThis' if len(a:contextStack) let typeInfo = omni#cpp#utils#CreateTypeInfo(substitute(a:contextStack[0], '^::', '', 'g')) endif elseif curItem.kind == 'itemCast' let typeInfo = omni#cpp#utils#CreateTypeInfo(s:ResolveCCast(curItem.tokens)) elseif curItem.kind == 'itemCppCast' let typeInfo = omni#cpp#utils#CreateTypeInfo(s:ResolveCppCast(curItem.tokens)) elseif curItem.kind == 'itemScope' let typeInfo = omni#cpp#utils#CreateTypeInfo(substitute(s:TokensToString(curItem.tokens), '\s', '', 'g')) endif if omni#cpp#utils#IsTypeInfoValid(typeInfo) let szCurrentContext = omni#cpp#utils#GetTypeInfoString(typeInfo) endif let bSearchDecl = 0 endfor return typeInfo endfunc " Get symbol name function! s:GetSymbol(tokens) let szSymbol = '' let state = 0 for token in a:tokens if state == 0 if token.value == '::' let szSymbol .= token.value let state = 1 elseif token.kind == 'cppWord' let szSymbol .= token.value let state = 2 " Maybe end of token endif elseif state == 1 if token.kind == 'cppWord' let szSymbol .= token.value let state = 2 " Maybe end of token else " Error break endif elseif state == 2 if token.value == '::' let szSymbol .= token.value let state = 1 else break endif endif endfor return szSymbol endfunc " Search a declaration. " eg: std::map " can be empty " Note: The returned type info can be a typedef " The typedef resolution is done later " @return " - a dictionnary where keys are " - type: the type of value same as type() " - value: the value function! s:GetTypeInfoOfVariable(contextStack, szVariable, bSearchDecl) let result = {} if a:bSearchDecl " Search type of declaration "let result = s:SearchTypeInfoOfDecl(a:szVariable) let result = s:SearchDecl(a:szVariable) endif if result=={} let szFilter = "index(['m', 'v'], v:val.kind[0])>=0" let tagItem = s:ResolveSymbol(a:contextStack, a:szVariable, szFilter) if tagItem=={} return result endif let szCmdWithoutVariable = substitute(omni#cpp#utils#ExtractCmdFromTagItem(tagItem), '\C\<'.a:szVariable.'\>.*', '', 'g') let tokens = omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCodeFromLine(szCmdWithoutVariable)) let result = omni#cpp#utils#CreateTypeInfo(omni#cpp#utils#ExtractTypeInfoFromTokens(tokens)) " TODO: Namespace resolution for result if result != {} && result.value=='' " result.value=='' " eg: " struct " { " }gVariable; if has_key(tagItem, 'typeref') " Maybe the variable is a global var of an " unnamed class, struct or union. " eg: " 1) " struct " { " }gVariable; " In this case we need the tags (the patched version) " Note: We can have a named type like this: " 2) " class A " { " }gVariable; if s:IsUnnamedType(tagItem) " It's an unnamed type we are in the case 1) let result = omni#cpp#utils#CreateTypeInfo(tagItem) else " It's not an unnamed type we are in the case 2) " eg: tagItem.typeref = 'struct:MY_STRUCT::MY_SUBSTRUCT' let szTypeRef = substitute(tagItem.typeref, '^\w\+:', '', '') " eg: szTypeRef = 'MY_STRUCT::MY_SUBSTRUCT' let result = omni#cpp#utils#CreateTypeInfo(szTypeRef) endif endif endif endif return result endfunc " Get the type info string from the returned type of function function! s:GetTypeInfoOfReturnedType(contextStack, szFunctionName) let result = {} let szFilter = "index(['f', 'p'], v:val.kind[0])>=0" let tagItem = s:ResolveSymbol(a:contextStack, a:szFunctionName, szFilter) if tagItem != {} let szCmdWithoutVariable = substitute(omni#cpp#utils#ExtractCmdFromTagItem(tagItem), '\C\<'.a:szFunctionName.'\>.*', '', 'g') let tokens = omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCodeFromLine(szCmdWithoutVariable)) let result = omni#cpp#utils#CreateTypeInfo(omni#cpp#utils#ExtractTypeInfoFromTokens(tokens)) " TODO: Namespace resolution for result return result endif return result endfunc " Resolve a symbol, return a tagItem " Gets the first symbol found in the context stack function! s:ResolveSymbol(contextStack, szSymbol, szTagFilter) let tagItem = {} for szCurrentContext in a:contextStack if szCurrentContext != '::' let szTagQuery = substitute(szCurrentContext, '^::', '', 'g').'::'.a:szSymbol else let szTagQuery = a:szSymbol endif let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') call filter(tagList, a:szTagFilter) if len(tagList) let tagItem = tagList[0] break endif endfor return tagItem endfunc " Return if the tag item represent an unnamed type function! s:IsUnnamedType(tagItem) let bResult = 0 if has_key(a:tagItem, 'typeref') " Note: Thanks for __anon ! let bResult = match(a:tagItem.typeref, '\C\<__anon') >= 0 endif return bResult endfunc " Search the declaration of a variable and return the type info function! s:SearchTypeInfoOfDecl(szVariable) let szReVariable = '\C\<'.a:szVariable.'\>' let originalPos = getpos('.') let origPos = originalPos[1:2] let curPos = origPos let stopPos = origPos while curPos !=[0,0] " We go to the start of the current scope let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) if curPos != [0,0] let matchPos = curPos " Now want to search our variable but we don't want to go in child " scope while matchPos != [0,0] let matchPos = searchpos('{\|'.szReVariable, 'W', stopPos[0]) if matchPos != [0,0] " We ignore matches under comment if omni#cpp#utils#IsCursorInCommentOrString() continue endif " Getting the current line let szLine = getline('.') if match(szLine, szReVariable)>=0 " We found our variable " Check if the current instruction is a decl instruction let tokens = omni#cpp#utils#TokenizeCurrentInstruction() let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) if szTypeInfo != '' call setpos('.', originalPos) return omni#cpp#utils#CreateTypeInfo(szTypeInfo) endif else " We found a child scope, we don't want to go in, thus " we search for the end } of this child scope let bracketEnd = searchpairpos('{', '', '}', 'nW', g:omni#cpp#utils#expIgnoreComments) if bracketEnd == [0,0] break endif if bracketEnd[0] >= stopPos[0] " The end of the scope is after our cursor we stop " the search break else " We move the cursor and continue to search our " variable call setpos('.', [0, bracketEnd[0], bracketEnd[1], 0]) endif endif endif endwhile " Backing to the start of the scope call setpos('.', [0,curPos[0], curPos[1], 0]) let stopPos = curPos endif endwhile let result = {} if s:LocalSearchDecl(a:szVariable)==0 && !omni#cpp#utils#IsCursorInCommentOrString() let tokens = omni#cpp#utils#TokenizeCurrentInstruction() let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) if szTypeInfo != '' let result = omni#cpp#utils#CreateTypeInfo(szTypeInfo) endif endif call setpos('.', originalPos) return result endfunc " Search a declaration " @return " - tokens of the current instruction if success " - empty list if failure function! s:SearchDecl(szVariable) let result = {} let originalPos = getpos('.') let searchResult = s:LocalSearchDecl(a:szVariable) if searchResult==0 " searchdecl() may detect a decl if the variable is in a conditional " instruction (if, elseif, while etc...) " We have to check if the detected decl is really a decl instruction let tokens = omni#cpp#utils#TokenizeCurrentInstruction() for token in tokens " Simple test if index(['if', 'elseif', 'while', 'for', 'switch'], token.value)>=0 " Invalid declaration instruction call setpos('.', originalPos) return result endif endfor let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) if szTypeInfo != '' let result = omni#cpp#utils#CreateTypeInfo(szTypeInfo) endif endif call setpos('.', originalPos) return result endfunc " Extract the type info string from an instruction. " We use a small parser to extract the type " We parse the code according to a C++ BNF from: http://www.nongnu.org/hcb/#basic.link " @param tokens: token list of the current instruction function! s:ExtractTypeInfoFromDecl(tokens) return omni#cpp#utils#ExtractTypeInfoFromTokens(a:tokens) endfunc " Convert tokens to string function! s:TokensToString(tokens) let result = '' for token in a:tokens let result = result . token.value . ' ' endfor return result[:-2] endfunc " Resolve a cast. " Resolve a C++ cast " @param list of token. tokens must be a list that represents " a cast expression (C++ cast) the function does not control " if it's a cast or not " eg: static_cast(something) " @return type info string function! s:ResolveCppCast(tokens) return omni#cpp#utils#ExtractTypeInfoFromTokens(s:ResolveCast(a:tokens, '<', '>')) endfunc " Resolve a cast. " Resolve a C cast " @param list of token. tokens must be a list that represents " a cast expression (C cast) the function does not control " if it's a cast or not " eg: (MyClass*)something " @return type info string function! s:ResolveCCast(tokens) return omni#cpp#utils#ExtractTypeInfoFromTokens(s:ResolveCast(a:tokens, '(', ')')) endfunc " Resolve a cast. " Resolve a C cast " @param list of token. tokens must be a list that represents " a cast expression (C cast) the function does not control " if it's a cast or not " eg: (MyClass*)something " @return type tokens function! s:ResolveCast(tokens, startChar, endChar) let tokens = omni#cpp#utils#BuildParenthesisGroups(a:tokens) " We remove useless parenthesis eg: (((MyClass))) let tokens = omni#cpp#utils#SimplifyParenthesis(tokens) let countItem=0 let startIndex = -1 let endIndex = -1 let i = 0 for token in tokens if startIndex==-1 if token.value==a:startChar let countItem += 1 let startIndex = i endif else if token.value==a:startChar let countItem += 1 elseif token.value==a:endChar let countItem -= 1 endif if countItem==0 let endIndex = i break endif endif let i+=1 endfor return tokens[startIndex+1 : endIndex-1] endfunc " Replacement for build-in function 'searchdecl' " It does not require that the upper-level bracket is in the first column. " Otherwise it should be equal to 'searchdecl(name, 0, 1)' " @param name: name of variable to find declaration for function! s:LocalSearchDecl(name) if g:OmniCpp_LocalSearchDecl == 0 let bUserIgnoreCase = &ignorecase " Forcing the noignorecase option " avoid bug when, for example, if we have a declaration like this : "A a;" set noignorecase let result = searchdecl(a:name, 0, 1) " Restoring user's setting let &ignorecase = bUserIgnoreCase return result endif let lastpos = getpos('.') let winview = winsaveview() let lastfoldenable = &foldenable let &foldenable = 0 " We add \C (noignorecase) to " avoid bug when, for example, if we have a declaration like this : "A a;" let varname = "\\C\\<" . a:name . "\\>" " Go to first blank line before begin of highest scope normal 99[{ let scopepos = getpos('.') while (line('.') > 1) && (len(split(getline('.'))) > 0) call cursor(line('.')-1, 0) endwhile let declpos = [ 0, 0, 0, 0 ] while search(varname, '', scopepos[1]) > 0 " Check if we are a string or a comment if omni#cpp#utils#IsCursorInCommentOrString() continue endif " Remember match let declpos = getpos('.') endwhile if declpos[1] != 0 " We found a match call winrestview(winview) call setpos('.', declpos) let &foldenable = lastfoldenable return 0 endif while search(varname, '', lastpos[1]) > 0 " Check if current scope is ending before variable let old_cur = getpos('.') normal ]} let new_cur = getpos('.') call setpos('.', old_cur) if (new_cur[1] < lastpos[1]) || ((new_cur[1] == lastpos[1]) && (new_cur[2] < lastpos[2])) continue endif " Check if we are a string or a comment if omni#cpp#utils#IsCursorInCommentOrString() continue endif " We found match call winrestview(winview) call setpos('.', old_cur) let &foldenable = lastfoldenable return 0 endwhile " No match found. call winrestview(winview) let &foldenable = lastfoldenable return 1 endfunc vim-scripts-20180807ubuntu1/autoload/omni/cpp/maycomplete.vim0000644000000000000000000000610713332536306021057 0ustar " Description: Omni completion script for cpp files " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 " Check if we can use omni completion in the current buffer function! s:CanUseOmnicompletion() " For C and C++ files and only if the omnifunc is omni#cpp#complete#Main return (index(['c', 'cpp'], &filetype)>=0 && &omnifunc == 'omni#cpp#complete#Main' && !omni#cpp#utils#IsCursorInCommentOrString()) endfunc " Return the mapping of omni completion function! omni#cpp#maycomplete#Complete() let szOmniMapping = "\\" " 0 = don't select first item " 1 = select first item (inserting it to the text, default vim behaviour) " 2 = select first item (without inserting it to the text) if g:OmniCpp_SelectFirstItem == 0 " We have to force the menuone option to avoid confusion when there is " only one popup item set completeopt-=menu set completeopt+=menuone let szOmniMapping .= "\" elseif g:OmniCpp_SelectFirstItem == 2 " We have to force the menuone option to avoid confusion when there is " only one popup item set completeopt-=menu set completeopt+=menuone let szOmniMapping .= "\" let szOmniMapping .= "\=pumvisible() ? \"\\\" : \"\"\" endif return szOmniMapping endfunc " May complete function for dot function! omni#cpp#maycomplete#Dot() if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteDot let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction('.')) if len(g:omni#cpp#items#data) let s:bMayComplete = 1 return '.' . omni#cpp#maycomplete#Complete() endif endif return '.' endfunc " May complete function for arrow function! omni#cpp#maycomplete#Arrow() if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteArrow let index = col('.') - 2 if index >= 0 let char = getline('.')[index] if char == '-' let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction('>')) if len(g:omni#cpp#items#data) let s:bMayComplete = 1 return '>' . omni#cpp#maycomplete#Complete() endif endif endif endif return '>' endfunc " May complete function for double points function! omni#cpp#maycomplete#Scope() if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteScope let index = col('.') - 2 if index >= 0 let char = getline('.')[index] if char == ':' let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction(':')) if len(g:omni#cpp#items#data) if len(g:omni#cpp#items#data[-1].tokens) && g:omni#cpp#items#data[-1].tokens[-1].value != '::' let s:bMayComplete = 1 return ':' . omni#cpp#maycomplete#Complete() endif endif endif endif endif return ':' endfunc vim-scripts-20180807ubuntu1/autoload/omni/cpp/namespaces.vim0000644000000000000000000007042713332536306020665 0ustar " Description: Omni completion script for cpp files " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 let g:omni#cpp#namespaces#CacheResolve = {} let g:omni#cpp#namespaces#CacheUsing = {} " TODO: For the next release "let g:omni#cpp#namespaces#CacheAlias = {} " Get the using namespace list from a line function! s:GetNamespaceAliasListFromLine(szLine) let result = {} let tokens = omni#cpp#tokenizer#Tokenize(a:szLine) let szAlias = '' let szNamespace = '' let state = 0 for token in tokens if state==0 let szAlias = '' let szNamespace = '' if token.value == '/*' let state = 1 elseif token.value == '//' " It's a comment let state = -1 break elseif token.value == 'namespace' let state = 2 endif elseif state==1 if token.value == '*/' let state=0 endif elseif state==2 if token.kind == 'cppWord' let szAlias .= token.value let state = 3 else let state = -1 break endif elseif state == 3 if token.value == '=' let state = 4 else let state = -1 break endif elseif state == 4 if token.value == '::' let szNamespace .= token.value let state = 5 elseif token.kind == 'cppWord' let szNamespace .= token.value let state = 6 " Maybe end of tokens endif elseif state==5 if token.kind == 'cppWord' let szNamespace .= token.value let state = 6 " Maybe end of tokens else " Error, we can't have 'namespace ALIAS = Something::' let state = -1 break endif elseif state==6 if token.value == '::' let szNamespace .= token.value let state = 5 else call extend(result, {szAlias : szNamespace}) let state = 0 endif endif endfor if state == 6 call extend(result, {szAlias : szNamespace}) endif return result endfunc " Get the using namespace list from a line function! s:GetNamespaceListFromLine(szLine) let result = [] let tokens = omni#cpp#tokenizer#Tokenize(a:szLine) let szNamespace = '' let state = 0 for token in tokens if state==0 let szNamespace = '' if token.value == '/*' let state = 1 elseif token.value == '//' " It's a comment let state = -1 break elseif token.value == 'using' let state = 2 endif elseif state==1 if token.value == '*/' let state=0 endif elseif state==2 if token.value == 'namespace' let state = 3 else " Error, 'using' must be followed by 'namespace' let state = -1 break endif elseif state==3 if token.value == '::' let szNamespace .= token.value let state = 4 elseif token.kind == 'cppWord' let szNamespace .= token.value let state = 5 " Maybe end of tokens endif elseif state==4 if token.kind == 'cppWord' let szNamespace .= token.value let state = 5 " Maybe end of tokens else " Error, we can't have 'using namespace Something::' let state = -1 break endif elseif state==5 if token.value == '::' let szNamespace .= token.value let state = 4 else call extend(result, [szNamespace]) let state = 0 endif endif endfor if state == 5 call extend(result, [szNamespace]) endif return result endfunc " Get the namespace list from a namespace map function! s:GetUsingNamespaceListFromMap(namespaceMap, ...) let stopLine = 0 if a:0>0 let stopLine = a:1 endif let result = [] let keys = sort(keys(a:namespaceMap), 'omni#common#utils#CompareNumber') for i in keys if stopLine != 0 && i > stopLine break endif call extend(result, a:namespaceMap[i]) endfor return result endfunc " Get global using namespace list from the current buffer function! omni#cpp#namespaces#GetListFromCurrentBuffer(...) let namespaceMap = s:GetAllUsingNamespaceMapFromCurrentBuffer() let result = [] if namespaceMap != {} let result = s:GetUsingNamespaceListFromMap(namespaceMap, (a:0 > 0)? a:1 : line('.')) endif return result endfunc " Get global using namespace map from the current buffer and include files recursively function! s:GetAllUsingNamespaceMapFromCurrentBuffer(...) let includeGuard = (a:0>0)? a:1 : {} let szBufferName = getreg("%") let szFilePath = omni#cpp#utils#ResolveFilePath(szBufferName) let szFilePath = (szFilePath=='')? szBufferName : szFilePath let namespaceMap = {} if has_key(includeGuard, szFilePath) return namespaceMap else let includeGuard[szFilePath] = 1 endif let namespaceMap = omni#cpp#namespaces#GetMapFromCurrentBuffer() if g:OmniCpp_NamespaceSearch != 2 " We don't search included files if OmniCpp_NamespaceSearch != 2 return namespaceMap endif for inc in omni#cpp#includes#GetList() let lnum = inc.pos[0] let tmpMap = s:GetAllUsingNamespaceMapFromFile(inc.include, includeGuard) if tmpMap != {} if has_key(namespaceMap, lnum) call extend(namespaceMap[lnum], s:GetUsingNamespaceListFromMap(tmpMap)) else let namespaceMap[lnum] = s:GetUsingNamespaceListFromMap(tmpMap) endif endif endfor return namespaceMap endfunc " Get global using namespace map from a file and include files recursively function! s:GetAllUsingNamespaceMapFromFile(szFilePath, ...) let includeGuard = {} if a:0 >0 let includeGuard = a:1 endif let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) let szFilePath = (szFilePath=='')? a:szFilePath : szFilePath let namespaceMap = {} if has_key(includeGuard, szFilePath) return namespaceMap else let includeGuard[szFilePath] = 1 endif " If g:OmniCpp_NamespaceSearch == 1 (search namespaces only in the current " buffer) we don't use cache for the current buffer let namespaceMap = omni#cpp#namespaces#GetMapFromBuffer(szFilePath, g:OmniCpp_NamespaceSearch==1) if g:OmniCpp_NamespaceSearch != 2 " We don't search included files if OmniCpp_NamespaceSearch != 2 return namespaceMap endif for inc in omni#cpp#includes#GetList(szFilePath) let lnum = inc.pos[0] let tmpMap = s:GetAllUsingNamespaceMapFromFile(inc.include, includeGuard) if tmpMap != {} if has_key(namespaceMap, lnum) call extend(namespaceMap[lnum], s:GetUsingNamespaceListFromMap(tmpMap)) else let namespaceMap[lnum] = s:GetUsingNamespaceListFromMap(tmpMap) endif endif endfor return namespaceMap endfunc " Get global using namespace map from a the current buffer function! omni#cpp#namespaces#GetMapFromCurrentBuffer() let namespaceMap = {} let originalPos = getpos('.') call setpos('.', [0, 1, 1, 0]) let curPos = [1,1] while curPos != [0,0] let curPos = searchpos('\C^using\s\+namespace', 'W') if curPos != [0,0] let szLine = getline('.') let startPos = curPos[1] let endPos = match(szLine, ';', startPos-1) if endPos!=-1 " We get the namespace list from the line let namespaceMap[curPos[0]] = s:GetNamespaceListFromLine(szLine) endif endif endwhile call setpos('.', originalPos) return namespaceMap endfunc " Get global using namespace map from a file function! omni#cpp#namespaces#GetMapFromBuffer(szFilePath, ...) let bUpdate = 0 if a:0 > 0 let bUpdate = a:1 endif let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) let szFilePath = (szFilePath=='')? a:szFilePath : szFilePath if !bUpdate && has_key(g:omni#cpp#namespaces#CacheUsing, szFilePath) return copy(g:omni#cpp#namespaces#CacheUsing[szFilePath]) endif let namespaceMap = {} " The file exists, we get the global namespaces in this file let szFixedPath = escape(szFilePath, g:omni#cpp#utils#szEscapedCharacters) execute 'silent! lvimgrep /\C^using\s\+namespace/gj '.szFixedPath " key = line number " value = list of namespaces let listQuickFix = getloclist(0) for qf in listQuickFix let szLine = qf.text let startPos = qf.col let endPos = match(szLine, ';', startPos-1) if endPos!=-1 " We get the namespace list from the line let namespaceMap[qf.lnum] = s:GetNamespaceListFromLine(szLine) endif endfor if szFixedPath != '' let g:omni#cpp#namespaces#CacheUsing[szFixedPath] = namespaceMap endif return copy(namespaceMap) endfunc " Get the stop position when searching for local variables function! s:GetStopPositionForLocalSearch() " Stop position when searching a local variable let originalPos = getpos('.') let origPos = originalPos[1:2] let stopPosition = origPos let curPos = origPos while curPos !=[0,0] let stopPosition = curPos let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) endwhile call setpos('.', originalPos) return stopPosition endfunc " Get namespaces alias used at the cursor postion in a vim buffer " Note: The result depends on the current cursor position " @return " - Map of namespace alias function! s:GetNamespaceAliasMap() " We store the cursor position because searchpairpos() moves the cursor let result = {} let originalPos = getpos('.') let origPos = originalPos[1:2] let stopPos = s:GetStopPositionForLocalSearch() let stopLine = stopPos[0] let curPos = origPos let lastLine = 0 let nextStopLine = origPos[0] let szReAlias = '\Cnamespace\s\+\w\+\s\+=' while curPos !=[0,0] let curPos = searchpos('}\|\('. szReAlias .'\)', 'bW',stopLine) if curPos!=[0,0] && curPos[0]!=lastLine let lastLine = curPos[0] let szLine = getline('.') if origPos[0] == curPos[0] " We get the line until cursor position let szLine = szLine[:origPos[1]] endif let szLine = omni#cpp#utils#GetCodeFromLine(szLine) if match(szLine, szReAlias)<0 " We found a '}' let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) else " We get the namespace alias from the line call extend(result, s:GetNamespaceAliasListFromLine(szLine)) let nextStopLine = curPos[0] endif endif endwhile " Setting the cursor to the original position call setpos('.', originalPos) call s:ResolveAliasKeys(result) return result endfunc " Resolve an alias " eg: namespace IAmAnAlias1 = Ns1 " eg: namespace IAmAnAlias2 = IAmAnAlias1::Ns2 " => IAmAnAlias2 = Ns1::Ns2 function! s:ResolveAliasKey(mapNamespaceAlias, szAlias) let szResult = a:mapNamespaceAlias[a:szAlias] " ::Ns1::Ns2::Ns3 => ['Ns1', 'Ns2', 'Ns3'] let listNamespace = split(szResult, '::') if len(listNamespace) " szBeginPart = 'Ns1' let szBeginPart = remove(listNamespace, 0) " Is 'Ns1' an alias ? if has_key(a:mapNamespaceAlias, szBeginPart) && szBeginPart != a:szAlias " Resolving alias 'Ns1' " eg: Ns1 = NsResolved let szResult = s:ResolveAliasKey(a:mapNamespaceAlias, szBeginPart) " szEndPart = 'Ns2::Ns3' let szEndPart = join(listNamespace, '::') if szEndPart != '' " Concatenation => szResult = 'NsResolved::Ns2::Ns3' let szResult .= '::' . szEndPart endif endif endif return szResult endfunc " Resolve all keys in the namespace alias map function! s:ResolveAliasKeys(mapNamespaceAlias) let mapNamespaceAlias = a:mapNamespaceAlias call map(mapNamespaceAlias, 's:ResolveAliasKey(mapNamespaceAlias, v:key)') endfunc " Resolve namespace alias function! omni#cpp#namespaces#ResolveAlias(mapNamespaceAlias, szNamespace) let szResult = a:szNamespace " ::Ns1::Ns2::Ns3 => ['Ns1', 'Ns2', 'Ns3'] let listNamespace = split(a:szNamespace, '::') if len(listNamespace) " szBeginPart = 'Ns1' let szBeginPart = remove(listNamespace, 0) " Is 'Ns1' an alias ? if has_key(a:mapNamespaceAlias, szBeginPart) " Resolving alias 'Ns1' " eg: Ns1 = NsResolved let szResult = a:mapNamespaceAlias[szBeginPart] " szEndPart = 'Ns2::Ns3' let szEndPart = join(listNamespace, '::') if szEndPart != '' " Concatenation => szResult = 'NsResolved::Ns2::Ns3' let szResult .= '::' . szEndPart endif " If a:szNamespace starts with '::' we add '::' to the beginning " of the result if match(a:szNamespace, '^::')>=0 let szResult = omni#cpp#utils#SimplifyScope('::' . szResult) endif endif endif return szResult endfunc " Resolve namespace alias function! s:ResolveAliasInNamespaceList(mapNamespaceAlias, listNamespaces) call map(a:listNamespaces, 'omni#cpp#namespaces#ResolveAlias(a:mapNamespaceAlias, v:val)') endfunc " Get namespaces used at the cursor postion in a vim buffer " Note: The result depends on the current cursor position " @return " - List of namespace used in the reverse order function! omni#cpp#namespaces#GetUsingNamespaces() " We have to get local using namespace declarations " We need the current cursor position and the position of the start of the " current scope " We store the cursor position because searchpairpos() moves the cursor let result = [] let originalPos = getpos('.') let origPos = originalPos[1:2] let stopPos = s:GetStopPositionForLocalSearch() let stopLine = stopPos[0] let curPos = origPos let lastLine = 0 let nextStopLine = origPos[0] while curPos !=[0,0] let curPos = searchpos('\C}\|\(using\s\+namespace\)', 'bW',stopLine) if curPos!=[0,0] && curPos[0]!=lastLine let lastLine = curPos[0] let szLine = getline('.') if origPos[0] == curPos[0] " We get the line until cursor position let szLine = szLine[:origPos[1]] endif let szLine = omni#cpp#utils#GetCodeFromLine(szLine) if match(szLine, '\Cusing\s\+namespace')<0 " We found a '}' let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) else " We get the namespace list from the line let result = s:GetNamespaceListFromLine(szLine) + result let nextStopLine = curPos[0] endif endif endwhile " Setting the cursor to the original position call setpos('.', originalPos) " 2) Now we can get all global using namespace declaration from the " beginning of the file to nextStopLine let result = omni#cpp#namespaces#GetListFromCurrentBuffer(nextStopLine) + result " Resolving alias in the namespace list " TODO: For the next release "let g:omni#cpp#namespaces#CacheAlias= s:GetNamespaceAliasMap() "call s:ResolveAliasInNamespaceList(g:omni#cpp#namespaces#CacheAlias, result) return ['::'] + result endfunc " Resolve a using namespace regarding the current context " For each namespace used: " - We get all possible contexts where the namespace " can be define " - We do a comparison test of each parent contexts with the current " context list " - If one and only one parent context is present in the " current context list we add the namespace in the current " context " - If there is more than one of parent contexts in the " current context the namespace is ambiguous " @return " - result item " - kind = 0|1 " - 0 = unresolved or error " - 1 = resolved " - value = resolved namespace function! s:ResolveNamespace(namespace, mapCurrentContexts) let result = {'kind':0, 'value': ''} " If the namespace is already resolved we add it in the list of " current contexts if match(a:namespace, '^::')>=0 let result.kind = 1 let result.value = a:namespace return result elseif match(a:namespace, '\w\+::\w\+')>=0 let mapCurrentContextsTmp = copy(a:mapCurrentContexts) let resolvedItem = {} for nsTmp in split(a:namespace, '::') let resolvedItem = s:ResolveNamespace(nsTmp, mapCurrentContextsTmp) if resolvedItem.kind " Note: We don't extend the map let mapCurrentContextsTmp = {resolvedItem.value : 1} else break endif endfor if resolvedItem!={} && resolvedItem.kind let result.kind = 1 let result.value = resolvedItem.value endif return result endif " We get all possible parent contexts of this namespace let listTagsOfNamespace = [] if has_key(g:omni#cpp#namespaces#CacheResolve, a:namespace) let listTagsOfNamespace = g:omni#cpp#namespaces#CacheResolve[a:namespace] else let listTagsOfNamespace = omni#common#utils#TagList('^'.a:namespace.'$') let g:omni#cpp#namespaces#CacheResolve[a:namespace] = listTagsOfNamespace endif if len(listTagsOfNamespace)==0 return result endif call filter(listTagsOfNamespace, 'v:val.kind[0]=="n"') " We extract parent context from tags " We use a map to avoid multiple entries let mapContext = {} for tagItem in listTagsOfNamespace let szParentContext = omni#cpp#utils#ExtractScope(tagItem) let mapContext[szParentContext] = 1 endfor let listParentContext = keys(mapContext) " Now for each parent context we test if the context is in the current " contexts list let listResolvedNamespace = [] for szParentContext in listParentContext if has_key(a:mapCurrentContexts, szParentContext) call extend(listResolvedNamespace, [omni#cpp#utils#SimplifyScope(szParentContext.'::'.a:namespace)]) endif endfor " Now we know if the namespace is ambiguous or not let len = len(listResolvedNamespace) if len==1 " Namespace resolved let result.kind = 1 let result.value = listResolvedNamespace[0] elseif len > 1 " Ambiguous namespace, possible matches are in listResolvedNamespace else " Other cases endif return result endfunc " Resolve namespaces "@return " - List of resolved namespaces function! omni#cpp#namespaces#ResolveAll(namespacesUsed) " We add the default context '::' let contextOrder = 0 let mapCurrentContexts = {} " For each namespace used: " - We get all possible contexts where the namespace " can be define " - We do a comparison test of each parent contexts with the current " context list " - If one and only one parent context is present in the " current context list we add the namespace in the current " context " - If there is more than one of parent contexts in the " current context the namespace is ambiguous for ns in a:namespacesUsed let resolvedItem = s:ResolveNamespace(ns, mapCurrentContexts) if resolvedItem.kind let contextOrder+=1 let mapCurrentContexts[resolvedItem.value] = contextOrder endif endfor " Build the list of current contexts from the map, we have to keep the " order let mapReorder = {} for key in keys(mapCurrentContexts) let mapReorder[ mapCurrentContexts[key] ] = key endfor let result = [] for key in sort(keys(mapReorder)) call extend(result, [mapReorder[key]]) endfor return result endfunc " Build the context stack function! s:BuildContextStack(namespaces, szCurrentScope) let result = copy(a:namespaces) if a:szCurrentScope != '::' let tagItem = omni#cpp#utils#GetResolvedTagItem(a:namespaces, omni#cpp#utils#CreateTypeInfo(a:szCurrentScope)) if has_key(tagItem, 'inherits') let listBaseClass = omni#cpp#utils#GetClassInheritanceList(a:namespaces, omni#cpp#utils#CreateTypeInfo(a:szCurrentScope)) let result = listBaseClass + result elseif has_key(tagItem, 'kind') && index(['c', 's', 'u', 'n'], tagItem.kind[0])>=0 call insert(result, omni#cpp#utils#ExtractTypeInfoFromTag(tagItem)) endif endif return result endfunc " Returns the class scope at the current position of the cursor " @return a string that represents the class scope " eg: ::NameSpace1::Class1 " The returned string always starts with '::' " Note: In term of performance it's the weak point of the script function! s:GetClassScopeAtCursor() " We store the cursor position because searchpairpos() moves the cursor let originalPos = getpos('.') let endPos = originalPos[1:2] let listCode = [] let result = {'namespaces': [], 'scope': ''} while endPos!=[0,0] let endPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) let szReStartPos = '[;{}]\|\%^' let startPos = searchpairpos(szReStartPos, '', '{', 'bWn', g:omni#cpp#utils#expIgnoreComments) " If the file starts with a comment so the startPos can be [0,0] " we change it to [1,1] if startPos==[0,0] let startPos = [1,1] endif " Get lines backward from cursor position to last ; or { or } " or when we are at the beginning of the file. " We store lines in listCode if endPos!=[0,0] " We remove the last character which is a '{' " We also remove starting { or } or ; if exits let szCodeWithoutComments = substitute(omni#cpp#utils#GetCode(startPos, endPos)[:-2], '^[;{}]', '', 'g') call insert(listCode, {'startLine' : startPos[0], 'code' : szCodeWithoutComments}) endif endwhile " Setting the cursor to the original position call setpos('.', originalPos) let listClassScope = [] let bResolved = 0 let startLine = 0 " Now we can check in the list of code if there is a function for code in listCode " We get the name of the namespace, class, struct or union " and we store it in listClassScope let tokens = omni#cpp#tokenizer#Tokenize(code.code) let bContinue=0 let bAddNamespace = 0 let state=0 for token in tokens if state==0 if index(['namespace', 'class', 'struct', 'union'], token.value)>=0 if token.value == 'namespace' let bAddNamespace = 1 endif let state= 1 " Maybe end of tokens endif elseif state==1 if token.kind == 'cppWord' " eg: namespace MyNs { class MyCl {}; } " => listClassScope = [MyNs, MyCl] call extend( listClassScope , [token.value] ) " Add the namespace in result if bAddNamespace call extend(result.namespaces, [token.value]) let bAddNamespace = 0 endif let bContinue=1 break endif endif endfor if bContinue==1 continue endif " Simple test to check if we have a chance to find a " class method let aPos = matchend(code.code, '::\s*\~*\s*\w\+\s*(') if aPos ==-1 continue endif let startLine = code.startLine let listTmp = [] " eg: 'void MyNamespace::MyClass::foo(' " => tokens = ['MyClass', '::', 'MyNamespace', 'void'] let tokens = reverse(omni#cpp#tokenizer#Tokenize(code.code[:aPos-1])[:-4]) let state = 0 " Reading tokens backward for token in tokens if state==0 if token.kind=='cppWord' call insert(listTmp, token.value) let state=1 endif elseif state==1 if token.value=='::' let state=2 else break endif elseif state==2 if token.kind=='cppWord' call insert(listTmp, token.value) let state=1 else break endif endif endfor if len(listTmp) if len(listClassScope) let bResolved = 1 " Merging class scopes " eg: current class scope = 'MyNs::MyCl1' " method class scope = 'MyCl1::MyCl2' " If we add the method class scope to current class scope " we'll have MyNs::MyCl1::MyCl1::MyCl2 => it's wrong " we want MyNs::MyCl1::MyCl2 let index = 0 for methodClassScope in listTmp if methodClassScope==listClassScope[-1] let listTmp = listTmp[index+1:] break else let index+=1 endif endfor endif call extend(listClassScope, listTmp) break endif endfor let szClassScope = '::' if len(listClassScope) if bResolved let szClassScope .= join(listClassScope, '::') else let szClassScope = join(listClassScope, '::') " The class scope is not resolved, we have to check using " namespace declarations and search the class scope in each " namespace if startLine != 0 let namespaces = ['::'] + omni#cpp#namespaces#GetListFromCurrentBuffer(startLine) let namespaces = omni#cpp#namespaces#ResolveAll(namespaces) let tagItem = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(szClassScope)) if tagItem != {} let szClassScope = omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) endif endif endif endif let result.scope = szClassScope return result endfunc " Get all contexts at the cursor position function! omni#cpp#namespaces#GetContexts() " Get the current class scope at the cursor, the result depends on the current cursor position let scopeItem = s:GetClassScopeAtCursor() let listUsingNamespace = copy(g:OmniCpp_DefaultNamespaces) call extend(listUsingNamespace, scopeItem.namespaces) if g:OmniCpp_NamespaceSearch && &filetype != 'c' " Get namespaces used in the file until the cursor position let listUsingNamespace = omni#cpp#namespaces#GetUsingNamespaces() + listUsingNamespace " Resolving namespaces, removing ambiguous namespaces let namespaces = omni#cpp#namespaces#ResolveAll(listUsingNamespace) else let namespaces = ['::'] + listUsingNamespace endif call reverse(namespaces) " Building context stack from namespaces and the current class scope return s:BuildContextStack(namespaces, scopeItem.scope) endfunc vim-scripts-20180807ubuntu1/autoload/omni/cpp/settings.vim0000644000000000000000000000541013332536306020374 0ustar " Description: Omni completion script for cpp files " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 function! omni#cpp#settings#Init() " Global scope search on/off " 0 = disabled " 1 = enabled if !exists('g:OmniCpp_GlobalScopeSearch') let g:OmniCpp_GlobalScopeSearch = 1 endif " Sets the namespace search method " 0 = disabled " 1 = search namespaces in the current file " 2 = search namespaces in the current file and included files if !exists('g:OmniCpp_NamespaceSearch') let g:OmniCpp_NamespaceSearch = 1 endif " Set the class scope completion mode " 0 = auto " 1 = show all members (static, public, protected and private) if !exists('g:OmniCpp_DisplayMode') let g:OmniCpp_DisplayMode = 0 endif " Set if the scope is displayed in the abbr column of the popup " 0 = no " 1 = yes if !exists('g:OmniCpp_ShowScopeInAbbr') let g:OmniCpp_ShowScopeInAbbr = 0 endif " Set if the function prototype is displayed in the abbr column of the popup " 0 = no " 1 = yes if !exists('g:OmniCpp_ShowPrototypeInAbbr') let g:OmniCpp_ShowPrototypeInAbbr = 0 endif " Set if the access (+,#,-) is displayed " 0 = no " 1 = yes if !exists('g:OmniCpp_ShowAccess') let g:OmniCpp_ShowAccess = 1 endif " Set the list of default namespaces " eg: ['std'] if !exists('g:OmniCpp_DefaultNamespaces') let g:OmniCpp_DefaultNamespaces = [] endif " Set MayComplete to '.' " 0 = disabled " 1 = enabled " default = 1 if !exists('g:OmniCpp_MayCompleteDot') let g:OmniCpp_MayCompleteDot = 1 endif " Set MayComplete to '->' " 0 = disabled " 1 = enabled " default = 1 if !exists('g:OmniCpp_MayCompleteArrow') let g:OmniCpp_MayCompleteArrow = 1 endif " Set MayComplete to dot " 0 = disabled " 1 = enabled " default = 0 if !exists('g:OmniCpp_MayCompleteScope') let g:OmniCpp_MayCompleteScope = 0 endif " When completeopt does not contain longest option, this setting " controls the behaviour of the popup menu selection when starting the completion " 0 = don't select first item " 1 = select first item (inserting it to the text) " 2 = select first item (without inserting it to the text) " default = 0 if !exists('g:OmniCpp_SelectFirstItem') let g:OmniCpp_SelectFirstItem= 0 endif " Use local search function for variable definitions " 0 = use standard vim search function " 1 = use local search function " default = 0 if !exists('g:OmniCpp_LocalSearchDecl') let g:OmniCpp_LocalSearchDecl= 0 endif endfunc vim-scripts-20180807ubuntu1/autoload/omni/cpp/tokenizer.vim0000644000000000000000000000773613332536306020563 0ustar " Description: Omni completion tokenizer " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 " TODO: Generic behaviour for Tokenize() " From the C++ BNF let s:cppKeyword = ['asm', 'auto', 'bool', 'break', 'case', 'catch', 'char', 'class', 'const', 'const_cast', 'continue', 'default', 'delete', 'do', 'double', 'dynamic_cast', 'else', 'enum', 'explicit', 'export', 'extern', 'false', 'float', 'for', 'friend', 'goto', 'if', 'inline', 'int', 'long', 'mutable', 'namespace', 'new', 'operator', 'private', 'protected', 'public', 'register', 'reinterpret_cast', 'return', 'short', 'signed', 'sizeof', 'static', 'static_cast', 'struct', 'switch', 'template', 'this', 'throw', 'true', 'try', 'typedef', 'typeid', 'typename', 'union', 'unsigned', 'using', 'virtual', 'void', 'volatile', 'wchar_t', 'while', 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not', 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'] let s:reCppKeyword = '\C\<'.join(s:cppKeyword, '\>\|\<').'\>' " The order of items in this list is very important because we use this list to build a regular " expression (see below) for tokenization let s:cppOperatorPunctuator = ['->*', '->', '--', '-=', '-', '!=', '!', '##', '#', '%:%:', '%=', '%>', '%:', '%', '&&', '&=', '&', '(', ')', '*=', '*', ',', '...', '.*', '.', '/=', '/', '::', ':>', ':', ';', '?', '[', ']', '^=', '^', '{', '||', '|=', '|', '}', '~', '++', '+=', '+', '<<=', '<%', '<:', '<<', '<=', '<', '==', '=', '>>=', '>>', '>=', '>'] " We build the regexp for the tokenizer let s:reCComment = '\/\*\|\*\/' let s:reCppComment = '\/\/' let s:reComment = s:reCComment.'\|'.s:reCppComment let s:reCppOperatorOrPunctuator = escape(join(s:cppOperatorPunctuator, '\|'), '*./^~[]') " Tokenize a c++ code " a token is dictionary where keys are: " - kind = cppKeyword|cppWord|cppOperatorPunctuator|unknown|cComment|cppComment|cppDigit " - value = 'something' " Note: a cppWord is any word that is not a cpp keyword function! omni#cpp#tokenizer#Tokenize(szCode) let result = [] " The regexp to find a token, a token is a keyword, word or " c++ operator or punctuator. To work properly we have to put " spaces and tabs to our regexp. let reTokenSearch = '\(\w\+\)\|\s\+\|'.s:reComment.'\|'.s:reCppOperatorOrPunctuator " eg: 'using namespace std;' " ^ ^ " start=0 end=5 let startPos = 0 let endPos = matchend(a:szCode, reTokenSearch) let len = endPos-startPos while endPos!=-1 " eg: 'using namespace std;' " ^ ^ " start=0 end=5 " token = 'using' " We also remove space and tabs let token = substitute(strpart(a:szCode, startPos, len), '\s', '', 'g') " eg: 'using namespace std;' " ^ ^ " start=5 end=15 let startPos = endPos let endPos = matchend(a:szCode, reTokenSearch, startPos) let len = endPos-startPos " It the token is empty we continue if token=='' continue endif " Building the token let resultToken = {'kind' : 'unknown', 'value' : token} " Classify the token if token =~ '^\d\+' " It's a digit let resultToken.kind = 'cppDigit' elseif token=~'^\w\+$' " It's a word let resultToken.kind = 'cppWord' " But maybe it's a c++ keyword if match(token, s:reCppKeyword)>=0 let resultToken.kind = 'cppKeyword' endif else if match(token, s:reComment)>=0 if index(['/*','*/'],token)>=0 let resultToken.kind = 'cComment' else let resultToken.kind = 'cppComment' endif else " It's an operator let resultToken.kind = 'cppOperatorPunctuator' endif endif " We have our token, let's add it to the result list call extend(result, [resultToken]) endwhile return result endfunc vim-scripts-20180807ubuntu1/autoload/omni/cpp/utils.vim0000644000000000000000000004723713332536306017711 0ustar " Description: Omni completion script for cpp files " Maintainer: Vissale NEANG " Last Change: 26 sept. 2007 let g:omni#cpp#utils#CACHE_TAG_INHERITS = {} let g:omni#cpp#utils#szFilterGlobalScope = "(!has_key(v:val, 'class') && !has_key(v:val, 'struct') && !has_key(v:val, 'union') && !has_key(v:val, 'namespace')" let g:omni#cpp#utils#szFilterGlobalScope .= "&& (!has_key(v:val, 'enum') || (has_key(v:val, 'enum') && v:val.enum =~ '^\\w\\+$')))" " Expression used to ignore comments " Note: this expression drop drastically the performance "let omni#cpp#utils#expIgnoreComments = 'match(synIDattr(synID(line("."), col("."), 1), "name"), '\CcComment')!=-1' " This one is faster but not really good for C comments let omni#cpp#utils#reIgnoreComment = escape('\/\/\|\/\*\|\*\/', '*/\') let omni#cpp#utils#expIgnoreComments = 'getline(".") =~ g:omni#cpp#utils#reIgnoreComment' " Characters to escape in a filename for vimgrep "TODO: Find more characters to escape let omni#cpp#utils#szEscapedCharacters = ' %#' " Resolve the path of the file " TODO: absolute file path function! omni#cpp#utils#ResolveFilePath(szFile) let result = '' let listPath = split(globpath(&path, a:szFile), "\n") if len(listPath) let result = listPath[0] endif return simplify(result) endfunc " Get code without comments and with empty strings " szSingleLine must not have carriage return function! omni#cpp#utils#GetCodeFromLine(szSingleLine) " We set all strings to empty strings, it's safer for " the next of the process let szResult = substitute(a:szSingleLine, '".*"', '""', 'g') " Removing c++ comments, we can use the pattern ".*" because " we are modifying a line let szResult = substitute(szResult, '\/\/.*', '', 'g') " Now we have the entire code in one line and we can remove C comments return s:RemoveCComments(szResult) endfunc " Remove C comments on a line function! s:RemoveCComments(szLine) let result = a:szLine " We have to match the first '/*' and first '*/' let startCmt = match(result, '\/\*') let endCmt = match(result, '\*\/') while startCmt!=-1 && endCmt!=-1 && startCmt0 let result = result[ : startCmt-1 ] . result[ endCmt+2 : ] else " Case where '/*' is at the start of the line let result = result[ endCmt+2 : ] endif let startCmt = match(result, '\/\*') let endCmt = match(result, '\*\/') endwhile return result endfunc " Get a c++ code from current buffer from [lineStart, colStart] to " [lineEnd, colEnd] without c++ and c comments, without end of line " and with empty strings if any " @return a string function! omni#cpp#utils#GetCode(posStart, posEnd) let posStart = a:posStart let posEnd = a:posEnd if a:posStart[0]>a:posEnd[0] let posStart = a:posEnd let posEnd = a:posStart elseif a:posStart[0]==a:posEnd[0] && a:posStart[1]>a:posEnd[1] let posStart = a:posEnd let posEnd = a:posStart endif " Getting the lines let lines = getline(posStart[0], posEnd[0]) let lenLines = len(lines) " Formatting the result let result = '' if lenLines==1 let sStart = posStart[1]-1 let sEnd = posEnd[1]-1 let line = lines[0] let lenLastLine = strlen(line) let sEnd = (sEnd>lenLastLine)?lenLastLine : sEnd if sStart >= 0 let result = omni#cpp#utils#GetCodeFromLine(line[ sStart : sEnd ]) endif elseif lenLines>1 let sStart = posStart[1]-1 let sEnd = posEnd[1]-1 let lenLastLine = strlen(lines[-1]) let sEnd = (sEnd>lenLastLine)?lenLastLine : sEnd if sStart >= 0 let lines[0] = lines[0][ sStart : ] let lines[-1] = lines[-1][ : sEnd ] for aLine in lines let result = result . omni#cpp#utils#GetCodeFromLine(aLine)." " endfor let result = result[:-2] endif endif " Now we have the entire code in one line and we can remove C comments return s:RemoveCComments(result) endfunc " Extract the scope (context) of a tag item " eg: ::MyNamespace " @return a string of the scope. a scope from tag always starts with '::' function! omni#cpp#utils#ExtractScope(tagItem) let listKindScope = ['class', 'struct', 'union', 'namespace', 'enum'] let szResult = '::' for scope in listKindScope if has_key(a:tagItem, scope) let szResult = szResult . a:tagItem[scope] break endif endfor return szResult endfunc " Simplify scope string, remove consecutive '::' if any function! omni#cpp#utils#SimplifyScope(szScope) let szResult = substitute(a:szScope, '\(::\)\+', '::', 'g') if szResult=='::' return szResult else return substitute(szResult, '::$', '', 'g') endif endfunc " Check if the cursor is in comment function! omni#cpp#utils#IsCursorInCommentOrString() return match(synIDattr(synID(line("."), col(".")-1, 1), "name"), '\C\=0 endfunc " Tokenize the current instruction until the cursor position. " @return list of tokens function! omni#cpp#utils#TokenizeCurrentInstruction(...) let szAppendText = '' if a:0>0 let szAppendText = a:1 endif let startPos = searchpos('[;{}]\|\%^', 'bWn') let curPos = getpos('.')[1:2] " We don't want the character under the cursor let column = curPos[1]-1 let curPos[1] = (column<1)?1:column return omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCode(startPos, curPos)[1:] . szAppendText) endfunc " Tokenize the current instruction until the word under the cursor. " @return list of tokens function! omni#cpp#utils#TokenizeCurrentInstructionUntilWord() let startPos = searchpos('[;{}]\|\%^', 'bWn') " Saving the current cursor pos let originalPos = getpos('.') " We go at the end of the word execute 'normal gee' let curPos = getpos('.')[1:2] " Restoring the original cursor pos call setpos('.', originalPos) let szCode = omni#cpp#utils#GetCode(startPos, curPos)[1:] return omni#cpp#tokenizer#Tokenize(szCode) endfunc " Build parenthesis groups " add a new key 'group' in the token " where value is the group number of the parenthesis " eg: (void*)(MyClass*) " group1 group0 " if a parenthesis is unresolved the group id is -1 " @return a copy of a:tokens with parenthesis group function! omni#cpp#utils#BuildParenthesisGroups(tokens) let tokens = copy(a:tokens) let kinds = {'(': '()', ')' : '()', '[' : '[]', ']' : '[]', '<' : '<>', '>' : '<>', '{': '{}', '}': '{}'} let unresolved = {'()' : [], '[]': [], '<>' : [], '{}' : []} let groupId = 0 " Note: we build paren group in a backward way " because we can often have parenthesis unbalanced " instruction " eg: doSomething(_member.get()-> for token in reverse(tokens) if index([')', ']', '>', '}'], token.value)>=0 let token['group'] = groupId call extend(unresolved[kinds[token.value]], [token]) let groupId+=1 elseif index(['(', '[', '<', '{'], token.value)>=0 if len(unresolved[kinds[token.value]]) let tokenResolved = remove(unresolved[kinds[token.value]], -1) let token['group'] = tokenResolved.group else let token['group'] = -1 endif endif endfor return reverse(tokens) endfunc " Determine if tokens represent a C cast " @return " - itemCast " - itemCppCast " - itemVariable " - itemThis function! omni#cpp#utils#GetCastType(tokens) " Note: a:tokens is not modified let tokens = omni#cpp#utils#SimplifyParenthesis(omni#cpp#utils#BuildParenthesisGroups(a:tokens)) if tokens[0].value == '(' return 'itemCast' elseif index(['static_cast', 'dynamic_cast', 'reinterpret_cast', 'const_cast'], tokens[0].value)>=0 return 'itemCppCast' else for token in tokens if token.value=='this' return 'itemThis' endif endfor return 'itemVariable' endif endfunc " Remove useless parenthesis function! omni#cpp#utils#SimplifyParenthesis(tokens) "Note: a:tokens is not modified let tokens = a:tokens " We remove useless parenthesis eg: (((MyClass))) if len(tokens)>2 while tokens[0].value=='(' && tokens[-1].value==')' && tokens[0].group==tokens[-1].group let tokens = tokens[1:-2] endwhile endif return tokens endfunc " Function create a type info function! omni#cpp#utils#CreateTypeInfo(param) let type = type(a:param) return {'type': type, 'value':a:param} endfunc " Extract type info from a tag item " eg: ::MyNamespace::MyClass function! omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) let szTypeInfo = omni#cpp#utils#ExtractScope(a:tagItem) . '::' . substitute(a:tagItem.name, '.*::', '', 'g') return omni#cpp#utils#SimplifyScope(szTypeInfo) endfunc " Build a class inheritance list function! omni#cpp#utils#GetClassInheritanceList(namespaces, typeInfo) let result = [] for tagItem in omni#cpp#utils#GetResolvedTags(a:namespaces, a:typeInfo) call extend(result, [omni#cpp#utils#ExtractTypeInfoFromTag(tagItem)]) endfor return result endfunc " Get class inheritance list where items in the list are tag items. " TODO: Verify inheritance order function! omni#cpp#utils#GetResolvedTags(namespaces, typeInfo) let result = [] let tagItem = omni#cpp#utils#GetResolvedTagItem(a:namespaces, a:typeInfo) if tagItem!={} let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) if has_key(g:omni#cpp#utils#CACHE_TAG_INHERITS, szTypeInfo) let result = g:omni#cpp#utils#CACHE_TAG_INHERITS[szTypeInfo] else call extend(result, [tagItem]) if has_key(tagItem, 'inherits') for baseClassTypeInfo in split(tagItem.inherits, ',') let namespaces = [omni#cpp#utils#ExtractScope(tagItem), '::'] call extend(result, omni#cpp#utils#GetResolvedTags(namespaces, omni#cpp#utils#CreateTypeInfo(baseClassTypeInfo))) endfor endif let g:omni#cpp#utils#CACHE_TAG_INHERITS[szTypeInfo] = result endif endif return result endfunc " Get a tag item after a scope resolution and typedef resolution function! omni#cpp#utils#GetResolvedTagItem(namespaces, typeInfo) let typeInfo = {} if type(a:typeInfo) == 1 let typeInfo = omni#cpp#utils#CreateTypeInfo(a:typeInfo) else let typeInfo = a:typeInfo endif let result = {} if !omni#cpp#utils#IsTypeInfoValid(typeInfo) return result endif " Unnamed type case eg: '1::2' if typeInfo.type == 4 " Here there is no typedef or namespace to resolve, the tagInfo.value is a tag item " representing a variable ('v') a member ('m') or a typedef ('t') and the typename is " always in global scope return typeInfo.value endif " Named type case eg: 'MyNamespace::MyClass' let szTypeInfo = omni#cpp#utils#GetTypeInfoString(typeInfo) " Resolving namespace alias " TODO: For the next release "let szTypeInfo = omni#cpp#namespaces#ResolveAlias(g:omni#cpp#namespaces#CacheAlias, szTypeInfo) if szTypeInfo=='::' return result endif " We can only get members of class, struct, union and namespace let szTagFilter = "index(['c', 's', 'u', 'n', 't'], v:val.kind[0])>=0" let szTagQuery = szTypeInfo if s:IsTypeInfoResolved(szTypeInfo) " The type info is already resolved, we remove the starting '::' let szTagQuery = substitute(szTypeInfo, '^::', '', 'g') if len(split(szTagQuery, '::'))==1 " eg: ::MyClass " Here we have to get tags that have no parent scope " That's why we change the szTagFilter let szTagFilter .= '&& ' . g:omni#cpp#utils#szFilterGlobalScope let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') call filter(tagList, szTagFilter) if len(tagList) let result = tagList[0] endif else " eg: ::MyNamespace::MyClass let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') call filter(tagList, szTagFilter) if len(tagList) let result = tagList[0] endif endif else " The type is not resolved let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') call filter(tagList, szTagFilter) if len(tagList) " Resolving scope (namespace, nested class etc...) let szScopeOfTypeInfo = s:ExtractScopeFromTypeInfo(szTypeInfo) if s:IsTypeInfoResolved(szTypeInfo) let result = s:GetTagOfSameScope(tagList, szScopeOfTypeInfo) else " For each namespace of the namespace list we try to get a tag " that can be in the same scope if g:OmniCpp_NamespaceSearch && &filetype != 'c' for scope in a:namespaces let szTmpScope = omni#cpp#utils#SimplifyScope(scope.'::'.szScopeOfTypeInfo) let result = s:GetTagOfSameScope(tagList, szTmpScope) if result!={} break endif endfor else let szTmpScope = omni#cpp#utils#SimplifyScope('::'.szScopeOfTypeInfo) let result = s:GetTagOfSameScope(tagList, szTmpScope) endif endif endif endif if result!={} " We have our tagItem but maybe it's a typedef or an unnamed type if result.kind[0]=='t' " Here we can have a typedef to another typedef, a class, struct, union etc " but we can also have a typedef to an unnamed type, in that " case the result contains a 'typeref' key let namespaces = [omni#cpp#utils#ExtractScope(result), '::'] if has_key(result, 'typeref') let result = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(result)) else let szCmd = omni#cpp#utils#ExtractCmdFromTagItem(result) let szCode = substitute(omni#cpp#utils#GetCodeFromLine(szCmd), '\C\<'.result.name.'\>.*', '', 'g') let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTokens(omni#cpp#tokenizer#Tokenize(szCode)) let result = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(szTypeInfo)) " TODO: Namespace resolution for result endif endif endif return result endfunc " Returns if the type info is valid " @return " - 1 if valid " - 0 otherwise function! omni#cpp#utils#IsTypeInfoValid(typeInfo) if a:typeInfo=={} return 0 else if a:typeInfo.type == 1 && a:typeInfo.value=='' " String case return 0 elseif a:typeInfo.type == 4 && a:typeInfo.value=={} " Dictionary case return 0 endif endif return 1 endfunc " Get the string of the type info function! omni#cpp#utils#GetTypeInfoString(typeInfo) if a:typeInfo.type == 1 return a:typeInfo.value else return substitute(a:typeInfo.value.typeref, '^\w\+:', '', 'g') endif endfunc " A resolved type info starts with '::' " @return " - 1 if type info starts with '::' " - 0 otherwise function! s:IsTypeInfoResolved(szTypeInfo) return match(a:szTypeInfo, '^::')!=-1 endfunc " A returned type info's scope may not have the global namespace '::' " eg: '::NameSpace1::NameSpace2::MyClass' => '::NameSpace1::NameSpace2' " 'NameSpace1::NameSpace2::MyClass' => 'NameSpace1::NameSpace2' function! s:ExtractScopeFromTypeInfo(szTypeInfo) let szScope = substitute(a:szTypeInfo, '\w\+$', '', 'g') if szScope =='::' return szScope else return substitute(szScope, '::$', '', 'g') endif endfunc " @return " - the tag with the same scope " - {} otherwise function! s:GetTagOfSameScope(listTags, szScopeToMatch) for tagItem in a:listTags let szScopeOfTag = omni#cpp#utils#ExtractScope(tagItem) if szScopeOfTag == a:szScopeToMatch return tagItem endif endfor return {} endfunc " Extract the cmd of a tag item without regexp function! omni#cpp#utils#ExtractCmdFromTagItem(tagItem) let line = a:tagItem.cmd let re = '\(\/\^\)\|\(\$\/\)' if match(line, re)!=-1 let line = substitute(line, re, '', 'g') return line else " TODO: the cmd is a line number return '' endif endfunc " Extract type from tokens. " eg: examples of tokens format " 'const MyClass&' " 'const map < int, int >&' " 'MyNs::MyClass' " '::MyClass**' " 'MyClass a, *b = NULL, c[1] = {}; " 'hello(MyClass a, MyClass* b' " @return the type info string eg: ::std::map " can be empty function! omni#cpp#utils#ExtractTypeInfoFromTokens(tokens) let szResult = '' let state = 0 let tokens = omni#cpp#utils#BuildParenthesisGroups(a:tokens) " If there is an unbalanced parenthesis we are in a parameter list let bParameterList = 0 for token in tokens if token.value == '(' && token.group==-1 let bParameterList = 1 break endif endfor if bParameterList let tokens = reverse(tokens) let state = 0 let parenGroup = -1 for token in tokens if state==0 if token.value=='>' let parenGroup = token.group let state=1 elseif token.kind == 'cppWord' let szResult = token.value.szResult let state=2 elseif index(['*', '&'], token.value)<0 break endif elseif state==1 if token.value=='<' && token.group==parenGroup let state=0 endif elseif state==2 if token.value=='::' let szResult = token.value.szResult let state=3 else break endif elseif state==3 if token.kind == 'cppWord' let szResult = token.value.szResult let state=2 else break endif endif endfor return szResult endif for token in tokens if state==0 if token.value == '::' let szResult .= token.value let state = 1 elseif token.kind == 'cppWord' let szResult .= token.value let state = 2 " Maybe end of token endif elseif state==1 if token.kind == 'cppWord' let szResult .= token.value let state = 2 " Maybe end of token else break endif elseif state==2 if token.value == '::' let szResult .= token.value let state = 1 else break endif endif endfor return szResult endfunc " Get the preview window string function! omni#cpp#utils#GetPreviewWindowStringFromTagItem(tagItem) let szResult = '' let szResult .= 'name: '.a:tagItem.name."\n" for tagKey in keys(a:tagItem) if index(['name', 'static'], tagKey)>=0 continue endif let szResult .= tagKey.': '.a:tagItem[tagKey]."\n" endfor return substitute(szResult, "\n$", '', 'g') endfunc vim-scripts-20180807ubuntu1/bin/0000755000000000000000000000000013332536306013233 5ustar vim-scripts-20180807ubuntu1/bin/dtd2vim0000755000000000000000000001247213332536300014532 0ustar #!/usr/bin/perl # # Author: Mikolaj Machowski ( mikmach AT wp DOT pl ) # Version: 2.0 # License: GPL v. 2 # Date: 25 Apr 2006 # # Script for creation XML data file for Vim7 XML omni-completion from DTDs # Requires: perlSGML (tested against 1997Sep18 version) # USAGE: # # dtd2vim [] # # This command will create file (remove .dtd extension and add .vim; # other extensions will remain intact). # # (not obligatory) will be part of dictionary name and will be # used as argument for :XMLns command (file name - sans extensions) have to be # the same. # # perlSGML and this script doesn't work with multiple files. User has to # prepare single DTD file to parse all data. # # In created file global variable is named g:xmldata_. When second # argument wasn't provided 'xxxx' will be used. # After that place file in: # # ~/.vim/autoload/xml # # directory. Of course it can be also global directory or other Vim data # hierarchy of files. Example for DocBook 4.4: # DTD is in file docbook.dtd, call command with # # dtd2vim.pl docbook.dtd docbook44 # # Put file as: # # ~/.vim/autoload/xml/docbook44.vim # # Omni-completion for DocBook 4.4 files will be started with: # # :XMLns docbook44 # # command. # # Potential problems: not always properly detected vimxmlroot. # # ChangeLog: # 1.1 (19 Apr) # - commented out generation of * to mark required attributes - too many # false positives # - skip more DTD keywords: NAME, NUMBER # License: # Copyright (C) 2006 Mikolaj Machowski # # This script is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; see the file COPYING.LIB. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. use SGML::DTD; if ( $#ARGV < 0 ){ print "Script generating XML omni completion data file for Vim7\n"; print "USAGE:\n"; print " dtd2vim.pl []\n"; exit 1; } open (FILE, "@ARGV[0]") or die "$!"; $dtd = new SGML::DTD; $dtd->read_dtd(\*FILE); close FILE; @top_elements = $dtd->get_top_elements(); $tops = join "', '", @top_elements; $tops = "'" . $tops . "'"; $" = ","; #" Dirty trick: highlighting cant cope with LIST_SEP. var @entities_data = $dtd->get_gen_data_ents("0"); @entities = $dtd->get_gen_ents("0"); $ents = join "', '", @entities; $ents = "'" . $ents . "'"; $output = @ARGV[0]; $output =~ s/\.dtd$//; $output .= '.vim'; open (DATA, "> $output") or die "$!"; if (@ARGV > 1){ $dialect = @ARGV[1]; } else { $dialect = 'xxxx'; } print DATA "let g:xmldata_$dialect = {\n"; print DATA "\\ 'vimxmlentities': [$ents],\n"; print DATA "\\ 'vimxmlroot': [$tops],\n"; # Initialize tag info string $taginfo = ''; @list_of_elements = $dtd->get_elements(); foreach $element (@list_of_elements) { # Get possible childs of current element @element_childs = $dtd->get_base_children($element); @element_childs = (@element_childs, $dtd->get_inc_children($element)); @element_nochilds = $dtd->get_exc_children($element); # Remove pcdata if first value of table if ($element_childs[0] =~ /pcdata/) { shift @element_childs; } foreach $child (@element_childs) { $i = 0; foreach $nochild (@element_nochilds) { if ( $child eq $nochild ) { $i = $i + 1; } } if ( $i == 0 ) { push @children, $child; } } @element_childs = @children; undef @children; $childs = join "', '", @element_childs; $childs = "'" . $childs . "'"; $childs =~ s/'EMPTY'//; if ( $childs =~ '^$') { $taginfo .= "\\ '$element': ['/>', ''],\n"; } print DATA "\\ '".$element."': [\n\\ [$childs],\n"; %element_attributes = $dtd->get_elem_attr($element); @attr_names = keys %element_attributes; # @attr_values = values %element_attributes; print DATA '\ { '; $attrs = ''; foreach $attr_name (@attr_names) { foreach $item (@{$element_attributes{$attr_name}}) { if ($item !~ /(IMPLIED|FIXED|REQUIRED|CDATA|ID|ENTIT|NAME|NUMBER|NMTOKEN|NOTATION)/) { # IDREF, IDREFS, NMTOKENS, ENTITIES will be cared of by super-strings push @val, $item; } #if ($item =~ /REQUIRED/) { #push @req, $attr_name; #$req{$attr_name} = '1'; #} } if (@val) { $attr_vls = join "', '", @val; $attr_vls = "'" . $attr_vls . "'"; undef @val; } $attrs .= "'".$attr_name ."': [$attr_vls], "; undef $attr_vls; } $attrs =~ s/..$//; print DATA $attrs; print DATA "}\n\\ ],\n"; } #$req = join "': ['*', ''],\n\\ '", keys %req; #$req = "\\ '" . $req . "': ['*', '']"; #print DATA "\\ 'vimxmlattrinfo': {\n$req\n\\ },\n"; print DATA "\\ 'vimxmltaginfo': {\n$taginfo\\ }"; # Close big dictionary and add modeline to data file print DATA "\n\\ }\n\" vim:ft=vim:ff=unix"; # Space necessary to get above line from default 'modelines' range # # # close DATA or die "$!"; # vim:isk+=$,%:ft=perl:ff=unix:tw=80:fo+=o: vim-scripts-20180807ubuntu1/bin/vimplate0000755000000000000000000001740413332536300015002 0ustar #!/usr/bin/perl -w use strict; use warnings; =head1 NAME vimplate - the vim template system. =cut use constant VERSION => '0.2.3'; use POSIX qw(strftime cuserid setlocale LC_ALL); use English qw(-no_match_vars); use Getopt::Long qw(:config no_ignore_case ); use Pod::Usage; my $vimplaterc=''; =head1 DEPENDS on PACKAGES B http://search.cpan.org/~abw/Template-Toolkit-2.14 please install Template-Toolkit on your system. =cut BEGIN { eval { require Template; }; if ($EVAL_ERROR=~/Can't locate Template.pm/) { print STDERR "$EVAL_ERROR"; print STDERR '-' x 60, "\n"; print STDERR "please install Template-Toolkit!\n"; print STDERR "example with $^X -MCPAN -e\"install Template\"\n"; print STDERR '-' x 60, "\n"; exit 1; } } =head1 DEPENDS on SETTINGS B on unix/bsd/linux the variable home is set. On Windows please set the variable home to the value where _vimplaterc should be locatet. =cut unless ( $ENV{'HOME'} ) { print STDERR "Variable HOME isn't set!\n"; print STDERR "Please read the documentation.\n"; exit 1; } else { if ( $^O =~ /Win/ ) { $vimplaterc = $ENV{'HOME'} . '/_vimplaterc'; unless ( $ENV{'USER'} ) { $ENV{'USER'}=$ENV{'USERNAME'}; } else { print STDERR "Variable USER isn't set!\n"; print STDERR "Please set this variable.\n"; } } else { $vimplaterc = $ENV{'HOME'} . '/.vimplaterc'; } } =head1 SYNOPSIS =over 4 =item vimplate <-template=