1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-09 08:40:04 +08:00

chore(format): format code

This commit is contained in:
Eric Wong 2024-04-16 11:30:52 +08:00
parent 1d8dbeb8bb
commit d393df8ada

View File

@ -10,8 +10,6 @@ local M = {}
local uv = vim.loop
local logger = require('spacevim.logger').derive('job')
local _jobs = {}
local _jobid = 0
@ -46,28 +44,28 @@ local function new_job_obj(id, handle, opt, state)
end
local function default_dev() -- {{{
local env = vim.fn.environ()
env['NVIM'] = vim.v.servername
env['NVIM_LISTEN_ADDRESS'] = nil
env['NVIM_LOG_FILE'] = nil
env['VIMRUNTIME'] = nil
return env
local env = vim.fn.environ()
env['NVIM'] = vim.v.servername
env['NVIM_LISTEN_ADDRESS'] = nil
env['NVIM_LOG_FILE'] = nil
env['VIMRUNTIME'] = nil
return env
end
-- }}}
local function setup_env(env, clear_env) -- {{{
if clear_env then
if clear_env then
return env
end
--- @type table<string,string|number>
env = vim.tbl_extend('force', default_dev(), env or {})
end
--- @type table<string,string|number>
env = vim.tbl_extend('force', default_dev(), env or {})
local renv = {} --- @type string[]
for k, v in pairs(env) do
local renv = {} --- @type string[]
for k, v in pairs(env) do
renv[#renv + 1] = string.format('%s=%s', k, tostring(v))
end
end
return renv
return renv
end
-- }}}
@ -207,27 +205,27 @@ function M.start(cmd, opts)
end
function M.send(id, data) -- {{{
local jobobj = _jobs['jobid_' .. id]
local jobobj = _jobs['jobid_' .. id]
if not jobobj then
if not jobobj then
error('can not find job:' .. id)
end
end
local stdin = jobobj.state.stdin
local stdin = jobobj.state.stdin
if not stdin then
if not stdin then
error('no stdin stream for jobid:' .. id)
end
end
if type(data) == 'table' then
if type(data) == 'table' then
for _, v in ipairs(data) do
stdin:write(v)
stdin:write('\n')
end
elseif type(data) == 'string' then
elseif type(data) == 'string' then
stdin:write(data)
stdin:write('\n')
elseif data == nil then
elseif data == nil then
stdin:write('', function()
stdin:shutdown(function()
if stdin then
@ -235,7 +233,7 @@ elseif data == nil then
end
end)
end)
end
end
end
function M.chanclose(id, t)
@ -250,7 +248,6 @@ function M.chanclose(id, t)
if stdin and stdin:is_active() then
stdin:close()
end
elseif t == 'stdout' then
elseif t == 'stderr' then
else
@ -268,5 +265,4 @@ function M.stop(id)
local handle = jobobj.handle
handle:kill(6)
end
return M