refactor: Complete modular migration from kickstart.nvim

Major architectural overhaul to transform the flat kickstart.nvim structure
  into a maintainable, modular configuration while preserving upstream sync capability.

  ## Structure Changes
  - Migrated from flat `lua/custom/` to organized `lua/core/` and `lua/plugins/`
  - Separated plugin specs from configs: `lua/plugins/spec/` and `lua/plugins/config/`
  - Complex configs (LSP, Debug) now use directory structure with sub-modules:
    - `lsp/init.lua`, `lsp/servers.lua`, `lsp/keymaps.lua`
    - `debug/init.lua`, `debug/adapters.lua`, `debug/keymaps.lua`

  ## Core Improvements
  - Created dedicated core modules: options, keymaps, autocmds, bootstrap, health
  - Added comprehensive health check (`lua/core/health.lua`) for diagnostics
  - Simplified init.lua to just orchestrate module loading
  - Better separation of concerns throughout

  ## Plugin Updates
  - Fixed Blink.cmp configuration (removed invalid fuzzy options)
  - Integrated Copilot with Blink.cmp for unified completion experience
  - Added autopairs and indent-line from kickstart examples
  - Optimized for Nix development environments (removed venv assumptions)

  ## Documentation
  - Updated README with modular structure and kickstart sync instructions
  - Created comprehensive KEYBIND_ANALYSIS.md with all mappings
  - Added modular.txt help documentation
  - Created TODO_TEST.md checklist for testing

  ## Benefits
  - Easier to maintain and extend
  - Clean separation allows upstream kickstart merges without conflicts
  - Scalable architecture for adding new languages/tools
  - Better code organization and discoverability

  All kickstart functionality preserved while gaining modularity and maintainability.
This commit is contained in:
dlond 2025-09-02 13:21:18 +12:00 committed by Daniel Lond
parent 277be1e79b
commit f81cab2da3
55 changed files with 2039 additions and 2299 deletions

View file

@ -1,26 +0,0 @@
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
-- LSP reload function
local function reload_lsp()
local clients = vim.lsp.get_clients()
if #clients == 0 then
print('No LSP clients running')
return
end
for _, client in ipairs(clients) do
vim.lsp.stop_client(client.id)
end
vim.defer_fn(function()
vim.cmd('LspStart')
print('LSP servers reloaded')
end, 500)
end
-- Reload LSP keybind
vim.keymap.set('n', '<leader>lr', reload_lsp, { desc = '[L]SP [R]eload all servers' })
-- Standard practice for Lua modules that don't need to return complex data
return {}

View file

@ -1,69 +0,0 @@
-- Place custom vim options here
-- Set based on your font installation
vim.g.have_nerd_font = true
-- Indentation settings
vim.o.smartindent = true
vim.o.autoindent = true
vim.o.expandtab = true
vim.o.tabstop = 2
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
-- Add any other custom vim.o or vim.g settings from your old config here
-- For example, if you changed defaults for:
-- vim.opt.number = true -- (Already default in kickstart)
-- vim.opt.mouse = 'a' -- (Already default in kickstart)
-- etc... Review the options section of your old init.lua and add any *changed* values here.
-- The kickstart defaults are generally sensible, so you might not need many overrides.
-- Function to check if running in a shared tmux session
local function is_shared_tmux_session()
if not vim.env.TMUX then
return false
end
local handle = io.popen('tmux list-sessions -F "#{session_name}:#{session_attached}" 2>/dev/null')
if not handle then
return false
end
local current_session = vim.fn.system('tmux display-message -p "#S"'):gsub('\n', '')
local output = handle:read('*a')
handle:close()
-- Check if session name contains "shared" (case insensitive)
if current_session:lower():find('shared') then
return true
end
-- Also check if multiple users are attached
for line in output:gmatch('[^\r\n]+') do
local session_name, attached_count = line:match('([^:]+):(%d+)')
if session_name == current_session and tonumber(attached_count) > 1 then
return true
end
end
return false
end
-- Warn before quitting if in a shared tmux session
vim.api.nvim_create_autocmd('VimLeavePre', {
callback = function()
if is_shared_tmux_session() then
local choice = vim.fn.confirm(
'You are in a shared tmux session. Other users may be affected.\nDo you really want to quit?',
'&Yes\n&No',
2 -- Default to No
)
-- vim.fn.confirm returns 1 for Yes, 2 for No, 0 for Esc
-- The & makes Y/y and N/n work as shortcuts (case-insensitive)
if choice ~= 1 then
return -- Prevent quit unless explicitly choosing Yes
end
end
end,
})

View file

@ -1,29 +0,0 @@
return {
'saghen/blink.cmp',
dependencies = {
"giuxtaposition/blink-cmp-copilot",
},
opts = {
sources = {
default = { "lsp", "path", "copilot", "buffer" },
providers = {
copilot = {
name = "copilot",
module = "blink-cmp-copilot",
score_offset = 100, -- High priority to show Copilot near the top
async = true,
},
},
},
keymap = {
preset = 'default',
accept = '<C-y>', -- Your preferred accept key
},
appearance = {
-- Show source of completion (LSP/Copilot/Buffer)
use_nvim_cmp_as_default = false,
nerd_font_variant = 'mono',
},
fuzzy = {},
},
}

View file

@ -1,35 +0,0 @@
return {
-- Use copilot.lua for API access (no UI)
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup({
suggestion = { enabled = false }, -- Disable inline ghost text
panel = { enabled = false }, -- Disable suggestion panel
filetypes = {
yaml = false,
markdown = false,
help = false,
gitcommit = false,
gitrebase = false,
hgcommit = false,
svn = false,
cvs = false,
["."] = false,
},
copilot_node_command = 'node', -- Node.js version must be > 18.x
server_opts_overrides = {},
})
end,
},
-- Bridge between copilot.lua and blink.cmp
{
"giuxtaposition/blink-cmp-copilot",
dependencies = {
"zbirenbaum/copilot.lua",
},
},
}

View file

@ -1,157 +0,0 @@
-- ~/dlond/nvim/lua/custom/plugins/debug.lua
-- Debug Adapter Protocol (DAP) setup, integrating kickstart's UI preferences
return {
-- Main DAP plugin
{
'mfussenegger/nvim-dap',
dependencies = {
-- UI for nvim-dap
{
'rcarriga/nvim-dap-ui',
dependencies = { 'nvim-neotest/nvim-nio' }, -- nvim-dap-ui often needs nio
config = function()
local asyn = require 'plenary.async'
local dapui = require 'dapui'
dapui.setup {
-- Borrowed icon and control settings from kickstart/plugins/debug.lua
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
icons = {
pause = '',
play = '',
step_into = '',
step_over = '',
step_out = '',
step_back = 'b', -- Kickstart uses 'b', nvim-dap default might be different
run_last = '▶▶',
terminate = '',
disconnect = '',
},
},
-- You can customize layouts, floating window behavior, etc.
-- layouts = { ... },
-- floating = { ... },
}
-- Automatically open/close dapui when DAP session starts/stops
local dap = require 'dap'
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open()
end
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close()
end
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close()
end
end,
},
-- Optional: Virtual text for DAP (shows variable values inline)
-- { 'theHamsta/nvim-dap-virtual-text', opts = {} },
-- If you need Go debugging, you would add 'leoluz/nvim-dap-go' here
-- and call its setup in the nvim-dap config function.
-- { 'leoluz/nvim-dap-go' },
},
config = function()
local dap = require 'dap'
local dapui = require 'dapui'
local async = require 'plenary.async'
-- Configure the LLDB DAP adapter for C/C++
-- Assumes 'lldb-dap' executable is in PATH (from pkgs.llvmPackages_XX.lldb)
dap.adapters.lldb = {
type = 'executable',
command = 'lldb-dap',
name = 'lldb-dap (Nix)',
}
dap.configurations.cpp = {
{
name = 'Launch C/C++ (lldb-dap)',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- local utils = require 'custom.utils'
-- local target = utils:get_target()
-- return utils.pick_executable(vim.fn.getcwd() .. '/' .. target)
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
-- Ensure your C/C++ project is compiled with debug symbols (e.g., -g flag with clang/gcc)
},
}
dap.configurations.c = dap.configurations.cpp -- Use same config for C
-- Python DAP configuration (using debugpy)
-- Ensure python3Packages.debugpy is in your home.packages
dap.adapters.python = {
type = 'executable',
command = 'python', -- Should be the python from your Nix env
args = { '-m', 'debugpy.adapter' },
}
dap.configurations.python = {
{
type = 'python',
request = 'launch',
name = 'Launch Python file',
program = '${file}', -- Debug the current file
pythonPath = function()
local venv = os.getenv 'VIRTUAL_ENV'
if venv then
return venv .. '/bin/python'
end
-- Fallback to trying to find python3, then python in PATH
-- This could be made more robust by getting python path from Nix if needed
local py3 = vim.fn.executable 'python3'
if py3 ~= 0 and py3 ~= '' then
return py3
end
return 'python'
end,
},
}
-- If you added 'leoluz/nvim-dap-go' as a dependency:
-- require('dap-go').setup() -- Call its setup function
-- Launch and Control
vim.keymap.set('n', '<leader>dc', function()
async.run(function()
dap.continue()
if not dapui.windows or vim.tbl_isempty(dapui.windows) then
dapui.open()
end
end)
end, { desc = 'DAP: [C]ontinue show UI (async-safe)' })
vim.keymap.set('n', '<leader>db', dap.toggle_breakpoint, { desc = 'DAP: Toggle [B]reakpoint' })
vim.keymap.set('n', '<leader>dl', dap.run_last, { desc = 'DAP: Run [L]ast' })
-- DAP: Stepping
vim.keymap.set('n', '<leader>di', dap.step_into, { desc = 'DAP: Step [I]nto' })
vim.keymap.set('n', '<leader>dk', dap.step_over, { desc = 'DAP: Step [O]ver (k)' })
vim.keymap.set('n', '<leader>do', dap.step_out, { desc = 'DAP: Step [O]ut' })
vim.keymap.set('n', '<leader>dx', function()
async.run(function()
dap.run_to_cursor()
end)
end, { desc = 'DAP: Run to Cursor (x) (asyn-safe)' })
-- DAP: Termination
vim.keymap.set('n', '<leader>dt', function()
async.run(function()
dap.terminate()
dapui.close()
end)
end, { desc = 'DAP: [T]erminate (async-safe)' })
-- DAP: UI
vim.keymap.set('n', '<leader>dr', dap.repl.open, { desc = 'DAP: Open [R]EPL' })
vim.keymap.set('n', '<leader>du', dapui.toggle, { desc = 'DAP: Toggle [U]I' })
end,
},
}

View file

@ -1,40 +0,0 @@
-- Formatter configuration
return {
-- ========================================
-- Formatter Configuration (conform.nvim)
-- ========================================
{
'stevearc/conform.nvim',
event = 'BufWritePre', -- Format on save
-- cmd = { 'ConformInfo' }, -- Optional: If you want the command available
-- keys = { ... } -- Optional: Define keys if needed
opts = {
formatters_by_ft = {
lua = { 'stylua' },
c = { 'clang_format' },
cpp = { 'clang_format' },
-- Use ruff for Python formatting (includes isort and is faster than black
-- Ensure 'ruff' is installed via Home Manager (pkgs.ruff)
python = { 'ruff_format', 'ruff_fix' },
-- python = { 'isort', 'black' },
nix = { 'alejandra' }, -- Add nix formatter
-- Add other filetypes and formatters, e.g.:
-- javascript = { "prettier" },
-- typescript = { "prettier" },
-- css = { "prettier" },
-- html = { "prettier" },
-- json = { "prettier" },
-- yaml = { "prettier" },
-- markdown = { "prettier" },
-- bash = { "shfmt" },
},
-- Configure format_on_save behavior
format_on_save = {
-- I recommend these options, but adjust to your liking
timeout_ms = 500, -- Stop formatting if it takes too long
lsp_fallback = true, -- Fallback to LSP formatting if conform fails
},
},
},
}

View file

@ -1,73 +0,0 @@
return {
-- Fugitive - Git integration
{
'tpope/vim-fugitive',
cmd = { 'Git', 'G', 'Gdiff', 'Gread', 'Gwrite', 'Ggrep', 'GMove', 'GDelete', 'GBrowse', 'GRemove' },
keys = {
{ '<leader>gs', '<cmd>Git<cr>', desc = 'Git status' },
{ '<leader>gd', '<cmd>Gdiff<cr>', desc = 'Git diff' },
{ '<leader>gc', '<cmd>Git commit<cr>', desc = 'Git commit' },
{ '<leader>gb', '<cmd>Git blame<cr>', desc = 'Git blame' },
{ '<leader>gl', '<cmd>Git log<cr>', desc = 'Git log' },
{ '<leader>gp', '<cmd>Git push<cr>', desc = 'Git push' },
{ '<leader>gf', '<cmd>Git fetch<cr>', desc = 'Git fetch' },
},
},
-- Gitsigns - Git gutter and hunk operations
{
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
on_attach = function(bufnr)
local gitsigns = require('gitsigns')
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then
vim.cmd.normal({']c', bang = true})
else
gitsigns.nav_hunk('next')
end
end, { desc = 'Next git hunk' })
map('n', '[c', function()
if vim.wo.diff then
vim.cmd.normal({'[c', bang = true})
else
gitsigns.nav_hunk('prev')
end
end, { desc = 'Previous git hunk' })
-- Actions
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'Stage hunk' })
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'Reset hunk' })
map('v', '<leader>hs', function() gitsigns.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end, { desc = 'Stage hunk' })
map('v', '<leader>hr', function() gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end, { desc = 'Reset hunk' })
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'Stage buffer' })
map('n', '<leader>hu', gitsigns.undo_stage_hunk, { desc = 'Undo stage hunk' })
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'Reset buffer' })
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'Preview hunk' })
map('n', '<leader>hb', function() gitsigns.blame_line{full=true} end, { desc = 'Blame line' })
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = 'Toggle line blame' })
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'Diff this' })
map('n', '<leader>hD', function() gitsigns.diffthis('~') end, { desc = 'Diff this ~' })
map('n', '<leader>td', gitsigns.toggle_deleted, { desc = 'Toggle deleted' })
-- Text object
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'Select hunk' })
end,
},
},
}

View file

@ -1,17 +0,0 @@
-- You can add your own plugins here or in other files in this directory!
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {
-- { import = 'custom.plugins.completion' },
-- { import = 'custom.plugins.theme' },
-- { import = 'custom.plugins.avante' },
{ import = 'custom.plugins.copilot' },
{ import = 'custom.plugins.debug' },
{ import = 'custom.plugins.formatting' },
{ import = 'custom.plugins.git' },
{ import = 'custom.plugins.lsp' },
{ import = 'custom.plugins.nvim-tmux-navigator' },
{ import = 'custom.plugins.telescope' },
{ import = 'custom.plugins.treesitter' },
}

View file

@ -1,3 +0,0 @@
return {
require 'custom.plugins.lsp.lsp',
}

View file

@ -1,91 +0,0 @@
-- ~/dlond/nvim/lua/custom/plugins/lsp.lua
-- LSP configuration, assuming LSP servers are installed via Nix/Home Manager
return {
{
'neovim/nvim-lspconfig',
-- only load when editing these filetypes (optional)
ft = {
'c',
'cpp',
'objc',
'objcpp',
'cuda',
'cmake',
--
'go',
'nix',
'python',
'rust',
'tex',
},
opts = function()
local lspconfig = require 'lspconfig'
local capabilities = {}
pcall(function()
capabilities = require('blink.cmp').get_lsp_capabilities()
end)
local util = require 'lspconfig.util'
local query_driver = table.concat({
'/nix/store/*/bin/clang*',
'/opt/homebrew/opt/llvm/bin/clang*',
'/usr/bin/clang*',
}, ';')
local servers = {
clangd = {
cmd = {
'clangd',
'--background-index',
'--clang-tidy',
'--header-insertion=never',
'--query-driver=' .. query_driver,
'--compile-commands-dir=build',
'--resource-dir=' .. (function()
local ok, result = pcall(vim.fn.systemlist, { 'clang++', '--print-resource-dir' })
if ok and result and result[1] then
return result[1]
else
return '/usr/lib/clang/19/include' -- fallback
end
end)(),
},
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
root_dir = util.root_pattern('CMakeLists.txt', '.git'),
single_file_support = true,
},
pyright = {
settings = {
python = {
analysis = {
autoSearchPaths = true,
diagnosticMode = 'openFilesOnly',
useLibraryCodeForTypes = true,
typeCheckingMode = 'basic',
},
},
},
positionEncoding = 'utf-8',
},
ruff = {},
nixd = {},
texlab = {},
cmake = {
cmd = { 'cmake-language-server' },
filetypes = { 'cmake' },
root_dir = util.root_pattern('CMakeLists.txt', '.git'),
},
}
for name, config in pairs(servers) do
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
lspconfig[name].setup(config)
end
end,
},
}

View file

@ -1,11 +0,0 @@
return {
{
'christoomey/vim-tmux-navigator',
config = function()
vim.keymap.set('n', '<C-h>', ':TmuxNavigateLeft<CR>', { desc = 'Navigate to left tmux pane' })
vim.keymap.set('n', '<C-j>', ':TmuxNavigateDown<CR>', { desc = 'Navigate to lower tmux pane' })
vim.keymap.set('n', '<C-k>', ':TmuxNavigateUp<CR>', { desc = 'Navigate to upper tmux pane' })
vim.keymap.set('n', '<C-l>', ':TmuxNavigateRight<CR>', { desc = 'Navigate to right tmux pane' })
end,
},
}

View file

@ -1,85 +0,0 @@
return {
-- ========================================
-- Telescope Override
-- ========================================
{
'nvim-telescope/telescope.nvim',
-- Ensure dependencies are loaded
dependencies = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
cond = function()
return vim.fn.executable 'make' == 1
end,
},
{ 'nvim-telescope/telescope-ui-select.nvim' },
},
opts = { -- Use opts to merge/override defaults
pickers = {
find_files = {
-- Use rg for finding files (ensure rg is installed via Nix/Home Manager)
find_command = { 'rg', '--files', '--hidden', '-g', '!.git' },
},
},
-- Configure extensions
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
},
-- Configuration for fzf-native extension
fzf = {
fuzzy = true, -- Enable fuzzy matching
override_generic_sorter = true, -- Override the generic sorter
override_file_sorter = true, -- Override the file sorter
case_mode = 'smart_case', -- Ignore case unless capitals are used
},
},
},
-- The config function ensures extensions are loaded after setup
config = function(_, opts)
require('telescope').setup(opts)
-- Load extensions after setup
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select')
-- *** ADD TELESCOPE KEYMAPS HERE ***
local builtin = require 'telescope.builtin'
-- Add the find_files keymap
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
-- Add other Telescope keymaps from kickstart's init.lua (uncomment to enable)
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
-- Fuzzy search in current buffer (corrected function body)
vim.keymap.set('n', '<leader>/', function()
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
-- Search in open files (corrected function body)
vim.keymap.set('n', '<leader>s/', function()
builtin.live_grep {
grep_open_files = true,
prompt_title = 'Live Grep in Open Files',
}
end, { desc = '[S]earch [/] in Open Files' })
-- Search Neovim files (corrected function body)
vim.keymap.set('n', '<leader>sn', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' })
end,
},
}

View file

@ -1,52 +0,0 @@
return {
-- ========================================
-- Treesitter Configuration Override
-- ========================================
{
'nvim-treesitter/nvim-treesitter',
-- build = ':TSUpdate', -- Keep build command if needed from kickstart
-- main = 'nvim-treesitter.configs', -- Keep if needed from kickstart
event = { 'BufReadPost', 'BufNewFile' },
build = ':TSUpdate',
opts = { -- Use opts to merge/override defaults
ensure_installed = {
'bash',
'c',
'cmake',
'cpp',
'diff',
'html',
'lua',
'luadoc',
'make',
'markdown',
'markdown_inline',
'nix',
'python',
'query',
'vim',
'vimdoc',
'yaml',
},
auto_install = true,
-- Keep other kickstart defaults like highlight/indent settings unless you want to change them
highlight = {
enable = true,
-- additional_vim_regex_highlighting = { 'ruby' }, -- Keep if needed
},
indent = {
enable = true,
-- disable = { 'ruby' }, -- Keep if needed
},
},
config = function(_, opts)
require('nvim-treesitter.configs').setup(opts)
end,
-- If kickstart used a config function for treesitter and you need to replicate
-- parts of it that aren't handled by opts, add it here.
-- config = function(_, opts)
-- require('nvim-treesitter.configs').setup(opts)
-- end,
},
}

View file

@ -1,69 +0,0 @@
-- local async = require 'plenary.async'
-- local pickers = require 'telescope.pickers'
-- local finders = require 'telescope.finders'
-- local sorters = require('telescope.config').values
-- local actions = require 'telescope.actions'
-- local action_state = require 'telescope.actions.state'
--
-- local function collect_executables(start_dir)
-- local results = {}
--
-- -- Add '.', start_dir so it works with your fd version
-- local fd = vim.fn.systemlist {
-- 'fd',
-- '.',
-- start_dir,
-- '--exec',
-- 'file',
-- '{}',
-- }
--
-- for _, line in ipairs(fd) do
-- local path, typeinfo = line:match '^(.-):%s*(.+)$'
-- if path and not path:match 'CMakeFiles' and typeinfo and (typeinfo:match 'Mach%-O' or typeinfo:match 'ELF') then
-- table.insert(results, path)
-- end
-- end
--
-- return results
-- end
--
-- local function pick_executable(start_dir)
-- return async.wrap(function(_start_dir, on_choice)
-- local executables = collect_executables(_start_dir)
--
-- if #executables == 0 then
-- vim.notify('No executables found in ' .. _start_dir, vim.log.levels.WARN)
-- on_choice(nil)
-- return
-- end
--
-- pickers
-- .new({}, {
-- prompt_title = 'Select Executable',
-- finder = finders.new_table { results = executables },
-- sorter = sorters.generic_sorter {},
-- attach_mappings = function(_, map)
-- actions.select_default:replace(function(prompt_bufnr)
-- local entry = action_state.get_selected_entry()
-- actions.close(prompt_bufnr)
-- on_choice(entry.value)
-- end)
-- map('i', '<Esc>', function(bufnr)
-- actions.close(bufnr)
-- on_choice(nil)
-- end)
-- map('n', 'q', function(bufnr)
-- actions.close(bufnr)
-- on_choice(nil)
-- end)
-- return true
-- end,
-- })
-- :find()
-- end, 2)(start_dir)
-- end
--
-- return {
-- pick_executable = pick_executable,
-- }