convert to mise
Some checks failed
ci / ci (push) Failing after 1m0s

This commit is contained in:
2026-01-18 21:01:05 -07:00
parent 72b6886838
commit aff2c8c914
27 changed files with 320 additions and 115 deletions

View File

@@ -10,8 +10,12 @@
-- change on the underlying filesystem.
--------------------------------------------------------------------------------
--- @alias u.examples.FsDir { kind: 'dir'; path: string; expanded: boolean; children: u.examples.FsNode[] }
--- @alias u.examples.FsFile { kind: 'file'; path: string }
--- @class u.examples.FsDir
--- @field kind 'dir'
--- @field path string
--- @field expanded boolean
--- @field children u.examples.FsNode[]
--- @alias u.examples.FsFile table
--- @alias u.examples.FsNode u.examples.FsDir | u.examples.FsFile
--- @alias u.examples.ShowOpts { root_path?: string, width?: number, focus_path?: string }
@@ -58,7 +62,7 @@ function H.relative(path, base)
end
--- @param root_path string
--- @return { tree: u.examples.FsDir; path_to_node: table<string, u.examples.FsNode> }
--- @return { tree: u.examples.FsDir, path_to_node: table<string, u.examples.FsNode> }
function H.get_tree_inf(root_path)
logger:info { 'get_tree_inf', root_path }
--- @type table<string, u.examples.FsNode>
@@ -112,12 +116,11 @@ function H.populate_dir_children(tree, path_to_node)
end)
end
--- @param opts {
--- bufnr: number;
--- prev_winnr: number;
--- root_path: string;
--- focus_path?: string;
--- }
--- @class u.examples.RenderOpts
--- @field bufnr number
--- @field prev_winnr number
--- @field root_path string
--- @field focus_path? string
---
--- @return { expand: fun(path: string), collapse: fun(path: string) }
local function _render_in_buffer(opts)
@@ -310,7 +313,7 @@ local function _render_in_buffer(opts)
--
local renderer = Renderer.new(opts.bufnr)
tracker.create_effect(function()
--- @type { tree: u.examples.FsDir; path_to_node: table<string, u.examples.FsNode> }
--- @type { tree: u.examples.FsDir, path_to_node: table<string, u.examples.FsNode> }
local tree_inf = s_tree_inf:get()
local tree = tree_inf.tree
@@ -406,11 +409,10 @@ end
-- Public API functions:
--------------------------------------------------------------------------------
--- @type {
--- bufnr: number;
--- winnr: number;
--- controller: { expand: fun(path: string), collapse: fun(path: string) };
--- } | nil
--- @class u.examples.CurrentInf
--- @field bufnr number
--- @field winnr number
--- @field controller table
local current_inf = nil
--- Show the filetree:

View File

@@ -22,12 +22,11 @@ vim.api.nvim_create_autocmd('VimResized', {
end,
})
--- @alias u.examples.Notification {
--- kind: number;
--- id: number;
--- text: string;
--- timer: uv.uv_timer_t;
--- }
--- @class u.examples.Notification
--- @field kind number
--- @field id number
--- @field text string
--- @field timer uv.uv_timer_t
local M = {}

View File

@@ -44,23 +44,21 @@ local function shallow_copy_arr(arr) return vim.iter(arr):totable() end
-- shortest portion of this function.
--------------------------------------------------------------------------------
--- @alias u.examples.SelectController {
--- get_items: fun(): T[];
--- set_items: fun(items: T[]);
--- set_filter_text: fun(filter_text: string);
--- get_selected_indices: fun(): number[];
--- get_selected_items: fun(): T[];
--- set_selected_indices: fun(indicies: number[], ephemeral?: boolean);
--- close: fun();
--- }
--- @alias u.examples.SelectOpts<T> {
--- items: `T`[];
--- multi?: boolean;
--- format_item?: fun(item: T): u.renderer.Tree;
--- on_finish?: fun(items: T[], indicies: number[]);
--- on_selection_changed?: fun(items: T[], indicies: number[]);
--- mappings?: table<string, fun(select: u.examples.SelectController)>;
--- }
--- @class u.examples.SelectController<T>
--- @field get_items fun(): T[]
--- @field set_items fun(items: T[])
--- @field set_filter_text fun(filter_text: string)
--- @field get_selected_indices fun(): number[]
--- @field get_selected_items fun(): T[]
--- @field set_selected_indices fun(indices: number[], ephemeral?: boolean)
--- @field close fun()
--- @class u.examples.SelectOpts<T>
--- @field items T[]
--- @field multi? boolean
--- @field format_item? fun(item: T): u.renderer.Tree
--- @field on_finish? fun(items: T[], indices: number[])
--- @field on_selection_changed? fun(items: T[], indices: number[])
--- @field mappings? table<string, fun(select: u.examples.SelectController)>
--- @generic T
--- @param opts u.examples.SelectOpts<T>
@@ -326,7 +324,7 @@ function M.create_picker(opts) -- {{{
safe_wrap(function()
local items = s_items:get()
local selected_indices = s_selected_indices:get()
--- @type { orig_idx: number; item: T }[]
--- @type { orig_idx: number, item: T }[]
local filtered_items = s_filtered_items:get()
local cursor_index = s_cursor_index:get()
local indices = shallow_copy_arr(selected_indices)
@@ -477,7 +475,7 @@ function M.create_picker(opts) -- {{{
local selected_indices = s_selected_indices:get()
local top_offset = s_top_offset:get()
local cursor_index = s_cursor_index:get()
--- @type { filtered_idx: number; orig_idx: number; item: T; formatted: string }[]
--- @type { filtered_idx: number, orig_idx: number, item: T, formatted: string }[]
local visible_items = s_visible_items:get()
-- The above has to run in the execution context for the signaling to work, but
@@ -791,14 +789,14 @@ function M.buffers() -- {{{
-- ensure that `cwd` ends with a trailing slash:
if cwd[#cwd] ~= '/' then cwd = cwd .. '/' end
--- @type { name: string; changed: number; bufnr: number }[]
--- @type { name: string, changed: number, bufnr: number }[]
local bufs = vim.fn.getbufinfo { buflisted = 1 }
M.create_picker {
multi = true,
items = bufs,
--- @param item { name: string; changed: number; bufnr: number }
--- @param item { name: string, changed: number, bufnr: number }
format_item = function(item)
local item_name = item.name
if item_name == '' then item_name = '[No Name]' end

View File

@@ -21,10 +21,10 @@ local surrounds = {
['`'] = { left = '`', right = '`' },
}
--- @type { left: string; right: string } | nil
--- @type { left: string, right: string } | nil
local CACHED_BOUNDS = nil
--- @return { left: string; right: string }|nil
--- @return { left: string, right: string }|nil
local function prompt_for_bounds()
if vim_repeat.is_repeating() then
-- If we are repeating, we don't want to prompt for bounds, because
@@ -55,7 +55,7 @@ local function prompt_for_bounds()
end
--- @param range u.Range
--- @param bounds { left: string; right: string }
--- @param bounds { left: string, right: string }
local function do_surround(range, bounds)
local left = bounds.left
local right = bounds.right