stevearc / aerial.nvim

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

Revert window ignore → closes #369 #370

Closed Zeioth closed 1 month ago

Zeioth commented 1 month ago

Reverts https://github.com/stevearc/aerial.nvim/commit/51a07949abf169b4cad30e14c165ac1ec0ce4e6f

Closes: #369

stevearc commented 1 month ago

This means that the behavior would go back to not opening Aerial at all if you toggle it in the Neotree buffer. Is that a better situation than this one?

Another thing to look into: if you want aerial to stick to the right edge of your editor, you can set the options

require("aerial").setup({
  layout = {
    default_direction = "right",
    placement = "edge",
  }
})

Would that solve your issue?

Zeioth commented 1 month ago

@stevearc That solution works fine steve thank you:

How I've tested

Happy day scenario

I've focused neotree and opened aerial screenshot_2024-05-06_21-40-26_072753969

It opens in the correct position, and once I click the code, aerial is populated correctly screenshot_2024-05-06_21-40-31_743902030

Bad day scenario

It is still possible to fuck the UI when performing obscure actions such as

This is already better, but maybe I would still revert, or check that out. Up to you.

Zeioth commented 1 month ago

If I repeat that I can spawn infinite aerials screenshot_2024-05-06_21-50-55_265972373

stevearc commented 1 month ago

@Zeioth Try setting the attach_mode as well

require("aerial").setup({
  layout = {
    default_direction = "right",
    placement = "edge",
  },
  attach_mode = "global"
})
Zeioth commented 1 month ago

I had it already. Full config:

{
    "stevearc/aerial.nvim",
    event = "VeryLazy",
    opts = {
      ignore = {
        buftypes = { "nofile" },
      },
      filter_kind = { -- Symbols that will appear on the tree
        -- "Class",
        "Constructor",
        "Enum",
        "Function",
        "Interface",
        -- "Module",
        "Method",
        -- "Struct",
      },
      open_automatic = false, -- Open if the buffer is compatible
      autojump = true,
      link_folds_to_tree = false,
      link_tree_to_folds = false,
      attach_mode = "global",
      backends = { "lsp", "treesitter", "markdown", "man" },
      disable_max_lines = vim.g.big_file.lines,
      disable_max_size = vim.g.big_file.size,
      layout = {
        min_width = 28,
        default_direction = "right",
        placement = "edge",
      },
      show_guides = true,
      guides = {
        mid_item = "├ ",
        last_item = "└ ",
        nested_top = "│ ",
        whitespace = "  ",
      },
      keymaps = {
        ["[y"] = "actions.prev",
        ["]y"] = "actions.next",
        ["[Y"] = "actions.prev_up",
        ["]Y"] = "actions.next_up",
        ["{"] = false,
        ["}"] = false,
        ["[["] = false,
        ["]]"] = false,
      },
    },
    config = function(_, opts)
      require("aerial").setup(opts)
      -- HACK: The first time you opened aerial on a session, close all folds.
      vim.api.nvim_create_autocmd("FileType", {
        desc = "Aerial: The first time its open on a session, close all folds.",
        callback = function()
          local is_aerial = vim.bo.filetype == "aerial"
          local is_ufo_available = require("base.utils").is_available("nvim-ufo")
          if is_ufo_available and is_aerial and vim.g.new_aerial_session == nil then
            vim.g.new_aerial_session = false
            require("aerial").tree_set_collapse_level(0, 0)
          end
        end,
      })
    end
  },
stevearc commented 1 month ago

@Zeioth I believe I've fixed the issue with multiple aerial windows opening when attach_mode = "global". I think this was the last bug in this scenario, so I'm closing this PR (it seems unlikely that we would want to revert this change anyway). If there are still problems, feel free to continue the discussion on the linked issue or create a new issue