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

vim.lsp.buf.rename returns nil on successful rename #5

Closed
tdcdev opened this issue May 27, 2024 · 3 comments
Closed

vim.lsp.buf.rename returns nil on successful rename #5

tdcdev opened this issue May 27, 2024 · 3 comments
Assignees

Comments

@tdcdev
Copy link

tdcdev commented May 27, 2024

Hi @gregorias,

Thanks for this nice plugin!

I have an issue with the LSP rename function. I am using nvim 0.10 and pyright LSP server.

When I try to force a word it seems that the LSP rename is not called and only the local transformer is triggered. After some digging, it appears that the LSP rename is called but is overridden by the local transformer.

I think the problem comes from here as the vim.lsp.buf.rename returns nothing if the rename is done without errors.

Regards,

@tdcdev tdcdev changed the title vim.lsp.buf.rename return nil on successful rename vim.lsp.buf.rename returns nil on successful rename May 27, 2024
@gregorias
Copy link
Owner

Hi Thomas,

Thanks for reporting.

The default lsp rename is transform_lsp_rename_with_failover. It’s intended behavior that if the rename fails, we just apply a local transformation. It would only be a bug if LSP rename was working, but Coerce somehow didn’t recognize or use that.

If you’d like to have different behavior:

  1. You can relatively easily configure your own modes (instructions, default modes).
  2. You can make a case that this plugin should use different defaults.

@tdcdev
Copy link
Author

tdcdev commented May 28, 2024

It would only be a bug if LSP rename was working, but Coerce somehow didn’t recognize or use that.

I think this is exactly what happens. Because transform_lsp_rename returns the result of vim.lsp.buf.rename which is nil if the rename succeed.

EDIT:

Actually it seems vim.lsp.buf.rename returns nothing.

@gregorias
Copy link
Owner

gregorias commented May 28, 2024 via email

@gregorias gregorias self-assigned this Jun 1, 2024
gregorias added a commit that referenced this issue Jun 1, 2024
While working on #5, I noticed that the failover parameter is unused.
This commit rectifies this.
gregorias added a commit that referenced this issue Jun 1, 2024
While working on #5, I noticed that the failover parameter is unused.
This commit rectifies this.
gregorias added a commit that referenced this issue Jun 1, 2024
Issue #5 has correctly pointed out that vim.lsp.buf.rename doesn’t
return anything. This test starts the first half of the task: testing
that we return false if rename fails.
gregorias added a commit that referenced this issue Jun 10, 2024
Adds a test that will check #5 after I uncomment the TODO.
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

No branches or pull requests

2 participants