Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sdoerner opened this issue Sep 9, 2024 · 1 comment

Comments

@sdoerner
Copy link

sdoerner commented Sep 9, 2024

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:

  • I couldn't find a way to un-define comment-token in the user languages.toml. (maybe there is one?)
  • Relevant code is roughly here. Seems this is using serde aliases. But at this point, I think the configs are already merged. Probably this needs to be handled earlier to remove the default config option if either of the two versions is present in the user config.
  • Arguably the default languages.toml could be updated to list both tokens for SQL. This would fix the issue for SQL but doesn't solve the customization problem more generally.
@Nikita0x
Copy link

Nikita0x commented Sep 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants