Skip to content
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

Check language server rename support before showing rename-to prompt #6249

Closed
the-mikedavis opened this issue Mar 10, 2023 · 0 comments · Fixed by #6257
Closed

Check language server rename support before showing rename-to prompt #6249

the-mikedavis opened this issue Mar 10, 2023 · 0 comments · Fixed by #6257
Labels
A-language-server Area: Language server client C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR

Comments

@the-mikedavis
Copy link
Member

If a language server doesn't support LSP renaming, rename_symbol (<space>r) should bail early. Currently it creates the "rename-to" prompt and then fails to rename.

We check whether the server declares rename support here when creating the rename request future:

helix/helix-lsp/src/client.rs

Lines 1115 to 1120 in d63e570

// Return early if the language server does not support renaming.
match capabilities.rename_provider {
Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
// None | Some(false)
_ => return None,
};

(The rename text entered in the prompt is used in the params for that request.) We should extract that match as a function:

pub fn supports_rename(&self) -> bool { /* check rename capability */ }

and then check that support before creating the prompt.

bash-language-server is a language server in the wild that doesn't support symbol renaming and can be used to test this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant