Closed izderadicka closed 2 years ago
The Perl Language Server binds on a local port (see Debug Adapter Protocol). You are trying to open two projects that are bound to the same port. (See first line of your logs) That is not possible atm. If someone knows how to do this, feel free to contribute.
For now you can set the local port in your workspace settings for your two projects to different ones.
Open your settings with Ctrl + ,
and go to your workspace of each project.
Insert into settings of one of your workspaces
"settings": {
"perl.debugAdapterPort" : "13604", # another port than 13603
}
Would it be possible to assign a random available port for every new running instance of the VS Code ?
I don't think that this is a good idea. You should always set the port on your own.
The current behavior is that the Language Server pretty much crashes and burns... At least we could check if the requested port is available, and report if it is not.
💡 But as long as we have the OPTION to declare a range where the LanguageServer can open a port, I'm not sure why we would oppose automatic assignment, within the specified range?
👉 And a range of 1 port corresponds to the current behavior...
Totally agree (and I'd say that may be a range starting from 1025 to 65534 by default) I tried changing the extension so that it would try assigning a random available port with get-port (https://github.com/sindresorhus/get-port) during the extension startup but didn't manage to build the resulting extention package to check whether it works or not (yet).
I realise that using get-port may cause a race condition but I tried checking the concept (if that works then maybe it may be improved then)
Ok, maybe somebody who knows how to build extensions properly, may try that: that looks like a simple change: adding get-port to the list of dependencies and using it to get a random available port (for example, when the port is set to some special value in the extension configuration, say 0 ( what is done now is it either reads a fixed value from the configuration or defaults to the fixed value 13603)
I think you both got a point. I've tried building it with your suggestion. The module get-port looks promising (pun intended!) but i got problems building the extension. get-port has a dependency (node:net) that can't be resolved by now. I am a little bit confused why nodejs doesnt find one of its own core librarys... I am trying to get it working, but i am not a pro in Typescript and nodeJS, nevertheless i am optimistic.
I tried several times but failed by now. I added some lines and my builds are successfull, but i can't activate the Extension in VSCode due to different errors. I think that get-port and VSCode Extensions are incompatible in the way I am trying to build them together in a VSCode Extension. Does anybody of you have more experience in NodeJS, Typescript and VSCode Extension? I think my mistake is somewhere in the Typescript or NodeJS Build Configuration.
FYI or if you wanna try on your own:
git clone https://github.com/richterger/Perl-LanguageServer.git
cd Perl-LanguageServer/clients/vscode/perl
npm i get-port
import getPort from 'get-port' ;
export async function activate(context: vscode.ExtensionContext) { ...
let debug_adapter_port : string = await getPort({port: ( config.get('debugAdapterPort') || 13603 )}).toString() ; }
5. `npm i vsce -g` (see https://code.visualstudio.com/api/working-with-extensions/publishing-extension)
6. `vsce package` (to build extension, will create a .vsix-File)
7. Install Extension by going to "Extension"-Tab, click the three small points on the upper side of the extension modal, and click "Install from VSIX..."
Hi, I'm totally new to LSP's and have never used vscode in my life. But I got it up and running fairly easily by installing Perl-LanguageServer and using using coc-nvim and coc-perl plugins in neovim.
However, if I open more than one perl file at a time, the LSP crashes.
I see the help above says to set a different port but the instructions are for vscode. Should I set those using :CocConfig instead?
Or maybe I should abandon coc and use neovim's lspconfig plugin?
Feeling a little lost.
coc-perl plugins
Let's have a look at https://github.com/bmeneg/coc-perl :
The options are placed in the coc-settings.json (which can be opened directly issuing :CocConfig) and has the following format:
{ "perl": { "enable": true, "debugAdapterPort": "13604" "logLevel": 1, } }
The available options are exactly the same exposed by the language server.
Thanks @ecos-ps. But what I don't understand is that if I open two files in the same directory, the server crashes. I assume the two files in the same directory will share the same coc-settings.json file which gets saved in the nvim directory. So if they are sharing the same coc-settings.json file, won't they still be using the same port?
Also, even if it is possible to set a different port for each file, it seems like a huge hassle to set up a new port every time I want to open a new perl file. Am I missing some basic knowledge here?
@sdondley The Perl Language Server is built generic and for standalone use of the LSP (Language Server Procotol) and DAP (Debug Adapter Protocol). We offer a VSCode Extension since we are using it in everyday business, but I can't say anything about other IDEs.
Every IDE that implement LSP and DAP is capable of using it, but since i am not aware of all IDEs and their specific implementation, it is hard to help you. I think your questions are better suited in https://github.com/bmeneg/coc-perl because they state that they are using Perl Language Server with nvim and i am sure they can help! When they can't, nobody can by now.
OK, thanks. I've asked for help at coc-perl. Thanks for your response and being helpful.
I ended up ditching the coc plugin and just went with the nvim-lspconfig plugin. Seems to work well now.
@sdondley Please feel free to write a short summary / introduction / tutorial for using Perl Language Server in nvim and push it to README.md in the repo and in https://github.com/bmeneg/coc-perl as well. This will help other people to work with it properly, contributions are welcome!
@ecos-ps OK, but I could not get completion working at all. Any ideas what the problem might be?
I spent a lot of time trying to get P::LS and PLS working. Posted something to Reddit: https://www.reddit.com/r/neovim/comments/t37alb/anyone_out_there_have_nvimlspconfig_working_100/
I managed to get PLS working 100% after discovering an undocumented config setting for syntax checking but I have had not luck getting completion working with P::LS.
Perl::LanguageServer does not support completion (yet). Perl::LanguageServer has a debugger, which PLS doesn't have, on the other side PLS has some few features that Perl::LanguageServer does not have.
I think that get-port and VSCode Extensions are incompatible in the way I am trying to build them together in a VSCode Extension.
@ecos-ps I investigated this a little bit. I do not know typescript, but it seems to be easy to understand with the help of google. I think we have run into these issues: https://github.com/microsoft/vscode/issues/130367, and https://github.com/electron/electron/issues/21457. I have added a possible workaround in #140 which currently does not work for me, so this is to be considered as work-in-progress.
Fixed with commit 0fabd96215814f0aad18cc7bbea84dc10a83d67b
Hi,
when I open two Perl projects in VS Code, in both Perl language server crashes with this message:
I'm on windows 10, but using WSL 2 - so project and language server in running in Linux - Ubuntu 20.04 (perl v5.30.0).
I was scanning through output of lang. server and found this repeating on second project/window:
and this on first project/window:
Full logs for both projects are attached first_project.txt second_project.txt .