-
Notifications
You must be signed in to change notification settings - Fork 3
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
How to disable in comments? #31
Comments
First, update to the latest release. require'ultimate-autopair'.setup({
extensions={
rules={rules={{'call',function(o)
return o.col==1 or vim.treesitter.get_node({pos={o.linenr-1,o.col-2}}):type()~='comment'
end
}}}
}
}) |
Thank you. I just updated to
Here's my config
|
Oh sorry, I forgot to check if tressitter parser is attached to the buffer, or if in cmd line mode. require'ultimate-autopair'.setup({
extensions={
rules={rules={{'call',function(o)
return o.incmd
or o.col==1
or not pcall(vim.treesitter.get_node,{pos={o.linenr-1,o.col-2}})
or vim.treesitter.get_node({pos={o.linenr-1,o.col-2}}):type()~='comment'
end
}}}
}
}) |
Surprisingly, the first one works as expected when inside a comment. However, when outside of a comment quotes (single and double) are not pairing. The 2nd solution is just ignored from within a comment but otherwise, does not break usual behavior/expectations outside of a comment. |
So, is your problem solved? |
I thought my last message made it perfectly clear neither solution solves the problem. With all due respect, are you testing this as you go? |
Can you please describe in more detail what you want? |
Did you read the topic? I don't understand how it's possible that this question is coming up now. |
That's what I don't understand, the example 2 I gave disables auto-pairing (and all other features) when inserting inside comments. |
Interesting. It's working like a charm now and I'm not seeing the results I posted last night. Looks like we've got a winner here. Thanks again for providing this. This, along with being able to 'jump', are my favorite features of this autopair solution. |
Just wanted to thank you again and explain something I just picked up on which helps me to now understand why I wasn't seeing consistent results. Scenario 1: I am on any line in a .lua file and type Scenario 2: I am on any line in a .lua file and type Scenario 3: In an already commented line, I type any character that would normally autopair. Results: Scenario 2: Pass, the character does not autopair Scenario 3: Pass, the character does not autopair I suppose this has to do with deeper level treesitter stuff I don't quite grok and the solution provided is more than acceptable since I do try to make use of All the best. |
Is this even possible?
Thanks in advance
The text was updated successfully, but these errors were encountered: