-
-
Notifications
You must be signed in to change notification settings - Fork 959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support local source changes for rust-analyzer #1124
Comments
Actually, looking at the code, it seems like this can be handled by registering the The only question is if there's already shared code that supports easy local text manipulation based on span information and text. I'll have to dig into this some more sometime this weekend, but if you have any other pointers, feel free to let me know. |
Okay, that was fairly easy to implement. I'll see about making this into a proper extension, but for starters, this will make sure local edits are applied as expected: const { commands, workspace } = require('coc.nvim')
exports.activate = context => {
context.subscriptions.push(commands.registerCommand('rust-analyzer.applySourceChange', async({ _cursorPosition, _label, workspaceEdit }) => {
await workspace.applyEdit(workspaceEdit)
}, null, true))
} For anyone finding this issue: add this to a |
I'm porting rust-analyzer-vscode to a coc extension, https://www.npmjs.com/package/coc-rust-analyzer, give it a try.
|
@fannheyward great! Are you going to host the code somewhere so others can contribute? |
@JeanMertz yes, I'll open it on GitHub later. |
These commands are works!
|
@fannheyward after you have a repo, I'll add a note in Avi-D-coder/coc-rust-analyzer pointing to it, since I never got around to finishing it. |
@fannheyward great work so far. Two things I've noticed, but I'm not sure if it's a limitation of the plugin, coc itself, or my configuration:
|
@Avi-D-coder @JeanMertz I make it open: https://github.com/fannheyward/coc-rust-analyzer
This issue can be closed, any issue/feature/feedback can be post in coc-rust-analyzer repo, thanks. |
I'm looking into making the rust-analyzer LSP work as much as possible with Coc.
Everything mostly works out of the box, except that the server does not support
workspace/executeCommand
, and so code actions don't work.Instead, the response of a
textDocument/codeAction
request returns a set of actions, each having theircommand
set torust-analyzer.applySourceChange
, andarguments
containing the data needed to manipulate the code locally to apply the source change.I've implemented something similar before for LanguageClient-neovim.
Given that this doesn't fit into an "extension" (as far as I know), I suspect support for something like this will have to be hard-coded into coc.nvim itself?
Are you open to such a change, or do you have any pointers for me to make this work as expected?
The text was updated successfully, but these errors were encountered: