# Setting up the Ada Language Server in VIM

**URL:** <https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861>\
**Category:** General\
**Created:** [March 6, 2025, 10:59am UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861 "2025-03-06T10:59:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)\
**Post date:** [March 6, 2025, 10:59am UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/1 "2025-03-06T10:59:50Z")

</div>

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](https://github.com/AdaCore/ada_language_server/issues/1243) getting this working in Ada.

This is what I want to achieve:  
check out a repo like [ALS](https://github.com/AdaCore/ada_language_server) and open a given file (like [this](https://github.com/AdaCore/ada_language_server/blob/da46ea594b538f49127c01eb977c37fb583699dc/testsuite/ada_lsp/T713-012.completion.generic_package/src/foo.adb) 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](https://github.com/AdaCore/ada_language_server/blob/da46ea594b538f49127c01eb977c37fb583699dc/doc/settings.md) and so I have added this in the directory I found the closest gpr file:

```ada
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.

---

<div class="post-metadata">

**Author:** ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)\
**Post date:** [March 6, 2025, 11:00am UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/2 "2025-03-06T11:00:30Z")

</div>

Typical output from the log files

```ada
==> /home/oscko/.als/ada_ls_log.2025-03-06T104750.56864.log <==
[ALS.MAIN] Exception while handling LSP.SERVER_REQUESTS.RENAME.REQUEST
[ALS.MAIN] raised CONSTRAINT_ERROR : gpr2-project-tree.ads:501 access check failed
_ALS.MAIN_ [/home/oscko/bin/ada_language_server]
_ALS.MAIN_ 0x1d17706
_ALS.MAIN_ 0x2046e13
_ALS.MAIN_ 0x1db07a1
_ALS.MAIN_ 0x1ddc17d
_ALS.MAIN_ 0x1dd611b
_ALS.MAIN_ 0x1177af4
_ALS.MAIN_ 0x118157f
_ALS.MAIN_ 0x1d3e03b
_ALS.MAIN_ 0x3e93c85
_ALS.MAIN_ [/lib/x86_64-linux-gnu/libc.so.6]
_ALS.MAIN_ 0x7f40b7eb9aa2
_ALS.MAIN_ 0x7f40b7f46c3a
_ALS.MAIN_ 0xfffffffffffffffe
[ALS.MAIN] [/home/oscko/bin/ada_language_server]
_ALS.MAIN_ 0x1d17706
_ALS.MAIN_ 0x2046e13
_ALS.MAIN_ 0x1db07a1
_ALS.MAIN_ 0x1ddc17d
_ALS.MAIN_ 0x1dd611b
_ALS.MAIN_ 0x1177af4
_ALS.MAIN_ 0x118157f
_ALS.MAIN_ 0x1d3e03b
_ALS.MAIN_ 0x3e93c85
_ALS.MAIN_ [/lib/x86_64-linux-gnu/libc.so.6]
_ALS.MAIN_ 0x7f40b7eb9aa2
_ALS.MAIN_ 0x7f40b7f46c3a
_ALS.MAIN_ 0xfffffffffffffffe

==> /home/oscko/.als/ada_ls_log.2025-03-06T104750.56691.log <==
[ALS.PROJECT] GPR2 messages after load:
   [ALS.PROJECT] embedded_kb/kb: warning: can't find a toolchain for the following configuration: language 'Ada', target 'x86_64-linux', default runtime
[ALS.PROJECT] Updating project sources
[ALS.PROJECT] GPR2 messages after updating sources:
   [ALS.PROJECT] embedded_kb/kb: warning: can't find a toolchain for the following configuration: language 'Ada', target 'x86_64-linux', default runtime
[ALS.PROJECT] Prepend Context Id: file:///home/oscko/dev/ada_language_server/testsuite/ada_lsp/declaration.overridings_on_usage/default.gpr
[ALS.PROJECT] Project status after loading:
_ALS.PROJECT_ (PROJECT_TYPE => CONFIGURED_PROJECT,
_ALS.PROJECT_ STATUS => VALID_PROJECT_WITH_WARNING,
_ALS.PROJECT_ PROJECT_FILE => {GNATCOLL.VFS.VIRTUAL_FILE object},
_ALS.PROJECT_ MISSING_ADA_RUNTIME => TRUE,
_ALS.PROJECT_ GPR2_MESSAGES => {GPR2.LOG.OBJECT object},
_ALS.PROJECT_ ALIRE_MESSAGES => {VSS.STRING_VECTORS.VIRTUAL_STRING_VECTOR object})
[ALS.MAIN] Creating fallback context
[ALS.MAIN] In Message_Handler Text_Document_Did_Open URI:
[ALS.MAIN] file:///home/oscko/dev/ada_language_server/testsuite/ada_lsp/declaration.overridings_on_usage/class_definition.subclass.adb
[ALS.MAIN] Out Message_Handler Text_Document_Did_Open

```

---

<div class="post-metadata">

**Author:** ![mgrojo](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/mgrojo/32/15_2.png) [@mgrojo](https://forum.ada-lang.io/u/mgrojo)\
**Post date:** [March 6, 2025, 8:11pm UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/3 "2025-03-06T20:11:07Z")

</div>

> ```ada
> [ALS.PROJECT] embedded_kb/kb: warning: can't find a toolchain for the >following configuration: language 'Ada', target 'x86_64-linux', default runtime
> 
> ```

I think you might have this problem:

> <https://github.com/AdaCore/ada_language_server/issues/1160>
>
> I get a strange error message when I try to compile my file. If I build using th…e build command in Visual Studio, I get the following error:
> 
> \` can't find a toolchain for the following configuration\`
> 
> I also get an error message in the problems tab area:
> 
> \`imported project file "pico\_bsp.gpr" not found\`
> 
> However, it compiles successfully when I build from VS Code's terminal using \*alr build\*. If I go back and execute the build command again, I get:
> 
> \`\`\`
> gprconfig: can't find a toolchain for the following configuration:
> gprconfig: language 'ada', target 'arm-eabi', runtime 'light-cortex-m0'
> cpu\_controller\_config.gpr:2:06: imported project file "pico\_bsp.gpr" not found
> cpu\_controller\_config.gpr:2:06: imported by "/Users/joebeazelman/Projects/Repos/cpu\_controller/config/cpu\_controller\_config.gpr"
> cpu\_controller\_config.gpr:2:06: imported by "/Users/joebeazelman/Projects/Repos/cpu\_controller/cpu\_controller.gpr"
> gprbuild: "cpu\_controller.gpr" processing failed
> \`\`\`

---

<div class="post-metadata">

**Author:** ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)\
**Post date:** [March 7, 2025, 12:22pm UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/4 "2025-03-07T12:22:44Z")

</div>

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:

```ada
_ALS.PROJECT_ MISSING_ADA_RUNTIME => TRUE,

```

Will report back.

---

<div class="post-metadata">

**Author:** ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)\
**Post date:** [March 7, 2025, 2:02pm UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/5 "2025-03-07T14:02:38Z")

</div>

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:

```ada
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:

 ![image](https://forum.ada-lang.io/uploads/default/original/1X/f1968562d61085d7095eafcf110a3f942212c38a.png)

The logs still show this as failing when I try to rename or go to definition:

```ada
[ALS.PROJECT] Prepend Context Id: file:///home/oscko/dev/ada_language_server/gnat/lsp_server.gpr
[ALS.PROJECT] Project status after loading:
_ALS.PROJECT_ (PROJECT_TYPE => CONFIGURED_PROJECT,
_ALS.PROJECT_ STATUS => VALID_PROJECT_WITH_WARNING,
_ALS.PROJECT_ PROJECT_FILE => {GNATCOLL.VFS.VIRTUAL_FILE^@ object},
_ALS.PROJECT_ MISSING_ADA_RUNTIME => FALSE,
_ALS.PROJECT_ GPR2_MESSAGES => {GPR2.LOG.OBJECT^@ object},
_ALS.PROJECT_ ALIRE_MESSAGES => {VSS.STRING_VECTORS.VIRTUAL_STRING_VECTOR^@ object})
[ALS.MAIN] Creating fallback context
[ALS.MAIN] In Message_Handler Text_Document_Did_Open URI:
[ALS.MAIN] file:///home/oscko/dev/ada_language_server/testsuite/ada_lsp/called_by/p.adb
[ALS.MAIN] Out Message_Handler Text_Document_Did_Open
[ALS.MAIN] Exception while handling LSP.SERVER_REQUESTS.RENAME.REQUEST
[ALS.MAIN] raised CONSTRAINT_ERROR : gpr2-project-tree.ads:501 access check failed
_ALS.MAIN_ [/home/oscko/bin/ada_language_server]
_ALS.MAIN_ 0x1d17706
_ALS.MAIN_ 0x2046e13
_ALS.MAIN_ 0x1db07a1
_ALS.MAIN_ 0x1ddc17d
_ALS.MAIN_ 0x1dd611b
_ALS.MAIN_ 0x1177af4
_ALS.MAIN_ 0x118157f
_ALS.MAIN_ 0x1d3e03b
_ALS.MAIN_ 0x3e93c85
_ALS.MAIN_ [/lib/x86_64-linux-gnu/libc.so.6]
_ALS.MAIN_ 0x7fa994f0baa2
_ALS.MAIN_ 0x7fa994f98c3a

```

---

<div class="post-metadata">

**Author:** ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)\
**Post date:** [March 7, 2025, 2:14pm UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/6 "2025-03-07T14:14:29Z")

</div>

Nope, adding the [FSF builds of GNAT 14](https://github.com/alire-project/GNAT-FSF-builds/releases) (ensuring gcc-ada and gcc are in sync) and adding it to the PATH did nothing. GPR PATH still unset.

```ada
[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](https://github.com/alire-project/GNAT-FSF-builds/releases) and added that to the PATH as well. No difference. `grep GPR PATH ~/.als/ada_ls_*` still only shows empty hits:

```ada
[ALS.MAIN] GPR PATH:
[ALS.MAIN] GPR PATH:
[ALS.MAIN] GPR PATH:
[ALS.MAIN] GPR PATH:

```

---

<div class="post-metadata">

**Author:** ![mgrojo](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/mgrojo/32/15_2.png) [@mgrojo](https://forum.ada-lang.io/u/mgrojo)\
**Post date:** [March 7, 2025, 6:11pm UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/7 "2025-03-07T18:11:08Z")

</div>

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.

Have you followed the tutorial?

> **[Getting Started](https://github.com/AdaCore/ada_language_server/wiki/Getting-Started)**
>
> Server implementing the Microsoft Language Protocol for Ada and SPARK - AdaCore/ada\_language\_server

---

<div class="post-metadata">

**Author:** ![nerd\_type](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/nerd_type/32/530_2.png) [@nerd\_type](https://forum.ada-lang.io/u/nerd_type)\
**Post date:** [March 8, 2025, 6:03am UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/8 "2025-03-08T06:03:11Z")

</div>

I was able to get the Ada Langauge Server working with nvim by installing the ada-language-server package using the Mason nvim package manager.

After I installed the language server I added this to my init.lua:

```ada
require("lspconfig").ads_ls.setup {
  settings = {
      ada = {
         projectfile = ""
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)\
**Post date:** [March 10, 2025, 1:18pm UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/9 "2025-03-10T13:18:08Z")

</div>

@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:

```ada
❯ 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?!

For instance, trying a rename of `Do_Something` in [testsuite/ada\_lsp/completion.invisible.insert\_with\_clause.renamed\_units/bar.ads](https://github.com/AdaCore/ada_language_server/blob/5fa261b0f4904293bd096b89d4cc5b1f0cee1b46/testsuite/ada_lsp/completion.invisible.insert_with_clause.renamed_units/bar.ads) will fail with the above error about ` raised CONSTRAINT_ERROR : gpr2-project-tree.ads:501 access check failed`, but renaming in [source/ada/lsp-search.adb](https://github.com/AdaCore/ada_language_server/blob/5fa261b0f4904293bd096b89d4cc5b1f0cee1b46/source/ada/lsp-search.adb) works fine.

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/**`.

@nerd_type That’s pretty much [my config](https://github.com/fatso83/dotfiles/blob/afde07c02458c5048786fcba0a546b540e96b58d/common-setup/vim/dotvim/coc-settings.json#L19) already 🙂

---

<div class="post-metadata">

**Author:** ![simonjwright](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/simonjwright/32/11_2.png) [@simonjwright](https://forum.ada-lang.io/u/simonjwright)\
**Post date:** [March 10, 2025, 4:18pm UTC](https://forum.ada-lang.io/t/setting-up-the-ada-language-server-in-vim/1861/10 "2025-03-10T16:18:47Z")

</div>

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/`.
