|
| 1 | +return { |
| 2 | + -- edgy |
| 3 | + { |
| 4 | + "folke/edgy.nvim", |
| 5 | + event = "VeryLazy", |
| 6 | + keys = { |
| 7 | + { |
| 8 | + "<leader>ue", |
| 9 | + function() |
| 10 | + require("edgy").toggle() |
| 11 | + end, |
| 12 | + desc = "Edgy Toggle", |
| 13 | + }, |
| 14 | + -- stylua: ignore |
| 15 | + { "<leader>uE", function() require("edgy").select() end, desc = "Edgy Select Window" }, |
| 16 | + }, |
| 17 | + opts = function() |
| 18 | + local opts = { |
| 19 | + bottom = { |
| 20 | + { |
| 21 | + ft = "toggleterm", |
| 22 | + size = { height = 0.25 }, |
| 23 | + title = "Terminal", |
| 24 | + pinned = true, -- Ensures the terminal stays in the same window |
| 25 | + filter = function(buf, win) |
| 26 | + return vim.api.nvim_win_get_config(win).relative == "" |
| 27 | + end, |
| 28 | + }, |
| 29 | + { |
| 30 | + ft = "noice", |
| 31 | + size = { height = 0.25 }, |
| 32 | + filter = function(buf, win) |
| 33 | + return vim.api.nvim_win_get_config(win).relative == "" |
| 34 | + end, |
| 35 | + }, |
| 36 | + "Trouble", |
| 37 | + { ft = "qf", title = "QuickFix" }, |
| 38 | + { |
| 39 | + ft = "help", |
| 40 | + size = { height = 20 }, |
| 41 | + -- don't open help files in edgy that we're editing |
| 42 | + filter = function(buf) |
| 43 | + return vim.bo[buf].buftype == "help" |
| 44 | + end, |
| 45 | + }, |
| 46 | + { title = "Spectre", ft = "spectre_panel", size = { height = 0.4 } }, |
| 47 | + { title = "Neotest Output", ft = "neotest-output-panel", size = { height = 15 } }, |
| 48 | + }, |
| 49 | + left = { |
| 50 | + { title = "Neotest Summary", ft = "neotest-summary" }, |
| 51 | + -- "neo-tree", |
| 52 | + }, |
| 53 | + right = { |
| 54 | + { title = "Grug Far", ft = "grug-far", size = { width = 0.4 } }, |
| 55 | + }, |
| 56 | + keys = { |
| 57 | + -- increase width |
| 58 | + ["<c-Right>"] = function(win) |
| 59 | + win:resize("width", 2) |
| 60 | + end, |
| 61 | + -- decrease width |
| 62 | + ["<c-Left>"] = function(win) |
| 63 | + win:resize("width", -2) |
| 64 | + end, |
| 65 | + -- increase height |
| 66 | + ["<c-Up>"] = function(win) |
| 67 | + win:resize("height", 2) |
| 68 | + end, |
| 69 | + -- decrease height |
| 70 | + ["<c-Down>"] = function(win) |
| 71 | + win:resize("height", -2) |
| 72 | + end, |
| 73 | + }, |
| 74 | + } |
| 75 | + |
| 76 | + if LazyVim.has("neo-tree.nvim") then |
| 77 | + local pos = { |
| 78 | + filesystem = "left", |
| 79 | + buffers = "top", |
| 80 | + git_status = "right", |
| 81 | + document_symbols = "bottom", |
| 82 | + diagnostics = "bottom", |
| 83 | + } |
| 84 | + local sources = LazyVim.opts("neo-tree.nvim").sources or {} |
| 85 | + for i, v in ipairs(sources) do |
| 86 | + table.insert(opts.left, i, { |
| 87 | + title = "Neo-Tree " .. v:gsub("_", " "):gsub("^%l", string.upper), |
| 88 | + ft = "neo-tree", |
| 89 | + filter = function(buf) |
| 90 | + return vim.b[buf].neo_tree_source == v |
| 91 | + end, |
| 92 | + pinned = true, |
| 93 | + open = function() |
| 94 | + vim.cmd(("Neotree show position=%s %s dir=%s"):format(pos[v] or "bottom", v, LazyVim.root())) |
| 95 | + end, |
| 96 | + }) |
| 97 | + end |
| 98 | + end |
| 99 | + |
| 100 | + -- trouble |
| 101 | + for _, pos in ipairs({ "top", "bottom", "left", "right" }) do |
| 102 | + opts[pos] = opts[pos] or {} |
| 103 | + table.insert(opts[pos], { |
| 104 | + ft = "trouble", |
| 105 | + filter = function(_buf, win) |
| 106 | + return vim.w[win].trouble |
| 107 | + and vim.w[win].trouble.position == pos |
| 108 | + and vim.w[win].trouble.type == "split" |
| 109 | + and vim.w[win].trouble.relative == "editor" |
| 110 | + and not vim.w[win].trouble_preview |
| 111 | + end, |
| 112 | + }) |
| 113 | + end |
| 114 | + |
| 115 | + -- snacks terminal |
| 116 | + for _, pos in ipairs({ "top", "bottom", "left", "right" }) do |
| 117 | + opts[pos] = opts[pos] or {} |
| 118 | + table.insert(opts[pos], { |
| 119 | + ft = "snacks_terminal", |
| 120 | + size = { height = 0.4 }, |
| 121 | + title = "%{b:snacks_terminal.id}: %{b:term_title}", |
| 122 | + filter = function(_buf, win) |
| 123 | + return vim.w[win].snacks_win |
| 124 | + and vim.w[win].snacks_win.position == pos |
| 125 | + and vim.w[win].snacks_win.relative == "editor" |
| 126 | + and not vim.w[win].trouble_preview |
| 127 | + end, |
| 128 | + }) |
| 129 | + end |
| 130 | + return opts |
| 131 | + end, |
| 132 | + }, |
| 133 | + |
| 134 | + -- use edgy's selection window |
| 135 | + { |
| 136 | + "nvim-telescope/telescope.nvim", |
| 137 | + optional = true, |
| 138 | + opts = { |
| 139 | + defaults = { |
| 140 | + get_selection_window = function() |
| 141 | + require("edgy").goto_main() |
| 142 | + return 0 |
| 143 | + end, |
| 144 | + }, |
| 145 | + }, |
| 146 | + }, |
| 147 | + |
| 148 | + -- prevent neo-tree from opening files in edgy windows |
| 149 | + { |
| 150 | + "nvim-neo-tree/neo-tree.nvim", |
| 151 | + optional = true, |
| 152 | + opts = function(_, opts) |
| 153 | + opts.open_files_do_not_replace_types = opts.open_files_do_not_replace_types |
| 154 | + or { "terminal", "Trouble", "qf", "Outline", "trouble" } |
| 155 | + table.insert(opts.open_files_do_not_replace_types, "edgy") |
| 156 | + end, |
| 157 | + }, |
| 158 | + |
| 159 | + -- Fix bufferline offsets when edgy is loaded |
| 160 | + { |
| 161 | + "akinsho/bufferline.nvim", |
| 162 | + optional = true, |
| 163 | + opts = function() |
| 164 | + local Offset = require("bufferline.offset") |
| 165 | + if not Offset.edgy then |
| 166 | + local get = Offset.get |
| 167 | + Offset.get = function() |
| 168 | + if package.loaded.edgy then |
| 169 | + local old_offset = get() |
| 170 | + local layout = require("edgy.config").layout |
| 171 | + local ret = { left = "", left_size = 0, right = "", right_size = 0 } |
| 172 | + for _, pos in ipairs({ "left", "right" }) do |
| 173 | + local sb = layout[pos] |
| 174 | + local title = " Sidebar" .. string.rep(" ", sb.bounds.width - 8) |
| 175 | + if sb and #sb.wins > 0 then |
| 176 | + ret[pos] = old_offset[pos .. "_size"] > 0 and old_offset[pos] |
| 177 | + or pos == "left" and ("%#Bold#" .. title .. "%*" .. "%#BufferLineOffsetSeparator#│%*") |
| 178 | + or pos == "right" and ("%#BufferLineOffsetSeparator#│%*" .. "%#Bold#" .. title .. "%*") |
| 179 | + ret[pos .. "_size"] = old_offset[pos .. "_size"] > 0 and old_offset[pos .. "_size"] or sb.bounds.width |
| 180 | + end |
| 181 | + end |
| 182 | + ret.total_size = ret.left_size + ret.right_size |
| 183 | + if ret.total_size > 0 then |
| 184 | + return ret |
| 185 | + end |
| 186 | + end |
| 187 | + return get() |
| 188 | + end |
| 189 | + Offset.edgy = true |
| 190 | + end |
| 191 | + end, |
| 192 | + }, |
| 193 | +} |
0 commit comments