Perl Navigator is an actively developed Language Server Protocol (LSP) implementation providing advanced code intelligence for Perl. Currently at version 0.8.20, it is designed to work across various operating systems (Windows, macOS, Linux) and integrates with popular editors supporting LSP, such as VS Code, Neovim, Emacs, and Sublime Text. It offers features like syntax checking, smart context-aware autocompletion, 'Go To Definition' (including core and installed modules), code formatting via Perl::Tidy, Perl::Critic static analysis, and imports cleanup via perlimports. A key differentiator is its broad Perl version compatibility, working back to Perl 5.8, and its robust parsing capabilities for modern Perl features and class builders like Moo/Moose/Object::Pad. While the core server is written in TypeScript and Node.js, its primary function is to enhance the Perl development experience through editor integration, not to be consumed as a JavaScript/TypeScript library directly.
npm install perlnavigator-serverNo compatibility data collected yet for this library.
Demonstrates a typical LSP client configuration for Perl Navigator, showing how to invoke the server executable and configure basic settings like Perl path and include directories. This is how editors interact with the server.
Interact with Perl Navigator by configuring your code editor's LSP client to run the `perlnavigator` executable, typically installed globally via npm. Do not attempt to import it as a library in your JavaScript/TypeScript code.
Install required Perl modules using CPAN (e.g., `cpanm Perl::Critic Perl::Tidy perlimports`) and ensure your Perl environment is correctly configured and accessible by the server.
Set the `perlnavigator.perlPath` configuration option to the full, absolute path of your Perl executable (e.g., `"/home/user/perl5/perlbrew/perls/perl-5.38.2/bin/perl"`). Avoid aliases or relative paths.
Use LSP client settings to define `perlnavigator.perlPath` and an array of `perlnavigator.includePaths` (which map to Perl's `@INC`). For containerized setups, this often involves careful path mapping or custom wrapper scripts for `perlPath`. The `$workspaceFolder` variable can be used in `includePaths` to reference project roots.
Ensure you save your Perl file before expecting `perlimports` features (like diagnostics or formatting) to reflect the latest changes. This is standard behavior for this specific feature.
After cloning and running `npm install`, navigate to the `server/` directory and execute `npx tsc` to compile the server code. Then, you can reference `server/out/server.js` when configuring your LSP client.
Run `sudo npm install -g perlnavigator-server` to install globally, or ensure the installation directory is added to your system's PATH environment variable. If installing from source, ensure `npx tsc` was run in the `server/` directory and your editor configuration points to the correct `server/out/server.js` path.
Verify and set the `perlnavigator.perlPath` setting in your editor's LSP configuration to the absolute path of your Perl executable. Also, add directories containing your project's Perl modules to `perlnavigator.includePaths` (e.g., `"perlnavigator.includePaths": ["$workspaceFolder/lib", "/path/to/cpan_modules"]`).
Install the necessary Perl modules via CPAN (e.g., `cpanm Perl::Critic Perl::Tidy perlimports`). Additionally, check your editor's LSP settings for `perlnavigator.perlcriticEnabled`, `perlnavigator.perlcriticProfile`, `perlnavigator.perltidyProfile`, and `perlnavigator.perlimportsProfile` to ensure they are enabled and point to valid profile files if custom ones are used.