[feature request] Add ToggleHL<modName> command
SAKASHITA-Koki opened this issue · 3 comments
Thank you for the cool plugin!
I use this plugin by enabling and disabling it as needed.
For this usage, the ToggleHL<modName>
command would be very useful.
I personally add this command by overriding BaseMod:createUsercmd
before setup
, as shown below in my config.
It works fine for me, but it would be even better if you could add it officially.
function BaseMod:createUsercmd()
local function underscore_to_camel_case(input)
local result = input:gsub("(%l)(%w*)_(%w+)", function(first, middle, last)
return first:upper() .. middle .. last:sub(1, 1):upper() .. last:sub(2)
end)
result = result:gsub("^%l", string.upper)
return result
end
api.nvim_create_user_command("EnableHL" .. underscore_to_camel_case(self.meta.name), function()
if not self.conf.enable then
self:enable()
end
end, {})
api.nvim_create_user_command("DisableHL" .. underscore_to_camel_case(self.meta.name), function()
if self.conf.enable then
self:disable()
end
end, {})
-- add ToggleHL<modName> command
api.nvim_create_user_command("ToggleHL" .. underscore_to_camel_case(self.meta.name), function()
if self.conf.enable then
self:disable()
else
self:enable()
end
end, {})
end
thanks
sorry for late reply, recently I feel tired of writing Lua (sorry again 😂), I'll merge it in after some time.
No worries at all! It seems to be a bad timing, sorry 🙏
Whenever you feel like it, please take care of it. I'm looking forward to it.
Thanks for the plugin @shellRaining , I have a feature request similar to this one which is to enable a certain mode only for the current buffer (not globally).
My use case is that I want to enable the indent mode only for yaml
files.