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

Commit

Permalink
feat: add more luv methods and types (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Feb 10, 2023
1 parent bb70e41 commit fc01efe
Showing 1 changed file with 35 additions and 14 deletions.
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

0 comments on commit fc01efe

Please sign in to comment.