]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/autoload/ctags.vim
Vim scripts refactoring
[dotfiles.git] / vim / .vim / autoload / 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 function! ctags#do(lang, onlyCmd, verbose) abort
9     let dst = tagfiles()
10     if len(dst) == 0
11         echohl WarningMsg | echomsg "No tagfiles" | echohl None
12         return
13     endif
14     let dst = sort(dst, {a, b -> len(a) > len(b) ? 1 : len(a) == len(b) ? 0 : -1})[0]
15     let src = "/" . join(split(dst, "/")[:-3], "/")
16     if dst[0] != "/"
17         let dst = getcwd() . "/.tags/tags"
18         let src = getcwd()
19     endif
20     let cmdline = [
21         \"uctags",
22         \"--languages=" . a:lang,
23         \"--python-kinds=-i",
24         \"--c++-kinds=+p",
25         \"--recurse",
26     \]
27     if a:verbose == v:true | let cmdline += ["--verbose"] | endif
28     let cmdline += ["-f", dst, src]
29     if a:onlyCmd == v:true
30         echo join(cmdline, " ")
31         return
32     endif
33     execute "!" . join(cmdline, " ")
34     if a:verbose != v:true | redraw! | endif
35 endfunction