try watch compile_config

This commit is contained in:
dlond 2025-05-30 04:33:51 +12:00
parent b2038d3788
commit 381206c8f2
1 changed files with 16 additions and 6 deletions

View File

@ -124,6 +124,12 @@ return {
'neovim/nvim-lspconfig',
ft = M.clang_filetypes,
config = function()
vim.api.nvim_create_autocmd('BufReadPost', {
group = vim.api.nvim_create_augroup('clangd-lazy-init', { clear = true }),
pattern = '*',
callback = function(args)
local ft = vim.bo[args.buf].filetype
if vim.tbl_contains(M.clang_filetypes, ft) then
local dir = find_compile_commands()
M.start_clangd(dir)
if dir ~= '' then
@ -131,5 +137,9 @@ return {
end
vim.keymap.set('n', '<leader>cc', M.pick_commands_dir, { desc = 'Pick location of compile_commands.json for clangd' })
vim.api.nvim_clear_autocmds { group = 'clangd-lazy-init' }
end
end,
})
end,
}