Skip to content

Commit

Permalink
feat: use edgy.nvim to define window layout. (#1393)
Browse files Browse the repository at this point in the history
* feat: use edgy.nvim to define window layout.

* perf: remove toggleterm workaround.

* fix: set aerial layout with edgy.

* refactor: use trouble to provide outline, remove aerial.

* style: eliminate duplicated code.

* fix: toggle edgy left.

* style: fix code style, use za to fold.
  • Loading branch information
ayamir authored Jan 15, 2025
1 parent f33b808 commit d7666c1
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 112 deletions.
7 changes: 3 additions & 4 deletions lua/keymap/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ function mapping.lsp(buf)
-- LSP-related keymaps, ONLY effective in buffers with LSP(s) attached
["n|<leader>li"] = map_cr("LspInfo"):with_silent():with_buffer(buf):with_desc("lsp: Info"),
["n|<leader>lr"] = map_cr("LspRestart"):with_silent():with_buffer(buf):with_nowait():with_desc("lsp: Restart"),
["n|go"] = map_cr("AerialToggle!"):with_silent():with_buffer(buf):with_desc("lsp: Toggle outline"),
["n|gto"] = map_callback(function()
require("telescope").extensions.aerial.aerial()
["n|go"] = map_callback(function()
require("edgy").toggle("right")
end)
:with_silent()
:with_buffer(buf)
:with_desc("lsp: Toggle outline in Telescope"),
:with_desc("lsp: Toggle outline"),
["n|g["] = map_cr("Lspsaga diagnostic_jump_prev")
:with_silent()
:with_buffer(buf)
Expand Down
9 changes: 8 additions & 1 deletion lua/keymap/tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ local vim_path = require("core.global").vim_path
require("keymap.helpers")

local plug_map = {
-- Plugin: edgy
["n|<C-n>"] = map_callback(function()
require("edgy").toggle("left")
end)
:with_noremap()
:with_silent()
:with_desc("filetree: Toggle"),

-- Plugin: vim-fugitive
["n|gps"] = map_cr("G push"):with_noremap():with_silent():with_desc("git: Push"),
["n|gpl"] = map_cr("G pull"):with_noremap():with_silent():with_desc("git: Pull"),
["n|<leader>gG"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"),

-- Plugin: nvim-tree
["n|<C-n>"] = map_cr("NvimTreeToggle"):with_noremap():with_silent():with_desc("filetree: Toggle"),
["n|<leader>nf"] = map_cr("NvimTreeFindFile"):with_noremap():with_silent():with_desc("filetree: Find file"),
["n|<leader>nr"] = map_cr("NvimTreeRefresh"):with_noremap():with_silent():with_desc("filetree: Refresh"),

Expand Down
80 changes: 0 additions & 80 deletions lua/modules/configs/completion/aerial.lua

This file was deleted.

8 changes: 0 additions & 8 deletions lua/modules/configs/tool/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ return function()
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
},
extensions = {
aerial = {
show_lines = false,
show_nesting = {
["_"] = false, -- This key will be the default
lua = true, -- You can set the option for specific filetypes
},
},
fzf = {
fuzzy = false,
override_generic_sorter = true,
Expand Down Expand Up @@ -97,6 +90,5 @@ return function()
require("telescope").load_extension("undo")
require("telescope").load_extension("zoxide")
require("telescope").load_extension("persisted")
require("telescope").load_extension("aerial")
require("telescope").load_extension("advanced_git_search")
end
12 changes: 1 addition & 11 deletions lua/modules/configs/tool/toggleterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,11 @@ return function()
return vim.o.columns * 0.40
end
end,
on_open = function(term)
on_open = function()
-- Prevent infinite calls from freezing neovim.
-- Only set these options specific to this terminal buffer.
vim.api.nvim_set_option_value("foldmethod", "manual", { scope = "local" })
vim.api.nvim_set_option_value("foldexpr", "0", { scope = "local" })

-- Prevent horizontal terminal from obscuring `nvim-tree`.
local api = require("nvim-tree.api")
local tree = require("nvim-tree.view")
if tree.is_visible() and term.direction == "horizontal" then
local width = vim.fn.winwidth(tree.get_winnr())
api.tree.toggle()
tree.View.width = width
api.tree.toggle(false, true)
end
end,
highlights = {
Normal = {
Expand Down
4 changes: 2 additions & 2 deletions lua/modules/configs/ui/bufferline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ return function()
padding = 0,
},
{
filetype = "aerial",
text = "Symbol Outline",
filetype = "trouble",
text = "LSP Outline",
text_align = "center",
padding = 0,
},
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/ui/catppuccin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ return function()
information = { "underline" },
},
},
aerial = true,
aerial = false,
alpha = false,
barbar = false,
beacon = false,
Expand Down
95 changes: 95 additions & 0 deletions lua/modules/configs/ui/edgy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
return function()
local trouble_filter = function(position)
return function(_, win)
return vim.w[win].trouble
and vim.w[win].trouble.position == position
and vim.w[win].trouble.type == "split"
and vim.w[win].trouble.relative == "editor"
and not vim.w[win].trouble_preview
end
end

require("modules.utils").load_plugin("edgy", {
animate = {
enabled = true,
},
wo = {
winbar = false,
},
exit_when_last = true,
close_when_all_hidden = true,
keys = {
["q"] = false,
["Q"] = false,
["<c-q>"] = false,
["za"] = function(win)
win:toggle()
end,
["<A-i>"] = function(win)
win:next({ focus = true })
end,
["<A-o>"] = function(win)
win:prev({ focus = true })
end,
["<A-j>"] = function(win)
win:resize("height", -2)
end,
["<A-k>"] = function(win)
win:resize("height", 2)
end,
["<A-h>"] = function(win)
win:resize("width", -2)
end,
["<A-l>"] = function(win)
win:resize("width", 2)
end,
},
bottom = {
{ ft = "qf", size = { height = 0.3 } },
{
ft = "toggleterm",
size = { height = 0.3 },
filter = function(_, win)
return vim.api.nvim_win_get_config(win).relative == ""
end,
},
{
ft = "help",
size = { height = 20 },
filter = function(buf)
return vim.bo[buf].buftype == "help"
end,
},
},
left = {
{
ft = "NvimTree",
pinned = true,
collapsed = false,
open = "NvimTreeOpen",
size = {
height = 0.5,
width = 40,
},
},
},
right = {
{
ft = "trouble",
pinned = true,
collapsed = false,
size = { height = 0.6, width = 0.2 },
open = "Trouble symbols toggle win.position=right",
filter = trouble_filter("right"),
},
{
ft = "trouble",
pinned = true,
collapsed = true,
size = { height = 0.4, width = 0.2 },
open = "Trouble lsp toggle win.position=right",
filter = trouble_filter("right"),
},
},
})
end
5 changes: 0 additions & 5 deletions lua/modules/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ completion["nvimdev/lspsaga.nvim"] = {
config = require("completion.lspsaga"),
dependencies = { "nvim-tree/nvim-web-devicons" },
}
completion["stevearc/aerial.nvim"] = {
lazy = true,
event = "LspAttach",
config = require("completion.aerial"),
}
completion["DNLHC/glance.nvim"] = {
lazy = true,
event = "LspAttach",
Expand Down
4 changes: 4 additions & 0 deletions lua/modules/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ ui["dstein64/nvim-scrollview"] = {
event = { "BufReadPost", "BufAdd", "BufNewFile" },
config = require("ui.scrollview"),
}
ui["folke/edgy.nvim"] = {
event = "VeryLazy",
config = require("ui.edgy"),
}

return ui

0 comments on commit d7666c1

Please sign in to comment.