Created
November 20, 2021 09:28
-
-
Save sunjon/8d1fd69e0f243ad708790f6788afc7e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ft-lua behaviour wanted, but messes up everything else | |
line = "gb", | |
-- block = "gb", | |
block = "gc", | |
}, | |
ignore = function() | |
-- ignore empty lines for lua files | |
if vim.bo.filetype == "lua" then | |
return "^$" | |
end | |
end, | |
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 diff = max(ctx.range.srow, ctx.range.erow) - min(ctx.range.srow, ctx.range.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
try this