Microsoft Language Server Protocol (LSP): A possible revolution for Notepad++?
-
which PS3 plugin did you install? Depending on it you have to use the correct python version and copy
the pythonXX.dll to the PS plugin directory.
Like I have the latest PS, hence I use python 3.8 -
Now I’m thinking that, if I remember correctly, you have to use python 3.8. PS3 started with this version.
-
@Ekopalypse said in Microsoft Language Server Protocol (LSP): A possible revolution for Notepad++?:
which PS3 plugin did you install? Depending on it you have to use the correct python version and copy
the pythonXX.dll to the PS plugin directory.I installed v3.0.4 and have the DLL for python 3.8 (that was bundled with the above ZIP) already in place:
PS VinsWorldcom C:\usr\bin\npp64\plugins\PythonScript > ls -al total 5680 drwxr-x--- 1 VinsWorldcom 0 Nov 5 15:00 .\ drwxr-x--- 1 VinsWorldcom 0 Nov 5 15:00 ..\ drwxr-x--- 1 VinsWorldcom 0 Sep 7 07:33 doc\ drwxr-x--- 1 VinsWorldcom 0 Nov 5 14:27 lib\ -rw-r----a 1 VinsWorldcom 4209224 Jul 20 16:06 python38.dll -rw-r----a 1 VinsWorldcom 1606144 Sep 7 07:31 PythonScript.dll drwxr-x--- 1 VinsWorldcom 0 Nov 5 14:34 scripts\
Am I to understand that I need to upgrade my OS Python3.6 version to match the 3.8 for PythonScript?
Cheers.
-
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 theprefer installed python libraries
from PS configuration dialog. -
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.
-
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 themjedi.preload_module(['os','sys', ...])
-
@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.
-
:-D - the same would happen to me if I try to write perl :-D
-
@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.:
У меня есть немного для php, js, vbs, 1C, MySql.
https://github.com/trdm/jn-npp-scripts -
@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.
-
let me have a look and play with it a bit.
-
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. -
@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.
-
@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. -
@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!
-
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.
-
-