Compare commits
No commits in common. "65fdc27a8ef92e33c873feead2ebb60f1d56a4b8" and "239f8a47692f45c2ff7b98639057da641562482e" have entirely different histories.
65fdc27a8e
...
239f8a4769
2 changed files with 3 additions and 54 deletions
|
|
@ -143,47 +143,12 @@ function M.compile(bufnr, name, provider, ctx, opts)
|
||||||
table.concat(reload_cmd, ' ')
|
table.concat(reload_cmd, ' ')
|
||||||
)
|
)
|
||||||
|
|
||||||
local stderr_acc = {}
|
|
||||||
local obj
|
local obj
|
||||||
obj = vim.system(
|
obj = vim.system(
|
||||||
reload_cmd,
|
reload_cmd,
|
||||||
{
|
{
|
||||||
cwd = cwd,
|
cwd = cwd,
|
||||||
env = provider.env,
|
env = provider.env,
|
||||||
stderr = vim.schedule_wrap(function(err, data)
|
|
||||||
if not data or not vim.api.nvim_buf_is_valid(bufnr) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
stderr_acc[#stderr_acc + 1] = data
|
|
||||||
local errors_mode = provider.errors
|
|
||||||
if errors_mode == nil then
|
|
||||||
errors_mode = 'diagnostic'
|
|
||||||
end
|
|
||||||
if provider.error_parser and errors_mode then
|
|
||||||
local output = table.concat(stderr_acc)
|
|
||||||
if errors_mode == 'diagnostic' then
|
|
||||||
diagnostic.set(bufnr, name, provider.error_parser, output, ctx)
|
|
||||||
elseif errors_mode == 'quickfix' then
|
|
||||||
local ok, diags = pcall(provider.error_parser, output, ctx)
|
|
||||||
if ok and diags and #diags > 0 then
|
|
||||||
local items = {}
|
|
||||||
for _, d in ipairs(diags) do
|
|
||||||
table.insert(items, {
|
|
||||||
bufnr = bufnr,
|
|
||||||
lnum = d.lnum + 1,
|
|
||||||
col = d.col + 1,
|
|
||||||
text = d.message,
|
|
||||||
type = d.severity == vim.diagnostic.severity.WARN and 'W' or 'E',
|
|
||||||
})
|
|
||||||
end
|
|
||||||
vim.fn.setqflist(items, 'r')
|
|
||||||
local win = vim.fn.win_getid()
|
|
||||||
vim.cmd.cwindow()
|
|
||||||
vim.fn.win_gotoid(win)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end),
|
|
||||||
},
|
},
|
||||||
vim.schedule_wrap(function(result)
|
vim.schedule_wrap(function(result)
|
||||||
if active[bufnr] and active[bufnr].obj == obj then
|
if active[bufnr] and active[bufnr].obj == obj then
|
||||||
|
|
@ -217,9 +182,7 @@ function M.compile(bufnr, name, provider, ctx, opts)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
vim.fn.setqflist(items, 'r')
|
vim.fn.setqflist(items, 'r')
|
||||||
local win = vim.fn.win_getid()
|
vim.cmd('copen')
|
||||||
vim.cmd.cwindow()
|
|
||||||
vim.fn.win_gotoid(win)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -265,17 +228,6 @@ function M.compile(bufnr, name, provider, ctx, opts)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
stop_open_watcher(bufnr)
|
stop_open_watcher(bufnr)
|
||||||
stderr_acc = {}
|
|
||||||
local errors_mode = provider.errors
|
|
||||||
if errors_mode == nil then
|
|
||||||
errors_mode = 'diagnostic'
|
|
||||||
end
|
|
||||||
if errors_mode == 'diagnostic' then
|
|
||||||
diagnostic.clear(bufnr)
|
|
||||||
elseif errors_mode == 'quickfix' then
|
|
||||||
vim.fn.setqflist({}, 'r')
|
|
||||||
vim.cmd.cwindow()
|
|
||||||
end
|
|
||||||
do_open(bufnr, output_file, provider.open)
|
do_open(bufnr, output_file, provider.open)
|
||||||
opened[bufnr] = true
|
opened[bufnr] = true
|
||||||
end)
|
end)
|
||||||
|
|
@ -336,7 +288,6 @@ function M.compile(bufnr, name, provider, ctx, opts)
|
||||||
diagnostic.clear(bufnr)
|
diagnostic.clear(bufnr)
|
||||||
elseif errors_mode == 'quickfix' then
|
elseif errors_mode == 'quickfix' then
|
||||||
vim.fn.setqflist({}, 'r')
|
vim.fn.setqflist({}, 'r')
|
||||||
vim.cmd.cwindow()
|
|
||||||
end
|
end
|
||||||
vim.api.nvim_exec_autocmds('User', {
|
vim.api.nvim_exec_autocmds('User', {
|
||||||
pattern = 'PreviewCompileSuccess',
|
pattern = 'PreviewCompileSuccess',
|
||||||
|
|
@ -378,9 +329,7 @@ function M.compile(bufnr, name, provider, ctx, opts)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
vim.fn.setqflist(items, 'r')
|
vim.fn.setqflist(items, 'r')
|
||||||
local win = vim.fn.win_getid()
|
vim.cmd('copen')
|
||||||
vim.cmd.cwindow()
|
|
||||||
vim.fn.win_gotoid(win)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ M.typst = {
|
||||||
end,
|
end,
|
||||||
open = true,
|
open = true,
|
||||||
reload = function(ctx)
|
reload = function(ctx)
|
||||||
return { 'typst', 'watch', '--diagnostic-format', 'short', ctx.file }
|
return { 'typst', 'watch', ctx.file }
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue