eXe
eXe

Reputation: 194

How to change the project used by Indexer during a Vim session?

I'm trying to use Indexer (vimscript #3221) to index the files of a specific project created with project.vim (vimscript #69). As the plugin's documentation says, if I don't set the g:indexer_projectsSettngsFilename variable in ~/.vimrc, it uses ~/.vimprojects file by default. But I want to be able to specify the project without setting that variable in ~/.vimrc (i.e., I want to do it in a more local way).

I tried to set g:indexer_projectsSettngsFilename in _vimrc_local.vim, setting it manually after Vim is started, re-source the plugin (by running :so) once the variable has been set, run :IndexerRebuild afterwards. In either case the plugin does not create the index file for the project.

So how can I make Indexer to change its project during a Vim session?

Upvotes: 2

Views: 248

Answers (1)

Dmitry Frank
Dmitry Frank

Reputation: 10767

The Indexer plugin has a dependency: Vimprj, which manages options for different projects: exactly what you need.

The Indexer repository has some examples under doc/examples directory. Check, for example, doc/examples/vimprj_indexer_files.

In short, in the root directory of your project, you need to create the .vimprj directory, and after this, when you open some file under your project directory, all .vimprj/*.vim files will be sourced, and $INDEXER_PROJECT_ROOT variable will be set to the path of your project (which is one level above the .vimprj dir).

I usually put my .indexer_files in .vimprj directory too, and refer to it from .vimprj/my.vim file like this:

" get path to ".vimprj" folder
let s:sPath = expand('<sfile>:p:h')

" specify our ".vimprj/.indexer_files"
let g:indexer_indexerListFilename = s:sPath.'/.indexer_files'

And I can refer from .indexer_files to $INDEXER_PROJECT_ROOT like this:

[my_project]
option:ctags_params = "--langmap=c:.c.h --languages=c"

$INDEXER_PROJECT_ROOT

For more information, see the article: Vim: convenient code navigation for your projects, which explains the usage of Indexer + Vimprj thoroughly.

Upvotes: 1

Related Questions