From 8c2846693728d6b87c8d3b09fa0e8ab494d7d4b7 Mon Sep 17 00:00:00 2001 From: dlond Date: Fri, 30 May 2025 01:50:13 +1200 Subject: [PATCH] debugging watcher --- lua/custom/plugins/lsp/clangd.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/custom/plugins/lsp/clangd.lua b/lua/custom/plugins/lsp/clangd.lua index 52d3cf55..9a014a21 100644 --- a/lua/custom/plugins/lsp/clangd.lua +++ b/lua/custom/plugins/lsp/clangd.lua @@ -7,10 +7,16 @@ local watcher local function find_compile_commands() local lines = vim.fn.systemlist { 'fd', '-u', '-t', 'f', 'compile_commands.json' } + + if vim.tbl_isempty(lines) then + return nil + end + table.sort(lines, function(a, b) return a:match 'debug' and not b:match 'debug' end) - return vim.fn.fnamemodify(lines[1] or '', ':h') + + return vim.fn.fnamemodify(lines[1], ':h') end function M.stop_clangd() @@ -102,10 +108,11 @@ return { ft = M.clang_filetypes, config = function() local dir = find_compile_commands() - vim.notify('[clangd] Found compile_commands at: ' .. dir) - if dir ~= '' then + if dir then + vim.notify('[clangd] Found compile_commands at: ' .. dir) M.setup_clangd(dir) else + vim.notify '[clangd] No compile_commands found, watching ...' M.watch_compile_commands() end