Don't use compdb on Windows since its borked
This commit is contained in:
parent
2cd7d34375
commit
0434fc3ac2
@ -21,45 +21,58 @@ function build.set_dir(dirname)
|
||||
end
|
||||
|
||||
build.dir = build_dir
|
||||
|
||||
echo('Processing compile_commands.json with compdb ...', 'DiagnosticInfo')
|
||||
local compile_commands = current_dir .. '/compile_commands.json'
|
||||
-- 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
|
||||
on_exit = function()
|
||||
if vim.fn.executable('compdb') == 1 then
|
||||
echo('Processing compile_commands.json with compdb ...', 'DiagnosticInfo')
|
||||
-- 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
|
||||
on_exit = function()
|
||||
-- This is a callback so doesn't run on the main thread which causes
|
||||
-- issues for running commands, so schedule that on the main thread.
|
||||
vim.schedule(function()
|
||||
vim.cmd('LspRestart')
|
||||
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
|
||||
end)
|
||||
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'
|
||||
for _, line in ipairs(output) do
|
||||
if string.sub(line, 1, #warning) ~= warning then
|
||||
table.insert(error, line)
|
||||
end
|
||||
end
|
||||
|
||||
-- Display the error message if there was one
|
||||
if table.maxn(error) > 0 then
|
||||
echo(vim.fn.join(error, '\n'), 'Error')
|
||||
return
|
||||
end
|
||||
end,
|
||||
|
||||
stderr_buffered = true,
|
||||
}
|
||||
)
|
||||
else
|
||||
vim.uv.fs_copyfile(build_dir .. '/compile_commands.json', compile_commands, nil,
|
||||
function()
|
||||
-- This is a callback so doesn't run on the main thread which causes
|
||||
-- issues for running commands, so schedule that on the main thread.
|
||||
vim.schedule(function()
|
||||
vim.cmd('LspRestart')
|
||||
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
|
||||
end)
|
||||
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'
|
||||
for _, line in ipairs(output) do
|
||||
if string.sub(line, 1, #warning) ~= warning then
|
||||
table.insert(error, line)
|
||||
end
|
||||
end
|
||||
|
||||
-- Display the error message if there was one
|
||||
if table.maxn(error) > 0 then
|
||||
echo(vim.fn.join(error, '\n'), 'Error')
|
||||
return
|
||||
end
|
||||
end,
|
||||
|
||||
stderr_buffered = true,
|
||||
}
|
||||
)
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function build.select_dir(callback)
|
||||
|
Loading…
x
Reference in New Issue
Block a user