]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/plugin/ctags.vim
859020ec0a0baa85a704c1990b518bbd556fecc5
[dotfiles.git] / vim / .vim / plugin / ctags.vim
1 " Exuberant Ctags creator
2 " Maintainer: Sergey Matveev <stargrave@stargrave.org>
3 " License: GNU General Public License version 3 of the License or later
4 "
5 " Create "tags" file in your project's root first.
6 " Then :Ctags LANG to fill it.
7
8 function! s:ctags(lang, onlyCmd, verbose)
9     let dst = tagfiles()[0]
10     let src = "/" . join(split(dst, "/")[:-2], "/")
11     if dst[0] != "/"
12         let dst = getcwd() . "/tags"
13         let src = getcwd()
14     endif
15     let cmdline = [
16         \'uctags',
17         \'--languages=' . a:lang,
18         \'--python-kinds=-i',
19         \'--c++-kinds=+p',
20         \'--recurse',
21     \]
22     if a:verbose == v:true | let cmdline += ['--verbose'] | endif
23     let cmdline += ['-f', dst, src]
24     if a:onlyCmd == v:true
25         echo join(cmdline, " ")
26         return
27     endif
28     execute "!" . join(cmdline, " ")
29     if a:verbose != v:true | redraw! | endif
30 endfunction
31
32 command! -nargs=1 Ctags silent call s:ctags(<f-args>, v:false, v:false)
33 command! -nargs=1 Ctagsv silent call s:ctags(<f-args>, v:true, v:false)
34 command! -nargs=1 Ctagscmd call s:ctags(<f-args>, v:true, v:true)