From ddc04478180e016f9ca7a2f5c248967ce73f6c20 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 12 Oct 2021 19:10:20 +0200 Subject: [PATCH] feat: add commenting plugin to nvim --- .config/nvim/init.lua | 3 ++ .config/nvim/lua/plugin/comment.lua | 54 +++++++++++++++++++++++++++++ .config/nvim/lua/plugins.lua | 3 ++ 3 files changed, 60 insertions(+) create mode 100644 .config/nvim/lua/plugin/comment.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 1694204..4c60c50 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -17,3 +17,6 @@ require("plugin.cmp") -- ./lua/plugin/cmp.lua -- treesitter require("plugin.treesitter") -- ./lua/plugin/treesitter.lua + +-- commenting, done right +require("plugin.comment") -- ./lua/plugin/comment.lua diff --git a/.config/nvim/lua/plugin/comment.lua b/.config/nvim/lua/plugin/comment.lua new file mode 100644 index 0000000..6cb9912 --- /dev/null +++ b/.config/nvim/lua/plugin/comment.lua @@ -0,0 +1,54 @@ +-- Author : swytch +-- Created : Tuesday Oct. 12, 2021 19:07:36 CET +-- License : GPLv3 +-- Description : Comment plugin config file + +require("Comment").setup { + ---Add a space b/w comment and the line + ---@type boolean + padding = true, + + ---Lines to be ignored while comment/uncomment. + ---Could be a regex string or a function that returns a regex string. + ---Example: Use '^$' to ignore empty lines + ---@type string|function + ignore = nil, + + ---Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode + ---@type table + mappings = { + ---operator-pending mapping + ---Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}` + basic = true, + ---extended mapping + ---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}` + extra = false, + }, + + ---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode + ---@type table + toggler = { + ---line-comment toggle + line = 'gcc', + ---block-comment toggle + block = 'gbc', + }, + + ---LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode + ---@type table + opleader = { + ---line-comment opfunc mapping + line = 'gc', + ---block-comment opfunc mapping + block = 'gb', + }, + + ---Pre-hook, called before commenting the line + ---@type function|nil + pre_hook = nil, + + ---Post-hook, called after commenting is done + ---@type function|nil + post_hook = nil, +} + diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index e002111..dffc26d 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -69,6 +69,9 @@ return require("packer").startup(function() } } + -- commenting, simplified + use "numToStr/Comment.nvim" + -- display colors directly in editor use { "norcalli/nvim-colorizer.lua",