Repository navigation
Add get_grammar_names method to registry struct - #74
Merged
Merged
Conversation
Keats
reviewed
Sep 4, 2026
|
|
||
| /// Gets the name and aliases of all grammars in the registry | ||
| /// Outputs a vector of tuples of the form (Name, Aliases) | ||
| pub fn get_grammar_names(&self) -> Vec<(String, Vec<String>)> { |
Contributor
There was a problem hiding this comment.
Do you need owned values? I would rather borrow and let the user clone if they need to. Maybe use a struct rather than a tuple as well?
…nstead of cloned values.
Contributor
Author
|
#74 (comment) The requested changes have been added. I am unfamiliar with lifetimes, can you ensure that I implemented this correctly? #[derive(Debug, PartialEq)]
pub struct GrammarNameAndAliases<'a> {
pub name: &'a String,
pub aliases: &'a Vec<String>,
} |
Keats
requested changes
Sep 4, 2026
| #[derive(Debug, PartialEq)] | ||
| pub struct GrammarNameAndAliases<'a> { | ||
| pub name: &'a String, | ||
| pub aliases: &'a Vec<String>, |
|
|
||
| #[derive(Debug, PartialEq)] | ||
| pub struct GrammarNameAndAliases<'a> { | ||
| pub name: &'a String, |
Contributor
Author
|
The requested changes have been added. Thank you for assisting me with this - I appreciate it. Let me know if there is anything else. |
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A small PR that adds a getter function to the registry struct to output all contained grammar names and their aliases.
Purpose:
I am working on integrating giallo into typst to replace syntect. In order to allow for auto completion of the available grammars, the default grammar name/alias list need to be generated. Since it can change for every new version of the builtin registry, a consistent getter is required.
I believe this functionality does not exist in the current version of giallo.
Tests:
A testcase has been added to ensures this method works.
Improvements could be made to allow for more read assess to the internal registry data.
No AI was used in the writing of this code.