Difference between revisions of "HowTo Use OpenFOAM with Visual Studio Code"

From OpenFOAMWiki
Line 12: Line 12:
 
# In VS Code, open the folder where you ran the setupVScodeFOAM command. Note that it does not matter whether the source files are in this folder or not.
 
# In VS Code, open the folder where you ran the setupVScodeFOAM command. Note that it does not matter whether the source files are in this folder or not.
  
Note that after doing the steps above  "Go to definition" or similar features will only work after ccls finished generating its cache. This process can take a while (see if there is a "ccls" process that heavily uses the cpu).
+
Note that after doing the steps above, "Go to definition" or similar features will only work after ccls finished generating its cache. This process can take a while (see if there is a "ccls" process that heavily uses the cpu).
  
 
For questions about this setup ask [mailto:volker.weissmann@gmx.de Volker Weißmann].
 
For questions about this setup ask [mailto:volker.weissmann@gmx.de Volker Weißmann].
  
 
If you find that "Go to Definition" or some other features do not work on some specific function, please file a bug report for the [https://github.com/MaskRay/vscode-ccls/issues ccls plugin].
 
If you find that "Go to Definition" or some other features do not work on some specific function, please file a bug report for the [https://github.com/MaskRay/vscode-ccls/issues ccls plugin].

Revision as of 00:10, 24 November 2020

The C++ language server (ccls) can read and analyze C++ source code to provide features like "Go to Definition" in many Editors. Because ccls needs to know how the files are compiled, you need to do a bit of configuration. This guide shows how to set this up for OpenFOAM in Visual Studio Code.

Please note, that this depends on OpenFOAM commits that still lie in the future. I will remove this note once the commits get approved.

  1. Install VS Code
  2. Install the ccls vs code extension
  3. Install bear
  4. Rebuild OpenFOAM and all your custom libraries that use wmake
  5. Run the command setupVScodeFOAM (you need to set the environment for that)
  6. In VS Code, open the folder where you ran the setupVScodeFOAM command. Note that it does not matter whether the source files are in this folder or not.

Note that after doing the steps above, "Go to definition" or similar features will only work after ccls finished generating its cache. This process can take a while (see if there is a "ccls" process that heavily uses the cpu).

For questions about this setup ask Volker Weißmann.

If you find that "Go to Definition" or some other features do not work on some specific function, please file a bug report for the ccls plugin.