From da02fa05bd8061ba60bc0d0f12b28c52943135ba Mon Sep 17 00:00:00 2001 From: ayamir Date: Thu, 9 Jan 2025 20:48:03 +0800 Subject: [PATCH 1/7] feat: use edgy.nvim to define window layout. --- lua/modules/configs/ui/edgy.lua | 33 +++++++++++++++++++++++++++++++++ lua/modules/plugins/ui.lua | 4 ++++ 2 files changed, 37 insertions(+) create mode 100644 lua/modules/configs/ui/edgy.lua diff --git a/lua/modules/configs/ui/edgy.lua b/lua/modules/configs/ui/edgy.lua new file mode 100644 index 000000000..86d39095b --- /dev/null +++ b/lua/modules/configs/ui/edgy.lua @@ -0,0 +1,33 @@ +return function() + require("modules.utils").load_plugin("edgy", { + animate = { + enabled = false, + }, + wo = { + winbar = false, + }, + exit_when_last = true, + close_when_all_hidden = true, + bottom = { + { ft = "qf", size = { height = 0.3 } }, + { ft = "trouble", 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", size = { height = 0.5 } }, + }, + }) +end diff --git a/lua/modules/plugins/ui.lua b/lua/modules/plugins/ui.lua index 3d62237e1..2fa399368 100644 --- a/lua/modules/plugins/ui.lua +++ b/lua/modules/plugins/ui.lua @@ -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 From 1a1156e5c403d24291f016407386216427960cd6 Mon Sep 17 00:00:00 2001 From: ayamir Date: Thu, 9 Jan 2025 20:56:49 +0800 Subject: [PATCH 2/7] perf: remove toggleterm workaround. --- lua/modules/configs/tool/toggleterm.lua | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lua/modules/configs/tool/toggleterm.lua b/lua/modules/configs/tool/toggleterm.lua index 8e12a29e2..4cee6cf69 100644 --- a/lua/modules/configs/tool/toggleterm.lua +++ b/lua/modules/configs/tool/toggleterm.lua @@ -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 = { From bd71c7416e8bf1a6ba5fdb489d26ba8e08604fc6 Mon Sep 17 00:00:00 2001 From: ayamir Date: Thu, 9 Jan 2025 20:59:32 +0800 Subject: [PATCH 3/7] fix: set aerial layout with edgy. --- lua/modules/configs/ui/edgy.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/modules/configs/ui/edgy.lua b/lua/modules/configs/ui/edgy.lua index 86d39095b..c0214b972 100644 --- a/lua/modules/configs/ui/edgy.lua +++ b/lua/modules/configs/ui/edgy.lua @@ -29,5 +29,8 @@ return function() left = { { ft = "NvimTree", size = { height = 0.5 } }, }, + right = { + { ft = "aerial", size = { width = 30 } }, + }, }) end From ddebcd09fe322f4ce33917b631e570a1cbf1d57f Mon Sep 17 00:00:00 2001 From: ayamir Date: Fri, 10 Jan 2025 21:39:20 +0800 Subject: [PATCH 4/7] refactor: use trouble to provide outline, remove aerial. --- lua/keymap/completion.lua | 7 +- lua/modules/configs/completion/aerial.lua | 80 ----------------------- lua/modules/configs/tool/telescope.lua | 8 --- lua/modules/configs/ui/bufferline.lua | 4 +- lua/modules/configs/ui/catppuccin.lua | 2 +- lua/modules/configs/ui/edgy.lua | 75 +++++++++++++++++++-- lua/modules/plugins/completion.lua | 5 -- 7 files changed, 77 insertions(+), 104 deletions(-) delete mode 100644 lua/modules/configs/completion/aerial.lua diff --git a/lua/keymap/completion.lua b/lua/keymap/completion.lua index 3b0628a0c..d9d4dfdcc 100644 --- a/lua/keymap/completion.lua +++ b/lua/keymap/completion.lua @@ -16,13 +16,12 @@ function mapping.lsp(buf) -- LSP-related keymaps, ONLY effective in buffers with LSP(s) attached ["n|li"] = map_cr("LspInfo"):with_silent():with_buffer(buf):with_desc("lsp: Info"), ["n|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) diff --git a/lua/modules/configs/completion/aerial.lua b/lua/modules/configs/completion/aerial.lua deleted file mode 100644 index 4c89afd5a..000000000 --- a/lua/modules/configs/completion/aerial.lua +++ /dev/null @@ -1,80 +0,0 @@ -return function() - require("modules.utils").load_plugin("aerial", { - lazy_load = false, - close_on_select = true, - highlight_on_jump = false, - disable_max_lines = 8500, - disable_max_size = 1000000, - ignore = { filetypes = { "NvimTree", "terminal", "nofile" } }, - -- Use symbol tree for folding. Set to true or false to enable/disable - -- Set to "auto" to manage folds if your previous foldmethod was 'manual' - -- This can be a filetype map (see :help aerial-filetype-map) - manage_folds = "auto", - layout = { - -- Determines the default direction to open the aerial window. The 'prefer' - -- options will open the window in the other direction *if* there is a - -- different buffer in the way of the preferred direction - -- Enum: prefer_right, prefer_left, right, left, float - default_direction = "prefer_right", - }, - -- Keymaps in aerial window. Can be any value that `vim.keymap.set` accepts OR a table of keymap - -- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true }) - -- Additionally, if it is a string that matches "actions.", - -- it will use the mapping at require("aerial.actions"). - -- Set to `false` to remove a keymap - keymaps = { - ["?"] = "actions.show_help", - ["g?"] = "actions.show_help", - [""] = "actions.jump", - ["<2-LeftMouse>"] = "actions.jump", - [""] = "actions.jump_vsplit", - [""] = "actions.jump_split", - [""] = "actions.down_and_scroll", - [""] = "actions.up_and_scroll", - ["{"] = "actions.prev", - ["}"] = "actions.next", - ["[["] = "actions.prev_up", - ["]]"] = "actions.next_up", - ["q"] = "actions.close", - ["o"] = "actions.tree_toggle", - ["O"] = "actions.tree_toggle_recursive", - ["zr"] = "actions.tree_increase_fold_level", - ["zR"] = "actions.tree_open_all", - ["zm"] = "actions.tree_decrease_fold_level", - ["zM"] = "actions.tree_close_all", - ["zx"] = "actions.tree_sync_folds", - ["zX"] = "actions.tree_sync_folds", - }, - -- A list of all symbols to display. Set to false to display all symbols. - -- This can be a filetype map (see :help aerial-filetype-map) - -- To see all available values, see :help SymbolKind - filter_kind = { - "Array", - "Boolean", - "Class", - "Constant", - "Constructor", - "Enum", - "EnumMember", - "Event", - "Field", - "File", - "Function", - "Interface", - "Key", - "Method", - "Module", - "Namespace", - "Null", - -- "Number", - "Object", - "Operator", - "Package", - -- "Property", - -- "String", - "Struct", - -- "TypeParameter", - -- "Variable", - }, - }) -end diff --git a/lua/modules/configs/tool/telescope.lua b/lua/modules/configs/tool/telescope.lua index 71884d085..eb096fb78 100644 --- a/lua/modules/configs/tool/telescope.lua +++ b/lua/modules/configs/tool/telescope.lua @@ -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, @@ -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 diff --git a/lua/modules/configs/ui/bufferline.lua b/lua/modules/configs/ui/bufferline.lua index b01200d3f..5898e18f9 100644 --- a/lua/modules/configs/ui/bufferline.lua +++ b/lua/modules/configs/ui/bufferline.lua @@ -34,8 +34,8 @@ return function() padding = 0, }, { - filetype = "aerial", - text = "Symbol Outline", + filetype = "trouble", + text = "LSP Outline", text_align = "center", padding = 0, }, diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index 2af1da1c6..f30bcd1d5 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -46,7 +46,7 @@ return function() information = { "underline" }, }, }, - aerial = true, + aerial = false, alpha = false, barbar = false, beacon = false, diff --git a/lua/modules/configs/ui/edgy.lua b/lua/modules/configs/ui/edgy.lua index c0214b972..1bcdbfe4c 100644 --- a/lua/modules/configs/ui/edgy.lua +++ b/lua/modules/configs/ui/edgy.lua @@ -1,16 +1,41 @@ return function() require("modules.utils").load_plugin("edgy", { animate = { - enabled = false, + enabled = true, }, wo = { winbar = false, }, exit_when_last = true, close_when_all_hidden = true, + keys = { + ["q"] = false, + ["Q"] = false, + [""] = false, + ["zz"] = function(win) + win:toggle() + end, + [""] = function(win) + win:next({ focus = true }) + end, + [""] = function(win) + win:prev({ focus = true }) + end, + [""] = function(win) + win:resize("height", -2) + end, + [""] = function(win) + win:resize("height", 2) + end, + [""] = function(win) + win:resize("width", -2) + end, + [""] = function(win) + win:resize("width", 2) + end, + }, bottom = { { ft = "qf", size = { height = 0.3 } }, - { ft = "trouble", size = { height = 0.3 } }, { ft = "toggleterm", size = { height = 0.3 }, @@ -27,10 +52,52 @@ return function() }, }, left = { - { ft = "NvimTree", size = { height = 0.5 } }, + { + ft = "NvimTree", + pinned = true, + collapsed = false, + open = "NvimTreeOpen", + size = { + height = 0.5, + width = 40, + }, + }, }, right = { - { ft = "aerial", size = { width = 30 } }, + { + ft = "trouble", + pinned = true, + collapsed = false, + open = "Trouble symbols toggle win.position=right", + filter = function(_, win) + return vim.w[win].trouble + and vim.w[win].trouble.position == "right" + and vim.w[win].trouble.type == "split" + and vim.w[win].trouble.relative == "editor" + and not vim.w[win].trouble_preview + end, + size = { + height = 0.5, + width = 0.2, + }, + }, + { + ft = "trouble", + pinned = true, + collapsed = true, + open = "Trouble lsp toggle win.position=right", + filter = function(_, win) + return vim.w[win].trouble + and vim.w[win].trouble.position == "right" + and vim.w[win].trouble.type == "split" + and vim.w[win].trouble.relative == "editor" + and not vim.w[win].trouble_preview + end, + size = { + height = 0.3, + width = 0.2, + }, + }, }, }) end diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index af694f73f..277e3d134 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -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", From c00337fdaeaa02ad7a669da57bc89ffaee534998 Mon Sep 17 00:00:00 2001 From: ayamir Date: Fri, 10 Jan 2025 21:42:36 +0800 Subject: [PATCH 5/7] style: eliminate duplicated code. --- lua/modules/configs/ui/edgy.lua | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lua/modules/configs/ui/edgy.lua b/lua/modules/configs/ui/edgy.lua index 1bcdbfe4c..5a7960fcf 100644 --- a/lua/modules/configs/ui/edgy.lua +++ b/lua/modules/configs/ui/edgy.lua @@ -1,4 +1,12 @@ return function() + local trouble_filter = function(_, win) + return vim.w[win].trouble + and vim.w[win].trouble.position == "right" + and vim.w[win].trouble.type == "split" + and vim.w[win].trouble.relative == "editor" + and not vim.w[win].trouble_preview + end + require("modules.utils").load_plugin("edgy", { animate = { enabled = true, @@ -69,13 +77,7 @@ return function() pinned = true, collapsed = false, open = "Trouble symbols toggle win.position=right", - filter = function(_, win) - return vim.w[win].trouble - and vim.w[win].trouble.position == "right" - and vim.w[win].trouble.type == "split" - and vim.w[win].trouble.relative == "editor" - and not vim.w[win].trouble_preview - end, + filter = trouble_filter, size = { height = 0.5, width = 0.2, @@ -86,13 +88,7 @@ return function() pinned = true, collapsed = true, open = "Trouble lsp toggle win.position=right", - filter = function(_, win) - return vim.w[win].trouble - and vim.w[win].trouble.position == "right" - and vim.w[win].trouble.type == "split" - and vim.w[win].trouble.relative == "editor" - and not vim.w[win].trouble_preview - end, + filter = trouble_filter, size = { height = 0.3, width = 0.2, From 3e7dfb2edb06026e3b29bdd973448a66dd7cec70 Mon Sep 17 00:00:00 2001 From: ayamir Date: Mon, 13 Jan 2025 10:59:52 +0800 Subject: [PATCH 6/7] fix: toggle edgy left. --- lua/keymap/tool.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index 4a15c68e3..471e9b1a4 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -7,13 +7,20 @@ local vim_path = require("core.global").vim_path require("keymap.helpers") local plug_map = { + -- Plugin: edgy + ["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|gG"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"), -- Plugin: nvim-tree - ["n|"] = map_cr("NvimTreeToggle"):with_noremap():with_silent():with_desc("filetree: Toggle"), ["n|nf"] = map_cr("NvimTreeFindFile"):with_noremap():with_silent():with_desc("filetree: Find file"), ["n|nr"] = map_cr("NvimTreeRefresh"):with_noremap():with_silent():with_desc("filetree: Refresh"), From 3b7b8cf91f3a3d7681e1824037a92cdf6ddbccc4 Mon Sep 17 00:00:00 2001 From: ayamir Date: Tue, 14 Jan 2025 10:43:13 +0800 Subject: [PATCH 7/7] style: fix code style, use za to fold. --- lua/modules/configs/ui/edgy.lua | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lua/modules/configs/ui/edgy.lua b/lua/modules/configs/ui/edgy.lua index 5a7960fcf..e13c246ca 100644 --- a/lua/modules/configs/ui/edgy.lua +++ b/lua/modules/configs/ui/edgy.lua @@ -1,10 +1,12 @@ return function() - local trouble_filter = function(_, win) - return vim.w[win].trouble - and vim.w[win].trouble.position == "right" - and vim.w[win].trouble.type == "split" - and vim.w[win].trouble.relative == "editor" - and not vim.w[win].trouble_preview + 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", { @@ -20,7 +22,7 @@ return function() ["q"] = false, ["Q"] = false, [""] = false, - ["zz"] = function(win) + ["za"] = function(win) win:toggle() end, [""] = function(win) @@ -76,23 +78,17 @@ return function() ft = "trouble", pinned = true, collapsed = false, + size = { height = 0.6, width = 0.2 }, open = "Trouble symbols toggle win.position=right", - filter = trouble_filter, - size = { - height = 0.5, - width = 0.2, - }, + 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, - size = { - height = 0.3, - width = 0.2, - }, + filter = trouble_filter("right"), }, }, })