debugging watcher

This commit is contained in:
dlond 2025-05-30 01:42:30 +12:00
parent fd43193eee
commit bb078e642e
1 changed files with 4 additions and 2 deletions

View File

@ -3,7 +3,7 @@ local M = {}
M.clang_filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' } M.clang_filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' }
local lspconfig = require 'lspconfig' local lspconfig = require 'lspconfig'
local watcher = nil local watcher
local function find_compile_commands() local function find_compile_commands()
local lines = vim.fn.systemlist { 'fd', '-u', '-t', 'f', 'compile_commands.json' } local lines = vim.fn.systemlist { 'fd', '-u', '-t', 'f', 'compile_commands.json' }
@ -17,6 +17,7 @@ function M.stop_clangd()
for _, client in ipairs(vim.lsp.get_clients()) do for _, client in ipairs(vim.lsp.get_clients()) do
if client.name == 'clangd' then if client.name == 'clangd' then
client.stop { force = true } client.stop { force = true }
vim.notify '[clangd] stopped clangd'
end end
end end
end end
@ -77,11 +78,11 @@ function M.watch_compile_commands()
return return
end end
vim.notify('clangd: Starting watcher for compile_commands.json', vim.log.levels.INFO)
local uv = vim.uv or vim.loop local uv = vim.uv or vim.loop
watcher = uv.new_fs_event() watcher = uv.new_fs_event()
local cwd = vim.fn.getcwd() local cwd = vim.fn.getcwd()
vim.notify('clangd: Watching for compile_commands.json in ' .. cwd, vim.log.levels.INFO)
watcher:start( watcher:start(
cwd, cwd,
{ recursive = true }, { recursive = true },
@ -101,6 +102,7 @@ return {
ft = M.clang_filetypes, ft = M.clang_filetypes,
config = function() config = function()
local dir = find_compile_commands() local dir = find_compile_commands()
vim.notify('[clangd] Found compile_commands at: ' .. dir)
if dir ~= '' then if dir ~= '' then
M.setup_clangd(dir) M.setup_clangd(dir)
else else