Seeking for help
-
@Ekopalypse said in Seeking for help:
Many thanks to you as well.
I think a Npp language server client would be awesome - I just don’t have the chops to create it. Happy there are others that see the value and I appreciate you taking on the enormous task. Happy to help test / troubleshoot / contribute how I can.
Cheers.
-
Even when I set my config up like @Michael-Vincent’s for perl, I don’t see messages in the LSP output console. It may be that my IT department is blocking some aspects (I just got a notification that Notepad++ was being virus scanned when reloading it, which I normally never see). I think at this point, I will have to give up on LSP at work (which is unfortunate, because I do a lot more coding at work than at home); maybe I’ll run some experiments at home, where I know IT cannot be getting in my way. ;-)
-
I have now had a chance to use your plugin and as an alpha release I am mightily impressed.
I have tested using pylsp.exe and with all options installed.
Got a bit of a fright on my 3000 line plus python file I decided to test it on (perhaps I should have been so ambitious) but it even worked on this file if a little slowly at times, which may be the pylsp implementation as much as anything as I have all options enabled in pylsp so it is doing a lot, but I was able to work through the issue and the annotations and console helped.
A couple of things, which at present would be very much nice to have and are not essential would be:
-
Ability to configure the colours of the various styles of messages in the console, I still use a white background and the default colours are a bit washed out. Also would be good for the annotations as well.
-
Add hotspot links to the diagnostic info message in the console, i.e. line:3284 - Cyclomatic complexity too high: 15 (threshold 15), so that they could be clicked to take you to the line in the file being edited. I know these appear as annotations in the edited file but with a large file and the console shown it would be good to just click on the messages and be taken to that line in the file.
-
If the completion list is empty do not show it, not sure what the issue is but I was getting an empty completion dropdown on entering ‘.’ in some cases.
-
Not sure how well this is interacting with the Undo CTRL-Z functionality as that seemed to pop up completion lists (empty again) and trigger seemingly multiple call to the lsp, not sure how well scintilla notifies this so you might not be able to do much about it.
So far so good, and keep up the good work, I have also downloaded the source code and the V language has peeked my interest, not one I have had much exposure to yet amongst the seemingly hundreds I have used during a 35 year development career, but one I am going to have to become more familiar with even if only to possibly contribute to this project. Just need to get GCC installed and working first though.
-
-
Thanks for testing and the kind words.
As for GCC, the V community seems to prefer builds from https://winlibs.com/#download-release.
Just unzip and make sure gcc is in the path or can be found.Unfortunately pyls is very slow compared to other language servers I’ve tested and I’m pretty sure jedi is the culprit.
I read that the author of jedi wants to rewrite it with rust, that should give a good performance boost.Doh, of course, colors need to be customizable.
Will be included in the next version (I assume tomorrow).Currently I am toying with how such diagnostic messages should be displayed. On the one hand I want them in the Scintilla editor, on the other hand I hate it when they are constantly shown and hidden. Maybe it is an option to use an indicator, a squiggled line (?) while typing and annotations, as is the case now, when saving the file !?
V is a very young language that has potential, but whether it can use it, only the future will probably tell, I think. :-)
As long as the plugin is in alpha status, I’ll try to implement the functions needed first.
In beta status, I then plan refinements such as hotspot links etc…
Please don’t misunderstand, I’m absolutely happy about the thoughts you made, they make total sense. Thanks again. -
Thanks for the hint re GCC, all downloaded and working now, time to do some more learning of V.
I assume you use Notepad++ for V, if so do you know of a lexer, I have found a UDL which does a half way decent job but is easily confused with things like ‘\\’?
-
Yes, I wrote a lexer for V, but unfortunately it doesn’t help you because
it doesn’t work with a 32bit npp because, as far as I’ve investigated/understood,
x86 code handles the thiscall needed for the cpp-lexer methods differently.
X64 code handles this the same way as stdcall and this is supported by V.
I haven’t had the muse to follow this up yet, if you want to do that, I can provide my lexer code. -
I have a portable x64 version I could use for V, so the lexer would be much appreciated.
It’s just I haven’t switched over to x64 version of my main customised/built from source version yet because of issue with a missing x64 version of one of the plugins I use quite a lot, I could replicate the functionality in x64 with my own plugin but I haven’t had the time of yet.
-
@nick-brown said in Seeking for help:
a missing x64 version of one of the plugins
Which one?
Not to hijack the thread, but this was my reason for not switching from 32-bit to 64-bit, but I was able to find alternative workflows / tools / scripting that solved the issue and I moved to 64-bit a few years back.
Cheers.
-
Automation Scripts or NppScripts.dll as the plugin dll is called, I believe the author has released a x64 version but I could not get my scripts to work in that version, possibly due to incompatibly .net versions, I don’t know I haven’t really looked into it, the scripts I use are c#.net so should be easily transferrable to a plugin when I get around to it,.
-
@nick-brown - done, uploaded here.
I have been using it for 2-3 months and never had any stability problems.
There is one thing that I am not sure if it has been fixed or is still a problem. Occasionally it happened, twice in my case, that the folding gets corrupted. This is also why the plugin has the menu itemToggle Fold Debug Margin
.
If you see this and are able to reproduce it, I would ask you to let me know. -
I just found this thread now, but I’ve also been working on an LSP plugin off and on for the last several months. I don’t know how much you have implemented, I only have a couple methods but I have pretty much all the infrastructure.
It’s in C++ and depends on libraries that I have written for my other plugins (as well as some third party libraries).
https://sourceforge.net/p/kered13-notepad-plugins/code/ci/default/tree/NPP LSP/src/
-
Hello, thank you for this tip.
I would love to collaborate with you, but my cpp knowledge is weak at best and in reality non-existent.
Is there already a plugin that Npp users can use?
I hope others who read this and know about cpp will take this as inspiration and start contributing to your project.As of today, I have defined all requests, notifications and responses for version 3.16.
33% are technically implemented, meaning you should be able to use them,
but they may not be as well integrated into Npp as they could be.
For example, diagnostic messages are displayed as a squiggly line and the textual
representation is available in the console window, but you can’t hover over them
to see what they mean.
In my opinion, this 33% are the most important.
Code errors, completion hints, signature info, goto definition/implementation/declaration,
find references, code formatting and hovering over code symbols (as I said, hovering over error/warning indicators is not possible at the moment).My current plan is to finish the open 67% and then start integrating it into Npp in a more meaningful way.
I’m really bad at estimating how long it will take to implement the remaining 67%, but if I can keep up my current
pace I hope to finish it within the next 2 weeks.
Let’s see what real life has to say about it :-)Btw. what language server do you use for testing?
I find gopls, which I found recently, is a good one to get hints on errors in client / server communication, while pyls seems to be the most forgiving, which is not really good if you want to develop a generic lsp client :-D -
@ekopalypse I’ve mostly been using the Eclipse Java language server and the Microsoft Python language server. The Eclipse server has been very picky in particular, so it’s been good for ensuring that my plugin is conformant. It was a bit of a pain getting them setup, so I’ll share the configs that worked for me (this JSON format is how I’m storing plugin settings, but I think you can figure out to get the relevant information out of it):
{ "servers": { "java": { "commandLine": "java -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar ./plugins/org.eclipse.equinox.launcher_1.6.300.v20210813-1054.jar -configuration ./config_win -data C:\\Users\\Derek\\Downloads\\jdt-language-server-1.4.0-202109161824 --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED", "initializationOptions": { "extendedClientCapabilities": { "shouldLanguageServerExitOnShutdown": true } }, "workingDirectory": "C:\\Users\\Derek\\Downloads\\jdt-language-server-1.4.0-202109161824" }, "python": { "commandLine": "dotnet exec C:\\Users\\Derek\\Documents\\python-language-server\\output\\bin\\Debug\\Microsoft.Python.LanguageServer.dll", "initializationOptions": { "excludeFiles": [], "includeFiles": [] } } } }
I have hover support working for Publish Diagnostics, feel free to look at my code if you want to see how I did it. I know you said you’re weak on C++, but I think you’ll be able to follow it. Mine is actually a bit more complicated than necessary, for a minimal implementation you only need to handle the SCN_DWELLSTART and SCN_DWELLEND events, which is very straightforward and the first thing that I implemented. However for my plugin I wanted the calltip to remain until the mouse left the indicator, so I hooked into raw input mouse events by creating a message only window to get the mouse coordinates. I also handled overlapping diagnostics by using an interval tree implementation that I pulled from Github (with some slight modifications).
-
Thanks a lot - I will definitely have a look at the Java Language Server and your implementation to get some ideas ;-)
-
@ekopalypse By the way I was skimming your code to see how you handle certain tricky cases that took me awhile to figure out, and it looks like you don’t handle Replace in Opened Documents, have you tested this? In particular test using Replace in Opened Documents to make changed to a background file. This will probably cause issues with incremental sync if you don’t handle it correctly.
What I learned in my development was that when you use this feature Notepad++ uses a hidden scintilla (internally called “scratchtilla”) to apply the changes. You’ll get the SCN_MODIFIED notifications like normal, but you need to get the Scintilla from Sci_NotifyHeader.hwndFrom instead of using the current Scintilla.
But there’s a second catch: If the a change is applied to the primary or secondary scintilla then you will get two SCN_MODIFIED notifications: One from the primary/secondary scintilla and one from the scratchtilla. To make sure I wasn’t sending duplicate change notifications I had to implement somewhat complicated logic where I get the docpointer (SCI_GETDOCPOINTER) from the scratchtilla and compare it to the docpointers from the primary and secondary scintillas. If the notification is from the scratchtilla and is the same document as either the primary or secondary scintillas then I ignore the message. You can see how I implented this in NppLsp.cpp:shouldSendModified.
…And after writing this I realized that I have a similar duplicate modifed bug when the same document is opened and edited in the primary and secondary Scintilla at the same time, so now I’ll have to go fix that! This also means that a triple modified bug is possible if you use Replace in Opened Documents with the same document in both views.
-
Thank you very much for the hints. No, currently I am only testing with a single document and only in one view, BUT I already had an issue where I sent two did_change notifications and was confused as to why this was happening. Perhaps I had two views open at the time - good to know there are certain pitfalls. Many thanks at this point.
Phew … sounds like I’m going to have a lot of fun in the future.
Maybe I should start implementing some test cases already. -
@derek-brown said in Seeking for help:
It’s in C++ and depends on libraries that I have written for my other plugins (as well as some third party libraries).
You haven’t released a compiled version yet?
-
@michael-vincent No I haven’t, I think I will soon. I had been thinking about making an announcement this week or next after finishing up a few things, but I saw this thread and decided to go ahead and post now. But I’d still like to finish some things before releasing a dll. If you want to try it, for now you’ll have to build it yourself with Visual Studio.
-
-
@michael-vincent I have finally release a preview version, I made a separate thread for the development of my plugin here.
Implementing completions was much harder than I expected, so it took awhile. I also was busy with other stuff for a couple weeks in there. I think future methods will be easier though, completions were difficult because it’s a stateful interaction with the server where you also don’t want to block the Scintilla thread, creating some really tricky concurrency issues.
-
-
-
@Ekopalypse I don’t know how much development you’re still doing, but I made a small program to help with testing my LSP plugin, and I thought I would share it with you. It acts as an LSP server, but you enter all the server messages yourself. So if you want to test some method and you’re having trouble getting an LSP server that provides the behavior you want, you can use this instead.
Make sure you create the server process with a console, then it will display all the messages it receives from the client, and you can type into the console the messages you want to send back. Sending messages is triggered on an empty line, so you can type multi-line JSON to send. When you’re starting the server you can also provide it with initializationOptions and it will send that JSON back as it’s server capabilities, so you can configure whatever capabilities you want it to have. It will automatically handle startup, shutdown, and exit messages, everything else is manual.