Error when sourcing a session
scheatkode opened this issue · comments
Describe the bug
An error occurs on sourcing a Session.vim
file.
To Reproduce
Steps to reproduce the behavior:
- Open a file or two
:mksession
- Restart Neovim
:source Session.vim
Expected behavior
No error.
Output of :checkhealth nvim-treesitter
nvim-treesitter: require("nvim-treesitter.health").check()
Installation
- OK:
tree-sitter
found 0.20.7 (parser generator, only needed for :TSInstallFromGrammar)
- OK:
node
found v18.13.0 (only needed for :TSInstallFromGrammar)
- OK:
git
executable found.
- OK:
cc
executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (GCC) 12.2.0
- OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
OS Info:
{
machine = "x86_64",
release = "6.1.5-arch2-1",
sysname = "Linux",
version = "#1 SMP PREEMPT_DYNAMIC Thu, 12 Jan 2023 22:42:33 +0000"
}
Parser/Features H L F I J
- markdown ✓ . ✓ . ✓
- norg . . . . .
- lua ✓ ✓ ✓ ✓ ✓
- bash ✓ ✓ ✓ . ✓
- sql ✓ . . . ✓
- make ✓ . ✓ . ✓
- rust ✓ ✓ ✓ ✓ ✓
- css ✓ . ✓ ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
- javascript ✓ ✓ ✓ ✓ ✓
- jsonc ✓ ✓ ✓ ✓ ✓
- scss ✓ . ✓ ✓ .
- svelte ✓ . ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- yaml ✓ ✓ ✓ ✓ ✓
- prisma ✓ . . . .
- gitattributes ✓ . . . ✓
- cpp ✓ ✓ ✓ ✓ ✓
- jq ✓ . . . ✓
- go ✓ ✓ ✓ ✓ ✓
- help ✓ . . . ✓
- query ✓ ✓ ✓ ✓ ✓
- hcl ✓ . ✓ ✓ ✓
- comment ✓ . . . .
- http ✓ . . . ✓
- awk ✓ . . . ✓
- json ✓ ✓ ✓ ✓ .
- git_rebase ✓ . . . ✓
- markdown_inline ✓ . . . ✓
- gitignore ✓ . . . .
- regex ✓ . . . .
- gitcommit ✓ . . . ✓
- jsonnet ✓ . . . .
- json5 ✓ . . . ✓
- gowork ✓ . . . ✓
- jsdoc ✓ . . . .
- diff ✓ . . . .
- toml ✓ ✓ ✓ ✓ ✓
- dockerfile ✓ . . . ✓
- tsx ✓ ✓ ✓ ✓ ✓
- vue ✓ . ✓ ✓ ✓
- gomod ✓ . . . ✓
- python ✓ ✓ ✓ ✓ ✓
- vim ✓ ✓ ✓ . ✓
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}
Output of nvim --version
NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
Features: +acl +iconv +tui
Additional context
Here's the error message:
Error detected while processing /home/scheatkode/repositories/github.com/amplium/universe/Session.vim[19]..BufReadPost Autocommands for "*": Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:22: Error executing lua: /usr/share/nvim/runtime/filetype.lua:23: Vim(append):Error executing lua callback: ...r-textobjects/lua/nvim-treesitter/t extobjects/attach.lua:83: bad argument #1 to 'ipairs' (table expected, got string) stack traceback: [C]: in function 'ipairs' ...r-textobjects/lua/nvim-treesitter/textobjects/attach.lua:83: in function 'detach' ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:518: in function 'detach_module' ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:527: in function 'reattach_module' ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:131: in function <...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:130> [C]: in function 'nvim_exec_autocmds' ...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:80: in function <...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:79> [C]: in function 'xpcall' .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:110: in function 'try' ...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:79: in function 'trigger' ...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:35: in function <...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:26> [C]: in function 'nvim_cmd' /usr/share/nvim/runtime/filetype.lua:23: in function [C]: in function 'nvim_buf_call' /usr/share/nvim/runtime/filetype.lua:22: in function stack traceback: [C]: in function 'nvim_cmd' /usr/share/nvim/runtime/filetype.lua:23: in function [C]: in function 'nvim_buf_call' /usr/share/nvim/runtime/filetype.lua:22: in function stack traceback: [C]: in function 'nvim_buf_call'
Below is a quick fix to resolve the issue. Even if this is easily fixable, I'm not confident enough to open a PR since I'm not familiar with the codebase, therefore I'm not sure this is the right/preferred way of handling it.
diff --git a/lua/nvim-treesitter/textobjects/attach.lua b/lua/nvim-treesitter/textobjects/attach.lua
index 448c684..4de62e4 100644
--- a/lua/nvim-treesitter/textobjects/attach.lua
+++ b/lua/nvim-treesitter/textobjects/attach.lua
@@ -55,7 +55,11 @@ function M.make_attach(functions, submodule, keymap_modes, opts)
end
function M.make_detach(functions, submodule, keymap_modes)
- keymap_modes = keymap_modes or "n"
+ if type(keymap_modes) == "string" then
+ keymap_modes = { keymap_modes }
+ elseif type(keymap_modes) ~= "table" then
+ keymap_modes = { "n" }
+ end
return function(bufnr)
local config = configs.get_module("textobjects." .. submodule)
local lang = parsers.get_buf_lang(bufnr)
Sorry.. I see why this happens. Thanks for the fix!
This is introduced in #363
No worries. Thank you for your time and quick response !
Hi @scheatkode, I think some other people still experience the problem with detaching keymaps, so I think fundamentally something is broken. #368 changes the detaching logic completely, and if you don't mind can you test if it works for you as well? I appreciate your time!