I am new to Ada programming and just want to setup my editor with basic language support (go to definition, rename, etc). This has been quite frictionless with Javascript, Typescript, Python and Bash, for basic cases, but I am struggling getting this working in Ada.
This is what I want to achieve:
check out a repo like ALS and open a given file (like this and be able to
“Go to Definition”
“Rename”
etc
What kind of configuration do I need to add for this to work? It is not immediately obvious to me as a complete beginner to ADA what to add to the project specific config, if anything.
I did read about the settings and so I have added this in the directory I found the closest gpr file:
testsuite/ada_lsp/declaration.overridings_on_usage on HEAD (76c0255) [?]
$ cat .als.json
{
"projectFile": "default.gpr"
}
That did not seem to achieve anything. All operations still fail.
Thanks! I will check this out. It definitely seems like you are onto something, as I did not go that far down the error log list, but now I see this as well:
You were absolutely onto something! On my private mac, I got this working, rename and go to definition, but I was missing something on Ubuntu.
I only had alire and gnat studio installed, but did not have the standalone environment, so had to install that:
apt install gnat
apt install gprbuild
I now see _ALS.PROJECT_ MISSING_ADA_RUNTIME => FALSE, in the logs, but unlike on my mac, GPR PATH is unset. Not quite sure what to do there, but will check if installing the FSF builds work.
I am able to get feedback from the compiler inline, at least:
Nope, adding the FSF builds of GNAT 14 (ensuring gcc-ada and gcc are in sync) and adding it to the PATH did nothing. GPR PATH still unset.
[ALS.MAIN] ALS version: 26.0.202502240 ()
[ALS.MAIN] Initializing server ...
[ALS.MAIN] GPR PATH:
[ALS.MAIN] PATH: /home/oscko/.asdf/plugins/nodejs/shims:/home/oscko/.asdf/installs/nodejs/22.14.0/bin:/opt/gnat-x86_6
4-linux-14.2.0-1/bin:/home/oscko/gnatstudio/bin:...
Same errors, as well.
edit: I also downloaded the latest FSF GprBuild and added that to the PATH as well. No difference. grep GPR PATH ~/.als/ada_ls_* still only shows empty hits:
Forget about GPR PATH, that’s probably the value of the environment variables GPR_PROJECT_PATH or ADA_PROJECT_PATH. Mine is also empty, and that’s not a problem.
@mgrojo Thanks for the tutorial link. Since I was not using VS Code, I did not follow the tutorial, although that does not seem to matter all that much. I looked through the steps, and I could see nothing relevant there that I did not already do. Basically, all it says is to make sure the GNAT tooling is available on the PATH. Which it is:
❯ which gprbuild ; which gcc
/opt/gprbuild-x86_64-linux-24.0.0-2/bin/gprbuild
/opt/gnat-x86_64-linux-14.2.0-1/bin/gcc
I did make one interesting find, though: the Ada Language Server in Ubuntu is working, but only in parts of the source tree?!
Even stranger is that both of these files work fine (-ish - loads of other errors) with ALS on my macOS , using the same setup?! I have even compared pwd output to see if this mattered, but even when identical I still have issues with the files in testsuite/**.
macOS, ALS, Emacs, ada-ts-mode. I find that ALS can get confused if I ask it to handle code that isn’t accessed via the GPR; for example, a little sketch folder under tmp/ rather than src/.