lyuts / vim-rtags

Vim bindings for rtags, llvm/clang based c++ code indexer.
BSD 2-Clause "Simplified" License
282 stars 56 forks source link

global excludeSysHeaders and word_under_cursor functions (<cword>) #2

Closed martong closed 10 years ago

martong commented 10 years ago

Hi,

I found your plugin the most promising from the 3 available github vim-rtags projects. So I added some improvements which you might find useful. I think excludeSysHeaders should be global, because it can have influence for all rc commands.

Best Regards, Gabor

lyuts commented 10 years ago

Hi, thanks for your interest in the plugin.

Regarding the change, the reason I didn't want to make this flag global is because I thought it would be better to let the specific rc command decide whether to include or exclude system headers. For instance, consider the fake case with open function. When searching for its declaration, I might want to have system headers included, but when searching for its usages, i might want to skip system headers as i'm only interested in my code using this function.

What do you think about making the getRcCmd() function take a excludeSysHeaders parameter?

Your comment/suggestions are welcome.

Thanks.

martong commented 10 years ago

The reason I thought it is good to make it global is because of the same use case what you mention with the 'open' function. I think the exact same behaviour can be achieved like this:

:let g:excludeSysHeaders = 1
:call rtags#JumpTo()
:let g:excludeSysHeaders = 0
:call rtags#FindRefs()

This way the user can more conveniently set up whether she wants to pass "-H" to rc. At least I think it is more convenient than to remember that the second parameter should be 1 if she wants to exlude the system headers. Though it is not that easy right now to query the value of the global variable, but a funtion could do that.

lyuts commented 10 years ago

Thought about this more, my opinion is that we do need to have a global setting to control search criterias for all commands. I also do think that the way a user invokes the command should provide control over criterias as well. Including/excluding is just one example.

Seems to me a function should take some kind of a filter. Otherwise the mapping will looks ugly, like, map <leader>rj :let g:includeA=1 | let g:includeB = 0 | let g:includeC = 1 | call JumpTo()<CR> and in some cases you might have to restore those variables to the values prior to invocation.

I'll merge this for a global setting, but will spend some effort trying to come up with a convenient and flexible search criteria management.

Thanks.