Closed yutkat closed 2 years ago
I haven't explored custom mapping. Can you try using the regular setup? It is to call
require("text case").setup()
There is an example in the readme using Packer. I should probably add examples using other package managers
My guess is the setup method is not registering the methods. If that's the case, once they are registered, I think custom mappings should work out of the box. But the setup itself also initializes mappings with ga as prefix, therefore there is no need to add them by yourself
I tried to add the gas
(snake case) myself because the wiki mentioned it but did not seem to provide the mapping.
https://github.com/johmsalas/text-case.nvim/blob/main/lua/textcase/plugin/presets.lua https://github.com/johmsalas/text-case.nvim/wiki/String-Case-functions
Good catch. I added a note in the string case functions page. Let me know if it still fails after calling the setup method (even let me know if it works!)
By the way, I can still make a fix out of this issue. I can change the module so that it register the methods without calling the setup function. And the setup function would be only for registering the keybindings
I still can't find the command to_snake_case
in my environment...
:nmap ga
n gal * <Cmd>lua require('textcase').current_word('to_lower_case')<CR>
n gaL * <Cmd>lua require('textcase').lsp_rename('to_lower_case')<CR>
n gaol * <Cmd>lua require('textcase').operator('to_lower_case')<CR>
n gau * <Cmd>lua require('textcase').current_word('to_upper_case')<CR>
n gaU * <Cmd>lua require('textcase').lsp_rename('to_upper_case')<CR>
n gaou * <Cmd>lua require('textcase').operator('to_upper_case')<CR>
n gap * <Cmd>lua require('textcase').current_word('to_pascal_case')<CR>
n gaP * <Cmd>lua require('textcase').lsp_rename('to_pascal_case')<CR>
n gaop * <Cmd>lua require('textcase').operator('to_pascal_case')<CR>
n gad * <Cmd>lua require('textcase').current_word('to_dash_case')<CR>
n gaD * <Cmd>lua require('textcase').lsp_rename('to_dash_case')<CR>
n gaod * <Cmd>lua require('textcase').operator('to_dash_case')<CR>
n gac * <Cmd>lua require('textcase').current_word('to_camel_case')<CR>
n gaC * <Cmd>lua require('textcase').lsp_rename('to_camel_case')<CR>
n gaoc * <Cmd>lua require('textcase').operator('to_camel_case')<CR>
n gan * <Cmd>lua require('textcase').current_word('to_constant_case')<CR>
n gaN * <Cmd>lua require('textcase').lsp_rename('to_constant_case')<CR>
n gaon * <Cmd>lua require('textcase').operator('to_constant_case')<CR>
use({
"johmsalas/text-case.nvim",
event = "VimEnter",
config = function()
require("textcase").setup()
end,
})
Hi!
Calling .setup()
is not anymore a requirement. setup
sets keybinding by default. But if you want to add custom key mappings then setup isn't enforced anymore
When you say. you can't find the command. What does it mean?
Is it using Telescope? If that's the case, just merged a PR providing better description It requires calling setup()
Is it calling directly the functions? They are under the api namespace. By the way, it was broken but the last PR fixes it
https://github.com/johmsalas/text-case.nvim/wiki/String-Case-functions
local textcase = require('textcase')
local result = textcase.api.to_dash_case('Dash case')
I haven't setup a template for issues, a good question would be, what are the reproduction steps?
Thanks for your help making better this plugin!
With the latest version, to_snake_case is not mapped to s
by default, but if I map it myself, it's works.
Thank you.
nmap gas <Cmd>lua require('textcase').current_word('to_snake_case')<CR>
This could be updated in the wiki, as it still shows as a default keymap (trigger)
I set up the following mapping.
nmap gas <Cmd>lua require('textcase').current_word('to_snake_case')<CR>
error occurs