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

Remove snippet language inheritance #1712

Closed
AndreasArvidsson opened this issue Jan 29, 2025 · 0 comments · Fixed by #1715
Closed

Remove snippet language inheritance #1712

AndreasArvidsson opened this issue Jan 29, 2025 · 0 comments · Fixed by #1715

Comments

@AndreasArvidsson
Copy link
Collaborator

Today in snippets we inherit snippet from one language to another. For example typescript inherits all javascript snippets.

This behavior is defined here:

def get_super_languages(language: str) -> list[str]:
"""Returns a list of languages that are considered a superset of <language>, including <language> itself. Eg `javascript` will be included in the list when <language> is `typescript`.
Note that the order of languages returned here is very important: more general must precede more specific, so that specific langs can properly override general languages.
"""
match language:
case "_":
return ["_"]
case "typescript":
return ["_", "javascript", "typescript"]
case "javascriptreact":
return ["_", "html", "javascript", "javascriptreact"]
case "typescriptreact":
return [
"_",
"html",
"javascript",
"typescript",
"javascriptreact",
"typescriptreact",
]
case _:
return ["_", language]

This was made in an effort to make the snippet files as small as possible. In hindsight this was a bad decision. First of all is not at all obvious to users which languages are inherited and there is no simple way for them to extend this list. I recommend that we remove this and update the snippet files to just explicitly include all languages that are needed.

@phillco @pokey @nriley @knausj85

nriley pushed a commit that referenced this issue Feb 1, 2025
While I was at it I added missing languages and a few snippets

Fixes #1712
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

Successfully merging a pull request may close this issue.

1 participant