refactor(plugins): replace neo-tree with yazi as the file manager
This commit is contained in:
1 parent
63bae171e3
commit
2eedac5134
4 files changed
+85
-395
No files matched your search
+25
-35
@@ -1,53 +1,43 @@
|
||||
--- User plugins: cursor animation and snacks.nvim (picker + dashboard) customization
|
||||
|
||||
-- Confirm action for file-opening pickers:
|
||||
-- open in a vertical split by default, reuse the window when the buffer is
|
||||
-- already visible in this tab, plain edit when the main window holds an
|
||||
-- empty scratch buffer. Explicit edit-cmd keybinds (<c-s> split, <c-v>
|
||||
-- vsplit, <c-t> tab) carry `action.cmd` and are passed through untouched.
|
||||
local function vsplit_confirm(picker, item, action)
|
||||
-- Confirm action for file-opening pickers: <CR> opens the selection as a
|
||||
-- tab via `tabdrop` (:tab drop semantics — focus the buffer if it's already
|
||||
-- visible in any tab, don't spawn a tab from an empty buffer, else open a
|
||||
-- new tab). Explicit edit-cmd keybinds (<S-CR>/<c-v> vsplit, <c-s> split)
|
||||
-- carry `action.cmd` and are passed through untouched.
|
||||
local function tab_confirm(picker, item, action)
|
||||
local actions = require "snacks.picker.actions"
|
||||
if action.cmd then return actions.jump(picker, item, action) end
|
||||
local path = item and item.file and require("snacks.picker.util").path(item)
|
||||
if not (item and (item.buf or path)) then return actions.jump(picker, item, action) end
|
||||
local buf = item.buf or vim.fn.bufadd(path)
|
||||
local visible = false
|
||||
for _, w in ipairs(vim.fn.win_findbuf(buf)) do
|
||||
if
|
||||
vim.api.nvim_win_get_tabpage(w) == vim.api.nvim_get_current_tabpage()
|
||||
and vim.api.nvim_win_get_config(w).relative == ""
|
||||
then
|
||||
visible = true
|
||||
break
|
||||
end
|
||||
end
|
||||
local main_buf = picker.main and vim.api.nvim_win_is_valid(picker.main) and vim.api.nvim_win_get_buf(picker.main)
|
||||
local main_empty = main_buf
|
||||
and vim.api.nvim_buf_get_name(main_buf) == ""
|
||||
and vim.bo[main_buf].buftype == ""
|
||||
and not vim.bo[main_buf].modified
|
||||
local cmd = (visible or main_empty) and "edit" or "vsplit"
|
||||
return actions.jump(picker, item, vim.tbl_extend("force", {}, action, { cmd = cmd }))
|
||||
return actions.jump(picker, item, vim.tbl_extend("force", {}, action, { cmd = "tabdrop" }))
|
||||
end
|
||||
|
||||
-- Tab-on-enter + vsplit-on-shift-enter for the file-opening pickers only;
|
||||
-- location pickers (lsp_*, lines, diagnostics, grep) and sources with their
|
||||
-- own confirm (git_branches, projects) keep their defaults.
|
||||
local picker_sources = {}
|
||||
for _, source in ipairs { "files", "git_files", "smart", "recent", "buffers" } do
|
||||
picker_sources[source] = {
|
||||
confirm = tab_confirm,
|
||||
win = {
|
||||
input = { keys = { ["<S-CR>"] = { "edit_vsplit", mode = { "n", "i" } } } },
|
||||
list = { keys = { ["<S-CR>"] = "edit_vsplit" } },
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
---@type LazySpec
|
||||
return {
|
||||
{ "sphamba/smear-cursor.nvim", opts = {} },
|
||||
|
||||
-- terminals are handled by kitty now
|
||||
{ "akinsho/toggleterm.nvim", enabled = false },
|
||||
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
opts = {
|
||||
picker = {
|
||||
jump = { reuse_win = true },
|
||||
-- vsplit-by-default only for file-opening pickers; location pickers
|
||||
-- (lsp_*, lines, diagnostics, grep) keep the default in-window jump
|
||||
sources = {
|
||||
files = { confirm = vsplit_confirm },
|
||||
git_files = { confirm = vsplit_confirm },
|
||||
smart = { confirm = vsplit_confirm },
|
||||
recent = { confirm = vsplit_confirm },
|
||||
buffers = { confirm = vsplit_confirm },
|
||||
},
|
||||
sources = picker_sources,
|
||||
},
|
||||
dashboard = {
|
||||
enabled = true,
|
||||
|
||||
Reference in new issue
Block a user