Community
    • Login

    New (incomplete) LSP client plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    59 Posts 8 Posters 8.7k 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.
    • EkopalypseE
      Ekopalypse @Michael Vincent
      last edited by

      @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.

      Michael VincentM 1 Reply Last reply Reply Quote 1
      • EkopalypseE
        Ekopalypse
        last edited by Ekopalypse

        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

        8da952b0-04f3-4a2e-ace7-2d30abfd3924-image.png

        1 Reply Last reply Reply Quote 1
        • Michael VincentM
          Michael Vincent @Ekopalypse
          last edited by

          @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.

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

            @Michael-Vincent

            Do you have any idea how to name such a flag?
            I was thinking of a boolean value named send_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?

            Michael VincentM 1 Reply Last reply Reply Quote 2
            • Michael VincentM
              Michael Vincent @Ekopalypse
              last edited by

              @Ekopalypse

              I think that’s brilliant and flexible - to be globally and “locally” (per LS) override.

              Cheers.

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

                v.0.0.18 has been released

                @Michael-Vincent

                The new (experimental) flag complete_always has been introduced.

                b5aee544-0ad4-4f28-8df6-01e5e478cb9a-image.png

                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.

                Michael VincentM 1 Reply Last reply Reply Quote 1
                • Michael VincentM
                  Michael Vincent @Ekopalypse
                  last edited by Michael Vincent

                  @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.

                  rdipardoR 1 Reply Last reply Reply Quote 3
                  • rdipardoR
                    rdipardo @Michael Vincent
                    last edited by

                    @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.

                    #2403 Add an autocomplete popup mode doing no processing

                    Michael VincentM 1 Reply Last reply Reply Quote 1
                    • Michael VincentM
                      Michael Vincent @rdipardo
                      last edited by

                      @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.

                      Mark OlsonM 1 Reply Last reply Reply Quote 0
                      • Mark OlsonM
                        Mark Olson @Michael Vincent
                        last edited by Mark Olson

                        It seems to me that the basic workflow for getting Notepad++ - style autocomplete alongside LSP autocomplete would be something like this:

                        1. Whenever the current buffer is updated, make a list of words in the file
                        2. Get a list of autocompletions from the language server
                        3. filter the words in the file for ones that could be autocompletions
                        4. Display language server autocompletions in lexicographic order with an icon to distinguish them, and then normal word-in-file autocompletions (with no icon) in lexicographic order.

                        Obviously the devil is in the details, but implementing Notepad++ - style autocompletion is surely a lot easier than implementing a general-purpose LSP client.

                        It might even be possible to provide autocompletions from all other open buffers from the FAW (similar to VSCode) if you did something like this:

                        1. On NPPM_BUFFERACTIVATED, check if the activated buffer is in the FAW, and if its lexer language matches the LSP, list the words in that buffer.
                        2. When a buffer from the FAW is navigated away from (but not closed), cache the words in that buffer in a data structure like a trie, so that they can easily be used for autocompletions.

                        My idea of using a trie only really works for static, unchanging word lists (like the buffers that are open but not currently being edited), because constructing a trie is pretty expensive and doesn’t pay for itself until you’ve done a lot of searches.

                        Michael VincentM 1 Reply Last reply Reply Quote 2
                        • Michael VincentM
                          Michael Vincent @Mark Olson
                          last edited by

                          @Mark-Olson said in New (incomplete and x64 only) LSP client plugin:

                          Obviously the devil is in the details, but implementing Notepad++ - style autocompletion is surely a lot easier than implementing a general-purpose LSP client.

                          I could be misunderstanding your numbered workflow, but I don’t think the LSP client should be responsible for getting all word autocompletes from the current buffer.

                          What I think needs to happen is Notepad++ provides an autocompletion collection point if you will. It dumps its ‘autoComplete/LANG.xml’ entries, current document words and anything else it’s configured for. The collection point is also the place where my QuickText plugin would send possible autocompletes and my TagLEET plugin would send possible autocompletes and @Ekopalypse 's LSP Client would send possible autocompletes. After collecting them all, Notepad++ sorts, filters dups, appends icons, … whatever … then makes the Scintilla call to SCI_AUTOCSHOW to display the list. Then we do it again for the next typed character.

                          Of course this idea is fraught with issues like the race conditions of how quickly a plugin can submit its autocomplete partial list to the collection point before the collection point says - “I’ve had enough, we’ve waited to long, time to display before the user falls asleep”.

                          There’s probably a proper software design pattern with a callback or an observable or something far to abstract for me to articulate that handles this exact thing - but I think that has to be put in Notepad++ for the plugins to make use of. Otherwise, we’re where we currently are, with plugins offering autocomplete directly to Scintilla, bypassing Notepad++, which results in stepping on each other and Notepad++, and a poor user experience.

                          Cheers.

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

                            First of all, thanks to everyone for participating in this topic.

                            The more I think about it, the more I feel that implementing a custom completion dialog is the way to go … but … hmm … I don’t know

                            Michael VincentM 1 Reply Last reply Reply Quote 0
                            • Michael VincentM
                              Michael Vincent @Ekopalypse
                              last edited by

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

                              The more I think about it, the more I feel that implementing a custom completion dialog is the way to go … but … hmm … I don’t know

                              Reply

                              For example, see @pnedev NppGTags. Also, I think 3P, though I’ve never used that plugin (I have the former).

                              Cheers.

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

                                Just a quick info

                                It can happen that Npp blocks when multiple language servers are running and a message is received from an inactive one, i.e. one that is not used by the current buffer.

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

                                  v.0.0.19 has been released which should address the aforementioned issue.

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

                                    I am thinking about whether it is necessary to create a “dockableDialog” for symbols of the current buffer.
                                    On the one hand Npp already offers the FunctionList dialog,
                                    on the other hand Lsp-Symbols offers not only functions, but also constants, structures, classes …
                                    But is a “dockableDialog” really needed for this?
                                    I was just thinking that a kind of “search bar” would be sufficient, if not better, for this.
                                    In my case, I usually know the approximate name of the symbol
                                    and then either just want to take a quick look at it or jump there.
                                    In other words, you could use a search bar, which would be sorted alphabetically,
                                    to display the symbols and possibly open another dialog next to it, which, for example, shows the complete function.
                                    Or what do you think? How would you use/prefer a symbol dialog?

                                    rdipardoR 1 Reply Last reply Reply Quote 2
                                    • rdipardoR
                                      rdipardo @Ekopalypse
                                      last edited by

                                      Go for the docked symbols panel. The built-in function list is a joke, if we’re being honest.

                                      1 Reply Last reply Reply Quote 2
                                      • rdipardoR
                                        rdipardo
                                        last edited by

                                        Glad to see the symbols panel was implemented. Is there any way the SCN_ZOOM callback can also resize the icon column? In current builds it gets crowded out by the identifiers at larger scales, e.g.,

                                        npplspclient-syms-pnl-scn_zoom

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

                                          @rdipardo

                                          The symbol dialog is still a bit buggy, it currently only handles parent-child relationships, but not grandparent-child relationships etc.
                                          The Borrow Checker and I are constantly arguing about this :-D
                                          Yes, the resizing of all(!?) dialogs needs to be addressed.

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

                                            Feature-wise, v.0.0.26 has reached beta status, i.e. no new features are planned before the first beta is released.
                                            So if you think something is missing, now would be a good time to open an issue on github.

                                            Before the release of the first beta version, the following issues needs to be addressed

                                            • handle NPPN_GLOBALMODIFIED message
                                            • new workspace dialog
                                            • new completion and signature dialogs that allow both to be shown at the same time
                                            • the symbol dialog shows the correct hierarchy
                                            • the hover dialog will hopefully get a proper web view
                                            • console dialog shows debug log
                                            • all dialogs get their own configuration section to customize the colors
                                            • the progress dialog is “glued” to its position
                                            • code action hints (I’m not sure how to do this yet)
                                            • reference dialog gets a kind of in-progress label

                                            If I have forgotten anything, please let me know.
                                            Thanks for reading :-)

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