text-case.nvim
text-case.nvim copied to clipboard
Conversion happens on all text, not on selection
Hi,
I'm trying to convert my workflow from VS Code world to Neovim. The following is a regular use-case for me in VS Code: I select a rectangular area of text, then run a case converter from command palette.
I tried to do the same in with Neovim + textcase. I have mapped 'ga.' to open the telescope extension. See the following video: https://user-images.githubusercontent.com/2431112/194544178-c076f473-cc4d-4f53-b4d6-faaedb8e0cc1.mov
The order of operations in the video is:
- Select a block.
- 'ga.' to have the popup open.
- Select snake case.
To my surprise, all text was converted to snake case, not only the selected block.
Hi @kontza,
What command are you using for mapping ga.
to Telescope? Unfortunately the regular :Telescope <command>
does not work because the visual mode is dropped. So, should be <cmd>TextCaseOpenTelescope<CR>
instead
Oh, actually, when I tested for this issue, it worked, but now I was able to reproduce it. I noticed it only happens with the Telescope option, as a workaround, mapping the conversion directly does work
nnoremap gac :lua require('textcase').current_word('to_camel_case')<CR>
Will have a look into the issue. thanks for reporting
Ok, thanks for the tip above.
And to answer your question about mappings: this is how I have mapped ga.
:
vim.api.nvim_set_keymap('n', 'ga.',
'<cmd>TextCaseOpenTelescope<CR>',
{ desc = "Telescope" })
vim.api.nvim_set_keymap('v', 'ga.',
'<cmd>TextCaseOpenTelescope<CR>',
{ desc = "Telescope" })
@kontza did my fix solve your problem? Can you please test with the latest version?
Yup, it works. Cheers!