austin----- / code-gnu-global

Provide Intellisense for C/C++ with the help of the GNU Global tool in Visual Studio Code
153 stars 67 forks source link

Go to Definition for functions declared outside the project folder #8

Open rei-vilo opened 8 years ago

rei-vilo commented 8 years ago

I'm using the procedure described to add folders and index files external to the project folder as per 2.3 Applied usage in the GNU GLOBAL Source Code Tag System tutorial.

$ cd project/folder
$ (cd /external/path1; gtags) 
$ (cd /external/path2; gtags) 
$ export GTAGSLIBPATH=/external/path1:/external/path2

Let's consider function_in_path1() declared in file /external/path1/functions1.cpp with the corresponding header. The main.cpp includes /external/path1/functions1.h and calls function_in_path1().

When pointing on function_in_path1() and calling the contextual menu, the options Go to Definition, 'Peek DefinitionandFind All Referencesare displayed but none of them actually works. However,global function_in_path1` returns the right path and file.

$ cd project/folder $ global function_in_path1 ../../../../external/path1/functions1.cpp

Thank you!

austin----- commented 8 years ago

Did you run code from the same shell after GTAGSLIBPATH is exported?

rei-vilo commented 8 years ago

Good point!

I launched VSC as a standard app on my Mac, but I created the indexes with gtags and set the GTAGSLIBPATH variable on a Terminal window.

So the question might be now, how to set the GTAGSLIBPATH variable within VSC.

austin----- commented 8 years ago

As a workaround, refer to https://code.visualstudio.com/Docs/editor/setup on how to setup vscode to launch from command line on OS X.

I will probably add an extension setting to set this env variable within vscode.

rei-vilo commented 8 years ago

Thank you for the pointer!