aerial.nvim icon indicating copy to clipboard operation
aerial.nvim copied to clipboard

Local bindings don't work after an initial error

Open weakphish opened this issue 2 years ago • 3 comments

Describe the bug If I try and toggle the Aerial window in a non-supported buffer (blank or otherwise), my binding (<leader>tb) won't work for the rest of the session.

System information

  • OS: MacOS
  • Neovim version: v.0.6.1
  • AerialInfo:
Aerial Info
-----------
Filetype: rust
Configured backends:
  lsp (supported) (attached)
  treesitter (supported)
  markdown (not supported) [Filetype is not markdown]
Show symbols: all symbols
  • Aerial config:
 38 require("aerial").setup {
 37   backends = { "lsp", "treesitter", "markdown" },
 36   close_behavior = "auto",
 35   min_width = 40,
 34   max_width = 40,
 33   show_guides = true,
 32
 31   -- Symbols to display (can be a filetype map)
 30   -- filter_kind = {
 29   --   -- "Array",
 28   --   -- "Boolean",
 27   --   "Class",
 26   --   -- "Constant",
 25   --   "Constructor",
 24   --   "Enum",
 23   --   -- "EnumMember",
 22   --   -- "Event",
 21   --   -- "Field",
 20   --   -- "File",
 19   --   "Function",
 18   --   "Interface",
 17   --   -- "Key",
 16   --   "Method",
 15   --   "Module",
 14   --   -- "Namespace",
 13   --   -- "Null",
 12   --   -- "Number",
 11   --   -- "Object",
 10   --   -- "Operator",
  9   --   -- "Package",
  8   --   -- "Property",
  7   --   -- "String",
  6   --   "Struct",
  5   --   -- "TypeParameter",
  4   --   -- "Variable",
  3   -- },
  2   -- Set it to false to display all symbols
  1   filter_kind = false,
39  }

To Reproduce Steps to reproduce the behavior:

  1. Open a blank buffer (nvim)
  2. Attempt to toggle Aerial, get error
  3. Attempt to use binding in supported buffer

weakphish avatar Mar 29 '22 15:03 weakphish

Tried it myself, couldn't get it to repro. Couple things you can try to get more debugging info:

  • When you get into the state where your mapping fails, does calling :AerialToggle or :AerialOpen still work?
  • When your mapping fails, if you do a map <leader>tb does it show your binding?
  • Do you see anything in the :messages besides "Aerial could find no supported backend"?

Kind of a sideways suggestion but you can put your keymaps in the on_attach callback. I personally prefer this approach, but agree it should work the other way and understand if you prefer global maps.

require("aerial").setup({
  on_attach = function(bufnr)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>tb', '<cmd>AerialToggle!<CR>', {})
  end
})

stevearc avatar Mar 30 '22 02:03 stevearc

Hey, thanks for the reply!

  1. Yeah, weirdly, they both work
  2. It shows it on the bottom right of the status bar (lualine) if that's what you mean, yeah, it does
  3. No other messages

I'll try the suggestion when I have a chance; I do prefer global mappings but if that fixed it then it's not a big deal :)

Thanks!

weakphish avatar Mar 30 '22 03:03 weakphish

Thaaaaat's pretty weird! If :AerialToggle works when called directly, then I don't think it could be anything aerial-specific. It does sound like there's something wonky happening with the bindings, though what that could be I'm not sure.

Another thing to try would be to manually run :nnoremap <leader>tb <cmd>AerialToggle!<CR> after the bindings break. Or even try nmapping it to a different key combination and see if that works.

stevearc avatar Mar 30 '22 03:03 stevearc