准备
- 下载ctags,然后配置到环境变量
Plug 'ludovicchabant/vim-gutentags'
Plug 'skywind3000/gutentags_plus'
Plug 'skywind3000/vim-preview' "方便预览
- 安装GTags
配置
"gtags"
let $GTAGSLABEL = 'native-pygments'
""let $GTAGSCONF = 'F:\soft\gvim_8.2.3322_x64\vim\glo665wb\share\gtags\gtags.conf'
let $GTAGSCONF = $vim . '/glo665wb/share/gtags/gtags.conf'
"ctags"
" gutentags搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归 "
let g:gutentags_project_root = ['.root', '.svn', '.git', '.project']
" enable gtags module
let g:gutentags_modules = ['ctags', 'gtags_cscope']
" config project root markers.
let g:gutentags_project_root = ['.root']
" 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录 "
let s:vim_tags = expand('~/.cache/tags')
let g:gutentags_cache_dir = s:vim_tags
" 检测 ~/.cache/tags 不存在就新建 "
if !isdirectory(s:vim_tags)
silent! call mkdir(s:vim_tags, 'p')
endif
" change focus to quickfix window after search (optional).
let g:gutentags_plus_switch = 1
" 配置 ctags 的参数 "
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
let g:gutentags_ctags_extra_args += ['--c++-kinds=+pxI']
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" 如果使用 universal ctags 需要增加下面一行,老的 Exuberant-ctags 不能加下一行
let g:gutentags_ctags_extra_args += ['--output-format=e-ctags']
" Vim打开后自动连接cscope数据库。当同一Vim打开多个project时易发生冲突
let g:gutentags_auto_add_gtags_cscope = 1
"vimpreview"
noremap <m-p> :PreviewTag<cr>
noremap <m-u> :PreviewScroll -1<cr>
noremap <m-d> :PreviewScroll +1<cr>
inoremap <m-u> <c-\><c-o>:PreviewScroll -1<cr>
inoremap <m-d> <c-\><c-o>:PreviewScroll +1<cr>
autocmd FileType qf nnoremap <silent><buffer> p :PreviewQuickfix<cr>
autocmd FileType qf nnoremap <silent><buffer> P :PreviewClose<cr>
noremap <F4> :PreviewSignature!<cr>
inoremap <F4> <c-\><c-o>:PreviewSignature!<cr>
参考链接
gstag篇https://zhuanlan.zhihu.com/p/36279445 https://zhuanlan.zhihu.com/p/43671939
|