@@ -2,14 +2,12 @@ local M = {}
22
33--- @type table<string , string>
44local PICKER_MODULES = {
5- telescope = " telescope" ,
5+ telescope = " telescope.pickers " ,
66 [" fzf-lua" ] = " fzf-lua" ,
7- snacks = " snacks" ,
7+ snacks = " snacks.picker " ,
88}
99
10- function M .check ()
11- vim .health .start (" peekstack" )
12-
10+ local function report_environment ()
1311 if vim .fn .has (" nvim-0.12" ) == 1 then
1412 vim .health .ok (" nvim >= 0.12" )
1513 else
@@ -21,20 +19,52 @@ function M.check()
2119 else
2220 vim .health .warn (" rg not found (grep.search will be unavailable)" )
2321 end
22+ end
2423
25- local ok , cfg_mod = pcall (require , " peekstack.config" )
26- if not ok then
27- return
24+ --- @param cfg PeekstackConfig
25+ local function report_providers (cfg )
26+ --- @type { name : string , enabled : boolean , note : string ? } []
27+ local entries = {
28+ { name = " lsp" , enabled = cfg .providers .lsp .enable },
29+ { name = " diagnostics" , enabled = cfg .providers .diagnostics .enable },
30+ { name = " file" , enabled = cfg .providers .file .enable },
31+ { name = " grep" , enabled = true , note = " always registered" },
32+ { name = " marks" , enabled = cfg .providers .marks .enable },
33+ }
34+
35+ --- @type string[]
36+ local enabled_names = {}
37+ for _ , entry in ipairs (entries ) do
38+ if entry .enabled then
39+ enabled_names [# enabled_names + 1 ] = entry .name
40+ end
2841 end
29- local cfg = cfg_mod .get ()
3042
31- -- Picker backend
32- local backend = cfg .picker and cfg .picker .backend
33- if backend and backend ~= " builtin" then
43+ if # enabled_names == 0 then
44+ vim .health .warn (" providers: none enabled" )
45+ else
46+ vim .health .ok (" providers enabled: " .. table.concat (enabled_names , " , " ))
47+ end
48+
49+ for _ , entry in ipairs (entries ) do
50+ if not entry .enabled then
51+ vim .health .info (string.format (" provider '%s' disabled" , entry .name ))
52+ elseif entry .note then
53+ vim .health .info (string.format (" provider '%s' (%s)" , entry .name , entry .note ))
54+ end
55+ end
56+ end
57+
58+ --- @param cfg PeekstackConfig
59+ local function report_picker (cfg )
60+ local backend = cfg .picker and cfg .picker .backend or " builtin"
61+ if backend == " builtin" then
62+ vim .health .ok (" picker backend 'builtin'" )
63+ else
3464 local plugin_name = PICKER_MODULES [backend ]
3565 if plugin_name then
36- local has = pcall (require , plugin_name )
37- if has then
66+ local installed = pcall (require , plugin_name )
67+ if installed then
3868 vim .health .ok (" picker backend '" .. backend .. " ' available" )
3969 else
4070 vim .health .warn (" picker backend '" .. backend .. " ' is configured but the plugin is not installed" )
@@ -44,31 +74,124 @@ function M.check()
4474 end
4575 end
4676
47- -- Persist
77+ if cfg .picker and cfg .picker .builtin and cfg .picker .builtin .preview_lines ~= nil then
78+ vim .health .info (string.format (" picker.builtin.preview_lines = %d" , cfg .picker .builtin .preview_lines ))
79+ end
80+ end
81+
82+ --- @param cfg PeekstackConfig
83+ local function report_persist (cfg )
4884 local persist = cfg .persist
49- if persist and persist .enabled then
50- local fs = require (" peekstack.util.fs" )
51- local repo = fs .repo_root ()
52- if repo then
53- vim .health .ok (" persist enabled (repo: " .. repo .. " )" )
54- else
55- vim .health .warn (" persist enabled but not inside a git repository; sessions will use cwd-based storage" )
85+ if not persist or not persist .enabled then
86+ vim .health .info (" persist disabled" )
87+ return
88+ end
89+
90+ vim .health .ok (" persist enabled (max_items=" .. tostring (persist .max_items ) .. " )" )
91+
92+ local has_repo = true
93+ local ok_fs , fs = pcall (require , " peekstack.util.fs" )
94+ if ok_fs then
95+ local ok_path , path = pcall (fs .scope_path , " repo" )
96+ if ok_path and path then
97+ vim .health .info (" storage path: " .. path )
5698 end
57- if persist .auto and persist .auto .enabled then
58- vim .health .ok (" auto persist enabled (session: " .. (persist .auto .session_name or " auto" ) .. " )" )
99+ has_repo = fs .repo_root () ~= nil
100+ if not has_repo then
101+ vim .health .warn (" not inside a git repository; sessions fall back to cwd-based storage" )
59102 end
60103 end
61104
62- -- Tree-sitter context
63- local title = cfg .ui and cfg .ui .title
64- if title and title .context and title .context .enabled then
65- local parser = vim .treesitter .get_parser (0 )
66- if parser then
67- vim .health .ok (" tree-sitter context enabled (parser available for current buffer)" )
68- else
69- vim .health .info (" tree-sitter context enabled but no parser for the current buffer filetype" )
70- end
105+ if type (persist .auto ) ~= " table" then
106+ vim .health .info (" auto persist disabled" )
107+ return
108+ end
109+
110+ if not persist .auto .enabled then
111+ vim .health .info (" auto persist disabled" )
112+ return
113+ end
114+
115+ local message = string.format (
116+ " auto persist enabled (session=%q, debounce_ms=%d, save_on_leave=%s)" ,
117+ tostring (persist .auto .session_name ),
118+ persist .auto .debounce_ms or 0 ,
119+ tostring (persist .auto .save_on_leave )
120+ )
121+ if has_repo then
122+ vim .health .ok (message )
123+ else
124+ vim .health .warn (message .. " ; inactive outside git repository" )
125+ end
126+ end
127+
128+ --- @param events string[] ?
129+ --- @return string
130+ local function format_events (events )
131+ if not events or # events == 0 then
132+ return " (none)"
133+ end
134+ return table.concat (events , " , " )
135+ end
136+
137+ --- @param cfg PeekstackConfig
138+ local function report_close_events (cfg )
139+ local quick = cfg .ui and cfg .ui .quick_peek and cfg .ui .quick_peek .close_events
140+ vim .health .info (" quick_peek close_events: " .. format_events (quick ))
141+
142+ local inline = cfg .ui and cfg .ui .inline_preview and cfg .ui .inline_preview .close_events
143+ if cfg .ui and cfg .ui .inline_preview and cfg .ui .inline_preview .enabled then
144+ vim .health .info (" inline_preview close_events: " .. format_events (inline ))
145+ else
146+ vim .health .info (" inline_preview disabled" )
147+ end
148+ end
149+
150+ --- @param cfg PeekstackConfig
151+ local function report_treesitter (cfg )
152+ local context = cfg .ui and cfg .ui .title and cfg .ui .title .context
153+ if not context or not context .enabled then
154+ vim .health .info (" title context disabled (ui.title.context.enabled = false)" )
155+ return
156+ end
157+
158+ vim .health .ok (string.format (" title context enabled (max_depth=%d)" , context .max_depth or 0 ))
159+
160+ local bufnr = vim .api .nvim_get_current_buf ()
161+ local filetype = vim .bo [bufnr ].filetype
162+ local label = filetype ~= " " and string.format (" filetype=%q" , filetype ) or " no filetype"
163+
164+ local ok_parser , parser = pcall (vim .treesitter .get_parser , bufnr )
165+ if ok_parser and parser then
166+ vim .health .ok (" tree-sitter parser available for current buffer (" .. label .. " )" )
167+ else
168+ vim .health .info (" tree-sitter context enabled but no parser for the current buffer (" .. label .. " )" )
169+ end
170+ end
171+
172+ function M .check ()
173+ vim .health .start (" peekstack: environment" )
174+ report_environment ()
175+
176+ local ok , cfg_mod = pcall (require , " peekstack.config" )
177+ if not ok then
178+ vim .health .error (" peekstack.config could not be loaded" )
179+ return
71180 end
181+ local cfg = cfg_mod .get ()
182+
183+ vim .health .start (" peekstack: providers" )
184+ report_providers (cfg )
185+
186+ vim .health .start (" peekstack: picker" )
187+ report_picker (cfg )
188+
189+ vim .health .start (" peekstack: persist" )
190+ report_persist (cfg )
191+
192+ vim .health .start (" peekstack: ui" )
193+ report_close_events (cfg )
194+ report_treesitter (cfg )
72195end
73196
74197return M
0 commit comments