You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'comments''com' E524 E525
'comments''com'string (default
"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-")
local tobuffer
A comma-separated list of strings that can startacommentline. See
format-comments. See option-backslash about using backslashes toinserta space.
'commentstring''cms' E537
'commentstring''cms'string (default "")
local tobuffer
A template foracomment. The "%s"in the value is replaced with the
comment text. Currently only used toadd markers for folding, see
fold-marker.
Hey! I also considered that at some point, but didn't really use any of the comments features, so decided against it (didn't want to bother with it 😅).
I wouldn't mind supporting it, though, as comments is heavily related to commentstring. Do you have any ideas on how this would work and how it would be configured? Maybe we could somehow automatically guess the comments value based on the commentstring?
Had chatgpt do some research for me, and came up with the following function:
functionget_comments_for_filetype(ft)
-- Create a hidden buffer in the backgroundlocaltemp_buf=vim.api.nvim_create_buf(true, true)
-- Set the desired filetype in the temporary buffervim.api.nvim_buf_set_option(temp_buf, 'filetype', ft)
-- Get the comments var from the temporary bufferlocalcomments=vim.api.nvim_buf_get_option(temp_buf, 'comments')
-- Delete the temporary buffervim.api.nvim_buf_delete(temp_buf, { force=true })
returncommentsend
You could also do something similar to this for the commentstring to avoid having to support them manually.
From
:h comments
This plugin should also set the
comments
var. That way OG plugins like https://github.com/glts/vim-textobj-comment will also work.The text was updated successfully, but these errors were encountered: