Compare commits

..

No commits in common. "15d38795258b34c8864a65790eee4e63b309b1cd" and "d774c2867f5861e7c06f653937d42f438ad779e3" have entirely different histories.

2 changed files with 31 additions and 31 deletions

View File

@ -26,41 +26,37 @@ function build.set_dir(dirname)
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, {
-- Invoke async function to avoid blocking the UI
vim.schedule(function()
echo('Processing compile_commands.json with compdb ...', 'DiagnosticInfo')
-- Restart clangd language server
-- TODO: Configure cmake language server?
on_exit = function()
vim.cmd [[ LspRestart clangd ]]
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
end,
-- 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)
-- 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
-- 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,
-- Display the error message if there was one
if table.maxn(error) > 0 then
echo(vim.fn.join(error, '\n'), 'Error')
return
end
stderr_buffered = true,
}
)
-- TODO: Configure cmake language server?
-- Restart clangd language server
vim.cmd [[ LspRestart clangd ]]
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
end)
end
function build.select_dir(callback)

View File

@ -43,3 +43,7 @@ vim.keymap.set('n', 'Q', '<nop>', {noremap = true})
-- Undo neovim's default mapping of Y to y$
vim.cmd('unmap Y')
-- Move visually selected blocks around
vim.keymap.set('v', 'J', ":move '>+1<CR>gv=gv'")
vim.keymap.set('v', 'K', ":move '<-2<CR>gv=gv'")