Autocompletion with VS Code


Please read tips for efficient and successful posting and posting code

_ROOT Version: 5.34
_Platform: Mac & Linux Server (SSH)
Compiler: Not Provided


Hey everyone,

I always used vim as editor of choice. This is not very convenient to me because I did not made use of the additional packages which are available. I prefer an IDE.
As currently used editor, I switched to Visual Code (Version 1.42) with the C/C++ add-on. There, I can make use of the autocompletion with IntelliSense.
Nevertheless, typing ROOT macros is not supported. Already defined Tvariables are not recognised.
Can you tell me, if there is a possibility to include the ROOT include libraries and the compiler flags to access this functionality? I guess, the “includePath” variable in the system has to be appended, but how?

Furthermore, I work on a server via SSH. Thus, I can use my local editor to edit the files on the remote machine. Which changes do I have to apply there?
Maybe you already found a suitable solution. If you need any further information, please give me a hint where to find them.
Thanks in advance!

Cheers,
Christoph

Please see the doc of Visual Studio Code - all I remember is that there are multiple ways to set this.

For remote editing you could use for instance sshfs.

Axel.

Finally, I found a solution which I want to mention here.
I am sure, others will deal with a similar problem. It might be explained elsewhere, if you read the docs carefully, but for completeness, I will summarise it specifically for ROOT.

In Visual Studio Code, you can edit the setting as explained here:
According my previous assumption, you need to adjust a “settings.json” file (There are different ones according to your preferred deepness of changes). If you have found your ROOT library files, you need to include the link into the settings.json file as seen in this screenshot

2 Likes

That is for sure one way of doing it.

You might be also interested in the cmake-tools extension!
If your code is build with CMake you can have it generate a compile_commands.json file that the extension can pass to Intellisense and setup all the include paths for all the files in your project accordingly and automatically.
This is extremely helpful if ROOT is not your only dependency, since in this way you don’t have to update your settings.json every time you include a new dependency in your project.

Cheers,
Valerio

1 Like

Putting root include path into C_Cpp.default.includePath might be too brutal. I’d rather put it into per-workspace .vscode/c_cpp_properties.json.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.