Coding in Vala with Visual Studio Code

Visual Studio Code is Microsoft's little brother to the full Visual Studio. It is Open Source and can be found on GitHub: Visual Studio Code.

All plugins can be installed via the in-IDE plugin management system. If you open a Vala file, Visual Studio Code will even suggest to you the Vala-code plugin to install.

Syntax Highlighting

Syntax highlighting via the Vala plugin.

Code Formatting

Code formatting via the VSCode uncrustify plugin.


Debugging can be done with either GDB(demo video) or LLDB.

If you want to use GDB, you can do this with the vscode-cpptools plugin.

If you want to use LLDB, there are 2 options: CodeLLDB and code-debug

I personally had the most success with CodeLLDB.

Caveat – mangling of C-files

Due to how code lines are annotated in the C-files generated by Vala, the debugging functionality will only work on Vala-files.

Some Vala statements result in multiple C-lines. Currently, the first C-line will be annotated with the corresponding Vala code line, while the subsequent line(s) will be annotated with their C-lines. However, the annotations (created by Vala) are not on the same format:

  • The Vala code line hints have absolute paths.
  • The C-Code line hints have only filename.

The result is that VS Code will complain about not being able to find the C-files. You have 3 options:

  • Ignore the issue and get the pop ups from VS Code that it cannot find the files.
  • Mangle the C-files to correct the path
  • Mangle the C-files to delete the C-line hints.

If you choose to delete the C-Line hints or just ignore the issue, the result in debugging will be the same: You will be able to step throug the Vala code, but sometimes the IDE will jump "randomly" back and forth between Vala lines. I guess this is a result of how Valac structures it's generated C-code, how allocation / de-allocation of stuff happens, and how the code is optimised by the compiler.

If you choose to mangle the C-files (either way), it should be done in the build process. Depending on the build system of the project you are working on, you may be able to do a "nice and clean" scripting job between the call of the Vala compiler and the C-compiler. Personally, I just resorted to wrap my Vala compiler in a script that a) called the original Vala compiler, then b) mangled the C-files afterwards.

For further info, see this bug issue: Bug 734953 - The #line directive to c file doesn't include the path

  • – March 2018

Projects/Vala/Tools/VisualStudioCode (last edited 2020-04-23 16:27:30 by PrincetonFerro)