Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help: Error executing vim.schedule in extmark.lua: "Invalid chunk: expected Array with 1 or 2 Strings" #364

Closed
D4nitrix13 opened this issue Mar 9, 2025 · 2 comments
Labels
question Further information is requested

Comments

@D4nitrix13
Copy link

Neovim version (nvim -v)

v0.10.2

Neovim distribution

LazyVim

Description

Error executing vim.schedule in extmark.lua: "Invalid chunk: expected Array with 1 or 2 Strings"

Image

Description:

While using the render-markdown.nvim plugin, I encountered the following error:

Error executing vim.schedule lua callback: ...ender-markdown.nvim/lua/render-markdown/core/extmark.lua:37: Invalid chunk: expected Array with 1 or 2 Strings
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...ender-markdown.nvim/lua/render-markdown/core/extmark.lua:37: in function 'show'
        ...azy/render-markdown.nvim/lua/render-markdown/core/ui.lua:150: in function 'run_update'
        ...azy/render-markdown.nvim/lua/render-markdown/core/ui.lua:90: in function <...azy/render-markdown.nvim/lua/render-markdown/core/ui.lua:89>

Steps to Reproduce:

  1. Open a Markdown file in Neovim.
  2. Perform an action that triggers the plugin’s functionality (e.g., saving the file or entering insert mode).
  3. Observe the error message in the command line or message window.

My Configuration (~/.config/nvim/lua/plugins/markdown.lua):

return {
  "MeanderingProgrammer/render-markdown.nvim",
  dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" },
  opts = {
    heading = {
      enabled = true,
      sign = true,
      style = "full",
      icons = { "", "", "", "", "", "" },
      left_pad = 1,
    },
    bullet = {
      enabled = true,
      icons = { "", "", "", "" },
      right_pad = 1,
      highlight = "render-markdownBullet",
    },
  },
}

This error seems to be related to the nvim_buf_set_extmark function, which expects an array with one or two strings but is receiving a different value.

I have tried updating all plugins and verifying the configuration, but the issue persists. Any help in resolving this would be greatly appreciated.

Relevant Code (extmark.lua) ~/.local/share/nvim/lazy/render-markdown.nvim/lua/render-markdown/core/extmark.lua

---@class render.md.Extmark
---@field private id? integer
---@field private mark render.md.Mark
local Extmark = {}
Extmark.__index = Extmark

---@param mark render.md.Mark
---@return render.md.Extmark
function Extmark.new(mark)
    local self = setmetatable({}, Extmark)
    self.id = nil
    self.mark = mark
    return self
end

---@return render.md.Mark
function Extmark:get()
    return self.mark
end

---@param range? render.md.Range
---@return boolean
function Extmark:inside(range)
    if range == nil then
        return false
    end
    local row = self.mark.start_row
    return range:contains(row, row)
end

---@param ns integer
---@param buf integer
function Extmark:show(ns, buf)
    if self.id == nil then
        local mark = self.mark
        mark.opts.strict = false
        self.id = vim.api.nvim_buf_set_extmark(buf, ns, mark.start_row, mark.start_col, mark.opts)
    end
end

---@param ns integer
---@param buf integer
function Extmark:hide(ns, buf)
    if self.id ~= nil then
        vim.api.nvim_buf_del_extmark(buf, ns, self.id)
        self.id = nil
    end
end

return Extmark
@D4nitrix13 D4nitrix13 added the question Further information is requested label Mar 9, 2025
MeanderingProgrammer added a commit that referenced this issue Mar 9, 2025
## Details

Issue: #364

Broke in last refactor due to passing list of lines to `virt_text`
property. Fix is to get rid of the additional list wrapper. Added unit
tests to catch this in the future.
@MeanderingProgrammer
Copy link
Owner

Ah crap, thanks for letting me know, was due to a bad refactor change I pushed.

Fixed here: 932432c

@D4nitrix13
Copy link
Author

Okay thanks for the solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants