alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
288 stars 49 forks source link

Add user specified IDE or Editor during the initialization process #1203

Open Joebeazelman opened 2 years ago

Joebeazelman commented 2 years ago

One feature that may greatly assist the onboarding process is offer the user the ability to automatically setup one or more of the supported Ada IDEs or Editors. After Alire completing the initialization process, Alr configures the necessary environment variables and or generates the appropriate files. It could also prompt the user to launch the crate after it's completed. There's many approaches, the simplest way is to add an option such as --ide which access from several Editors or IDEs such as VSCode or GNATStudio.

For VSCode, it can automatically create the .vscode directory and the launch.json and settings.json files needed. In addition, it would be helpful to install or suggest to the user useful extensions for Ada development such as debuggers and AdaCore's Ada Extension.

There are two ways of doing providing this support. By default, Alire can create an extension a file (.vscode/extensions.json). It doesn't install any extensions, but suggests them for installation:

{
    "recommendations": [
        "eg2.tslint",
        "dbaeumer.vscode-eslint",
        "msjsdiag.debugger-for-chrome"
    ]
}

The other way is to automatically install them automatically from VSCode's command-line:

$ code -h
Visual Studio Code 1.16.0

Usage: code [options] [paths...]

Options:
  --extensions-dir <dir>                                       Set the root path for extensions.
  --list-extensions                                            List the installed extensions.
  --show-versions                                              Show versions of installed extensions, when using --list-extension.
  --install-extension (<extension-id> | <extension-vsix-path>) Installs an extension.
  --uninstall-extension <extension-id>                         Uninstalls an extension.
  --enable-proposed-api <extension-id>                         Enables proposed api features for an extension.
  --disable-extensions                                         Disable all installed extensions.
Fabien-Chouteau commented 2 years ago

It could also prompt the user to launch the crate after it's completed.

I don't understand this part. Which alr command are you referring to here?

For VSCode, it can automatically create the .vscode directory and the launch.json and settings.json files needed.

I am against IDE specific files in the repositories/crates, we have the alire.toml and <crate>.gpr. In my opinion it's the VSCode plugin that has to be improved to understand those existing files.

Joebeazelman commented 2 years ago

It could also prompt the user to launch the crate after it's completed. I don't understand this part. Which alr command are you referring to

I meant issuing the alr edit after the crate has been initialized, assuming the default editor is also configured.

It maybe beyond the scope of Alire to configure an IDE, but the latest release of GnatStudio doesn't support MacOS, making the onboard process more difficult for MacOS users. Perhaps, it can configure the VSCode to be the default editor and create the initial suggested extensions settings so the user can download them without having to know of their existence or search for them. There's several extensions with the name Ada which can cause confusion when searching for them.

Fabien-Chouteau commented 2 years ago

I meant issuing the alr edit after the crate has been initialized, assuming the default editor is also configured.

Could be an option if we do an interactive init mode.

Perhaps, it can configure the VSCode to be the default editor and create the initial suggested extensions settings so the user can download them without having to know of their existence or search for them.

Beyond the scope of Alire in my opinion. And I don't know if an external tool can install Code extensions like that.

mosteo commented 2 years ago

I've copied the part about launching the editor to #1203, so I'm closing this one as I agree with Fabien that configuring editors is beyond our scope, at least in the short term.

Joebeazelman commented 2 years ago

I think there's a misunderstanding. Let me provide a clear walk-through examples to clarify. Let's say the user initializes a new crate with visual studio code as the default editor from the CLI (ignore the syntax):

alr init my_ada_repo --bin --editor 'vscode' --launch

The command above initializes a new executable crate with visual studio code as the default editor and an option to launch the editor when it completed.

During the init process, Alire creates a .vscode folder with a static file called extensions.json at the root of the crate. The file just contains a list of recommended useful extensions in json format (actual debugger and ada extension name is different):

.vscode/extensions.json

{
    "recommendations": [
        "ada-language-server",
        "gdb-debugger"
    ]
}

That's all Alire has to do! Everything afterwards is up to visual studio, the extensions and the user. It's just an extra step and is no more beyond the scope of Alire than configuring any editor or toolchain. Without it, the crate files are foreign to visual studio and the user would have to know:

  1. An Ada extension exists somewhere online
  2. The name of the extension so they can install it.

This should work identically across all platforms.

From the user's point of view, whenever the user launches visual studio from the crate folder (alr edit), visual studio will use the extensions.js file to recommend the ada language server and debugger extensions to the user for installation. If the user accepts the recommendations, visual studio will automatically download and install them. The user is then greeted with a complete Ada development experience with syntax coloring, auto-formatting, etc.

Originally, I suggested doing a lot more since the Ada extension is unaware of Alire. This meant setting up the visual studio configuration files so even if the user didn't use alr edit, which is cumbersome if you work outside the CLI, the ada extension would still recognize the crate. I agree, this work should really be done by the Ada extension.

mosteo commented 2 years ago

If it's only generating a file it looks more doable. I'll reopen to not lose track.