hlchunk.nvim icon indicating copy to clipboard operation
hlchunk.nvim copied to clipboard

[feature request] Add ToggleHL<modName> command

Open SAKASHITA-Koki opened this issue 1 year ago • 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

SAKASHITA-Koki avatar Jul 26 '24 23:07 SAKASHITA-Koki

sorry for late reply, recently I feel tired of writing Lua (sorry again 😂), I'll merge it in after some time.

shellRaining avatar Aug 05 '24 12:08 shellRaining

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.

SAKASHITA-Koki avatar Aug 05 '24 15:08 SAKASHITA-Koki

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.

carlosflorencio avatar Aug 07 '24 21:08 carlosflorencio