diff --git a/lua/plugins/config/compile-commands-picker.lua b/lua/plugins/config/compile-commands-picker.lua index bc7c5c86..cabe87c1 100644 --- a/lua/plugins/config/compile-commands-picker.lua +++ b/lua/plugins/config/compile-commands-picker.lua @@ -90,7 +90,14 @@ CompileFlags: local clients = vim.lsp.get_active_clients({ name = 'clangd' }) if #clients > 0 then vim.notify('Restarting clangd...', vim.log.levels.INFO) - vim.cmd('LspRestart clangd') + -- Stop and start clangd to pick up new config + for _, client in ipairs(clients) do + client.stop() + end + vim.defer_fn(function() + vim.cmd('LspStart clangd') + vim.notify('Clangd restarted with new configuration', vim.log.levels.INFO) + end, 100) end else vim.notify('Failed to create .clangd file', vim.log.levels.ERROR) diff --git a/lua/plugins/config/lsp/init.lua b/lua/plugins/config/lsp/init.lua index fab3e1d8..930dd4a4 100644 --- a/lua/plugins/config/lsp/init.lua +++ b/lua/plugins/config/lsp/init.lua @@ -21,9 +21,6 @@ function M.setup() -- Setup LSP keymaps require('plugins.config.lsp.keymaps').setup() - - -- Setup compile_commands.json picker for C/C++ projects - require('plugins.config.compile-commands-picker').setup() end return M \ No newline at end of file diff --git a/lua/plugins/spec/telescope.lua b/lua/plugins/spec/telescope.lua index 383c5e84..e6759e6d 100644 --- a/lua/plugins/spec/telescope.lua +++ b/lua/plugins/spec/telescope.lua @@ -17,5 +17,7 @@ return { }, config = function() require('plugins.config.telescope').setup() + -- Setup compile_commands.json picker for C/C++ projects + require('plugins.config.compile-commands-picker').setup() end, } \ No newline at end of file