Can anyone suggest a better ctags solution for me?

I used ctags with the vim script below and had no problems running my small projects. But when I got into some major projects, in games written in C ++, the recursive command ctags and cscope seems a lot slower than I thought. Actually, I managed to run it in the background, but it looks like my laptop is pretty busy doing tags.

I heard that there is a solution that you create a tag in each subdirectory, and while you are working in a specific subdirectory, you can consult the tag in the root directory for another tag subdirectory. Is it possible? If someone can give me a specific HOW-TOS with this method, I would be very grateful.

Or, if there is a better solution, I really want to know about it.

Here is my code for vim script

function! UpdateTags()
    let curdir = getcwd()
    let gitdir = finddir('.git', '.;/')

    if isdirectory(gitdir)
        let l:rootdir = fnamemodify(gitdir, ':h')
        execute 'silent cd ' . l:rootdir
        execute 'silent !ctags -R --c++-kinds=+p --fields=+iaS --extra=+q &'
        if has("cscope")
            execute 'silent !cscope -Rbkq &'
            execute 'silent cs reset'
        endif " has("cscope") 
        execute 'silent cd ' . curdir
    endif
endfunction
+3
source share
1 answer

I use ctags -Rslower than using ctags with a file like ctags -L input. So what I did in my current java projects with about 3,000 files in it, to ask git to give me the paths to the files, collect them in an archive (e.g. javafiles.txt), and then execute it ctags -L javafiles.txtoutside the editor.

If you do not want to leave vim, you can use shellscript to call Ctags with the necessary parameters. I.E. Create a file autotags.shin the root directory of the git project with the following lines:

#!/bin/bash

set -e
git ls-files | sed "/\.cpp$/!d" >> cscope.files


ctags -L cscope.files

Do not forget to give him permission to execute. When you have shellscript, your vimscript code will look like this:

function! UpdateTags()
    let curdir = getcwd()
    let gitdir = finddir('.git', '.;/')

    if isdirectory(gitdir)
        let l:rootdir = fnamemodify(gitdir, ':h')
        execute 'silent cd ' . l:rootdir
        execute 'silent !./autotags.sh &'
        if has("cscope")
            execute 'silent !cscope -bkq &'
            execute 'silent cs reset'
        endif " has("cscope") 
        execute 'silent cd ' . curdir
    endif
endfunction

- cscope.files, , cscope . http://cscope.sourceforge.net/large_projects.html

, , , , , , ctags cscope.

+1

All Articles