kommentary
kommentary copied to clipboard
Expose Lua API directly
Now that we have vim.keymap.set
API in Neovim nightly, it allows us to setup keymaps in really clean ways.
I'm using legendary.nvim to set all my keymaps, and I try to keep them all in the same place. I tend to have plugins not set their own keymaps through the plugin config, and instead set the keymaps in my single location where I set up all my keymaps.
You can also now set keymaps directly to Lua functions.
Can you expose the implementations of the <Plug>
mappings as Lua functions I can map from my keymaps file?
I'm not sure if this is what you are wanting but I use the following function (found at the bottom of 'lua/kommentary/init.lua') for my custom keymaps:
require('kommentary').toggle_comment(arg1, arg2)
Arg1 is the first line you want commented and arg2 is the last. For example, to toggle comments on the current line I use:
require('kommentary').toggle_comment(vim.fn.line('.'), vim.fn.line('.'))
And to comment a visual selection would be:
require('kommentary').toggle_comment(vim.fn.line('v'), vim.fn.line('.'))
I hope this helped!
Hi, thanks for your interest in kommentary, unfortunately I'll not be adding any new features, I'm sorry I never got to this issue.