Visual Studio Code extension for a Vala Language Server
Note: This extension (as well as the associated language server) is deprecated in favor of the vala-vscode extension which is much more actively developed. It will be unpublished on september 1, 2020.
Client extension for this Language Server for the Vala language: https://github.com/philippejer/vala-language-server-alpha
Note that the syntax highlighting in the example below is provided by this extension: https://marketplace.visualstudio.com/items?itemName=philippejer.vala-grammar
Supported language server features
The following features work decently well:
- Go to definition (code navigation)
- Mouse hover (symbol declaration)
- Document symbols (outline)
- Find references / references code lens / symbol rename (rename support is limited, use with care)
- Code completion (crude and hack-ish but still fairly fast and usable in common situations)
Building the extension and installing manually
Usually these steps do the trick:
- Requires VSCode Extension Manager:
npm i -g vsce
This will produce a
vala-language-client-x.x.x.vsix which can then be installed manually with
A common issue is that the language server requires Meson 0.50+ in the
PATH and that the build directory needs to exist (the server uses the intropection feature of Meson to determine the source files and compiler switches).
2019-10-20: A fallback is now available by adding a
vala-language-server.json configuration file under the project root directory. This file will be detected and used to configure the list of sources files and/or directories and the compiler parameters (it is possible to simply copy the Vala compiler command line from e.g.
compile_commands.json). An example configuration can be found here.
Tiny completion snippets
For some reason, a still unresolved issue in VSCode is the tiny completion snippets, see this issue.
A "dirty" but functional solution is to use this extension to load a custom CSS, with the following configuration:
Do not forget to restart VSCode as admin and run the "Reload Custom CSS and JS" command.
Of course, it is possible to download the file locally to tweak the size of the popup and then use a file URI like so:
There are a few useful configuration settings:
vls.trace.server ("off"|"messages"|"verbose") -> Traces the communication between VS Code and the language server.
vls.serverPath (string) -> Name or full path to the language server executable (not required if in the
vls.logLevel ("off"|"warn"|"info"|"debug"|"silly") -> Log level for the language server itself.
vls.methodCompletionMode ("off"|"space"|"nospace") -> Enables insertion of parentheses in method completion (with or without a space).
vls.referencesCodeLensEnabled (true|false) -> Enables/disables references code lens.
vls.minimalCodeCheckEnabled (true|false) -> Requires the experimental compiler branch: Enables/disables minimal code checking (disables flow analysis for things like unused variables etc.).
Other non-specific but related settings:
editor.wordBasedSuggestions (true|false) -> set to false to avoid having text-based completion when the server cannot provide completion (confusing).
editor.quickSuggestionsDelay (milliseconds) -> can be set to some high value to effectively disable the automatic completion popup for global symbols (completion can then be invoked on demand via the CTRL+SPACE shortcut).
editor.suggestOnTriggerCharacters (true|false) -> Can be set to false to disable the automatic completion popup when the '.' character is typed (completion can then be invoked on demand via the CTRL+SPACE shortcut).
editor.hover.delay (milliseconds) -> The default value of 300 milliseconds can be a little too low.
As an example, personal configuration:
VLS: Restart Server -> restarts the server if it stops working for some reason