Closed Markus00000 closed 2 years ago
The config is exposed, so you can modify the marker_padding value, comment the line, then restore:
local function noPad()
local comment_opts = require('nvim_comment').config
print("marker_padding: ", comment_opts.marker_padding)
local old = comment_opts.marker_padding
comment_opts.marker_padding = false
print("marker_padding: ", comment_opts.marker_padding)
comment_opts.marker_padding = true
end
Thank you!
I ended up creating a toggle function and mappings:
function _G.padding_toggle()
require('nvim_comment').config.marker_padding = not require('nvim_comment').config.marker_padding
end
vim.api.nvim_set_keymap('n', '<Leader>k', ':lua padding_toggle(); vim.api.nvim_command("CommentToggle"); padding_toggle()<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('v', '<Leader>k', ':lua padding_toggle(); vim.api.nvim_command("\'<,\'>CommentToggle"); padding_toggle()<CR>', {noremap = true, silent = true})
(I wasn’t sure how to pass visual selection line numbers from mappings to Lua functions or how to get them directly in Lua.)
I’m using padded and unpadded comments. Having a way to create mappings for each would be useful. Ideas:
line_mapping_padded
andline_mapping_unpadded
marker_padding
parameter that can be called in custom mappings