AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
226 stars 54 forks source link

Which env variables are required ? #1137

Closed NicoPy closed 1 year ago

NicoPy commented 1 year ago

When launched from outside a Alire terminal ALS shows GPR PATH: at startup. When launched from a Alire terminal, ALS shows GPR_PATH:xxx whith xxx set to the content of GPR_PROJECT_PATH env variable. Is it required to set GPR_PROJECT_PATH env variable ?

Also, are other env variables set by Alire required ?

AnthonyLeonardoGracio commented 1 year ago

Hello @NicoPy,

GPR_PROJECT_PATH is an environment variable used to search for imported projects (see here for more info).

If you are not using Alire, you will need to set this variable when importing projects using base names instead of absolute or relative paths (e.g: when using with "gnatcoll"; in a .gpr file).

Regards,

reznikmm commented 1 year ago

ALS checks ALIRE=True env to see if alire was activated. If so it skips alr execution. Beside this only gprbuild related variables (like GPR_PROJECT_PATH) are used.

NicoPy commented 1 year ago

In the case that ALIRE is not set but an Alire project is detected (ALS run outside Alire terminal), does ALS automatically set GPR_PROJECT_PATH ?

reznikmm commented 1 year ago

@NicoPy Yes, ALS sets the GPR_PROJECT_PATH, but this settings is visible only in subprocess of ALS, such as gnatls. It doesn't influence VS Code terminals or debugger for example, because they are launched by VS Code, not by ALS itself. Auto-detected tasks (such as Build current project, or Check current file) were modified to take alr environments into account.

NicoPy commented 1 year ago

I'm trying to find a solution to a problem I have : I'm trying to use ALS with Eclipse editor. I'm able to make it work correctly with one Alire project (by running Eclipse from an Alire terminal). But as Eclipse is a multi-project editor, I'd like that each project uses it's own ALS configuration. That is currently not possible. ALS being able to determine it's configuration from an Alire project (when env variables are not set) would be a solution.

Note : To be more specific, the problem is related to the ALS search path for auto-completion/documentation. With multiple projects, the ALS search path is not project specific. I know ALS has been designed for a single project editor but I have use cases where a multi-project editor is really helpful. For example when designing a system where part of the software runs on a PC and another part runs of an embedded target.

AnthonyLeonardoGracio commented 1 year ago

Hello @NicoPy,

Why not spawn multiple ALS instances, one per project?

NicoPy commented 1 year ago

Currently, the Eclipse plugin managing the language server spawns one ALS per open file in the editor. When Eclipse is launched from a Alire terminal, all ALS instances use the same configuration. When Eclipse is launched outside a Alire terminal, all ALS instances also use the same (default ?) configuration.

Here, configuration refers to source file locations which is set by GPR_PROJECT_PATH if I have correctly understood how all this works.

From what I have observed, ALS reports GPR_PROJECT_PATH is set when run from a Alire terminal but not set when run outside a Alire terminal.

AnthonyLeonardoGracio commented 1 year ago

One server per file? That's not expected at all, and very different from what VS Code or GNAT Studio does... Note that we have tried to integrate the ALS to the Eclipse ecosystem with our GNATbench plugin, and we failed because the LSP 4 Eclipse plugin was not mature enough.

Regards,

NicoPy commented 1 year ago

One server per file? That's not expected at all, and very different from what VS Code or GNAT Studio does...

I've double checked and that's not true. There is one server spawned per project. However, sometimes (quite often ?), when switching from one editor to another one, another server is launched. This made me think badly.

Note that we have tried to integrate the ALS to the Eclipse ecosystem with our GNATbench plugin, and we failed because the LSP 4 Eclipse plugin was not mature enough.

Yes, LSP 4 Eclipse is not perfect.