├── vimfiles ├── ftplugin │ ├── txt.vim │ ├── python.vim │ ├── cs.vim │ ├── java.vim │ ├── c.vim │ └── php.vim ├── plugin │ ├── filetype.vim │ ├── phpcs.vim │ ├── checksyntax.vim │ ├── Tabular.vim │ ├── tasklist.vim │ └── php-doc.vim ├── phpm │ ├── lib │ │ └── epc │ │ │ ├── object.php │ │ │ └── phpm │ │ │ ├── install.php │ │ │ ├── reader.php │ │ │ ├── listinstalled.php │ │ │ ├── listall.php │ │ │ └── parser.php │ ├── phpm │ ├── reader.php │ ├── generator.php │ ├── settings.xml │ ├── HISTORY │ ├── README │ └── list.xml ├── .netrwhist ├── template.spec ├── nerdtree_plugin │ ├── exec_menuitem.vim │ └── fs_menu.vim ├── after │ └── plugin │ │ └── TabularMaps.vim ├── doc │ ├── checksyntax.txt │ ├── Tabular.txt │ └── NERD_tree.txt └── autoload │ ├── tabular.vim │ └── checksyntax.vim ├── hotkeys ├── TODO ├── .vimrc ├── ptags.cpp └── README /vimfiles/ftplugin/txt.vim: -------------------------------------------------------------------------------- 1 | set autoindent 2 | -------------------------------------------------------------------------------- /vimfiles/plugin/filetype.vim: -------------------------------------------------------------------------------- 1 | augroup filetypedetect 2 | au BufNewFile,BufRead *.xt setf xt 3 | augroup END 4 | -------------------------------------------------------------------------------- /vimfiles/phpm/lib/epc/object.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jqlblue/php-vim/HEAD/vimfiles/phpm/lib/epc/object.php -------------------------------------------------------------------------------- /vimfiles/phpm/lib/epc/phpm/install.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jqlblue/php-vim/HEAD/vimfiles/phpm/lib/epc/phpm/install.php -------------------------------------------------------------------------------- /vimfiles/phpm/lib/epc/phpm/reader.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jqlblue/php-vim/HEAD/vimfiles/phpm/lib/epc/phpm/reader.php -------------------------------------------------------------------------------- /vimfiles/phpm/lib/epc/phpm/listinstalled.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jqlblue/php-vim/HEAD/vimfiles/phpm/lib/epc/phpm/listinstalled.php -------------------------------------------------------------------------------- /vimfiles/phpm/phpm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /usr/share/vim/vimfiles/phpm/ 3 | args=" " 4 | while (( "$#" )); do 5 | args="$args $1" 6 | shift 7 | done 8 | php reader.php $args 9 | -------------------------------------------------------------------------------- /vimfiles/ftplugin/python.vim: -------------------------------------------------------------------------------- 1 | " Auto expand tabs to spaces 2 | setlocal expandtab 3 | 4 | " Switch syntax highlighting on, if it was not 5 | syntax on 6 | 7 | inoremap " "" 8 | inoremap ' '' 9 | -------------------------------------------------------------------------------- /vimfiles/.netrwhist: -------------------------------------------------------------------------------- 1 | let g:netrw_dirhistmax =10 2 | let g:netrw_dirhist_cnt =3 3 | let g:netrw_dirhist_1='/var/log/httpd' 4 | let g:netrw_dirhist_2='/var/www/html' 5 | let g:netrw_dirhist_3='/usr/share/vim/vimfiles/phpm/phpdoc/en/reference/zlib/functions' 6 | -------------------------------------------------------------------------------- /vimfiles/phpm/reader.php: -------------------------------------------------------------------------------- 1 | query( $argv ) ) 10 | { 11 | echo $xml->display(); 12 | } 13 | else 14 | { 15 | echo "Could not find the function specified"; 16 | echo "\n"; 17 | } 18 | ?> 19 | -------------------------------------------------------------------------------- /vimfiles/phpm/generator.php: -------------------------------------------------------------------------------- 1 | > Starting up the XML generator...\n"; 8 | 9 | include( "lib/epc/object.php" ); 10 | $parser = new EPC_Phpm_Parser( "settings.xml" ); 11 | 12 | $parser->run(); 13 | 14 | echo ">> Finished\n\n"; 15 | ?> 16 | -------------------------------------------------------------------------------- /vimfiles/plugin/phpcs.vim: -------------------------------------------------------------------------------- 1 | function! Phpcs() 2 | " phpcs 命令的路径和参数, 请根据环境自行修改 3 | let l:filename=@% 4 | let l:phpcs_output=system('phpcs --report=csv --standard=Zend '.l:filename) 5 | let l:phpcs_list=split(l:phpcs_output, "\n") 6 | unlet l:phpcs_list[0] 7 | cexpr l:phpcs_list 8 | cwindow 9 | endfunction 10 | 11 | " :w 自动验证语法 12 | autocmd BufWritePost *.php call Phpcs() 13 | " :Phpcs 验证语法 14 | set errorformat=\"%f\"\\,%l\\,%c\\,%t%*[a-zA-Z]\\,\"%m\"\\,%*[a-zA-Z0-9_.-]\\,%*[0-9] 15 | command! Phpcs execute Phpcs() 16 | -------------------------------------------------------------------------------- /vimfiles/template.spec: -------------------------------------------------------------------------------- 1 | Name: 2 | Version: 3 | Release: 1%{?dist} 4 | Summary: 5 | 6 | Group: 7 | License: 8 | URL: 9 | Source0: 10 | BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) 11 | 12 | BuildRequires: 13 | Requires: 14 | 15 | %description 16 | 17 | 18 | %prep 19 | %setup -q 20 | 21 | 22 | %build 23 | %configure 24 | make %{?_smp_mflags} 25 | 26 | 27 | %install 28 | rm -rf $RPM_BUILD_ROOT 29 | make install DESTDIR=$RPM_BUILD_ROOT 30 | 31 | 32 | %clean 33 | rm -rf $RPM_BUILD_ROOT 34 | 35 | 36 | %files 37 | %defattr(-,root,root,-) 38 | %doc 39 | 40 | 41 | 42 | %changelog 43 | -------------------------------------------------------------------------------- /vimfiles/phpm/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | /usr/share/vim/vimfiles/phpm/phpdoc/en/reference 8 | 9 | 1 10 | 11 | php.xml 12 | 13 | 14 | 15 | 16 | B 17 | G 18 | b 19 | B 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /hotkeys: -------------------------------------------------------------------------------- 1 | some shortcut keys in use php-vim 2 | 3 | f3 - show tag list,press agian to close 4 | f2 - show NERD_tree,press again to close 5 | [v,i]ctrl+p - 在可视和插入模式下,调用phpdoc会函数和类添加phpdocument 6 | [v]ctrl+a - 在可视模式下,调用phpAlign对代码格式进行对齐 7 | [i]ctrl+h - 在插入模式下,调用phpm打开php函数的定义 8 | [v]ctrl+c - 注释代码块或者行,再按一下则取消注释 9 | [v,i]ctrl+方向键 - 以峰驼的形式,跳转到上一处或者下一处 10 | 11 | ctrl+] - 跳转到定义处 12 | ctrl+t - 从定义处跳转回来 13 | ctrl+w ctrl+] - 水平分割窗口,并在上部打开定义所在文件,跳转到定义处 14 | ctrl+\ - 打开新标签页。并跳转到定义处 15 | alt+] - 垂直分割窗口,并在右部打开定义所在文件,跳转到定义处 16 | 17 | 18 | ctrl+鼠标左键 - 跳转到定义处 19 | ctrl+鼠标右键 - 从定义处跳转回来 20 | 21 | some command in use php-vim 22 | 23 | :tabnew[:tabe] - 打开新的标签页 24 | :tabclose[:tabc] - 关闭正在打开的标签页 25 | :vimgrep - 在文件夹中查找 26 | 在当前目录下查找含有“getInfo”的php文档,但不跳到第一个匹配 27 | :vimgrep /getInfo/gj ./*/*.php 28 | 如果要包含子文件夹,则用 29 | :vimgrep /getInfo/gj ./**/*.php 30 | :vim[grep][!] /{pattern}/[g][j] {file} 31 | :cw - 打开quickfix窗口查看匹配结果 32 | 33 | 34 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | 1 use cscope in vim with php 2 | 2 update phpm 3 | 3 other 4 | 4 check phpcs use,and uncomment later 5 | 5 search in floder 6 | 在当前目录下查找含有“getInfo”的php文档,但不跳到第一个匹配 7 | :vimgrep /getInfo/gj ./*/*.php 8 | 如果要包含子文件夹,则用 9 | :vimgrep /getInfo/gj ./**/*.php 10 | :cw 11 | 打开quickfix窗口查看匹配结果 12 | :vim[grep][!] /{pattern}/[g][j] {file} 13 | Search for {pattern} in the files {file} … and set 14 | the error list to the matches. 15 | Without the ‘g’ flag each line is added only once. 16 | With ‘g’ every match is added. 17 | 18 | {pattern} is a Vim search pattern. Instead of 19 | enclosing it in / any non-ID character (see 20 | |’isident’|) can be used, so long as it does not 21 | appear in {pattern}. 22 | ‘ignorecase’ applies. To overrule it put |/c| in the 23 | pattern to ignore case or |/C| to match case. 24 | ‘smartcase’ is not used. 25 | 26 | When a number is put before the command this is used 27 | as the maximum number of matches to find. Use 28 | “:1vimgrep pattern file” to find only the first. 29 | Useful if you only want to check if there is a match 30 | and quit quickly when it’s found. 31 | 32 | Without the ‘j’ flag Vim jumps to the first match. 33 | With ‘j’ only the quickfix list is updated. 34 | With the [!] any changes in the current buffer are 35 | abandoned. 36 | 37 | @@@@ test github 38 | -------------------------------------------------------------------------------- /vimfiles/plugin/checksyntax.vim: -------------------------------------------------------------------------------- 1 | " checksyntax.vim -- Check syntax when saving a file (php, ruby, tex ...) 2 | " @Author: Tom Link (micathom AT gmail com) 3 | " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) 4 | " @Created: 04-Mai-2005. 5 | " @Last Change: 2011-05-26. 6 | " GetLatestVimScripts: 1431 0 :AutoInstall: checksyntax.vim 7 | " @Revision: 396 8 | 9 | if exists('g:loaded_checksyntax') 10 | finish 11 | endif 12 | let g:loaded_checksyntax = 103 13 | 14 | 15 | " @TPluginInclude 16 | if !exists('g:checksyntax_auto') 17 | " If non-null, enable automatic syntax checks after saving a file. 18 | let g:checksyntax_auto = 1 19 | endif 20 | 21 | 22 | " @TPluginInclude 23 | augroup CheckSyntax 24 | autocmd! 25 | if g:checksyntax_auto 26 | autocmd CheckSyntax BufWritePost * call checksyntax#Check(0) 27 | endif 28 | augroup END 29 | 30 | 31 | " :display: CheckSyntax[!] [NAME] 32 | " Check the current buffer's syntax (type defaults to &filetype). 33 | " Or use NAME instead of &filetype. 34 | " 35 | " With the bang !, use the alternative syntax checker (see 36 | " |g:checksyntax|). 37 | command! -bang -nargs=? CheckSyntax call checksyntax#Check(1, "", ) 38 | 39 | 40 | " @TPluginInclude 41 | if !hasmapto(':CheckSyntax') && empty(maparg('', 'n')) 42 | noremap :CheckSyntax 43 | inoremap :CheckSyntax 44 | endif 45 | 46 | -------------------------------------------------------------------------------- /vimfiles/phpm/HISTORY: -------------------------------------------------------------------------------- 1 | 20/11/2004 2 | - Added support for extended information, all the old XML files will not 3 | work with this new functionality: 4 | * -e/--extended: extended description 5 | * -s/--short: short description 6 | - Added remote install: you can now query for projects and install from the 7 | eide.org server ( see http://wiki.cc/php/Epc_phpm for more information ) 8 | - Added help to the program "-h/--help" 9 | - New settings param in settings.xml , so make sure to update this! 10 | - A new phpDocumentor converter is in place for people that want to generate their 11 | own XML files ( contact me and I'll put them on the server ) 12 | 13 | 14/11/2004 14 | - Added support for multiple projects, all XML is now in "xml/" 15 | This needs the "-p pro" call where "pro" is a project name 16 | - Added support for wildcard query if a exact match isn't found 17 | - Multiple function calls will be output to the terminal if more than one 18 | hit was found for the param 19 | - Added "defaultproject" node to the settings 20 | - Added support for case/case-insensitive queries: 21 | * -c/--case or -ci/--case-insensitive 22 | - The query needs to be the last thing passed in the argument line 23 | 24 | 01/11/2004 25 | - Added a "phpm" bash script 26 | - More information and renamed the files to be a bit more 27 | description to what they do. 28 | - Added more configuration options to color the output 29 | with Console_Color ( Optional ) 30 | 31 | 31/10/2004 32 | First release with base functionality 33 | -------------------------------------------------------------------------------- /vimfiles/ftplugin/cs.vim: -------------------------------------------------------------------------------- 1 | " {{{ Settings 2 | 3 | " Auto expand tabs to spaces 4 | set expandtab 5 | 6 | " Auto indent after a { 7 | set autoindent 8 | set smartindent 9 | 10 | " Linewidth to endless 11 | set textwidth=0 12 | 13 | " Do not wrap lines automatically 14 | set nowrap 15 | 16 | " Correct indentation after opening a phpdocblock and automatic * on every 17 | " line 18 | set formatoptions=qroct 19 | 20 | " }}} Settings 21 | 22 | " {{{ Automatic close char mapping 23 | 24 | " More common in PEAR coding standard 25 | inoremap { {}O 26 | " Maybe this way in other coding standards 27 | " inoremap { {}O 28 | 29 | inoremap [ [] 30 | 31 | " Standard mapping after PEAR coding standard 32 | inoremap ( () 33 | 34 | " Maybe this way in other coding standards 35 | " inoremap ( ( ) 36 | 37 | inoremap " "" 38 | inoremap ' '' 39 | 40 | " }}} Automatic close char mapping 41 | 42 | " {{{ Wrap visual selections with chars 43 | 44 | :vnoremap ( "zdi(z) 45 | :vnoremap { "zdi{z} 46 | :vnoremap [ "zdi[z] 47 | :vnoremap ' "zdi'z' 48 | :vnoremap " "zdi"z" 49 | 50 | " }}} Wrap visual selections with chars 51 | 52 | " {{{ Autocompletion using the TAB key 53 | 54 | " This function determines, wether we are on the start of the line text (then tab indents) or 55 | " if we want to try autocompletion 56 | func! InsertTabWrapper() 57 | let col = col('.') - 1 58 | if !col || getline('.')[col - 1] !~ '\k' 59 | return "\" 60 | else 61 | return "\" 62 | endif 63 | endfunction 64 | 65 | " Remap the tab key to select action with InsertTabWrapper 66 | inoremap =InsertTabWrapper() 67 | 68 | " }}} Autocompletion using the TAB key 69 | -------------------------------------------------------------------------------- /vimfiles/nerdtree_plugin/exec_menuitem.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================ 2 | " File: exec_menuitem.vim 3 | " Description: plugin for NERD Tree that provides an execute file menu item 4 | " Maintainer: Martin Grenfell 5 | " Last Change: 22 July, 2009 6 | " License: This program is free software. It comes without any warranty, 7 | " to the extent permitted by applicable law. You can redistribute 8 | " it and/or modify it under the terms of the Do What The Fuck You 9 | " Want To Public License, Version 2, as published by Sam Hocevar. 10 | " See http://sam.zoy.org/wtfpl/COPYING for more details. 11 | " 12 | " ============================================================================ 13 | if exists("g:loaded_nerdtree_exec_menuitem") 14 | finish 15 | endif 16 | let g:loaded_nerdtree_exec_menuitem = 1 17 | 18 | call NERDTreeAddMenuItem({ 19 | \ 'text': '(!)Execute file', 20 | \ 'shortcut': '!', 21 | \ 'callback': 'NERDTreeExecFile', 22 | \ 'isActiveCallback': 'NERDTreeExecFileActive' }) 23 | 24 | function! NERDTreeExecFileActive() 25 | let node = g:NERDTreeFileNode.GetSelected() 26 | return !node.path.isDirectory && node.path.isExecutable 27 | endfunction 28 | 29 | function! NERDTreeExecFile() 30 | let treenode = g:NERDTreeFileNode.GetSelected() 31 | echo "==========================================================\n" 32 | echo "Complete the command to execute (add arguments etc):\n" 33 | let cmd = treenode.path.str({'escape': 1}) 34 | let cmd = input(':!', cmd . ' ') 35 | 36 | if cmd != '' 37 | exec ':!' . cmd 38 | else 39 | echo "Aborted" 40 | endif 41 | endfunction 42 | -------------------------------------------------------------------------------- /vimfiles/ftplugin/java.vim: -------------------------------------------------------------------------------- 1 | " .vim/ftplugin/php.vim by Tobias Schlitt . 2 | " No copyright, feel free to use this, as you like. 3 | 4 | " {{{ Settings 5 | 6 | " Auto expand tabs to spaces 7 | setlocal expandtab 8 | 9 | " Auto indent after a { 10 | " setlocal autoindent 11 | " setlocal smartindent 12 | 13 | " Linewidth to endless 14 | setlocal textwidth=0 15 | 16 | " Do not wrap lines automatically 17 | setlocal nowrap 18 | 19 | " Correct indentation after opening a phpdocblock and automatic * on every 20 | " line 21 | " setlocal formatoptions=qroct 22 | 23 | " Switch syntax highlighting on, if it was not 24 | syntax on 25 | 26 | " }}} Settings 27 | 28 | " {{{ Command mappings 29 | 30 | " Map ; to "add ; to the end of the line, when missing" 31 | noremap ; :s/\([^;]\)$/\1;/ 32 | 33 | " }}} 34 | 35 | " {{{ Automatic close char mapping 36 | 37 | " More common in PEAR coding standard 38 | inoremap { {}O 39 | " Maybe this way in other coding standards 40 | " inoremap { {}O 41 | 42 | inoremap [ [] 43 | 44 | " Maybe this way in other coding standards 45 | inoremap ( () 46 | 47 | inoremap " "" 48 | inoremap ' '' 49 | 50 | " }}} Automatic close char mapping 51 | 52 | " {{{ Dictionary completion 53 | 54 | " Use the dictionary completion 55 | setlocal complete-=k complete+=k 56 | 57 | " }}} Dictionary completion 58 | 59 | " {{{ Autocompletion using the TAB key 60 | 61 | " This function determines, wether we are on the start of the line text (then tab indents) or 62 | " if we want to try autocompletion 63 | func! InsertTabWrapper() 64 | let col = col('.') - 1 65 | if !col || getline('.')[col - 1] !~ '\k' 66 | return "\" 67 | else 68 | return "\" 69 | endif 70 | endfunction 71 | 72 | " Remap the tab key to select action with InsertTabWrapper 73 | inoremap =InsertTabWrapper() 74 | 75 | " }}} Autocompletion using the TAB key 76 | -------------------------------------------------------------------------------- /vimfiles/after/plugin/TabularMaps.vim: -------------------------------------------------------------------------------- 1 | if !exists(':Tabularize') 2 | finish " Tabular.vim wasn't loaded 3 | endif 4 | 5 | let s:save_cpo = &cpo 6 | set cpo&vim 7 | 8 | AddTabularPattern! assignment /[|&+*/%<>=!~-]\@!=]=\|=\~\)\@![|&+*/%<>=!~-]*=/l1r1 9 | AddTabularPattern! two_spaces / /l0 10 | 11 | AddTabularPipeline! multiple_spaces / / map(a:lines, "substitute(v:val, ' *', ' ', 'g')") | tabular#TabularizeStrings(a:lines, ' ', 'l0') 12 | 13 | AddTabularPipeline! argument_list /(.*)/ map(a:lines, 'substitute(v:val, ''\s*\([(,)]\)\s*'', ''\1'', ''g'')') 14 | \ | tabular#TabularizeStrings(a:lines, '[(,)]', 'l0') 15 | \ | map(a:lines, 'substitute(v:val, ''\(\s*\),'', '',\1 '', "g")') 16 | \ | map(a:lines, 'substitute(v:val, ''\s*)'', ")", "g")') 17 | 18 | function! SplitCDeclarations(lines) 19 | let rv = [] 20 | for line in a:lines 21 | " split the line into declaractions 22 | let split = split(line, '\s*[,;]\s*') 23 | " separate the type from the first declaration 24 | let type = substitute(split[0], '\%(\%([&*]\s*\)*\)\=\k\+$', '', '') 25 | " add the ; back on every declaration 26 | call map(split, 'v:val . ";"') 27 | " add the first element to the return as-is, and remove it from the list 28 | let rv += [ remove(split, 0) ] 29 | " transform the other elements by adding the type on at the beginning 30 | call map(split, 'type . v:val') 31 | " and add them all to the return 32 | let rv += split 33 | endfor 34 | return rv 35 | endfunction 36 | 37 | AddTabularPipeline! split_declarations /,.*;/ SplitCDeclarations(a:lines) 38 | 39 | AddTabularPattern! ternary_operator /^.\{-}\zs?\|:/l1 40 | 41 | AddTabularPattern! cpp_io /<<\|>>/l1 42 | 43 | AddTabularPattern! pascal_assign /:=/l1 44 | 45 | AddTabularPattern! trailing_c_comments /\/\*\|\*\/\|\/\//l1 46 | 47 | let &cpo = s:save_cpo 48 | unlet s:save_cpo 49 | -------------------------------------------------------------------------------- /vimfiles/phpm/README: -------------------------------------------------------------------------------- 1 | -------------- 2 | Program: phpm 3 | Author: Havard Eide 4 | Version: 0.3 5 | License: GPL 6 | Release: 20/11/2004 7 | -------------- 8 | Quick description: 9 | phpm is a program for accessing API calls for PHP libraries. 10 | It was originally created to query the PHP manual from the shell, 11 | but comes with a range of pre-generated project API's that can 12 | be queried. 13 | 14 | -------------- 15 | The files: 16 | * generator.php 17 | This is the XML generator: if you have a CVS dir with the 18 | PHP doc code - configure "settings.xml" and run this 19 | with "php epcmanual.php" 20 | 21 | * reader.php 22 | This is the actual query tool: run it with 23 | "php reader.php mysql_query" to get the result. 24 | If a exact hit isn't found it will query the API for functions 25 | that start with the argument, if this fails the program will 26 | try a wildcard query for anything that contains the argument. 27 | The "xml/*.xml" contains all the functions, pregenerated, so 28 | you don't need to run the "generator.php" to generate it. 29 | 30 | To query a different project than the default: 31 | "php reader.php -p pro query" where "pro" is one of the projects listed 32 | below. 33 | 34 | * The "phpm" script 35 | You will need to symlink this to /usr/bin/, /usr/local/bin with: 36 | "sudo ln -s /Users/nucleuz/Sites/phpm/phpm /usr/bin/phpm" 37 | to make it work from anywhere in the terminal. 38 | 39 | You will also need to change the first command to reference the folder 40 | where this program is installed 41 | 42 | * xml files 43 | Update the settings.xml and point to a directory where you want 44 | the XML files to be stored. Download and copy the XML bundle from eide.org 45 | to this folder. 46 | 47 | ---------------- 48 | ToDo: 49 | - Versioning 50 | - Integrate with wordpress [Planned for v0.4] 51 | - Support for wildcard query [Done - v0.2] 52 | - Query for a class 53 | - Get extended result "-e" -> more text from the DocBook needs to be extracted. [Done -v0.3] 54 | 55 | Havard Eide. 56 | -------------------------------------------------------------------------------- /vimfiles/ftplugin/c.vim: -------------------------------------------------------------------------------- 1 | " .vim/ftplugin/c.vim by Tobias Schlitt . 2 | " No copyright, feel free to use this, as you like. 3 | 4 | " {{{ Settings 5 | 6 | " Auto expand tabs to spaces 7 | set expandtab 8 | 9 | " Auto indent after a { 10 | set autoindent 11 | set smartindent 12 | 13 | " Linewidth to endless 14 | set textwidth=0 15 | 16 | " Do not wrap lines automatically 17 | set nowrap 18 | 19 | " Correct indentation after opening a phpdocblock and automatic * on every 20 | " line 21 | set formatoptions=qroct 22 | 23 | " Switch syntax highlighting on, if it was not 24 | syntax on 25 | 26 | " }}} Settings 27 | 28 | " {{{ Command mappings 29 | 30 | " Map ; to run PHP parser check 31 | " noremap ; :!php5 -l % 32 | 33 | " Map ; to "add ; to the end of the line, when missing" 34 | noremap ; :s/\([^;]\)$/\1;/ 35 | 36 | " }}} 37 | 38 | " {{{ Automatic close char mapping 39 | 40 | " More common in PEAR coding standard 41 | inoremap { {}O 42 | " Maybe this way in other coding standards 43 | " inoremap { {}O 44 | 45 | inoremap [ [] 46 | 47 | " Standard mapping after PEAR coding standard 48 | inoremap ( () 49 | 50 | " Maybe this way in other coding standards 51 | " inoremap ( ( ) 52 | 53 | inoremap " "" 54 | inoremap ' '' 55 | 56 | " }}} Automatic close char mapping 57 | 58 | " {{{ Wrap visual selections with chars 59 | 60 | :vnoremap ( "zdi(z) 61 | :vnoremap { "zdi{z} 62 | :vnoremap [ "zdi[z] 63 | :vnoremap ' "zdi'z' 64 | " Removed in favor of register addressing 65 | " :vnoremap " "zdi"z" 66 | 67 | " }}} Wrap visual selections with chars 68 | 69 | " {{{ Autocompletion using the TAB key 70 | 71 | " This function determines, wether we are on the start of the line text (then tab indents) or 72 | " if we want to try autocompletion 73 | func! InsertTabWrapper() 74 | let col = col('.') - 1 75 | if !col || getline('.')[col - 1] !~ '\k' 76 | return "\" 77 | else 78 | return "\" 79 | endif 80 | endfunction 81 | 82 | " Remap the tab key to select action with InsertTabWrapper 83 | inoremap =InsertTabWrapper() 84 | 85 | " }}} Autocompletion using the TAB key 86 | -------------------------------------------------------------------------------- /vimfiles/phpm/lib/epc/phpm/listall.php: -------------------------------------------------------------------------------- 1 | settings = $settings; 25 | if( !isset( $this->settings->download["listing"] ) ) 26 | { 27 | die( "The download listing setting was not set!" ); 28 | } 29 | } 30 | // }}} 31 | 32 | // {{{ public function run() 33 | /** 34 | * The only function to run on the object. 35 | * 36 | * It will attempt to download the settings file and list all the 37 | * projects that can be downloaded from the central server. 38 | * 39 | * @access public 40 | * @return void 41 | */ 42 | public function run() 43 | { 44 | $list = @file_get_contents( $this->settings->download["listing"] ); 45 | if( $list ) 46 | { 47 | echo ">>The following projects are available from the server:\n"; 48 | $xml = new SimpleXMLElement( $list ); 49 | foreach( $xml->project as $project ) 50 | { 51 | echo 'Project: "' . $project->name . '" '; 52 | echo 'version: '. $project->version . ' '. "\n\t\t"; 53 | echo 'key: "' . $project->key . '"' . "\n"; 54 | } 55 | echo "\n>>Install any of these with: 'phpm --install {key}'\n"; 56 | } 57 | else 58 | { 59 | echo ">>Could not get the settings file from the server.\n"; 60 | } 61 | } 62 | // }}} 63 | 64 | // {{{ public function toXML() 65 | /** 66 | * Override the parent toXML(). 67 | * 68 | * @return string A XML string with the settings URL listed as variable. 69 | */ 70 | public function toXML() 71 | { 72 | return parent::toXML( array( "settings" => $this->settings->download["listing"] ) ); 73 | } 74 | // }}} 75 | } 76 | ?> -------------------------------------------------------------------------------- /vimfiles/phpm/list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | epc 6 | Eide PHP Classes 7 | CVS Head 8 | 2004/11/20 9 | http://eide.org/?epc=php 10 | GPL 11 | 12 | 13 | ism 14 | Isom 15 | 0.1.4 16 | 2004/11/20 17 | http://ismo.morrdusk.net/ 18 | PHP 19 | 20 | 21 | moj 22 | Mojavi 23 | 3.0.0 24 | 2004/11/20 25 | http://www.mojavi.org 26 | LGPL 27 | 28 | 29 | php 30 | php.net manual 31 | 2004/11/20 32 | CVS HEAD 33 | http://php.net/manual 34 | PHP 35 | 36 | 37 | phr 38 | Phrame 39 | 2.1RC1 40 | 2004/11/20 41 | http://sourceforge.net/projects/phrame 42 | LGPL 43 | 44 | 45 | phv 46 | php.MVC 47 | 0.3.4 48 | 2004/11/20 49 | http://www.phpmvc.net 50 | LGPL 51 | 52 | 53 | pra 54 | Prado 55 | 1.6 56 | 2004/11/20 57 | http://www.xisc.com/ 58 | BSD 59 | 60 | 61 | rmf 62 | rmfPHP 63 | 0.1.2 64 | 2004/11/20 65 | http://www.rwfphp.org/ 66 | BSD (?) 67 | 68 | 69 | sim 70 | SimpleTest 71 | 1.0RC1 72 | 2004/11/20 73 | http://sourceforge.net/projects/simpletest/ 74 | The Open Group Test Suite License 75 | 76 | 77 | std 78 | studs 79 | 1.0RC1 80 | 2004/11/20 81 | http://www.mojavelinux.com/projects/studs/ 82 | Apache2.0 83 | 84 | 85 | wct 86 | wact 87 | CVS head 88 | 2004/11/20 89 | http://wact.sourceforge.net 90 | LGPL 91 | 92 | 93 | xp 94 | wact 95 | xp-2004-11-12 96 | 2004/11/20 97 | http://xp-framework.net/ 98 | BSD 99 | 100 | 101 | -------------------------------------------------------------------------------- /vimfiles/doc/checksyntax.txt: -------------------------------------------------------------------------------- 1 | *checksyntax.txt* checksyntax -- Check syntax when saving a file (php, ruby, tex ...) 2 | Author: Tom Link, micathom at gmail com 3 | 4 | By default, |:CheckSyntax| is mapped to (if not mapped already), and 5 | automatically executed when saving the buffer. 6 | The |:CheckSyntax| command takes one optional argument: the mode (default: 7 | &filetype). The following modes are pre-defined (and maybe some more): 8 | 9 | c, cpp :: Check syntax via splint 10 | html :: Check syntax via tidy 11 | javascript :: Check syntax via jsl or gjslint 12 | java :: Check syntax via jlint or javaCheckstyle 13 | lua :: Parse file (luac -p) 14 | php :: Check syntax (php -l) 15 | phpp :: Parse a file (php -f) (alternative php checker) 16 | python :: Check file with pyflakes 17 | pylint :: Use the pylint compiler plugin (alternative python checker) 18 | ruby :: Check syntax (ruby -c; no auto-checks) 19 | tex, latex :: Parse file (chktex -q -v0; no auto-checks) 20 | xml, docbk :: Check syntax via xmllint 21 | 22 | See |g:checksyntax| for how to define your own syntax checkers. 23 | 24 | This plugin was originally based on Klaus Horsten's php_console 25 | (vimscript #779) and it is the successor of php_check_syntax.vim 26 | (vimscript #1272). In opposition to php_console, it is not a php 27 | ftplugin but a general solution for checking the syntax when saving a 28 | file (using the appropriate interpreter, lint or whatsoever). 29 | 30 | 31 | ----------------------------------------------------------------------- 32 | Install~ 33 | 34 | Edit the vba file and type: > 35 | 36 | :so % 37 | 38 | See :help vimball for details. If you have difficulties or use vim 7.0, 39 | please make sure, you have the current version of vimball (vimscript 40 | #1502) installed or update your runtime. 41 | 42 | 43 | ======================================================================== 44 | Contents~ 45 | 46 | :CheckSyntax ............... |:CheckSyntax| 47 | ....................... || 48 | i_ ..................... |i_| 49 | g:checksyntax .............. |g:checksyntax| 50 | checksyntax#Check .......... |checksyntax#Check()| 51 | 52 | 53 | ======================================================================== 54 | plugin/checksyntax.vim~ 55 | 56 | *:CheckSyntax* 57 | CheckSyntax[!] [NAME] 58 | Check the current buffer's syntax (type defaults to &filetype). 59 | Or use NAME instead of &filetype. 60 | 61 | With the bang !, use the alternative syntax checker (see 62 | |g:checksyntax|). 63 | 64 | ** 65 | ... :CheckSyntax 66 | 67 | *i_* 68 | i_ ... :CheckSyntax 69 | 70 | 71 | ======================================================================== 72 | autoload/checksyntax.vim~ 73 | 74 | *g:checksyntax* 75 | g:checksyntax (default: {}) 76 | A dictionary {name/filetype => definition} of syntax checkers, where 77 | definition is a dictionary with the following fields: 78 | 79 | Mandatory (either one of the following): 80 | cmd ... A shell command used as 'makeprg' to check the file. 81 | exec ... A vim command used to check the file. 82 | compiler ... A vim compiler that is used to check the file. 83 | 84 | Optional: 85 | auto ... Run automatically when saving a file. 86 | efm ... An 'errorformat' string. 87 | okrx ... A |regexp| matching the command output if no error were 88 | found. 89 | failrx ... A |regexp| matching the command output if an error 90 | was found. 91 | alt ... The name of an alternative syntax checker (see 92 | |:CheckSyntax|). 93 | prepare ... An ex command that is run before doing anything. 94 | ignore_nr ... A list of error numbers that should be ignored. 95 | 96 | *checksyntax#Check()* 97 | checksyntax#Check(manually, ?bang='', ?type=&ft) 98 | 99 | 100 | 101 | vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl: 102 | -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | " .vimrc 2 | " See: http://vimdoc.sourceforge.net/htmldoc/options.html for details 3 | 4 | " Source local settings 5 | if filereadable("~/.vimrc") 6 | source ~/.vimrc 7 | endif 8 | 9 | " disable VI's compatible mode(关闭vi兼容模式) 10 | set nocompatible 11 | " set encoding=utf-8(设置支持多语言) 12 | set fileencodings=utf-8,gbk,default,latin1 13 | "set gui options(设置字体,配色方案) 14 | if has("gui_running") 15 | set guifont=Courier\ New\ 14 16 | " on windows,use "set guifont=Courier:14 " 17 | " set color schema(设置配色方案) 18 | " colorscheme oceandeep 19 | endif 20 | 21 | " Basic editing options 22 | set number " Show line numbers.显示行号 23 | set expandtab " Use the appropriate number of spaces to insert a .用空格替换tab 24 | set shiftwidth=2 " Number of spaces to use for each step of (auto)indent.自动缩进的空格数 25 | set tabstop=2 " Number of spaces that a in the file counts for.一个tab用几个空格替换 26 | au FileType html,python,vim,javascript,css setl shiftwidth=2 27 | au FileType html,python,vim,javascript,css setl tabstop=2 28 | au FileType java,php setl shiftwidth=4 29 | au FileType java,php setl tabstop=4 30 | 31 | set textwidth=80 " Maximum width of text that is being inserted. A longer 32 | " line will be broken after white space to get this width.(每行的最大字符数,超过的话,将换行) 33 | set hlsearch " When there is a previous search pattern, highlight all 34 | " its matches.(搜索时高亮显示) 35 | 36 | set incsearch " While typing a search command, show immediately where the 37 | " so far typed pattern matches.(搜索时,立即高亮显示输入的字符) 38 | set fileformat=unix " 文本格式 39 | set nobackup " 不生成备份文件 40 | " Show a status bar " 显示状态栏 41 | set ruler 42 | set laststatus=2 43 | " Show Tab Bar 44 | set showtabline=2 " 生成多tab 45 | set tabline+=%f 46 | " Enable Code Folding 47 | set foldenable 48 | set foldmethod=syntax 49 | set mouse=a " Enable the use of the mouse.(可以使用鼠标) 50 | 51 | 52 | set cmdheight=1 "设定命令行的行数为 1 53 | "去掉烦死我的错误声音 54 | set vb t_vb= 55 | "工作目录随文件变 56 | autocmd BufEnter * cd %:p:h 57 | "设置状态栏 58 | set statusline=%F%m%r,%Y,%{&fileformat}\ \ \ ASCII=\%b,HEX=\%B\ \ \ %l,%c%V\ %p%%\ \ \ [\ %L\ lines\ in\ all\ ] 59 | "不显示工具条 60 | "set guioptions-=T 61 | set backspace=indent,eol,start "不设定的话在插入状态无法用退格键和 Delete 62 | filetype indent on "设置文件类型的检测,e.g. for PHP 63 | filetype plugin on "为特定的文件类型允许插件文件的载入 64 | 65 | " Allow file inline modelines to provide settings 66 | set modeline 67 | 68 | 69 | 70 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 71 | " => Plugin configuration 72 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 73 | " NERDTree 74 | map :NERDTreeToggle 75 | let NERDTreeIgnore=['\.svn$','\.bak$'] 76 | 77 | " taglist 78 | set tags=tags;/ 79 | let Tlist_Ctags_Cmd="/usr/bin/ctags" 80 | map :TlistToggle 81 | let Tlist_Auto_Highlight_Tag = 1 82 | let Tlist_Auto_Open = 0 83 | let Tlist_Auto_Update = 1 84 | let Tlist_Close_On_Select = 0 85 | let Tlist_Compact_Format = 0 86 | let Tlist_Display_Prototype = 0 87 | let Tlist_Display_Tag_Scope = 1 88 | let Tlist_Enable_Fold_Column = 0 89 | let Tlist_Exit_OnlyWindow = 0 90 | let Tlist_File_Fold_Auto_Close = 0 91 | let Tlist_GainFocus_On_ToggleOpen = 1 92 | let Tlist_Hightlight_Tag_On_BufEnter = 1 93 | let Tlist_Inc_Winwidth = 0 94 | let Tlist_Max_Submenu_Items = 1 95 | let Tlist_Max_Tag_Length = 30 96 | let Tlist_Process_File_Always = 0 97 | let Tlist_Show_Menu = 0 98 | let Tlist_Show_One_File = 0 99 | let Tlist_Sort_Type = "order" 100 | let Tlist_Use_Horiz_Window = 0 101 | let Tlist_Use_Right_Window = 0 102 | let Tlist_WinWidth = 40 103 | let tlist_php_settings = 'php;c:class;i:interfaces;d:constant;f:function' 104 | 105 | " Disable phpsyntax based indenting for .php files {{{ 106 | au BufRead,BufNewFile *.php set indentexpr= | set smartindent 107 | " }}} 108 | 109 | " {{{ .phps files handled like .php 110 | 111 | au BufRead,BufNewFile *.phps set filetype=php 112 | 113 | " }}} 114 | 115 | " {{{ Settings 116 | 117 | 118 | 119 | " MovingThroughCamelCaseWords 120 | nnoremap :cal search('\<\\U\@<=\u\\u\ze\%(\U\&\>\@!\)\\%^','bW') 121 | nnoremap :cal search('\<\\U\@<=\u\\u\ze\%(\U\&\>\@!\)\\%$','W') 122 | inoremap :cal search('\<\\U\@<=\u\\u\ze\%(\U\&\>\@!\)\\%^','bW') 123 | inoremap :cal search('\<\\U\@<=\u\\u\ze\%(\U\&\>\@!\)\\%$','W') 124 | 125 | " }}} 126 | 127 | " Map to turn spelling on (VIM 7.0+) 128 | map :setlocal spell! spelllang=en_us 129 | " Map to turn spelling (de) on (VIM 7.0+) 130 | "map :setlocal spell! spelllang=de 131 | 132 | " Highlight current line in insert mode. 133 | autocmd InsertLeave * se nocul 134 | autocmd InsertEnter * se cul 135 | 136 | if has("cscope") 137 | set csprg=/usr/bin/cscope 138 | set csto=0 139 | set cst 140 | set nocsverb 141 | " add any database in current directory 142 | if filereadable("cscope.out") 143 | cs add cscope.out 144 | " else add database pointed to by environment 145 | elseif $CSCOPE_DB != "" 146 | cs add $CSCOPE_DB 147 | endif 148 | set csverb 149 | endif 150 | -------------------------------------------------------------------------------- /ptags.cpp: -------------------------------------------------------------------------------- 1 | // Save this file as ptags.cpp and compile by 2 | // g++ -o ptags ptags.cpp 3 | //***************************************************************** 4 | // Copyright policy is GNU/GPL but additional request is 5 | // that you include author's name and email on all copies 6 | // Author : Al Dev Email: alavoor@yahoo.com 7 | // Usage : ptags *.php3 *.inc 8 | // This will generate a file called tags 9 | //***************************************************************** 10 | #include 11 | #include 12 | #include // for sprintf 13 | #include // for system 14 | #include // for memset 15 | #include // for isspace 16 | 17 | #define BUFF_LEN 1024 18 | #define LOCATION 9 19 | using namespace std; 20 | 21 | char *ltrim(char *dd); 22 | char *rtrim(char *ee); 23 | 24 | main(int argc, char **argv) 25 | { 26 | if (argc < 2) 27 | { 28 | cerr << "\nUsage: " << argv[0] << " file .... " << endl; 29 | exit(0); 30 | } 31 | 32 | char fname[100] = "tag_file.out"; 33 | FILE *fpout; 34 | ofstream fout(fname); 35 | if (fout.fail()) 36 | { 37 | cerr << "\nError opening file : " << fname << endl; 38 | exit(-1); 39 | } 40 | //fpout = fopen(fname, "w"); 41 | 42 | for (int ii = 1; ii < argc; ii++) 43 | { 44 | /* 45 | char buff[2024]; 46 | 47 | sprintf(buff, "\\rm -f %s; ls %s > %s 2>/dev/null", outfile, argv[1], outfile); 48 | cout << "\nbuff = " << buff << endl; 49 | 50 | system(buff); 51 | fclose(fp); 52 | */ 53 | FILE *fpin = NULL; 54 | fpin = fopen(argv[ii], "r"); 55 | if (fpin == NULL) 56 | { 57 | cerr << "\nError opening file : " << argv[ii] << endl; 58 | exit(-1); 59 | } 60 | char buff[BUFF_LEN + 100]; 61 | memset(buff, 0, BUFF_LEN +10); 62 | for ( ; fgets(buff, BUFF_LEN, fpin) != NULL; ) 63 | { 64 | char aa[BUFF_LEN + 100]; 65 | char aapointer[BUFF_LEN + 100]; 66 | memset(aa, 0, BUFF_LEN +10); 67 | strcpy(aa, buff); 68 | strcpy(aapointer, ltrim(aa)); 69 | strcpy(aa, aapointer); 70 | 71 | // Remove the trailing new line.. 72 | { 73 | int tmpii = strlen(aa); 74 | if (aa[tmpii-1] == '\n') 75 | aa[tmpii-1] = 0; 76 | } 77 | //cout << "aa is : " << aa << endl; 78 | //cout << "aapointer is : " << aapointer << endl; 79 | if (strncmp(aa, "function ", LOCATION) != 0) 80 | continue; 81 | //cout << buff << endl; 82 | 83 | // Example tags file output is like - 84 | // al2 al.c /^al2()$/;" f 85 | { 86 | char bb[BUFF_LEN + 100]; 87 | memset(bb, 0, BUFF_LEN +10); 88 | strcpy(bb, & aa[LOCATION]); 89 | char *cc = bb; 90 | while (cc != NULL && *cc != '(') 91 | *cc++; 92 | *cc = 0; 93 | cc = rtrim(bb); 94 | //cout << "bb is : " << bb << endl; 95 | //cout << cc << "\t" << argv[ii] << "\t" << "/^" << aa << "$/;\"\tf" << endl; 96 | fout << cc << "\t" << argv[ii] << "\t" << "/^" << aa << "$/;\"\tf" << endl; 97 | //fprintf(fpout, "%s\t%s\t/^%s$/;\"f\n", cc, argv[ii], aa ); 98 | } 99 | 100 | memset(buff, 0, BUFF_LEN +10); 101 | } 102 | fclose(fpin); 103 | } 104 | fout.flush(); 105 | fout.close(); 106 | //fclose(fpout); 107 | 108 | // Sort and generate the tag file 109 | { 110 | char tmpaa[1024]; 111 | sprintf(tmpaa, "sort %s > tags; \\rm -f %s", fname, fname); 112 | system(tmpaa); 113 | } 114 | } 115 | 116 | char *ltrim(char *dd) 117 | { 118 | if (dd == NULL) 119 | return NULL; 120 | 121 | while (isspace(*dd)) 122 | dd++; 123 | 124 | return dd; 125 | } 126 | 127 | char *rtrim(char *ee) 128 | { 129 | if (ee == NULL) 130 | return NULL; 131 | 132 | int tmpii = strlen(ee) - 1; 133 | for (; tmpii >= 0 ; tmpii--) 134 | { 135 | if (isspace(ee[tmpii]) ) 136 | { 137 | //cout << "\nis a space!!" << endl; 138 | ee[tmpii] = 0; 139 | } 140 | } 141 | return ee; 142 | } -------------------------------------------------------------------------------- /vimfiles/phpm/lib/epc/phpm/parser.php: -------------------------------------------------------------------------------- 1 | settings = simplexml_load_file( $conf ); 33 | if( !file_exists( $this->settings->cvsdir ) ) 34 | { 35 | die( "Can't find the CVS dir in: " . $this->settings->cvsdir ); 36 | } 37 | } 38 | else 39 | { 40 | die( "Can't load a settings file that is missing...." ); 41 | } 42 | $this->startDir = $startDir; 43 | } 44 | // }}} 45 | 46 | // {{{ public function run() 47 | /** 48 | * Main function on the object, initiates the parsing 49 | * of the main document tree. 50 | * 51 | * @access public 52 | * @return void 53 | */ 54 | public function run() 55 | { 56 | // XML declaration is good to have: 57 | $this->buffer = '' . "\n"; 58 | /* 59 | * We loop over all the directories in the dir given in the 60 | * constructor: each of these will have a directory called "functions", this 61 | * is where all the XML files we want to process are. 62 | */ 63 | $dir = new RecursiveDirectoryIterator( $this->settings->cvsdir ); 64 | foreach( $dir as $file ) 65 | { 66 | echo ">>Processing: $file\n"; 67 | if( $file->isDir() && $file->getFileName() != "CVS" ) 68 | { 69 | foreach( $file->getChildren() as $f ) 70 | { 71 | if( $f->getFileName() == "functions" ) 72 | { 73 | $this->processDirectory( $f->getChildren() ); 74 | } 75 | } 76 | } 77 | } 78 | $this->buffer .= "\n"; 79 | file_put_contents( $this->settings->save, $this->buffer ); 80 | } 81 | // }}} 82 | 83 | // {{{ private function processDirectory( $file ) 84 | /** 85 | * Helper function that iterates over the XML files in a single "functions/" 86 | * directory. 87 | * It passes each file to the processFile() function. 88 | * 89 | * @access private 90 | * @return void 91 | * @param $file object A DirectoryIterator instance 92 | */ 93 | private function processDirectory( DirectoryIterator $file ) 94 | { 95 | foreach( $file as $f ) 96 | { 97 | $this->processFile( $f ); 98 | } 99 | } 100 | // }}} 101 | 102 | // {{{ private function processFile( $file ) 103 | /** 104 | * This function is where all the lookup of the manual entry is. 105 | * 106 | * We are very lazy here: we suppress any errors that the Dom might throw at 107 | * us, and we load the XML data as HTML - we're just interested in a particular 108 | * node - no need to have a whole document that is valid, as long as we are able 109 | * to get to the "methodsynopsis" node. 110 | * 111 | 112 | * @param object $file A DirectoryIterator instance 113 | * @access private 114 | * @return void 115 | */ 116 | private function processFile( DirectoryIterator $file ) 117 | { 118 | $dom = new DomDocument(); 119 | @$dom->loadHTML( file_get_contents( $file->getPathName() ) ); 120 | $xpath = new DomXpath( $dom ); 121 | 122 | // Get the node where the description of the function call is: 123 | $result = @$xpath->query( "//methodsynopsis" ); 124 | // Make sure we find a node: 125 | if( $result->item( 0 ) ) 126 | { 127 | $item = $result->item( 0 ); 128 | if( $this->settings->debug == 1 ) 129 | { 130 | echo "\tparsing: " . $file->getFileName() . "\n"; 131 | } 132 | 133 | /* 134 | * Get the first para in the documentation, this might come 135 | * out wrong for some of the functions, but: it's the closest 136 | * we can come to something useful. 137 | */ 138 | $result = @$xpath->query( "//para" ); 139 | if( $result->item( 0 ) ) 140 | { 141 | $para = simplexml_import_dom( $result->item( 0 ) ); 142 | $desc = $para->asXml(); 143 | // defenently don't need tags for the terminal :) 144 | $desc = htmlentities( strip_tags( $desc ) ); 145 | // We don't need all the space/newlines around either 146 | $desc = preg_replace( "/[\r\n][\s]+/", " ", $desc ); 147 | 148 | // Some of the functions are undocumented: 149 | if( strstr( $desc, "warn.undocumented.func;" ) ) 150 | { 151 | $desc = "Undocumented"; 152 | } 153 | $item->appendChild( 154 | $dom->createElement( 155 | "desc", 156 | $desc 157 | ) 158 | ); 159 | } 160 | $xml = simplexml_import_dom( $item ); 161 | // Set the "function" attribute - this is what we will look for later. 162 | $xml['function'] = (string)$xml->methodname; 163 | $result = @$xpath->query( "//para" ); 164 | $this->buffer .= "\n" . $xml->asXml(); 165 | } 166 | } 167 | 168 | } 169 | // }}} 170 | 171 | // }}} 172 | ?> 173 | -------------------------------------------------------------------------------- /vimfiles/ftplugin/php.vim: -------------------------------------------------------------------------------- 1 | " .vim/ftplugin/php.vim by Tobias Schlitt . 2 | " No copyright, feel free to use this, as you like. 3 | 4 | " Including PDV 5 | source /usr/share/vim/vimfiles/plugin/php-doc.vim 6 | 7 | let PHP_autoformatcomment = 1 8 | 9 | " {{{ Settings 10 | 11 | " Auto expand tabs to spaces 12 | setlocal expandtab 13 | 14 | " Auto indent after a { 15 | setlocal autoindent 16 | setlocal smartindent 17 | 18 | " Linewidth to 79, because of the formatoptions this is only valid for 19 | " comments 20 | setlocal textwidth=79 21 | setlocal formatoptions=qrocb 22 | 23 | " Do not wrap lines automatically 24 | " setlocal nowrap 25 | 26 | " Correct indentation after opening a phpdocblock and automatic * on every 27 | " line 28 | setlocal formatoptions=qroct 29 | 30 | " Use php syntax check when doing :make 31 | setlocal makeprg=php\ -l\ % 32 | 33 | " Use errorformat for parsing PHP error output 34 | setlocal errorformat=%m\ in\ %f\ on\ line\ %l 35 | 36 | " Switch syntax highlighting on, if it was not 37 | syntax on 38 | 39 | " Use pman for manual pages 40 | setlocal keywordprg=pman 41 | 42 | " }}} Settings 43 | 44 | " {{{ Command mappings 45 | 46 | " Map ; to run PHP parser check 47 | " noremap ; :!php5 -l % 48 | 49 | " Map ; to "add ; to the end of the line, when missing" 50 | noremap ; :s/\([^;]\)$/\1;/ 51 | 52 | " DEPRECATED in favor of PDV documentation (see below!) 53 | " Map -P to run actual file with PHP CLI 54 | " noremap :w!:!php5 % 55 | 56 | " Map +p to single line mode documentation (in insert and command mode) 57 | inoremap :call PhpDocSingle()i 58 | nnoremap :call PhpDocSingle() 59 | " Map +p to multi line mode documentation (in visual mode) 60 | vnoremap :call PhpDocRange() 61 | 62 | " Map -H to search phpm for the function name currently under the cursor (insert mode only) 63 | inoremap :!/usr/share/vim/vimfiles/phpm/phpm =expand("") 64 | 65 | " Map -a to alignment function 66 | vnoremap :call PhpAlign() 67 | 68 | " Map -a to (un-)comment function 69 | vnoremap :call PhpUnComment() 70 | 71 | " }}} 72 | 73 | " {{{ Automatic close char mapping 74 | 75 | " More common in PEAR coding standard 76 | " inoremap { {}O 77 | " Maybe this way in other coding standards 78 | inoremap { {}O 79 | 80 | inoremap [ [] 81 | 82 | " Standard mapping after PEAR coding standard 83 | inoremap ( () 84 | " inoremap ( () 85 | 86 | " Maybe this way in other coding standards 87 | " inoremap ( ( ) 88 | 89 | inoremap " "" 90 | inoremap ' '' 91 | 92 | " }}} Automatic close char mapping 93 | 94 | " {{{ Wrap visual selections with chars 95 | 96 | :vnoremap ( "zdi(z) 97 | :vnoremap { "zdi{z} 98 | :vnoremap [ "zdi[z] 99 | :vnoremap ' "zdi'z' 100 | " Removed in favor of register addressing 101 | " :vnoremap " "zdi"z" 102 | 103 | " }}} Wrap visual selections with chars 104 | 105 | " {{{ Dictionary completion 106 | 107 | " The completion dictionary is provided by Rasmus: 108 | " http://lerdorf.com/funclist.txt 109 | setlocal dictionary-=/usr/share/vim/vimfiles/funclist.txt dictionary+=/usr/share/vim/vimfiles/funclist.txt 110 | " Use the dictionary completion 111 | setlocal complete-=k complete+=k 112 | 113 | " }}} Dictionary completion 114 | 115 | " {{{ Autocompletion using the TAB key 116 | 117 | " This function determines, wether we are on the start of the line text (then tab indents) or 118 | " if we want to try autocompletion 119 | func! InsertTabWrapper() 120 | let col = col('.') - 1 121 | if !col || getline('.')[col - 1] !~ '\k' 122 | return "\" 123 | else 124 | return "\" 125 | endif 126 | endfunction 127 | 128 | " Remap the tab key to select action with InsertTabWrapper 129 | inoremap =InsertTabWrapper() 130 | 131 | " }}} Autocompletion using the TAB key 132 | 133 | " {{{ Alignment 134 | 135 | func! PhpAlign() range 136 | let l:paste = &g:paste 137 | let &g:paste = 0 138 | 139 | let l:line = a:firstline 140 | let l:endline = a:lastline 141 | let l:maxlength = 0 142 | while l:line <= l:endline 143 | " Skip comment lines 144 | if getline (l:line) =~ '^\s*\/\/.*$' 145 | let l:line = l:line + 1 146 | continue 147 | endif 148 | " \{-\} matches ungreed * 149 | let l:index = substitute (getline (l:line), '^\s*\(.\{-\}\)\s*\S\{0,1}=\S\{0,1\}\s.*$', '\1', "") 150 | let l:indexlength = strlen (l:index) 151 | let l:maxlength = l:indexlength > l:maxlength ? l:indexlength : l:maxlength 152 | let l:line = l:line + 1 153 | endwhile 154 | 155 | let l:line = a:firstline 156 | let l:format = "%s%-" . l:maxlength . "s %s %s" 157 | 158 | while l:line <= l:endline 159 | if getline (l:line) =~ '^\s*\/\/.*$' 160 | let l:line = l:line + 1 161 | continue 162 | endif 163 | let l:linestart = substitute (getline (l:line), '^\(\s*\).*', '\1', "") 164 | let l:linekey = substitute (getline (l:line), '^\s*\(.\{-\}\)\s*\(\S\{0,1}=\S\{0,1\}\)\s\(.*\)$', '\1', "") 165 | let l:linesep = substitute (getline (l:line), '^\s*\(.\{-\}\)\s*\(\S\{0,1}=\S\{0,1\}\)\s\(.*\)$', '\2', "") 166 | let l:linevalue = substitute (getline (l:line), '^\s*\(.\{-\}\)\s*\(\S\{0,1}=\S\{0,1\}\)\s\(.*\)$', '\3', "") 167 | 168 | let l:newline = printf (l:format, l:linestart, l:linekey, l:linesep, l:linevalue) 169 | call setline (l:line, l:newline) 170 | let l:line = l:line + 1 171 | endwhile 172 | let &g:paste = l:paste 173 | endfunc 174 | 175 | " }}} 176 | 177 | " {{{ (Un-)comment 178 | 179 | func! PhpUnComment() range 180 | let l:paste = &g:paste 181 | let &g:paste = 0 182 | 183 | let l:line = a:firstline 184 | let l:endline = a:lastline 185 | 186 | while l:line <= l:endline 187 | if getline (l:line) =~ '^\s*\/\/.*$' 188 | let l:newline = substitute (getline (l:line), '^\(\s*\)\/\/ \(.*\).*$', '\1\2', '') 189 | else 190 | let l:newline = substitute (getline (l:line), '^\(\s*\)\(.*\)$', '\1// \2', '') 191 | endif 192 | call setline (l:line, l:newline) 193 | let l:line = l:line + 1 194 | endwhile 195 | 196 | let &g:paste = l:paste 197 | endfunc 198 | 199 | " }}} 200 | -------------------------------------------------------------------------------- /vimfiles/nerdtree_plugin/fs_menu.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================ 2 | " File: fs_menu.vim 3 | " Description: plugin for the NERD Tree that provides a file system menu 4 | " Maintainer: Martin Grenfell 5 | " Last Change: 17 July, 2009 6 | " License: This program is free software. It comes without any warranty, 7 | " to the extent permitted by applicable law. You can redistribute 8 | " it and/or modify it under the terms of the Do What The Fuck You 9 | " Want To Public License, Version 2, as published by Sam Hocevar. 10 | " See http://sam.zoy.org/wtfpl/COPYING for more details. 11 | " 12 | " ============================================================================ 13 | if exists("g:loaded_nerdtree_fs_menu") 14 | finish 15 | endif 16 | let g:loaded_nerdtree_fs_menu = 1 17 | 18 | call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) 19 | call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) 20 | call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) 21 | if g:NERDTreePath.CopyingSupported() 22 | call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) 23 | endif 24 | 25 | "FUNCTION: s:echo(msg){{{1 26 | function! s:echo(msg) 27 | redraw 28 | echomsg "NERDTree: " . a:msg 29 | endfunction 30 | 31 | "FUNCTION: s:echoWarning(msg){{{1 32 | function! s:echoWarning(msg) 33 | echohl warningmsg 34 | call s:echo(a:msg) 35 | echohl normal 36 | endfunction 37 | 38 | "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 39 | "prints out the given msg and, if the user responds by pushing 'y' then the 40 | "buffer with the given bufnum is deleted 41 | " 42 | "Args: 43 | "bufnum: the buffer that may be deleted 44 | "msg: a message that will be echoed to the user asking them if they wish to 45 | " del the buffer 46 | function! s:promptToDelBuffer(bufnum, msg) 47 | echo a:msg 48 | if nr2char(getchar()) ==# 'y' 49 | exec "silent bdelete! " . a:bufnum 50 | endif 51 | endfunction 52 | 53 | "FUNCTION: NERDTreeAddNode(){{{1 54 | function! NERDTreeAddNode() 55 | let curDirNode = g:NERDTreeDirNode.GetSelected() 56 | 57 | let newNodeName = input("Add a childnode\n". 58 | \ "==========================================================\n". 59 | \ "Enter the dir/file name to be created. Dirs end with a '/'\n" . 60 | \ "", curDirNode.path.str() . g:NERDTreePath.Slash()) 61 | 62 | if newNodeName ==# '' 63 | call s:echo("Node Creation Aborted.") 64 | return 65 | endif 66 | 67 | try 68 | let newPath = g:NERDTreePath.Create(newNodeName) 69 | let parentNode = b:NERDTreeRoot.findNode(newPath.getParent()) 70 | 71 | let newTreeNode = g:NERDTreeFileNode.New(newPath) 72 | if parentNode.isOpen || !empty(parentNode.children) 73 | call parentNode.addChild(newTreeNode, 1) 74 | call NERDTreeRender() 75 | call newTreeNode.putCursorHere(1, 0) 76 | endif 77 | catch /^NERDTree/ 78 | call s:echoWarning("Node Not Created.") 79 | endtry 80 | endfunction 81 | 82 | "FUNCTION: NERDTreeMoveNode(){{{1 83 | function! NERDTreeMoveNode() 84 | let curNode = g:NERDTreeFileNode.GetSelected() 85 | let newNodePath = input("Rename the current node\n" . 86 | \ "==========================================================\n" . 87 | \ "Enter the new path for the node: \n" . 88 | \ "", curNode.path.str()) 89 | 90 | if newNodePath ==# '' 91 | call s:echo("Node Renaming Aborted.") 92 | return 93 | endif 94 | 95 | try 96 | let bufnum = bufnr(curNode.path.str()) 97 | 98 | call curNode.rename(newNodePath) 99 | call NERDTreeRender() 100 | 101 | "if the node is open in a buffer, ask the user if they want to 102 | "close that buffer 103 | if bufnum != -1 104 | let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" 105 | call s:promptToDelBuffer(bufnum, prompt) 106 | endif 107 | 108 | call curNode.putCursorHere(1, 0) 109 | 110 | redraw 111 | catch /^NERDTree/ 112 | call s:echoWarning("Node Not Renamed.") 113 | endtry 114 | endfunction 115 | 116 | " FUNCTION: NERDTreeDeleteNode() {{{1 117 | function! NERDTreeDeleteNode() 118 | let currentNode = g:NERDTreeFileNode.GetSelected() 119 | let confirmed = 0 120 | 121 | if currentNode.path.isDirectory 122 | let choice =input("Delete the current node\n" . 123 | \ "==========================================================\n" . 124 | \ "STOP! To delete this entire directory, type 'yes'\n" . 125 | \ "" . currentNode.path.str() . ": ") 126 | let confirmed = choice ==# 'yes' 127 | else 128 | echo "Delete the current node\n" . 129 | \ "==========================================================\n". 130 | \ "Are you sure you wish to delete the node:\n" . 131 | \ "" . currentNode.path.str() . " (yN):" 132 | let choice = nr2char(getchar()) 133 | let confirmed = choice ==# 'y' 134 | endif 135 | 136 | 137 | if confirmed 138 | try 139 | call currentNode.delete() 140 | call NERDTreeRender() 141 | 142 | "if the node is open in a buffer, ask the user if they want to 143 | "close that buffer 144 | let bufnum = bufnr(currentNode.path.str()) 145 | if buflisted(bufnum) 146 | let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" 147 | call s:promptToDelBuffer(bufnum, prompt) 148 | endif 149 | 150 | redraw 151 | catch /^NERDTree/ 152 | call s:echoWarning("Could not remove node") 153 | endtry 154 | else 155 | call s:echo("delete aborted") 156 | endif 157 | 158 | endfunction 159 | 160 | " FUNCTION: NERDTreeCopyNode() {{{1 161 | function! NERDTreeCopyNode() 162 | let currentNode = g:NERDTreeFileNode.GetSelected() 163 | let newNodePath = input("Copy the current node\n" . 164 | \ "==========================================================\n" . 165 | \ "Enter the new path to copy the node to: \n" . 166 | \ "", currentNode.path.str()) 167 | 168 | if newNodePath != "" 169 | "strip trailing slash 170 | let newNodePath = substitute(newNodePath, '\/$', '', '') 171 | 172 | let confirmed = 1 173 | if currentNode.path.copyingWillOverwrite(newNodePath) 174 | call s:echo("Warning: copying may overwrite files! Continue? (yN)") 175 | let choice = nr2char(getchar()) 176 | let confirmed = choice ==# 'y' 177 | endif 178 | 179 | if confirmed 180 | try 181 | let newNode = currentNode.copy(newNodePath) 182 | call NERDTreeRender() 183 | call newNode.putCursorHere(0, 0) 184 | catch /^NERDTree/ 185 | call s:echoWarning("Could not copy node") 186 | endtry 187 | endif 188 | else 189 | call s:echo("Copy aborted.") 190 | endif 191 | redraw 192 | endfunction 193 | 194 | " vim: set sw=4 sts=4 et fdm=marker: 195 | -------------------------------------------------------------------------------- /vimfiles/plugin/Tabular.vim: -------------------------------------------------------------------------------- 1 | " Tabular: Align columnar data using regex-designated column boundaries 2 | " Maintainer: Matthew Wozniski (mjw@drexel.edu) 3 | " Date: Thu, 11 Oct 2007 00:35:34 -0400 4 | " Version: 0.1 5 | 6 | " Abort if running in vi-compatible mode or the user doesn't want us. 7 | if &cp || exists('g:tabular_loaded') 8 | if &cp && &verbose 9 | echo "Not loading Tabular in compatible mode." 10 | endif 11 | finish 12 | endif 13 | 14 | let g:tabular_loaded = 1 15 | 16 | " Stupid vimscript crap {{{1 17 | let s:savecpo = &cpo 18 | set cpo&vim 19 | 20 | " Private Things {{{1 21 | 22 | " Dictionary of command name to command 23 | let s:TabularCommands = {} 24 | 25 | " Generate tab completion list for :Tabularize {{{2 26 | " Return a list of commands that match the command line typed so far. 27 | " NOTE: Tries to handle commands with spaces in the name, but Vim doesn't seem 28 | " to handle that terribly well... maybe I should give up on that. 29 | function! s:CompleteTabularizeCommand(argstart, cmdline, cursorpos) 30 | let names = keys(s:TabularCommands) 31 | if exists("b:TabularCommands") 32 | let names += keys(b:TabularCommands) 33 | endif 34 | 35 | let cmdstart = substitute(a:cmdline, '^\s*\S\+\s*', '', '') 36 | 37 | return filter(names, 'v:val =~# ''^\V'' . escape(cmdstart, ''\'')') 38 | endfunction 39 | 40 | " Choose the proper command map from the given command line {{{2 41 | " Returns [ command map, command line with leading removed ] 42 | function! s:ChooseCommandMap(commandline) 43 | let map = s:TabularCommands 44 | let cmd = a:commandline 45 | 46 | if cmd =~# '^\s\+' 47 | if !exists('b:TabularCommands') 48 | let b:TabularCommands = {} 49 | endif 50 | let map = b:TabularCommands 51 | let cmd = substitute(cmd, '^\s\+', '', '') 52 | endif 53 | 54 | return [ map, cmd ] 55 | endfunction 56 | 57 | " Parse '/pattern/format' into separate pattern and format parts. {{{2 58 | " If parsing fails, return [ '', '' ] 59 | function! s:ParsePattern(string) 60 | if a:string[0] != '/' 61 | return ['',''] 62 | endif 63 | 64 | let pat = '\\\@ 0)] =~ '^\s*$' 106 | throw "Empty element" 107 | endif 108 | 109 | if end == -1 110 | let rv = [ a:string ] 111 | else 112 | let rv = [ a:string[0 : end-1] ] + s:SplitCommands(a:string[end+1 : -1]) 113 | endif 114 | 115 | return rv 116 | endfunction 117 | 118 | " Public Things {{{1 119 | 120 | " Command associating a command name with a simple pattern command {{{2 121 | " AddTabularPattern[!] [] name /pattern[/format] 122 | " 123 | " If is provided, the command will only be available in the current 124 | " buffer, and will be used instead of any global command with the same name. 125 | " 126 | " If a command with the same name and scope already exists, it is an error, 127 | " unless the ! is provided, in which case the existing command will be 128 | " replaced. 129 | " 130 | " pattern is a regex describing the delimiter to be used. 131 | " 132 | " format describes the format pattern to be used. The default will be used if 133 | " none is provided. 134 | com! -nargs=+ -bang AddTabularPattern 135 | \ call AddTabularPattern(, 0) 136 | 137 | function! AddTabularPattern(command, force) 138 | try 139 | let [ commandmap, rest ] = s:ChooseCommandMap(a:command) 140 | 141 | let name = matchstr(rest, '.\{-}\ze\s*/') 142 | let pattern = substitute(rest, '.\{-}\s*\ze/', '', '') 143 | 144 | let [ pattern, format ] = s:ParsePattern(pattern) 145 | 146 | if empty(name) || empty(pattern) 147 | throw "Invalid arguments!" 148 | endif 149 | 150 | if !a:force && has_key(commandmap, name) 151 | throw string(name) . " is already defined, use ! to overwrite." 152 | endif 153 | 154 | let command = "tabular#TabularizeStrings(a:lines, " . string(pattern) 155 | 156 | if !empty(format) 157 | let command .= ", " . string(format) 158 | endif 159 | 160 | let command .= ")" 161 | 162 | let commandmap[name] = ":call tabular#PipeRange(" 163 | \ . string(pattern) . "," 164 | \ . string(command) . ")" 165 | catch 166 | echohl ErrorMsg 167 | echomsg "AddTabularPattern: " . v:exception 168 | echohl None 169 | endtry 170 | endfunction 171 | 172 | " Command associating a command name with a pipeline of functions {{{2 173 | " AddTabularPipeline[!] [] name /pattern/ func [ | func2 [ | func3 ] ] 174 | " 175 | " If is provided, the command will only be available in the current 176 | " buffer, and will be used instead of any global command with the same name. 177 | " 178 | " If a command with the same name and scope already exists, it is an error, 179 | " unless the ! is provided, in which case the existing command will be 180 | " replaced. 181 | " 182 | " pattern is a regex that will be used to determine which lines will be 183 | " filtered. If the cursor line doesn't match the pattern, using the command 184 | " will be a no-op, otherwise the cursor and all contiguous lines matching the 185 | " pattern will be filtered. 186 | " 187 | " Each 'func' argument represents a function to be called. This function 188 | " will have access to a:lines, a List containing one String per line being 189 | " filtered. 190 | com! -nargs=+ -bang AddTabularPipeline 191 | \ call AddTabularPipeline(, 0) 192 | 193 | function! AddTabularPipeline(command, force) 194 | try 195 | let [ commandmap, rest ] = s:ChooseCommandMap(a:command) 196 | 197 | let name = matchstr(rest, '.\{-}\ze\s*/') 198 | let pattern = substitute(rest, '.\{-}\s*\ze/', '', '') 199 | 200 | let commands = matchstr(pattern, '^/.\{-}\\\@CompleteTabularizeCommand 239 | \ Tabularize ,call Tabularize() 240 | 241 | function! Tabularize(command) range 242 | if empty(a:command) 243 | if !exists("s:last_tabularize_command") 244 | echohl ErrorMsg 245 | echomsg "Tabularize hasn't been called yet; no pattern/command to reuse!" 246 | echohl None 247 | return 248 | endif 249 | else 250 | let s:last_tabularize_command = a:command 251 | endif 252 | 253 | let command = s:last_tabularize_command 254 | 255 | let range = a:firstline . ',' . a:lastline 256 | 257 | try 258 | let [ pattern, format ] = s:ParsePattern(command) 259 | 260 | if !empty(pattern) 261 | let cmd = "tabular#TabularizeStrings(a:lines, " . string(pattern) 262 | 263 | if !empty(format) 264 | let cmd .= "," . string(format) 265 | endif 266 | 267 | let cmd .= ")" 268 | 269 | exe range . 'call tabular#PipeRange(pattern, cmd)' 270 | else 271 | if exists('b:TabularCommands') && has_key(b:TabularCommands, command) 272 | let command = b:TabularCommands[command] 273 | elseif has_key(s:TabularCommands, command) 274 | let command = s:TabularCommands[command] 275 | else 276 | throw "Unrecognized command " . string(command) 277 | endif 278 | 279 | exe range . command 280 | endif 281 | catch 282 | echohl ErrorMsg 283 | echomsg "Tabularize: " . v:exception 284 | echohl None 285 | return 286 | endtry 287 | endfunction 288 | 289 | " Stupid vimscript crap, part 2 {{{1 290 | let &cpo = s:savecpo 291 | unlet s:savecpo 292 | 293 | " vim:set sw=2 sts=2 fdm=marker: 294 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 在fedora上用vim打造一个php集成开发环境(ide) 2 | 1 安装vim 3 | yum install vim-X11.x86_64 vim-common.x86_64 vim-enhanced.x86_64 4 | vim-minimal.x86_64 5 | 6 | 2 创建配置文件 7 | touch ~/.vimrc 8 | 9 | 3 我的配置文件 10 | " .vimrc 11 | " See: http://vimdoc.sourceforge.net/htmldoc/options.html for details 12 | 13 | "设定 gvim 运行在增强模式下,不使用vi的键盘模式 14 | set nocompatible 15 | "设置支持多语言,解决乱码 16 | set encoding=utf-8 17 | set fileencodings=utf-8,gbk,default,latin1 18 | "设置字体,配色方案 19 | if has("gui_running") 20 | set guifont=Courier\ New\ 14 21 | " on windows,use "set guifont=Courier:14 " 22 | "设置配色方案 23 | " colorscheme oceandeep 24 | endif 25 | 26 | "基本编辑器设置 27 | set number "显示行号 28 | set expandtab "编辑时将所有 Tab 替换为空格 29 | set shiftwidth=2 "自动缩进的时候,缩进尺寸为2个空格 30 | set tabstop=2 "设置 softtabstop 为 2. 输入 tab 后就跳了2格 31 | "对于不同类型的文件,进行自定义设置 32 | au FileType html,python,vim,javascript,css setl shiftwidth=2 33 | au FileType html,python,vim,javascript,css setl tabstop=2 34 | au FileType java,php setl shiftwidth=4 35 | au FileType java,php setl tabstop=4 36 | 37 | set textwidth=80 "设置每行的最大字符数,超过的话,将换行 38 | set hlsearch "搜索时高亮显示 39 | set incsearch "输入搜索内容时就显示搜索结果 40 | set fileformat=unix "文本格式 41 | set nobackup "覆盖文件时不备份 42 | 43 | set ruler "打开状态栏标尺 44 | set laststatus=2 "显示状态栏 (默认值为 1, 无法显示状态栏) 45 | set cmdheight=1 "设定命令行的行数为 1 46 | 47 | set showtabline=2 "显示tab标签 48 | set tabline+=%f "tab标签 49 | " Enable Code Folding 50 | set foldenable 51 | set foldmethod=syntax 52 | set mouse=a "任何情况都可以使用鼠标) 53 | 54 | "去掉错误声音 55 | set vb t_vb= 56 | "工作目录随文件变 57 | autocmd BufEnter * cd %:p:h 58 | "设置状态栏 59 | set statusline=%F%m%r,%Y,%{&fileformat}\ \ \ ASCII=\%b,HEX=\%B\ \ \ %l,%c%V\ 60 | %p%%\ \ \ [\ %L\ lines\ in\ all\ ] 61 | "不显示工具条 62 | set guioptions-=T 63 | set backspace=indent,eol,start "不设定的话在插入状态无法用退格键和 Delete 64 | filetype on "设置文件类型的检测 65 | filetype plugin on "为特定的文件类型允许插件文件的载入 66 | 67 | "按住ctrl键,移动方向键时,以峰驼的方式 68 | nnoremap :cal 69 | search('\<\\U\@<=\u\\u\ze\%(\U\&\>\@!\)\\%^','bW') 70 | nnoremap :cal 71 | search('\<\\U\@<=\u\\u\ze\%(\U\&\>\@!\)\\%$','W') 72 | inoremap :cal 73 | search('\<\\U\@<=\u\\u\ze\%(\U\&\>\@!\)\\%^','bW') 74 | inoremap :cal 75 | search('\<\\U\@<=\u\\u\ze\%(\U\&\>\@!\)\\%$','W') 76 | 77 | "php语法检查 78 | setlocal makeprg=\/usr/bin/php\ -l\ -n\ -d\ html_errors=off\ % 79 | setlocal errorformat=%m\ in\ %f\ on\ line\ %l 80 | "autocmd BufWritePost *.php,*.phps :make 81 | map :w:noh:make 82 | 83 | "Disable phpsyntax based indenting for .php files 84 | au BufRead,BufNewFile *.php set indentexpr= | set smartindent 85 | au BufRead,BufNewFile *.phps set filetype=php 86 | 87 | 5 插件配置 88 | 89 | 1)集成NERDTree实现目录导航 90 | wget https://github.com/scrooloose/nerdtree/tarball/master 91 | tar zxvf scrooloose-nerdtree-4.1.0-35-g1cd5048.tar.gz 92 | cp doc/NERD_tree.txt /usr/share/vim/vimfiles/doc/ 93 | cp plugin/NERD_tree.vim /usr/share/vim/vimfiles/plugin/ 94 | cp -fr nerdtree_plugin/ /usr/share/vim/vimfiles/ 95 | 最后在 .vimrc 添加如下内容: 96 | 97 | "NERDTree 98 | map :NERDTreeToggle 99 | let NERDTreeIgnore=['\.svn$','\.bak$'] 100 | 101 | 通过F10即可调出目录导航,通过键盘ctrl+w+w可以在导航和编辑中的文件之前切换焦点。“u”可到上一级目录,回车则展开文件夹 102 | 103 | 2)集成task list url:http://www.vim.org/scripts/script.php?script_id=2607 104 | cp tasklist.vim /usr/share/vim/vimfiles/plugin/ 105 | 通过":TaskList"可以列出代码中的TODO和FIXME列表,将鼠标移动到相应的项目上时,会关闭列表窗口,并跳转到代码指定的位置 106 | 107 | 3)集成tag list url:http://www.vim.org/scripts/script.php?script_id=273 108 | taglist 可以列出已打开文件中定义的类、函数、常量,甚至变量。 109 | cp plugin/taglist.vim /usr/share/vim/vimfiles/plugin/ 110 | cp doc/taglist.txt /usr/share/vim/vimfiles/doc/ 111 | 最后在 .vimrc 添加如下内容: 112 | 113 | "taglist 114 | set tags=tags;/ 115 | let Tlist_Ctags_Cmd="/usr/bin/ctags" 116 | map :TlistToggle 117 | let Tlist_Auto_Highlight_Tag = 1 118 | let Tlist_Auto_Open = 0 119 | let Tlist_Auto_Update = 1 120 | let Tlist_Close_On_Select = 0 121 | let Tlist_Compact_Format = 0 122 | let Tlist_Display_Prototype = 0 123 | let Tlist_Display_Tag_Scope = 1 124 | let Tlist_Enable_Fold_Column = 0 125 | let Tlist_Exit_OnlyWindow = 0 126 | let Tlist_File_Fold_Auto_Close = 0 127 | let Tlist_GainFocus_On_ToggleOpen = 1 128 | let Tlist_Hightlight_Tag_On_BufEnter = 1 129 | let Tlist_Inc_Winwidth = 0 130 | let Tlist_Max_Submenu_Items = 1 131 | let Tlist_Max_Tag_Length = 30 132 | let Tlist_Process_File_Always = 0 133 | let Tlist_Show_Menu = 0 134 | let Tlist_Show_One_File = 0 135 | let Tlist_Sort_Type = "order" 136 | let Tlist_Use_Horiz_Window = 0 137 | let Tlist_Use_Right_Window = 0 138 | let Tlist_WinWidth = 40 139 | let tlist_php_settings = 'php;c:class;i:interfaces;d:constant;f:function' 140 | 141 | map :tab split:exec("tag ".expand("")) 142 | map :vsp :exec("tag ".expand("")) 143 | 144 | 需要安装ctags,本文采用yum安装,如需编译安装,请参见其他资料。 145 | 通过ctags -R生成tags后,可以使用如下快捷键: 146 | ctrl+] - 跳转到定义处 147 | ctrl+t - 从定义处跳转回来 148 | ctrl+w ctrl+] - 水平分割窗口,并在上部打开定义所在文件,跳转到定义处 149 | ctrl+\ - 打开新标签页。并跳转到定义处 150 | alt+] - 垂直分割窗口,并在右部打开定义所在文件,跳转到定义处 151 | 152 | ctrl+鼠标左键 - 跳转到定义处 153 | ctrl+鼠标右键 - 从定义处跳转回来 154 | 155 | 4)集成php-doc url http://www.vim.org/scripts/script.php?script_id=1355 156 | cp php-doc.vim /usr/share/vim/vimfiles/plugin/ 157 | 158 | 最后在 .vimrc 添加如下内容: 159 | "在通常模式(n)和插入模式(i),按ctrl+p插入注释 160 | inoremap ^[:call PhpDocSingle()i 161 | nnoremap :call PhpDocSingle() 162 | "选择多行,在可视模式(v)下,对选中的多行插入注释 163 | vnoremap :call PhpDocRange() 164 | 165 | 5)集成PHPM url http://eide.org/2009/01/02/phpm/ 166 | cp -fr phpm /usr/share/vim/vimfiles 167 | 最后在 .vimrc 添加如下内容: 168 | 169 | " Map -H to search phpm for the function name currently under the cursor 170 | (insert mode only) 171 | inoremap :!/usr/share/vim/vimfiles/phpm/phpm 172 | =expand("") 173 | 在插入模式下,按ctrl+h,即可调出光标在函数的说明,参数,返回值 174 | 175 | 6)集成funclist,实现自动完成 url 176 | http://svn.php.net/viewvc/phpdoc/doc-base/trunk/funclist.txt 177 | cp funclist.txt /usr/share/vim/vimfiles 178 | 最后在 .vimrc 添加如下内容: 179 | 180 | setlocal dictionary-=/usr/share/vim/vimfiles/funclist.txt 181 | dictionary+=/usr/share/vim/vimfiles/funclist.txt 182 | " Use the dictionary completion 183 | setlocal complete-=k complete+=k 184 | 185 | func! InsertTabWrapper() 186 | let col = col('.') - 1 187 | if !col || getline('.')[col - 1] !~ '\k' 188 | return "\" 189 | else 190 | return "\" 191 | endif 192 | endfunction 193 | 194 | " Remap the tab key to select action with InsertTabWrapper 195 | inoremap =InsertTabWrapper() 196 | 在插入模式下,按tab,即可调出函数列表 197 | 198 | 7)在任意模式下,按";"在行尾输入添加";",如果没有";"的话 199 | noremap ; :s/\([^;]\)$/\1;/ 200 | 201 | 8)配置 PhpAlign,手动格式代码的对齐 202 | 在 .vimrc 添加如下内容: 203 | 204 | " Map -a to alignment function 205 | vnoremap :call PhpAlign() 206 | 207 | func! PhpAlign() range 208 | let l:paste = &g:paste 209 | let &g:paste = 0 210 | 211 | let l:line = a:firstline 212 | let l:endline = a:lastline 213 | let l:maxlength = 0 214 | while l:line <= l:endline 215 | " Skip comment lines 216 | if getline (l:line) =~ '^\s*\/\/.*$' 217 | let l:line = l:line + 1 218 | continue 219 | endif 220 | " \{-\} matches ungreed * 221 | let l:index = substitute (getline (l:line), 222 | '^\s*\(.\{-\}\)\s*\S\{0,1}=\S\{0,1\}\s.*$', '\1', "") 223 | let l:indexlength = strlen (l:index) 224 | let l:maxlength = l:indexlength > l:maxlength ? l:indexlength : 225 | l:maxlength 226 | let l:line = l:line + 1 227 | endwhile 228 | 229 | let l:line = a:firstline 230 | let l:format = "%s%-" . l:maxlength . "s %s %s" 231 | 232 | while l:line <= l:endline 233 | if getline (l:line) =~ '^\s*\/\/.*$' 234 | let l:line = l:line + 1 235 | continue 236 | endif 237 | let l:linestart = substitute (getline (l:line), '^\(\s*\).*', '\1', "") 238 | let l:linekey = substitute (getline (l:line), 239 | '^\s*\(.\{-\}\)\s*\(\S\{0,1}=\S\{0,1\}\)\s\(.*\)$', '\1', "") 240 | let l:linesep = substitute (getline (l:line), 241 | '^\s*\(.\{-\}\)\s*\(\S\{0,1}=\S\{0,1\}\)\s\(.*\)$', '\2', "") 242 | let l:linevalue = substitute (getline (l:line), 243 | '^\s*\(.\{-\}\)\s*\(\S\{0,1}=\S\{0,1\}\)\s\(.*\)$', '\3', "") 244 | 245 | let l:newline = printf (l:format, l:linestart, l:linekey, l:linesep, 246 | l:linevalue) 247 | call setline (l:line, l:newline) 248 | let l:line = l:line + 1 249 | endwhile 250 | let &g:paste = l:paste 251 | endfunc 252 | 在可视模式下,选中代码,按ctrl+a,即可格式代码的对齐 253 | 254 | 9)配置 PhpUnComment,批量注释代码 255 | 在 .vimrc 添加如下内容: 256 | 257 | vnoremap :call PhpUnComment() 258 | 259 | func! PhpUnComment() range 260 | let l:paste = &g:paste 261 | let &g:paste = 0 262 | 263 | let l:line = a:firstline 264 | let l:endline = a:lastline 265 | 266 | while l:line <= l:endline 267 | if getline (l:line) =~ '^\s*\/\/.*$' 268 | let l:newline = substitute (getline (l:line), 269 | '^\(\s*\)\/\/ \(.*\).*$', '\1\2', '') 270 | else 271 | let l:newline = substitute (getline (l:line), 272 | '^\(\s*\)\(.*\)$', '\1// \2', '') 273 | endif 274 | call setline (l:line, l:newline) 275 | let l:line = l:line + 1 276 | endwhile 277 | 278 | let &g:paste = l:paste 279 | endfunc 280 | 在可视模式下,选中代码,按ctrl+c,即批量注释代码,再按就取消注释 281 | 282 | 10)设置自动补齐 283 | 在 .vimrc 添加如下内容: 284 | 285 | inoremap { {}O 286 | 287 | inoremap [ [] 288 | 289 | " Standard mapping after PEAR coding standard 290 | inoremap ( () 291 | " inoremap ( () 292 | 293 | " Maybe this way in other coding standards 294 | " inoremap ( ( ) 295 | 296 | inoremap " "" 297 | inoremap ' '' 298 | 11)在文件夹中查找 299 | :vimgrep /pattern/gj ./**/*.php 300 | 这哥命令告诉vim,在当前目前下的所有.php文件中全局查找符合pattern的结果。 301 | 运行 302 | :cw 303 | 会列出查找结果。 304 | 305 | 11)转换大小写 306 | ~ 转换当前光标所在字符的大小写 307 | u 将选中的字符全转成小写 308 | U 将选中的字符全转成大写 309 | UV 将当前行转成大写 310 | guw 将当前的单词转成小写 311 | 312 | 12)排序 313 | vim在linux上,可以通过在命令模式下输入相关命令,进行文本的排序 314 | %!sort -u 排序时,删除重复的行 315 | %!sort -f 排序时,忽略大小写 316 | %!sort -r 进行逆向排序 317 | 排序时,都是以行为单位。按照字典顺序,如:a-z, 0-100的顺序进行排序 318 | sort /pattern/ 可以在排序时,过滤掉正则匹配到的字符。 319 | sort /^./ 将不是按照第一个字符排序,而是过滤掉第一个字符,从第二个开始。正则表达式/^./匹配开头的第一个字符。 320 | 321 | 322 | 参考链接 323 | http://eide.org/category/php/ 324 | http://taggedzi.com/articles/display/vim-for-php-developers-part-3 325 | http://www.foolbirds.com/c/vi 326 | https://github.com/tobyS/vip 327 | http://lostechies.com/derickbailey/2010/05/11/vim-grep-find-all-occurrences-of-text-in-your-project/ 328 | -------------------------------------------------------------------------------- /vimfiles/autoload/tabular.vim: -------------------------------------------------------------------------------- 1 | " Tabular: Align columnar data using regex-designated column boundaries 2 | " Maintainer: Matthew Wozniski (mjw@drexel.edu) 3 | " Date: Thu, 11 Oct 2007 00:35:34 -0400 4 | " Version: 0.1 5 | 6 | " Stupid vimscript crap {{{1 7 | let s:savecpo = &cpo 8 | set cpo&vim 9 | 10 | " Private Functions {{{1 11 | 12 | " Return the number of bytes in a string after expanding tabs to spaces. {{{2 13 | " This expansion is done based on the current value of 'tabstop' 14 | function! s:Strlen(string) 15 | let rv = 0 16 | let i = 0 17 | 18 | for char in split(a:string, '\zs') 19 | if char == "\t" 20 | let rv += &ts - i 21 | let i = 0 22 | else 23 | let rv += 1 24 | let i = (i + 1) % &ts 25 | endif 26 | endfor 27 | 28 | return rv 29 | endfunction 30 | 31 | " Align a string within a field {{{2 32 | " These functions do not trim leading and trailing spaces. 33 | 34 | " Right align 'string' in a field of size 'fieldwidth' 35 | function! s:Right(string, fieldwidth) 36 | let spaces = a:fieldwidth - s:Strlen(a:string) 37 | return matchstr(a:string, '^\s*') . repeat(" ", spaces) . substitute(a:string, '^\s*', '', '') 38 | endfunction 39 | 40 | " Left align 'string' in a field of size 'fieldwidth' 41 | function! s:Left(string, fieldwidth) 42 | let spaces = a:fieldwidth - s:Strlen(a:string) 43 | return a:string . repeat(" ", spaces) 44 | endfunction 45 | 46 | " Center align 'string' in a field of size 'fieldwidth' 47 | function! s:Center(string, fieldwidth) 48 | let spaces = a:fieldwidth - s:Strlen(a:string) 49 | let right = spaces / 2 50 | let left = right + (right * 2 != spaces) 51 | return repeat(" ", left) . a:string . repeat(" ", right) 52 | endfunction 53 | 54 | " Remove spaces around a string {{{2 55 | 56 | " Remove all trailing spaces from a string. 57 | function! s:StripTrailingSpaces(string) 58 | return matchstr(a:string, '^.\{-}\ze\s*$') 59 | endfunction 60 | 61 | " Remove all leading spaces from a string. 62 | function! s:StripLeadingSpaces(string) 63 | return matchstr(a:string, '^\s*\zs.*$') 64 | endfunction 65 | 66 | " Split a string into fields and delimiters {{{2 67 | " Like split(), but include the delimiters as elements 68 | " All odd numbered elements are delimiters 69 | " All even numbered elements are non-delimiters (including zero) 70 | function! s:SplitDelim(string, delim) 71 | let rv = [] 72 | let beg = 0 73 | 74 | let len = len(a:string) 75 | let searchoff = 0 76 | 77 | while 1 78 | let mid = match(a:string, a:delim, beg + searchoff, 1) 79 | if mid == -1 || mid == len 80 | break 81 | endif 82 | 83 | let matchstr = matchstr(a:string, a:delim, beg + searchoff, 1) 84 | let length = strlen(matchstr) 85 | 86 | if length == 0 && beg == mid 87 | " Zero-length match for a zero-length delimiter - advance past it 88 | let searchoff += 1 89 | continue 90 | endif 91 | 92 | if beg == mid 93 | let rv += [ "" ] 94 | else 95 | let rv += [ a:string[beg : mid-1] ] 96 | endif 97 | 98 | let rv += [ matchstr ] 99 | 100 | let beg = mid + length 101 | let searchoff = 0 102 | endwhile 103 | 104 | let rv += [ strpart(a:string, beg) ] 105 | 106 | return rv 107 | endfunction 108 | 109 | " Replace lines from `start' to `start + len - 1' with the given strings. {{{2 110 | " If more lines are needed to show all strings, they will be added. 111 | " If there are too few strings to fill all lines, lines will be removed. 112 | function! s:SetLines(start, len, strings) 113 | if a:start > line('$') + 1 || a:start < 1 114 | throw "Invalid start line!" 115 | endif 116 | 117 | if len(a:strings) > a:len 118 | let fensave = &fen 119 | let view = winsaveview() 120 | call append(a:start + a:len - 1, repeat([''], len(a:strings) - a:len)) 121 | call winrestview(view) 122 | let &fen = fensave 123 | elseif len(a:strings) < a:len 124 | let fensave = &fen 125 | let view = winsaveview() 126 | sil exe (a:start + len(a:strings)) . ',' . (a:start + a:len - 1) . 'd_' 127 | call winrestview(view) 128 | let &fen = fensave 129 | endif 130 | 131 | call setline(a:start, a:strings) 132 | endfunction 133 | 134 | " Runs the given commandstring argument as an expression. {{{2 135 | " The commandstring expression is expected to reference the a:lines argument. 136 | " If the commandstring expression returns a list the items of that list will 137 | " replace the items in a:lines, otherwise the expression is assumed to have 138 | " modified a:lines itself. 139 | function! s:FilterString(lines, commandstring) 140 | exe 'let rv = ' . a:commandstring 141 | 142 | if type(rv) == type(a:lines) && rv isnot a:lines 143 | call filter(a:lines, 0) 144 | call extend(a:lines, rv) 145 | endif 146 | endfunction 147 | 148 | " Public API {{{1 149 | 150 | if !exists("g:tabular_default_format") 151 | let g:tabular_default_format = "l1" 152 | endif 153 | 154 | let s:formatelempat = '\%([lrc]\d\+\)' 155 | 156 | function! tabular#ElementFormatPattern() 157 | return s:formatelempat 158 | endfunction 159 | 160 | " Given a list of strings and a delimiter, split each string on every 161 | " occurrence of the delimiter pattern, format each element according to either 162 | " the provided format (optional) or the default format, and join them back 163 | " together with enough space padding to guarantee that the nth delimiter of 164 | " each string is aligned. 165 | function! tabular#TabularizeStrings(strings, delim, ...) 166 | if a:0 > 1 167 | echoerr "TabularizeStrings accepts only 2 or 3 arguments (got ".(a:0+2).")" 168 | return 1 169 | endif 170 | 171 | let formatstr = (a:0 ? a:1 : g:tabular_default_format) 172 | 173 | if formatstr !~? s:formatelempat . '\+' 174 | echoerr "Tabular: Invalid format \"" . formatstr . "\" specified!" 175 | return 1 176 | endif 177 | 178 | let format = split(formatstr, s:formatelempat . '\zs') 179 | 180 | let lines = map(a:strings, 's:SplitDelim(v:val, a:delim)') 181 | 182 | " Strip spaces 183 | " - Only from non-delimiters; spaces in delimiters must have been matched 184 | " intentionally 185 | " - Don't strip leading spaces from the first element; we like indenting. 186 | for line in lines 187 | if line[0] !~ '^\s*$' 188 | let line[0] = s:StripTrailingSpaces(line[0]) 189 | endif 190 | if len(line) >= 3 191 | for i in range(2, len(line)-1, 2) 192 | let line[i] = s:StripLeadingSpaces(s:StripTrailingSpaces(line[i])) 193 | endfor 194 | endif 195 | endfor 196 | 197 | " Find the max length of each field 198 | let maxes = [] 199 | for line in lines 200 | for i in range(len(line)) 201 | if i == len(maxes) 202 | let maxes += [ s:Strlen(line[i]) ] 203 | else 204 | let maxes[i] = max( [ maxes[i], s:Strlen(line[i]) ] ) 205 | endif 206 | endfor 207 | endfor 208 | 209 | let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"')) 210 | 211 | " Concatenate the fields, according to the format pattern. 212 | for idx in range(len(lines)) 213 | let line = lines[idx] 214 | for i in range(len(line)) 215 | let how = format[i % len(format)][0] 216 | let pad = format[i % len(format)][1:-1] 217 | 218 | if how =~? 'l' 219 | let field = s:Left(line[i], maxes[i]) 220 | elseif how =~? 'r' 221 | let field = s:Right(line[i], maxes[i]) 222 | elseif how =~? 'c' 223 | let field = s:Center(line[i], maxes[i]) 224 | endif 225 | 226 | let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad)) 227 | endfor 228 | 229 | let lines[idx] = s:StripTrailingSpaces(join(line, '')) 230 | endfor 231 | endfunction 232 | 233 | " Apply 0 or more filters, in sequence, to selected text in the buffer {{{2 234 | " The lines to be filtered are determined as follows: 235 | " If the function is called with a range containing multiple lines, then 236 | " those lines will be used as the range. 237 | " If the function is called with no range or with a range of 1 line, then 238 | " if "includepat" is not specified, 239 | " that 1 line will be filtered, 240 | " if "includepat" is specified and that line does not match it, 241 | " no lines will be filtered 242 | " if "includepat" is specified and that line does match it, 243 | " all contiguous lines above and below the specified line matching the 244 | " pattern will be filtered. 245 | " 246 | " The remaining arguments must each be a filter to apply to the text. 247 | " Each filter must either be a String evaluating to a function to be called. 248 | function! tabular#PipeRange(includepat, ...) range 249 | let top = a:firstline 250 | let bot = a:lastline 251 | 252 | if a:includepat != '' && top == bot 253 | if top < 0 || top > line('$') || getline(top) !~ a:includepat 254 | return 255 | endif 256 | while top > 1 && getline(top-1) =~ a:includepat 257 | let top -= 1 258 | endwhile 259 | while bot < line('$') && getline(bot+1) =~ a:includepat 260 | let bot += 1 261 | endwhile 262 | endif 263 | 264 | let lines = map(range(top, bot), 'getline(v:val)') 265 | 266 | for filter in a:000 267 | if type(filter) != type("") 268 | echoerr "PipeRange: Bad filter: " . string(filter) 269 | endif 270 | 271 | call s:FilterString(lines, filter) 272 | 273 | unlet filter 274 | endfor 275 | 276 | call s:SetLines(top, bot - top + 1, lines) 277 | endfunction 278 | 279 | function! s:SplitDelimTest(string, delim, expected) 280 | let result = s:SplitDelim(a:string, a:delim) 281 | 282 | if result !=# a:expected 283 | echomsg 'Test failed!' 284 | echomsg ' string=' . string(a:string) . ' delim=' . string(a:delim) 285 | echomsg ' Returned=' . string(result) 286 | echomsg ' Expected=' . string(a:expected) 287 | endif 288 | endfunction 289 | 290 | function! tabular#SplitDelimUnitTest() 291 | let assignment = '[|&+*/%<>=!~-]\@!=]=\|=\~\)\@![|&+*/%<>=!~-]*=' 292 | let two_spaces = ' ' 293 | let ternary_operator = '^.\{-}\zs?\|:' 294 | let cpp_io = '<<\|>>' 295 | let pascal_assign = ':=' 296 | let trailing_c_comments = '\/\*\|\*\/\|\/\/' 297 | 298 | call s:SplitDelimTest('a+=b', assignment, ['a', '+=', 'b']) 299 | call s:SplitDelimTest('a-=b', assignment, ['a', '-=', 'b']) 300 | call s:SplitDelimTest('a!=b', assignment, ['a!=b']) 301 | call s:SplitDelimTest('a==b', assignment, ['a==b']) 302 | call s:SplitDelimTest('a&=b', assignment, ['a', '&=', 'b']) 303 | call s:SplitDelimTest('a|=b', assignment, ['a', '|=', 'b']) 304 | call s:SplitDelimTest('a=b=c', assignment, ['a', '=', 'b', '=', 'c']) 305 | 306 | call s:SplitDelimTest('a b c', two_spaces, ['a', ' ', 'b', ' ', 'c']) 307 | call s:SplitDelimTest('a b c', two_spaces, ['a b', ' ', ' c']) 308 | call s:SplitDelimTest('ab c', two_spaces, ['ab', ' ', '', ' ', 'c']) 309 | 310 | call s:SplitDelimTest('a?b:c', ternary_operator, ['a', '?', 'b', ':', 'c']) 311 | 312 | call s:SplitDelimTest('a<t Display list. 36 | " 37 | " Usage: Start the script with the mapped key, a new window appears 38 | " with the matches found, moving around the window will also 39 | " update the position of the current document. 40 | " 41 | " The following keys are mapped to the results window: 42 | " 43 | " q - Quit, and restore original cursor position. 44 | " 45 | " e - Exit, and keep results window open note that 46 | " movements on the result window will no longer be 47 | " updated. 48 | " 49 | " - Quit and place the cursor on the selected line. 50 | " 51 | " Aknowledgments: Many thanks to Zhang Shuhan for taking the time to beta 52 | " test and suggest many of the improvements and features 53 | " found in the script. I don't think I would have 54 | " implemented it wihout his help. Thanks! 55 | " 56 | "------------------------------------------------------------------------------ 57 | " Please send me any bugs you find, so I can keep the script up to date. 58 | "------------------------------------------------------------------------------ 59 | 60 | " History: {{{1 61 | "------------------------------------------------------------------------------ 62 | " 63 | " 1.00 Initial version. 64 | " 65 | " User Options: {{{1 66 | "------------------------------------------------------------------------------ 67 | " 68 | " t 69 | " This is the default key map to view the task list. 70 | " to overwrite use something like: 71 | " map v TaskList 72 | " in your vimrc file 73 | " 74 | " g:tlWindowPosition 75 | " This is specifies the position of the window to be opened. By 76 | " default it will open at on top. To overwrite use: 77 | " let g:tlWindowPosition = 1 78 | " in your vimrc file, options are as follows: 79 | " 0 = Open on top 80 | " 1 = Open on the bottom 81 | " 82 | " g:tlTokenList 83 | " This is the list of tokens to search for default is 84 | " 'FIXME TODO XXX'. The results are groupped and displayed in the 85 | " order that they appear. to overwrite use: 86 | " let g:tlTokenList = ['TOKEN1', 'TOKEN2', 'TOKEN3'] 87 | " in your vimrc file 88 | " 89 | " g:tlRememberPosition 90 | " If this is set to 1 then the script will try to get back to the 91 | " position where it last was closed. By default it will find the line 92 | " closest to the current cursor position. 93 | " to overwrite use: 94 | " let g:tlRememberPosition = 1 95 | " in your vimrc file 96 | " 97 | 98 | " Global variables: {{{1 99 | "------------------------------------------------------------------------------ 100 | 101 | " Load script once 102 | "------------------------------------------------------------------------------ 103 | if exists("g:loaded_tasklist") || &cp 104 | finish 105 | endif 106 | let g:loaded_tasklist = 1 107 | 108 | " Set where the window opens 109 | "------------------------------------------------------------------------------ 110 | if !exists('g:tlWindowPosition') 111 | " 0 = Open at top 112 | let g:tlWindowPosition = 0 113 | endif 114 | 115 | " Set the token list 116 | "------------------------------------------------------------------------------ 117 | if !exists('g:tlTokenList') 118 | " default list of tokens 119 | let g:tlTokenList = ["FIXME", "TODO", "XXX"] 120 | endif 121 | 122 | " Remember position 123 | "------------------------------------------------------------------------------ 124 | if !exists('g:tlRememberPosition') 125 | " 0 = Donot remember, find closest match 126 | let g:tlRememberPosition = 0 127 | endif 128 | 129 | " Script variables: {{{1 130 | "------------------------------------------------------------------------------ 131 | 132 | " Function: Open Window {{{1 133 | "-------------------------------------------------------------------------- 134 | function! s:OpenWindow(buffnr, lineno) 135 | " Open results window and place items there. 136 | if g:tlWindowPosition == 0 137 | execute 'sp -TaskList_'.a:buffnr.'-' 138 | else 139 | execute 'botright sp -TaskList_'.a:buffnr.'-' 140 | endif 141 | 142 | let b:original_buffnr = a:buffnr 143 | let b:original_line = a:lineno 144 | 145 | set noswapfile 146 | set modifiable 147 | normal! "zPGddgg 148 | set fde=getline(v:lnum)[0]=='L' 149 | set foldmethod=expr 150 | set foldlevel=0 151 | normal! zR 152 | 153 | " Resize line if too big. 154 | let l:hits = line("$") 155 | if l:hits < winheight(0) 156 | sil! exe "resize ".l:hits 157 | endif 158 | 159 | " Clean up. 160 | let @z = "" 161 | set nomodified 162 | endfunction 163 | 164 | " Function: Search file {{{1 165 | "-------------------------------------------------------------------------- 166 | function! s:SearchFile(hits, word) 167 | " Search at the beginning and keep adding them to the register 168 | let l:match_count = 0 169 | normal! gg0 170 | let l:max = strlen(line('$')) 171 | let l:last_match = -1 172 | let l:div = 0 173 | while search(a:word, "Wc") > 0 174 | let l:curr_line = line('.') 175 | if l:last_match == l:curr_line 176 | if l:curr_line == line('$') 177 | break 178 | endif 179 | normal! j0 180 | continue 181 | endif 182 | let l:last_match = l:curr_line 183 | if foldlevel(l:curr_line) != 0 184 | normal! 99zo 185 | endif 186 | if l:div == 0 187 | if a:hits != 0 188 | let @z = @z."\n" 189 | endif 190 | let l:div = 1 191 | endif 192 | normal! 0 193 | let l:lineno = ' '.l:curr_line 194 | let @z = @z.'Ln '.strpart(l:lineno, strlen(l:lineno) - l:max).': ' 195 | let l:text = getline(".") 196 | let @z = @z.strpart(l:text, stridx(l:text, a:word)) 197 | let @z = @z."\n" 198 | normal! $ 199 | let l:match_count = l:match_count + 1 200 | endwhile 201 | return l:match_count 202 | endfunction 203 | 204 | " Function: Get line number {{{1 205 | "-------------------------------------------------------------------------- 206 | function! s:LineNumber() 207 | let l:text = getline(".") 208 | if strpart(l:text, 0, 5) == "File:" 209 | return 0 210 | endif 211 | if strlen(l:text) == 0 212 | return -1 213 | endif 214 | let l:num = matchstr(l:text, '[0-9]\+') 215 | if l:num == '' 216 | return -1 217 | endif 218 | return l:num 219 | endfunction 220 | 221 | " Function: Update document position {{{1 222 | "-------------------------------------------------------------------------- 223 | function! s:UpdateDoc() 224 | let l:line_hit = LineNumber() 225 | 226 | match none 227 | if l:line_hit == -1 228 | redraw 229 | return 230 | endif 231 | 232 | let l:buffnr = b:original_buffnr 233 | exe 'match Search /\%'.line(".").'l.*/' 234 | if line(".") < (line("$") - (winheight(0) / 2)) + 1 235 | normal! zz 236 | endif 237 | execute bufwinnr(l:buffnr)." wincmd w" 238 | match none 239 | if l:line_hit == 0 240 | normal! 1G 241 | else 242 | exe "normal! ".l:line_hit."Gzz" 243 | exe 'match Search /\%'.line(".").'l.*/' 244 | endif 245 | execute bufwinnr('-TaskList_'.l:buffnr.'-')." wincmd w" 246 | redraw 247 | endfunction 248 | 249 | " Function: Clean up on exit {{{1 250 | "-------------------------------------------------------------------------- 251 | function! s:Exit(key) 252 | 253 | call UpdateDoc() 254 | match none 255 | 256 | let l:original_line = b:original_line 257 | let l:last_position = line('.') 258 | 259 | if a:key == -1 260 | nunmap e 261 | nunmap q 262 | nunmap 263 | execute bufwinnr(b:original_buffnr)." wincmd w" 264 | else 265 | bd! 266 | endif 267 | 268 | let b:last_position = l:last_position 269 | 270 | if a:key == 0 271 | exe "normal! ".l:original_line."G" 272 | endif 273 | 274 | match none 275 | normal! zz 276 | 277 | execute "set updatetime=".s:old_updatetime 278 | endfunction 279 | 280 | " Function: Check for screen update {{{1 281 | "-------------------------------------------------------------------------- 282 | function! s:CheckForUpdate() 283 | if stridx(expand("%:t"), '-TaskList_') == -1 284 | return 285 | endif 286 | if b:selected_line != line(".") 287 | call UpdateDoc() 288 | let b:selected_line = line(".") 289 | endif 290 | endfunction 291 | 292 | " Function: Start the search. {{{1 293 | "-------------------------------------------------------------------------- 294 | function! s:TaskList() 295 | let l:original_buffnr = bufnr('%') 296 | let l:original_line = line(".") 297 | 298 | " last position 299 | if !exists('b:last_position') 300 | let b:last_position = 1 301 | endif 302 | let l:last_position = b:last_position 303 | 304 | 305 | " get file name 306 | let @z = "File:".expand("%:p")."\n\n" 307 | 308 | " search file 309 | let l:index = 0 310 | let l:count = 0 311 | let l:hits = 0 312 | while l:index < len(g:tlTokenList) 313 | let l:search_word = g:tlTokenList[l:index] 314 | let l:hits = s:SearchFile(l:hits, l:search_word) 315 | let l:count = l:count + l:hits 316 | let l:index = l:index + 1 317 | endwhile 318 | 319 | " Make sure we at least have one hit. 320 | if l:count == 0 321 | echohl Search 322 | echo "tasklist.vim: No task information found." 323 | echohl None 324 | execute 'normal! '.l:original_line.'G' 325 | return 326 | endif 327 | 328 | " display window 329 | call s:OpenWindow(l:original_buffnr, l:original_line) 330 | 331 | " restore the cursor position 332 | if g:tlRememberPosition != 0 333 | exec 'normal! '.l:last_position.'G' 334 | else 335 | normal! gg 336 | endif 337 | 338 | " Map exit keys 339 | nnoremap q :call Exit(0) 340 | nnoremap :call Exit(1) 341 | nnoremap e :call Exit(-1) 342 | 343 | " Setup syntax highlight {{{ 344 | syntax match tasklistFileDivider /^File:.*$/ 345 | syntax match tasklistLineNumber /^Ln\s\+\d\+:/ 346 | 347 | highlight def link tasklistFileDivider Title 348 | highlight def link tasklistLineNumber LineNr 349 | highlight def link tasklistSearchWord Search 350 | " }}} 351 | 352 | " Save globals and change updatetime 353 | let b:selected_line = line(".") 354 | let s:old_updatetime = &updatetime 355 | set updatetime=350 356 | 357 | " update the doc and hook the CheckForUpdate function. 358 | call UpdateDoc() 359 | au! CursorHold nested call CheckForUpdate() 360 | 361 | endfunction 362 | "}}} 363 | 364 | " Command 365 | command! TaskList call s:TaskList() 366 | 367 | " Default key map 368 | if !hasmapto('TaskList') 369 | map t TaskList 370 | endif 371 | 372 | " Key map to Command 373 | nnoremap