Seeking for help
-
@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.
-
@Derek-Brown said in Seeking for help:
Wow, thank you so much. This will definitely be very helpful.
I still need to work on my client a bit, I’m nowhere near where I want to be, but reality keeps throwing a wrench in the works.
Also found Odin and the language intrigues me as well. My NppDebugger will be based on this language :-)
Nochamls, thank you very much.
If you don’t mind me asking, what about their LSP version?
Are they satisfied with the result? -
@Ekopalypse said in Seeking for help:
Nochamls, thank you very much.
If you don’t mind me asking, what about their LSP version?
Are they satisfied with the result?what the hell deepl … even I understand that does not make sense :-)
Again, thank you very much.
If you don’t mind me asking, what about your LSP version?
Are you satisfied with the result? -
@Ekopalypse I’m making gradual progress, working on it off and on between other distractions. I’m very happy with what I have so far. If I can find enough time to finish it I think it will be very good.