1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-14 02:35:41 +08:00

refactor(format): refactor on_exit function

This commit is contained in:
Eric Wong 2024-04-16 14:35:15 +08:00
parent 17a380aed9
commit c9fd7f91c7

View File

@ -31,15 +31,12 @@ local function on_exit(id, code, single)
.. single
)
if code == 0 and single == 0 then
local formatted_context
if current_task.formatter.use_stderr then
vim.api.nvim_buf_set_lines(
current_task.bufnr,
current_task.start_line,
current_task.end_line,
false,
stderr
)
formatted_context = stderr
else
formatted_context = stdout
end
if table.concat(stdout, '\n') == table.concat(current_task.stdin, '\n') then
util.msg('no necessary changes')
else
@ -49,10 +46,9 @@ local function on_exit(id, code, single)
current_task.start_line,
current_task.end_line,
false,
stdout
formatted_context
)
end
end
else
util.msg('formatter ' .. current_task.formatter.exe .. ' failed to run')
end