New (incomplete and x64 only) LSP client plugin
-
This post is deleted! -
It took some fiddling, but I got it to work and I have some preliminary thoughts (having used it with Python only):
- The most important failing I saw in the previous iteration was that when I tried to import a really big library like numpy, it caused Notepad++ to hang. This no longer happens. Great job!
- I would greatly prefer for syntax errors (e.g., referencing a variable not previously defined) to display over all formatting issues. If there is a way to configure this (including possibly disabling all formatting warnings), I would appreciate if the config file was more explicit about it.
- I think the default
warning_color
should be a fair amount darker, because the yellow is pretty hard to see on the white background of the defaultstylers.xml
.
-
I was going to ask why the DLL’s export table includes
DllMain
:$ readpe --exports NppLspClient.dll Exported functions Library Name: NppLspClient.dll Functions Function Ordinal: 1 Address: 0x7e10 Name: DllMain Function Ordinal: 2 Address: 0x3020 Name: beNotified [ . . . ]
I suppose it’s because Rust’s
#[no_mangle]
attribute implicitly exports whatever symbol it qualifies? https://github.com/rust-lang/rust/issues/67399The older V binaries export
DllMain
as well, so probably nothing to worry about. -
Thanks for testing and the nice comments.
@Mark-Olson
Doh, error_color and warning_color will be configurable again in the next version, sorry.
Regarding the sorting of diagnostic messages, within a source file this is easily possible,
but as far as sorting across files is concerned, as can be seen in the attached screenshot,
it looks more difficult. The plugin cannot know in advance whether there will still be messages,
which have a higher urgency than those already received, which means
that sorting would have to take place after every message received …
hmm … let’s see how this can be managed efficiently.@rdipardo
Haha … I hadn’t even realized that yet. Yes, with V it was only possible to build a plugin
if DllMain was also exported … it took me some time to find that out.
I think this is also the case in C if you create a DLL with gcc today.
If my memories don’t deceive me, I stumbled across a gcc thread back then that discussed this. -
Version v.0.0.15-alpha published.
Changes:
- Error and warning colors are configurable again
- Within a file, diagnostics are ordered by severity
New:
- Goto declaration/implementation/definition support
- Hover support (see screenshot below)
-
@Mark-Olson said in New (incomplete and x64 only) LSP client plugin:
having used it with Python only
Well done - can you please share the config file you used to get the Python LSP working?
Cheers.
-
[lspservers.python] mode = "io" executable = 'C:\path\to\Python311\Scripts\pylsp.exe' args = '--check-parent-process --log-file %AppData%\\Roaming\\Notepad++\\plugins\\config\\NppLspClient\\pylsp.log' auto_start_server = false
It definitely does not work reliably without using Folder as Workspace. If you use Folder as Workspace, it’s definitely more reliable.
-
@Mark-Olson said in New (incomplete and x64 only) LSP client plugin:
It definitely does not work reliably without using Folder as Workspace. If you use Folder as Workspace, it’s definitely more reliable.
Reply
Ahh, I have that exact config (with my paths of course) and it’s not doing anything. I never use Folder as Workspace though, wonder if that’s my issue? I’ll try …
Cheers.
-
@Michael-Vincent
Yes, currently FAW must be used, and the logic is as followsIf the current file starts with a root path, then send the root path to the language server, otherwise do nothing.
The next version will use the current directory of the current file instead of doing nothing.
@Mark-Olson - what do you mean by “more reliable”?
Have you encountered a situation where it didn’t work with FAW? Reproducible?
Personally, I don’t like using the FAW dialog as it introduces some difficulties and even performance issues. But I didn’t want to create another “explorer-like” dialog either. But that would have its advantages, one could create a TreeList, then it could be used to see which files contain errors. Hmm … maybe I should go that way anyway … I’m still undecided.
Does anyone have any other ideas?
-
@Ekopalypse said in New (incomplete and x64 only) LSP client plugin:
Have you encountered a situation where it didn’t work with FAW? Reproducible?
Reproducible? I doubt it. I think what probably happened is that I opened of FAW, then closed it, then opened up a file.
I keep a lot of one-off scripts in my Python directory (the same directory as the executable) because it’s convenient to do so (can run
python -m whatever
from anywhere), but of course that’s a terrible place to open FAW because theLib/site-packages
subdirectory can have tens of thousands of files. -
@Ekopalypse said in New (incomplete and x64 only) LSP client plugin:
The next version will use the current directory of the current file instead of doing nothing.
Sounds good. I did get it working with FAW - and that makes sense why.
One thing to think about and not seeing the code I’m just assuming based on the previous V version, you should just do autocompletes. Don’t bother checking if one is active. Maybe it’s my personal preference, but if I’m using a Language Server, I want those completions to be foremost presented, and then if that can’t find any, the “default” Notepad++ ones would show up based on the language or current text in the doc - depending on how it’s configured.
I see currently, you check:
I don’t bother with any of the autocomplete plugin stuff I do - I just present it and Scintilla autocomplete is “smart enough” that when there is no match, the autocomplete window no longer shows - freeing up Notepad++ default autocomplete (if configured) to do it’s thing through Scintilla.
I hope this is making sense. I just noticed when I was typing, I was getting all the Notepad++ autoComplete XML stuff and local doc stuff showing until there were no more options that matched, and then the Language Server started showing me its suggestions - which is what I wanted to see first.
Cheers.
-
@Michael-Vincent said in New (incomplete and x64 only) LSP client plugin:
which is what I wanted to see first.
… yeah, and I thought, what’s he talking about, I always get the completions from the language server first … and then ahh - because I disabled Npp’s autocomplete - - another doh moment :-D
v.0.0.16 puplished
Changes:
- The root directory is set to the current file directory if it cannot be found in the root directories of the workspace…
New:
- Format document support
Note that symbols and reference dialogs are not usable at the moment - I haven’t bothered to disable these functions.
-
v.0.0.17 has been released and has thus reached the functional scope of the former Vlang version.
New:
- Support for symbols and references
- Provision of a help function for reloading the current file
-
@Ekopalypse said in New (incomplete and x64 only) LSP client plugin:
ahh - because I disabled Npp’s autocomplete
Not really an option for me. I use languages that I won’t have language servers for and I want autocomplete to work for them too. Turning it on and off would also be a pain.
Could there be a setting to skip the check?
Cheers.
-
Do you have any idea how to name such a flag?
I was thinking of a boolean value namedsend_completion_request_always
and it should be available in both the global and lspserver sections.The absence would mean `false" and has the current behavior, i.e. if a completion list is active, it will be used and not canceled.
If the boolean value is present in the global section, each lspserver inherits its value unless it explicitly overrides it.Other ideas?
-
I think that’s brilliant and flexible - to be globally and “locally” (per LS) override.
Cheers.
-
v.0.0.18 has been released
The new (experimental) flag
complete_always
has been introduced.To be honest, I’m not very happy with it - quite a bit of flickering. I’m still thinking about whether other solutions are possible/useful.
-
@Ekopalypse said in New (incomplete and x64 only) LSP client plugin:
quite a bit of flickering
Yes, that’s because every time a character is typed, autocompletion is called. The way you had it was “nicer” in that autocompletion was just called once and further typing didn’t “filter” (i.e., shorten and redisplay) the list, it just “narrowed” (i.e. moved to the closest match).
This is a symptom of a rather immature autocomplete feature and the Notepad++ implementation and probably other “stuff”. Meaning, there can only be one active autocomplete list at a time, but there is no way to add to that list. So type a character and Notepad++ creates its own list based on the ‘autoComplete/LANG.xml’ file and any current words in the doc (depending on settings of course) and my QuickText plugin creates its list for the language if you match a snip and my TagLEET plugin creates a list based on all the CTags in the project and now your LSPClient creates a list, and on and on … last list wins? or maybe not?
Of course, if you don’t have any of those plugins, you don’t see the issue, but it would be nice (not for you to solve) if Notepad++ / Scintilla had a sort of universal autocomplete where you don’t create the list, just submit your items to add to the list and the universal autocomplete compiles a consolidated list of all the available completions before displaying. That way, you can get the goodness of Notepad++ default fallback for non-LSP languages and the useful “other words in document” (great for typing documentation or README files where words / phrases are repeated) plus any plugin could make use of autocomplete sending suggestions (like the plugins I previously mentioned above) without conflicting with each other - rather cooperatively creating a curated list of the possible completions for the user.
FOR NOW: definitely keep this “feature” disabled by default and maybe document the “issues” with enabling it. And if ultimately you don’t like it or it makes the maintenance difficult - you can remove it. I do appreciate you adding it in so quickly for me to test / play with. I’ve sorta gotten used to this subpar autocomplete experience (read: flickering and somewhat not reliable) so I may be a bad judge of how “well” this
complete_always
mode works.
I also cannot stress enough how AWESOME it is that you are tackling LSP for Notepad++!! I have tried some quick Python frameworks running with PythonScript to no avail - which is also why your dockable-dialogs-from-PythonScript piqued my interest. LSP plugin is a daunting task - again, thank you!
Cheers.
-
@Michael-Vincent said in New (incomplete and x64 only) LSP client plugin:
it would be nice [. . .] if Notepad++ / Scintilla had a sort of universal autocomplete where you don’t create the list, just submit your items to add to the list and the universal autocomplete compiles a consolidated list of all the available completions before displaying.
-
@rdipardo said in New (incomplete and x64 only) LSP client plugin:
#2403 Add an autocomplete popup mode doing no processing
Indeed - that describes the problem rather well. I see the proposed solution is a new autocomplete mode. So maybe that would help with LSP type flickering described, but I don’t think it address the “universal autocomplete” I’m talking about where other plugins (other than the Language Server) and Notepad++ itself could all create a list that gets displayed.
Cheers.