style(picker): fix autogen types for select & resume

This commit is contained in:
Folke Lemaitre 2025-02-19 19:44:52 +01:00
parent 08c2eaf369
commit 5f2864e8c9
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
5 changed files with 47 additions and 42 deletions

View file

@ -797,6 +797,23 @@ TROUBLE *snacks-picker-examples-trouble*
---@field notify? boolean
<
>lua
---@alias snacks.Picker.ref (fun():snacks.Picker?)|{value?: snacks.Picker}
<
>lua
---@class snacks.picker.Last
---@field cursor number
---@field topline number
---@field opts? snacks.picker.Config
---@field selected snacks.picker.Item[]
---@field filter snacks.picker.Filter
<
>lua
---@alias snacks.picker.history.Record {pattern: string, search: string, live?: boolean}
<
>lua
---@alias snacks.picker.Extmark vim.api.keyset.set_extmark|{col:number, row?:number, field?:string}
---@alias snacks.picker.Text {[1]:string, [2]:string?, virtual?:boolean, field?:string}
@ -875,23 +892,6 @@ that shows a preview based on the item data.
---@field preview? snacks.win.Config|{} preview window config
<
>lua
---@alias snacks.Picker.ref (fun():snacks.Picker?)|{value?: snacks.Picker}
<
>lua
---@class snacks.picker.Last
---@field cursor number
---@field topline number
---@field opts? snacks.picker.Config
---@field selected snacks.picker.Item[]
---@field filter snacks.picker.Filter
<
>lua
---@alias snacks.picker.history.Record {pattern: string, search: string, live?: boolean}
<
==============================================================================
7. Module *snacks-picker-module*

View file

@ -1,4 +1,4 @@
*snacks.nvim.txt* For Neovim Last change: 2025 February 19
*snacks* For Neovim Last change: 2025 February 19
==============================================================================
Table of Contents *snacks.nvim-table-of-contents*

View file

@ -609,6 +609,23 @@ Snacks.picker.pick({source = "files", ...})
---@field notify? boolean
```
```lua
---@alias snacks.Picker.ref (fun():snacks.Picker?)|{value?: snacks.Picker}
```
```lua
---@class snacks.picker.Last
---@field cursor number
---@field topline number
---@field opts? snacks.picker.Config
---@field selected snacks.picker.Item[]
---@field filter snacks.picker.Filter
```
```lua
---@alias snacks.picker.history.Record {pattern: string, search: string, live?: boolean}
```
```lua
---@alias snacks.picker.Extmark vim.api.keyset.set_extmark|{col:number, row?:number, field?:string}
---@alias snacks.picker.Text {[1]:string, [2]:string?, virtual?:boolean, field?:string}
@ -687,23 +704,6 @@ It's a previewer that shows a preview based on the item data.
---@field preview? snacks.win.Config|{} preview window config
```
```lua
---@alias snacks.Picker.ref (fun():snacks.Picker?)|{value?: snacks.Picker}
```
```lua
---@class snacks.picker.Last
---@field cursor number
---@field topline number
---@field opts? snacks.picker.Config
---@field selected snacks.picker.Item[]
---@field filter snacks.picker.Filter
```
```lua
---@alias snacks.picker.history.Record {pattern: string, search: string, live?: boolean}
```
## 📦 Module
```lua
@ -2706,8 +2706,6 @@ Snacks.picker.actions.toggle_preview(picker)
Snacks.picker.actions.yank(picker, item, action)
```
## 📦 `snacks.picker.core.picker`
```lua
@ -2962,3 +2960,5 @@ Get the word under the cursor or the current visual selection
```lua
picker:word()
```

View file

@ -602,9 +602,15 @@ function M.picker_types(types)
lines[#lines + 1] = ""
lines[#lines + 1] = "---@class snacks.picker"
for _, source in ipairs(sources) do
local t = types[source] or "snacks.picker.Config"
t = t:gsub("|.*", "") .. "|{}"
lines[#lines + 1] = ("---@field %s fun(opts?: %s): snacks.Picker"):format(source, t)
if source ~= "select" then
local t = types[source] or "snacks.picker.Config"
t = t:gsub("|.*", "") .. "|{}"
if source == "resume" then
lines[#lines + 1] = ("---@field %s fun(): snacks.Picker"):format(source)
else
lines[#lines + 1] = ("---@field %s fun(opts?: %s): snacks.Picker"):format(source, t)
end
end
end
vim.fn.writefile(lines, "lua/snacks/picker/types.lua")
end

View file

@ -51,9 +51,8 @@
---@field qflist fun(opts?: snacks.picker.qf.Config|{}): snacks.Picker
---@field recent fun(opts?: snacks.picker.recent.Config|{}): snacks.Picker
---@field registers fun(opts?: snacks.picker.Config|{}): snacks.Picker
---@field resume fun(opts?: snacks.picker.Config|{}): snacks.Picker
---@field resume fun(): snacks.Picker
---@field search_history fun(opts?: snacks.picker.history.Config|{}): snacks.Picker
---@field select fun(opts?: snacks.picker.Config|{}): snacks.Picker
---@field smart fun(opts?: snacks.picker.smart.Config|{}): snacks.Picker
---@field spelling fun(opts?: snacks.picker.Config|{}): snacks.Picker
---@field treesitter fun(opts?: snacks.picker.treesitter.Config|{}): snacks.Picker