better-ts-errors.nvim
better-ts-errors.nvim copied to clipboard
Crashing when trying to view an error
Description
Error 15:11:37 msg_show.lua_error E5108: Error executing lua ...b/.local/share/nvim/lazy/nui.nvim/lua/nui/utils/init.lua:29: Invalid window id: 1000
stack traceback:
[C]: in function 'nvim_win_get_width'
...b/.local/share/nvim/lazy/nui.nvim/lua/nui/utils/init.lua:29: in function 'get_window_size'
....local/share/nvim/lazy/nui.nvim/lua/nui/layout/utils.lua:94: in function 'get_container_info'
....local/share/nvim/lazy/nui.nvim/lua/nui/layout/utils.lua:161: in function 'update_layout_config'
...b/.local/share/nvim/lazy/nui.nvim/lua/nui/popup/init.lua:388: in function 'update_layout'
...azy/better-ts-errors.nvim/lua/better-ts-errors/popup.lua:25: in function 'show'
...tter-ts-errors.nvim/lua/better-ts-errors/diagnostics.lua:138: in function 'show'
...lazy/better-ts-errors.nvim/lua/better-ts-errors/main.lua:31: in function 'toggle'
...lazy/better-ts-errors.nvim/lua/better-ts-errors/init.lua:11: in function 'toggle'
[string ":lua"]:1: in main chunk
Steps to reproduce
<leader>dd on an error in a svelte file
Expected behaviour
The UI to show the formatted error
Environment
NVIM v0.10.1 Build type: Release LuaJIT 2.1.1720049189
- better-ts-errors version: latest
Hm, I am not sure how to reproduce it, it looks like an error is coming from nui which is used to show the popup window.
Here is Svelte file on my side
Does this happen in a specific project? On all svelte files? Does it happen on any other types of files (react etc)? I don't see a type of file being an issue, since there is no runtime use of the types of files.
You can open this window even in Lua files and it doesn't use TS Server
Do you know which Nui version you have installed?
I had the same issue (using LazyVim). I just needed to install the nui package itself:
-- ./lua/plugins/nui.lua
return {
"MunifTanjim/nui.nvim",
lazy = true,
}
I guess having it listed as a dependency wasn't enough?
Thanks for confirmation! That's weird that listing it as a dependency is not enough.
I will take a look if I can pinpoint why and if it's the plugin who is doing something wrong or a package manager
Okay, so that didn't actually solve the problem completely, it's just intermittent now.
E5108: Error executing lua ...r/.local/share/nvim/lazy/nui.nvim/lua/nui/utils/init.lua:29: Invalid window id: 1000
stack traceback:
[C]: in function 'nvim_win_get_width'
...r/.local/share/nvim/lazy/nui.nvim/lua/nui/utils/init.lua:29: in function 'get_window_size'
....local/share/nvim/lazy/nui.nvim/lua/nui/layout/utils.lua:94: in function 'get_container_info'
....local/share/nvim/lazy/nui.nvim/lua/nui/layout/utils.lua:161: in function 'update_layout_config'
...r/.local/share/nvim/lazy/nui.nvim/lua/nui/popup/init.lua:388: in function 'update_layout'
...azy/better-ts-errors.nvim/lua/better-ts-errors/popup.lua:25: in function 'show'
...tter-ts-errors.nvim/lua/better-ts-errors/diagnostics.lua:138: in function 'show'
...lazy/better-ts-errors.nvim/lua/better-ts-errors/main.lua:31: in function 'toggle'
...lazy/better-ts-errors.nvim/lua/better-ts-errors/init.lua:11: in function 'toggle'
[string ":lua"]:1: in main chunk
There seems to be similar issues reported:
- https://github.com/folke/trouble.nvim/issues/284
- https://github.com/nvim-neo-tree/neo-tree.nvim/issues/544
Looks like Telescope was causing this issue for a bit, but it's been patched it seems:
- https://github.com/nvim-telescope/telescope.nvim/issues/2532
It may be worthwhile to check and see that what caused their problem is not also causing the issue here.
If it's not an issue w/ this plugin, I'm wondering if @liamwh and I have a similar plugin that's surfacing this issue - one that you don't have?
This is my :Lazy output:
alpha-nvim
better-ts-errors.nvim
catpuccin
cmp-nvim-lsp
cmp-vsnip
lazy.nvim
lspkind-nvim
lualine.nvim
mason-lspconfig.nvim
mason.nvim
mini.comment
mini.pairs
neo-tree.nvim
neodev.nvim
none-ls-extras.nvim
none-ls.nvim
nui.nvim
nvim-cmp
nvim-lspconfig
nvim-surround
nvim-treesitter
nvim-web-devicons
plenary.nvim
schemastore.nvim
tailwind-tools
telescope-ui-select.nvim
telescope.nvim
tokyonight.nvim
vim-vsnip
I had the same issue (using LazyVim). I just needed to install the
nuipackage itself:-- ./lua/plugins/nui.lua return { "MunifTanjim/nui.nvim", lazy = true, }I guess having it listed as a dependency wasn't enough?
That worked for me. thanks!
Reproduction steps:
- (over a ts error) toggle the better-ts-errors window open
- toggle the better-ts-errors window closed
- split the window (
:vs) - close the original window
- attempt to toggle the better-ts-errors window again
I had the same issue (using LazyVim). I just needed to install the
nuipackage itself:-- ./lua/plugins/nui.lua return { "MunifTanjim/nui.nvim", lazy = true, }
I guess having it listed as a dependency wasn't enough?
This work for me as well but it still being weird. adding the dependency should be enough
I was able to reproduce this error consistently
Some Context
I use auto-session plugin which saves my open buffers and cursor location. I can go to the root of a directory and hit nvim which will restore the session for me. I think the underlying view or session restoration API is the culprit here.
Theory
The error only appears if the session was created before bte was installed or if the session was created while bte was enabled=false in the config. The error should not be specific to the plugin I'm using but the API that the plugin is using. I don't know what that API is, :mkview maybe? Maybe a combination of different things.
Reproduce
- Disable bte and save config
return {
"OlegGulevskyy/better-ts-errors.nvim",
dependencies = { "MunifTanjim/nui.nvim" },
config = {
keymaps = {
toggle = "<leader>dd", -- default '<leader>dd'
go_to_definition = "<leader>dx", -- default '<leader>dx'
},
},
enabled = false, -- <- THIS IS IMPORTANT
}
- Create new ts project
pnpm create vite bte-test - Go to project root and run
nvim - Open a file
- Make sure to save this session with the opened buffers. In my case autosession does it automatically when I save
:wa - Close the project
- Enable bte by setting
enabled = truein lua config - Open the ts project again and load the session. In my case autosession does that automatically when I hit
nvimfrom project root - Go to some error and try
:BetterTsErrors. This should give you theinvalid buffer iderror from nui - Loss
I found this when I noticed that bte only breaks if my older projects. If the session was created before better-ts-errors (bte) was installed then I will get this error:
Error executing lua ...local/share/nvim/lazy/nui.nvim/lua/nui/utils/autocmd.lua:464: Invalid buffer id: 2
However, if session was created after bte was installed, for example if I start a new project with vite, then bte will work as expected with no errors.
@walker-tx are you using some sort of plugin that manages sessions or maybe some other session related features that neovim offers?
Reproduction steps:
- (over a ts error) toggle the better-ts-errors window open
- toggle the better-ts-errors window closed
- split the window (
:vs)- close the original window
- attempt to toggle the better-ts-errors window again
I was also able to reproduce the error this way but I'd like to add something. Once bte enters the error state it stays like that unless I first delete my session (clear open buffers, view and other stuff) and start fresh.
https://github.com/user-attachments/assets/07d698c1-1788-4421-aa73-1a19c8c38959
Sometimes I'm hitting <leader>dd twice. Ignore that part.