pub enum Language {
Show 18 variants
Rust,
Python,
JavaScript,
TypeScript,
HTML,
CSS,
C,
Cpp,
Go,
Json,
Java,
CSharp,
Php,
Ruby,
Bash,
Lua,
Pascal,
Odin,
}Expand description
Language configuration for syntax highlighting
Variants§
Implementations§
Source§impl Language
impl Language
Sourcepub fn highlight_config(&self) -> Result<HighlightConfiguration, String>
pub fn highlight_config(&self) -> Result<HighlightConfiguration, String>
Get tree-sitter highlight configuration for this language
Sourcepub fn highlight_category(&self, index: usize) -> Option<HighlightCategory>
pub fn highlight_category(&self, index: usize) -> Option<HighlightCategory>
Map tree-sitter highlight index to a highlight category
Source§impl Language
impl Language
Sourcepub fn id(&self) -> &'static str
pub fn id(&self) -> &'static str
Returns the language ID (lowercase identifier used in config/internal)
Sourcepub fn lsp_language_id(&self, path: &Path) -> &'static str
pub fn lsp_language_id(&self, path: &Path) -> &'static str
Returns the LSP languageId for use in textDocument/didOpen.
This considers the file extension to return the correct LSP-spec language ID.
For example, .tsx files return "typescriptreact" instead of "typescript",
and .jsx files return "javascriptreact" instead of "javascript".
Sourcepub fn display_name(&self) -> &'static str
pub fn display_name(&self) -> &'static str
Returns the human-readable display name
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Try to map a syntect syntax name to a tree-sitter Language.
This is used to get tree-sitter features (indentation, semantic highlighting) when using a syntect grammar for syntax highlighting. This is best-effort since tree-sitter only supports ~18 languages while syntect supports 100+.
Syntect uses names like “Rust”, “Python”, “JavaScript”, “JSON”, “C++”, “C#”, “Bourne Again Shell (bash)”, etc.