• Login
Community
  • Login

Microsoft Language Server Protocol (LSP): A possible revolution for Notepad++?

Scheduled Pinned Locked Moved General Discussion
38 Posts 7 Posters 10.8k 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.
  • E
    Ekopalypse @Michael Vincent
    last edited by Nov 5, 2020, 8:07 PM

    @Michael-Vincent

    Yes, and copy the pythonXX.dll from the installation to C:\usr\bin\npp64\plugins\PythonScript
    then PS sees all your pip installed modules.
    In addition, check the prefer installed python libraries from PS configuration dialog.

    b83b6798-9b58-47cf-9c5c-ab5bc64325ed-image.png

    M 1 Reply Last reply Nov 5, 2020, 8:17 PM Reply Quote 1
    • M
      Michael Vincent @Ekopalypse
      last edited by Nov 5, 2020, 8:17 PM

      @Ekopalypse

      Thanks - I actually got it working by copying PyFlakes, Jedi (and Parso which seemed to be a Jedi dependency) install directories from my system Python3 to the PythonScript/lib folder.

      Autocompletion now works for “objects”:

      import socket
      
      addrs = socket.getaddrinfo("localhost", 12345, socket.AF_UNSPEC, socket.SOCK_DGRAM)
      sock = None
      
      for addr in addrs:
          af, socktype, proto, cname, sa = addr
      
          try:
              sock = socket.socket(af, socktype, proto)
      [...]
      

      and then typing:

      sock. brings up a list of all methods I can call on the socket object - but it’s slow - noticeably slow in populating that autocomplete list.

      Pretty cool though! I’ll do some more playing with this and thanks for the script and help setting it up.

      Cheers.

      E 1 Reply Last reply Nov 5, 2020, 8:19 PM Reply Quote 0
      • E
        Ekopalypse @Michael Vincent
        last edited by Nov 5, 2020, 8:19 PM

        @Michael-Vincent

        it should be slow only for the first time it discovers an object. If you use certain objects more often
        then others, you could try to preload them jedi.preload_module(['os','sys', ...])

        M 1 Reply Last reply Nov 5, 2020, 8:22 PM Reply Quote 1
        • M
          Michael Vincent @Ekopalypse
          last edited by Nov 5, 2020, 8:22 PM

          @Ekopalypse said in Microsoft Language Server Protocol (LSP): A possible revolution for Notepad++?:

          preload them jedi.preload_module([‘os’,‘sys’, …])

          Thanks for the tip! Python is obviously not my strength; hence, the want for some “IDE-lite” help from Notepad++.

          Cheers.

          E 1 Reply Last reply Nov 5, 2020, 8:23 PM Reply Quote 1
          • E
            Ekopalypse @Michael Vincent
            last edited by Nov 5, 2020, 8:23 PM

            @Michael-Vincent

            :-D - the same would happen to me if I try to write perl :-D

            1 Reply Last reply Reply Quote 1
            • T
              TroshinDV
              last edited by Nov 6, 2020, 12:03 AM

              @pidgeon777 said in Microsoft Language Server Protocol (LSP): A possible revolution for Notepad++?:

              Microsoft Language Server Protocol (LSP) defines the protocol used between an editor or IDE and a language server that provides language features like autocomplete, go to definition, find all references etc.:

              Screenshot_270.png
              У меня есть немного для php, js, vbs, 1C, MySql.
              https://github.com/trdm/jn-npp-scripts

              1 Reply Last reply Reply Quote 0
              • M
                Michael Vincent @Ekopalypse
                last edited by Dec 2, 2020, 2:39 AM

                @Ekopalypse said in Microsoft Language Server Protocol (LSP): A possible revolution for Notepad++?:

                ok, this is my “lsp” script (called python_ide.py)

                I wonder if this pylspclient can be used? It’s supposedly an LSP client written in Python so theoretically PythonScript could run it.

                I’ve been playing with it from the command line with my system Python3 and not having much luck with the examples/python-language-server.py script included and having the python-language-server installed.

                Cheers.

                E 2 Replies Last reply Dec 2, 2020, 1:53 PM Reply Quote 1
                • E
                  Ekopalypse @Michael Vincent
                  last edited by Dec 2, 2020, 1:53 PM

                  @Michael-Vincent

                  let me have a look and play with it a bit.

                  1 Reply Last reply Reply Quote 1
                  • E
                    Ekopalypse @Michael Vincent
                    last edited by Ekopalypse Dec 2, 2020, 2:14 PM Dec 2, 2020, 2:11 PM

                    @Michael-Vincent

                    It looks like the main problem might be that this lspclient is written for Python2.
                    Let me see if I can make a working version. Probably in 6-7 hours.

                    M 1 Reply Last reply Dec 2, 2020, 3:23 PM Reply Quote 0
                    • M
                      Michael Vincent @Ekopalypse
                      last edited by Dec 2, 2020, 3:23 PM

                      @Ekopalypse said in Microsoft Language Server Protocol (LSP): A possible revolution for Notepad++?:

                      lspclient is written for Python2

                      Weird - it seems to “run” OK - not throwing any errors, but just not initializing with the language server:

                      PS VinsWorldcom ~\source\personal\pylspclient\examples > python3 .\python-language-server.py
                      2020-12-02 10:19:26,251 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'autopep8': No module named 'pycodestyle'
                      
                      2020-12-02 10:19:26,297 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'pycodestyle': No module named 'pycodestyle'
                      
                      2020-12-02 10:19:26,301 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'pydocstyle': No module named 'pydocstyle'
                      
                      2020-12-02 10:19:26,492 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'rope_completion': No module named 'rope'
                      
                      2020-12-02 10:19:26,496 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'rope_rename': No module named 'rope'
                      
                      {'capabilities': {'codeActionProvider': True, 'codeLensProvider': {'resolveProvider': False}, 'completionProvider': {'resolveProvider': False, 'triggerCharacters': ['.']}, 'documentFormattingProvider': True, 'documentHighlightProvider': True, 'documentRangeFormattingProvider': True, 'documentSymbolProvider': True, 'definitionProvider': True, 'executeCommandProvider': {'commands': []}, 'hoverProvider': True, 'referencesProvider': True, 'renameProvider': True, 'foldingRangeProvider': True, 'signatureHelpProvider': {'triggerCharacters': ['(', ',', '=']}, 'textDocumentSync': {'change': 2, 'save': {'includeText': True}, 'openClose': True}, 'workspace': {'workspaceFolders': {'supported': True, 'changeNotifications': True}}, 'experimental': {}}}
                      init =  None
                      

                      NOTE: I made 2 small changes to the the examples/python-language-server.py script:

                      diff --git a/examples/python-language-server.py b/examples/python-language-server.py
                      index 72026e5..0e67858 100644
                      --- a/examples/python-language-server.py
                      +++ b/examples/python-language-server.py
                      @@ -19,7 +19,7 @@ class ReadPipe(threading.Thread):
                                   line = self.pipe.readline().decode('utf-8')
                      
                       if __name__ == "__main__":
                      -    pyls_cmd = ["python", "-m", "pyls"]
                      +    pyls_cmd = ["python3", "-m", "pyls"]
                           p = subprocess.Popen(pyls_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                           read_pipe = ReadPipe(p.stderr)
                           read_pipe.start()
                      @@ -143,7 +143,7 @@ if __name__ == "__main__":
                           root_uri = 'file:///path/to/python/project'
                           workspace_folders = [{'name': 'python-lsp', 'uri': root_uri}]
                           print(lsp_client.initialize(p.pid, None, root_uri, None, capabilities, "off", workspace_folders))
                      -    print(lsp_client.initialized())
                      +    print("init = ", lsp_client.initialized())
                      
                           lsp_client.shutdown()
                           lsp_client.exit()
                      

                      Cheers.

                      1 Reply Last reply Reply Quote 0
                      • E
                        Ekopalypse
                        last edited by Dec 3, 2020, 12:06 AM

                        @Michael-Vincent - I tried to make it work but after three
                        Npp crashes I decided to make my implementation work with python3.
                        I’ll keep working on it an updates will be made available via the github repo.

                        M 1 Reply Last reply Dec 3, 2020, 12:18 AM Reply Quote 2
                        • M
                          Michael Vincent @Ekopalypse
                          last edited by Dec 3, 2020, 12:18 AM

                          @Ekopalypse said in Microsoft Language Server Protocol (LSP): A possible revolution for Notepad++?:

                          I’ll keep working on it an updates will be made available via the github repo.

                          I’ll keep checking back then - thanks!

                          pidgeon777P 1 Reply Last reply Dec 20, 2021, 10:17 AM Reply Quote 1
                          • pidgeon777P
                            pidgeon777 @Michael Vincent
                            last edited by Dec 20, 2021, 10:17 AM

                            A plugin implementing an LSP client in Notepad++ has finally been released.

                            https://github.com/Ekopalypse/NppLspClient

                            Credits to @Ekopalypse for that.

                            I encourage everyone to give it a try and report back for any found issue.

                            E 1 Reply Last reply Dec 20, 2021, 11:37 AM Reply Quote 2
                            • E
                              Ekopalypse @pidgeon777
                              last edited by Dec 20, 2021, 11:37 AM

                              … but bear in mind that this is in an early alpha stage and that there is another plugin that already covers some pitfalls when it comes to implementing LSP for Npp and Scintilla.

                              1 Reply Last reply Reply Quote 2
                              • M Michael Vincent referenced this topic on Jan 6, 2022, 2:02 PM
                              • First post
                                Last post
                              The Community of users of the Notepad++ text editor.
                              Powered by NodeBB | Contributors