Skip to content

Commit 24a3c34

Browse files
author
Bassam Data
committed
fix(ctags): fix some ctgas issues with modulizing
1 parent fb79b31 commit 24a3c34

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
deps/
22
TODO.md
3+
CLAUDE.md
34

45
# MacOS
56
.DS_Store

lua/namu/namu_ctags/init.lua

+22-14
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ local function symbols_to_selecta_items(raw_symbols)
140140
local bufnr = vim.api.nvim_get_current_buf()
141141
local cache_key = string.format("%d_%d", bufnr, vim.b[bufnr].changedtick or 0)
142142

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
145145
end
146146

147147
local items = {}
@@ -246,10 +246,10 @@ local function show_picker(selectaItems, notify_opts)
246246
row_position = M.config.row_position,
247247
hooks = {
248248
on_render = function(buf, filtered_items)
249-
ui.apply_kind_highlights(buf, filtered_items)
249+
ui.apply_kind_highlights(buf, filtered_items, M.config)
250250
end,
251251
on_buffer_clear = function()
252-
ui.clear_preview_highlight()
252+
ui.clear_preview_highlight(state.original_win, state.preview_ns)
253253
if state.original_win and state.original_pos and vim.api.nvim_win_is_valid(state.original_win) then
254254
vim.api.nvim_win_set_cursor(state.original_win, state.original_pos)
255255
end
@@ -263,34 +263,34 @@ local function show_picker(selectaItems, notify_opts)
263263
on_select = function(selected_items)
264264
-- TODO: we need smart mechanis on here.
265265
if M.config.preview.highlight_mode == "select" then
266-
ui.clear_preview_highlight()
266+
ui.clear_preview_highlight(state.original_win, state.preview_ns)
267267
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)
269269
end
270270
end
271271
if type(selected_items) == "table" and selected_items[1] then
272272
jump_to_symbol(selected_items[1].value)
273273
end
274274
end,
275275
},
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(
277277
selectaItems,
278278
current_symbol
279279
) or nil,
280280
on_select = function(item)
281-
ui.clear_preview_highlight()
281+
ui.clear_preview_highlight(state.original_win, state.preview_ns)
282282
jump_to_symbol(item.value)
283283
end,
284284
on_cancel = function()
285-
ui.clear_preview_highlight()
285+
ui.clear_preview_highlight(state.original_win, state.preview_ns)
286286
if state.original_win and state.original_pos and vim.api.nvim_win_is_valid(state.original_win) then
287287
vim.api.nvim_win_set_cursor(state.original_win, state.original_pos)
288288
end
289289
end,
290290
on_move = function(item)
291291
if M.config.preview.highlight_on_move and M.config.preview.highlight_mode == "always" then
292292
if item then
293-
ui.highlight_symbol(item.value)
293+
ui.highlight_symbol(item.value, state.original_win, state.preview_ns)
294294
end
295295
end
296296
end,
@@ -318,7 +318,7 @@ local function show_picker(selectaItems, notify_opts)
318318
group = augroup,
319319
pattern = tostring(picker_win),
320320
callback = function()
321-
ui.clear_preview_highlight()
321+
ui.clear_preview_highlight(state.original_win, state.preview_ns)
322322
vim.api.nvim_del_augroup_by_name("NamuCleanup")
323323
end,
324324
once = true,
@@ -383,7 +383,8 @@ local function request_symbols(bufnr, callback)
383383
end
384384

385385
---Main entry point for symbol jumping functionality
386-
function M.show()
386+
function M.show(opts)
387+
opts = opts or {}
387388
-- Store current window and position
388389
state.original_win = vim.api.nvim_get_current_win()
389390
state.original_buf = vim.api.nvim_get_current_buf()
@@ -401,8 +402,15 @@ function M.show()
401402
local bufnr = vim.api.nvim_get_current_buf()
402403
local cache_key = string.format("%d_%d", bufnr, vim.b[bufnr].changedtick or 0)
403404

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)
406414
return
407415
end
408416

0 commit comments

Comments
 (0)