-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat: add FlutterRename command #234
Conversation
This command adds support for `updateImportsOnRename` setting (https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration). It is useful when file is renamed after class rename (when enabled `renameFilesWithClasses` setting). It will fallback to `vim.lsp.buf.rename()` if no `dartls` client found. If client is found, file is the same as class name, and class is being renamed, it will request for changes via `workspace/willRenameFiles`. Results of `workspace/willRenameFiles` will be applied after class rename. To test it try to rename class which is in the file with same file name. Before: class renamed, file renamed, usage of class renamed, but imports are not updated. After: class renamed, file renamed, usage and imports are updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just had a quick look, not a super detailed review atm. Looks good generally, just some stylistic comments. Also one somewhat big comment which is mainly I wonder if a lot of this logic isn't already handled by the lsp stuff like calculating which files to update etc. also I wonder if vim.lsp.util.rename
can't also be used here
will fix #233 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sidlatau thanks for factoring out the ui.input
calls and the lsp.get_client
stuff makes things much cleaner. The remaining stuff I've flagged are almost entirely stylistic. Things like
- Adding type annotations to make the code easier to use with lua ls
- preferring
old
->prev
,actual
->current
expand("magic")
->vim.fs.(base|dir)name(api.nvim_buf_get_name())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏾
This command adds support for
updateImportsOnRename
setting (https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration).It is useful when the file is renamed after a class rename (when enabled
renameFilesWithClasses
setting).It will fall back to
vim.lsp.buf.rename()
if nodartls
client is found.If the client is found, the file is the same as the class name, and the class is being renamed, it will request for changes via
workspace/willRenameFiles
. Results ofworkspace/willRenameFiles
will be applied after the class rename.To test it try to rename the class that is in the file with the same file name.
vim.lsp.buf.rename()
: class renamed, file renamed, usage of class renamed, but imports are not updated.FlutterRename
: class renamed, file renamed, usage and imports are updated.