stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.55k stars 76 forks source link

bug: Floating window is closed when jump even with `close_on_select = false` #336

Open amano-takahisa opened 6 months ago

amano-takahisa commented 6 months ago

Neovim version (nvim -v)

NVIM v0.9.4

Operating system/version

Arch Linux

Output of :AerialInfo

Aerial Info


Filetype: python
Configured backends:
treesitter (supported) (attached)
lsp (supported)
markdown (not supported) [Filetype is not markdown]
man (not supported) [Filetype is not man]
Show symbols: Class, Constructor, Enum, Function, Interface, Module, Method, Struct

Describe the bug

With config close_on_select = false, floating window is closed when I click an item in the window to jump.

Previously, the floating window remained even I jumped, so the window was conveniently used as an index by displaying it in the upper right corner of the editing window. At some point, (may be from this commit?) the window disappeared when I clicked to jump.

Since the floating window is very useful when I editing multiple files with split windows, it would be great if you could provide an option which I can keep the floating window.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. Add config close_on_select = false. (I think it's default.)
  2. Open floating window with :AerialOpen float.
  3. Click an item in the floating window.

Expected Behavior

The floating window is kept open even editing window is jumped to the code.

Minimal example file

No response

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/aerial.nvim",
    config = function()
      require("aerial").setup({
        -- add your aerial config here
      })
    end,
  },
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require("nvim-treesitter.configs").setup({
        ensure_installed = { "c", "lua" },
        auto_install = true,
        highlight = { enable = true },
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

No response

stevearc commented 6 months ago

Yeah, that commit is probably where this changed. The trouble is there are some people that expect the floating window to auto-close, and some people that want it to remain open. You could create a keymap that re-opens the float after navigation, would this work for you?

local aerial = require("aerial")
aerial.setup({
  keymaps = {
    ["<CR>"] = function()
      aerial.select()
      aerial.open({ direction = "float" })
    end
  }
})
amano-takahisa commented 5 months ago

Thank you for your suggestion. The suggested keymap setup works as you described in my environment. However, I want to keep floating window all the time. The keymap config close the floating window when another window is selected with mouse click, c-w v etc.