AdaCore / ada_language_server

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

Project support (scenario) #1049

Open AlexandreMarkus opened 1 year ago

AlexandreMarkus commented 1 year ago

Would be great if scenario would be supported in VS Code. There is some extensions that uses dropdown menu in the status bar or you could add an icon in the activity bar with some options in there.

reznikmm commented 1 year ago

I agree. For now you can specify scenario variables in settings.

AlexandreMarkus commented 1 year ago

I agree. For now you can specify scenario variables in settings.

I do use 3 different scenario variables with multiple values in each. Then, depending on each value I choose, it will build something different. Not sure how I can use the current method efficiently. Do you think I can?

TamaMcGlinn commented 1 year ago

Note I requested the same thing here, in an alr issue. I wrote a plugin for this for NeoVim, which is equivalent to what we would need (but I have never written a VSCode plugin before).

A quickfix for VSCode that should but doesn't currently work, is to set your editor settings to read the project file from an environment variable; GPR_PROJECT_FILE is customary for this, and restart vscode but prepending the env variable so that you can quite quickly switch, for example GPR_PROJECT_FILE=foo.gpr vscode .

That should work if you just have a .vscode/settings.json with this:

{
    "ada.projectFile": "${env:GPR_PROJECT_FILE}"
}

The error message I get from als indicates that VSCode is not expanding the env variable like the docs say it should:

Unable to load project file: /home/tama/code/test_multigpr/${env:GPR_PROJECT_FILE} /home/tama/code/test_multigpr/${env:GPR_PROJECT_FILE} is not a regular file

By the way, test_multigpr may be useful to you for debugging this; a simple open source multiple gpr project where you can easily see if switching worked before Foo.Get_Foo has two different definitions for each gpr file.