Closed pidgeon777 closed 1 year ago
Seems like a nice feature to have! Did I understand you correctly that this preview window should be shown as a sort of confirmation dialog when you press enter? And then you would need to press enter (or y) again?
Hey @pidgeon777, are you still interested in this feature?
Hey @pidgeon777, are you still interested in this feature?
Hi @smjonas sorry for the wait, somehow I missed the updates on this issue.
Well, yes, I would be highly interested.
Seems like a nice feature to have! Did I understand you correctly that this preview window should be shown as a sort of confirmation dialog when you press enter? And then you would need to press enter (or y) again?
What I meant, is that it could be used in two ways:
a. Show a live preview of the changes introduced with the LSP rename feature when typing the new variable name. b. Show a preview confirmation dialog just showing the new changes before applying them.
In both cases, it would be necessary to show the preview of the newly modified code before applying the changes.
And this could be a live preview (as expressed in case a
) or just a confirmation (case b
).
Also, it would be really nice to show all of those changes in the way I described them in my first post so that it would be possible to know in an easy way which files would get modified, for example.
I would be happy to help you beta-testing this new feature, if needed 👍.
At least for the current file, this is already possible. See :h command-preview
:
4. Return an integer (0, 1, 2) which controls how Nvim behaves as follows:
0: No preview is shown.
1: Preview is shown without preview window (even with "inccommand=split").
2: Preview is shown and preview window is opened (if "inccommand=split").
For "inccommand=nosplit" this is the same as 1.
You should probably return 2
at https://github.com/smjonas/inc-rename.nvim/blob/de322174a1adc8527b3805dd01e18a7f4ffec22b/lua/inc_rename/init.lua#L319
At least for the current file, this is already possible. See
:h command-preview
:
Since https://github.com/neovim/neovim/pull/19360 the command preview does work across multiple files.
You should probably return
2
at https://github.com/smjonas/inc-rename.nvim/blob/de322174a1adc8527b3805dd01e18a7f4ffec22b/lua/inc_rename/init.lua#L319
I am already returning 2
(not in the function being executed but in the preview callback): https://github.com/smjonas/inc-rename.nvim/blob/ce0e1d795608dc567c8ae3cd56c44f0516ea3276/lua/inc_rename/init.lua#L244
That is why I am a bit confused what you mean by "Show a live preview of the changes introduced with the LSP rename feature when typing the new variable name." @pidgeon777. Isn't that already the case?
I think for your second suggestion with the preview window we can make use of inccommand=split
(which if enabled will give us a buffer number in the preview callback) and then format the results nicely in that window.
I am already returning 2 (not in the function being executed but in the preview callback):
My bad, looked at the wrong code :)
@pidgeon777 probably doens't have inccommand=split
set.
I'm trying to test the branch but noice seems to crash when I select "Yes" "No" in the new user choice popup, or when I try to autocomplete, or when activating a previous command from the history etc.
In particular, in the new noice popup, when I digit :IncRename
and then a space
, Neovim (Neovide) crashes when pressing space
.
I can't reproduce the crash with noice
(NVIM v0.9.0-dev-98-g1c478391c). Can you create an issue on the noice repo with the exact error message?
In the meanwhile I disabled noice
and inc-rename.nvim
doesn't lead Neovim to crash anymore. Here is the result when trying to rename a function:
Now I will test your PR.
EDIT: Tested, see:
@pidgeon777 Neovide is not working properly with Noice. See the tracking issue on the noice github. Disable multigrid and use Neovim nightly is you want to use Noice.
Thanks @folke, I'll try to report any found issue in the Noice
issue tracker 👍.
It would be great for this plugin to show a rename preview panel similar to the quick fix one, containing a row for each of the symbols which will be updated with the LSP rename.
Also, those rows should be grouped in files where the change will occur. Example: