Skip to content

Commit

Permalink
fix: various type errors in codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed May 25, 2024
1 parent ee7903f commit c564e6c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions lua/neorg/core/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function utils.ts_parse_query(language, query_string)
if vim.treesitter.query.parse then
return vim.treesitter.query.parse(language, query_string)
else
---@diagnostic disable-next-line
return vim.treesitter.parse_query(language, query_string)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lua/neorg/modules/core/completion/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.private = {
end
if type(source) == "string" then
-- check if the file is open; use the buffer contents if it is
if vim.fn.bufnr(source) ~= -1 then
if vim.fn.bufnr(source) ~= -1 then ---@diagnostic disable-line
source = vim.uri_to_bufnr(vim.uri_from_fname(source))
else
iter_src = io.open(source, "r"):read("*a")
Expand All @@ -118,7 +118,7 @@ module.private = {
local norg_tree = norg_parser:parse()[1]
local query = vim.treesitter.query.parse("norg", query_str)
local links = {}
for id, node in query:iter_captures(norg_tree:root(), iter_src) do
for id, node in query:iter_captures(norg_tree:root(), iter_src, 0, -1) do
local capture = query.captures[id]
if capture == "title" then
local original_title = treesitter.get_node_text(node, iter_src)
Expand Down
6 changes: 3 additions & 3 deletions lua/neorg/modules/core/integrations/treesitter/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ module.public = {
local root = tree:root()

--- Recursively searches for a node of a given type
---@param node userdata #The starting point for the search
---@param node TSNode #The starting point for the search
local function descend(node)
-- Iterate over all children of the node and try to match their type
for child, _ in node:iter_children() do ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
Expand Down Expand Up @@ -471,7 +471,7 @@ module.public = {
end

--- Recursively searches for a node of a given type
---@param node userdata #The starting point for the search
---@param node TSNode #The starting point for the search
local function descend(node)
-- Iterate over all children of the node and try to match their type
for child, _ in node:iter_children() do ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
Expand Down Expand Up @@ -596,7 +596,7 @@ module.public = {
--- Extracts the document root from the current document or from the string
---@param src number|string The number of the buffer to extract or string with code (can be nil)
---@param filetype string? #The filetype of the buffer or the string with code
---@return userdata? #The root node of the document
---@return TSNode? #The root node of the document
get_document_root = function(src, filetype)
filetype = filetype or "norg"

Expand Down

0 comments on commit c564e6c

Please sign in to comment.