From 4c6d17824cdd85edb080362f317f9002b163845b Mon Sep 17 00:00:00 2001 From: dlond Date: Fri, 30 May 2025 02:14:17 +1200 Subject: [PATCH] debugging watcher --- lua/custom/plugins/lsp/clangd.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lua/custom/plugins/lsp/clangd.lua b/lua/custom/plugins/lsp/clangd.lua index c1f8b038..7ceb8901 100644 --- a/lua/custom/plugins/lsp/clangd.lua +++ b/lua/custom/plugins/lsp/clangd.lua @@ -107,14 +107,19 @@ return { 'neovim/nvim-lspconfig', ft = M.clang_filetypes, config = function() - local dir = find_compile_commands() - 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 + vim.api.nvim_create_autocmd('FileType', { + pattern = M.clang_filetypes, + callback = function() + local dir = find_compile_commands() + 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 + end, + }) vim.keymap.set('n', 'cc', M.pick_commands_dir, { desc = 'Pick location of compile_commands.json for clangd' }) end,