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

Allow vars_ and func_ in code actions to be configured #106

Closed
karthiknadig opened this issue Mar 25, 2021 · 4 comments · Fixed by #110
Closed

Allow vars_ and func_ in code actions to be configured #106

karthiknadig opened this issue Mar 25, 2021 · 4 comments · Fixed by #110
Labels

Comments

@karthiknadig
Copy link
Contributor

Currently code action provides random function and variable names when extracting. We want to use set it a constant value like new_var, or new_func, and let the users change the name as needed.

/cc @luabud

@pappasam
Copy link
Owner

pappasam commented Mar 25, 2021

I don't believe this was possible in LSP 3.15, but it might be possible in LSP 3.16 with codeAction/resolve. That said, once again, the same 2 issues:

  1. My client (coc) doesn't yet support 3.16, so this will be hard for me to test in practice until the relevant PR is resolved
  2. (bigger issue) pygls doesn't yet support 3.16

I'm happy to keep this issue, and any other 3.16-related issues, open. We can flag them with a LSP-3.16 label or something to stay organized

@pappasam
Copy link
Owner

pappasam commented Mar 25, 2021

I'd be happy to consider any suggestions you may have here. I've considered this in the past, but specifying data for codeAction is not very straightforward. For example, "inline variable" doesn't need a new name, but "extract into variable" does. Additionally, because the LSP spec crams all code actions into LSP request / response, differences between code actions become really hard to handle without editor-specific logic

@dimbleby
Copy link
Contributor

dimbleby commented Mar 25, 2021

microsoft/language-server-protocol#764, and microsoft/language-server-protocol#1164

So far as I can see the TLDR is that the protocol just doesn't support this yet, not even at 3.16.

(codeAction/resolve seems like it would be a good opportunity to provide a new name, having chosen the refactoring, but I don't think that's what it currently is for)

@karthiknadig
Copy link
Contributor Author

@pappasam I was thinking of using initializationOptions for this. We wanted to use a constant value in this case instead of the randomly generated names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants