VSCode as a Perl IDE
Tags: perl, programming, vscode, vscodium
Published: 2021-06-05 20:23:11

# Overview
The VSCode IDE implements it's language support via the [Language Server Protocol](https://langserver.org/) which is designed to cleanly separate language support from the editor. For Perl a fully functional language server is implemented in [Perl::LanguageServer](https://metacpan.org/release/Perl-LanguageServer) and will work with any LSP capable editor. 

VSCode can edit both locally or in a remote environment. This brief guide will get you started editing locally (i.e. on your desktop or laptop), however the Perl VSCode extension and Perl's LanguageServer will work in either scenario.

# Install a Perl interpreter for development

**Although a Perl interpreter is likely already installed** (i.e. system perl) on Linux , BSD, or MacOS the best practice is to leave if for the system to use and install your own interpreter for your development work. On Windows you likely will install Strawberry Perl.

Please follow [this guide](https://www.perl.com/article/downloading-and-installing-perl-in-2021/) to installing a perl interpreter for your development.

# Install Perl's LanguageServer

Assuming cpanm is installed, simply run:

```
cpanm Perl::LanguageServer
```
That's it. The Perl LanguageServer is now ready.

# Install VSCode (actually VSCodium)

[VSCodium](https://vscodium.com/) is the fully-foss version of VSCode (think Chromium). I recommend you install VSCodium rather than VSCode.

Fedora, SuSE, and the Debian family of Linux distributions can install from [this maintained repo](https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo).

For other OS including MacOS and Windows simply pick your favourite approach from the [official install instructions](https://github.com/VSCodium/vscodium#download-install)

# Install the Perl extension for VSCode

Run VSCode (VSCodium) and using the familiar "File -> Open" interface, open a Perl source file. Observe that whilst syntax highlighting is available already via the built-in "Perl Language Basics" plugin, actual IDE functions do not - i.e. try "Run -> Start Debugging".

We need to configure VSCode to use our Perl LanguageServer by installing the [Perl extension](https://marketplace.visualstudio.com/items?itemName=richterger.perl). The good news is that the extension is in the official VS Marketplace making it very quick and easy.

**In actual VSCode** the quickest route is hit `Ctrl-P` then type:
```
ext install richterger.perl
```
You could also click "File -> Preferences -> Extensions" then search for "perl" and click install.

**In VSCodium** the [Open VSX registry](https://open-vsx.org/) is used which doesn't [yet](https://github.com/richterger/Perl-LanguageServer/issues/98) include the perl extensions.

From the VS Marketplace [plugin page](https://marketplace.visualstudio.com/items?itemName=richterger.perl) download the extension with the "Download Extension" link on the right hand side.

On your local system's command line (there is no need to close VSCodium), change directory to your downloads and run:
```
codium --install-extension richterger.perl-*.vsix 
```
Returning to VSCode or VSCodium, observe that the Perl extension is now installed in the extensions list ("File -> Preferences -> Extensions" or `Ctrl-Shift-X`)

Open a Perl source file, click "Run -> Start Debugging" or hit `F5` and observe there is no error as before.

Now explore all VSCocde IDE functions working nicely with Perl!