1

I have a .h file who contains these code:

template<BLA>
func1() {}

// something 

template<BLA>
func2() {
  func1();
}

when I typed the command GoToDefinition, the error appeared :"YCM : 'RuntimeError : can't jump to definition.'". Do I miss something? And how to find the definition?

By the way, I have this in my .vimrc:

let g:ycm_global_ycm_extra_conf = ' ~/ycm_extra_conf.py'

**************second edit*******************

I reinstalled my YCM, and I tried ctags for YCM by this command :

ctags -R --fields=+l 

It works, and thanks.

4

1 回答 1

2

Last time I've checked, YCM understanding of a source code is restricted to one translation unit. It'll be very difficult for it to find where a function is defined as it's likely to be in another translation unit.

In other words, it should work as long as you want to jump to a definition that is in the same .cpp file as the one your are currently editing. Thus, it should also work when trying to access to a template function definition from it's call site -- as we're supposed to include the related code. If it doesn't, it could be related to an improper understanding of the source code by clang engine YCM is using, or to YCM not configured to use clang.

Regarding tags, they could do the job, but indeed, in C++, you'll want a way to narrow the tags presented. That's what had me started lh-tags: it presents all matching tags and it permits to filter them on various criteria (filename, kind, scope, ...)

于 2016-10-14T08:36:10.930 回答