kommentary
kommentary copied to clipboard
prefer_single_line_comments does not work for xml
I set
require('kommentary.config').configure_language("default", {
prefer_single_line_comments = true,
})
for
<string>DejaVu Sans</string>
<string>DejaVu Sans Mono</string>
expect(nerdcommenter)
<!--<string>DejaVu Sans</string>-->
<!--<string>DejaVu Sans Mono</string>-->
but get
<!-- <string>DejaVu Sans</string>
<string>DejaVu Sans Mono</string> -->
Do you have JoosepAlviste/nvim-ts-context-commentstring
installed? The following lines in that plugin's instruction will mess up with prefer_single_line_comments
single_line_comment_string = 'auto',
multi_line_comment_strings = 'auto',
I comment JoosepAlviste/nvim-ts-context-commentstring
and suy/vim-context-commentstring
, then do PlugClean
and PlugUpdate
. The problem is still. Can you get the expected result? @yhu266
Yes I do get expected results. I have the following configurations (in Lua)
require('kommentary.config').configure_language('default', {
prefer_single_line_comments = true,
use_consistent_indentation = true,
ignore_whitespace = true,
-- JoosepAlviste/nvim-ts-context-commentstring
hook_function = function()
require('ts_context_commentstring.internal').update_commentstring()
end,
})
Thanks @yhu266 . I tried but problem remains. Because xml's commentstring <!--%s-->
does not end with %s
, the following function believes xml
is a language that doesn't support multi-line comments. The ending return
gives {false,{"<!--","-->"}}
.
https://github.com/b3nj5m1n/kommentary/blob/0f8e910156b8ea92690ec3c85808cdba04007ed0/lua/kommentary/config.lua#L269-L283
This will turn mode
into force_multi
, and ignore user options.
https://github.com/b3nj5m1n/kommentary/blob/0f8e910156b8ea92690ec3c85808cdba04007ed0/lua/kommentary/config.lua#L377-L384
It is safe
but not perfect
. Also, current single_line_comment_string
does not support surrounding comment.
The same thing is happening for me on Markdown and HTML filetypes.
Do you have JoosepAlviste/nvim-ts-context-commentstring installed? The following lines in that plugin's instruction will mess up with prefer_single_line_comments
For context, I don't have this installed.