-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathutils.lua
More file actions
49 lines (44 loc) · 1011 Bytes
/
utils.lua
File metadata and controls
49 lines (44 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
local M = {}
M.get_client_channel = function()
for _, chan in ipairs(vim.api.nvim_list_chans()) do
if chan.client and chan.client.name == "github-preview" then
return chan.id
end
end
return nil
end
---@param log_level string
M.log_exit = function(log_level)
if not log_level then
return
end
return function(job_id, exit_code)
vim.print("++++++++++++++++")
vim.print("job# " .. job_id .. ":")
vim.print("exit_code: " .. exit_code)
end
end
---@param log_level string
M.log_job = function(log_level)
-- https://neovim.io/doc/user/channel.html#channel-bytes
if not log_level then
return
end
local lines = { "" }
return function(job_id, data)
local eof = #data > 0 and data[#data] == ""
lines[#lines] = lines[#lines] .. data[1]
for i = 2, #data do
table.insert(lines, data[i])
end
if eof then
vim.print("----------------")
vim.print("job# " .. job_id .. ":")
for _, line in ipairs(lines) do
vim.print(line)
end
lines = { "" }
end
end
end
return M