rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.98k stars 1.55k forks source link

Announcements: Client Changes #4604

Open matklad opened 4 years ago

matklad commented 4 years ago

This issue exists to announce changes which might affect rust-analyzer plugins for different editors. If you maintain such a plugin, consider subscribing to this issue.

All our protocol extensions are documented at lsp-extensions.md. I'll try to remember to leave a comment on this issue if I modify that file.

matklad commented 4 years ago

After https://github.com/rust-analyzer/rust-analyzer/pull/4632, all our current extensions are documented. There were a bunch of minor changes here and there. Most notably some requests were moved from rust-analyzer/foo to experimental/foo, in hope that this might be useful for other servers, and to mark the extensions we intend to upstream to the protocol itself.

Notably, inlay hints and runnables are are still unchanged: i want to upstream these two as well, but I am not too happy with their current state, and I don't have time to polish them right now. So i opted for documenting them as is, and cleaning up later.

matklad commented 4 years ago

https://github.com/rust-analyzer/rust-analyzer/pull/4688 documents our initilizationOptions.

matklad commented 4 years ago

4710 changes API for runnables. The idea is that it's the client who is reponsible for running stuff, to make it possible to, eg, inject debugger support or other custom tools. So, rust-analzyer provides a more abstract representation of a cargo command, to make it easier for the client to make sense of it.

matklad commented 4 years ago

4717 adds API for lazily computing code action edits.

matklad commented 4 years ago

5188 adds status notification.

matklad commented 4 years ago

adds "memory usage" command: https://github.com/rust-analyzer/rust-analyzer/pull/5244

matklad commented 4 years ago

https://github.com/rust-analyzer/rust-analyzer/pull/4972 will switch to gzipping release artifacts.

matklad commented 4 years ago

rust-analyzer is available via rustup.

15:04:42|~/projects/rust-analyzer/editors/code|master✓
λ rustup component add --toolchain nightly rust-analyzer-preview
info: component 'rust-analyzer-preview' for target 'x86_64-unknown-linux-gnu' is up to date

15:04:46|~/projects/rust-analyzer/editors/code|master✓
λ rustup run nightly rust-analyzer --version
rust-analyzer f5a4a4b

The "officially recommended" binary at the moment is still the one from releases in this repo, but rustup one should be fine as well.

matklad commented 4 years ago

https://github.com/rust-analyzer/rust-analyzer/pull/5782

matklad commented 3 years ago

https://github.com/rust-analyzer/rust-analyzer/pull/5930 adapts the latest changes of the semantic tokens

matklad commented 3 years ago

Flexible runnables configuration:

p3achyjr commented 3 years ago

I am adding a rust-analyzer action for #6462, and will be changing the hash.

matklad commented 3 years ago

https://github.com/rust-analyzer/rust-analyzer/pull/6521 removes our custom support for code action resolving in favor of one provided by LSP 1.16.

matklad commented 3 years ago

6761 adds a rust-analyzer --print-config-schema command which prints JSON-schema for the configuration for rust-analyzer, in the style of package.json. This should allow non-VS Code clients to show better auto-complete & docs for user config, and should also help to ensure that the defaults are the same between vscode and other editors.

lnicola commented 3 years ago

In #6996 we want to stop releasing uncompressed binaries. Clients that can automatically install the LSP server binary should download the .gz file instead.

We've also changed the naming convention to include the platform tuple:

This allows us to support new platforms more easily, speeds up downloads and avoids wasting disk space.

lnicola commented 3 years ago

7068 adds a command to show our HIR representation of a function.

edwin0cheng commented 3 years ago

7412 adds a new readyPartial in status notification :

export type Status = "loading" | "ready" | "readyPartial" | "invalid" | "needsReload";
lnicola commented 3 years ago

7625 adds a "copy runnable command line" command.

matklad commented 3 years ago

It is now possible to use ut8 coordinate space for positions and ranges: https://github.com/rust-analyzer/rust-analyzer/pull/7657

matklad commented 3 years ago

8054 adds a new request to move functions, statements, etc up and down.

jplatte commented 3 years ago

Side note: There's a missing n in the title, it should be "Announcements".

matklad commented 3 years ago

https://github.com/rust-analyzer/rust-analyzer/pull/8355 replaces rust-analyzer specific rust-analyzer/status with a more general experimental/serverStatus. close upstream issue: https://github.com/microsoft/language-server-protocol/issues/511

bstaletic commented 3 years ago

For the record, here the new status is documented as requiring serverStatus capability, when in rust-analyzer only reacted to serverStatusNotification.

Is that a typo in the docs or a bug in #8355?

theli-ua commented 3 years ago

@matklad ping re bstaletic's question. Would like a clarification on what was the intention there, please.

matklad commented 3 years ago

Bug in the spec!

matklad commented 3 years ago

Pushed the fix and clarified the docs in https://github.com/rust-analyzer/rust-analyzer/pull/8580. @bstaletic I see that you are using the status to check is this a good occasion to bother the server with requests. I guess you can do that, but its not really necessary. In VS Code client, we just always send the requests, without checking if the server is ready.

The status notification is used solely to draw an entry in the modline for the user: https://github.com/rust-analyzer/rust-analyzer/blob/master/editors/code/src/ctx.ts#L69-L91

matklad commented 3 years ago

7698 and #8877 extend workspace/symbol to allow for filtering, such as "give me all types in my project" or "give me all types and functions in my project and its dependencies". I feel that we might want to iterate a bit on what exactly the filtering parameter looks like, but, if we do that we'll add new capability.

lnicola commented 3 years ago

8926 drops the uncompressed release artifacts and those that don't contain the target name:

matklad commented 3 years ago

With https://github.com/rust-analyzer/rust-analyzer/pull/9693, it's now possible to pass a Range in the Hover request, and not just a position.

matklad commented 3 years ago

https://github.com/rust-analyzer/rust-analyzer/pull/9732 add client capabilities for curstom client-side rust-analyzre commands. So, heads up, action required: if your client implements any of

                "rust-analyzer.runSingle",
                "rust-analyzer.debugSingle",
                "rust-analyzer.showReferences",
                "rust-analyzer.gotoLocation",
                "editor.action.triggerParameterHints",

Then add

"experimental": {
  "commands": {
    "commands": [ "rust-analyzer.runSingle", "rust-analyzer.debugSingle", "rust-analyzer.showReferences", "rust-analyzer.gotoLocation", "editor.action.triggerParameterHints"]
  }
}

to the capabilities. Note the nested commands/commands. This feels stupid, but is intentional -- it mirrors the capability for server commands, and allows us to add more fields to the cap in a backwrad compatible way

lnicola commented 3 years ago

After #9828, the crate graph is returned in the dot (GraphViz) syntax instead of a SVG. The Code extension runs a built-in GraphViz to render it.

lnicola commented 2 years ago

11445 changes inlay hints to be closer to the future LSP version, see https://github.com/rust-analyzer/rust-analyzer/pull/11445/files#diff-d0486663bf81f5c3f31447f48e7b526c1d62d712dee2b5e644fe6a4fc91a108d.

nemethf commented 2 years ago

11830 allows OnTypeFormatting request to return SnippetTextEdit

lnicola commented 2 years ago

11935 fully switches to LSP inlay hints, experimental/inlayHints is now gone.

Veykril commented 2 years ago

https://github.com/rust-lang/rust-analyzer/pull/12010 will change a lot of the config keys we currently have, to make them more consistent as well as giving us the ability to extend configurations without breakage more easily. The PR description contains all the key changes as well as the few config keys that have been merged/split.

We are planning on merging the PR next week on monday on May 9th after our stable release to let it sit with nightly for a full week until the next stable release.

If you have points to raise regarding this please do so on zulip https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/r-a.20config.20format or on the linked PR.

Veykril commented 2 years ago

Follow up to my previous comment, since most clients don't have the luxury of matching up server with client like the VSCode extension does we'll add a compatibility layer for some time that will keep accepting the old values (though we do want to remove this in the future at some point, so it would be great if the clients could nudge their users to updating their configs/if the clients could transition over to the new one)

puremourning commented 2 years ago

It's not a matter of matching versions, it's a matter of breaking existing users' configuration, right?

flodiebold commented 2 years ago

@puremourning kind of, yeah. The VSCode extension will update configurations to the new format if I understand correctly, but that's not an option for most clients. But e.g. the Emacs plugin has its own customizations for most RA options, which can (will need to) be translated to the new config format.

puremourning commented 2 years ago

exactly, so "delaying" isn't really solving.

flodiebold commented 2 years ago

It's solving the problem for clients like VSCode and Emacs; clients that just let users directly pass RA config JSON will need a different solution. Maybe we will have to take on the "nudging users to update their configs" somehow.

theli-ua commented 2 years ago

For the transition period - ra could just send a showMessage notification to user notifying them about upcoming config changes, wouldn't that work better when paired with "delaying" ?

puremourning commented 2 years ago

It might yeah, for clients that implement that message, which, err, ahem, mine doesn't (!). But I think that's a fair compromise.

Veykril commented 1 year ago

https://github.com/rust-lang/rust-analyzer/pull/13792 and 2 earlier PRs now allow controlling the flycheck (checkOnSave) features a bit via notifications. They have been described in the lsp-ext docs in https://github.com/rust-lang/rust-analyzer/pull/13792.

HKalbasi commented 1 year ago

13699 uses location links in inlay hints. It is not a lsp extension and it exists in standard lsp, but since no language server which I'm aware of is currently using this feature, it is very likely that some clients have not implemented this feature. See inlay hint label part in lsp spec.

lnicola commented 1 year ago

If merged, #13876 will add a ZIP release artifact on Windows containing the language binary corresponding PDB. This should make life easier for Windows users since they no longer have to install anything. Ideally, we'd only keep producing one format, so we might drop the .gz version in the future.

There's also the alternative to produce .tar.gz everywhere (Windows can extract those, at least from the command line), but IMHO that's the worse format, perpetuated only because of historical reasons.

If you're maintaining a client that can automatically download rust-analyzer, consider leaving a comment on #13876 regarding your preferred format.

ian-h-chamberlain commented 1 year ago

13848 adds a client capability colorDiagnosticOutput to declare that a client is capable of rendering the "full compiler diagnostic" with ANSI color and style codes. VSCode is probably the only client using this for now. The docs have been updated as part of that PR as well.

matklad commented 1 year ago

https://github.com/rust-lang/rust-analyzer/pull/14141 adds support for positionEncoding = "utf-32", in addition to utf-8 and utf-16 which we support since forever.

bruno-ortiz commented 1 year ago

https://github.com/rust-lang/rust-analyzer/pull/11557 adds a viewTree which allows to navigate through project dependencies

Ddystopia commented 1 year ago

14662 adds support for locally built documentation

adenine-dev commented 1 year ago

15081 adds support for a memory layout viewer.