Closed Hubro closed 1 year ago
Hi, thanks for reporting!
Code to handle attach and detach is mostly copied from treesitter-textobjects
. Either I introduced that bug when copying or it was there in the first place. In any case we just need to take a look how it works now in the treesitter-textobjects
and "borrow" the better version :)
I will try to take a look at in the upcoming days, but my time is quite limited this week.
If you would like to work on it I would gladly accept a PR :)
I tried switching back to the regular tree-sitter config just to make sure, and that doesn't cause a crash. Copying whatever they do now will probably resolve the issue.
I'll take a look if I get time, but unfortunately I'm in the same boat :slightly_smiling_face:
Another related crash, things completely exploded when I tried to rename a file in nvim-tree.lua:
E5108: Error executing lua: ...al/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/utils.lua:176: Error executing lua: vim/_editor.lua:0: nvim_exec2()..BufReadPost A
utocommands for "*.{md,mdown,mkd,mkdn,markdown,mdwn,mdx}"..FileType Autocommands for "*": Vim(append):Error executing lua callback: vim/keymap.lua:0: opts: expe
cted table, got function
stack traceback:
[C]: in function 'error'
vim/shared.lua: in function 'validate'
vim/keymap.lua: in function 'bind'
...xt/lua/nvim-next/integrations/treesitter-textobjects.lua:65: in function 'setup_bindings'
...xt/lua/nvim-next/integrations/treesitter-textobjects.lua:85: in function 'detach'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:522: in function 'detach_module'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:531: in function 'reattach_module'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:132>
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
...al/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/utils.lua:178: in function <...al/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/utils.lua:176>
[C]: in function 'nvim_buf_call'
...al/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/utils.lua:176: in function 'rename_loaded_buffers'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:32: in function 'rename'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:85: in function 'on_confirm'
/usr/share/nvim/runtime/lua/vim/ui.lua:103: in function 'input'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:79: in function 'f'
...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/api.lua:32: in function <...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/api.lua:30>
stack traceback:
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
...al/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/utils.lua:178: in function <...al/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/utils.lua:176>
[C]: in function 'nvim_buf_call'
...al/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/utils.lua:176: in function 'rename_loaded_buffers'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:32: in function 'rename'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:85: in function 'on_confirm'
/usr/share/nvim/runtime/lua/vim/ui.lua:103: in function 'input'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:79: in function 'f'
...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/api.lua:32: in function <...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/api.lua:30>
stack traceback:
[C]: in function 'nvim_buf_call'
...al/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/utils.lua:176: in function 'rename_loaded_buffers'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:32: in function 'rename'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:85: in function 'on_confirm'
/usr/share/nvim/runtime/lua/vim/ui.lua:103: in function 'input'
...y/nvim-tree.lua/lua/nvim-tree/actions/fs/rename-file.lua:79: in function 'f'
...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/api.lua:32: in function <...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/api.lua:30>
EDIT: Found one that is easier to reproduce, just open literally any markdown file:
Error detected while processing BufReadPost Autocommands for "*.{md,mdown,mkd,mkdn,markdown,mdwn,mdx}"..FileType Autocommands for "*":
Error executing lua callback: vim/keymap.lua:0: opts: expected table, got function
stack traceback:
[C]: in function 'error'
vim/shared.lua: in function 'validate'
vim/keymap.lua: in function 'bind'
...xt/lua/nvim-next/integrations/treesitter-textobjects.lua:65: in function 'setup_bindings'
...xt/lua/nvim-next/integrations/treesitter-textobjects.lua:85: in function 'detach'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:522: in function 'detach_module'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:531: in function 'reattach_module'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:132>
Hi, I experienced it as well but I don't have a reliable way of reproducing it. I've just pushed a commit that should fix it. Do you mind give it a try?
@ghostbuster91 For me, I can 100% reproduce this by simply trying to open a markdown file, even one that doesn't exist:
$ nvim foo.md
Error:
Error detected while processing BufNewFile Autocommands for "*.{md,mdown,mkd,mkdn,markdown,mdwn,mdx}"..FileType Autocommands for "*":
Error executing lua callback: vim/keymap.lua:0: opts: expected table, got function
stack traceback:
[C]: in function 'error'
vim/shared.lua: in function 'validate'
vim/keymap.lua: in function 'bind'
...xt/lua/nvim-next/integrations/treesitter-textobjects.lua:65: in function 'setup_bindings'
...xt/lua/nvim-next/integrations/treesitter-textobjects.lua:85: in function 'detach'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:522: in function 'detach_module'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:531: in function 'reattach_module'
...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:132>
I updated to the newest version now
And it seems to have fixed it, at least it fixed the above error. I've had this happen in other scenarios as well, such as renaming or deleting files from nvim-tree.lua
.
We can assume it's fixed for now, and I'll reopen if it happens again :slightly_smiling_face:
Thanks for your work!
I have this autocommand set up in
ftdetect/envrc.lua
:After I installed and configured
nvim-next
, I now get a crash whenever I open a.envrc
file:Interestingly, if I remove my autocommand and open an
.envrc
file, nothing crashes. I can even setft=bash
afterwards and it works fine.