devjoe / vim-codequery

Search + Browse + Understand your code more efficiently.
MIT License
193 stars 19 forks source link

Finding db file in non-git repositories #26

Open paulwalko opened 6 years ago

paulwalko commented 6 years ago

I noticed that this plugin only works correctly if the db for searching is either in the current directory or it's in the root of a git repository. Many times neither of these are true. Do you know the best way to do this?

I ended up modifying my path: 'set path+=;/' in .vimrc and just used findfile(db_name) where the db is being searched for. I'm definitely no vim expert so there might be a better way to do this.

It would probably be better to use something other than path, but I don't know to do this.

Thoughts? I'd be happy to submit a pr once we figure out the best method.

devjoe commented 6 years ago

Always run :CodeQueryMakeDB in the root of a git repository.

A tip is that you can open any file (such as README.md) in this folder and specify the language you want to build (like :CodeQueryMakeDB python). Then you will have a database file which indexed all necessary files. What you need to do next is call CodeQueryMoveDBToGitDir python to archive this database file to .git/codequery/. Finally, you should not worry about the location of the database file.

If the tip doesn't work for your case, please let me know the way you use vim-codequery.

paulwalko commented 6 years ago

The project I'm not working on is not a git repository, so your tip doesn't work.

devjoe commented 6 years ago

Gotcha!

Maybe we could store database files under ~/.vim-codequery/ directory. Do you have any thought to design this feature?

paulwalko commented 6 years ago

I suppose something like that would work, using the path where the db was created as a key and then have vim search for the longest key that is included in the current path.

What do you think of what I suggested in the original comment? I really don't know much about vimscript, but it seems much simpler because the functionality for search up your current is already built in.

xfactor9 commented 4 years ago

modify db.vim to force the lookup_path as getcwd(), and let lookup_path = findfile(git_root_dir . '/' . db_name, '.') where your start vim is the DB search folder, it's more intuitive and similar usage as ctags and cscope