stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.72k stars 83 forks source link

bug: aerial navigation window jumps in size on up/down #254

Closed ten3roberts closed 1 year ago

ten3roberts commented 1 year ago

Neovim version (nvim -v)

NVIM v0.10.0-dev-345+g66b7f6254

Operating system/version

Fedora 38

Output of :AerialInfo

Aerial Info


Filetype: rust
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

When using the navigation window in a "parent" view and navigating ontop of a symbol with many children, such as a struct with many methods, the window will resize to accomodate the children shown on the right.

This is expected behavior.

However, this causes the window to shift and makes you lose track of your cursor. If repeatedly pressing up/down to navigate to your symbol the window will jump around to all different sizes which is distracting.

Steps To Reproduce

  1. Open a file with many nested symbols
  2. :AerialNavOpen
  3. jjjjjjjjj

Expected Behavior

What would be preferred would be a sticky size, so that it does not size down for a while, so that the window does not go 10, 16, 5, 32, 5 in height when pressing up, but rather stays a somewhat consistent size

Minimal example file

pub struct Foo {}

impl Foo {
    fn bar1(&self) {
        println!("Hello, world!");
    }
    fn bar2(&self) {
        println!("Hello, world!");
    }
    fn bar3(&self) {
        println!("Hello, world!");
    }
    fn bar4(&self) {
        println!("Hello, world!");
    }
    fn bar5(&self) {
        println!("Hello, world!");
    }
    fn bar6(&self) {
        println!("Hello, world!");
    }
    fn bar7(&self) {
        println!("Hello, world!");
    }
    fn bar8(&self) {
        println!("Hello, world!");
    }
    fn bar9(&self) {
        println!("Hello, world!");
    }
    fn bar10(&self) {
        println!("Hello, world!");
    }
    fn bar11(&self) {
        println!("Hello, world!");
    }
    fn bar12(&self) {
        println!("Hello, world!");
    }
    fn bar13(&self) {
        println!("Hello, world!");
    }
}

struct Baz {}

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

image

image

image

ten3roberts commented 1 year ago

Another solution would be to truncate the children to the size of parent list, so that it doesn't size up and down on j/k but only on l/h

Thanks for this great feature btw, ever since the start this plugin is just getting better and better :heart:

stevearc commented 1 year ago

If you want want to pin the window to a specific size, you can specify the height in the config opts. Would that work for you?

require("aerial").setup({
  nav = {
    height = 0.8,
  },
})