Open rrthomas opened 1 year ago
VLS needs a way of understanding your project's compiler flags and we get this through meson.build
or compile_commands.json
. Makefiles aren't currently supported.
Thanks; did I miss that being documented somewhere?
Also, that doesn't explain to me why VAPIs installed with the compiler (like Posix
) are not found.
Without compiler flags, libvala doesn't know whether you're using Posix profile, so the VAPI won't be included. In this case, the errors you see should be exactly the same as if you ran valac
on the file with no other arguments.
Thanks; did I miss that being documented somewhere?
It may not be documented as well as it could be:
https://github.com/vala-lang/vala-language-server/blob/3b5fe941bea6ecd5c8fcb84930c40b8582eea165/README.md?plain=1#L75-L80 https://github.com/vala-lang/vala-language-server/blob/master/README.md#editors
We try to emit warnings in your editor if we can't find your compiler args. This could be improved:
Ah yes, good point about the compiler flags. Thanks for the documentation pointers. Is there some way I can pass the compiler flags to VLS manually? (So then I could set them in my Codium workspace, potentially.)
Is there some way I can pass the compiler flags to VLS manually?
You can write your own compile_commands.json
file and stick it in your project root. But you might find that a bit cumbersome.
Outside of switching to Meson (which is what the vast majority of Vala projects use), this would be a feature request. I can think of a few possibilities:
valac_flags.txt
file like what clang does. Downsides: isn't very robust and will only work with very simple projects.valac
to spit out a compile_commands.json
when run. So you can just add -gencc
to your build script. Downsides: as this would be an upstream change, it wouldn't solve your problem until the next Vala release.Something simple would be nice, like 2. In this case I would have been quite happy to write a quick per-project config file, and have that minor maintenance burden. I think at this stage there probably won't be many new autotools Vala projects (although automake has good Vala support).
You might be interested to know that in the end I decided to use Python instead of Vala for this project: I started translating C into Vala, but while this was as easy as ever, I realised that in this case it would be no harder to rewrite the code from scratch than to translate some highly-involved C into "good" Vala (translating it into "bad, C-style" Vala would be easy, but not great progress). The final choice (of Python), was just because I am more familiar with writing this kind of (command-line, POSIXy) code in (typed) Python right now, and I find it quicker to write than Vala.
Describe the bug
I am fairly new to VLS/vala-vscode (I was trying them in Codium to upgrade my Vala editing experience).
I cannot see where the VAPI path is set: I can't find any sort of configuration or command-line option I could be passing to
vala-language-server
.I am getting warnings from Codium that "Posix" cannot be found, which baffles me, as of course it is installed as part of Vala; and there's no problem finding "GLib":
Also, a few VAPIs in the same directory as my source code are not found.
After some more research, I tried turning on debug in VLS, which gave me the following:
It does not find any other GIR information, and I notice that it only seems to find namespaces mentioned in GIRs, not in VAPIs. I also found this issue: https://github.com/vala-lang/vala-language-server/issues/220 but the symptoms I am getting are not the same: my Vala source file is being built, just VLS is not (apparently) finding the namespace information.
Software OS and version (e.g. Ubuntu 20.04): Ubuntu 22.04 Code editor (e.g. VSCode): Codium Vala Language Server (e.g. git commit, or PPA/AUR version): 3b5fe941 Vala version (
valac --version
): 0.56.0To Reproduce Source code repo: https://github.com/rrthomas/mmv/tree/vala
Steps to reproduce the behavior:
mmv.vala
.Thanks very much for VLS! I already did some useful refactoring.