Skip to content

Instantly share code, notes, and snippets.

@Joebeazelman
Last active November 1, 2022 19:25
Show Gist options
  • Save Joebeazelman/d8283e714f06bfd972c209e32c2aa86a to your computer and use it in GitHub Desktop.
Save Joebeazelman/d8283e714f06bfd972c209e32c2aa86a to your computer and use it in GitHub Desktop.
@Joebeazelman
Copy link
Author

Visual Studio Code and Alire Configuration

This gist is a setup and configuration guide for Ada development using Visual Studio. It should work across all platforms supporting VSCode.

Operating System Setup

It's important that your operating system is properly configured. Special considerations for each major operating system must be taken to ensure success. In general, so long as your operating system is POSIX compliant, the instructions provided should work without modification. This includes Linux, MacOS and most UNIX operating systems.

It's important to note there are minor differences between shells such as bash, zsh and fish. If a command you type from the terminal doesn't work as expected, your shell might be the culprit.

Windows

If you're running Windows, it's strongly recommended you install a UNIX/POSIX compatibility layer. The GNAT compiler toolchain is designed for UNIX and makes extensive use of its shell. There are three major UNIX compatibility environments available for Windows: Cygwin (https://www.cygwin.com ), MinGW (https://www.mingw-w64.org) and WSL (https://learn.microsoft.com/en-us/windows/wsl/). If you're running Windows 10 or higher (Windows 10 Build 19041, or Windows 11), WSL offers the best compatibility since it runs a Linux in a light weight virtual machine. It's beyond the scope of this gist to cover how to install, configure and use a compatibility layer.

Download and Install Visual Studio Code

Of all the IDEs available for Ada, Visual Studio Code is the most flexible and easiest to use across all major development platforms. Unfortunately, it's not Ada friendly right out of the box. There's no file type recognition, no syntax coloring and no auto-formatting outside of its basic editing and terminal facilities.

Download the Visual Studio Code installer from https://code.visualstudio.com. Once downloaded, run the installer which should only take a minute.

Include Visual Studio Code in the $PATH environment variable

After it completes, launch VSCode and open the Command Pallet (Shift + Command + P (Mac) / Ctrl + Shift + P (Windows/Linux)) and type shell command to find the Shell Command: Install 'code' command in PATH command. This installs the command in your $PATH variable so you can launch VSCode from the command-line by typing code. You can test it by exiting out of VS Code and typing code from the terminal's prompt.

Download and Install Alire

It's strongly recommended you install and familiarize yourself with Alire. It will greatly increase your productivity and modernize your workflow. While it claims to be an Ada Library Repository (A-da LI-brary RE-pository), it does far more. Before Alire, setting up and managing an Ada development project was a laborious and complex process.

Download Alire https://alire.ada.dev. Open the archive and from inside its bin folder copy alr to your executable folder. .

Download and Install AdaCore's Language Server

AdaCore's Language Server by itself, it provides the vast majority of the features needed for Ada-friendly development:

Indentation/formatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment