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.
    • 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
                                  • EkopalypseE
                                    Ekopalypse @Ekopalypse
                                    last edited by

                                    I’m starting to question whether using a WebView for the hover part is really beneficial.
                                    It complicates more than one could, probably, benefit from and it slows down the startup of npp considerably.
                                    I know I could start it “lazily” by initializing everything the first time I use it.
                                    But running 6 additional processes … hmmm … and what are they doing in the background? Links can also be opened via Scintilla … the styling options are of course limited but is that really needed.
                                    And there are certainly some servers that don’t support Markdown at all …
                                    yes pylsp I am looking at you for example.
                                    What do you think, does it make sense to use a WebView?

                                    5c188b4d-20ec-4f6b-a17b-a43e575af505-image.png

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

                                      @Ekopalypse ,

                                      I recently found perlnavigator, which is a Perl LSP server that has with a pre-built Windows executable, and I can actually unzip it at work (where I was never able to get Perl::LanguageServer to install properly at work, so I never bothered at home). And I confirmed it defaults to STDIO mode for communication, so it should be compatible with your new plugin. (And it’s dead-simple to install: just unzip the perlnavigator-win-x86_64.zip and put the perlnavigator.exe in your path or a known location; --stdio seems to be the only command line argument needed)

                                      So I downloaded your NppLspClient v0.0.26-alpha and installed it in a v8.6.2 portable (since the alpha download pages showed they need < v8.6.3).

                                      Initial problem: when it creates NppLspConfig.toml, I get an error in the auto-generated config file:
                                      b73994b8-d5e6-4fa5-809a-ad9002b56f24-image.png

                                      If I add [lspservers] as line 1, that error goes away. But I would hope the auto-created config would not have syntax errors. :-)

                                      Second, I was surprised to not see syntax highlighting in the config file. Why did you pick a config language that Notepad++ doesn’t recognize out-of-the-box? ;-) Do you prefer a UDL (like the one listed in the UDL Collection)? Or do you just assign .toml to the INI builtin language?

                                      ----

                                      But, after a few false starts (which were me having mistakes in the config file), I was able to get it working (for the first level of “it works”)

                                      [lspservers.perl]
                                      mode = "io"
                                      executable = 'c:\\usr\\local\\bin\\perlnavigator.exe'
                                      args = '--stdio'
                                      auto_start_server = false
                                      

                                      And I can see a function in the “Symbols”, and clicking in the Symbols list will take me to the definition of a function. But if I add a new function, or insert lines before a function, it doesn’t refresh. Is there a way to get it to refresh automatically (at least when the source is saved)? Or is that a limitation of the current implementation of the Client? Or is the PerlNavigator server not responding to your client’s request for a refresh?

                                      Even though clicking in the Symbols panel will allow me to go to the function, “Goto declaration/implementation/definition” doesn’t seem to do anything for me. I don’t know whether it’s just there need to be more options sent to the perlnavigator server somehow. (its main page seems to show some LspClients in other editors have settings that they can pass to the server; is there something like that in NppLspClient?)

                                      Is there something specific at >= v8.6.3 that causes it to “not work”, or have you just not upgraded beyond that yet, so haven’t tried? (I tried installing it in my daily 8.6.4, and it didn’t crash and would show my function, but since I haven’t seen many features work, I don’t know if there’s something that I haven’t tried that causes a crash, or what.)

                                      Anyway, sorry for the rambling. I still don’t have a lot of (really, any) experience with LSP. But I’m really hoping I can eventually figure out how to make it useful for my perl code.

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

                                        @PeterJones

                                        First of all, many thanks for the testing and the detailed experience report.

                                        But I would hope the auto-created config would not have syntax errors. :-)

                                        The error comes from the TOML linter. From the plugin’s point of view, an initial configuration is not usable because it does not contain an lspserver configuration. I am currently not sure if I can simply overwrite the error message, but a check for this specific text and then a more meaningful message should always be possible.

                                        Why did you pick a config language that Notepad++ doesn’t recognize out-of-the-box?

                                        I wanted to have a configuration file format that could use comments and that was already supported by V at the time, hence my choice of toml. I am currently using a very experimental toml lexer, but previously I used the udl lexer.

                                        … at least when the source is saved

                                        That should already work, symbols are queried every time you save a document.
                                        Can you give a simple test case?

                                        “Goto declaration/implementation/definition” doesn’t seem to do anything for me

                                        It could be that this is not supported by the server or you have discovered a bug.
                                        Right now I’m just returning from the function, maybe I should log something in the console window to alert the user that the current operation is not supported by the server.

                                        Is there something specific at >= v8.6.3 that causes it to “not work”,

                                        Yes, certain events have been disabled that the plugin requires.
                                        See here for more information) for more information. Everything seems to work with 8.6.5 so far.

                                        By the way, if you enable debugging via the configuration, the communication between the lsp client and the servers is logged which can be helpful for root cause analysis.
                                        The log is created in the plugin\config\npplspclient directory with the respective Npp process ID.
                                        Caution, the respective log is also deleted when Npp is closed.

                                        LSP communication currently recognizes 3 message types that can be sent by the client or any server.
                                        Requests, responses and notifications.
                                        Each request must be sent with a unique ID and answered by the other side with a response and this ID.
                                        Notifications are only received and do not have this ID.

                                        PeterJonesP 1 Reply Last reply Reply Quote 2
                                        • PeterJonesP
                                          PeterJones @Ekopalypse
                                          last edited by

                                          @Ekopalypse ,

                                          because it does not contain an lspserver configuration

                                          Ah, okay. I can confirm, I can remove my dummy [lspservers] section once I have [lspservers.perl], and it won’t flag that error.

                                          hence my choice of toml.

                                          My question was actually meant as a “tongue-in-cheek” joke. Sorry if that didn’t translate. TOML is a standards-based similar to INI, so I can definitely see why one would want to use it (and why it would be a pre-implemented for your language of choice, as opposed to trying to implement an INI library, given the multitude of INI variations)

                                          I am currently using a very experimental toml lexer, but previously I used the udl lexer.

                                          Okay, I’ll probably snag the UDL, then.

                                          That should already work, symbols are queried every time you save a document.
                                          Can you give a simple test case?

                                          Apparently, I cannot, because the same experiments I tried yesterday are working today.

                                          It could be that this is not supported by the server or you have discovered a bug.

                                          PerlNavigator claims to support “Go to definition”, whether it needs to go elsewhere in the same file or into a used module.

                                          627342e9-4e9b-4511-9dae-982813df7c68-image.png

                                          Right now I’m just returning from the function, maybe I should log something in the console window to alert the user that the current operation is not supported by the server.

                                          … or maybe the Diagnostics window (unless that has a different meaning… I don’t know what all the specifics are for LSP yet, and what is expected to go where4)

                                          I selected the name of a function that comes from an external module, and then started the LSP server and did Goto definition, and nothing happened. I then grabbed the log at that point:

                                          2024-04-03 06:18:31.141685 [INFO][ThreadId(1)] -   process arguments provided are: "--stdio" !!
                                          2024-04-03 06:18:31.540531 [INFO][ThreadId(1)] -   start_server perl started.
                                          2024-04-03 06:18:31.540748 [INFO][ThreadId(1)] - {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix"]}}},"completion":{"completionItem":{"commitCharactersSupport":false,"deprecatedSupport":false,"documentationFormat":["plaintext"],"insertReplaceSupport":false,"preselectSupport":false,"snippetSupport":false},"completionItemKind":{},"dynamicRegistration":false,"insertTextMode":1},"formatting":{"dynamicRegistration":false},"hover":{"contentFormat":["plaintext","markdown"],"dynamicRegistration":false},"publishDiagnostics":{"codeDescriptionSupport":false,"dataSupport":false,"relatedInformation":true,"versionSupport":false},"rangeFormatting":{"dynamicRegistration":false},"signatureHelp":{"contextSupport":false,"dynamicRegistration":false,"signatureInformation":{"activeParameterSupport":false,"documentationFormat":["plaintext"],"parameterInformation":{"labelOffsetSupport":false}}},"synchronization":{"didSave":true,"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":false}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true}},"clientInfo":{"name":"","version":"-alpha"},"processId":27088,"rootUri":"file:///C:/usr/local/apps/npp/npp862.ps3","workspaceFolders":[{"name":"npp862.ps3","uri":"file:///C:/usr/local/apps/npp/npp862.ps3"}]}}
                                          2024-04-03 06:18:31.541009 [INFO][ThreadId(10)] - <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix"]}}},"completion":{"completionItem":{"commitCharactersSupport":false,"deprecatedSupport":false,"documentationFormat":["plaintext"],"insertReplaceSupport":false,"preselectSupport":false,"snippetSupport":false},"completionItemKind":{},"dynamicRegistration":false,"insertTextMode":1},"formatting":{"dynamicRegistration":false},"hover":{"contentFormat":["plaintext","markdown"],"dynamicRegistration":false},"publishDiagnostics":{"codeDescriptionSupport":false,"dataSupport":false,"relatedInformation":true,"versionSupport":false},"rangeFormatting":{"dynamicRegistration":false},"signatureHelp":{"contextSupport":false,"dynamicRegistration":false,"signatureInformation":{"activeParameterSupport":false,"documentationFormat":["plaintext"],"parameterInformation":{"labelOffsetSupport":false}}},"synchronization":{"didSave":true,"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":false}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true}},"clientInfo":{"name":"","version":"-alpha"},"processId":27088,"rootUri":"file:///C:/usr/local/apps/npp/npp862.ps3","workspaceFolders":[{"name":"npp862.ps3","uri":"file:///C:/usr/local/apps/npp/npp862.ps3"}]}}
                                          2024-04-03 06:18:31.541807 [INFO][ThreadId(1)] - Storing on_buffer_activated request for C:\usr\local\apps\npp\npp862.ps3\lsp-test.pl [2058226367408]
                                          2024-04-03 06:18:31.724127 [INFO][ThreadId(9)] - >>>  {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"resolveProvider":true,"triggerCharacters":["$","@","%","-",">",":"]},"definitionProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"hoverProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",",")"]},"workspace":{"workspaceFolders":{"supported":true}}}}}
                                          2024-04-03 06:18:31.724411 [INFO][ThreadId(1)] - ServerCapabilities { position_encoding: None, text_document_sync: Some(Kind(Incremental)), selection_range_provider: None, hover_provider: Some(Simple(true)), completion_provider: Some(CompletionOptions { resolve_provider: Some(true), trigger_characters: Some(["$", "@", "%", "-", ">", ":"]), all_commit_characters: None, work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, completion_item: None }), signature_help_provider: Some(SignatureHelpOptions { trigger_characters: Some(["(", ",", ")"]), retrigger_characters: None, work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None } }), definition_provider: Some(Left(true)), type_definition_provider: None, implementation_provider: None, references_provider: None, document_highlight_provider: None, document_symbol_provider: Some(Left(true)), workspace_symbol_provider: Some(Left(true)), code_action_provider: None, code_lens_provider: None, document_formatting_provider: Some(Left(true)), document_range_formatting_provider: Some(Left(true)), document_on_type_formatting_provider: None, rename_provider: None, document_link_provider: None, color_provider: None, folding_range_provider: None, declaration_provider: None, execute_command_provider: None, workspace: Some(WorkspaceServerCapabilities { workspace_folders: Some(WorkspaceFoldersServerCapabilities { supported: Some(true), change_notifications: None }), file_operations: None }), call_hierarchy_provider: None, semantic_tokens_provider: None, moniker_provider: None, linked_editing_range_provider: None, inline_value_provider: None, inlay_hint_provider: None, diagnostic_provider: None, experimental: None }
                                          2024-04-03 06:18:31.724480 [INFO][ThreadId(1)] - Handling stored file C:\usr\local\apps\npp\npp862.ps3\lsp-test.pl [2058226367408]
                                          2024-04-03 06:18:31.724488 [INFO][ThreadId(10)] - <<< {"jsonrpc":"2.0","method":"initialized","params":{}}
                                          2024-04-03 06:18:31.724572 [INFO][ThreadId(10)] - <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"perl","text":"#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\nuse lib '.';\r\nuse myModule;\r\n\r\nprint \"Hello World\\n\";\r\n\r\n=head2 ThisHereFunction\r\n\r\nPOD description\r\n\r\n=cut\r\n\r\n# Comment before sub\r\nsub ThisHereFunction {\r\n    # comment as first line of sub\r\n    my ($x,$y,$z) = @_;\r\n    return 0;\r\n}\r\n\r\nsub second { 1; }\r\n\r\nmy $t = ThisHereFunction();\r\n\r\nmy $f = myModule::func();\r\n","uri":"file:///C:/usr/local/apps/npp/npp862.ps3/lsp-test.pl","version":0}}}
                                          2024-04-03 06:18:31.724604 [INFO][ThreadId(10)] - <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///C:/usr/local/apps/npp/npp862.ps3/lsp-test.pl"}}}
                                          2024-04-03 06:18:31.726886 [INFO][ThreadId(9)] - >>>  {"jsonrpc":"2.0","id":0,"method":"workspace/workspaceFolders"}
                                          2024-04-03 06:18:31.726966 [ERROR][ThreadId(1)] - Unhandled request 
                                          {
                                            "id": 0,
                                            "jsonrpc": "2.0",
                                            "method": "workspace/workspaceFolders"
                                          }
                                          2024-04-03 06:18:31.727015 [INFO][ThreadId(9)] - >>>  {"jsonrpc":"2.0","id":1,"method":"workspace/workspaceFolders"}
                                          2024-04-03 06:18:31.727046 [ERROR][ThreadId(1)] - Unhandled request 
                                          {
                                            "id": 1,
                                            "jsonrpc": "2.0",
                                            "method": "workspace/workspaceFolders"
                                          }
                                          2024-04-03 06:18:31.780060 [INFO][ThreadId(9)] - >>>  {"jsonrpc":"2.0","id":1,"result":[{"kind":12,"location":{"range":{"start":{"line":16,"character":0},"end":{"line":20,"character":100}},"uri":"file:///C:/usr/local/apps/npp/npp862.ps3/lsp-test.pl"},"name":"ThisHereFunction"},{"kind":12,"location":{"range":{"start":{"line":22,"character":0},"end":{"line":22,"character":100}},"uri":"file:///C:/usr/local/apps/npp/npp862.ps3/lsp-test.pl"},"name":"second"}]}
                                          2024-04-03 06:18:32.738187 [INFO][ThreadId(9)] - >>>  {"jsonrpc":"2.0","id":2,"method":"workspace/workspaceFolders"}
                                          2024-04-03 06:18:32.738469 [ERROR][ThreadId(1)] - Unhandled request 
                                          {
                                            "id": 2,
                                            "jsonrpc": "2.0",
                                            "method": "workspace/workspaceFolders"
                                          }
                                          2024-04-03 06:18:58.116894 [INFO][ThreadId(10)] - <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/definition","params":{"position":{"character":8,"line":26},"textDocument":{"uri":"file:///C:/usr/local/apps/npp/npp862.ps3/lsp-test.pl"}}}
                                          2024-04-03 06:18:58.117730 [INFO][ThreadId(9)] - >>>  {"jsonrpc":"2.0","id":2,"result":null}
                                          

                                          It looks like the server replies with "result":null …

                                          stopping the server, clearing out the log, and simplifying the code to

                                          #!/usr/bin/perl
                                          
                                          use warnings;
                                          use strict;
                                          use lib '.';
                                          use myModule;
                                          
                                          print "Hello World\n";
                                          
                                          sub ThisHereFunction {
                                              my ($x,$y,$z) = @_;
                                              return 0;
                                          }
                                          
                                          my $t = ThisHereFunction();
                                          

                                          … with my cursor in the middle of the sH from ThisHereFunction() on the last line

                                          Then I start the LSP server again, and do Goto definition, and even though the definition is just a few lines above in the same file, it doesn’t go anywhere, and the pair of commands in the log shows:

                                          2024-04-03 06:36:09.405503 [INFO][ThreadId(13)] - <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/definition","params":{"position":{"character":12,"line":14},"textDocument":{"uri":"file:///C:/usr/local/apps/npp/npp862.ps3/lsp-test.pl"}}}
                                          2024-04-03 06:36:09.406479 [INFO][ThreadId(12)] - >>>  {"jsonrpc":"2.0","id":3,"result":null}
                                          

                                          So it’s still returning null. :-(

                                          I am hoping that @Michael-Vincent , who knows Perl, and has tried your plugin earlier in this conversation with other languages, and seems to understand how it should behave, will be able to try some experiments with Perl and the PerlNavigator, so that he can supply differences of behavior between what he’s already seen with other languages and what he sees in Perl … or so that he can tell me what I’m doing wrong with my what-I-thought-were-simple Perl experiments. It might just be that I’m not doing things in the right order, or not using the right steps to activate features.

                                          Everything seems to work with 8.6.5 so far.

                                          Oh, good. I was thinking of updating to that version for my daily use anyway, since it seems to be stable. But it will be nice to be able to play with this plugin without having to jump to a different N++ instance.

                                          Michael VincentM EkopalypseE 2 Replies Last reply Reply Quote 2
                                          • Michael VincentM
                                            Michael Vincent @PeterJones
                                            last edited by Michael Vincent

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

                                            I am hoping that @Michael-Vincent , who knows Perl, and has tried your plugin earlier in this conversation with other languages,

                                            I should note: Notepad++ 8.6.5 64-bit with NppLspClient v.0.0.26-alpha

                                            Trying with Perl setup as @PeterJones , I get the same results - it seems like it’s not working.

                                            With this Python setup:

                                            [lspservers.python]
                                            mode = "io"
                                            executable = 'c:\Users\VinsWorldcom\AppData\Roaming\Python\Scripts\pylsp.exe'
                                            args = '--check-parent-process --log-file c:\Users\VinsWorldcom\tmp\pylsp.log -vvv'
                                            auto_start_server = false
                                            

                                            and this simple Python script:

                                            #!python
                                            
                                            import os
                                            import sys
                                            
                                            def myadd(n1, n2):
                                                return n1 + n2
                                                
                                            t = myadd(1, 2)
                                            

                                            Putting my caret between the y and a of the myadd() call on the last line and selecting Plugins => NppLspClient => Goto definition, it moves my caret to just before the m in the def myadd( ... line - as expected. Log shows:

                                            2024-04-03 10:44:09.702659 [INFO][ThreadId(4)] - <<< {"id":75,"jsonrpc":"2.0","method":"textDocument/definition","params":{"position":{"character":6,"line":8},"textDocument":{"uri":"file:///C:/Users/VinsWorldcom/tmp/crapps/test.py"}}}
                                            2024-04-03 10:44:09.705734 [INFO][ThreadId(3)] - >>>  {"jsonrpc":"2.0","id":75,"result":[{"uri":"file:\/\/\/c:\/Users\/VinsWorldcom\/tmp\/crapps\/test.py","range":{"start":{"line":5,"character":4},"end":{"line":5,"character":9}}}]}
                                            

                                            Cheers.

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