Skip to content

Commit e7f393f

Browse files
authored
fix(typecheck): use type definitions from nvim runtime instead (#1358)
* fix(typecheck): use type definitions from nvim runtime instead * fix(typecheck): add neodev for stable API * fix(typecheck): workaround couple of edge cases
1 parent c1d36ad commit e7f393f

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

.github/workflows/.luarc.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"lua/?/init.lua"
77
],
88
"Lua.workspace.library": [
9+
"/home/runner/work/neorg/neorg/deps/neovim/runtime/lua",
910
"/home/runner/work/neorg/neorg/deps/neodev.nvim/types/stable"
1011
],
1112
"Lua.diagnostics.libraryFiles": "Disable",

.github/workflows/typecheck.yml

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ jobs:
2020
repository: "folke/neodev.nvim"
2121
path: "deps/neodev.nvim"
2222

23+
- name: Checkout neovim for type annotations
24+
uses: actions/checkout@v3
25+
with:
26+
repository: "neovim/neovim"
27+
path: "deps/neovim"
28+
2329
- name: Type Check Code Base
2430
uses: mrcjkb/[email protected]
2531
with:

lua/neorg/core/utils.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ function utils.get_language_shorthands(reverse_lookup)
105105
["yaml"] = { "yml" },
106106
}
107107

108-
return reverse_lookup and vim.tbl_add_reverse_lookup(langs) or langs
108+
-- TODO: `vim.tbl_add_reverse_lookup` deprecated: NO ALTERNATIVES
109+
-- GOOD JOB CORE DEVS
110+
-- <https://github.com/neovim/neovim/pull/27639>
111+
return reverse_lookup and vim.tbl_add_reverse_lookup(langs) or langs ---@diagnostic disable-line
109112
end
110113

111114
--- Checks whether Neovim is running at least at a specific version.

lua/neorg/modules/core/integrations/treesitter/module.lua

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ module.public = {
232232
-- Do we need to go through each tree? lol
233233
vim.treesitter.get_parser(opts.buf, opts.ft):for_each_tree(function(tree)
234234
-- Get the root for that tree
235+
---@type TSNode
235236
local root = tree:root()
236237

237238
--- Recursively searches for a node of a given type

lua/neorg/modules/core/tempus/module.lua

+10-17
Original file line numberDiff line numberDiff line change
@@ -222,23 +222,16 @@ module.public = {
222222
---@param parsed_date Date #The date to convert
223223
---@return osdate #A Lua date
224224
to_lua_date = function(parsed_date)
225-
return os.date( ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
226-
"*t",
227-
os.time(
228-
vim.tbl_deep_extend(
229-
"force",
230-
os.date("*t"),
231-
{ ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
232-
day = parsed_date.day,
233-
month = parsed_date.month and parsed_date.month.number or nil,
234-
year = parsed_date.year,
235-
hour = parsed_date.time and parsed_date.time.hour,
236-
min = parsed_date.time and parsed_date.time.minute,
237-
sec = parsed_date.time and parsed_date.time.second,
238-
}
239-
)
240-
)
241-
)
225+
local now = os.date("*t") --[[@as osdate]]
226+
local parsed = os.time(vim.tbl_deep_extend("force", now, {
227+
day = parsed_date.day,
228+
month = parsed_date.month and parsed_date.month.number or nil,
229+
year = parsed_date.year,
230+
hour = parsed_date.time and parsed_date.time.hour,
231+
min = parsed_date.time and parsed_date.time.minute,
232+
sec = parsed_date.time and parsed_date.time.second,
233+
}) --[[@as osdateparam]])
234+
return os.date("*t", parsed) --[[@as osdate]]
242235
end,
243236

244237
--- Converts a lua `osdate` to a Neorg date.

0 commit comments

Comments
 (0)