folke / edgy.nvim

Easily create and manage predefined window layouts, bringing a new edge to your workflow
Apache License 2.0
840 stars 17 forks source link

bug: inconsistent folding with dynamic titles / winbar #57

Closed willothy closed 2 months ago

willothy commented 11 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM 0.10 nightly

Operating system/version

Arch Linux, 6.5.2-arch1-1

Describe the bug

When using dynamic titles (title = "%{%v:lua.custom_edgy_title()%}"), the width of a window is not calculated properly when folded. This leads to some windows getting wider when folded because highlight attrs / the result of the expr are not accounted for.

Steps To Reproduce

  1. Create an edgy view for a filetype in the bottom or top view (where title width affects folded width).
  2. Create a custom title function in the global namespace
  3. Open the view, and another view next to it so it can be folded (terminal and qf in minimal init)
  4. Fold the view

The width of the folded view will not be the same as the actual text width of the winbar.

Expected Behavior

The window should be folded to the text width of the winbar.

Repro

-- 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", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/edgy.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

function _G.custom_edgy_title()
  return "%#EdgyTitle#Test%#*"
end

require("edgy").setup({
  bottom = {
    {
      ft = "qf",
      title = "%{%v:lua.custom_edgy_title()%}",
    },
    {
      ft = "terminal",
      title = "%{%v:lua.custom_edgy_title()%}",
    },
  },
})

vim.api.nvim_create_autocmd("TermOpen", {
  callback = function(ev)
    vim.bo[ev.buf].filetype = "terminal"
  end
})
github-actions[bot] commented 3 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 2 months ago

This issue was closed because it has been stalled for 7 days with no activity.