Skip to content

Conversation

@puremourning
Copy link
Member

@puremourning puremourning commented Dec 30, 2025

This change is Reviewable

Rust analyzer returns the full rendered output of the error from the
rust compiler, which is quite useful as a detailed diagnostic. Provide a
way for LSP concrete implementations to override the detailed diag, and
return it. Do the same for GetDoc. Requires a client to support
'markdown' filetype parameter, but doesn't fundamentally break clients
that don't.

LSP has "Hint" type diagnostics. YCM sorts diagnostics based on the
'kind'. This worked fine with Warning and Error (where 'E' < 'W'), but
unfortunately, 'H' is less then warning meaning that the hints override
warnings. This makes some errors look silly. Return the actual severity
(integer) as well as the kind, allowing YCM to sort them correctly.

Add 2 secret subcommands to rust:

- BuildProcMacros; this tells RA to rebuild the compile time macros
  which can get out of whack occasionally.
- ExpandMacro: Useful to view the expanded form of a macro_rules! macro.
  We just use a text output with no special formatting as that's better
  than nothing and we don't really have a way to tell YCM to render the
  output as rust code (though we could add that later)
This adds support for rename/create/delete of files in response to user
actions and for "workspace edits" to be sent to the client in cases
other than as a result of a YcmCompelter command.

The purpose of this is to support some niche language servers that send
these edits in response to external triggers (in particular this is
used by the Slint language server).

But resource operations are independently useful, creation of classes,
rename of files in response to refactorings, etc. Requires client
support, of course.

We model these unsolicited requests as notifications for the client
because YCM protocol does not have "server to client" requests like LSP
and there's really nothing that a server can do in response to the
rejection anyway. When we get such a request, we put it in the
notifications queue and "ack" the request.
Rust projects don't just have a single Cargo.toml. They can have a deep
folder structure with multiple crates within.  Cargo.lock is a better
indicator of the root of the project.

Bit even then we probably want to find the _furthest_ away Cargo.foo not
the nearest, as that's more likely to be the real project root.
Implement that somewhat generically so that other completers can use it.
Java already has a similar codepath but it's more complicated so not
touching it.

Finally, even with the above 2 changes, we still have a problem because
there might just be gaps. Taking wasmtime project for example there
are:

./Cargo.toml
./Cargo.lock
./src/foo.rs
./crates/bar/Cargo.toml
./crates/bar/src/bar.rs
./crates/baz/Cargo.toml
./crates/baz/src/baz.rs

So, we allow for the top-level 'project_directory' setting to take
precedence _if_ the file opened is in a subdirectory of it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant