Community
    • Login

    New (incomplete) LSP client plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    59 Posts 8 Posters 8.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Murray Sobol 1M
      Murray Sobol 1
      last edited by

      Hi Ekopalypse:
      I’m in the midst of learning Rust, amongst a few other new languages.
      I installed your latest version of NppLspClient.
      Following your instructions, I tried to install a Language Server for Rust, they mentioned that the OLD version of RLS is no longer supported (deprecated I think) and recommended using rust-analyzer.
      Here is the link: https://github.com/rust-lang/rls
      I have rust-analyzer installed in Visual Studio Code w022 but was unsure how to install it for Notepad++.

      Any comments or advice would be appreciated.
      Thanks
      Murray

      EkopalypseE 1 Reply Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @Murray Sobol 1
        last edited by

        @Murray-Sobol-1

        Either download a pre-built binary or clone their repo and build it yourself, which is what I do to stay up to date.

        My config for rust looks like this

        [lspservers.rust]
        mode = "io"
        executable = 'D:\Repositories\rust\rust-analyzer\target\release\rust-analyzer.exe'
        auto_start_server = true
        # initialization_options = '{"completion":{"limit": 1000}}'
        

        Since rust-analyzer can be quite chatty, you might want to comment out the initialization_options if you are having performance issues. My old i5 2nd edition processor seems to get along fine most of the time even with the commented line.

        For questions, suggestions etc… a discussion via github is also possible.

        Murray Sobol 1M 1 Reply Last reply Reply Quote 3
        • Murray Sobol 1M
          Murray Sobol 1 @Ekopalypse
          last edited by

          @Ekopalypse I downloaded this file: https://github.com/rust-lang/rust-analyzer/releases/download/2024-11-25/rust-analyzer-i686-pc-windows-msvc.zip and unzipped it.
          You mention a “config for Rust”, how/ where do I place this??
          BTW: my environment is Windows 11 64-bitProfessional edition.

          EkopalypseE 1 Reply Last reply Reply Quote 0
          • EkopalypseE
            Ekopalypse @Murray Sobol 1
            last edited by

            @Murray-Sobol-1

            Is there a reason why you are using the 32bit version of rust analyzer?
            Does that fit your rust toolchain?
            For a 64 bit Windows I would have used this one I guess.

            You mention a “config for Rust”, how/ where do I place this??

            Plugin->NppLspClient->Open Configuration File

            Murray Sobol 1M 1 Reply Last reply Reply Quote 1
            • Murray Sobol 1M
              Murray Sobol 1 @Ekopalypse
              last edited by

              @Ekopalypse
              Thanks, I replaced rust-analyzer with the 64-bit version.
              When I try to edit/modify a Rust program, i.e. main.rs I do not get the coloring of keywords or suggested completions.
              Is there something else that i am missing in my setup??
              Here’s my Notepad++ debug info:
              Notepad++ v8.7.4 (64-bit)
              Build time : Dec 4 2024 - 23:50:05
              Path : C:\Program Files\Notepad++\notepad++.exe
              Command Line :
              Admin mode : OFF
              Local Conf mode : OFF
              Cloud Config : OFF
              Periodic Backup : ON
              Placeholders : OFF
              DirectWrite : OFF
              Multi-instance Mode : monoInst
              File Status Auto-Detection : cdEnabledNew (for current file/tab only)
              Dark Mode : OFF
              OS Name : Windows 11 Pro (64-bit)
              OS Version : 24H2
              OS Build : 26100.2454
              Current ANSI codepage : 1252
              Plugins :
              mimeTools (3.1)
              NppConverter (4.6)
              NppExport (0.4)
              NppLspClient (0.0.31)
              rustnpp (1.0.2)

              EkopalypseE 1 Reply Last reply Reply Quote 0
              • EkopalypseE
                Ekopalypse @Murray Sobol 1
                last edited by

                @Murray-Sobol-1

                This sounds like Rust is not part of your Notepad++ setup because keyword coloring is done by Npp/Scintilla and is not part of the language server protocol and if that is the case, then the NppLspClient plugin will not work with Rust files.

                So what does the NppLspClient plugin do?

                When loading the plugin, it checks if the configuration file is available and if not, it creates the minimal version where no servers are available. Currently, users have to manually configure the servers they want to use.

                When activating a buffer, the plugin checks whether the language of the current buffer is configured in the configuration file. If it finds a corresponding section, it checks whether the FolderAsWorkspace (FAW) dialog has entries, and if it finds something, it remembers its root node. If the server is to be started automatically, it checks whether the current file belongs to one of the root nodes of the FAW dialog. If this is the case, this root node path is used to initialize the configured server; if this is not the case, the current directory is used instead. An attempt is then made to start the process. That’s it, and the success or failure can be displayed in the console dialog.

                If this does not solve your problem, you are welcome to open a request in the NppLspClient github repo and attach the log entries together with your configuration for further investigation.

                EkopalypseE 1 Reply Last reply Reply Quote 1
                • EkopalypseE
                  Ekopalypse @Ekopalypse
                  last edited by

                  May I ask that one of the moderators change the title of this post to

                  New (incomplete) LSP client plugin

                  Since version v.0.0.30 a 32bit plugin is also available.

                  Thank you very much.

                  EkopalypseE 1 Reply Last reply Reply Quote 0
                  • EkopalypseE
                    Ekopalypse @Ekopalypse
                    last edited by

                    Thank you for renaming the title.

                    EkopalypseE 1 Reply Last reply Reply Quote 0
                    • PeterJonesP PeterJones forked this topic on
                    • PeterJonesP PeterJones referenced this topic on
                    • EkopalypseE
                      Ekopalypse @Ekopalypse
                      last edited by

                      I am looking for the reason for a phenomenon where I am slowly running out of ideas and would be grateful for any ideas.
                      Background: It can happen that Notepad++ does not start when the NppLspClient plugin is used and Notepad++ is run in dark mode. In light mode I, and also the user who reported this, can never see this. Even my normal Npp installation, which I use daily and has always run in dark mode, does not show this behavior. I can currently only reproduce this with a separate Npp installation and even then not always. It also only seems to occur when an Npp release version is used, I have also not been able to reproduce the problem via the Visual Studio debugger. I have implemented a stack tracer in the plugin but unfortunately I cannot recognize any pattern. The error that is reported is 0xc0000374 (heap corruption) which doesn’t make it any easier to find the reason as the heap was probably already corrupted long before the exception. And with two traces I have several DllMain calls in different frames (???).
                      If my plugin corrupts the heap, why only when dark mode is active? And why can’t I see this at least sometimes with my normal npp installation?
                      I’m confused. :(

                      EkopalypseE 1 Reply Last reply Reply Quote 1
                      • EkopalypseE
                        Ekopalypse @Ekopalypse
                        last edited by

                        @Ekopalypse

                        Issue solved in version v.0.0.33

                        1 Reply Last reply Reply Quote 6
                        • xomxX
                          xomx @Ekopalypse
                          last edited by PeterJones

                          @Ekopalypse

                          (in reply to this post)

                          I do not experience such a problem.

                          Beware that while the WINAPIs in your callstack screenshot seem to be decoded properly (is it the PH SW?), the N++ calls are not. So the immediate calls visible are response for calling the GetProp, but the N++ source origin (callstack frame No. 4) is most probably wrong. You need to build your own N++ (Debug or Release, it does not matter, but with the PDB-symbols generated!) and then repeat your callstack revealing steps.

                          EkopalypseE 1 Reply Last reply Reply Quote 3
                          • EkopalypseE
                            Ekopalypse @xomx
                            last edited by

                            Hello @xomx,
                            Thank you for the response.

                            The screenshot shows the sysinternals Process Explorer with symbol files loaded from a recent Notepad++ release build.

                            The tldr is that I need to figure out why my plugin is suddenly receiving a bunch of
                            5001 (SC_WIN_IDLE) messages in 2 of 4 dialogs that have the Scintilla control embedded.

                            The more detailed version.
                            The LspPlugin has 4 dock-able dialogs that all use the Scintilla control.
                            None of them currently have a lexer active, but are colored via the SCI_ADDSTYLEDTEXT message.
                            2 Dialogs, Diagnostics and References show the unusual behavior that they

                            a) receive SC_WIN_IDLE messages and
                            b) relatively much in a short time

                            In a 20 second test, starting from the start of Npp,
                            I received approx. 3800 dialog messages for all 4 dialogs, of which approx. 3000 were SC_WIN_IDLE messages.
                            Only received from the two dialogs mentioned. But only if something was added in the two dialogs.
                            A single letter was sufficient for this. If the letter was deleted again, the messages also stopped and the CPU load decreased again.

                            The two dialog groups, Diagnostics/References on one side and Symbols/Console on the other, differ in one detail.
                            Symbols/Console use the initial document create by Scintilla and that is always overwritten,
                            Diagnostics/References use a separate document (SCI_SETDOCPOINTER, SCI_CREATEDOCUMENT, SCI_RELEASEDOCUMENT …) for each LSP server.

                            I can’t say at the moment whether this is the actual trigger but I am confident that I will find out in the next few days.

                            xomxX 1 Reply Last reply Reply Quote 1
                            • xomxX
                              xomx @Ekopalypse
                              last edited by PeterJones

                              @Ekopalypse said in Notepad++ v8.7.6 Release Candidate:

                              with symbol files loaded from a recent Notepad++ release build.

                              These are 100% wrong (missing).
                              Let’s stop here and continue in more appropriate place.

                              –
                              moderator: moved the tangential posts from the v8.7.6-RC topic to here

                              1 Reply Last reply Reply Quote 2
                              • xomxX xomx referenced this topic on
                              • xomxX
                                xomx
                                last edited by xomx

                                Continue from: https://community.notepad-plus-plus.org/post/99308

                                Below I will show you what you will see with the correct PDBs loaded for the just launched N++ (none of its func invoked), the two N++ base threads will be its main thread and the backup-snapshots worker one:
                                npp-PDB.png

                                @Ekopalypse said in New (incomplete) LSP client plugin:

                                Diagnostics and References show the unusual behavior that they

                                a) receive SC_WIN_IDLE messages and
                                b) relatively much in a short time

                                I can confirm with Debug N++ v8.7.6rc2 & your plugin binary. I simply launched the N++, invoke your Toggle diagnostic window and then any action in it (even a mouse click inside that Diagnostics wnd) invokes the SC_WIN_IDLE:
                                npp-NppLspClient-Diagnostic-SC_WIN_IDLE.png
                                So I suppose that if you use this wnd a lot in a real plugin work, there will be one such message for every, even a small, change.
                                Edit: This behavior is not dependent on your plugin, it is there even without it.

                                EkopalypseE 1 Reply Last reply Reply Quote 3
                                • EkopalypseE
                                  Ekopalypse @xomx
                                  last edited by Ekopalypse

                                  @xomx

                                  Thank you very much for having a look and trying to help me solving this. I managed to confirm that the issue is because of using multiple views.
                                  See here for more details.

                                  @PeterJones - thanks for moving the topic to the right place.

                                  I will follow up on this tomorrow.

                                  EDIT: I forgot to mention that you are right, I copied the npp.pdb to the wrong directory :-(, but when I saw notepad++!SetLibraryProperty … it was enough confirmation for me to believe that the symbol file was found and loaded.

                                  mpheathM 1 Reply Last reply Reply Quote 1
                                  • mpheathM
                                    mpheath @Ekopalypse
                                    last edited by

                                    @Ekopalypse

                                    There is a change in IdleStyling

                                    execute(SCI_SETIDLESTYLING, SC_IDLESTYLING_ALL, 0);
                                    

                                    https://github.com/notepad-plus-plus/notepad-plus-plus/blob/8042e50b1979cf958c8a2fbd46e06f819ab30fb2/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp#L234

                                    now the whole document is styled at startup instead of what is visible. So more CPU usage.

                                    EkopalypseE 1 Reply Last reply Reply Quote 2
                                    • EkopalypseE
                                      Ekopalypse @mpheath
                                      last edited by

                                      @mpheath

                                      Thank you very much - and disabling it again in my init routine seems to solve the current problem, but I’m not sure if there isn’t an underlying issue here. I mean, why does this only happen when multiple documents are used in a single window? I will do some tests in the next few days.

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post
                                      The Community of users of the Notepad++ text editor.
                                      Powered by NodeBB | Contributors