14

I have opensuse 11.4 installed. Vim is version 7. Now I normally use it to browse the linux kernel source. So I generated the cscope database inside a directory within my home folder i.e. /home/aijazbaig1/cscope_DB/ and I got 3 files viz. cscope.out, cscope.po.out and cscope.in.out besides the cscope.files file which contains a list of all the relevant files which I want to search.

Additionally I have added the following to my .bashrc:

CSCOPE_DB=/home/aijazbaig1/cscope_DB/cscope.out
export CSCOPE_DB

But when I do a :cscope show from within vim it says there are no connections. Can anyone please let me know what is going wrong.

Keen to hear from you,

Aijaz Baig
  • 141
  • 1
  • 1
  • 3
  • A number of issues could cause this - see this site for help: http://vim.wikia.com/wiki/Cscope – Caffeinated Jun 23 '11 at 06:57
  • 2
    Yes I did try what was mentioned here: http://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks so I did add the line 'cs add $CSCOPE_DB' from within an 'if has ('cscope') block. Now it seems to be working but I cannot still use the ctrl+'\'+s and such commands to directly look for a work where my cursor is. I think may be I will have to download the cscope_maps.vim file and put it in my .vim/plugin/ directory isn't it?? But damn its a virtual machine and file sharing isnt working:(. Anyways thats a topic for another section – Aijaz Baig Jun 23 '11 at 09:07
  • Yes I was able to get those key strokes working by sticking the data of the cscope_maps.vim file into my .vimrc. – Aijaz Baig Jun 23 '11 at 11:25
  • 1
    Good you figured it out. You might want to answer your own question and mark it as answered so it doesn't show up as an unanswered question. – PonyEars Jun 25 '12 at 18:45

6 Answers6

15

This is mentioned in the comments above, but I want to make sure it's preserved in an answer.

The issue that came up for me was that vim didn't know where to look for the cscope database. When I added

cs add $CSCOPE_DB

to my .vimrc. Everything came out fine.

Wesley Bland
  • 8,073
  • 3
  • 44
  • 57
12

I figure since I've made the visit, I would try responding.

I was getting this error when searching using ctrl-space s (or any search for that matter):

E567: no cscope connections

I finally found the full solution at http://cscope.sourceforge.net/cscope_vim_tutorial.html, Step 11.

The idea is that you create a list of source files to be included in the view of cscope, generate the cscope.out in the same location, and update the export path accordingly:

  • find /my/project/dir -name '*.c' -o -name '*.h' > /foo/cscope.files
  • cscope -R -b (this may take a while depending on the size of your source)
  • export CSCOPE_DB=/foo/cscope.out (put this in your .bashrc/.zshrc/other-starting-script if you don't want to repeat this every time you log into the terminal)
blackstrype
  • 401
  • 6
  • 12
2

You need to add a "cscope connection", like this in vim:

:cscope add $PATH_TO_CSCOPE.out 

See :help cs for more examples.

Mathieu
  • 6,922
  • 6
  • 27
  • 37
Guru
  • 31
  • 6
2

Here's how I explore linux kernel source using cscope:

I use vim as my editor.

  1. While standing inside the kernel source root directory, run cscope in interactive mode while recursively going through subdirectories during search for source files:

cscope -R

When run for the first time, it will generate the database file with the name: cscope.out inside the current directory. Any subsequent runs will use the already generated database.

  1. Search for anything or any file and open it.
  2. Set cscope tags in vim to make the :tag and CTRL-] commands search through cscope first and then ctags' tags:

:set cscopetag

  1. Set cscope database inside current VIM session:

:cs add cscope.out

Now you can use CTRL-] and CTRL-t as you would do in ctags to navigate around! :)

0

I have the same issue on my PC. For now, to solve the issue:

  1. On terminal execute: which is cscope

  2. Open .vimrc file to edit: set csprg=/usr/bin/cscope

M.A.R.
  • 159
  • 1
  • 7
  • 14
HuyLe
  • 28
  • 2
0

I ran into a similar problem with no cscope connections on ubuntu 18.04, then I discovered my .vimrc file does not load the CSCOPE_DB variable. Looked a little around and found a solution.

You can just copy this directly in to your .vimrc file.

Part of the code loads your cscope file from your directory. The keybinds are just a nice bonus. Hope this helps.

Blaze
  • 16,456
  • 1
  • 21
  • 43