forked from CopilotC-Nvim/CopilotChat.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.lua
More file actions
54 lines (48 loc) · 976 Bytes
/
Copy pathutils.lua
File metadata and controls
54 lines (48 loc) · 976 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
50
51
52
53
54
local log = require('plenary.log')
local M = {}
--- Create class
---@param fn function The class constructor
---@return table
function M.class(fn)
local out = {}
out.__index = out
setmetatable(out, {
__call = function(cls, ...)
return cls.new(...)
end,
})
function out.new(...)
local self = setmetatable({}, out)
fn(self, ...)
return self
end
return out
end
--- Get the log file path
---@return string
function M.get_log_file_path()
return log.logfile
end
--- Check if the current version of neovim is stable
---@return boolean
function M.is_stable()
return vim.fn.has('nvim-0.10.0') == 0
end
--- Join multiple async functions
function M.join(on_done, fns)
local count = #fns
local results = {}
local function done()
count = count - 1
if count == 0 then
on_done(results)
end
end
for i, fn in ipairs(fns) do
fn(function(result)
results[i] = result
done()
end)
end
end
return M