JCLiang / vim-cscope-utils

A vim plugin that creates and auto-loads ctags, cscope, and pycscope database for you.
15 stars 4 forks source link

Tags per branch introduces some new issues #2

Closed martinpelikan closed 9 years ago

martinpelikan commented 9 years ago

The changes introduced in 12d5ad7a are a great idea! However, they have caused a few issues for my uses in their current implementation. Perhaps these issues can be addressed in the user configuration, so I'd like to hear what you think.

  1. Branch names should be sanitized to be file/directory-name safe. If, for example, your branch name has a directory separator '/' in it, such as 'username/mybranch/testing', the relevant tag files will now be nested under several sub-directories. This may be intentional (and even neat, if you want to organize your tags in this manner), but it feels somewhat unpredictable and unexpected for me.
  2. I like to use "vim -t {tag}". It seems like the plugin only loads the tags after the argument has already been parsed and attempted to be evaluated and thus this fails. However, I have been able to set the 'tags' option to point at .git/tags and get the expected behaviour. With the new branching scheme, setting this statically no longer works as the tags will live in different places.
  3. Some kind of LRU cleanup might be nice, although purely just final polish. Cscope databases can grow to moderate sizes with huge projects, and this can add up if they are kept for each branch. This can be cleaned up manually, and in the grand scheme of things probably won't add up to much on modern disks, but it can still be a neat feature.

Cheers

JCLiang commented 9 years ago

I fixed 1. in 308bb40edf971af535dc8a5010518d2afe29e518.

For 2., "vim -t {tag}" works for me with the tags per branch feature. Can you provide a way to reproduce the issue you met?

I'll put 3. into my TODO list...:P

martinpelikan commented 9 years ago

Thank you for fixing this (and the other issue about logging)!

As for 2, I've set this in my vimrc: set tags=.git/**/tags. This unfortunately loads the tags for every branch, and only works if vim is invoked at the root of my project.

Without this change, tagfiles() is empty at the time -t is evaluated. I use vim-plug to manage my plugins, is it possible that it simply loads the plugin too late into the process for -t to work? Putting some print statements in, it looks like ConnectCscopeDatabase is only called if I open a tags-compatible filetype, which seems to make sense, but that also seems to make it not load if -t is used.

JCLiang commented 9 years ago

I noticed that you used "{ 'for': ['python', 'c', 'cpp']}" with my plugin for on-demand loading. Could this be the root cause?

martinpelikan commented 9 years ago

That was absolutely it, a remnant of a previous workaround that I forgot to reconsider... Many thanks!