Skip to content
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

Fallback to next backend if LSP is still loading #177

Closed
axieax opened this issue Oct 28, 2022 · 2 comments
Closed

Fallback to next backend if LSP is still loading #177

axieax opened this issue Oct 28, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@axieax
Copy link
Contributor

axieax commented Oct 28, 2022

Describe the bug
A clear and concise description of what the bug is.

Previously, setting backends = {"lsp", "treesitter", ..} means that if LSP has not started yet, Treesitter's symbols will take over to be used in :AerialToggle instead. Now, the behaviour just seems to be hanging, waiting for the LSP to be ready.

System information

  • OS: mac
  • Neovim version: v0.8
  • AerialInfo: This is the AerialInfo during "Loading"
Aerial Info
-----------
Filetype: lua
Configured backends:
  lsp (supported) (attached)
  treesitter (supported)
  markdown (not supported) [Filetype is not markdown]
  man (not supported) [Filetype is not man]
Show symbols: all symbols
  • Aerial config:
require("aerial").setup({
  -- close_behavior = "close",
  highlight_on_hover = true,
  highlight_on_jump = 200,
  close_on_select = true,
  -- fold code from tree (overwrites treesitter foldexpr)
  manage_folds = false,
  -- link_tree_to_folds = true,
  -- link_folds_to_tree = true,
  show_guides = true,
  guides = {
    mid_item = "",
    last_item = "",
  },
  filter_kind = false,
  -- fall back to treesitter if LSP not available
  backends = { "lsp", "treesitter", "markdown", "man" },
  on_attach = function(bufnr)
    -- set fold level
    local name = vim.api.nvim_buf_get_name(bufnr)
    local matches = {
      vim.fn.expand("~/dotconfig/nvim/lua/axie/plugins/init.lua"),
      vim.fn.expand("~/.config/nvim/lua/axie/plugins/init.lua"),
    }
    if vim.tbl_contains(matches, name) then
      require("aerial").tree_set_collapse_level(bufnr, 1)
    end
  end,
  keymaps = {
    -- HELP: there is delay waiting for `<<` and `>>`
    ["<"] = "actions.tree_decrease_fold_level",
    [">"] = "actions.tree_increase_fold_level",
  },
})

To Reproduce
Steps to reproduce the behavior:

  1. Open up a file with a slow starting LSP server
  2. Toggle Aerial
  3. Loading...

If possible, provide a minimal file that will trigger the issue:

minimal code here

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@axieax axieax added the bug Something isn't working label Oct 28, 2022
@stevearc
Copy link
Owner

The previous behavior happened mostly as an accident of how the timing of various functions worked. The LSP backend didn't attach very quickly, so it was completely skipped over at first. Now, due to changes in LSP, or (more likely) the fact that we're inspecting the LSP state differently, it attaches earlier and never falls back to treesitter.

I've now added explicit support for racing all the symbol providers when a buffer is first attached. This should restore the functionality you want in a more supported, less brittle way.

@axieax
Copy link
Contributor Author

axieax commented Oct 30, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants