]> Sergey Matveev's repositories - dotfiles.git/blobdiff - vim/.vim/plugin/ctags.vim
Better ctags-ing
[dotfiles.git] / vim / .vim / plugin / ctags.vim
index a76e736dc4f8528ee3ca7d9ae4569dcbc3ff80ed..fbc438c019daed3852ad058dc2679df154d18cbe 100644 (file)
@@ -9,10 +9,15 @@ if exists("g:loaded_mein_ctags") | finish | endif
 let g:loaded_mein_ctags = 1
 
 function! s:ctags(lang, onlyCmd, verbose)
-    let dst = tagfiles()[0]
-    let src = "/" . join(split(dst, "/")[:-2], "/")
+    let dst = tagfiles()
+    if len(dst) == 0
+        echohl WarningMsg | echomsg "No tagfiles" | echohl None
+        return
+    endif
+    let dst = sort(dst, {a, b -> len(a) > len(b) ? 1 : len(a) == len(b) ? 0 : -1})[0]
+    let src = "/" . join(split(dst, "/")[:-3], "/")
     if dst[0] != "/"
-        let dst = getcwd() . "/tags"
+        let dst = getcwd() . "/.tags/tags"
         let src = getcwd()
     endif
     let cmdline = [