stevearc / aerial.nvim

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

bug: need to delete the keymaps before mapping a new one #358

Closed XXiaoA closed 2 months ago

XXiaoA commented 2 months ago

Neovim version (nvim -v)

NVIM v0.10.0-dev-2789+gd9235efa76

Operating system/version

Archlinux

Output of :AerialInfo

Aerial Info


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

Describe the bug

I map my zm in normal mode and aerial do so. Therefore, it cause a conflict. I think we ought to check if the keymap exists, and then delete it before we map it to a new functionality.

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

  1. nvim -u repro.lua repro.lua
  2. open aerial
  3. press zm

Expected Behavior

fold in the aerial only

Minimal example file

same as the repro.lua

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
    {
        "kevinhwang91/nvim-ufo",
        dependencies = { "kevinhwang91/promise-async" },
        opts = {},
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
vim.o.foldcolumn = "1" -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
vim.keymap.set("n", "zm", require("ufo").closeAllFolds)

Additional context

https://github.com/stevearc/aerial.nvim/assets/62557596/734d2c73-1b31-4b0e-ac21-4248c6894936

XXiaoA commented 2 months ago

Well..... it is not a bug. Instead, it is feature, named link_tree_to_folds