debugging watcher
This commit is contained in:
parent
bb078e642e
commit
8c28466937
|
@ -7,10 +7,16 @@ 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' }
|
||||||
|
|
||||||
|
if vim.tbl_isempty(lines) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
table.sort(lines, function(a, b)
|
table.sort(lines, function(a, b)
|
||||||
return a:match 'debug' and not b:match 'debug'
|
return a:match 'debug' and not b:match 'debug'
|
||||||
end)
|
end)
|
||||||
return vim.fn.fnamemodify(lines[1] or '', ':h')
|
|
||||||
|
return vim.fn.fnamemodify(lines[1], ':h')
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.stop_clangd()
|
function M.stop_clangd()
|
||||||
|
@ -102,10 +108,11 @@ return {
|
||||||
ft = M.clang_filetypes,
|
ft = M.clang_filetypes,
|
||||||
config = function()
|
config = function()
|
||||||
local dir = find_compile_commands()
|
local dir = find_compile_commands()
|
||||||
|
if dir then
|
||||||
vim.notify('[clangd] Found compile_commands at: ' .. dir)
|
vim.notify('[clangd] Found compile_commands at: ' .. dir)
|
||||||
if dir ~= '' then
|
|
||||||
M.setup_clangd(dir)
|
M.setup_clangd(dir)
|
||||||
else
|
else
|
||||||
|
vim.notify '[clangd] No compile_commands found, watching ...'
|
||||||
M.watch_compile_commands()
|
M.watch_compile_commands()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue