Client extension for Perl language server through coc.nvim
Published Package Summary
coc-perl
Perl Language client for Language Server Protocol through coc.nvim.
Language Servers support
This project supports two different language servers:
Being that each has its own characteristics and are differentiated through the way you enable and configure them in CoC configuration file.
Installation
In the current version of coc-perl, both supported language servers are automatically installed in case you don't have
it already, meaning you only need to define which server you want to enable in CoC configuration. However, for
Perl::LanguageServer it depends if you've local::lib set in your system or
not: if you have it set manually or through some other installation/dependency management tool, like
PerlBrew, Carton, Carmel, etc, the automatic installation should happen without any
problems, since the server will be placed in a local directory, that your user has access to; on the other hand,
without it set, the installation is required to be manually executed as root, as described by its own documentation.
Prerequisites
For Perl::LanguageServer you need to have cpan installed in your host system. The way coc-perl installs it is by
executing cpan Perl::LanguageServer with a specific version (the latest supported version). However, you can
manually install it on your system or your local library path in case you're using, preventing any installation done by coc-perl.
Now, for PerlNavigator, coc-perl also handles it automatically, but it requires git to be installed. In case you
decide to install it manually, since it's not present in CPAN and its initialization is entirely written in TypeScript
rather than Perl, you need to follow what's described on PerlNavigator
repository about installing it on
other editors. In summary, you need to clone the repository, install the server running the npx tsc command from
within server's folder and take note of the absolute path for the generated code, for instance
/home/<user>/PerlNavigator/server/out/server.js, which will be needed when configuring CoC later on.
Installing coc-perl
Inside (neo)vim run this command:
:CocInstall coc-perl
or, you can set g:coc_global_extensions.
let g:coc_global_extensions = [
\ 'coc-perl',
\ ]
or even install directly via any plugin manager, for example, with vim-plug:
Plug 'bmeneg/coc-perl'
Automatic language server installation
When coc-perl is installed for the first time, you probably won't have any configuration referring to what language
server you want to enable, thus neither Perl::LanguageServer nor PerlNavigator will be installed. Make sure to after
installing coc-perl, enable one of the servers in coc.nvim configuration file (keep reading the next sections to know
how perform such action) and then reopen a Perl file or, in case you're already with a Perl file opened, call
:CocRestart, so the automatic installation process can take place considering the choice you made regarding the
language server.
Choosing a Language Server
To enable a language server an option must be added to the coc-settings.json file, which can be accessed through the
(neo)vim command :CocConfig. However, before directly enabling them, it's important to understand how the
configuration properties are defined for each server.
Enabling one server
Only one language server can be enabled at a time. In case both are enabled, an error will be prompted on
:CocOpenLog and no server action will be seen on (neo)vim's buffer.
For enabling pls, you can use either options (the first is preferred):
{
"perl.enable": true
}
And for navigator:
{
"perlnavigator.enable": true,
}
If you're using a development branch of navigator, manually downloaded and/or installed, you'll need one additional
option: the server absolute path.
"perlnavigator.serverPath": "/home/<user>/PerlNavigator/server/out/server.js"
Other options
As user, you can change and pass different options to each language server, however, the options are tied to the server version being used. Because of that, make sure to always run the newest version of the server alongside the coc-perl extension. A brief example of using different options are as follows:
{
"perl.enable": true,
"perl.logLevel": 2,
"perl.logFile": "/home/<user>/coc-perl.log",
"perlnavigator.enable": false,
"perlnavigator.serverPath": "/home/<user>/PerlNavigator/server/out/server.js"
}
You can have options for both servers in the configuration file, but only one server can be enabled at a time, meaning that options for the disabled server won't reach the enabled server.
For a detailed list of all options, please visit PerlNavigator and Perl-LanguageServer repositories.
Differences from VSCode extension
Unfortunatelly not all features supported in the original VSCode extension are available in coc-perl due to the
differences between VSCode extension core code and coc.nvim. Although Language Server Protocol is fully compatible,
the Debug Adapter Protocol (DAP) is missing from
coc.nvim, cause the features related to lauching and debugging Perl code non-existent on (neo)vim through coc-perl.
For those navigating the extension code will notice some "DAP-related" variables are defined and "used", but in
reality they have no operation at all, serving just as placeholders to allow transparent use of VSCode extension
configuration file. Working is being done in different fronts to get DAP support to neovim as soon as possible, but a
third plugin might be required (besides coc.nvim and coc-perl).
Whenever a decent and full-featured support lands through another project, instructions will be presented in this README file.
Troubleshooting
Before filling an issue, it's important to gather some information to use as entry point.
Make sure to copy the contents from :CocConfig, :CocOpenLog and :CocCommand workspace.showOutput.
:CocConfig is important to understand how you're trying to use the extension and the server. :CocOpenLog shows the
log for coc.nvim itself, when trying to initialize the extension and the server. Finally, when issuing :CocCommand workspace.showOutput a selections window will pop up to choose the server (Perl::LanguageServer or PerlNavigator)
and, once you have done that, any errors from the server will be shown in a new buffer. Only then, an issue can be
filled with all this information presented inline.
But remember, server's code are far more complicated than this client extension, meaning that most of the bugs will be related to the server. Make sure to search for the symptoms you're experiencing in server's repository either.
Maintainers
bmeneg - Maintainer
ulwlu - Project creator and former maintainer
- Client extension for Perl language server through coc.nvim
- onLanguage:perl
Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.
Open Developer GuideVersion History
This published npm package does not include a history.md or changelog.md file. Browse its npm versions or repository releases for available release information.
Contributed Commands
All contributes.commands entries from the published package manifest for coc-perl@3.0.0.
This package does not declare any contributed commands.
Configuration Schema
All contributes.configuration entries from the published package manifest, including each raw property schema for coc-settings.json.
Raw JSON Schema
{
"type": "object",
"default": {},
"description": "object with environment settings for command that starts the LanguageServer, e.g. can be used to set KUBECONFIG.",
"patternProperties": {
"^.+$": {
"type": "string"
}
}
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable Perl::LanguageServer server."
}Raw JSON Schema
{
"type": "string",
"default": "ssh",
"description": "defaults to ssh on unix and plink on windows"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "If set, log output is written to the given logfile, instead of displaying it in the vscode output pane. Log output is always appended so you are responsible for rotating the file."
}Raw JSON Schema
{
"type": "array",
"default": [],
"description": "mapping of local to remote paths"
}Raw JSON Schema
{
"type": "string",
"default": "perl",
"description": "Perl interpreter binary"
}Raw JSON Schema
{
"type": "array",
"default": [],
"description": "array with paths to add to perl library path. This setting is used by the syntax checker and for the debuggee and also for the LanguageServer itself. perlInc should be absolute paths."
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "ip address of remote system"
}Raw JSON Schema
{
"type": "array",
"default": [],
"description": "optional arguments for ssh"
}Raw JSON Schema
{
"type": "string",
"default": 0,
"description": "optional, port for ssh to remote system"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "user for ssh login"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "directory for caching of parsed symbols, if the directory does not exists, it will be created, defaults to ${workspace}/.vscode/perl-lang. This should be one unqiue directory per project and an absolute path."
}Raw JSON Schema
{
"type": "integer",
"default": 0,
"description": "Log level 0-2"
}Raw JSON Schema
{
"type": "array",
"default": [],
"description": "Perl interpreter arguments"
}Raw JSON Schema
{
"type": "array",
"default": [
".pl",
".pm"
],
"description": "array for filtering perl file, defaults to *.pm|*.pl"
}Raw JSON Schema
{
"type": "array",
"default": [
".vscode",
".git",
".svn"
],
"description": "directories to ignore, defaults to .vscode, .git, .svn"
}Raw JSON Schema
{
"enum": [
"docker",
"docker-compose",
"kubectl"
],
"type": "string",
"default": "",
"description": "If set Perl::LanguageServer can run inside a container. Options are: 'docker', 'docker-compose', 'kubectl'"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "if true, the LanguageServer will not cache the result of parsing source files on disk, so it can be used within readonly directories"
}Raw JSON Schema
{
"type": "array",
"default": [],
"description": "arguments for containerCmd. Varies depending on containerCmd."
}Raw JSON Schema
{
"enum": [
"exec",
"run"
],
"type": "string",
"default": "exec",
"description": "To start a new container, set to 'run', to execute inside an existing container set to 'exec'. Note: kubectl only supports 'exec'"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Image to start or container to exec inside or pod to use"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "if true, show also local variables in symbol view"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "enviroment from vscode will be passed to debuggee, syntax check and perltidy. If set to true, no enviroment variables will be passed."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable Perl Navigator server."
}Raw JSON Schema
{
"type": "integer",
"default": 13603,
"description": "port to use for connection between vscode and debug adapter inside Perl::LanguageServer. On a multi user system every user must use a different port."
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "path of the workspace root on remote system"
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": true,
"description": "Log to stdout from the navigator. Viewable in the Perl Navigator LSP log."
}Raw JSON Schema
{
"type": "object",
"scope": "resource",
"default": {},
"description": "Pass environment variables to the perl executable. Skipped if undefined."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"default": "perl",
"description": "Full path to the perl executable (no aliases, .bat files or ~/)."
}Raw JSON Schema
{
"enum": [
"error",
"warning",
"info",
"hint",
"none"
],
"type": "string",
"scope": "resource",
"default": "hint",
"description": "Editor Diagnostic severity level for Critic severity 1."
}Raw JSON Schema
{
"enum": [
"error",
"warning",
"info",
"hint",
"none"
],
"type": "string",
"scope": "resource",
"default": "hint",
"description": "Editor Diagnostic severity level for Critic severity 2."
}Raw JSON Schema
{
"enum": [
"error",
"warning",
"info",
"hint",
"none"
],
"type": "string",
"scope": "resource",
"default": "hint",
"description": "Editor Diagnostic severity level for Critic severity 3."
}Raw JSON Schema
{
"enum": [
"error",
"warning",
"info",
"hint",
"none"
],
"type": "string",
"scope": "resource",
"default": "info",
"description": "Editor Diagnostic severity level for Critic severity 4."
}Raw JSON Schema
{
"enum": [
"error",
"warning",
"info",
"hint",
"none"
],
"type": "string",
"scope": "resource",
"default": "warning",
"description": "Editor Diagnostic severity level for Critic severity 5."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": true,
"description": "Boolean to indicate if $project/lib should be added to the path by default."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": true,
"description": "Add environment variables to current environment, or totally replace."
}Raw JSON Schema
{
"type": "array",
"scope": "resource",
"default": [],
"description": "Pass miscellaneous command line arguments to pass to the perl executable."
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Full path to the server JavaScript file (no aliases, .bat files or ~/)."
}Raw JSON Schema
{
"type": "integer",
"default": 100,
"description": "if debugAdapterPort is in use try ports from debugAdapterPort to debugAdapterPort + debugAdapterPortRange. Default 100."
}Raw JSON Schema
{
"type": "array",
"scope": "resource",
"default": [],
"description": "Array of paths added to @INC. You can use $workspaceFolder as a placeholder."
}Raw JSON Schema
{
"enum": [
"off",
"messages",
"verbose"
],
"type": "string",
"scope": "window",
"default": "messages",
"description": "Traces the communication between VS Code and the language server."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": true,
"description": "Enable warnings using -Mwarnings command switch."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"description": "Override theme for perl critic (normally in profile)."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": true,
"description": "Enable perl tidy."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"default": "",
"description": "Path to perl tidy profile (no aliases, .bat files or ~/)."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": true,
"description": "Enable perl critic."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"description": "Regex pattern with policies to exclude for perl critic (normally in profile)."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"description": "Regex pattern with policies to include for perl critic (normally in profile)."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"default": "",
"description": "Path to perl critic profile. Otherwise perlcritic itself will default to ~/.perlcriticrc. (no aliases, .bat files or ~/)."
}Raw JSON Schema
{
"type": "number",
"scope": "resource",
"description": "Override severity level for perl critic (normally in profile)."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"default": "",
"description": "Path to perlimports.toml (no aliases, .bat files or ~/)."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Enable perlimports as a linter."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Enable perlimports as a tidier."
}