[ACCEPTED]-vim cannot connect to cscope database-cscope

Accepted answer
Score: 19

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

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

cs add $CSCOPE_DB

to my .vimrc. Everything 1 came out fine.

Score: 13

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

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

E567: no cscope 6 connections

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

The idea is that you create 4 a list of source files to be included in 3 the view of cscope, generate the cscope.out 2 in the same location, and update the export 1 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)
Score: 3

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

:cscope add $PATH_TO_CSCOPE.out 

See :help cs for more examples.

Score: 2

Here's how I explore linux kernel source 7 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 6 run for the first time, it will generate 5 the database file with the name: cscope.out inside 4 the current directory. Any subsequent runs 3 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 2 you can use CTRL-] and CTRL-t as you would do in ctags 1 to navigate around! :)

Score: 0

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

  1. On terminal execute: which is cscope

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

Score: 0

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

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

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

More Related questions