helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.09k stars 2.46k forks source link

comment-tokens in languages.toml clashes with comment-token (singular) in default languages.toml #11666

Open sdoerner opened 3 weeks ago

sdoerner commented 3 weeks ago

Using SQL as an example, but this applies more generally.

Some SQL comments start with "#" (e.g. Mysql I think). So I tried to modify my languages.toml:

[[language]]
name = "sql"
comment-tokens = ["#", "--"]

Result:

Failed to parse language config: duplicate field `comment-tokens`
in `language`

The default sql language definition includes

comment-token = "--"

Possible solutions I looked at:

Nikita0x commented 2 weeks ago

One more question, the documentation says: "The tokens to use as a comment token, either a single token "//" or an array ["//", "///", "//!"] (the first token will be used for commenting). Also configurable as comment-token for backwards compatibility"

It says that in the case of an array - the first token will be used.

I have .vue files, in which there are 3 languages: html, js/ts, css. So there are 3 tokens used for commenting: 1) <!-- --> 2) // 3) /* */

How to make the correct token for comments be used? So far it only incorrectly uses comments for html - everywhere. Is it the tree sitter responsible for identifying the context in which the comment is being made - or is it an internal thing in rust? Please, clarify.