Skip to content

Commit 021b45d

Browse files
authored
Merge pull request #252 from Isrothy/fix-248
fix: Breaking changes in treesitter api
2 parents eab68b1 + 42b8b63 commit 021b45d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lua/neominimap/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ local check_treesitter = function(health)
3838
health.info("TreeSitter integration is enabled")
3939
if lualib_available("nvim-treesitter") then
4040
health.ok("TreeSitter is installed")
41-
local parsers = require("nvim-treesitter.parsers").available_parsers()
41+
local parsers = require("nvim-treesitter").get_available()
4242
if #parsers > 0 then
4343
health.ok("TreeSitter parsers are installed: " .. table.concat(parsers, ", "))
4444
else

lua/neominimap/map/treesitter.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,11 @@ M.extract_highlights_co = function(bufnr)
149149
return text.codepoints_pos(str, tabwidth)
150150
end, lines)
151151

152-
---@type fun(row:integer, char_idx:integer):integer
152+
---@type fun(row:integer, char_idx:integer):integer?
153153
local char_idx_to_codepoint_idx = function(row, char_idx)
154+
if code_point_list[row] == nil then
155+
return nil
156+
end
154157
local utf8_idx = text.byte_index_to_utf8_index(char_idx, utf8_pos_list[row])
155158
local code_point_idx = code_point_list[row][utf8_idx]
156159
return code_point_idx
@@ -179,10 +182,10 @@ M.extract_highlights_co = function(bufnr)
179182
if not hide then
180183
local from = row == h.start_row and h.start_col or 1
181184
local to = row == h.end_row and h.end_col or string.len(lines[row])
182-
from = char_idx_to_codepoint_idx(row, from)
183-
to = char_idx_to_codepoint_idx(row, to)
184-
if from ~= nil and to ~= nil then
185-
for col = from, to do
185+
local from_codepint = char_idx_to_codepoint_idx(row, from)
186+
local to_codepint = char_idx_to_codepoint_idx(row, to)
187+
if from_codepint ~= nil and to_codepint ~= nil then
188+
for col = from_codepint, to_codepint do
186189
local mrow, mcol = coord.codepoint_to_mcodepoint(vrow, col)
187190
if mcol > minimap_width then
188191
break

0 commit comments

Comments
 (0)