Sublime Forum

LSP: Universal language server plugin

#17

Sublime-lsp is a fork of Microsoft’s (excellent, IMO) Typescript plugin. It was a clever way to get a polished package up and running quickly, but there is a lot of Typescript baggage left in the implementation.

By now, I believe LSP has a more complete implementation of the LSP protocol, and has been tested against more language servers.

There appears to be little effort going into sublime-lsp from sourcegraph or other volunteers since Nov 2016.

1 Like

#18

Great work! I’ll check it out soon with PHP, Python and JavaScript.

In the mean time, I’ve created a pull request to list it on the LSP page.

0 Likes

#19

Awesome, thanks for submitting it there!
I haven’t tried the PHP language server yet, curious how it works!

0 Likes

#20

Should I replace https://github.com/Microsoft/TypeScript-Sublime-Plugin with this plugin?

0 Likes

#21

If you’re happy with Microsoft’s Typescript package I would hesitate to switch - for Typescript development it is more complete and stable than this LSP package.

LSP does offer code actions which Microsoft’s package does no have. I also use this package often for typescript development, so it is likely to improve in the future!

1 Like

#22

Thanks to many bug reports and contributions, version 0.2.0 was released this week.
Significant improvements were made in diagnostics handling and completions.

The update notes are on Github.

Besides Python and Javascript/Typescript we’ve had users try it with Clangd, Flow, PHP and OCaml/Reason!

6 Likes

#23

Hey Tom, thanks for the client, I would love to set it up for Java. I couldn’t find an example to get this done. I think the server is: https://github.com/eclipse/eclipse.jdt.ls based on http://langserver.org/

Would it be possible to get the client to connect for Java? If so, do you have a set of steps to follow?

0 Likes

#24

Hi Arin,

I haven’t seen reports of other people using the java language server yet. It is in use in the Atom IDE project and sounds like a complete implementation.

The installation steps for eclipse.jdt.ls sound a bit Eclipse-focused. Atom’s ide-java package provides some of the details you need (see their code here: https://github.com/atom/ide-java/blob/master/lib/main.js)

Download and uncompress this package

Try launching it manually first (see “command” below, or the ide-java code).
Be sure to set the config parameter to the relevant “config_win/”, “config_mac/” or “config_linux/” path within the language server you unpacked.

The LSP client config (add to your LSP Settings) should then look approximately like this:

"jdtls": {
	"command": ["java", "-jar", "PATH_TO_JDT_SERVER/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar", "-configuration", "PATH_TO_CONFIG_DIR"],
	"scopes": ["source.java"],
	"syntaxes": ["Packages/Java/Java.sublime-syntax"],
	"languageId": "java"
},

I’m keen to get documentation and default config for this added to the LSP project, please feel free to share your findings on GitHub! (https://github.com/tomv564/LSP)

1 Like

#25

We’ve accumulated features and fixes from 8 contributors over the last 2 weeks.
Time for another release: 0.2.1 on Package Control.

Besides Go, the package has been tested with the Julia and OCaml language servers (including the Reason language)

Release notes are here: https://github.com/tomv564/LSP/releases/tag/0.2.1

3 Likes

#26

This is really exciting! PHP support doesn’t seem to work, but I’ll see if I can help fix it.

0 Likes

#27

@tomv564 I’m using this with the jsts server and the thing I’m constantly running into is that it doesn’t pick up changes to type definitions/imports. I’m not sure if that’s something LSP should do, or if it’s the server… My current solution is to restart the server and then trigger it to run my file again by adding and removing some lines and then saving. Two questions:

  • do I open an issue for LSP or for the jsts server?
  • is there a clean way of clearing a server’s state and running the diagnostics again for a file?
0 Likes

#28

I suggest you open an issue for the javascript/typescript server, and it would be likelier to be fixed if you could narrow down a minimal reproduction.

Another case that the javascript/typescript server does not support is changes outside the editor (eg. git checkout another-branch). There is an API for this (DidChangeWatchedFiles), but I haven’t seen many implementations of this yet.

Restart server is a bit of a hack - it should be sending a didOpen for the document you were in, then you would get the diagnostics without the change. That could be a good suggestion for LSP.

0 Likes

#29

Thanks! My most common case is with type defs that are generated, we work with loads of code and api generation that we type-check against, and that’s always a process outside the editor that updates the imports. So that mostly with jsts then.

0 Likes

#30

I am trying to set up LSP for python, but it does not work for me. I have setup the LSP server , but when I choose the option to start the server from ST , it never complains about not being able to start it. Since it never complains, I assume that it was able to start it.

Here is what I have done till now.

  1. pip install python-language-server
  2. Installed the LSP plugin for ST
  3. opened a Python file
  4. Pressed CMD+SHIFT+P to choose Enable language server globally

Here is what I see in the logs (I can see that there are some errors)

LSP: global clients: jsts=True Package Control: Skipping automatic upgrade, last run at 2018-05-11 22:31:08, next run at 2018-05-11 23:31:08 or after LSP: global clients: pyls=True, jsts=True reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True LSP: global clients: pyls=False, jsts=True Traceback (most recent call last): File "/Users/gjanjua/Library/Application Support/Sublime Text 3/Installed Packages/LSP.sublime-package/plugin/configuration.py", line 81, in <lambda> File "/Users/gjanjua/Library/Application Support/Sublime Text 3/Installed Packages/LSP.sublime-package/plugin/core/clients.py", line 170, in unload_window_clients File "/Users/gjanjua/Library/Application Support/Sublime Text 3/Installed Packages/LSP.sublime-package/plugin/core/clients.py", line 211, in unload_client AttributeError: 'NoneType' object has no attribute 'send_request' reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=False, jsts=True LSP: global clients: pyls=True, jsts=True reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True ignored packages updated to: ["Jedi - Python autocompletion", "Vintage"] unloading plugin Jedi - Python autocompletion.__init__ reloading settings Packages/Jedi - Python autocompletion/sublime_jedi.sublime-settings generating meta info summary reloading settings Packages/User/Preferences.sublime-settings ignored packages updated to: ["Vintage"] reloading plugin Jedi - Python autocompletion.__init__ reloading settings Packages/Jedi - Python autocompletion/sublime_jedi.sublime-settings generating meta info summary reloading settings Packages/User/Preferences.sublime-settings reloading settings Packages/User/Preferences.sublime-settings reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True reloading settings Packages/User/LSP.sublime-settings LSP: global clients: pyls=True, jsts=True
Can you please let me know what is the wrong thing that I am doing here ?

Thanks
Gagan

0 Likes

#31

Do you know why lsp: show diagnostic messages for a C++ file are not similar to what I can see with cland-check ?

There are a log of false positive errors in the lsp: show diagnostic message window that I want to ignore, however, I am not sure how. I have edited my compile db json file and test the c++ file with new compile db json using cland-check, it is ok. However, the error messages are still appear in the lsp: diagnostic message window.

thank you.

0 Likes

#32

LSP uses clangd iirc?

0 Likes

#33

what is clandg iirc ? I have clangd on my system but not sure what should I do to force it reproduce clang-check output.

0 Likes

#34

LSP = language server protocal.
iirc = if I remember correctly.

clangd is a language server that implements the Language Server Protocol.

what should I do to force it reproduce clang-check output.

I am not sure whether this could be done but people use clangd here because it implements a LSP server.

0 Likes

#35

I prefer cquery over clangd. It’s more lightweight and runs a bit faster in my experiences.

4 Likes

#36

@randy3k can you explain how to use ccls/cquery using LSP in windows. I have been trying for a couple of days but it is not working and the official documentation for C/C++ does not have much setup guide as it has for other languages (it redirects to the GitHub rep. which don’t have much info for sublime either).
Thanks in advance

0 Likes