Closed merijn closed 11 months ago
Another smoking gun: This behaviour seems to only manifest when I have the following autocommand defined: au DiagnosticChanged * lua vim.diagnostic.setloclist({ open = false })
.
This is interesting, because I started experimenting because DiagnosticChanged
did not seem to fire when diagnostics were published by the LSP server, so something about how diagnostic publishing is handled seems wonky?
Ok, I'm able to reproduce, but I'm still searching what is causing it. For now I'm sure this is some not easy to find edge case.
@merijn I think I found problem and I it isn't related with plugin, but please check this for yourself and let me know.
So, I was able to reproduce same bug in lua lsp
with my plugin disabled.
Problem occurs for me when I have enabled tool(null_ls
for me) which do autoformat for me on save - in both my plugin and lua lsp.
Additionally I found tailwindcss
lsp attached to buffer(with or without my plugin) hang neovim with loclist open.
So I think it is something in nvim core or mentioned plugins/lsps.
I bet on core because to test I used fake data loclist instead calling vim.diagnostic.setloclist()
and problem still show up.
It may be some combination of loclist + DiagnosticChanged event + formatting maybe, I'm not sure.
@merijn I was able to reproduce this using tailwind ls with minimal file below. Steps to reproduce:
npm i -g @tailwindcss/language-server
- install ls which cause problem:_G.test()
- to populate loclist:lopen
:qa!
- nvim hangs--- CHANGE THESE
local pattern = "typescript"
local cmd = { "tailwindcss-language-server", "--stdio" }
-- Add files/folders here that indicate the root of a project
local root_markers = { ".git", ".editorconfig" }
-- Change to table with settings if required
local settings = vim.empty_dict()
vim.api.nvim_create_autocmd("FileType", {
pattern = pattern,
callback = function(args)
local match = vim.fs.find(root_markers, { path = args.file, upward = true })[1]
local root_dir = match and vim.fn.fnamemodify(match, ":p:h") or nil
vim.lsp.start {
name = "bugged-ls",
cmd = cmd,
root_dir = root_dir,
settings = settings,
}
end,
})
_G.test = function()
print "::::::::: debug message :::::::::"
vim.fn.setloclist(0, {}, " ", {
items = {
{
bufnr = 1,
col = 1,
end_col = 1,
end_lnum = 12,
lnum = 12,
text = "Parsing error: Identifier expected.",
type = "E",
},
{
bufnr = 1,
col = 1,
end_col = 2,
end_lnum = 12,
lnum = 12,
text = "Identifier expected.",
type = "E",
},
{
bufnr = 1,
col = 26,
end_col = 27,
end_lnum = 18,
lnum = 18,
text = "Property 'Z' does not exist on type 'typeof TestEnum'.",
type = "E",
},
},
title = "Diagnostics",
})
end
vim.api.nvim_create_autocmd('DiagnosticChanged', {
pattern = '*.ts',
callback = _G.test,
})
So it isn't related to my plugin it's something in core, if you want to use this mini file to report issue in core feel free to grab it.
Yeah, looking at the stack trace I was already wondering if it was maybe something in neovim itself, but I figured I'd try and rule out typescript-tools
first :)
Thanks for the help, I'll make an issue on the neovim repo.
Hey @merijn . Sorry for bothering but do you have any tutorial or link or anything that could help me do debugging like you did (in the first post)? I have simmilar issue as you (hanging on quit), but I have no idea on how to do the debugging
@KostkaBrukowa All I did for that was lldb -p <nvim process id>
to attach lldb to the hanging neovim and then hit bt
to get a backtrace of whatever it was doing when I attached the debugger :)
Luckily the homebrew binary of neovim seems to ship with (some) debugging symbols to produce actually useful function names.
Wow. That's really helpful. Thank you very much!!
I have run into some cursed issue, I'm not sure how to diagnose/debug this situation, so please let me know what additional info is ready.
I prefer having my errors in the
loclist
and with this plugin that wasn't happening. In debugging this situation I discovered that manually updating the loclist via:lua vim.diagnostic.setloclist()
with this plugin active causes neovim to hang indefinitely when quitting.Attaching a debugger I see it hangs in:
It seems to indefinitely spin inside nvim`ml_delete_int, but I have no idea why and whether this is a bug in neovim or inside this plugin.
This is neovim 0.9.2 from Homebrew on an Apple M1. I'm not sure what other info would be needed to figure out if this is a bug in the plugin or inside neovim?