2

I work with GVIM and cscope for C on Window 7. But, the cscope database gets soon outdated as and when code is updated. So, I added the following to my gvimrc

nmap <F11>  :cs k 0 <CR> :!cscope -bR <CR> :cs a cscope.out<CR>

Since, I almost always work with only one cscope database, it is sufficient to kill only the first cscope database connection. However, when I execute cscope command it does not run from my project root directory. I can't figure out how to instruct cscope/cmd.exe to run cscope from project directory from within GVIM.

How to achieve this. Are there any well known plugins available for this feature ?

FDinoff
  • 30,689
  • 5
  • 75
  • 96
tecMav
  • 305
  • 1
  • 2
  • 11

1 Answers1

0

Try out this plugin I made: https://github.com/mihaifm/bck

Among other things it has a ChangeToRoot command, which changes Vim's current working directory to the project root of the current file.

The project root is defined by the presence of several files/folders (root markers). The defaults are: ['.git/', '.git', '_darcs/', '.hg/', '.bzr/', '.svn/', 'Gemfile']

You can customize it with the g:BckRoots variable in your .vimrc. You probably need to add .sln in there if you're compiling with Visual Studio.

Anyway, after this, your mapping should look like this:

nmap <F11>  :cs k 0 <CR> :!cscope -bR <CR>:ChangeToRoot<CR>:cs a cscope.out<CR>

It will load that cscope.out from your project root.

mihai
  • 37,072
  • 9
  • 60
  • 86