-
Notifications
You must be signed in to change notification settings - Fork 73
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
WIth backends set to both LSP and treesitter, it fallbacks to treesitter initially #68
Comments
The specific issue was because the viml lsp doesn't provide diagnostics when a file is opened, so it wouldn't trigger a symbol fetch. The simple fix is to always fetch symbols on attach.
Should be fixed now. Thanks for the report! |
Updated and the issue sill exists. Before this fix, this issue happened on not only the viml buffer, but on other filetype buffers such as Just now I updated Thank you. |
Just to confirm: you are still seeing the behavior where you have to make changes to the buffer in order to see the LSP symbols? Because treesitter is so much faster than LSP, we do expect to see the treesitter symbols first, but the LSP symbols should take over after a second or so. I unfortunately can't reproduce the issue anymore on any files (go, vim, etc) so I won't be able to debug it myself. The first thing you should check is that we're actually fetching the symbols here aerial.nvim/lua/aerial/backends/lsp/init.lua Line 115 in 7566440
And once you confirm that, make sure the symbols callback is being called and not hitting an early return
|
Yes, I have to make some changes (like insert a new line by
For It's so weird it only happens for Btw, here is my Thank you very much. |
The fact that it's only the vim language server makes me suspicious. Try upgrading it to make sure you're on the latest version. Also, since I can't reproduce it locally the best I can do is give you some ideas of how to debug it yourself. Try putting some print statements in the locations mentioned in the previous comment. The results should help narrow it down a bit. |
Okay. I will try that later. Thank you for you help. Btw, if I remove "treesitter" from |
Interesting. One workaround you can use for now is to specifically exclude the treesitter backend for vim files require('aerial').setup({
backends = {
['_'] = {'lsp', 'treesitter', 'markdown'},
vim = {'lsp'},
}
}) |
M.fetch_symbols = function()
vim.lsp.buf.document_symbol()
print("hello")
end And I can definitely see the output "hello" for a
M.symbol_callback = function(_err, result, context, _config)
local client_id = context.client_id
if not result or vim.tbl_isempty(result) then
return
end
print("hello")
local bufnr = context.bufnr
-- Don't update if there are diagnostics errors, unless config option is set
-- or we have no symbols for this buffer
if
not config.lsp.update_when_errors
and data:has_symbols(bufnr)
and get_error_count(bufnr, client_id) > 0
then
return
end
-- Debounce this callback to avoid unnecessary re-rendering
if results[bufnr] == nil then
vim.defer_fn(function()
local r = results[bufnr]
results[bufnr] = nil
M.handle_symbols(r, bufnr)
end, 100)
end
results[bufnr] = result
end I couldn't see "hello" output, so it hit the first Any ideas? Thank you. |
I suspect that it's a race condition in the vimls server. It could be that we request the symbols so soon after the file is opened that it's still parsing, and instead of waiting until parsing is complete it returns an empty list. If that's the case then it would be resolved by fetching the symbols slightly later. Try replacing aerial.nvim/lua/aerial/backends/lsp/init.lua Line 115 in ed25c56
with vim.defer_fn(M.fetch_symbols, 10) However that wouldn't explain why it works when the treesitter backend is disabled. So perhaps it's something else entirely |
I made this change and it still didn't work. Next, I tried Screen.Recording.2022-03-22.at.23.03.52.movThank you. Btw, my treesitter setup is here. |
Hi @stevearc any updates for this? Thanks a lot. |
Cannot set multiple backends for vim due to an issue See stevearc/aerial.nvim#68
This is a bug in the language server. I've submitted a fix iamcco/vim-language-server#72 |
Great. Thank you. |
This issue was solved after your PR to vim language server was merged. Thank you very much. |
Describe the bug
First I have this setting
backends = {"lsp", "treesitter"}
. If I am correct, I think this means use LSP as the backend and fallback to treesitter if LSP is unavailable.I opened a buffer like
init.vim
(with viml LSP server enabled), and then I openaerial
window.aerial
fallback to treesitter, i.e., instead of showing symbols from LSP, it only showed symbols from treesitter. To make all the symbols from LSP to be shown, I have to make some changes like inserting an empty line or deleting a char. I think the expected behavior should be that all symbols from LSP will be shown as soon as I openaerial
. Because I already have viml LSP server enabled, it shouldn't use treesitter.If set
backends = {"lsp"}
, then all symbols from LSP will be shown immediately whenaerial
window is opened, i.e., no need to change text before showing the symbols.System information
Screenshots
I made a show demo video below
Screen.Recording.2022-03-18.at.14.20.46.mov
Thank you very much.
The text was updated successfully, but these errors were encountered: