diff --git a/after/plugin/comment.lua b/after/plugin/comment.lua new file mode 100644 index 0000000..db69845 --- /dev/null +++ b/after/plugin/comment.lua @@ -0,0 +1,47 @@ +local comment = require("Comment") + +local options = { + ---Add a space b/w comment and the line + padding = true, + ---Whether the cursor should stay at its position + sticky = true, + ---Lines to be ignored while (un)comment + ignore = nil, + ---LHS of toggle mappings in NORMAL mode + toggler = { + ---Line-comment toggle keymap + line = "cc", + ---Block-comment toggle keymap + block = "cb", + }, + ---LHS of operator-pending mappings in NORMAL and VISUAL mode + opleader = { + ---Line-comment keymap + line = "cc", + ---Block-comment keymap + block = "cb", + }, + ---LHS of extra mappings + extra = { + ---Add comment on the line above + above = "gcO", + ---Add comment on the line below + below = "gco", + ---Add comment at the end of line + eol = "gcA", + }, + ---Enable keybindings + ---NOTE: If given `false` then the plugin won't create any mappings + mappings = { + ---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}` + basic = true, + ---Extra mapping; `gco`, `gcO`, `gcA` + extra = false, + }, + ---Function to call before (un)comment + pre_hook = nil, + ---Function to call after (un)comment + post_hook = nil, +} + +comment.setup(options) diff --git a/lua/plugins.lua b/lua/plugins.lua index a55d308..022614d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -42,6 +42,7 @@ vim.pack.add({ { src = "https://github.com/petertriho/nvim-scrollbar" }, { src = "https://github.com/j-hui/fidget.nvim" }, { src = "https://github.com/nvimdev/lspsaga.nvim" }, + { src = "https://github.com/numtostr/comment.nvim" }, -- Framework specific { src = "https://github.com/adibhanna/laravel.nvim" }, diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json index facbbc2..ed81ba5 100644 --- a/nvim-pack-lock.json +++ b/nvim-pack-lock.json @@ -8,6 +8,10 @@ "rev": "2cb62890cee636fe46722d03b7b2331e54fb3755", "src": "https://github.com/saghen/blink.lib" }, + "comment.nvim": { + "rev": "e30b7f2008e52442154b66f7c519bfd2f1e32acb", + "src": "https://github.com/numtostr/comment.nvim" + }, "conform.nvim": { "rev": "619363c30309d29ffa631e67c8183f2a72caa373", "src": "https://github.com/stevearc/conform.nvim"