Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

feat: add more luv methods and types #122

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions types/override/luv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,37 @@
vim.loop = {}

---@class vim.loop.Timer
---@field start fun(timer:vim.loop.Timer, timeout:integer, repeat:integer, callback:fun())
---@field stop fun(timer:vim.loop.Timer)
---@field start fun(timer: vim.loop.Timer, timeout: integer, repeat: integer, callback: fun())
---@field stop fun(timer: vim.loop.Timer)

---@class vim.loop.Handle
local Handle = {}
function Handle:close() end
---@return boolean
function Handle:is_closing() end
---@return boolean
function Handle:is_active() end
---@field close fun(handle: vim.loop.Handle)
---@field is_closing fun(handle: vim.loop.Handle): boolean
---@field is_active fun(handle: vim.loop.Handle): boolean

---@class vim.loop.Pipe: vim.loop.Handle
---@class vim.loop.Stream: vim.loop.Handle
---@field shutdown fun(stream: vim.loop.Stream, callback?: fun()): boolean
---@field read_start fun(stream: vim.loop.Stream, callback? fun(err: string?, chunk: string): 0|'fail'
---@field read_stop fun(stream: vim.loop.Stream): 0|'fail'
---@field write fun(stream: vim.loop.Stream, data: string, callback?: function)
---@field try_write fun(stream: vim.loop.Stream, data: string)

---@class vim.loop.Check
local Check = {}
---@param fn fun()
function Check:start(fn) end
function Check:stop() end
---@class vim.loop.Pipe: vim.loop.Stream

---@class vim.loop.Prepare: vim.loop.Handle
---@field start fun(prepare: vim.loop.Prepare, callback: function): 0|'fail'
---@field stop fun(prepare: vim.loop.Prepare): 0|'fail'

---@class vim.loop.Check: vim.loop.Handle
---@field start fun(check: vim.loop.Check, callback: function): 0|'fail'
---@field stop fun(check: vim.loop.Check): 0|'fail'

---@class vim.loop.Process: vim.loop.Handle
---@field kill fun(process: vim.loop.Process, signum: integer|string): 0|'fail'
---@field get_pid fun(process: vim.loop.Process): integer

---@class vim.loop.TCP: vim.loop.Stream
---@field connect fun(tcp: vim.loop.TCP, host: string, port: integer, callback?: fun(err?: string))

return {
["vim.loop.new_timer"] = {
Expand All @@ -34,11 +45,21 @@ return {
["type"] = "vim.loop.Pipe",
} },
},
["vim.loop.new_prepare"] = {
["return"] = { {
["type"] = "vim.loop.Prepare",
} },
},
["vim.loop.new_check"] = {
["return"] = { {
["type"] = "vim.loop.Check",
} },
},
["vim.loop.new_tcp"] = {
["return"] = { {
["type"] = "vim.loop.TCP",
} },
},
["vim.loop.spawn"] = {
["return"] = { {
["type"] = "vim.loop.Process",
Expand Down