Block comment behave wierd
glyh opened this issue · 4 comments
This seems to be due to how neovim detects the paragraphs:
local function a()
print("hello")
print("hello")
print("hello")
print("hello")
print("hello")
end
When you press gcap
on this two times, it works as you would probably want.
local function a()
print("hello")
print("hello")
print("hello")
print("hello")
print("hello")
end
When you have a blank line there, neovim will detect the bottom part as the paragraph. It seems that in this case the region will start on the blank line, so that's where the comment starts. Now, since the block looks like this:
local function a()
--[[
print("hello")
print("hello")
print("hello")
print("hello")
print("hello")
end ]]
there isn't a blank line starting a new paragraph anymore, so neovim will detect the whole thing as a paragraph.
In general, I would advise against using the paragraph text object, since something treesitter based is much more accurate. I'm not sure in which capacity it supports lua, but have a look at this plugin in case you want a function text object.
Why not just add a newline above the first comment line?
Because that's not normally the expected behaviour.
Alright, thank you. But I'm sure there is situation you want manually partition into paragraphs, because the semantic unit itself is not enough in some cases.
Workaround: I've found gcip
instead of gcap
perfectly fit my need.