From 2e1f6052a3a1796b669687805b41825f316b3d64 Mon Sep 17 00:00:00 2001 From: stack Date: Thu, 18 Oct 2012 05:53:29 +0200 Subject: [PATCH 1/1] better plugins for tags in c/c++, python and php completion --- .gitmodules | 12 + .vimrc | 227 -------- .../archive/php-doc.vim | 506 ++++++++++++++++++ .../plugin/php-doc.vim | 506 ++++++++++++++++++ addons/PDV_-_phpDocumentor_for_Vim/version | 1 + addons/SuperTab%1643 | 1 + addons/Tagbar | 1 + addons/checksyntax | 2 +- addons/clang_complete | 1 + addons/phpcomplete | 1 + addons/python%790/archive/python3.0.vim | 370 ------------- addons/python%790/syntax/python3.0.vim | 370 ------------- addons/python%790/version | 1 - addons/snipmate-snippets | 2 +- addons/vim-addon-manager-known-repositories | 2 +- vimrc | 37 +- 16 files changed, 1063 insertions(+), 977 deletions(-) delete mode 100644 .vimrc create mode 100644 addons/PDV_-_phpDocumentor_for_Vim/archive/php-doc.vim create mode 100644 addons/PDV_-_phpDocumentor_for_Vim/plugin/php-doc.vim create mode 100644 addons/PDV_-_phpDocumentor_for_Vim/version create mode 160000 addons/SuperTab%1643 create mode 160000 addons/Tagbar create mode 160000 addons/clang_complete create mode 160000 addons/phpcomplete delete mode 100644 addons/python%790/archive/python3.0.vim delete mode 100644 addons/python%790/syntax/python3.0.vim delete mode 100644 addons/python%790/version diff --git a/.gitmodules b/.gitmodules index bbe1632..f14ab52 100644 --- a/.gitmodules +++ b/.gitmodules @@ -40,3 +40,15 @@ [submodule "addons/The_NERD_tree"] path = addons/The_NERD_tree url = git://github.com/scrooloose/nerdtree +[submodule "addons/clang_complete"] + path = addons/clang_complete + url = git://github.com/Rip-Rip/clang_complete +[submodule "addons/phpcomplete"] + path = addons/phpcomplete + url = git://github.com/shawncplus/phpcomplete.vim +[submodule "addons/SuperTab%1643"] + path = addons/SuperTab%1643 + url = git://github.com/ervandew/supertab +[submodule "addons/Tagbar"] + path = addons/Tagbar + url = git://github.com/majutsushi/tagbar diff --git a/.vimrc b/.vimrc deleted file mode 100644 index a03fc2c..0000000 --- a/.vimrc +++ /dev/null @@ -1,227 +0,0 @@ -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" General -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set nocompatible " get out of horrible vi-compatible mode -filetype indent plugin on | syn on -set history=1000 " How many lines of history to remember -set cf " enable error files and error jumping -set ffs=unix,dos,mac " support all three, in this order -set viminfo+=! " make sure it can save viminfo -set isk+=_,@,- " none of these should be word dividers, so make them not be -set nobackup - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Theme/Colors -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -syntax on " syntax highlighting on - -set background=dark -set t_Co=256 -colorscheme desert -"colorscheme xoria256 -"let g:solarized_termcolors=256 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vim UI -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set wildmenu " turn on wild menu -set ruler " Always show current positions along the bottom -set number " turn on line numbers -set lz " do not redraw while running macros (much faster) (LazyRedraw) -set hid " you can change buffer without saving -set backspace=2 " make backspace work normal -set whichwrap+=<,>,h,l " backspace and cursor keys wrap to -set shortmess=atI " shortens messages to avoid 'press a key' prompt -set report=0 " tell us when anything is changed via :... -" make the splitters between windows be blank -set fillchars=vert:\ ,stl:\ ,stlnc:\ - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Visual Cues -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set showmatch " show matching brackets -set mat=5 " how many tenths of a second to blink matching brackets for -set hlsearch " highlight searched for phrases -set incsearch " do highlight as you type you search phrase -set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " what to show when I hit :set list -set so=10 " Keep 10 lines (top/bottom) for scope -set novisualbell " don't blink -set noerrorbells " no noises -set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%04l,%04v][%p%%] -set laststatus=2 " always show the status line - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Text Formatting/Layout -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set fo=tcrqn " See Help (complex) -set si " smartindent -set tabstop=4 " tab spacing (settings below are just to unify it) -set softtabstop=4 " unify -set shiftwidth=4 " unify -set expandtab " space instead of tabs -set smarttab "Use the "shiftwidth" setting for inserting s instead of the "tabstop" setting, when at the beginning of a line. -set nowrap " do not wrap lines - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Folding -" Enable folding, but by default make it act like folding is off, because folding is annoying in anything but a few rare cases -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set foldenable " Turn on folding -set foldmethod=indent " Make folding indent sensitive -set foldlevel=100 " Don't autofold anything (but I can still fold manually) -set foldopen-=search " don't open folds when you search into them -set foldopen-=undo " don't open folds when you undo stuff - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Mouse Settings -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set mouse=a " mouse support in all modes -set mousehide " hide the mouse when typing text - -" ,p and shift-insert will paste the X buffer, even on the command line -nmap p i -imap -cmap - -" map to clear search -nmap :nohlsearch - -" this makes the mouse paste a block of text without formatting it -" (good for code) -map "*p - -" Convenient for non italian keyboard -map ò : - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Matchit -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let b:match_ignorecase = 1 - -" make tab in v mode ident code -vmap >gv -vmap I -nmap ^i - -"Easy to access esc key -map! -map - -" paste mode - this will avoid unexpected effects when you -" cut or copy some text from one window and paste it in Vim. -set pastetoggle= - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Perl -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let perl_extended_vars=1 " highlight advanced perl vars inside strings - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Custom Functions -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"switch spellcheck languages -let g:myLangList = [ "none", "it", "en_us" ] -function! MySpellLang() -"loop through languages -if !exists( "b:myLang" ) - let b:myLang=0 -endif -let b:myLang = b:myLang + 1 -if b:myLang >= len(g:myLangList) | let b:myLang = 0 | endif - -if b:myLang== 0 | setlocal spell nospell | endif -if b:myLang== 1 | setlocal spell spelllang=it | endif -if b:myLang== 2 | setlocal spell spelllang=en_us | endif - -echo "language spell:" g:myLangList[b:myLang] -endfunction - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Mappings -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" alt-i (normal mode) inserts a single char, and then switches back to normal -map i r -" set F4 to toogle number/nonumber -map :set invnumber -" encypt the file (toggle) -map ggVGg? -map :call MySpellLang() -" Map NERDTree show and hide -map :NERDTreeToggle -imap :NERDTreeToggle -" Taglist toggle -map :TlistOpen -imap :TlistClose - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Autocommands -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -if has ("autocmd") - " Enable file type detection ('filetype on'). - " Syntax of these languages is fussy over tabs Vs spaces - autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab - autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab - " Customisations based on house-style (arbitrary) - autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab - autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab - " Treat sh correctly - autocmd FileType sh setlocal ts=4 sts=4 sw=4 expandtab - " Treat .rss files as XML - autocmd BufNewFile,BufRead *.rss,*.atom setfiletype xml - - autocmd FileType c,cpp,slang set cindent - autocmd FileType c,cpp,slang set textwidth=79 - - autocmd BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full) - autocmd BufNewFile *.sh call append(0, "#!/bin/bash") - autocmd BufNewFile *.pl call append(0, "#!/usr/bin/perl") - autocmd BufNewFile *.py call append(0, "#!/bin/python") - - " When editing a file, always jump to the last known cursor position. - " Don't do it when the position is invalid or when inside an event handler - " (happens when dropping a file on gvim). - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal g`\"" | - \ endif -endif - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Useful abbrevs -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -iab xdate =strftime("%d/%m/%y %H:%M:%S") - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" General configs -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:h\")})%)%(\ %a%)\ -\ %{v:servername} -if &term == "screen" - set t_ts=^[k - set t_fs=^[\ -endif -if &term == "screen" || &term == "xterm" - set title -endif - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Plugin activation -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" vim-addon-manager -" -let vam_install_path = expand('$HOME') . '/.vim/addons' -exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager' -" Enable addons with vim-addon-manager using file type recognition -let ft_addons = { - \ 'always': ['surround', 'checksyntax', 'LargeFile', 'snipmate', 'snipmate-snippets', 'The_NERD_tree'], - \ 'r': [ 'Screen_vim__gnu_screentmux', 'Vim-R-plugin' ], - \ '^\%(c\|cpp\|javascript\|python\|php\|html\|xml\|r\|sh\|css\|java\|make\|xslt\|vim\)$': [ 'taglist-plus' ], - \ 'python': ['pythoncomplete', 'pydoc', 'python%790'], - \ 'gpg': ['gnupg'], - \ } -call vam#ActivateAddons(ft_addons['always'], {'auto_install': 1}) -au FileType * for l in values(filter(copy(ft_addons), string(expand('')).' =~ v:key')) | call vam#ActivateAddons(l, {'force_loading_plugins_now':1}) | endfor diff --git a/addons/PDV_-_phpDocumentor_for_Vim/archive/php-doc.vim b/addons/PDV_-_phpDocumentor_for_Vim/archive/php-doc.vim new file mode 100644 index 0000000..1db8429 --- /dev/null +++ b/addons/PDV_-_phpDocumentor_for_Vim/archive/php-doc.vim @@ -0,0 +1,506 @@ +" PDV (phpDocumentor for Vim) +" =========================== +" +" Version: 1.0.1 +" +" Copyright 2005 by Tobias Schlitt +" Inspired by phpDoc script for Vim by Vidyut Luther (http://www.phpcult.com/). +" +" Provided under the GPL (http://www.gnu.org/copyleft/gpl.html). +" +" This script provides functions to generate phpDocumentor conform +" documentation blocks for your PHP code. The script currently +" documents: +" +" - Classes +" - Methods/Functions +" - Attributes +" +" All of those supporting all PHP 4 and 5 syntax elements. +" +" Beside that it allows you to define default values for phpDocumentor tags +" like @version (I use $id$ here), @author, @license and so on. +" +" For function/method parameters and attributes, the script tries to guess the +" type as good as possible from PHP5 type hints or default values (array, bool, +" int, string...). +" +" You can use this script by mapping the function PhpDoc() to any +" key combination. Hit this on the line where the element to document +" resides and the doc block will be created directly above that line. +" +" Installation +" ============ +" +" For example include into your .vimrc: +" +" source ~/.vim/php-doc.vim +" imap :set paste:exe PhpDoc():set nopastei +" +" This includes the script and maps the combination +o (only in +" insert mode) to the doc function. +" +" Changelog +" ========= +" +" Version 1.0.0 +" ------------- +" +" * Created the initial version of this script while playing around with VIM +" scripting the first time and trying to fix Vidyut's solution, which +" resulted in a complete rewrite. +" +" Version 1.0.1 +" ------------- +" * Fixed issues when using tabs instead of spaces. +" * Fixed some parsing bugs when using a different coding style. +" * Fixed bug with call-by-reference parameters. +" * ATTENTION: This version already has code for the next version 1.1.0, +" which is propably not working! +" +" Version 1.1.0 (preview) +" ------------- +" * Added foldmarker generation. +" + +if has ("user_commands") + +" {{{ Globals + +" After phpDoc standard +let g:pdv_cfg_CommentHead = "/**" +let g:pdv_cfg_Comment1 = " * " +let g:pdv_cfg_Commentn = " * " +let g:pdv_cfg_CommentTail = " */" +let g:pdv_cfg_CommentSingle = "//" + +" Default values +let g:pdv_cfg_Type = "mixed" +let g:pdv_cfg_Package = "" +let g:pdv_cfg_Version = "$id$" +let g:pdv_cfg_Author = "Tobias Schlitt " +let g:pdv_cfg_Copyright = "1997-2005 The PHP Group" +let g:pdv_cfg_License = "PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}" + +let g:pdv_cfg_ReturnVal = "void" + +" Wether to create @uses tags for implementation of interfaces and inheritance +let g:pdv_cfg_Uses = 1 + +" Options +" :set paste before documenting (1|0)? Recommended. +let g:pdv_cfg_paste = 1 + +" Wether for PHP5 code PHP4 tags should be set, like @access,... (1|0)? +let g:pdv_cfg_php4always = 1 + +" Wether to guess scopes after PEAR coding standards: +" $_foo/_bar() == (1|0)? +let g:pdv_cfg_php4guess = 1 + +" If you selected 1 for the last value, this scope identifier will be used for +" the identifiers having an _ in the first place. +let g:pdv_cfg_php4guessval = "protected" + +" +" Regular expressions +" + +let g:pdv_re_comment = ' *\*/ *' + +" (private|protected|public) +let g:pdv_re_scope = '\(private\|protected\|public\)' +" (static) +let g:pdv_re_static = '\(static\)' +" (abstract) +let g:pdv_re_abstract = '\(abstract\)' +" (final) +let g:pdv_re_final = '\(final\)' + +" [:space:]*(private|protected|public|static|abstract)*[:space:]+[:identifier:]+\([:params:]\) +let g:pdv_re_func = '^\s*\([a-zA-Z ]*\)function\s\+\([^ (]\+\)\s*(\s*\(.*\)\s*)\s*[{;]\?$' +" [:typehint:]*[:space:]*$[:identifier]\([:space:]*=[:space:]*[:value:]\)? +let g:pdv_re_param = ' *\([^ &]*\) *&\?\$\([A-Za-z_][A-Za-z0-9_]*\) *=\? *\(.*\)\?$' + +" [:space:]*(private|protected|public\)[:space:]*$[:identifier:]+\([:space:]*=[:space:]*[:value:]+\)*; +let g:pdv_re_attribute = '^\s*\(\(private\|public\|protected\|var\|static\)\+\)\s*\$\([^ ;=]\+\)[ =]*\(.*\);\?$' + +" [:spacce:]*(abstract|final|)[:space:]*(class|interface)+[:space:]+\(extends ([:identifier:])\)?[:space:]*\(implements ([:identifier:][, ]*)+\)? +let g:pdv_re_class = '^\s*\([a-zA-Z]*\)\s*\(interface\|class\)\s*\([^ ]\+\)\s*\(extends\)\?\s*\([a-zA-Z0-9]*\)\?\s*\(implements*\)\? *\([a-zA-Z0-9_ ,]*\)\?.*$' + +let g:pdv_re_array = "^array *(.*" +let g:pdv_re_float = '^[0-9.]\+' +let g:pdv_re_int = '^[0-9]\+$' +let g:pdv_re_string = "['\"].*" +let g:pdv_re_bool = "\(true\|false\)" + +let g:pdv_re_indent = '^\s*' + +" Shortcuts for editing the text: +let g:pdv_cfg_BOL = "norm! o" +let g:pdv_cfg_EOL = "" + +" }}} + + " {{{ PhpDocSingle() + " Document a single line of code ( does not check if doc block already exists ) + +func! PhpDocSingle() + let l:endline = line(".") + 1 + call PhpDoc() + exe "norm! " . l:endline . "G$" +endfunc + +" }}} + " {{{ PhpDocRange() + " Documents a whole range of code lines ( does not add defualt doc block to + " unknown types of lines ). Skips elements where a docblock is already + " present. +func! PhpDocRange() range + let l:line = a:firstline + let l:endLine = a:lastline + let l:elementName = "" + while l:line <= l:endLine + " TODO: Replace regex check for existing doc with check more lines + " above... + if (getline(l:line) =~ g:pdv_re_func || getline(l:line) =~ g:pdv_re_attribute || getline(l:line) =~ g:pdv_re_class) && getline(l:line - 1) !~ g:pdv_re_comment + let l:docLines = 0 + " Ensure we are on the correct line to run PhpDoc() + exe "norm! " . l:line . "G$" + " No matter what, this returns the element name + let l:elementName = PhpDoc() + let l:endLine = l:endLine + (line(".") - l:line) + 1 + let l:line = line(".") + 1 + endif + let l:line = l:line + 1 + endwhile +endfunc + + " }}} +" {{{ PhpDocFold() + +" func! PhpDocFold(name) +" let l:startline = line(".") +" let l:currentLine = l:startLine +" let l:commentHead = escape(g:pdv_cfg_CommentHead, "*."); +" let l:txtBOL = g:pdv_cfg_BOL . matchstr(l:name, '^\s*') +" " Search above for comment start +" while (l:currentLine > 1) +" if (matchstr(l:commentHead, getline(l:currentLine))) +" break; +" endif +" let l:currentLine = l:currentLine + 1 +" endwhile +" " Goto 1 line above and open a newline +" exe "norm! " . (l:currentLine - 1) . "Go\" +" " Write the fold comment +" exe l:txtBOL . g:pdv_cfg_CommentSingle . " {"."{{ " . a:name . g:pdv_cfg_EOL +" " Add another newline below that +" exe "norm! o\" +" " Search for our comment line +" let l:currentLine = line(".") +" while (l:currentLine <= line("$")) +" " HERE!!!! +" endwhile +" +" +" endfunc + + +" }}} + +" {{{ PhpDoc() + +func! PhpDoc() + " Needed for my .vimrc: Switch off all other enhancements while generating docs + let l:paste = &g:paste + let &g:paste = g:pdv_cfg_paste == 1 ? 1 : &g:paste + + let l:line = getline(".") + let l:result = "" + + if l:line =~ g:pdv_re_func + let l:result = PhpDocFunc() + + elseif l:line =~ g:pdv_re_attribute + let l:result = PhpDocVar() + + elseif l:line =~ g:pdv_re_class + let l:result = PhpDocClass() + + else + let l:result = PhpDocDefault() + + endif + +" if g:pdv_cfg_folds == 1 +" PhpDocFolds(l:result) +" endif + + let &g:paste = l:paste + + return l:result +endfunc + +" }}} +" {{{ PhpDocFunc() + +func! PhpDocFunc() + " Line for the comment to begin + let commentline = line (".") - 1 + + let l:name = substitute (getline ("."), '^\(.*\)\/\/.*$', '\1', "") + + "exe g:pdv_cfg_BOL . "DEBUG:" . name. g:pdv_cfg_EOL + + " First some things to make it more easy for us: + " tab -> space && space+ -> space + " let l:name = substitute (l:name, '\t', ' ', "") + " Orphan. We're now using \s everywhere... + + " Now we have to split DECL in three parts: + " \[(skopemodifier\)]\(funcname\)\(parameters\) + let l:indent = matchstr(l:name, g:pdv_re_indent) + + let l:modifier = substitute (l:name, g:pdv_re_func, '\1', "g") + let l:funcname = substitute (l:name, g:pdv_re_func, '\2', "g") + let l:parameters = substitute (l:name, g:pdv_re_func, '\3', "g") . "," + let l:scope = PhpDocScope(l:modifier, l:funcname) + let l:static = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_static) : "" + let l:abstract = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_abstract) : "" + let l:final = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_final) : "" + + exe "norm! " . commentline . "G$" + + " Local indent + let l:txtBOL = g:pdv_cfg_BOL . l:indent + + exe l:txtBOL . g:pdv_cfg_CommentHead . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Comment1 . funcname . " " . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . g:pdv_cfg_EOL + + while (l:parameters != ",") && (l:parameters != "") + " Save 1st parameter + let _p = substitute (l:parameters, '\([^,]*\) *, *\(.*\)', '\1', "") + " Remove this one from list + let l:parameters = substitute (l:parameters, '\([^,]*\) *, *\(.*\)', '\2', "") + " PHP5 type hint? + let l:paramtype = substitute (_p, g:pdv_re_param, '\1', "") + " Parameter name + let l:paramname = substitute (_p, g:pdv_re_param, '\2', "") + " Parameter default + let l:paramdefault = substitute (_p, g:pdv_re_param, '\3', "") + + if l:paramtype == "" + let l:paramtype = PhpDocType(l:paramdefault) + endif + + if l:paramtype != "" + let l:paramtype = " " . l:paramtype + endif + exe l:txtBOL . g:pdv_cfg_Commentn . "@param" . l:paramtype . " $" . l:paramname . " " . g:pdv_cfg_EOL + endwhile + + if l:static != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@static" . g:pdv_cfg_EOL + endif + if l:abstract != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@abstract" . g:pdv_cfg_EOL + endif + if l:final != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@final" . g:pdv_cfg_EOL + endif + if l:scope != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@access " . l:scope . g:pdv_cfg_EOL + endif + exe l:txtBOL . g:pdv_cfg_Commentn . "@return " . g:pdv_cfg_ReturnVal . g:pdv_cfg_EOL + + " Close the comment block. + exe l:txtBOL . g:pdv_cfg_CommentTail . g:pdv_cfg_EOL + return l:modifier ." ". l:funcname +endfunc + +" }}} + " {{{ PhpDocVar() + +func! PhpDocVar() + " Line for the comment to begin + let commentline = line (".") - 1 + + let l:name = substitute (getline ("."), '^\(.*\)\/\/.*$', '\1', "") + + " Now we have to split DECL in three parts: + " \[(skopemodifier\)]\(funcname\)\(parameters\) + " let l:name = substitute (l:name, '\t', ' ', "") + " Orphan. We're now using \s everywhere... + + let l:indent = matchstr(l:name, g:pdv_re_indent) + + let l:modifier = substitute (l:name, g:pdv_re_attribute, '\1', "g") + let l:varname = substitute (l:name, g:pdv_re_attribute, '\3', "g") + let l:default = substitute (l:name, g:pdv_re_attribute, '\4', "g") + let l:scope = PhpDocScope(l:modifier, l:varname) + + let l:static = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_static) : "" + + let l:type = PhpDocType(l:default) + + exe "norm! " . commentline . "G$" + + " Local indent + let l:txtBOL = g:pdv_cfg_BOL . l:indent + + exe l:txtBOL . g:pdv_cfg_CommentHead . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Comment1 . l:varname . " " . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . g:pdv_cfg_EOL + if l:static != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@static" . g:pdv_cfg_EOL + endif + exe l:txtBOL . g:pdv_cfg_Commentn . "@var " . l:type . g:pdv_cfg_EOL + if l:scope != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@access " . l:scope . g:pdv_cfg_EOL + endif + + " Close the comment block. + exe l:txtBOL . g:pdv_cfg_CommentTail . g:pdv_cfg_EOL + return l:modifier ." ". l:varname +endfunc + +" }}} +" {{{ PhpDocClass() + +func! PhpDocClass() + " Line for the comment to begin + let commentline = line (".") - 1 + + let l:name = substitute (getline ("."), '^\(.*\)\/\/.*$', '\1', "") + + "exe g:pdv_cfg_BOL . "DEBUG:" . name. g:pdv_cfg_EOL + + " First some things to make it more easy for us: + " tab -> space && space+ -> space + " let l:name = substitute (l:name, '\t', ' ', "") + " Orphan. We're now using \s everywhere... + + " Now we have to split DECL in three parts: + " \[(skopemodifier\)]\(classname\)\(parameters\) + let l:indent = matchstr(l:name, g:pdv_re_indent) + + let l:modifier = substitute (l:name, g:pdv_re_class, '\1', "g") + let l:classname = substitute (l:name, g:pdv_re_class, '\3', "g") + let l:extends = g:pdv_cfg_Uses == 1 ? substitute (l:name, g:pdv_re_class, '\5', "g") : "" + let l:interfaces = g:pdv_cfg_Uses == 1 ? substitute (l:name, g:pdv_re_class, '\7', "g") . "," : "" + + let l:abstract = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_abstract) : "" + let l:final = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_final) : "" + + exe "norm! " . commentline . "G$" + + " Local indent + let l:txtBOL = g:pdv_cfg_BOL . l:indent + + exe l:txtBOL . g:pdv_cfg_CommentHead . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Comment1 . l:classname . " " . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . g:pdv_cfg_EOL + if l:extends != "" && l:extends != "implements" + exe l:txtBOL . g:pdv_cfg_Commentn . "@uses " . l:extends . g:pdv_cfg_EOL + endif + + while (l:interfaces != ",") && (l:interfaces != "") + " Save 1st parameter + let interface = substitute (l:interfaces, '\([^, ]*\) *, *\(.*\)', '\1', "") + " Remove this one from list + let l:interfaces = substitute (l:interfaces, '\([^, ]*\) *, *\(.*\)', '\2', "") + exe l:txtBOL . g:pdv_cfg_Commentn . "@uses " . l:interface . g:pdv_cfg_EOL + endwhile + + if l:abstract != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@abstract" . g:pdv_cfg_EOL + endif + if l:final != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@final" . g:pdv_cfg_EOL + endif + exe l:txtBOL . g:pdv_cfg_Commentn . "@package " . g:pdv_cfg_Package . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . "@version " . g:pdv_cfg_Version . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . "@copyright " . g:pdv_cfg_Copyright . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . "@author " . g:pdv_cfg_Author g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . "@license " . g:pdv_cfg_License . g:pdv_cfg_EOL + + " Close the comment block. + exe l:txtBOL . g:pdv_cfg_CommentTail . g:pdv_cfg_EOL + return l:modifier ." ". l:classname +endfunc + +" }}} +" {{{ PhpDocScope() + +func! PhpDocScope(modifiers, identifier) +" exe g:pdv_cfg_BOL . DEBUG: . a:modifiers . g:pdv_cfg_EOL + let l:scope = "" + if matchstr (a:modifiers, g:pdv_re_scope) != "" + if g:pdv_cfg_php4always == 1 + let l:scope = matchstr (a:modifiers, g:pdv_re_scope) + else + let l:scope = "x" + endif + endif + if l:scope =~ "^\s*$" && g:pdv_cfg_php4guess + if a:identifier[0] == "_" + let l:scope = g:pdv_cfg_php4guessval + else + let l:scope = "public" + endif + endif + return l:scope != "x" ? l:scope : "" +endfunc + +" }}} +" {{{ PhpDocType() + +func! PhpDocType(typeString) + let l:type = "" + if a:typeString =~ g:pdv_re_array + let l:type = "array" + endif + if a:typeString =~ g:pdv_re_float + let l:type = "float" + endif + if a:typeString =~ g:pdv_re_int + let l:type = "int" + endif + if a:typeString =~ g:pdv_re_string + let l:type = "string" + endif + if a:typeString =~ g:pdv_re_bool + let l:type = "bool" + endif + if l:type == "" + let l:type = g:pdv_cfg_Type + endif + return l:type +endfunc + +" }}} +" {{{ PhpDocDefault() + +func! PhpDocDefault() + " Line for the comment to begin + let commentline = line (".") - 1 + + let l:indent = matchstr(getline("."), '^\ *') + + exe "norm! " . commentline . "G$" + + " Local indent + let l:txtBOL = g:pdv_cfg_BOL . indent + + exe l:txtBOL . g:pdv_cfg_CommentHead . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . " " . g:pdv_cfg_EOL + + " Close the comment block. + exe l:txtBOL . g:pdv_cfg_CommentTail . g:pdv_cfg_EOL +endfunc + +" }}} + +endif " user_commands diff --git a/addons/PDV_-_phpDocumentor_for_Vim/plugin/php-doc.vim b/addons/PDV_-_phpDocumentor_for_Vim/plugin/php-doc.vim new file mode 100644 index 0000000..1db8429 --- /dev/null +++ b/addons/PDV_-_phpDocumentor_for_Vim/plugin/php-doc.vim @@ -0,0 +1,506 @@ +" PDV (phpDocumentor for Vim) +" =========================== +" +" Version: 1.0.1 +" +" Copyright 2005 by Tobias Schlitt +" Inspired by phpDoc script for Vim by Vidyut Luther (http://www.phpcult.com/). +" +" Provided under the GPL (http://www.gnu.org/copyleft/gpl.html). +" +" This script provides functions to generate phpDocumentor conform +" documentation blocks for your PHP code. The script currently +" documents: +" +" - Classes +" - Methods/Functions +" - Attributes +" +" All of those supporting all PHP 4 and 5 syntax elements. +" +" Beside that it allows you to define default values for phpDocumentor tags +" like @version (I use $id$ here), @author, @license and so on. +" +" For function/method parameters and attributes, the script tries to guess the +" type as good as possible from PHP5 type hints or default values (array, bool, +" int, string...). +" +" You can use this script by mapping the function PhpDoc() to any +" key combination. Hit this on the line where the element to document +" resides and the doc block will be created directly above that line. +" +" Installation +" ============ +" +" For example include into your .vimrc: +" +" source ~/.vim/php-doc.vim +" imap :set paste:exe PhpDoc():set nopastei +" +" This includes the script and maps the combination +o (only in +" insert mode) to the doc function. +" +" Changelog +" ========= +" +" Version 1.0.0 +" ------------- +" +" * Created the initial version of this script while playing around with VIM +" scripting the first time and trying to fix Vidyut's solution, which +" resulted in a complete rewrite. +" +" Version 1.0.1 +" ------------- +" * Fixed issues when using tabs instead of spaces. +" * Fixed some parsing bugs when using a different coding style. +" * Fixed bug with call-by-reference parameters. +" * ATTENTION: This version already has code for the next version 1.1.0, +" which is propably not working! +" +" Version 1.1.0 (preview) +" ------------- +" * Added foldmarker generation. +" + +if has ("user_commands") + +" {{{ Globals + +" After phpDoc standard +let g:pdv_cfg_CommentHead = "/**" +let g:pdv_cfg_Comment1 = " * " +let g:pdv_cfg_Commentn = " * " +let g:pdv_cfg_CommentTail = " */" +let g:pdv_cfg_CommentSingle = "//" + +" Default values +let g:pdv_cfg_Type = "mixed" +let g:pdv_cfg_Package = "" +let g:pdv_cfg_Version = "$id$" +let g:pdv_cfg_Author = "Tobias Schlitt " +let g:pdv_cfg_Copyright = "1997-2005 The PHP Group" +let g:pdv_cfg_License = "PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}" + +let g:pdv_cfg_ReturnVal = "void" + +" Wether to create @uses tags for implementation of interfaces and inheritance +let g:pdv_cfg_Uses = 1 + +" Options +" :set paste before documenting (1|0)? Recommended. +let g:pdv_cfg_paste = 1 + +" Wether for PHP5 code PHP4 tags should be set, like @access,... (1|0)? +let g:pdv_cfg_php4always = 1 + +" Wether to guess scopes after PEAR coding standards: +" $_foo/_bar() == (1|0)? +let g:pdv_cfg_php4guess = 1 + +" If you selected 1 for the last value, this scope identifier will be used for +" the identifiers having an _ in the first place. +let g:pdv_cfg_php4guessval = "protected" + +" +" Regular expressions +" + +let g:pdv_re_comment = ' *\*/ *' + +" (private|protected|public) +let g:pdv_re_scope = '\(private\|protected\|public\)' +" (static) +let g:pdv_re_static = '\(static\)' +" (abstract) +let g:pdv_re_abstract = '\(abstract\)' +" (final) +let g:pdv_re_final = '\(final\)' + +" [:space:]*(private|protected|public|static|abstract)*[:space:]+[:identifier:]+\([:params:]\) +let g:pdv_re_func = '^\s*\([a-zA-Z ]*\)function\s\+\([^ (]\+\)\s*(\s*\(.*\)\s*)\s*[{;]\?$' +" [:typehint:]*[:space:]*$[:identifier]\([:space:]*=[:space:]*[:value:]\)? +let g:pdv_re_param = ' *\([^ &]*\) *&\?\$\([A-Za-z_][A-Za-z0-9_]*\) *=\? *\(.*\)\?$' + +" [:space:]*(private|protected|public\)[:space:]*$[:identifier:]+\([:space:]*=[:space:]*[:value:]+\)*; +let g:pdv_re_attribute = '^\s*\(\(private\|public\|protected\|var\|static\)\+\)\s*\$\([^ ;=]\+\)[ =]*\(.*\);\?$' + +" [:spacce:]*(abstract|final|)[:space:]*(class|interface)+[:space:]+\(extends ([:identifier:])\)?[:space:]*\(implements ([:identifier:][, ]*)+\)? +let g:pdv_re_class = '^\s*\([a-zA-Z]*\)\s*\(interface\|class\)\s*\([^ ]\+\)\s*\(extends\)\?\s*\([a-zA-Z0-9]*\)\?\s*\(implements*\)\? *\([a-zA-Z0-9_ ,]*\)\?.*$' + +let g:pdv_re_array = "^array *(.*" +let g:pdv_re_float = '^[0-9.]\+' +let g:pdv_re_int = '^[0-9]\+$' +let g:pdv_re_string = "['\"].*" +let g:pdv_re_bool = "\(true\|false\)" + +let g:pdv_re_indent = '^\s*' + +" Shortcuts for editing the text: +let g:pdv_cfg_BOL = "norm! o" +let g:pdv_cfg_EOL = "" + +" }}} + + " {{{ PhpDocSingle() + " Document a single line of code ( does not check if doc block already exists ) + +func! PhpDocSingle() + let l:endline = line(".") + 1 + call PhpDoc() + exe "norm! " . l:endline . "G$" +endfunc + +" }}} + " {{{ PhpDocRange() + " Documents a whole range of code lines ( does not add defualt doc block to + " unknown types of lines ). Skips elements where a docblock is already + " present. +func! PhpDocRange() range + let l:line = a:firstline + let l:endLine = a:lastline + let l:elementName = "" + while l:line <= l:endLine + " TODO: Replace regex check for existing doc with check more lines + " above... + if (getline(l:line) =~ g:pdv_re_func || getline(l:line) =~ g:pdv_re_attribute || getline(l:line) =~ g:pdv_re_class) && getline(l:line - 1) !~ g:pdv_re_comment + let l:docLines = 0 + " Ensure we are on the correct line to run PhpDoc() + exe "norm! " . l:line . "G$" + " No matter what, this returns the element name + let l:elementName = PhpDoc() + let l:endLine = l:endLine + (line(".") - l:line) + 1 + let l:line = line(".") + 1 + endif + let l:line = l:line + 1 + endwhile +endfunc + + " }}} +" {{{ PhpDocFold() + +" func! PhpDocFold(name) +" let l:startline = line(".") +" let l:currentLine = l:startLine +" let l:commentHead = escape(g:pdv_cfg_CommentHead, "*."); +" let l:txtBOL = g:pdv_cfg_BOL . matchstr(l:name, '^\s*') +" " Search above for comment start +" while (l:currentLine > 1) +" if (matchstr(l:commentHead, getline(l:currentLine))) +" break; +" endif +" let l:currentLine = l:currentLine + 1 +" endwhile +" " Goto 1 line above and open a newline +" exe "norm! " . (l:currentLine - 1) . "Go\" +" " Write the fold comment +" exe l:txtBOL . g:pdv_cfg_CommentSingle . " {"."{{ " . a:name . g:pdv_cfg_EOL +" " Add another newline below that +" exe "norm! o\" +" " Search for our comment line +" let l:currentLine = line(".") +" while (l:currentLine <= line("$")) +" " HERE!!!! +" endwhile +" +" +" endfunc + + +" }}} + +" {{{ PhpDoc() + +func! PhpDoc() + " Needed for my .vimrc: Switch off all other enhancements while generating docs + let l:paste = &g:paste + let &g:paste = g:pdv_cfg_paste == 1 ? 1 : &g:paste + + let l:line = getline(".") + let l:result = "" + + if l:line =~ g:pdv_re_func + let l:result = PhpDocFunc() + + elseif l:line =~ g:pdv_re_attribute + let l:result = PhpDocVar() + + elseif l:line =~ g:pdv_re_class + let l:result = PhpDocClass() + + else + let l:result = PhpDocDefault() + + endif + +" if g:pdv_cfg_folds == 1 +" PhpDocFolds(l:result) +" endif + + let &g:paste = l:paste + + return l:result +endfunc + +" }}} +" {{{ PhpDocFunc() + +func! PhpDocFunc() + " Line for the comment to begin + let commentline = line (".") - 1 + + let l:name = substitute (getline ("."), '^\(.*\)\/\/.*$', '\1', "") + + "exe g:pdv_cfg_BOL . "DEBUG:" . name. g:pdv_cfg_EOL + + " First some things to make it more easy for us: + " tab -> space && space+ -> space + " let l:name = substitute (l:name, '\t', ' ', "") + " Orphan. We're now using \s everywhere... + + " Now we have to split DECL in three parts: + " \[(skopemodifier\)]\(funcname\)\(parameters\) + let l:indent = matchstr(l:name, g:pdv_re_indent) + + let l:modifier = substitute (l:name, g:pdv_re_func, '\1', "g") + let l:funcname = substitute (l:name, g:pdv_re_func, '\2', "g") + let l:parameters = substitute (l:name, g:pdv_re_func, '\3', "g") . "," + let l:scope = PhpDocScope(l:modifier, l:funcname) + let l:static = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_static) : "" + let l:abstract = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_abstract) : "" + let l:final = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_final) : "" + + exe "norm! " . commentline . "G$" + + " Local indent + let l:txtBOL = g:pdv_cfg_BOL . l:indent + + exe l:txtBOL . g:pdv_cfg_CommentHead . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Comment1 . funcname . " " . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . g:pdv_cfg_EOL + + while (l:parameters != ",") && (l:parameters != "") + " Save 1st parameter + let _p = substitute (l:parameters, '\([^,]*\) *, *\(.*\)', '\1', "") + " Remove this one from list + let l:parameters = substitute (l:parameters, '\([^,]*\) *, *\(.*\)', '\2', "") + " PHP5 type hint? + let l:paramtype = substitute (_p, g:pdv_re_param, '\1', "") + " Parameter name + let l:paramname = substitute (_p, g:pdv_re_param, '\2', "") + " Parameter default + let l:paramdefault = substitute (_p, g:pdv_re_param, '\3', "") + + if l:paramtype == "" + let l:paramtype = PhpDocType(l:paramdefault) + endif + + if l:paramtype != "" + let l:paramtype = " " . l:paramtype + endif + exe l:txtBOL . g:pdv_cfg_Commentn . "@param" . l:paramtype . " $" . l:paramname . " " . g:pdv_cfg_EOL + endwhile + + if l:static != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@static" . g:pdv_cfg_EOL + endif + if l:abstract != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@abstract" . g:pdv_cfg_EOL + endif + if l:final != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@final" . g:pdv_cfg_EOL + endif + if l:scope != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@access " . l:scope . g:pdv_cfg_EOL + endif + exe l:txtBOL . g:pdv_cfg_Commentn . "@return " . g:pdv_cfg_ReturnVal . g:pdv_cfg_EOL + + " Close the comment block. + exe l:txtBOL . g:pdv_cfg_CommentTail . g:pdv_cfg_EOL + return l:modifier ." ". l:funcname +endfunc + +" }}} + " {{{ PhpDocVar() + +func! PhpDocVar() + " Line for the comment to begin + let commentline = line (".") - 1 + + let l:name = substitute (getline ("."), '^\(.*\)\/\/.*$', '\1', "") + + " Now we have to split DECL in three parts: + " \[(skopemodifier\)]\(funcname\)\(parameters\) + " let l:name = substitute (l:name, '\t', ' ', "") + " Orphan. We're now using \s everywhere... + + let l:indent = matchstr(l:name, g:pdv_re_indent) + + let l:modifier = substitute (l:name, g:pdv_re_attribute, '\1', "g") + let l:varname = substitute (l:name, g:pdv_re_attribute, '\3', "g") + let l:default = substitute (l:name, g:pdv_re_attribute, '\4', "g") + let l:scope = PhpDocScope(l:modifier, l:varname) + + let l:static = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_static) : "" + + let l:type = PhpDocType(l:default) + + exe "norm! " . commentline . "G$" + + " Local indent + let l:txtBOL = g:pdv_cfg_BOL . l:indent + + exe l:txtBOL . g:pdv_cfg_CommentHead . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Comment1 . l:varname . " " . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . g:pdv_cfg_EOL + if l:static != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@static" . g:pdv_cfg_EOL + endif + exe l:txtBOL . g:pdv_cfg_Commentn . "@var " . l:type . g:pdv_cfg_EOL + if l:scope != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@access " . l:scope . g:pdv_cfg_EOL + endif + + " Close the comment block. + exe l:txtBOL . g:pdv_cfg_CommentTail . g:pdv_cfg_EOL + return l:modifier ." ". l:varname +endfunc + +" }}} +" {{{ PhpDocClass() + +func! PhpDocClass() + " Line for the comment to begin + let commentline = line (".") - 1 + + let l:name = substitute (getline ("."), '^\(.*\)\/\/.*$', '\1', "") + + "exe g:pdv_cfg_BOL . "DEBUG:" . name. g:pdv_cfg_EOL + + " First some things to make it more easy for us: + " tab -> space && space+ -> space + " let l:name = substitute (l:name, '\t', ' ', "") + " Orphan. We're now using \s everywhere... + + " Now we have to split DECL in three parts: + " \[(skopemodifier\)]\(classname\)\(parameters\) + let l:indent = matchstr(l:name, g:pdv_re_indent) + + let l:modifier = substitute (l:name, g:pdv_re_class, '\1', "g") + let l:classname = substitute (l:name, g:pdv_re_class, '\3', "g") + let l:extends = g:pdv_cfg_Uses == 1 ? substitute (l:name, g:pdv_re_class, '\5', "g") : "" + let l:interfaces = g:pdv_cfg_Uses == 1 ? substitute (l:name, g:pdv_re_class, '\7', "g") . "," : "" + + let l:abstract = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_abstract) : "" + let l:final = g:pdv_cfg_php4always == 1 ? matchstr(l:modifier, g:pdv_re_final) : "" + + exe "norm! " . commentline . "G$" + + " Local indent + let l:txtBOL = g:pdv_cfg_BOL . l:indent + + exe l:txtBOL . g:pdv_cfg_CommentHead . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Comment1 . l:classname . " " . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . g:pdv_cfg_EOL + if l:extends != "" && l:extends != "implements" + exe l:txtBOL . g:pdv_cfg_Commentn . "@uses " . l:extends . g:pdv_cfg_EOL + endif + + while (l:interfaces != ",") && (l:interfaces != "") + " Save 1st parameter + let interface = substitute (l:interfaces, '\([^, ]*\) *, *\(.*\)', '\1', "") + " Remove this one from list + let l:interfaces = substitute (l:interfaces, '\([^, ]*\) *, *\(.*\)', '\2', "") + exe l:txtBOL . g:pdv_cfg_Commentn . "@uses " . l:interface . g:pdv_cfg_EOL + endwhile + + if l:abstract != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@abstract" . g:pdv_cfg_EOL + endif + if l:final != "" + exe l:txtBOL . g:pdv_cfg_Commentn . "@final" . g:pdv_cfg_EOL + endif + exe l:txtBOL . g:pdv_cfg_Commentn . "@package " . g:pdv_cfg_Package . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . "@version " . g:pdv_cfg_Version . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . "@copyright " . g:pdv_cfg_Copyright . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . "@author " . g:pdv_cfg_Author g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . "@license " . g:pdv_cfg_License . g:pdv_cfg_EOL + + " Close the comment block. + exe l:txtBOL . g:pdv_cfg_CommentTail . g:pdv_cfg_EOL + return l:modifier ." ". l:classname +endfunc + +" }}} +" {{{ PhpDocScope() + +func! PhpDocScope(modifiers, identifier) +" exe g:pdv_cfg_BOL . DEBUG: . a:modifiers . g:pdv_cfg_EOL + let l:scope = "" + if matchstr (a:modifiers, g:pdv_re_scope) != "" + if g:pdv_cfg_php4always == 1 + let l:scope = matchstr (a:modifiers, g:pdv_re_scope) + else + let l:scope = "x" + endif + endif + if l:scope =~ "^\s*$" && g:pdv_cfg_php4guess + if a:identifier[0] == "_" + let l:scope = g:pdv_cfg_php4guessval + else + let l:scope = "public" + endif + endif + return l:scope != "x" ? l:scope : "" +endfunc + +" }}} +" {{{ PhpDocType() + +func! PhpDocType(typeString) + let l:type = "" + if a:typeString =~ g:pdv_re_array + let l:type = "array" + endif + if a:typeString =~ g:pdv_re_float + let l:type = "float" + endif + if a:typeString =~ g:pdv_re_int + let l:type = "int" + endif + if a:typeString =~ g:pdv_re_string + let l:type = "string" + endif + if a:typeString =~ g:pdv_re_bool + let l:type = "bool" + endif + if l:type == "" + let l:type = g:pdv_cfg_Type + endif + return l:type +endfunc + +" }}} +" {{{ PhpDocDefault() + +func! PhpDocDefault() + " Line for the comment to begin + let commentline = line (".") - 1 + + let l:indent = matchstr(getline("."), '^\ *') + + exe "norm! " . commentline . "G$" + + " Local indent + let l:txtBOL = g:pdv_cfg_BOL . indent + + exe l:txtBOL . g:pdv_cfg_CommentHead . g:pdv_cfg_EOL + exe l:txtBOL . g:pdv_cfg_Commentn . " " . g:pdv_cfg_EOL + + " Close the comment block. + exe l:txtBOL . g:pdv_cfg_CommentTail . g:pdv_cfg_EOL +endfunc + +" }}} + +endif " user_commands diff --git a/addons/PDV_-_phpDocumentor_for_Vim/version b/addons/PDV_-_phpDocumentor_for_Vim/version new file mode 100644 index 0000000..7f20734 --- /dev/null +++ b/addons/PDV_-_phpDocumentor_for_Vim/version @@ -0,0 +1 @@ +1.0.1 \ No newline at end of file diff --git a/addons/SuperTab%1643 b/addons/SuperTab%1643 new file mode 160000 index 0000000..e299037 --- /dev/null +++ b/addons/SuperTab%1643 @@ -0,0 +1 @@ +Subproject commit e2990372442fdf026cc1ef458abdf9a1a4e891ef diff --git a/addons/Tagbar b/addons/Tagbar new file mode 160000 index 0000000..568ef5f --- /dev/null +++ b/addons/Tagbar @@ -0,0 +1 @@ +Subproject commit 568ef5fd25468a58723b50cf40a48c5dcb46c802 diff --git a/addons/checksyntax b/addons/checksyntax index a91faeb..8dc46cd 160000 --- a/addons/checksyntax +++ b/addons/checksyntax @@ -1 +1 @@ -Subproject commit a91faeb042a1a252563c3272e8caab9d62045861 +Subproject commit 8dc46cd61b74af77ba9ad05fa1f61ea16842c7e8 diff --git a/addons/clang_complete b/addons/clang_complete new file mode 160000 index 0000000..d41dfae --- /dev/null +++ b/addons/clang_complete @@ -0,0 +1 @@ +Subproject commit d41dfae0b1e790de18f976af213cf5cdc9be0a46 diff --git a/addons/phpcomplete b/addons/phpcomplete new file mode 160000 index 0000000..04f43d0 --- /dev/null +++ b/addons/phpcomplete @@ -0,0 +1 @@ +Subproject commit 04f43d05ed994ba353e9bc1322c83927d477dfb9 diff --git a/addons/python%790/archive/python3.0.vim b/addons/python%790/archive/python3.0.vim deleted file mode 100644 index 7383876..0000000 --- a/addons/python%790/archive/python3.0.vim +++ /dev/null @@ -1,370 +0,0 @@ -" Vim syntax file -" Language: Python -" Maintainer: Dmitry Vasiliev -" URL: https://github.com/hdima/vim-scripts/blob/master/syntax/python/python3.0.vim -" Last Change: 2012-02-11 -" Filenames: *.py -" Version: 3.0.7 -" -" Based on python.vim (from Vim 6.1 distribution) -" by Neil Schemenauer -" -" Thanks: -" -" Jeroen Ruigrok van der Werven -" for the idea to highlight erroneous operators -" Pedro Algarvio -" for the patch to enable spell checking only for the right spots -" (strings and comments) -" John Eikenberry -" for the patch fixing small typo -" Caleb Adamantine -" for the patch fixing highlighting for decorators -" Andrea Riciputi -" for the patch with new configuration options -" Anton Butanaev -" for the patch fixing bytes literals highlighting -" for the patch fixing str.format syntax highlighting - -" -" Options: -" -" For set option do: let OPTION_NAME = 1 -" For clear option do: let OPTION_NAME = 0 -" -" Option names: -" -" For highlight builtin functions: -" python_highlight_builtins -" -" For highlight builtin objects: -" python_highlight_builtin_objs -" -" For highlight builtin funtions: -" python_highlight_builtin_funcs -" -" For highlight standard exceptions: -" python_highlight_exceptions -" -" For highlight string formatting: -" python_highlight_string_formatting -" -" For highlight str.format syntax: -" python_highlight_string_format -" -" For highlight string.Template syntax: -" python_highlight_string_templates -" -" For highlight indentation errors: -" python_highlight_indent_errors -" -" For highlight trailing spaces: -" python_highlight_space_errors -" -" For highlight doc-tests: -" python_highlight_doctests -" -" If you want all Python highlightings above: -" python_highlight_all -" (This option not override previously set options) -" -" For fast machines: -" python_slow_sync - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -if exists("python_highlight_all") && python_highlight_all != 0 - " Not override previously set options - if !exists("python_highlight_builtins") - if !exists("python_highlight_builtin_objs") - let python_highlight_builtin_objs = 1 - endif - if !exists("python_highlight_builtin_funcs") - let python_highlight_builtin_funcs = 1 - endif - endif - if !exists("python_highlight_exceptions") - let python_highlight_exceptions = 1 - endif - if !exists("python_highlight_string_formatting") - let python_highlight_string_formatting = 1 - endif - if !exists("python_highlight_string_format") - let python_highlight_string_format = 1 - endif - if !exists("python_highlight_string_templates") - let python_highlight_string_templates = 1 - endif - if !exists("python_highlight_indent_errors") - let python_highlight_indent_errors = 1 - endif - if !exists("python_highlight_space_errors") - let python_highlight_space_errors = 1 - endif - if !exists("python_highlight_doctests") - let python_highlight_doctests = 1 - endif -endif - -" Keywords -syn keyword pythonStatement break continue del -syn keyword pythonStatement exec return as -syn keyword pythonStatement pass raise -syn keyword pythonStatement global assert -syn keyword pythonStatement lambda yield -syn keyword pythonStatement with nonlocal -syn keyword pythonStatement False None True -syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite -syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained -syn keyword pythonRepeat for while -syn keyword pythonConditional if elif else -syn keyword pythonPreCondit import from -syn keyword pythonException try except finally -syn keyword pythonOperator and in is not or - -" Decorators (new in Python 2.4) -syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite -syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained -syn match pythonDot "\." display containedin=pythonDottedName - -" Comments -syn match pythonComment "#.*$" display contains=pythonTodo,@Spell -syn match pythonRun "\%^#!.*$" -syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$" -syn keyword pythonTodo TODO FIXME XXX contained - -" Errors -syn match pythonError "\<\d\+\D\+\>" display -syn match pythonError "[$?]" display -syn match pythonError "[&|]\{2,}" display -syn match pythonError "[=]\{3,}" display - -" TODO: Mixing spaces and tabs also may be used for pretty formatting multiline -" statements. For now I don't know how to work around this. -if exists("python_highlight_indent_errors") && python_highlight_indent_errors != 0 - syn match pythonIndentError "^\s*\%( \t\|\t \)\s*\S"me=e-1 display -endif - -" Trailing space errors -if exists("python_highlight_space_errors") && python_highlight_space_errors != 0 - syn match pythonSpaceError "\s\+$" display -endif - -" Strings -syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell -syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell -syn region pythonString start=+"""+ end=+"""+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest2,pythonSpaceError,@Spell -syn region pythonString start=+'''+ end=+'''+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest,pythonSpaceError,@Spell - -syn match pythonEscape +\\[abfnrtv'"\\]+ display contained -syn match pythonEscape "\\\o\o\=\o\=" display contained -syn match pythonEscapeError "\\\o\{,2}[89]" display contained -syn match pythonEscape "\\x\x\{2}" display contained -syn match pythonEscapeError "\\x\x\=\X" display contained -syn match pythonEscape "\\$" -syn match pythonEscape "\\u\x\{4}" display contained -syn match pythonEscapeError "\\u\x\{,3}\X" display contained -syn match pythonEscape "\\U\x\{8}" display contained -syn match pythonEscapeError "\\U\x\{,7}\X" display contained -syn match pythonEscape "\\N{[A-Z ]\+}" display contained -syn match pythonEscapeError "\\N{[^A-Z ]\+}" display contained - -" Raw strings -syn region pythonRawString start=+[bB]\=[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell -syn region pythonRawString start=+[bB]\=[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell -syn region pythonRawString start=+[bB]\=[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell -syn region pythonRawString start=+[bB]\=[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell - -syn match pythonRawEscape +\\['"]+ display transparent contained - -" Bytes -syn region pythonBytes start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell -syn region pythonBytes start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell -syn region pythonBytes start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell -syn region pythonBytes start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell - -syn match pythonBytesError ".\+" display contained -syn match pythonBytesContent "[\u0000-\u00ff]\+" display contained contains=pythonBytesEscape,pythonBytesEscapeError - -syn match pythonBytesEscape +\\[abfnrtv'"\\]+ display contained -syn match pythonBytesEscape "\\\o\o\=\o\=" display contained -syn match pythonBytesEscapeError "\\\o\{,2}[89]" display contained -syn match pythonBytesEscape "\\x\x\{2}" display contained -syn match pythonBytesEscapeError "\\x\x\=\X" display contained -syn match pythonBytesEscape "\\$" - -if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0 - " String formatting - syn match pythonStrFormatting "%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString - syn match pythonStrFormatting "%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString -endif - -if exists("python_highlight_string_format") && python_highlight_string_format != 0 - " str.format syntax - syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString - syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString -endif - -if exists("python_highlight_string_templates") && python_highlight_string_templates != 0 - " String templates - syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonRawString - syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonRawString - syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonRawString -endif - -if exists("python_highlight_doctests") && python_highlight_doctests != 0 - " DocTests - syn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained - syn region pythonDocTest2 start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained -endif - -" Numbers (ints, longs, floats, complex) -syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\x*\>" display - -syn match pythonHexNumber "\<0[xX]\x\+\>" display -syn match pythonOctNumber "\<0[oO]\o\+\>" display -syn match pythonBinNumber "\<0[bB][01]\+\>" display - -syn match pythonNumberError "\<\d\+\D\>" display -syn match pythonNumberError "\<0\d\+\>" display -syn match pythonNumber "\<\d\>" display -syn match pythonNumber "\<[1-9]\d\+\>" display -syn match pythonNumber "\<\d\+[jJ]\>" display - -syn match pythonFloat "\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display -syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display -syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display - -syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*\>" display -syn match pythonBinError "\<0[bB][01]*[2-9]\d*\>" display - -if exists("python_highlight_builtin_objs") && python_highlight_builtin_objs != 0 - " Builtin objects and types - syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ -endif - -if exists("python_highlight_builtin_funcs") && python_highlight_builtin_funcs != 0 - " Builtin functions - syn keyword pythonBuiltinFunc __import__ abs all any ascii - syn keyword pythonBuiltinFunc bin bool bytearray bytes - syn keyword pythonBuiltinFunc chr classmethod cmp compile complex - syn keyword pythonBuiltinFunc delattr dict dir divmod enumerate eval - syn keyword pythonBuiltinFunc exec filter float format frozenset getattr - syn keyword pythonBuiltinFunc globals hasattr hash hex id - syn keyword pythonBuiltinFunc input int isinstance - syn keyword pythonBuiltinFunc issubclass iter len list locals map max - syn keyword pythonBuiltinFunc memoryview min next object oct open ord - syn keyword pythonBuiltinFunc pow print property range - syn keyword pythonBuiltinFunc repr reversed round set setattr - syn keyword pythonBuiltinFunc slice sorted staticmethod str sum super tuple - syn keyword pythonBuiltinFunc type vars zip -endif - -if exists("python_highlight_exceptions") && python_highlight_exceptions != 0 - " Builtin exceptions and warnings - syn keyword pythonExClass BaseException - syn keyword pythonExClass Exception ArithmeticError - syn keyword pythonExClass LookupError EnvironmentError - - syn keyword pythonExClass AssertionError AttributeError BufferError EOFError - syn keyword pythonExClass FloatingPointError GeneratorExit IOError - syn keyword pythonExClass ImportError IndexError KeyError - syn keyword pythonExClass KeyboardInterrupt MemoryError NameError - syn keyword pythonExClass NotImplementedError OSError OverflowError - syn keyword pythonExClass ReferenceError RuntimeError StopIteration - syn keyword pythonExClass SyntaxError IndentationError TabError - syn keyword pythonExClass SystemError SystemExit TypeError - syn keyword pythonExClass UnboundLocalError UnicodeError - syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError - syn keyword pythonExClass UnicodeTranslateError ValueError VMSError - syn keyword pythonExClass WindowsError ZeroDivisionError - - syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning - syn keyword pythonExClass PendingDepricationWarning SyntaxWarning - syn keyword pythonExClass RuntimeWarning FutureWarning - syn keyword pythonExClass ImportWarning UnicodeWarning -endif - -if exists("python_slow_sync") && python_slow_sync != 0 - syn sync minlines=2000 -else - " This is fast but code inside triple quoted strings screws it up. It - " is impossible to fix because the only way to know if you are inside a - " triple quoted string is to start from the beginning of the file. - syn sync match pythonSync grouphere NONE "):$" - syn sync maxlines=200 -endif - -if version >= 508 || !exists("did_python_syn_inits") - if version <= 508 - let did_python_syn_inits = 1 - command -nargs=+ HiLink hi link - else - command -nargs=+ HiLink hi def link - endif - - HiLink pythonStatement Statement - HiLink pythonPreCondit Statement - HiLink pythonFunction Function - HiLink pythonConditional Conditional - HiLink pythonRepeat Repeat - HiLink pythonException Exception - HiLink pythonOperator Operator - - HiLink pythonDecorator Define - HiLink pythonDottedName Function - HiLink pythonDot Normal - - HiLink pythonComment Comment - HiLink pythonCoding Special - HiLink pythonRun Special - HiLink pythonTodo Todo - - HiLink pythonError Error - HiLink pythonIndentError Error - HiLink pythonSpaceError Error - - HiLink pythonString String - HiLink pythonRawString String - HiLink pythonEscape Special - HiLink pythonEscapeError Error - - HiLink pythonBytes String - HiLink pythonBytesContent String - HiLink pythonBytesError Error - HiLink pythonBytesEscape Special - HiLink pythonBytesEscapeError Error - - HiLink pythonStrFormatting Special - HiLink pythonStrFormat Special - HiLink pythonStrTemplate Special - - HiLink pythonDocTest Special - HiLink pythonDocTest2 Special - - HiLink pythonNumber Number - HiLink pythonHexNumber Number - HiLink pythonOctNumber Number - HiLink pythonBinNumber Number - HiLink pythonFloat Float - HiLink pythonNumberError Error - HiLink pythonOctError Error - HiLink pythonHexError Error - HiLink pythonBinError Error - - HiLink pythonBuiltinObj Structure - HiLink pythonBuiltinFunc Function - - HiLink pythonExClass Structure - - delcommand HiLink -endif - -let b:current_syntax = "python" diff --git a/addons/python%790/syntax/python3.0.vim b/addons/python%790/syntax/python3.0.vim deleted file mode 100644 index 7383876..0000000 --- a/addons/python%790/syntax/python3.0.vim +++ /dev/null @@ -1,370 +0,0 @@ -" Vim syntax file -" Language: Python -" Maintainer: Dmitry Vasiliev -" URL: https://github.com/hdima/vim-scripts/blob/master/syntax/python/python3.0.vim -" Last Change: 2012-02-11 -" Filenames: *.py -" Version: 3.0.7 -" -" Based on python.vim (from Vim 6.1 distribution) -" by Neil Schemenauer -" -" Thanks: -" -" Jeroen Ruigrok van der Werven -" for the idea to highlight erroneous operators -" Pedro Algarvio -" for the patch to enable spell checking only for the right spots -" (strings and comments) -" John Eikenberry -" for the patch fixing small typo -" Caleb Adamantine -" for the patch fixing highlighting for decorators -" Andrea Riciputi -" for the patch with new configuration options -" Anton Butanaev -" for the patch fixing bytes literals highlighting -" for the patch fixing str.format syntax highlighting - -" -" Options: -" -" For set option do: let OPTION_NAME = 1 -" For clear option do: let OPTION_NAME = 0 -" -" Option names: -" -" For highlight builtin functions: -" python_highlight_builtins -" -" For highlight builtin objects: -" python_highlight_builtin_objs -" -" For highlight builtin funtions: -" python_highlight_builtin_funcs -" -" For highlight standard exceptions: -" python_highlight_exceptions -" -" For highlight string formatting: -" python_highlight_string_formatting -" -" For highlight str.format syntax: -" python_highlight_string_format -" -" For highlight string.Template syntax: -" python_highlight_string_templates -" -" For highlight indentation errors: -" python_highlight_indent_errors -" -" For highlight trailing spaces: -" python_highlight_space_errors -" -" For highlight doc-tests: -" python_highlight_doctests -" -" If you want all Python highlightings above: -" python_highlight_all -" (This option not override previously set options) -" -" For fast machines: -" python_slow_sync - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -if exists("python_highlight_all") && python_highlight_all != 0 - " Not override previously set options - if !exists("python_highlight_builtins") - if !exists("python_highlight_builtin_objs") - let python_highlight_builtin_objs = 1 - endif - if !exists("python_highlight_builtin_funcs") - let python_highlight_builtin_funcs = 1 - endif - endif - if !exists("python_highlight_exceptions") - let python_highlight_exceptions = 1 - endif - if !exists("python_highlight_string_formatting") - let python_highlight_string_formatting = 1 - endif - if !exists("python_highlight_string_format") - let python_highlight_string_format = 1 - endif - if !exists("python_highlight_string_templates") - let python_highlight_string_templates = 1 - endif - if !exists("python_highlight_indent_errors") - let python_highlight_indent_errors = 1 - endif - if !exists("python_highlight_space_errors") - let python_highlight_space_errors = 1 - endif - if !exists("python_highlight_doctests") - let python_highlight_doctests = 1 - endif -endif - -" Keywords -syn keyword pythonStatement break continue del -syn keyword pythonStatement exec return as -syn keyword pythonStatement pass raise -syn keyword pythonStatement global assert -syn keyword pythonStatement lambda yield -syn keyword pythonStatement with nonlocal -syn keyword pythonStatement False None True -syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite -syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained -syn keyword pythonRepeat for while -syn keyword pythonConditional if elif else -syn keyword pythonPreCondit import from -syn keyword pythonException try except finally -syn keyword pythonOperator and in is not or - -" Decorators (new in Python 2.4) -syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite -syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained -syn match pythonDot "\." display containedin=pythonDottedName - -" Comments -syn match pythonComment "#.*$" display contains=pythonTodo,@Spell -syn match pythonRun "\%^#!.*$" -syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$" -syn keyword pythonTodo TODO FIXME XXX contained - -" Errors -syn match pythonError "\<\d\+\D\+\>" display -syn match pythonError "[$?]" display -syn match pythonError "[&|]\{2,}" display -syn match pythonError "[=]\{3,}" display - -" TODO: Mixing spaces and tabs also may be used for pretty formatting multiline -" statements. For now I don't know how to work around this. -if exists("python_highlight_indent_errors") && python_highlight_indent_errors != 0 - syn match pythonIndentError "^\s*\%( \t\|\t \)\s*\S"me=e-1 display -endif - -" Trailing space errors -if exists("python_highlight_space_errors") && python_highlight_space_errors != 0 - syn match pythonSpaceError "\s\+$" display -endif - -" Strings -syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell -syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell -syn region pythonString start=+"""+ end=+"""+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest2,pythonSpaceError,@Spell -syn region pythonString start=+'''+ end=+'''+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest,pythonSpaceError,@Spell - -syn match pythonEscape +\\[abfnrtv'"\\]+ display contained -syn match pythonEscape "\\\o\o\=\o\=" display contained -syn match pythonEscapeError "\\\o\{,2}[89]" display contained -syn match pythonEscape "\\x\x\{2}" display contained -syn match pythonEscapeError "\\x\x\=\X" display contained -syn match pythonEscape "\\$" -syn match pythonEscape "\\u\x\{4}" display contained -syn match pythonEscapeError "\\u\x\{,3}\X" display contained -syn match pythonEscape "\\U\x\{8}" display contained -syn match pythonEscapeError "\\U\x\{,7}\X" display contained -syn match pythonEscape "\\N{[A-Z ]\+}" display contained -syn match pythonEscapeError "\\N{[^A-Z ]\+}" display contained - -" Raw strings -syn region pythonRawString start=+[bB]\=[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell -syn region pythonRawString start=+[bB]\=[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell -syn region pythonRawString start=+[bB]\=[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell -syn region pythonRawString start=+[bB]\=[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell - -syn match pythonRawEscape +\\['"]+ display transparent contained - -" Bytes -syn region pythonBytes start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell -syn region pythonBytes start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell -syn region pythonBytes start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell -syn region pythonBytes start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell - -syn match pythonBytesError ".\+" display contained -syn match pythonBytesContent "[\u0000-\u00ff]\+" display contained contains=pythonBytesEscape,pythonBytesEscapeError - -syn match pythonBytesEscape +\\[abfnrtv'"\\]+ display contained -syn match pythonBytesEscape "\\\o\o\=\o\=" display contained -syn match pythonBytesEscapeError "\\\o\{,2}[89]" display contained -syn match pythonBytesEscape "\\x\x\{2}" display contained -syn match pythonBytesEscapeError "\\x\x\=\X" display contained -syn match pythonBytesEscape "\\$" - -if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0 - " String formatting - syn match pythonStrFormatting "%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString - syn match pythonStrFormatting "%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString -endif - -if exists("python_highlight_string_format") && python_highlight_string_format != 0 - " str.format syntax - syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString - syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString -endif - -if exists("python_highlight_string_templates") && python_highlight_string_templates != 0 - " String templates - syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonRawString - syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonRawString - syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonRawString -endif - -if exists("python_highlight_doctests") && python_highlight_doctests != 0 - " DocTests - syn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained - syn region pythonDocTest2 start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained -endif - -" Numbers (ints, longs, floats, complex) -syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\x*\>" display - -syn match pythonHexNumber "\<0[xX]\x\+\>" display -syn match pythonOctNumber "\<0[oO]\o\+\>" display -syn match pythonBinNumber "\<0[bB][01]\+\>" display - -syn match pythonNumberError "\<\d\+\D\>" display -syn match pythonNumberError "\<0\d\+\>" display -syn match pythonNumber "\<\d\>" display -syn match pythonNumber "\<[1-9]\d\+\>" display -syn match pythonNumber "\<\d\+[jJ]\>" display - -syn match pythonFloat "\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display -syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display -syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display - -syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*\>" display -syn match pythonBinError "\<0[bB][01]*[2-9]\d*\>" display - -if exists("python_highlight_builtin_objs") && python_highlight_builtin_objs != 0 - " Builtin objects and types - syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ -endif - -if exists("python_highlight_builtin_funcs") && python_highlight_builtin_funcs != 0 - " Builtin functions - syn keyword pythonBuiltinFunc __import__ abs all any ascii - syn keyword pythonBuiltinFunc bin bool bytearray bytes - syn keyword pythonBuiltinFunc chr classmethod cmp compile complex - syn keyword pythonBuiltinFunc delattr dict dir divmod enumerate eval - syn keyword pythonBuiltinFunc exec filter float format frozenset getattr - syn keyword pythonBuiltinFunc globals hasattr hash hex id - syn keyword pythonBuiltinFunc input int isinstance - syn keyword pythonBuiltinFunc issubclass iter len list locals map max - syn keyword pythonBuiltinFunc memoryview min next object oct open ord - syn keyword pythonBuiltinFunc pow print property range - syn keyword pythonBuiltinFunc repr reversed round set setattr - syn keyword pythonBuiltinFunc slice sorted staticmethod str sum super tuple - syn keyword pythonBuiltinFunc type vars zip -endif - -if exists("python_highlight_exceptions") && python_highlight_exceptions != 0 - " Builtin exceptions and warnings - syn keyword pythonExClass BaseException - syn keyword pythonExClass Exception ArithmeticError - syn keyword pythonExClass LookupError EnvironmentError - - syn keyword pythonExClass AssertionError AttributeError BufferError EOFError - syn keyword pythonExClass FloatingPointError GeneratorExit IOError - syn keyword pythonExClass ImportError IndexError KeyError - syn keyword pythonExClass KeyboardInterrupt MemoryError NameError - syn keyword pythonExClass NotImplementedError OSError OverflowError - syn keyword pythonExClass ReferenceError RuntimeError StopIteration - syn keyword pythonExClass SyntaxError IndentationError TabError - syn keyword pythonExClass SystemError SystemExit TypeError - syn keyword pythonExClass UnboundLocalError UnicodeError - syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError - syn keyword pythonExClass UnicodeTranslateError ValueError VMSError - syn keyword pythonExClass WindowsError ZeroDivisionError - - syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning - syn keyword pythonExClass PendingDepricationWarning SyntaxWarning - syn keyword pythonExClass RuntimeWarning FutureWarning - syn keyword pythonExClass ImportWarning UnicodeWarning -endif - -if exists("python_slow_sync") && python_slow_sync != 0 - syn sync minlines=2000 -else - " This is fast but code inside triple quoted strings screws it up. It - " is impossible to fix because the only way to know if you are inside a - " triple quoted string is to start from the beginning of the file. - syn sync match pythonSync grouphere NONE "):$" - syn sync maxlines=200 -endif - -if version >= 508 || !exists("did_python_syn_inits") - if version <= 508 - let did_python_syn_inits = 1 - command -nargs=+ HiLink hi link - else - command -nargs=+ HiLink hi def link - endif - - HiLink pythonStatement Statement - HiLink pythonPreCondit Statement - HiLink pythonFunction Function - HiLink pythonConditional Conditional - HiLink pythonRepeat Repeat - HiLink pythonException Exception - HiLink pythonOperator Operator - - HiLink pythonDecorator Define - HiLink pythonDottedName Function - HiLink pythonDot Normal - - HiLink pythonComment Comment - HiLink pythonCoding Special - HiLink pythonRun Special - HiLink pythonTodo Todo - - HiLink pythonError Error - HiLink pythonIndentError Error - HiLink pythonSpaceError Error - - HiLink pythonString String - HiLink pythonRawString String - HiLink pythonEscape Special - HiLink pythonEscapeError Error - - HiLink pythonBytes String - HiLink pythonBytesContent String - HiLink pythonBytesError Error - HiLink pythonBytesEscape Special - HiLink pythonBytesEscapeError Error - - HiLink pythonStrFormatting Special - HiLink pythonStrFormat Special - HiLink pythonStrTemplate Special - - HiLink pythonDocTest Special - HiLink pythonDocTest2 Special - - HiLink pythonNumber Number - HiLink pythonHexNumber Number - HiLink pythonOctNumber Number - HiLink pythonBinNumber Number - HiLink pythonFloat Float - HiLink pythonNumberError Error - HiLink pythonOctError Error - HiLink pythonHexError Error - HiLink pythonBinError Error - - HiLink pythonBuiltinObj Structure - HiLink pythonBuiltinFunc Function - - HiLink pythonExClass Structure - - delcommand HiLink -endif - -let b:current_syntax = "python" diff --git a/addons/python%790/version b/addons/python%790/version deleted file mode 100644 index 3a8b971..0000000 --- a/addons/python%790/version +++ /dev/null @@ -1 +0,0 @@ -3.0.7 \ No newline at end of file diff --git a/addons/snipmate-snippets b/addons/snipmate-snippets index b1c30e0..d57693f 160000 --- a/addons/snipmate-snippets +++ b/addons/snipmate-snippets @@ -1 +1 @@ -Subproject commit b1c30e017ef5c703e36ca7a79e102507a042b5a5 +Subproject commit d57693f610aecfb4a4e12bfaf759b94ace8b100f diff --git a/addons/vim-addon-manager-known-repositories b/addons/vim-addon-manager-known-repositories index 942bc28..d9fcfbf 160000 --- a/addons/vim-addon-manager-known-repositories +++ b/addons/vim-addon-manager-known-repositories @@ -1 +1 @@ -Subproject commit 942bc285696f6f2cbda9a2b7c2ddd755fdcff592 +Subproject commit d9fcfbf70e04c64d8dd277a0a845ad4d341b00e0 diff --git a/vimrc b/vimrc index 34ac080..d9bcc93 100644 --- a/vimrc +++ b/vimrc @@ -10,6 +10,14 @@ set viminfo+=! " make sure it can save viminfo set isk+=_,@,- " none of these should be word dividers, so make them not be set nobackup +set completeopt=longest,menuone,preview +inoremap pumvisible() ? "\" : "\u\" +inoremap pumvisible() ? '' : + \ '=pumvisible() ? "\Down>" : ""' + +inoremap pumvisible() ? '' : + \ '=pumvisible() ? "\Down>" : ""' + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Theme/Colors """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -152,9 +160,9 @@ map :call MySpellLang() " Map NERDTree show and hide map :NERDTreeToggle imap :NERDTreeToggle -" Taglist toggle -map :TlistOpen -imap :TlistClose +" Tagbar toggle +map :TagbarToggle +imap :TagbarToggle """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -181,6 +189,12 @@ if has ("autocmd") autocmd BufNewFile *.pl call append(0, "#!/usr/bin/perl") autocmd BufNewFile *.py call append(0, "#!/bin/python") + + " PHP documenter script bound to Control-P + autocmd FileType php inoremap :call PhpDocSingle()i + autocmd FileType php nnoremap :call PhpDocSingle() + autocmd FileType php vnoremap :call PhpDocRange() + " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). @@ -208,6 +222,8 @@ if &term == "screen" || &term == "xterm" set title endif + + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Plugin activation """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -217,11 +233,20 @@ let vam_install_path = expand('$HOME') . '/.vim/addons' exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager' " Enable addons with vim-addon-manager using file type recognition let ft_addons = { - \ 'always': ['surround', 'checksyntax', 'LargeFile', 'snipmate', 'snipmate-snippets', 'The_NERD_tree'], + \ 'always': ['surround', 'checksyntax', 'LargeFile', 'snipmate', 'snipmate-snippets', 'The_NERD_tree', 'SuperTab%1643'], \ 'r': [ 'Screen_vim__gnu_screentmux', 'Vim-R-plugin' ], - \ '^\%(c\|cpp\|javascript\|python\|php\|html\|xml\|r\|sh\|css\|java\|make\|xslt\|vim\)$': [ 'taglist-plus', 'checksyntax'], - \ 'python': ['pythoncomplete', 'pydoc', 'python%790'], + \ '^\%(c\|cpp\|javascript\|python\|php\|html\|xml\|r\|sh\|css\|java\|make\|xslt\|vim\)$': [ 'Tagbar', 'checksyntax'], + \ '^\%(c\|cpp\)$': [ 'clang_complete' ], + \ 'python': ['pythoncomplete', 'pydoc'], + \ 'php': ['phpcomplete', 'PDV_-_phpDocumentor_for_Vim'], \ 'gpg': ['gnupg'], \ } call vam#ActivateAddons(ft_addons['always'], {'auto_install': 1}) au FileType * for l in values(filter(copy(ft_addons), string(expand('')).' =~ v:key')) | call vam#ActivateAddons(l, {'force_loading_plugins_now':1}) | endfor + +" SuperTab option for context aware completion +let g:SuperTabDefaultCompletionType = "context" + +let g:clang_complete_copen = 1 +let g:clang_complete_auto = 1 +let g:clang_user_options='|| exit 0' -- 2.20.1