From 669174c7d12df190c95a99cdd6d1b0365bcaf32f Mon Sep 17 00:00:00 2001 From: godalming123 <68993177+godalming123@users.noreply.github.com> Date: Sat, 31 May 2025 17:39:09 +0100 Subject: [PATCH] Add grep syntax highlighting to global search picker --- helix-term/src/commands.rs | 3 ++- helix-term/src/ui/picker.rs | 5 +++++ helix-term/src/ui/prompt.rs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 604d69243..22ca00353 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2661,7 +2661,8 @@ fn global_search(cx: &mut Context) { Some((path.as_path().into(), Some((*line_num, *line_num)))) }) .with_history_register(Some(reg)) - .with_dynamic_query(get_files, Some(275)); + .with_dynamic_query(get_files, Some(275)) + .with_language("regex", std::sync::Arc::clone(&cx.editor.syn_loader)); cx.push_layer(Box::new(overlaid(picker))); } diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 7abdfce84..a6178b392 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -440,6 +440,11 @@ impl Picker { self } + pub fn with_language(mut self, language: &'static str, loader: Arc>) -> Self { + self.prompt.language = Some((language, loader)); + self + } + /// Move the cursor by a number of lines, either down (`Forward`) or up (`Backward`) pub fn move_by(&mut self, amount: u32, direction: Direction) { let len = self.matcher.snapshot().matched_item_count(); diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index ee5c46e76..25d1634f6 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -44,7 +44,7 @@ pub struct Prompt { callback_fn: CallbackFn, pub doc_fn: DocFn, next_char_handler: Option, - language: Option<(&'static str, Arc>)>, + pub language: Option<(&'static str, Arc>)>, } #[derive(Clone, Copy, PartialEq, Eq)]