Closed xbc5 closed 3 years ago
Hey @xbc5! Does the commentstring
get updated correctly when you set enable_autocmd = true
?
If so, you might have an issue in your kommentary config, you could try printing it out to debug it.
It does. What do you suspect the issue might be?
require('kommentary.config').configure_language('default', {
prefer_single_line_comments = true,
})
local langs = require("kommentary.config").config -- all default supported langs
for lang, _ in pairs(langs) do
require('kommentary.config').configure_language(lang, {
single_line_comment_string = 'auto',
multi_line_comment_strings = 'auto',
hook_function = function()
require('ts_context_commentstring.internal').update_commentstring()
end,
})
end
Hey @xbc5! Sorry it took a while to answer. I think I see what's going on with the config.
require("kommentary.config").config
does not return html
, so html
config relies on the default configget_default_config
is called after the hook function is called from the explicit configThe combination of these two things means that the hook_function
is not called for html
even if it were configured in the default
config.
An "easy" fix would be to just add another explicit config for html
:
require('kommentary.config').configure_language('html', {
single_line_comment_string = 'auto',
multi_line_comment_strings = 'auto',
hook_function = function()
require('ts_context_commentstring.internal').update_commentstring()
end,
})
A more correct fix would probably be to call the hook function after using the default config inside kommentary, then you could just configure the hook_function
in the default
config. But that would require making a PR to kommentary or creating an issue there.
Hope this helps!
Hey! I'll close this for now, feel free to re-open if you're still having trouble getting it to work.
Treesitter parsers html and javascript are installed; the module is loaded:
TSConfigInfo (modules)
Demo
index.html after commenting:
Config
packer:
config/kommentary.lua:
config.nvim-treesitter.lua: