]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/plugin/ctags.vim
Simplify format of .zhashd
[dotfiles.git] / vim / .vim / plugin / ctags.vim
1 " Universal 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 if exists("g:loaded_mein_ctags") | finish | endif
9 let g:loaded_mein_ctags = 1
10
11 function! s:ctags(lang, onlyCmd, verbose)
12     let dst = tagfiles()
13     if len(dst) == 0
14         echohl WarningMsg | echomsg "No tagfiles" | echohl None
15         return
16     endif
17     let dst = sort(dst, {a, b -> len(a) > len(b) ? 1 : len(a) == len(b) ? 0 : -1})[0]
18     let src = "/" . join(split(dst, "/")[:-3], "/")
19     if dst[0] != "/"
20         let dst = getcwd() . "/.tags/tags"
21         let src = getcwd()
22     endif
23     let cmdline = [
24         \"uctags",
25         \"--languages=" . a:lang,
26         \"--python-kinds=-i",
27         \"--c++-kinds=+p",
28         \"--recurse",
29     \]
30     if a:verbose == v:true | let cmdline += ["--verbose"] | endif
31     let cmdline += ["-f", dst, src]
32     if a:onlyCmd == v:true
33         echo join(cmdline, " ")
34         return
35     endif
36     execute "!" . join(cmdline, " ")
37     if a:verbose != v:true | redraw! | endif
38 endfunction
39
40 command! -nargs=1 Ctags silent call s:ctags(<f-args>, v:false, v:false)
41 command! -nargs=1 Ctagsv silent call s:ctags(<f-args>, v:true, v:false)
42 command! -nargs=1 Ctagscmd call s:ctags(<f-args>, v:true, v:true)