Closed mortezadadgar closed 1 year ago
There's no default go configuration for this plugin. You can set it up by extending default configuration. See :h ts-context-commentstring-commentstring-configuration
:
require('ts_context_commentstring').setup {
languages = {
go = { __default = '// %s', __multiline = '/* %s */' },
},
}
There's currently no way to provide this configuration without calling "require", but that should be a straightforward change.
A brief explanation. Commentstring is set when you open go file, because default golang ftplugin sets it up when buffer's filetype is being set. But with injections ftplugins are not executes, nor it would be trivial to describe expectations for such execution. As a result, your comment plugin works just fine in go files, but in markdown ts-context-commentstring
plugin walks tresitter injection tree upwards until it finds a language that it has a configuration for.
@Slotos well then I have to config commentstring for every language that I use that's not a good solution
Btw comment.mini
without this plugin can inject markdown code blocks commentstring so that should be possible
mini.comment
uses:
-- Using `vim.filetype.get_option()` for performance as it has caching
local cur_cs = vim.filetype.get_option(ft, 'commentstring')
I'd been musing patching in an ftplugin fallback in, didn't know it was this straightforward - that one line can simplify quite a lot of code in ts-context-commentstring.
Anyways, this can be a fun mini-project, if you enjoy coding.
@Slotos thanks for the idea, see #86
Minimal reproducible full config
Description
Hey, commentstring inside markdown's code block is not recognized properly instead relays on default commentstring of markdown files I see from documentation that markdown is not listed as supported so maybe that's the reason it's not working?
=require("ts_context_commentstring.internal").calculate_commentstring()
returns nil quickly debugging the source turns outnil
is returned from this line: https://github.com/JoosepAlviste/nvim-ts-context-commentstring/blob/main/lua/ts_context_commentstring/internal.lua#L112Steps to reproduce
<!-- -->
Expected behavior
to be commented by specified markdown code block
Actual behavior
commented by
<!-- -->
Additional context
No response