Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

~/.git causes gutentags to index the entire home directory #13

Closed
justinmk opened this issue Mar 13, 2015 · 15 comments
Closed

~/.git causes gutentags to index the entire home directory #13

justinmk opened this issue Mar 13, 2015 · 15 comments

Comments

@justinmk
Copy link
Contributor

I have a ~/.git/ folder for managing dotfiles. I don't want this to trigger gutentags. Is there a way to avoid this, while still enabling gutentags in ~/foo/.git subdirectories, which doesn't involve me setting up a bunch of autocmds and manually managing g:gutentags_enabled?

Thanks for this project, I like the choices you have made.

@Konfekt
Copy link

Konfekt commented Mar 13, 2015

Perhaps by abusing g:gutentags_exclude? (Supposedly meant to supply file extensions à la *.dll but perhaps accepting full paths as well)

@justinmk
Copy link
Contributor Author

g:gutentags_exclude just gets passed to ctags -x (which seems totally redundant with ~/.ctags). And as far as I know there's no good way to specify a -x pattern such that it will ignore a certain directory, yet not ignore subdirectories.

@nikital
Copy link

nikital commented Mar 14, 2015

@justinmk Off topic: I used to have a ~/.git to manage my dotfiles and I had problems similar to yours. Various tools that are supposed to find the root of the project would find the home directory.

This was annoying, so I changed my setup to avoid this class of problems entirely: I moved the dotfiles to ~/.dotfiles and use GNU Stow to symlink them to ~.

Something like:
http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html

@justinmk
Copy link
Contributor Author

Thanks, but using a tool to manage dotfiles is cheesy, and I doubt stow even works on windows.

nested git repos are a legitimate use of git, so tools built on git should be able to handle it. If gutentags supported projectionist, it could avoid this problem.

@ludovicchabant
Copy link
Owner

I myself use some ad-hoc install/uninstall scripts (both on Mac/Linux and Windows), because it's frankly not much to write, has no dependencies, and I can do funky stuff like generate an .hgrc file instead of linking to one, because I also need to bring in other local stuff with absolute paths, and I don't want to assume anything about where I cloned my dotfiles repo. See here: https://bitbucket.org/ludovicchabant/dotfiles/src/8b6ca7e40f371f9eea323aded0dfb1c66e8bdd43/install.sh?at=default

Anyway, back to @justinmk's original issue: If I understand this correctly, you have your whole home directory under Git, which is why you don't want to generate tags for it because it's super big? I have some changes coming up that add the ability to specify things like .tagsignore files and other things like that in the root directory (I'm not set yet on the design), which would let you ignore things more easily per-project. Stay tuned :)

@justinmk
Copy link
Contributor Author

@ludovicchabant https://github.com/tpope/vim-projectionist is a general solution to project "root finding" (and other things).

It would be ideal if I could tell gutentags to not try to find a root, and only build tags if projectionist#path() (the project root) is non-empty.

@sunaku
Copy link

sunaku commented Apr 9, 2015

@ludovicchabant Any luck on the .tagsignore file? My CPU is pegged at 100% while this plugin attempts to index my entire homedir just because I happen to have a ~/.git folder. 😱

@sunaku
Copy link

sunaku commented Apr 9, 2015

Here is a workaround I'm using to avoid this issue until it gets fixed properly. 😅

diff --git a/autoload/gutentags/ctags.vim b/autoload/gutentags/ctags.vim
index cf5a576..6292068 100644
--- a/autoload/gutentags/ctags.vim
+++ b/autoload/gutentags/ctags.vim
@@ -36,6 +36,12 @@ function! gutentags#ctags#init(project_root) abort
 endfunction

 function! gutentags#ctags#generate(proj_dir, tags_file, write_mode) abort
+    " Don't treat user's (massive) home directory as a project!
+    " https://github.com/ludovicchabant/vim-gutentags/issues/13
+    if a:proj_dir == $HOME
+        return
+    endif
+
     " Get to the tags file directory because ctags is finicky about
     " these things.
     let l:prev_cwd = getcwd()

sunaku added a commit to sunaku/vim-gutentags that referenced this issue Apr 9, 2015
sunaku added a commit to sunaku/vim-gutentags that referenced this issue Apr 9, 2015
@ludovicchabant
Copy link
Owner

Oh my, sorry, I totally forgot about this (I think I have too many projects going on :) feel free to submit pull requests if anyone wants to fix it themselves though ;) )

Anyway, turns out that the .tagsignore thing I mentioned is only a partial solution since it's more about being able to specify gutentags_exclude per project (kinda like a .gitignore/.hgignore but for ctags). It could solve the OP's problem, but not if you really want zero tags support in a given project. For that, I just added with 7316197 the ability to create a .notags file at the root of the project. It just flat out disables Gutentags for that project. I hope it helps!

@sunaku
Copy link

sunaku commented Apr 10, 2015

Perfect! 👍 The .notags file solves the problem for me. 🙇

@ludovicchabant
Copy link
Owner

Good!
FYI everyone, I also closed issue 17 which lets you write a standard .ctags options file at the root of your project, which lets you among other things specify --exclude rules for your project (so it makes the whole .tagsignore thing moot).

@justinmk
Copy link
Contributor Author

@ludovicchabant Cool, thanks!

justinmk added a commit to justinmk/config that referenced this issue Apr 10, 2015
@sunaku
Copy link

sunaku commented Apr 18, 2015

To automate 🚀 this workaround, I wrote this snippet in my vimrc:

" prevent gutentags from indexing the entire home directory
" https://github.com/ludovicchabant/vim-gutentags/issues/13
let s:notags = expand('~/.notags')
if !filereadable(s:notags)
  call writefile([], s:notags)
endif

Cheers! 🍰

@justinmk
Copy link
Contributor Author

@sunaku You could just commit ~/.notags to your git repo, if you source-control your home dir. That's what I did: https://github.com/justinmk/config/blob/master/.notags

@sunaku
Copy link

sunaku commented Apr 18, 2015

💡 Great idea! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants