summaryrefslogtreecommitdiff
path: root/mac/.config/LunarVim/lua/lvim/core/comment.lua
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
commit07d294425a98ee5d1e22d03e2b24ae2c76e487c0 (patch)
treea6818f0d64438c5fdb88b00a35d944f80c056213 /mac/.config/LunarVim/lua/lvim/core/comment.lua
parent6fc28cdb3529ca8ee864cb5c41674cb0a4af72a1 (diff)
updates
Diffstat (limited to 'mac/.config/LunarVim/lua/lvim/core/comment.lua')
-rw-r--r--mac/.config/LunarVim/lua/lvim/core/comment.lua86
1 files changed, 86 insertions, 0 deletions
diff --git a/mac/.config/LunarVim/lua/lvim/core/comment.lua b/mac/.config/LunarVim/lua/lvim/core/comment.lua
new file mode 100644
index 0000000..f07929c
--- /dev/null
+++ b/mac/.config/LunarVim/lua/lvim/core/comment.lua
@@ -0,0 +1,86 @@
+local M = {}
+
+function M.config()
+ lvim.builtin.comment = {
+ active = true,
+ on_config_done = nil,
+ ---Add a space b/w comment and the line
+ ---@type boolean
+ padding = true,
+
+ ---Whether cursor should stay at the
+ ---same position. Only works in NORMAL
+ ---mode mappings
+ sticky = 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 = "^$",
+
+ ---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,
+ ---Extra mapping
+ ---Includes `gco`, `gcO`, `gcA`
+ extra = true,
+ },
+
+ ---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",
+ },
+
+ ---LHS of extra mappings
+ ---@type table
+ 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",
+ },
+
+ ---Pre-hook, called before commenting the line
+ ---@type function|nil
+ pre_hook = function(...)
+ local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim")
+ if loaded and ts_comment then
+ return ts_comment.create_pre_hook()(...)
+ end
+ end,
+
+ ---Post-hook, called after commenting is done
+ ---@type function|nil
+ post_hook = nil,
+ }
+end
+
+function M.setup()
+ local nvim_comment = require "Comment"
+
+ nvim_comment.setup(lvim.builtin.comment)
+ if lvim.builtin.comment.on_config_done then
+ lvim.builtin.comment.on_config_done(nvim_comment)
+ end
+end
+
+return M