docs: more docs

This commit is contained in:
Folke Lemaitre 2025-01-14 23:36:25 +01:00
parent 2cc4dd1be8
commit 89847bd76d
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
4 changed files with 149 additions and 48 deletions

View file

@ -7,10 +7,6 @@ local M = {}
---@alias snacks.picker.preview fun(ctx: snacks.picker.preview.ctx):boolean?
---@alias snacks.picker.sort fun(a:snacks.picker.Item, b:snacks.picker.Item):boolean
---@class snacks.picker.finder.Item: snacks.picker.Item
---@field idx? number
---@field score? number
--- Generic filter used by finders to pre-filter items
---@class snacks.picker.filter.Config
---@field cwd? boolean|string only show files for the given cwd
@ -18,6 +14,11 @@ local M = {}
---@field paths? table<string, boolean> only show items that include or exclude the given paths
---@field filter? fun(item:snacks.picker.finder.Item):boolean custom filter function
---@class snacks.picker.matcher.Config
---@field fuzzy? boolean use fuzzy matching (defaults to true)
---@field smartcase? boolean use smartcase (defaults to true)
---@field ignorecase? boolean use ignorecase (defaults to true)
---@class snacks.picker.Item
---@field [string] any
---@field idx number
@ -28,6 +29,10 @@ local M = {}
---@field end_pos? {[1]:number, [2]:number}
---@field highlights? snacks.picker.Highlight[][]
---@class snacks.picker.finder.Item: snacks.picker.Item
---@field idx? number
---@field score? number
---@class snacks.picker.sources.Config
---@class snacks.picker.preview.Config
@ -48,9 +53,9 @@ local M = {}
---@field preset? string|fun(source:string):string
---@class snacks.picker.win.Config
---@field input? snacks.win.Config|{}
---@field list? snacks.win.Config|{}
---@field preview? snacks.win.Config|{}
---@field input? snacks.win.Config|{} input window config
---@field list? snacks.win.Config|{} result list window config
---@field preview? snacks.win.Config|{} preview window config
---@class snacks.picker.Config
---@field source? string source name and config to use
@ -88,6 +93,7 @@ local defaults = {
sources = {},
layout = {
cycle = true,
--- Use the default layout or vertical if the window is too narrow
preset = function()
return vim.o.columns >= 120 and "default" or "vertical"
end,

View file

@ -17,11 +17,6 @@ M.INVERSE_SCORE = 1000
local YIELD_MATCH = 5 -- ms
local clear = require("table.clear")
---@class snacks.picker.matcher.Config
---@field fuzzy? boolean
---@field smartcase? boolean
---@field ignorecase? boolean
---@class snacks.picker.matcher.Mods
---@field pattern string
---@field entropy number higher entropy is less likely to match