Skip to main content

edgy.nvim

info

You can enable the extra with the :LazyExtras command. Plugins marked as optional will only be configured if they are installed.

Below you can find a list of included plugins and their default settings.

caution

You don't need to copy the default settings to your config. They are only shown here for reference.

edgy.nvim

Create and display predefined window layouts.

opts = function()
local opts = {
bottom = {
{
ft = "toggleterm",
size = { height = 0.4 },
filter = function(buf, win)
return vim.api.nvim_win_get_config(win).relative == ""
end,
},
{
ft = "noice",
size = { height = 0.4 },
filter = function(buf, win)
return vim.api.nvim_win_get_config(win).relative == ""
end,
},
"Trouble",
{ ft = "qf", title = "QuickFix" },
{
ft = "help",
size = { height = 20 },
-- don't open help files in edgy that we're editing
filter = function(buf)
return vim.bo[buf].buftype == "help"
end,
},
{ title = "Spectre", ft = "spectre_panel", size = { height = 0.4 } },
{ title = "Neotest Output", ft = "neotest-output-panel", size = { height = 15 } },
},
left = {
{ title = "Neotest Summary", ft = "neotest-summary" },
-- "neo-tree",
},
right = {
{ title = "Grug Far", ft = "grug-far", size = { width = 0.4 } },
},
keys = {
-- increase width
["<c-Right>"] = function(win)
win:resize("width", 2)
end,
-- decrease width
["<c-Left>"] = function(win)
win:resize("width", -2)
end,
-- increase height
["<c-Up>"] = function(win)
win:resize("height", 2)
end,
-- decrease height
["<c-Down>"] = function(win)
win:resize("height", -2)
end,
},
}

if LazyVim.has("neo-tree.nvim") then
local pos = {
filesystem = "left",
buffers = "top",
git_status = "right",
document_symbols = "bottom",
diagnostics = "bottom",
}
local sources = LazyVim.opts("neo-tree.nvim").sources or {}
for i, v in ipairs(sources) do
table.insert(opts.left, i, {
title = "Neo-Tree " .. v:gsub("_", " "):gsub("^%l", string.upper),
ft = "neo-tree",
filter = function(buf)
return vim.b[buf].neo_tree_source == v
end,
pinned = true,
open = function()
vim.cmd(("Neotree show position=%s %s dir=%s"):format(pos[v] or "bottom", v, LazyVim.root()))
end,
})
end
end

-- trouble
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
opts[pos] = opts[pos] or {}
table.insert(opts[pos], {
ft = "trouble",
filter = function(_buf, win)
return vim.w[win].trouble
and vim.w[win].trouble.position == pos
and vim.w[win].trouble.type == "split"
and vim.w[win].trouble.relative == "editor"
and not vim.w[win].trouble_preview
end,
})
end

-- snacks terminal
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
opts[pos] = opts[pos] or {}
table.insert(opts[pos], {
ft = "snacks_terminal",
size = { height = 0.4 },
title = "%{b:snacks_terminal.id}: %{b:term_title}",
filter = function(_buf, win)
return vim.w[win].snacks_win
and vim.w[win].snacks_win.position == pos
and vim.w[win].snacks_win.relative == "editor"
and not vim.w[win].trouble_preview
end,
})
end
return opts
end

telescope.nvim (optional)

use edgy's selection window

opts = {
defaults = {
get_selection_window = function()
require("edgy").goto_main()
return 0
end,
},
}

neo-tree.nvim (optional)

prevent neo-tree from opening files in edgy windows

opts = function(_, opts)
opts.open_files_do_not_replace_types = opts.open_files_do_not_replace_types
or { "terminal", "Trouble", "qf", "Outline", "trouble" }
table.insert(opts.open_files_do_not_replace_types, "edgy")
end

bufferline.nvim (optional)

Fix bufferline offsets when edgy is loaded

opts = function()
local Offset = require("bufferline.offset")
if not Offset.edgy then
local get = Offset.get
Offset.get = function()
if package.loaded.edgy then
local old_offset = get()
local layout = require("edgy.config").layout
local ret = { left = "", left_size = 0, right = "", right_size = 0 }
for _, pos in ipairs({ "left", "right" }) do
local sb = layout[pos]
local title = " Sidebar" .. string.rep(" ", sb.bounds.width - 8)
if sb and #sb.wins > 0 then
ret[pos] = old_offset[pos .. "_size"] > 0 and old_offset[pos]
or pos == "left" and ("%#Bold#" .. title .. "%*" .. "%#BufferLineOffsetSeparator#│%*")
or pos == "right" and ("%#BufferLineOffsetSeparator#│%*" .. "%#Bold#" .. title .. "%*")
ret[pos .. "_size"] = old_offset[pos .. "_size"] > 0 and old_offset[pos .. "_size"] or sb.bounds.width
end
end
ret.total_size = ret.left_size + ret.right_size
if ret.total_size > 0 then
return ret
end
end
return get()
end
Offset.edgy = true
end
end