@@ -140,8 +140,8 @@ local function symbols_to_selecta_items(raw_symbols)
140
140
local bufnr = vim .api .nvim_get_current_buf ()
141
141
local cache_key = string.format (" %d_%d" , bufnr , vim .b [bufnr ].changedtick or 0 )
142
142
143
- if M . symbol_cache and M . symbol_cache .key == cache_key then
144
- return M . symbol_cache .items
143
+ if symbol_cache and symbol_cache .key == cache_key then
144
+ return symbol_cache .items
145
145
end
146
146
147
147
local items = {}
@@ -246,10 +246,10 @@ local function show_picker(selectaItems, notify_opts)
246
246
row_position = M .config .row_position ,
247
247
hooks = {
248
248
on_render = function (buf , filtered_items )
249
- ui .apply_kind_highlights (buf , filtered_items )
249
+ ui .apply_kind_highlights (buf , filtered_items , M . config )
250
250
end ,
251
251
on_buffer_clear = function ()
252
- ui .clear_preview_highlight ()
252
+ ui .clear_preview_highlight (state . original_win , state . preview_ns )
253
253
if state .original_win and state .original_pos and vim .api .nvim_win_is_valid (state .original_win ) then
254
254
vim .api .nvim_win_set_cursor (state .original_win , state .original_pos )
255
255
end
@@ -263,34 +263,34 @@ local function show_picker(selectaItems, notify_opts)
263
263
on_select = function (selected_items )
264
264
-- TODO: we need smart mechanis on here.
265
265
if M .config .preview .highlight_mode == " select" then
266
- ui .clear_preview_highlight ()
266
+ ui .clear_preview_highlight (state . original_win , state . preview_ns )
267
267
if type (selected_items ) == " table" and selected_items [1 ] then
268
- ui .highlight_symbol (selected_items [1 ].value )
268
+ ui .highlight_symbol (selected_items [1 ].value , state . original_win , state . preview_ns )
269
269
end
270
270
end
271
271
if type (selected_items ) == " table" and selected_items [1 ] then
272
272
jump_to_symbol (selected_items [1 ].value )
273
273
end
274
274
end ,
275
275
},
276
- initial_index = M .config .focus_current_symbol and current_symbol and find_symbol_index (
276
+ initial_index = M .config .focus_current_symbol and current_symbol and ui . find_symbol_index (
277
277
selectaItems ,
278
278
current_symbol
279
279
) or nil ,
280
280
on_select = function (item )
281
- ui .clear_preview_highlight ()
281
+ ui .clear_preview_highlight (state . original_win , state . preview_ns )
282
282
jump_to_symbol (item .value )
283
283
end ,
284
284
on_cancel = function ()
285
- ui .clear_preview_highlight ()
285
+ ui .clear_preview_highlight (state . original_win , state . preview_ns )
286
286
if state .original_win and state .original_pos and vim .api .nvim_win_is_valid (state .original_win ) then
287
287
vim .api .nvim_win_set_cursor (state .original_win , state .original_pos )
288
288
end
289
289
end ,
290
290
on_move = function (item )
291
291
if M .config .preview .highlight_on_move and M .config .preview .highlight_mode == " always" then
292
292
if item then
293
- ui .highlight_symbol (item .value )
293
+ ui .highlight_symbol (item .value , state . original_win , state . preview_ns )
294
294
end
295
295
end
296
296
end ,
@@ -318,7 +318,7 @@ local function show_picker(selectaItems, notify_opts)
318
318
group = augroup ,
319
319
pattern = tostring (picker_win ),
320
320
callback = function ()
321
- ui .clear_preview_highlight ()
321
+ ui .clear_preview_highlight (state . original_win , state . preview_ns )
322
322
vim .api .nvim_del_augroup_by_name (" NamuCleanup" )
323
323
end ,
324
324
once = true ,
@@ -383,7 +383,8 @@ local function request_symbols(bufnr, callback)
383
383
end
384
384
385
385
--- Main entry point for symbol jumping functionality
386
- function M .show ()
386
+ function M .show (opts )
387
+ opts = opts or {}
387
388
-- Store current window and position
388
389
state .original_win = vim .api .nvim_get_current_win ()
389
390
state .original_buf = vim .api .nvim_get_current_buf ()
@@ -401,8 +402,15 @@ function M.show()
401
402
local bufnr = vim .api .nvim_get_current_buf ()
402
403
local cache_key = string.format (" %d_%d" , bufnr , vim .b [bufnr ].changedtick or 0 )
403
404
404
- if M .symbol_cache and M .symbol_cache .key == cache_key then
405
- show_picker (M .symbol_cache .items , notify_opts )
405
+ if symbol_cache and symbol_cache .key == cache_key then
406
+ local items = symbol_cache .items
407
+ -- If filter_kind is specified, filter the cached items
408
+ if opts .filter_kind then
409
+ items = vim .tbl_filter (function (item )
410
+ return item .kind == opts .filter_kind
411
+ end , items )
412
+ end
413
+ show_picker (items , notify_opts )
406
414
return
407
415
end
408
416
0 commit comments