Sublime Forum

LSP: Universal language server plugin

#7

Awesome that you got it working!

Also appreciate the suggestions:

  1. Created an issue for this: https://github.com/tomv564/LSP/issues/1
  2. Supported by this plugin, but not yet by clangd.
  3. Could be a clang issue, could also be LSP falling back to sublime’s “smart” syntax-based suggestions.
  4. Clangd has recently added support for receiving extra compiler flags when you open a document. This is unfortunately not part of the LSP protocol, but I created an issue here: https://github.com/tomv564/LSP/issues/2
0 Likes

#8

Thanks for checking it out!

The client settings for plain javascript were missing - I have just added them in the default jsts configuration. Can update and try it again?

LSP uses both the full syntax name and scopes to detect relevant documents, this will probably need to change to something less brittle.

The auto_complete_triggers are left up to the user to add to Sublime’s syntax-specific settings.

In the short term LSP could include some defaults for popular languages, I created an issue for making this part of the setup easy.

1 Like

#9

Had just a very short look into it.

The python language server complains about the document not being within the workspace. May this caused by \\ being used on windows? Maybe some path translation is required?

pip install python-language-server

python 3.5.2 (windows 10 x64)

LSP: (stderr):  Traceback (most recent call last): 
LSP: (stderr):  File "c:\apps\python\lib\site-packages\jsonrpc\manager.py", line 108, in _get_responses 
LSP: (stderr):  result = method(*request.args, **request.kwargs) 
LSP: (stderr):  File "c:\apps\python\lib\site-packages\pyls\python_ls.py", line 83, in m_text_document__did_close 
LSP: (stderr):  self.workspace.rm_document(textDocument['uri']) 
LSP: (stderr):  File "c:\apps\python\lib\site-packages\pyls\workspace.py", line 31, in rm_document 
LSP: (stderr):  self._docs.pop(doc_uri) 
LSP: (stderr):  KeyError: 'file:///C:/Apps/Sublime/Data/Packages/CNC%20Sinumerik%20840D/plugin.py' 
LSP: notify: textDocument/didOpen 
LSP: (stderr):  2017-08-15 22:58:50,653 UTC - ERROR - jsonrpc.manager - API Exception: {'message': 'Document file:///C:/Apps/Sublime/Data/Packages/LSP/main.py not in workspace \\Apps\\Sublime\\Data\\Packages', 'type': 'ValueError', 'args': ('Document file:///C:/Apps/Sublime/Data/Packages/LSP/main.py not in workspace \\Apps\\Sublime\\Data\\Packages',)} 
LSP: (stderr):  Traceback (most recent call last): 
LSP: (stderr):  File "c:\apps\python\lib\site-packages\jsonrpc\manager.py", line 108, in _get_responses 
LSP: (stderr):  result = method(*request.args, **request.kwargs) 
LSP: (stderr):  File "c:\apps\python\lib\site-packages\pyls\python_ls.py", line 86, in m_text_document__did_open 
LSP: (stderr):  self.workspace.put_document(textDocument['uri'], textDocument['text']) 
LSP: (stderr):  File "c:\apps\python\lib\site-packages\pyls\workspace.py", line 27, in put_document 
LSP: (stderr):  self._check_in_workspace(doc_uri) 
LSP: (stderr):  File "c:\apps\python\lib\site-packages\pyls\workspace.py", line 69, in _check_in_workspace 
LSP: (stderr):  raise ValueError("Document %s not in workspace %s" % (doc_uri, self.root)) 
LSP: (stderr):  ValueError: Document file:///C:/Apps/Sublime/Data/Packages/LSP/main.py not in workspace \Apps\Sublime\Data\Packages 
0 Likes

#10

It looks like you have an older version of python-language-service installed, as _check_in_workspace disappeared in the (latest) release 0.4.1. Could you update and try again?

1 Like

#11

I quickly called pip install without -U flag yesterday, but wasn’t aware of it not to call an upgrade of existing packages.

Works like a charm now.

One tip: You might want to disable sublime’s default "show_definitions" setting for views handled by the LSP in order to avoid popup fighting.

I am really happy to see this plugin. I was looking for some approaches of language servers for ST again and again. It will enable ST to support nearly any language in the future without the need to create dedicated language packages for ST. Really cool.

0 Likes

#12

I tried hooking up Go with https://github.com/sourcegraph/go-langserver

Find Symbol References and Go to Symbol Definition work fairly well. Though, the autocompletion is flakey (especially non-stdlib) and the go-langserver process is chewing major CPU!

0 Likes

#13

@tomv564 The commands offered in the right-click menu seem like they should be based on where the mouse cursor is rather than where the text input caret is

0 Likes

#14

Glad you like it, agree about show_definitions (created an issue: https://github.com/tomv564/LSP/issues/9)

About dedicated language packages, they are often impressively complete and specialised. I hope we can get “good enough” language support with a consistent user experience with LSP, instead of covering all the nice-to-haves/quirks of each language.

0 Likes

#15

How does this differ from https://github.com/sourcegraph/sublime-lsp?

0 Likes

#16

Having to primary-click before opening the context menu was always a major annoyance.

It should be fixed now, along with the Code Actions context menu item.

Thanks for the feedback!

1 Like

#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