oivvio
oivvio

Reputation: 3156

In vim, do fuzzy search of definitions in virtualenv and create import statement

So I'm looking for a vim plugin that will do the following:

On execution open a list of all names defined in all modules in the currently used virtualenv, probably from a tags file already created with ctags.

Let the user limit the list by FuzzyFinder-style controls, with the addition that it should match the file path as well as the definition.

So if the search string User gave back a set of results

User         django/contrib/auth/models.py
UserAdmin    django/contrib/auth/admin.py  

the search string User;models would limit that down to just the first line

When a desired definition is found that name is inserted into the current buffer and a corresponding import statement is added to the top of the file.

Upvotes: 1

Views: 140

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172698

With the built-in taglist() function, you can access the tags database (so you don't need to parse the file yourself), and FuzzyFinder allows re-use of its nice drill-down logic via fuf#callbackitem#launch(); I use this myself for custom searches. You can probably combine the two parts with a bit of map(). Inserting the selected item and its import is also just a couple of :normal or append() calls. Voilà!

Upvotes: 2

Related Questions