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

Error executing lua callback: Vim:E315: ml_get: invalid lnum: 1 #9

Closed
avucic opened this issue Jun 24, 2023 · 11 comments · Fixed by #10
Closed

Error executing lua callback: Vim:E315: ml_get: invalid lnum: 1 #9

avucic opened this issue Jun 24, 2023 · 11 comments · Fixed by #10

Comments

@avucic
Copy link

avucic commented Jun 24, 2023

For some reason I have this error when I tray to delete buffer. Not sure if this related to the telescope. Any idea? Thanks in advance

Error executing lua callback: Vim:E315: ml_get: invalid lnum: 1
stack traceback:
        [C]: in function 'bufload'
        vim/_editor.lua: in function 'region'
        ...ls/neovim/0.9.1/share/nvim/runtime/lua/vim/highlight.lua:35: in function 'range'
        /Users/vucinjo/.local/share/nvim/lazy/markid/lua/markid.lua:87: in function 'highlight_tree'
        /Users/vucinjo/.local/share/nvim/lazy/markid/lua/markid.lua:103: in function 'cb'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:736: in function '_do_callback'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:176: in function 'invalidate'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:877: in function '_on_detach'
        ...s/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:73: in function <...s/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:69>
        [C]: at 0x010f000a80
        [C]: in function 'pcall'
        .../nvim/lazy/telescope.nvim/lua/telescope/actions/init.lua:1040: in function 'delete_cb'
        ...share/nvim/lazy/telescope.nvim/lua/telescope/pickers.lua:720: in function 'delete_selection'
        .../nvim/lazy/telescope.nvim/lua/telescope/actions/init.lua:1038: in function 'run_replace_or_original'
        ...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:253: in function <...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:252>

MacOS
NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

@David-Kunz
Copy link
Owner

Hi @avucic ,

Thanks for reporting! Can you include the steps to reproduce this problem? When I delete a buffer, everything works as expected.

Thank you and best regards,
David

@avucic
Copy link
Author

avucic commented Jul 1, 2023

Hi @David-Kunz thanks for helping me.

Not sure but I think this is related to the neovim/neovim#21416 and this plugin has the same issue
HiPhish/nvim-ts-rainbow2#40

When I open multiple files and I try to delete one I'm getting similar error like one mentioned in nvim-ts-rainbow2

E5108: Error executing lua ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:134: Vim:Error executing lua callback: ....1/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:148: Vim:Error executing lua callback: Vim:E315: ml_get: invalid lnum: 1
stack traceback:
        [C]: in function 'bufload'
        vim/_editor.lua: in function 'region'
        ...ls/neovim/0.9.1/share/nvim/runtime/lua/vim/highlight.lua:35: in function 'range'
        /Users/vucinjo/.local/share/nvim/lazy/markid/lua/markid.lua:87: in function 'highlight_tree'
        /Users/vucinjo/.local/share/nvim/lazy/markid/lua/markid.lua:103: in function 'cb'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:736: in function '_do_callback'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:176: in function 'invalidate'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:877: in function '_on_detach'
        ...s/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:73: in function <...s/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:69>
        [C]: in function 'bdelete'
        ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:134: in function 'buf_kill'
        ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:213: in function 'bufdelete'
        /Users/vucinjo/.config/nvim/lua/astronvim/utils/buffer.lua:138: in function 'close'
        [string ":lua"]:1: in main chunk

Similar issue was mentioned on bufdelete
It looks like some issue with callback mentioned in HiPhish/nvim-ts-rainbow2#40 but I'm not sure. When I disable markid I have no issue.

Let me know if this is not related to the markid or if I can help you more.
Regards

@David-Kunz
Copy link
Owner

David-Kunz commented Jul 1, 2023

Hi @avucic,

Thank you so much for this detailed analysis, greatly appreciated!

I still cannot reproduce the problem but I implemented a similar fix as in this PR.

Would you mind trying it out?

Thank you again and best regards,
David

@avucic
Copy link
Author

avucic commented Jul 1, 2023

I'm not familiar with nvim / lua so I'm not sure how to try it. What I did is following:

-- inisde lsp on_attach function
return function(client, bufnr)
  vim.api.nvim_buf_attach(bufnr, false, {
    on_detach = function()
      local ns = vim.api.nvim_get_namespaces()["markid"]
      vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
    end,
  })
end

No luck. Can you give me a hint hot to try?

@David-Kunz
Copy link
Owner

@avucic , sorry I should've been more precise: The fix is already in the main branch, so you just need to update the plugin.

@avucic
Copy link
Author

avucic commented Jul 1, 2023

A ha...I did that but unfortunately same thing

E5108: Error executing lua ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:134: Vim:Error executing lua callback: ....1/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:148: Vim:Error executing lua callback: Vim:E315: ml_get: invalid lnum: 1
stack traceback:
        [C]: in function 'bufload'
        vim/_editor.lua: in function 'region'
        ...ls/neovim/0.9.1/share/nvim/runtime/lua/vim/highlight.lua:35: in function 'range'
        /Users/vucinjo/.local/share/nvim/lazy/markid/lua/markid.lua:90: in function 'highlight_tree'
        /Users/vucinjo/.local/share/nvim/lazy/markid/lua/markid.lua:106: in function 'cb'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:736: in function '_do_callback'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:176: in function 'invalidate'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:877: in function '_on_detach'
        ...s/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:73: in function <...s/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:69>
        [C]: in function 'bdelete'
        ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:134: in function 'buf_kill'
        ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:213: in function 'bufdelete'
        /Users/vucinjo/.config/nvim/lua/astronvim/utils/buffer.lua:138: in function 'close'
        [string ":lua"]:1: in main chunk
stack traceback:
        [C]: in function '__newindex'
        ....1/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:148: in function 'destroy'
        ....1/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:184: in function 'on_detach'
        ....1/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:83: in function 'cb'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:736: in function '_do_callback'
        ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:878: in function '_on_detach'
        ...s/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:73: in function <...s/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:69>
        [C]: in function 'bdelete'
        ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:134: in function 'buf_kill'
        ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:213: in function 'bufdelete'
        /Users/vucinjo/.config/nvim/lua/astronvim/utils/buffer.lua:138: in function 'close'
        [string ":lua"]:1: in main chunk
stack traceback:
        [C]: in function 'bdelete'
        ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:134: in function 'buf_kill'
        ...al/share/nvim/lazy/bufdelete.nvim/lua/bufdelete/init.lua:213: in function 'bufdelete'
        /Users/vucinjo/.config/nvim/lua/astronvim/utils/buffer.lua:138: in function 'close'
        [string ":lua"]:1: in main chunk

@David-Kunz
Copy link
Owner

That's unfortunate. Let's wait for the response of your comment.

@avucic
Copy link
Author

avucic commented Jul 5, 2023

@David-Kunz After I install everything from scratch the issue disappear. Not sure what was the problem. Maybe it was related to the Astrovim update. Anyhow feel free to close this issue for and thanks for the help. Regards

@David-Kunz
Copy link
Owner

That's great news, thanks for the info @avucic 👍

@norpie
Copy link
Contributor

norpie commented Sep 11, 2023

I don't know if this has any adverse effects, but checking for the bufnr instead of 0 in the highlight_tree function

if not vim.api.nvim_buf_is_loaded(bufnr) then
      return
end

fixed it for me.

@avucic
Copy link
Author

avucic commented Sep 11, 2023

@norpie-dev Thank you. That seems to be the fix. I thought a clean install was the solution, but it's not...soon the problem appeared again.

@norpie norpie mentioned this issue Sep 14, 2023
David-Kunz added a commit that referenced this issue Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants