From d214e73407a5f20eb639e8ab264cb9c8247295da Mon Sep 17 00:00:00 2001 From: dlond Date: Wed, 3 Sep 2025 09:20:23 +1200 Subject: [PATCH] fix: sigh --- .../config/compile-commands-picker.lua | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/lua/plugins/config/compile-commands-picker.lua b/lua/plugins/config/compile-commands-picker.lua index 2df60fac..ecd095d3 100644 --- a/lua/plugins/config/compile-commands-picker.lua +++ b/lua/plugins/config/compile-commands-picker.lua @@ -39,48 +39,35 @@ function M.pick_compile_commands() return end - -- Multiple files found, show picker - local pickers = require('telescope.pickers') - local finders = require('telescope.finders') - local conf = require('telescope.config').values + -- Use Telescope's built-in find_files with custom settings + local builtin = require('telescope.builtin') local actions = require('telescope.actions') local action_state = require('telescope.actions.state') - -- Create a simple path array for the finder - local paths = {} - local path_to_info = {} - for _, file in ipairs(files) do - table.insert(paths, file.path) - path_to_info[file.path] = file - end - - pickers.new({}, { + builtin.find_files({ prompt_title = 'Select compile_commands.json', - finder = finders.new_table { - results = paths, -- Pass simple path strings - entry_maker = function(path) - local info = path_to_info[path] - return { - value = info, - display = info.display, - ordinal = info.display, - path = path, -- This is what the previewer needs - } - end, - }, - sorter = conf.generic_sorter{}, - previewer = conf.file_previewer{}, + cwd = vim.fn.getcwd(), + find_command = { 'find', '.', '-name', 'compile_commands.json', '-type', 'f' }, attach_mappings = function(prompt_bufnr, map) actions.select_default:replace(function() actions.close(prompt_bufnr) local selection = action_state.get_selected_entry() if selection then - M.set_compile_commands(selection.value) + -- Convert the selection to our file_info format + local path = selection[1] + local relative = path:gsub('^%./', '') + local file_info = { + path = vim.fn.getcwd() .. '/' .. relative, + display = relative, + dir = vim.fn.fnamemodify(path, ':h'), + relative_dir = vim.fn.fnamemodify(relative, ':h'), + } + M.set_compile_commands(file_info) end end) return true end, - }):find() + }) end function M.set_compile_commands(file_info)