try watch compile_config

This commit is contained in:
dlond 2025-05-30 04:48:00 +12:00
parent 381206c8f2
commit 386cb4d2ff
1 changed files with 3 additions and 2 deletions

View File

@ -95,6 +95,7 @@ function M.watch_compile_commands(dir)
end end
watcher:start(watch_path, { recursive = true }, function(err, fname, status) watcher:start(watch_path, { recursive = true }, function(err, fname, status)
print('[clangd] Watcher triggered: ', fname, vim.inspect(status))
if err then if err then
vim.schedule(function() vim.schedule(function()
vim.notify('[clangd] Watcher error: ' .. err, vim.log.levels.ERROR) vim.notify('[clangd] Watcher error: ' .. err, vim.log.levels.ERROR)
@ -110,8 +111,8 @@ function M.watch_compile_commands(dir)
debounce_timer:start(200, 0, function() debounce_timer:start(200, 0, function()
vim.schedule(function() vim.schedule(function()
vim.notify '[clangd] Detected compile_commands.json change. Reloading ...' vim.notify '[clangd] Detected compile_commands.json change. Reloading ...'
-- M.start_clangd(watch_path) watcher:stop()
M.reload_clangd() M.start_clangd(vim.fn.fnamemodify(fname, ':h')
end) end)
end) end)
end end