Hello,
Has anyone been able to get ada_language_server working with nvim using an Alire project? By ‘working’ I mean use alire to fetch and build a project. Then be able to edit the project source files with language server protocol features (navigation, tooltips, etc.) with nvim.
I used alire to fetch and build the “magic_hat” project using:
alr get mage_hat
cd mage_hat_0.3.0_255dc372
alr build
For nvim, ALS has been installed and my ‘init.lua’ has the following config code in it:
require('lspconfig').als.setup{
settings = {
ada = {
projectFile = "mage_hat.gpr"
}
}
}
When I open the ‘mage_hat.adb’ which is in the src folder of the mage_hat alire project I would expect the ALS to be operational but I am seeing errors in the ALS logs:
[ALS.MAIN] On_DidOpenTextDocument_Notification: file:///home/nintendo/Desktop/mage_hat_0.3.0_255dc372/src/mage_hat.adb
[ALS.IN] {"id":2,"params":{"textDocument":{"uri":"file:\/\/\/home\/nintendo\/Desktop\/mage_hat_0.3.0_255dc372\/src\/mage_hat.adb"}},"jsonrpc":"2.0","method":"textDocument\/semanticTokens\/full"}
[ALS.MAIN] Document_Tokens_Full_Request: Request 2 file:///home/nintendo/Desktop/mage_hat_0.3.0_255dc372/src/mage_hat.adb
[ALS.MAIN.EXCEPTIONS] Unexpected exception: raised GNATCOLL.PROJECTS.INVALID_PROJECT : gnatcoll-projects.adb:7714
_ALS.MAIN.EXCEPTIONS_ [/home/nintendo/.local/share/nvim/mason/bin/../../../../..//.local/share/alire/builds/gnatcoll_23.0.0_29478a20/30653702b467e53c8eee88abe2cde92767b6a0290a3d01a6e2dca2a07b06501b/lib/gnatcoll/relocatable/libgnatcoll.so.23.0.0 ]
_ALS.MAIN.EXCEPTIONS_ 0x7d8000a41d02 gnatcoll__projects__load at ???
_ALS.MAIN.EXCEPTIONS_ [/home/nintendo/.local/share/nvim/mason/bin/ada_language_server]
_ALS.MAIN.EXCEPTIONS_ 0x11c7b5a Lsp.Ada_Handlers.Load_Project at lsp-ada_handlers.adb:4877
_ALS.MAIN.EXCEPTIONS_ 0x116379b Lsp.Ada_Handlers.On_Didchangeconfiguration_Notification at lsp-ada_handlers.adb:4492
_ALS.MAIN.EXCEPTIONS_ 0xe9ed6e Lsp.Messages.Server_Notifications.Visit at lsp-messages-server_notifications.adb:55
_ALS.MAIN.EXCEPTIONS_ 0x10a5c6d Lsp.Servers.Processing_Task_Type.Process_Message at lsp-servers.adb:1198
_ALS.MAIN.EXCEPTIONS_ 0x10a52b6 Lsp.Servers.Processing_Task_TypeT at lsp-servers.adb:1291
_ALS.MAIN.EXCEPTIONS_ [/home/nintendo/.local/share/nvim/mason/bin/../../../../..//.local/share/alire/toolchains/gnat_native_13.2.2_a27fd794/lib/gcc/x86_64-pc-linux-gnu/13.2.0/adalib/libgnarl-13.so]
_ALS.MAIN.EXCEPTIONS_ 0x7d8000cc5438 System.Tasking.Stages.Task_Wrapper at s-tassta.adb:1211
_ALS.MAIN.EXCEPTIONS_ [/lib/x86_64-linux-gnu/libc.so.6]
_ALS.MAIN.EXCEPTIONS_ 0x7d7ffea94ac1
_ALS.MAIN.EXCEPTIONS_ 0x7d7ffeb2684e
_ALS.MAIN.EXCEPTIONS_ 0xfffffffffffffffe
[ALS.MAIN] Loading the implicit project
[ALS.MAIN] Show_Message: Unable to load project file: /home/nintendo/Desktop/mage_hat_0.3.0_255dc372/mage_hat.gpr
_ALS.MAIN_ mage_hat.gpr:2:06: imported project file "mage.gpr" not found
_ALS.MAIN_ mage_hat.gpr:17:32: unknown package or project "Mage"
_ALS.MAIN_ mage_hat.gpr:17:32: wrong expression kind for attribute "switches"
_ALS.MAIN_ mage_hat_config.gpr:2:06: imported project file "mage.gpr" not found
_ALS.MAIN_ mage_hat_config.gpr:2:06: imported by "/home/nintendo/Desktop/mage_hat_0.3.0_255dc372/config/mage_hat_config.gpr"
_ALS.MAIN_ mage_hat_config.gpr:2:06: imported by "/home/nintendo/Desktop/mage_hat_0.3.0_255dc372/mage_hat.gpr"
[ALS.OUT] {"jsonrpc":"2.0","method":"window/showMessage","params":{"type":1,"message":"Unable to load project file: /home/nintendo/Desktop/mage_hat_0.3.0_255dc372/mage_hat.gpr\nmage_hat.gpr:2:06: imported project file \"mage.gpr\" not found\nma ge_hat.gpr:17:32: unknown package or project \"Mage\"\nmage_hat.gpr:17:32: wrong expression kind for attribute \"switches\"\nmage_hat_config.gpr:2:06: imported project file \"mage.gpr\" not found\nmage_hat_config.gpr:2:06: imported by \"/home/n intendo/Desktop/mage_hat_0.3.0_255dc372/config/mage_hat_config.gpr\"\nmage_hat_config.gpr:2:06: imported by \"/home/nintendo/Desktop/mage_hat_0.3.0_255dc372/mage_hat.gpr\"\n"}}
[ALS.MAIN] RegisterCapability_Request: Request 2 1
[ALS.MAIN] In Text_Document_Did_Open
[ALS.MAIN] Uri : file:///home/nintendo/Desktop/mage_hat_0.3.0_255dc372/src/mage_hat.adb
[ALS.OUT] {"jsonrpc":"2.0","id":2,"method":"client/registerCapability","params":{"registrations":[{"id":"rf","method":"textDocument/rangeFormatting","registerOptions":{"documentSelector":["ada"]}}]}}
[ALS.MAIN] Finished Text_Document_Did_Open
[ALS.MAIN] Publish_Diagnostics: file:///home/nintendo/Desktop/mage_hat_0.3.0_255dc372/src/mage_hat.adb 1
[ALS.OUT] {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/nintendo/Desktop/mage_hat_0.3.0_255dc372/src/mage_hat.adb","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character" :0}},"severity":1,"source":"project","message":"Project file has error and can't be loaded."}]}}
[ALS.MAIN] SemanticTokens: Response 2 835
The errors in the ALS logs are similar to the errors I get if I try to build mage hat in the root folder without using Alire:
~/Desktop/mage_hat_0.3.0_255dc372$ gprbuild
using project file mage_hat.gpr
mage_hat.gpr:2:06: imported project file "mage.gpr" not found
mage_hat.gpr:17:32: unknown package or project "Mage"
mage_hat.gpr:17:32: wrong expression kind for attribute "switches"
mage_hat_config.gpr:2:06: imported project file "mage.gpr" not found
mage_hat_config.gpr:2:06: imported by "/home/nintendo/Desktop/mage_hat_0.3.0_255dc372/config/mage_hat_config.gpr"
mage_hat_config.gpr:2:06: imported by "/home/nintendo/Desktop/mage_hat_0.3.0_255dc372/mage_hat.gpr"
gprbuild: "mage_hat.gpr" processing failed
Any ideas would be greatly appreciated.