-
-
Notifications
You must be signed in to change notification settings - Fork 159
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abort visual commenting if it makes no sense #193
Comments
Very interesting use case. I tried and the following seems to work require('Comment').setup({
pre_hook = function(ctx)
local start_range = {
srow = ctx.range.srow,
erow = ctx.range.srow,
scol = ctx.range.scol,
ecol = ctx.range.scol,
}
local end_range = {
srow = ctx.range.erow,
erow = ctx.range.erow,
scol = ctx.range.ecol,
ecol = ctx.range.ecol,
}
ctx.range = start_range
local start_cstr = require('Comment.ft').calculate(ctx)
ctx.range = end_range
local end_cstr = require('Comment.ft').calculate(ctx)
return start_cstr == end_cstr and start_cstr or ''
end,
}) FYI, you don't need https://github.com/JoosepAlviste/nvim-ts-context-commentstring unless you need |
Great snippet, it works nicely! The reaon I use <html>
<body>
<script>
let name = "raafat"
</script>
</body>
</html> Which after a while of linewise commenting turns into: <html>
<body>
<script>
<!-- // <!-- // <!-- // <!-- // let name = "raafat" --> --> --> -->
</script>
</body>
</html> The same happens with |
You must be hitting this issue #62 (comment), which will, sadly, always remain a limitation |
I see. |
Hmmmm I am not sure as I don't use |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hey there, awesome plugin BTW!
This might not be strictly
Comment.nvim
specific but I'd love a pointer in the right direction.This issue is about nested filetype support so as the readme says I'm using nvim-ts-context-commentstring which integrates great with the readme pre_hook snippet
Consider the following example
Visually selecting lines 1 through 5 and commenting produces an unwanted mess:
My aim is to calculate the
commentstring
at the start and end of the visual selection and only comment if they match.I've found out that returning
%s
in thepre_hook
results in "aborting" (is there a proper way to do this?).Let me know what you think.
The text was updated successfully, but these errors were encountered: