0

I am curious to know why vi(m) has never gone ahead and integrated cscope style database into it. When it comes to working with Linux Kernel code navigation I find

vim + ctags + cscope

is a must. And although ctags and vim do work as one cscope still doesn't. Recently I read this an interview article on www.Linux.com on Brtfs maintainer Chris Mason. And he mentions how it would be much better if cscope were integrated into vim and knowing the benefits of it I second that statement.

My question here is why isn't it done yet? If anyone has ever tried doing so, what difficulties are faced that leads to abandoning the task?

Personally if and when time permits I would like to dig into it myself. But any background information will definitely help. Thanks!

spitfire88
  • 1,596
  • 3
  • 19
  • 31
  • You only need an autocmd that rebuilds the database on each `:w` or `` or `CursorHold` or some other event. That's quite trivial, actually, same for ctags. There are automatic `tags` generation plugins for ctags, though, but nothing buitin so I don't really know what you are asking for. Querying a `tags` file or a cscope db is almost at the same level of "integration", actually, with `set cscopetag`. – romainl Dec 18 '12 at 10:24

1 Answers1

1

Well, cscope is integrated into Vim, see :help :cscope. Similar to ctags, Vim will invoke the external tool and parse its output. As with ctags, this gives you a set of commands to query its database. This may be already enough for you, or you'll use a plugin to make the handling easier to use. (For example, I use easytags.vim to automatically update the ctags database; there may be similar plugins for cscope.)

In case you're talking about including the full cscope functionality directly into Vim, that's against the design guidelines of Vim as a general-purpose tool; after all, cscope is a tool with a quite limited scope (no pun intended) of programming languages. In my opinion, the inclusion of a special command and parser inside Vim is already quite something. But you may search the vim_dev mailing list for discussions around cscope, or directly ask there for the reasons of the current cscope integration level, or ultimately propose a patch to change it.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Appreciate your quick reply. However it doesn't answer my question. I understand that cscope does show up in "VIM help", at the same time as you mentioned, since it does not have support to many languages, it cannot be fully integrated into vim for whatever reasons. But my question here is why doesn't vim develop a way to do a similar functionality as cscope into itself? Vim is preferred by many for code navigation then isn't functionality provided by csope a must to do code navigation? Or do the design guidelines of Vim restrict that too? – spitfire88 Dec 18 '12 at 11:35
  • Vim is first and foremost a general-purpose text editor. For code navigation, one would need to correctly parse the programming language first (and not just approximately, like syntax highlighting does). The Unix philosophy (from which vi and ultimately Vim come from) states that each tool should do one job well. Vim's is editing, not parsing. – Ingo Karkat Dec 18 '12 at 11:53
  • If you say so. But I do feel there are plenty of programmers out there who use VIM for more than just general-purpose text editing – spitfire88 Dec 18 '12 at 12:06
  • ...I do, too, and there's nothing wrong with it. It just explains why certain things feel less _integrated_ (as you have asked) than in the purpose-built IDEs, which cover this more seamlessly (but also lack the superior editing facilities of Vim). – Ingo Karkat Dec 18 '12 at 12:30