vim-codequery icon indicating copy to clipboard operation
vim-codequery copied to clipboard

Finding db file in non-git repositories

Open paulwalko opened this issue 6 years ago • 5 comments

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.

paulwalko avatar Jun 12 '18 20:06 paulwalko

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.

devjoe avatar Jun 14 '18 16:06 devjoe

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

paulwalko avatar Jun 14 '18 17:06 paulwalko

Gotcha!

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

devjoe avatar Jun 18 '18 14:06 devjoe

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.

paulwalko avatar Jun 22 '18 04:06 paulwalko

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

xfactor9 avatar May 20 '20 00:05 xfactor9