Compare commits

...

5 Commits

Author SHA1 Message Date
renshyle e23068e70d
Merge 60898c2bb5 into 4281228da3 2025-07-24 20:45:11 +00:00
Valtteri Koskivuori 4281228da3
fix(queries): Fix filesystem permissions for snakemake (#14061) 2025-07-24 13:09:40 -04:00
kiara 395a71bf53
languages: nix formatter (#14046) 2025-07-23 12:51:17 -04:00
Ian Hobson 1e4bf6704a
Update Koto grammar and queries, add formatter (#14049) 2025-07-23 12:47:47 -04:00
renshyle 60898c2bb5
picker mouse support 2025-02-04 19:48:40 +02:00
10 changed files with 50 additions and 12 deletions

View File

@ -47,6 +47,7 @@ use helix_core::{
use helix_view::{
editor::Action,
graphics::{CursorKind, Margin, Modifier, Rect},
input::{MouseButton, MouseEvent, MouseEventKind},
theme::Style,
view::ViewPosition,
Document, DocumentId, Editor,
@ -247,6 +248,8 @@ pub struct Picker<T: 'static + Send + Sync, D: 'static> {
/// Current height of the completions box
completion_height: u16,
/// The area that contains the table's pickable items
picking_area: Rect,
cursor: u32,
prompt: Prompt,
@ -383,6 +386,7 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
show_preview: true,
callback_fn: Box::new(callback_fn),
completion_height: 0,
picking_area: Rect::default(),
widths,
preview_cache: HashMap::new(),
read_buffer: Vec::with_capacity(1024),
@ -565,6 +569,35 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
}
}
fn handle_mouse_event(&mut self, event: &MouseEvent) -> EventResult {
let MouseEvent {
kind, row, column, ..
} = *event;
// consume event if outside of the area with pickable items
if !self.picking_area.intersects(Rect::new(column, row, 1, 1)) {
return EventResult::Consumed(None);
}
match kind {
MouseEventKind::Down(MouseButton::Left) => {
// picking_area.height > 0 because the mouse position is inside the area
let offset = self.cursor - (self.cursor % self.picking_area.height as u32);
let new_cursor = offset + (row - self.picking_area.y) as u32;
// move if the new cursor is in bounds, on an item
if new_cursor < self.matcher.snapshot().matched_item_count() {
self.cursor = new_cursor;
}
}
MouseEventKind::ScrollUp => self.page_up(),
MouseEventKind::ScrollDown => self.page_down(),
_ => (),
}
EventResult::Consumed(None)
}
/// Get (cached) preview for the currently selected item. If a document corresponding
/// to the path is already open in the editor, it is used instead.
fn get_preview<'picker, 'editor>(
@ -726,6 +759,7 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
// -- Render the contents:
// subtract area of prompt from top
let inner = inner.clip_top(2);
self.picking_area = inner.clip_top(self.header_height());
let rows = inner.height.saturating_sub(self.header_height()) as u32;
let offset = self.cursor - (self.cursor % std::cmp::max(1, rows));
let cursor = self.cursor.saturating_sub(offset);
@ -1023,6 +1057,7 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
Event::Key(event) => *event,
Event::Paste(..) => return self.prompt_handle_event(event, ctx),
Event::Resize(..) => return EventResult::Consumed(None),
Event::Mouse(event) => return self.handle_mouse_event(event),
_ => return EventResult::Ignored(None),
};

View File

@ -1022,6 +1022,7 @@ shebangs = []
comment-token = "#"
language-servers = [ "nil", "nixd" ]
indent = { tab-width = 2, unit = " " }
formatter = { command = "nixfmt" }
[[grammar]]
name = "nix"
@ -4243,10 +4244,11 @@ comment-token = "#"
block-comment-tokens = ["#-", "-#"]
indent = { tab-width = 2, unit = " " }
language-servers = ["koto-ls"]
formatter = {command = "koto", args = ["--format"]}
[[grammar]]
name = "koto"
source = { git = "https://github.com/koto-lang/tree-sitter-koto", rev = "b420f7922d0d74905fd0d771e5b83be9ee8a8a9a" }
source = { git = "https://github.com/koto-lang/tree-sitter-koto", rev = "2ffc77c14f0ac1674384ff629bfc207b9c57ed89" }
[[language]]
name = "gpr"

View File

@ -5,11 +5,13 @@
"*"
"/"
"%"
"^"
"+="
"-="
"*="
"/="
"%="
"^="
"=="
"!="
"<"
@ -99,12 +101,18 @@
(export
(identifier) @namespace)
(call
function: (identifier) @function.method)
(chain
start: (identifier) @function)
(chain
lookup: (identifier) @variable.other.member)
(call
function: (identifier)) @function
(call_arg
(identifier) @variable.other.member)
[
(true)
(false)
@ -139,13 +147,10 @@
(self) @variable.builtin
(variable
type: (identifier) @type)
(type
_ @type)
(arg
(_ (identifier) @variable.parameter))
(ellipsis) @variable.parameter
(function
output_type: (identifier) @type)

View File

@ -11,10 +11,6 @@
(call_args
((call_arg) @parameter.inside . ","? @parameter.around) @parameter.around)
(chain
call: (tuple
((element) @parameter.inside . ","? @parameter.around) @parameter.around))
(map
((entry_inline) @entry.inside . ","? @entry.around) @entry.around)

0
runtime/queries/snakemake/LICENSE 100755 → 100644
View File

View File

View File

View File

View File

View File