自动补全

AutoComplPop---自动补全

http://svn.php.net/viewvc/phpdoc/doc-base/trunk/funclist.txt

vim 添加PHP函数自动补全

vim自动代码提示插件AutoComplPop

OmniCppComplete---CPP自动补全

如何让YouCompleteMe支持php补全

YouCompleteMe 实现代码补全

YouCompleteMe+syntastic vim自己主动补全插件

Windows 安装 YouCompleteMe

YouCompleteMe 安装全教程

vim插件——YouCompleteMe

YouCompleteMe git

自动补全

ctags --list-kinds=php

ctrl+w]  切换在当前窗口

查看出错信息
:YcmDebugInfo

superTab: 上下文补全插件
L9: vim-script
Syntastic: 语法检查
AutoComplPop: 函数自动补全
snipMate: 语法结构补全if else;while;for

AutoComplPop:
au FileType php setlocal dict+=$VIM/vimfiles/bundle/AutoComplPop/dict/php_funclist.txt
" if !exists('g:AutoComplPop_Behavior')
" let g:AutoComplPop_Behavior = {}
" let g:AutoComplPop_Behavior['php'] = []
" call add(g:AutoComplPop_Behavior['php'], {
" \ 'command' :"\\",
" \ 'pattern' : printf('−>∥::∥$\k\{%d,}$', 0),
" \ 'repeat' : 0,
" \})
" endif


CMake安装:
wget https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4.tar.gz
cd cmake-3.16.4
./bootstrap
gmake
gmake install

VIM8.2安装:
git clone https://github.com/vim/vim.git
make clean
./configure \
    --with-features=huge \
    --enable-multibyte \
    --enable-rubyinterp \
    --enable-pythoninterp \
    --enable-python3interp \
    --with-python-config-dir=/usr/lib64/python2.7/config \
    --with-python3-config-dir=/usr/local/python/lib/python3.7/config-3.7m-x86_64-linux-gnu \
    --enable-luainterp \
    --enable-cscope \
    --prefix=/usr

make VIMRUNTIMEDIR=/usr/share/vim/vim82
make install


YouComplete工作原理
  补全引擎:基于当前文件和你要访问的文件(和tags文件)生成标签库,每次输入时,在标签库里面搜索。

YouCompleteMe插件过大,用Vundle插件管理器安装过程中会报错,介绍一种用源码安装的方式。
1. 首先要保证已经安装Vundle

2. 进入目录
cd ~/.vim/bundle
3. 克隆代码
git clone https://github.com/Valloric/YouCompleteMe.git

4. 进入目录执行下面命令
cd YouCompleteMe
git submodule update --init --recursive

5. 安装
yum -y install golang
仅安装支持Python的版本:
./install.py
安装支持C语言家族的版本:
./install.py --clang-completer
安装支持go语言的版本:
./install.py --go-completer
安装支持Js、Java、Python、go所有语言的版本:
./install.py --all

vimrc配置

let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
" 不显示开启vim时检查ycm_extra_conf文件的信息
let g:ycm_confirm_extra_conf = 0
" 开启基于tag的补全,可以在这之后添加需要的标签路径
let g:ycm_collect_identifiers_from_tags_files = 1
" 开启语义补全
let g:ycm_seed_identifiers_with_syntax = 1
"注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 0
" 输入第 2 个字符开始补全
let g:ycm_min_num_of_chars_for_completion= 2
" 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_cache_omnifunc=0
"在注释输入中也能补全
let g:ycm_complete_in_comments = 1
"在字符串输入中也能补全
let g:ycm_complete_in_strings = 1
"定义快捷健补全
let g:ycm_key_list_select_completion = ['<c-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
" 设置在下面几种格式的文件上屏蔽ycm
let g:ycm_filetype_blacklist = {
      \ 'tagbar' : 1,
      \ 'qf' : 1,
      \ 'notes' : 1,
      \ 'markdown' : 1,
      \ 'unite' : 1,
      \ 'text' : 1,
      \ 'vimwiki' : 1,
      \ 'pandoc' : 1,
      \ 'infolog' : 1,
      \ 'mail' : 1
      \}
"设置关健字触发补全
let g:ycm_semantic_triggers =  {
  \   'c' : ['->', '.', ' ', '(', '[', '&'],
  \   'objc' : ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s',
  \             're!\[.*\]\s'],
  \   'ocaml' : ['.', '#'],
  \   'cpp,objcpp' : ['->', '.', '::'],
  \   'perl' : ['->'],
  \   'php' : ['->', '::'],
  \   'cs,java,javascript,typescript,d,python,perl6,scala,vb,elixir,go' : ['.'],
  \   'ruby' : ['.', '::'],
  \   'lua' : ['.', ':'],
  \   'erlang' : [':'],
  \ }
let g:ycm_cache_omnifunc = 1
let g:ycm_use_ultisnips_completer = 1
"定义函数跟踪快捷健
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>

ctags使用详解

universal-ctags

优雅得使用 Vim + Ctags

安装universal ctags(取代exuberant-ctags)
git clone https://github.com/universal-ctags/ctags.git
cd ctags
./autogen.sh
./configure
make
sudo make install

ctags --list-languages
ctags --list-maps
ctags --list-maps=php
ctags --list-kinds

ctags -R
ctags -f php.tags --languages=PHP -R
ctags `find . -name '*.phpr'
ctags -R --exclude=vendor --exclude=*test* --languages=PHP  //排除目录
ctags -R vendor --languages=PHP                             //子目录

ctags -R --c++-kinds=+px --fields=+iaS --extra=+q
其中:
c++-kinds: 用于指定C++语言的 tags记录类型,  
--c-kinds: 用于指定c语言的,通用格式是--{language}-kinds: 
--fileds: 用于指定每条标记的扩展字段域
--extra: 用于增加额外的条目: f表示为每个文件增加一个条目,q为每个类增加一个条目

:set tags=php.tags
:set tags+=vendor.tags
:set tags=php.tags, vendor.tags

:tag MyClass
:tag My<tab>


# vim ~/.tags
-R
--languages=php
--php-kinds=ctif
--exclude=*test*
--exclude=vendor/*/vendor
--fields=+aimS

# vim .vimrc
set tags+=tags.vendor
set tags=./tags;,tags       //;号,向上搜索

autocmd BufWritePost *.php silent execute "!ctags src"

快捷键:
<1> 把光标移到变量名或函数名上,然后按下Ctrl-]。用Ctrl-t退回原来的地方。 
<2> 在函数中移动光标
    [{     转到上一个位于第一列的"{"
    }]     转到下一个位于第一列的"{"
    {      转到上一个空行
    }      转到下一个空行 ([ and ] 也分别是两个指令)
    gd   转到当前光标所指的局部变量的定义
    *      转到当前光标所指的单词下一次出现的地方
    #     转到当前光标所指的单词上一次出现的地方
Ctrl-] Jump to the tag underneath the cursor
:ts <tag> <RET> Search for a particular tag
:tn Go to the next definition for the last tag
:tp Go to the previous definition for the last tag
:ts List all of the definitions of the last tag
Ctrl-t Jump back up in the tag stack