MunifTanjim / nui.nvim

UI Component Library for Neovim.
MIT License
1.62k stars 57 forks source link

Popup "Hides" Under Another #307

Closed harrisoncramer closed 11 months ago

harrisoncramer commented 11 months ago

I'm trying to build a layout that looks like the following, where the top and bottom sections are predefined in size and the middle section grows to fill the remaining available container:

Screenshot 2023-11-15 at 10 14 30 PM

Here's the code:

local Layout = require("nui.layout")
local Popup = require("nui.popup")

local opts = {
  buf_options = {
    filetype = "markdown",
  },
  focusable = true,
  border = {
    style = "rounded",
  },
}

local box_one = Popup(opts)
local box_two = Popup(opts)
local box_three = Popup(opts)

local layout = Layout(
  {
    position = "50%",
    relative = "editor",
    size = {
      width = "95%",
      height = "95%",
    },
  },
  Layout.Box({
    Layout.Box(box_one, { size = { height = 3 } }),
    Layout.Box({
      Layout.Box(box_two, { grow = 1 }),
      Layout.Box(box_three, { size = { height = 15 } }),
    }, { dir = "col", size = "100%" }),
  }, { dir = "col" })
)

layout:mount()

For some reason, it looks like box one and box two overlap, and when one is focused (either one) it hides the content in the other box. Am I doing something wrong here?

MunifTanjim commented 11 months ago

Try this instead?

local layout = Layout(
  {
    position = "50%",
    relative = "editor",
    size = {
      width = "95%",
      height = "95%",
    },
  },
  Layout.Box({
    Layout.Box(box_one, { size = 3 }),
    Layout.Box(box_two, { grow = 1 }),
    Layout.Box(box_three, { size = 15 }),
  }, { dir = "col" })
)
harrisoncramer commented 11 months ago

Wow thank you very much, it's quite simple! Thank you!