alire icon indicating copy to clipboard operation
alire copied to clipboard

Adds workspace generation as part of init.

Open pyjarrett opened this issue 3 years ago • 12 comments
trafficstars

I've found generating Visual Studio Code workspaces for projects for use with the Language Support for Ada plugin very helpful. I wasn't sure if you wanted this hidden behind an option, or if this was even a good idea in the general case.

When I've done this, I do: alr config --global --set editor.cmd "code.cmd workspace.code-workspace" to be able to easily swap between projects.

pyjarrett avatar Jan 02 '22 04:01 pyjarrett

First try

First try :P /s

pyjarrett avatar May 04 '22 22:05 pyjarrett

@Fabien-Chouteau I guess there's nothing blocking this one?

mosteo avatar May 09 '22 11:05 mosteo

I am not a huge fan of having this extra file just for VScode. But I wont block the PR.

Fabien-Chouteau avatar May 09 '22 12:05 Fabien-Chouteau

Perhaps we can add a config option to disable it?

mosteo avatar May 09 '22 12:05 mosteo

Up to you and @pyjarrett. The risk with an option is that some people won't see it.

Fabien-Chouteau avatar May 09 '22 12:05 Fabien-Chouteau

My intent was to move towards first-class support of VS code since it's an incredibly common editor on all platforms, and would minimize friction of people to try Ada + Alire very easily. Anecdotally, nearly everyone I know has an VS Code install.

The continuation of this PR would be a setting up .vscode/ along with launch.json and tasks.json from the Ada Language Server's getting started page. For people trying out a language and tooling, basic IDE and build/run/debug support should work right out of the box. Asking people to install a separate editor for a good experience is a big ask, especially since GNAT studio isn't available through Alire yet.

Maybe a configuration option on first Alire run would set the preferred editor between GNAT studio and VS code and set this?

@Fabien-Chouteau , I understand why you don't want this specific file, which is why I had asked about the question on gitter about alr install, since my other idea had been to make this a post-setup tool you could run easily.

pyjarrett avatar May 09 '22 12:05 pyjarrett

@reznikmm might want to be involved in this discussion as well.

pyjarrett avatar May 09 '22 12:05 pyjarrett

My intent was to move towards first-class support of VS code since it's an incredibly common editor on all platforms, and would minimize friction of people to try Ada + Alire very easily. Anecdotally, nearly everyone I know has an VS Code install.

I fully agree that we have to up our VS Code game :+1:

The continuation of this PR would be a setting up .vscode/ along with launch.json and tasks.json from the Ada Language Server's getting started page.

This is typically the kind of stuff I am afraid of. Extra files that will need to be maintained as the Ada plugin or VScode evolve.

For people trying out a language and tooling, basic IDE and build/run/debug support should work right out of the box. Asking people to install a separate editor for a good experience is a big ask,

100% :+1:

especially since GNAT studio isn't available through Alire yet.

That may change in the near future ;)

Maybe a configuration option on first Alire run would set the preferred editor between GNAT studio and VS code and set this?

@Fabien-Chouteau , I understand why you don't want this specific file, which is why I had asked about the question on gitter about alr install, since my other idea had been to make this a post-setup tool you could run easily.

What about this: a new alr vscode command that generates the required dirs and files and then start VScode? The dirs and files would be added to the alr init .gitignore so that people know not to check them in. The generation of files from Alire would evolve as the plug-in/VScode evolves.

We could also rename alr edit into alr gnatstudio with the option to download and install GS if not available already. alr edit is not so useful now that we have alr exec.

Fabien-Chouteau avatar May 09 '22 16:05 Fabien-Chouteau

What about this: a new alr vscode command that generates the required dirs and files and then start VScode? The dirs and files would be added to the alr init .gitignore so that people know not to check them in. The generation of files from Alire would evolve as the plug-in/VScode evolves.

We could also rename alr edit into alr gnatstudio with the option to download and install GS if not available already. alr edit is not so useful now that we have alr exec.

I think Alire should not get special commands for specific editors (that would pollute the commands list), but rather have a generic command that uses 1) a subcommand or --option=<name>, or 2) autodetects installed editors like GPS, vscode, nvim, emacs (using the presence of certain files in the user's home folder), or 3) use some configuration option.

About Generate_VSCode_Workspace... does Alire have more code that prints JSON? Another option may be to put the JSON in some .json file use the template stuff from GNATCOLL to generate the final JSON file.

Just my 2 cents.

onox avatar May 09 '22 20:05 onox

I think Alire should not get special commands for specific editors (that would pollute the commands list),

"Polution" of the command list doesn't seem like a strong argument to me. There are not many commands in Alire and we already have a system of categories to provide a clear list.

Now, if this is a shared concern, we can also go with:

  • alr edit --vscode
  • alr edit --gnatstudio

Or in the future add support for alr-something external commands like git has: alr something --plop = alr exec -- alr-something --plop

but rather have a generic command that uses 1) a subcommand or --option=<name>, or 2) autodetects installed editors like GPS, vscode, nvim, emacs (using the presence of certain files in the user's home folder), or 3) use some configuration option.

You can already do 1) with alr exec and if you add an alias it would be even more seamless. 2) we are unlikely to use the editor that users want in practice. I have all the editors that you mention installed but I only use GS for coding in Ada. 3) That's how the current alr edit works.

The difference here is that, unlike GNAT Studio, VS code requires special files to work.

About Generate_VSCode_Workspace... does Alire have more code that prints JSON? Another option may be to put the JSON in some .json file use the template stuff from GNATCOLL to generate the final JSON file.

Templated alr init or even template crates is an interesting feature. But for 10 lines of code I think the current implementation is ok.

Fabien-Chouteau avatar May 10 '22 08:05 Fabien-Chouteau

@reznikmm why not define Alire tasks in the AdaCore vscode plugin?https://code.visualstudio.com/api/extension-guides/task-provider

Fabien-Chouteau avatar May 17 '22 15:05 Fabien-Chouteau

What these tasks should do exactly?

reznikmm avatar May 18 '22 10:05 reznikmm