Closed CharlesARoy closed 2 years ago
I don't use Neovim, so I don't think I'll be of much help here. I don't think I was able to get it work the one time I tried.
@WhoIsSethDaniel contributed the instructions for how to use Neovim - can you help?
Hi @CharlesARoy. I may be able to help you. I use pls
and perlcritic
is working fine.
If you run perlcritic
on a perl file do you receive output? What is it?
If you then use pls
to work on the file do you not see the same errors?
Are you using a perlcriticrc
file?
I assume you have Perl::Critic
installed since pls
requires Perl::Critic
as a dependency.
If we start with a simple example: a single file in its own directory. Call it pc.pl
with the following contents:
#!/usr/bin/env perl
print "hi there."
If you now run perlcritic
on it you should see an error:
$ perlcritic pc.pl
Code before strictures are enabled at line 3, column 1. See page 429 of PBP. (Severity: 5)
If you then edit this file with neovim you should see the error in-line (typically in red, but may be different based on your theme -- I'm also assuming you have a default LSP configuration that has virtual text turned on).
Verify that PLS is running.
If you do not see an error when running perlcritic
than something is wrong with your perlcritic
installation. Or you have a perlcriticrc
file lying around that has non-default rules.
If you continue to have problems please let us know what version of neovim you are running and what plugins you are using with it. You may try to whittle down the plugins to see if one of them is causing problems. Perhaps just use lspconfig
while testing. Since you seem to be able to get python to work with lspconfig
this probably isn't the problem, but better safe than sorry.
Your final comment suggests that you also don't have hover or go-to-definition working. Is this the case? All I can tell you is that it does work. We just need to figure out why it isn't working for you. Given the near infinite flexibility of neovim this can be difficult...which is why working with as few plugins as possible while testing is very useful.
Thanks so much for the detailed response @WhoIsSethDaniel !
It took me a bit but I got it figured out.
First off (and I know this isn't ideal), my Neovim config is based on the setup Chris@Machine describes in these videos (repo here), and I'm still figuring out some of the details behind the config.
First, I reorganized my setup slightly to the following (moving perlpls.lua
to the settings directory):
tree
.
├── init.lua
├── lua
│ └── user
│ ├── alpha.lua
│ ├── autocommands.lua
│ ├── autopairs.lua
│ ├── bufferline.lua
│ ├── cmp.lua
│ ├── colorscheme.lua
│ ├── comment.lua
│ ├── gitsigns.lua
│ ├── icons.lua
│ ├── impatient.lua
│ ├── indentline.lua
│ ├── keymaps.lua
│ ├── lsp
│ │ ├── handlers.lua
│ │ ├── init.lua
│ │ ├── lsp-installer.lua
│ │ ├── null-ls.lua
│ │ └── settings
│ │ ├── jsonls.lua
│ │ ├── perlpls.lua
│ │ └── sumneko_lua.lua
│ ├── lualine.lua
│ ├── nvim-tree.lua
│ ├── options.lua
│ ├── plugins.lua
│ ├── project.lua
│ ├── telescope.lua
│ ├── toggleterm.lua
│ ├── treesitter.lua
│ └── whichkey.lua
└── plugin
└── packer_compiled.lua
I then required the user.lsp.settings.perlpls file in the init.lua file in the lsp directory (which contains the following):
Then, I configured the perlpls.lua file like this:
Turns out that the reason linting wasn't working had to do with a part of Chris' config that I didn't (and still don't) understand very well, which is his handlers.lua file. Anyway, as I understand it, the on_attach and capabilities functions are loaded from the handlers.lua file and then added to the perlpls config settings with the vim.tbl_deep_extend command. Finally, the perlpls language server is setup with the local config and perl opts.
Hello, I'm having a hard time getting linting to work with perlcriticrc and any pointers would be appreciated. With my current setup, I'm at least getting Perl autocomplete suggestions, so I know I'm almost there.
E.g.:![image](https://user-images.githubusercontent.com/46253001/155034637-49e3bf96-d086-4242-bd5a-1978bdb575cb.png)
My Neovim config looks like:
The init.lua file in the top directory requires the lsp directory which contains an init.lua file. That init.lua file looks like this:![image](https://user-images.githubusercontent.com/46253001/155034925-ddb45dd7-4f78-4bac-96ce-a6dfe924e45d.png)
It requires the user.lsp.perlpls file which has this for content:![image](https://user-images.githubusercontent.com/46253001/155035616-5081eb4a-87c6-4c44-abb1-a83befdb7188.png)
Per the perl-language-server documentation, I installed the PLS, using the information at this link and ran
cpanm PLS
to install it.Note, for all other language servers, I installed them using the nvim-lsp-installer, but unfortunately it doesn't support Perl.
My hope is that with Perl linting, I'll be able to get behavior like I have with Python, including goto definition, hover, etc.![image](https://user-images.githubusercontent.com/46253001/155036464-69bcf48d-fa41-49ca-a049-192c389486be.png)