summaryrefslogtreecommitdiff
path: root/lua/lvim/core/comment.lua
diff options
context:
space:
mode:
authorLostNeophyte <[email protected]>2023-01-25 18:55:31 +0100
committerLostNeophyte <[email protected]>2023-01-25 18:55:31 +0100
commit75b653cc623a8cd6de397e42f21b838a065eb0e0 (patch)
tree7b43499c99423651d7e75662bb4628569834e28f /lua/lvim/core/comment.lua
parent4f02e54d923414eb6690d64c7e334f624a2a9342 (diff)
refactor!: put all plugin options under `opts`
Diffstat (limited to 'lua/lvim/core/comment.lua')
-rw-r--r--lua/lvim/core/comment.lua122
1 files changed, 62 insertions, 60 deletions
diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua
index 48e776de..2f526c63 100644
--- a/lua/lvim/core/comment.lua
+++ b/lua/lvim/core/comment.lua
@@ -2,73 +2,75 @@ local M = {}
function M.config()
local config = {
- ---Add a space b/w comment and the line
- ---@type boolean
- padding = true,
+ opts = {
+ ---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,
+ ---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 = "^$",
+ ---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,
- },
+ ---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 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 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",
- },
+ ---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,
+ ---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,
+ ---Post-hook, called after commenting is done
+ ---@type function|nil
+ post_hook = nil,
+ },
}
---@cast config +LvimBuiltin
require("lvim.core.builtins").extend_defaults(config)
@@ -78,7 +80,7 @@ end
function M.setup()
local nvim_comment = require "Comment"
- nvim_comment.setup(lvim.builtin.comment)
+ nvim_comment.setup(lvim.builtin.comment.opts)
end
return M