Has anyone managed successfully using cscope
with Python code? I have VIM 7.2 and the latest version of cscope
installed, however it doesn't get my code's tags correctly (always off by a couple of lines). I tried the pycscope
script but its output isn't supported by the modern version of cscope
.
Any ideas? Or an alternative for browsing Python code with VIM? (I'm specifically interested in the extra features cscope
offers beyond the simple tags of ctags
)
This seems to work for me:
Change to the top directory of your python code. Create a file called
cscope.files
:You may need to perform a
cscope -b
first if the cross references don't get built properly.I got the same question you got, after browsing the internet, I found a way to fix this:
create a python script:
cscope_scan.py
excute this script under you code's root folder, this will generate the
cscope.files
and then excutecscope -b
I don't know what happens to my computer, the last two lines aren't working well, but I think manually type acscope -bk
is acceptable:)EDIT: I'm going to run through the process step by step:
Preparing the sources:
exhuberant ctags, has an option: -x
This is the key to the problem:
will give you your database of source objects in a known, format, described under
Gnu Global is not limited to only the "out of the box" type of files. Any regular file format will serve.
Also, you can use gtags-cscope, which comes with global as mentioned in section 3.7 of the manual, for a possible shortcut using gtags. You'll end up with an input of a ctags tabular file which Global/gtags can parse to get your objects, or you can use the source for pycscope together with your ctags file of known format to get an input for the vim cscope commands in
if_cscope.txt.
Either way it's quite doable.
Perhaps you'd prefer idutils?
Definintely possible since
z3c.recipe.tags
on pypi makes use of both ctags and idutils to create tag files for a buildout, which is a method I shall investigate in short while.
Of course, you could always use the greputils script below, it has support for idutils , we know idutils works with python, and if that fails, there is also something called vimentry from this year that also uses python, idutils and vim.
Reference links (not complete list):
Hopefully this helps you with your problem, I certainly helped me. I would have been quite sad tonight with a maggoty pycscope.
cscope
, this tool isn't designed to work with Python, and there are no plans to implement that compatibility. Whatever works now, apparently works by mistake, and there is no promise whatsoever that it will keep working.pycscope
. The latest version 0.3 is supported by thecscope
DB. The author ofpycscope
told me that he figured out the output format for thecscope
DB from reading the source code ofcscope
. That format isn't documented, on purpose, but nevertheless it currently works withpycsope
0.3, which is the solution I'll be using.I'm going to accept this answer since unfortunately no other answer provided help even after bounty was declared. No answers are upvoted, so I honestly have no idea where the bounty will go.
There is a wonderful Python-mode-klen plugin. If you have it and rope (python refactoring library) installed, then going to the definition of a particular term is as simple as
<C-c>g
or<C-c>rag
(first is filetype mapping, second is a global one). There are much more useful features, some useless for me. All of them are disableable. Features from list of questions found at cscope-intro:-
instead of the actual lines (though they point to the correct location). Maybe it will be fixed.Not very much, but I am not too experienced user of ropevim.