|
|
|
|
@@ -26,15 +26,22 @@ function build.set_dir(dirname)
|
|
|
|
|
|
|
|
|
|
build.dir = build_dir
|
|
|
|
|
|
|
|
|
|
-- Invoke async function to avoid blocking the UI
|
|
|
|
|
vim.schedule(function()
|
|
|
|
|
echo('Processing compile_commands.json with compdb ...', 'DiagnosticInfo')
|
|
|
|
|
|
|
|
|
|
-- Post-process compile_commands.json with compdb
|
|
|
|
|
local compile_commands = current_dir .. '/compile_commands.json'
|
|
|
|
|
local output = vim.fn.systemlist(
|
|
|
|
|
'compdb -p ' .. build.dir .. ' list > ' .. compile_commands)
|
|
|
|
|
-- Post-process compile_commands.json with compdb as an async job to avoid
|
|
|
|
|
-- blocking the user interface
|
|
|
|
|
vim.fn.jobstart(
|
|
|
|
|
'compdb -p ' .. build.dir .. ' list > ' .. compile_commands, {
|
|
|
|
|
|
|
|
|
|
-- Restart clangd language server
|
|
|
|
|
-- TODO: Configure cmake language server?
|
|
|
|
|
on_exit = function()
|
|
|
|
|
vim.cmd [[ LspRestart clangd ]]
|
|
|
|
|
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
-- Display any error messages to the user
|
|
|
|
|
on_stderr = function(_, output, _)
|
|
|
|
|
-- Remove any lines containing a compdb warning
|
|
|
|
|
local error = {}
|
|
|
|
|
local warning = 'WARNING:compdb'
|
|
|
|
|
@@ -49,14 +56,11 @@ function build.set_dir(dirname)
|
|
|
|
|
echo(vim.fn.join(error, '\n'), 'Error')
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
-- TODO: Configure cmake language server?
|
|
|
|
|
|
|
|
|
|
-- Restart clangd language server
|
|
|
|
|
vim.cmd [[ LspRestart clangd ]]
|
|
|
|
|
|
|
|
|
|
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
|
|
|
|
|
end)
|
|
|
|
|
stderr_buffered = true,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function build.select_dir(callback)
|
|
|
|
|
|