diff options
author | kylo252 <[email protected]> | 2022-10-15 18:32:11 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-10-15 18:32:11 +0200 |
commit | 48d1c38fa88dbfbaa35e81560cf0fa7d8793b195 (patch) | |
tree | 17f8dbae8d101fbb5e661e23c9d24a586471e9e2 /lua/lvim/core/comment.lua | |
parent | e94390a9225c418dd96eb6b6822ce0dc15ce7cce (diff) |
chore(plugins): bump version (#3248)
* ci: update workflows
* chore(plugins): bump version
* chore: update depdecated settings for comment.nvim
* chore(lsp): update skiplist
* fixup!: take 2 for comment.nvim
Diffstat (limited to 'lua/lvim/core/comment.lua')
-rw-r--r-- | lua/lvim/core/comment.lua | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua index d07739c6..501d01b6 100644 --- a/lua/lvim/core/comment.lua +++ b/lua/lvim/core/comment.lua @@ -1,27 +1,10 @@ local M = {} function M.config() - local pre_hook = nil - if lvim.builtin.treesitter.context_commentstring.enable then - pre_hook = function(ctx) - local U = require "Comment.utils" - - -- Determine whether to use linewise or blockwise commentstring - local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" - - -- Determine the location where to calculate commentstring from - local location = nil - if ctx.ctype == U.ctype.blockwise then - location = require("ts_context_commentstring.utils").get_cursor_location() - elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then - location = require("ts_context_commentstring.utils").get_visual_start_location() - end - - return require("ts_context_commentstring.internal").calculate_commentstring { - key = type, - location = location, - } - end + local pre_hook + local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim") + if loaded and ts_comment then + pre_hook = ts_comment.create_pre_hook() end lvim.builtin.comment = { active = true, @@ -30,6 +13,11 @@ function M.config() ---@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 @@ -45,9 +33,6 @@ function M.config() ---Extra mapping ---Includes `gco`, `gcO`, `gcA` extra = true, - ---Extended mapping - ---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}` - extended = false, }, ---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode @@ -68,6 +53,17 @@ function M.config() 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 = pre_hook, |