wrapping.nvim
wrapping.nvim copied to clipboard
Use treesitter to toggle hard wrapping in code comments
As I mentioned in #40 I would like to see the ability to auto-wrap code comments. I had a go at implementing this and, whilst it works, I am far from proficient at lua and using neovim's APIs so I wasn't sure how to properly test my implementation.
It's a relatively simple implementation, using tsutils
to get the node under the cursor and then toggling hard wrap + adding a text width when the cursor is in a comment. I added the following to the options:
require("wrapping").setup({
...
hard_wrap_comments = {
notify = false, -- This will override "notify_on_switch"
width = 79, -- Default textwidth if not set for the filetype
}
})
So that it was possible to disable wrap notifications specifically for this mode (and any other in the future!) and allow the user to set their preferred textwidth
if it is not set in an ftpluin
.
I left the plugin disabled by default.
Either way, the actual implementation probably needs some refinement, but the logic is there.