This content originally appeared on DEV Community and was authored by Dean Hamstead
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 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 to installing a perl interpreter for your development.
Install Perl's LanguageServer
Assuming cpanm is installed, simply run:
cpan Perl::LanguageServer
That's it. The Perl LanguageServer is now ready.
Install VSCode (actually VSCodium)
VSCodium 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.
For other OS including MacOS and Windows simply pick your favourite approach from the official install instructions
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 is used which doesn't yet include the perl extensions.
From the VS Marketplace plugin page 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!
This content originally appeared on DEV Community and was authored by Dean Hamstead
Dean Hamstead | Sciencx (2021-06-05T20:23:11+00:00) VSCode as a Perl IDE. Retrieved from https://www.scien.cx/2021/06/05/vscode-as-a-perl-ide/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.