Skip to content

Commit

Permalink
fix: provide a class for vim.api (#117)
Browse files Browse the repository at this point in the history
* fix: provide a class for vim.api

This works around a false-error in sumneko where it cannot determine the
type of:

 local a = vim.api  -- cannot infer type of a

By defining an explicit class for vim.api we avoid this error.

* fix: provide a class for vim.loop
  • Loading branch information
lewis6991 committed Feb 6, 2023
1 parent 70cab52 commit 9737bfc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions types/nightly/api.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
---@meta

-- This works around a false-error in sumneko where it cannot determine the
-- type of:
--
-- local a = vim.api -- cannot infer type of a
--
-- By defining an explicit class for vim.api we avoid this error.

---@class vim.api
local api = vim.api
vim.api = api


--- @param buffer buffer
--- @param first number
--- @param last number
Expand Down
4 changes: 4 additions & 0 deletions types/nightly/luv.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---@meta

---@class vim.loop
local luv = vim.loop
vim.loop = luv

---@class vim.loop.Timer
---@field start fun(timer:vim.loop.Timer, timeout:integer, repeat:integer, callback:fun())
---@field stop fun(timer:vim.loop.Timer)
Expand Down
10 changes: 10 additions & 0 deletions types/override/api.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- This works around a false-error in sumneko where it cannot determine the
-- type of:
--
-- local a = vim.api -- cannot infer type of a
--
-- By defining an explicit class for vim.api we avoid this error.

---@class vim.api
local api = vim.api
vim.api = api
4 changes: 4 additions & 0 deletions types/override/luv.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---@class vim.loop
local luv = vim.loop
vim.loop = luv

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

0 comments on commit 9737bfc

Please sign in to comment.