]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/pack/stargrave/start/ctags/autoload/ctags.vim
Move to vim9script
[dotfiles.git] / vim / .vim / pack / stargrave / start / ctags / autoload / ctags.vim
1 vim9script
2
3 # Universal Ctags creator
4 # Maintainer: Sergey Matveev <stargrave@stargrave.org>
5 # License: GNU General Public License version 3 of the License or later
6 #
7 # Create "tags" file in your project's root first.
8 # Then :Ctags LANG to fill it.
9
10 export def Do(lang: string, onlyCmd: bool, verbose: bool)
11     var dsts = tagfiles()
12     if len(dsts) == 0
13         echohl WarningMsg | echomsg "No tagfiles" | echohl None
14         return
15     endif
16     var dst = sort(dsts, (a, b) => len(a) > len(b) ? 1 : len(a) == len(b) ? 0 : -1)[0]
17     var src = "/" .. join(split(dst, "/")[: -3], "/")
18     if dst[0] != "/"
19         dst = getcwd() .. "/.tags/tags"
20         src = getcwd()
21     endif
22     var cmdline = [
23         "uctags",
24         "--languages=" .. lang,
25         "--python-kinds=-i",
26         "--c++-kinds=+p",
27         "--recurse",
28     ]
29     if verbose == v:true | cmdline += ["--verbose"] | endif
30     cmdline += ["-f", dst, src]
31     if onlyCmd == v:true
32         echo join(cmdline, " ")
33         return
34     endif
35     execute "!" .. join(cmdline, " ")
36     if verbose != v:true | redraw! | endif
37 enddef