cscope like functionality for C++ (using vim)
Asked Answered
T

3

14

Is there any utility or plugin which provides cscope like functionality for C++. I am looking for

  • all references to a symbol
  • global definitions
  • functions called by a function
  • functions calling a function
  • files including a file
Timmerman answered 10/3, 2010 at 14:23 Comment(0)
C
3

Vim can interface directly with cscope out of the box. Type :h cscope. This requires cscope functionality to be enabled when Vim is compiled and for cscope to be installed on your computer.

There is a Vim + cscope tutorial on the cscope web page.

Cortez answered 13/3, 2010 at 9:16 Comment(2)
is there any other tool which can provide similar functionalityTimmerman
I have found a program called Silent Bob (silentbob.sourceforge.net), but have not tried it. It claims to support C++, perl and Python.Cortez
T
12

There are some tools listed in the thread, https://www.reddit.com/r/emacs/comments/1qktcb/cscope_like_functionality_that_correctly_handles/:

Some other links

  • https://ruben2020.github.io/codequery/ "CodeQuery is a project that attempts to combine the features available from both cscope and ctags, provide faster database access compared to cscope (because it uses sqlite) and provides a nice GUI tool as well.", has own gui and vim plugin https://github.com/devjoe/vim-codequery; can't generate cscope database, but its own "CodeQuery sqlite3 db" is converted from cscope.out, generated by pycscope for python; starscope for Ruby, Go and Javascript; original cscope for C and limited C++; can also use TAGS.
  • https://github.com/cquery-project/cquery "cquery is a highly-scalable, low-latency language server for C/C++/Objective-C. It is tested and designed for large code bases like Chromium. cquery provides accurate and fast semantic analysis without interrupting workflow." ... finding definition/references, with clang, C/C++; very quick work, fast updates and eats a lot of RAM. Has vim support: https://github.com/cquery-project/cquery/wiki/Vim
  • https://www.gnu.org/software/global/ GNU Global is sometimes recommended as cscope replacement. It has "locate not only definitions but also references" and supports " 6 languages by built-in parser. (definition and reference): C, C++, Yacc, Java, PHP4 and assembly." And Vim integration: https://www.gnu.org/software/global/globaldoc_toc.html#Vim-editor

And there are some fast (indexed) greps like Russ Cox’ codesearch tools (It works with regex too - https://github.com/google/codesearch; example is https://codesearch.debian.net/about) or any other indexed grep...

And there are cross ref tools (GUI and web-servers) like LXR and other... https://github.com/oracle/opengrok/wiki/Comparison-with-Similar-Tools

Trousseau answered 24/1, 2018 at 3:47 Comment(1)
Thanks, rtags works perfectly. It is far superior to ctags+cscope, which is almost unusable in C++.Handmedown
C
3

Vim can interface directly with cscope out of the box. Type :h cscope. This requires cscope functionality to be enabled when Vim is compiled and for cscope to be installed on your computer.

There is a Vim + cscope tutorial on the cscope web page.

Cortez answered 13/3, 2010 at 9:16 Comment(2)
is there any other tool which can provide similar functionalityTimmerman
I have found a program called Silent Bob (silentbob.sourceforge.net), but have not tried it. It claims to support C++, perl and Python.Cortez
F
0

Try YouCompleteMe.

It's got code completion, go-to-definition and refactoring not just for C & C++, but for Rust, Go, Java, C# and more.

Make sure to install it with support for clangd as described here.

Fatso answered 8/12, 2023 at 21:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.