From 83271b98d8801e03d4bcfc1dd57a59cab7effa3d Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 28 Jan 2025 13:05:37 +0000 Subject: [PATCH] chore: remove pointless language --- helix-term/src/ui/markdown.rs | 63 ++++++++++++++-------------- languages.toml | 12 ------ runtime/queries/helix/highlights.scm | 1 - 3 files changed, 32 insertions(+), 44 deletions(-) delete mode 100644 runtime/queries/helix/highlights.scm diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs index c26265496..7b9182560 100644 --- a/helix-term/src/ui/markdown.rs +++ b/helix-term/src/ui/markdown.rs @@ -40,37 +40,6 @@ pub fn highlighted_code_block<'a>( let mut lines = Vec::new(); let get_theme = |key: &str| -> Style { theme.map(|t| t.get(key)).unwrap_or_default() }; - let text_style = get_theme(Markdown::TEXT_STYLE); - let code_style = get_theme(Markdown::BLOCK_STYLE); - - let theme = match theme { - Some(t) => t, - None => return styled_multiline_text(text, code_style), - }; - - let ropeslice = RopeSlice::from(text); - let syntax = config_loader - .load() - .language_configuration_for_injection_string(&InjectionLanguageMarker::Name( - language.into(), - )) - .and_then(|config| config.highlight_config(theme.scopes())) - .and_then(|config| Syntax::new(ropeslice, config, Arc::clone(&config_loader))); - - let syntax = match syntax { - Some(s) => s, - None => return styled_multiline_text(text, code_style), - }; - - let highlight_iter = syntax - .highlight_iter(ropeslice, None, None) - .map(|e| e.unwrap()); - let highlight_iter: Box> = - if let Some(spans) = additional_highlight_spans { - Box::new(helix_core::syntax::merge(highlight_iter, spans)) - } else { - Box::new(highlight_iter) - }; // Apply custom rendering rules to Helix code blocks. // These render selections as if in the real editor. @@ -133,6 +102,38 @@ pub fn highlighted_code_block<'a>( } } } else { + let text_style = get_theme(Markdown::TEXT_STYLE); + let code_style = get_theme(Markdown::BLOCK_STYLE); + + let theme = match theme { + Some(t) => t, + None => return styled_multiline_text(text, code_style), + }; + + let ropeslice = RopeSlice::from(text); + let syntax = config_loader + .load() + .language_configuration_for_injection_string(&InjectionLanguageMarker::Name( + language.into(), + )) + .and_then(|config| config.highlight_config(theme.scopes())) + .and_then(|config| Syntax::new(ropeslice, config, Arc::clone(&config_loader))); + + let syntax = match syntax { + Some(s) => s, + None => return styled_multiline_text(text, code_style), + }; + + let highlight_iter = syntax + .highlight_iter(ropeslice, None, None) + .map(|e| e.unwrap()); + let highlight_iter: Box> = + if let Some(spans) = additional_highlight_spans { + Box::new(helix_core::syntax::merge(highlight_iter, spans)) + } else { + Box::new(highlight_iter) + }; + let mut highlights = Vec::new(); for event in highlight_iter { match event { diff --git a/languages.toml b/languages.toml index 635d2b09b..0aca142a8 100644 --- a/languages.toml +++ b/languages.toml @@ -4077,15 +4077,3 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "gren" source = { git = "https://github.com/MaeBrooks/tree-sitter-gren", rev = "76554f4f2339f5a24eed19c58f2079b51c694152" } - -# this is just a dummy language, it's entry simply needs to exist -# but it doesn't matter what these values are as we are using a custom renderer -[[language]] -name = "helix" -scope = "source.helix" -injection-regex = "helix" -file-types = ["helix"] - -[[grammar]] -name = "helix" -source = { git = "https://github.com/MaeBrooks/tree-sitter-gren", rev = "76554f4f2339f5a24eed19c58f2079b51c694152" } diff --git a/runtime/queries/helix/highlights.scm b/runtime/queries/helix/highlights.scm deleted file mode 100644 index 475582af2..000000000 --- a/runtime/queries/helix/highlights.scm +++ /dev/null @@ -1 +0,0 @@ -; this file simply needs to exist