stevearc / aerial.nvim

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

bug: ```next()``` and ```prev()``` don't always work in visual mode if cursor is on a folded line #367

Open sxwpb opened 2 months ago

sxwpb commented 2 months ago

Neovim version (nvim -v)

NVIM v0.9.4

Operating system/version

fedora 39

Output of :AerialInfo

Aerial Info
-----------
Filetype: html
Configured backends:
  treesitter (supported) (attached)
Show symbols: Class, Constructor, Enum, Function, Interface, Module, Method, Struct

Describe the bug

see title

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

  1. nvim -u repro.lua example-file.html
  2. :AerialOpen
  3. :norm jl
  4. :wincmd p
  5. :3,6 fold
  6. :7|norm Vk

now <M-9> (which is mapped to next() ) does not work.

Expected Behavior

The cursor should move to the next symbol in accordance to the visible aerial symbol structure

Minimal example file

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Website</title>
  </head>
  <body>
    <main>
      <h1>heading</h1>
      <p>text1</p>
      <p>text2</p>
      <p>text3</p>
    </main>
  </body>
</html>

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
        backends = {
          ['_'] = { 'lsp' },
          html = { 'treesitter' },
        },

        manage_folds = false,
        link_tree_to_folds = false,
        link_folds_to_tree = false,

        on_first_symbols = function(bufnr)
          require("aerial").tree_set_collapse_level(bufnr, 0)
        end,

      })

      vim.keymap.set({'n','v'},'<M-8>', function() require('aerial').prev() end,{noremap = true, silent = true})
      vim.keymap.set({'n','v'},'<M-9>', function() require('aerial').next() end,{noremap = true, silent = true})

    end,
  },
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require("nvim-treesitter.configs").setup({
        ensure_installed = { "lua", "html" },
        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