refactor(nvim): use builtin :h commenting for comments

This commit is contained in:
Price Hiller 2024-05-09 22:41:06 -05:00
parent 6d4ec7861d
commit 73ee308ac8
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB
2 changed files with 2 additions and 53 deletions

View File

@ -121,8 +121,8 @@ M.setup = function()
vim.keymap.set("n", "<Tab>", "za", { silent = true, desc = "Toggle Fold" })
-- Alias <leader>/ to toggle comments
vim.keymap.set("n", "<leader>/", "gcc", { silent = true, desc = "Comment: Toggle Line" })
vim.keymap.set("v", "<leader>/", "gc", { silent = true, desc = "Comment: Toggle Selection" })
vim.keymap.set("n", "<leader>/", "gcc", { silent = true, remap = true, desc = "Comment: Toggle Line" })
vim.keymap.set("v", "<leader>/", "gc", { silent = true, remap = true, desc = "Comment: Toggle Selection" })
end
return M

View File

@ -1,51 +0,0 @@
return {
{
"numToStr/Comment.nvim",
config = function()
require("Comment").setup({
pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(),
})
end,
dependencies = {
{
"JoosepAlviste/nvim-ts-context-commentstring",
opts = function()
vim.g.skip_ts_context_commentstring_module = true
end,
config = function()
require("ts_context_commentstring").setup({
enable_autocmd = false,
})
end,
},
},
keys = {
{ "gc", desc = "> Comment: Line" },
{ "gb", desc = "> Comment: Block " },
{ "gbc", desc = "Comment: Toggle block comment" },
{ "gcc", desc = "Comment: Toggle line comment" },
{ "gcO", desc = "Comment: Add comment on line above" },
{ "gco", desc = "Comment: Add comment on line below" },
{ "gcA", desc = "Comment: Add comment at end of line" },
{
"<leader>/",
function()
local api = require("Comment.api")
api.toggle.linewise.current()
end,
desc = "Comment: Toggle Linewise",
},
{
"<leader>/",
function()
local api = require("Comment.api")
local esc = vim.api.nvim_replace_termcodes("<ESC>", true, false, true)
vim.api.nvim_feedkeys(esc, "nx", false)
api.toggle.linewise(vim.fn.visualmode())
end,
desc = "Comment: Toggle Blockwise",
mode = { "x" },
},
},
},
}