Created
November 19, 2021 03:07
-
-
Save sunjon/2414a671ade378766eff503ac505294c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local U = require "Comment.utils" | |
local VISUAL_LINE = U.cmotion["V"] | |
local min, max = math.min, math.max | |
require("Comment").setup { | |
opleader = { | |
-- line = "gc", -- TODO: had to switch these to achieve the lua behaviour wanted | |
line = "gb", | |
-- block = "gb", | |
block = "gc", | |
}, | |
pre_hook = function(ctx) | |
-- determine whether to use linewise or blockwise commentstrng (only for linewise visual selections) | |
if vim.bo.filetype == "lua" and (ctx.cmotion == VISUAL_LINE) then | |
local region = U.get_region "V" | |
local diff = max(region.srow, region.erow) - min(region.srow, region.erow) | |
ctx.ctype = (diff > 0) and U.ctype.block or U.ctype.line | |
end | |
end, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment