-
Notifications
You must be signed in to change notification settings - Fork 255
Adding support for Sublime Text 3 #214
Comments
@urschrei - great that you're digging into this. A couple things - Can you confirm that the test you're doing of hovering .to_vec works in VSCode with your configuration? I want to isolate that it's specific to the sublime plugin. I'm a little confused by:
Should this be read as separate lines? Seems so, but I'm not sure how the line separator works here. I don't think we use one generally since it would (I think) be added to the character count in Content-Length: 259 |
Sorry, I hadn't seen your comments in sourcegraph/sublime-lsp#12 (comment)! I think the separators I pasted above are inserted by the debug output in the Sublime console; if they weren't, wouldn't I be seeing errors from the RLS binary, as opposed to empty responses? In any case:
After a Sublime restart, I can see the debug telemetry being sent and received again, and I get squiggles and errors as I type. (🎉): Some questions (these aren't necessarily all for you. @alexsaveliev probably has some of them covered)
I'm happy to turn the results into some docs and screenshots, and then open a PR. |
Awesome! I'm glad we see some signs of life. Would love to follow along with progress here |
Circling back to this. I'm trying out https://github.com/tomv564/LSP with a recent rls, and everything seems to work now. Closing, but feel free to reopen if I'm missing something. |
I expect we'd need to implement our custom parts of the protocol to have a complete experience here. |
@nrc - seems like this bug is fixed, but we could open another for the extras you mention |
They're not really extras - its required to offer the complete RLS experience. But I plan to write some docs about this and organise the issues a bit today. |
@kamek-pf - I saw some of that, but it took a few seconds for the error to go away. You're seeing that sometimes the error doesn't go away at all? |
From what I see, it looks like it never goes away unless you break something else. |
@kamek-pf I played with it for a few minutes but couldn't get it to break once. That said, I don't doubt you're seeing an issue. Just to double check, how recent is your rls? |
I just installed it through rustup on my machine at work :
|
This is also going to cause problems for people who use Rust Enhanced (which is where all the Sublime Rust development is happening now), because it's not clear how to point LSP at its definitions (although that's more of an issue on their side) |
You can change the config to point to the different syntax file like this:
However, there currently isn't a way to merge/update the existing clients dictionary (see sublimelsp/LSP#76), so you have to copy all clients to your custom config. |
After ~3 days of use, this seems quite stable. I know there's some functionality missing, but aside from occasionally needing a server restart (which can be triggered from the command palette), it's working well enough to use as part of my setup. |
So, there seems to have been a blur of activity, and encouraged, I installed the LSP plugin on my Sublime 3, and tried editing Rust code. It says "LSP initialized" in the status bar, but that disappears after a short while. Besides that, I don't notice anything to be different from the normal editing experience. There is no autocomplete. Goto definition from the menu bar causes an error "Unable to find ..." to show in the status bar. I've tried the "LPS: show diagnostics", but it just shows a separate console-like window... that doesn't print anything at all. My RLS version, |
@golddranks Are you using Rust Enhanced, or the bundled Sublime Text Rust plugin? |
I haven't installed Rust Enhanced, but it recognizes that my code is Rust and syntax-hilights it, so I guess I'm using the bundled one...? |
@golddranks And you can |
Like I said, it's
|
@golddranks Hm. The only other thing I can suggest is copying the prefs explicitly into your LSP user prefs: Here's what I'm using, adapted for the bundled Rust package: https://gist.github.com/urschrei/5f526b1a00378bfc049b23323b0002fb |
Okay, I tried that. (I earlier had only the Still no effect – nothing changes. I'd like to help with debugging this, but I don't have a clue where to start. Is there a some way I can log the traffic between RLS and the editor? |
@golddranks Did you install LSP from the package manager ? I couldn't get it to work this way, I had to clone the repo. Not sure if anyone else is seeing this btw. |
@kamek-pf I installed it using Sublime's package control. I'll try installing from the repo! |
Tried to install it from the repo. Still no signs of life. Btw. now using I checked the console; it shows, among others:
(Used the user config shared by @urschrei) Still no signs of life in the editor, though. Trying with this simple program; creating a new project with cargo, and writing:
It recognises in the right bottom bar that the code is Rust. I think that it should be simple enough for RLS to able to provide completion? When I write a dot after |
Can you confirm the Rust scope is active by going to Tools -> Developer -> Show scope name |
Ah, okay, I managed to enable debug logging in console:
|
Scope:
Active syntax:
|
|
@golddranks you need to ensure your project folder is part of a Sublime project (Project > Add Folder to Project...) |
Okay, got some signs of life. (...so, it doesn't support single files at the moment?).
Next, it dies here, every time I save: (edit, or more like, the connection has died on the startup.)
Still no activity in editor itself, only in the debug log. |
I think we're confusing two different things :
The first one seems a bit buggy for me, the second one appears to work fine. Also, they both seem to have trouble dealing with multiple folders (representing different projects) in the same window. |
The issues I'm reporting in this threads are with LSP. |
Hmm, I got LSP and RLS to work on my laptop at work, but on my desktop at home I get the same error @golddranks has : Not the slightest idea what's different between the 2 setups. |
Setting |
So, the problem seems to be that the JSON message received is structured like This leads it to parse the value as
So, the parsing logic needs a bit more robustness and fixing. Sending a PR! |
Wow, great support and troubleshooting in this issue! Some updates:
A question:
|
Awesome ! @golddranks I compiled RLS from your branch, I can confirm it fixes it for me too. |
@tomv564 Can the requirement of the workspace be relaxed some day? It would be useful to be able to use RLS even when editing some single file "ad hoc". After implementing the fix, RLS+LSP now works for me. It shows warnings and errors, and hovering for types works. Go to symbol definition works. Code completion doesn't work for some reason, gonna look at it later. I haven't tried per-project settings yet. |
@golddranks I believe ad-hoc editing fits with the spirit of Sublime Text and LSP should support it in the future. I'll create an issue to track it now, thanks for your input! |
Code completion not working was a configuration issue (and my fault, because I was skipping the explanation :P) – I sent a PR to LSP that makes the docs hopefully clearer! Warnings, errors and code completion for fields and methods works now; for some reason, code completion with For some reason, sometimes hovering brings up "No description available", and sometimes the correct types. I'll keep investigating! |
Also, when starting writing a new line, like |
The |
Hooray, most of the initial bugs I stumbled upon are either fixed or waiting for merge! (I'm gonna start using Sublime as my daily Rust editor and try to find some more.) |
Some instructions for using rust-enhanced: https://github.com/rust-lang/rust-enhanced#rls |
And just to note that Rust Enhanced has been doing really well recently - 50k+ downloads and in the top 15 trending packages - rust-lang/rust-enhanced#224 |
Triage: It looks like there are no outstanding bugs and Sublime is supported. Thanks to everyone involved! 🎉 I'll close this but feel free to reopen if there's anything crucial or Sublime-specific that needs fixing. |
Sourcegraph have a beta version of an lsp client, here. I've set it up and configured it, and I've got
rls
(e24fc84, on Nightly6f10e2f63
) running too. Predictably, it's not working yet, but it looks like:sublime-lsp
is sending data torls
What are some next steps to figure out where the current incompatibilities are?
Sample request:
Action: hovering over
.to_vec()
, in a file at/Users/sth/dev/rust-geo/src/algorithm/simplifyvw.rs
This sends (visible from the
sublime-lsp
debug log in the console):And receives the response:
I've configured the
User
settings for Sublime-lsp as follows:(I've also set up
DYLD_LIBRARY_PATH
andRLS_ROOT
in my.bashrc
)The text was updated successfully, but these errors were encountered: