1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2025-04-01 20:49:50 +00:00

[neovim] replace neo-tree with snacks.nvim

Replace neo-tree.nvim with snacks.nvim for file explorer functionality and
remove several other plugins including:
- mini-animate
- mini-starter
- indent-blankline

The snacks.nvim plugin provides better file explorer, dashboard, indentation
guides, and other UI improvements in a more cohesive package.

Also removed the large file autocommand as snacks.nvim handles this with its
bigfile module.
This commit is contained in:
Daniel Carrillo 2025-03-29 18:26:13 +01:00
parent 8e93236e49
commit 7d01253a29
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
15 changed files with 71 additions and 249 deletions

View File

@ -68,26 +68,3 @@ vim.api.nvim_create_autocmd("FileType", {
pattern = { "hcl", "helm" },
command = "setlocal shiftwidth=2 tabstop=2",
})
-- Disable some plugins on very large files
vim.api.nvim_create_autocmd({ "BufEnter" }, {
pattern = { "*" },
callback = function(args)
local highlighter = require("vim.treesitter.highlighter")
local ts_was_active = highlighter.active[args.buf]
local file_size = vim.fn.getfsize(args.file)
if file_size > 1024 * 1024 then
vim.cmd("TSBufDisable highlight")
vim.cmd("syntax off")
vim.cmd("syntax clear")
vim.cmd("IlluminatePauseBuf")
vim.cmd("NoMatchParen")
vim.cmd("UfoDisable")
vim.cmd("IBLDisable")
vim.cmd("LspStop")
if ts_was_active then
vim.notify("File larger than 1MB; syntax highlighting and heavy CPU use plugins are turned off.")
end
end
end,
})

View File

@ -193,14 +193,10 @@ keymap("i", "jk", "<ESC>", vim.tbl_extend("force", opts, { desc = "Exit insert m
keymap("v", "<", "<gv", opts)
keymap("v", ">", ">gv", opts)
-- NeoTree
keymap("n", "<leader>e", ":Neotree toggle<cr>", vim.tbl_extend("force", opts, { desc = "Toggle Neotree" }))
keymap(
"n",
"<leader>gg",
":Neotree float git_status<cr>",
vim.tbl_extend("force", opts, { desc = "Open a float window with the git status" })
)
-- FileTree
keymap("n", "<leader>e", function()
Snacks.explorer()
end, vim.tbl_extend("force", opts, { desc = "Toggle file explorer" }))
-- Telescope
keymap(
@ -234,7 +230,7 @@ keymap(
vim.tbl_extend("force", opts, { desc = "Open a Telescope prompt to show all commands" })
)
-- Gitdiff
-- Git
keymap(
"n",
"<leader>df",
@ -242,6 +238,13 @@ keymap(
vim.tbl_extend("force", opts, { desc = "Open diff view file history for the current buffer" })
)
keymap("n", "<leader>dc", ":DiffviewClose<cr>", vim.tbl_extend("force", opts, { desc = "Close diff view" }))
-- Git
keymap({ "n", "v" }, "<leader>go", function()
Snacks.gitbrowse()
end, vim.tbl_extend("force", opts, { desc = "Git Browse" }))
keymap("n", "<leader>gg", function()
Snacks.picker.git_status()
end, vim.tbl_extend("force", opts, { desc = "Git Status" }))
-- Projects
keymap(

View File

@ -90,7 +90,6 @@ require("lazy").setup({
-- Plugins
{ "nvim-lua/plenary.nvim", lazy = true },
{ "echasnovski/mini.animate", event = "VeryLazy", version = "*" },
{ "echasnovski/mini.comment", event = "VeryLazy", version = "*" },
{ "echasnovski/mini.pairs", event = "VeryLazy", version = "*" },
{ "echasnovski/mini.surround", event = "VeryLazy", version = "*" },
@ -102,7 +101,6 @@ require("lazy").setup({
{ "akinsho/bufferline.nvim", event = "VeryLazy", version = "v4.*" },
{ "moll/vim-bbye" },
{ "nvim-lualine/lualine.nvim", event = "VeryLazy" },
{ "lukas-reineke/indent-blankline.nvim", event = "BufReadPost", main = "ibl" },
{ "nvim-zh/auto-save.nvim", event = "BufReadPost" },
{
"folke/noice.nvim",
@ -122,9 +120,9 @@ require("lazy").setup({
},
{ "nvim-treesitter/nvim-treesitter", event = "BufReadPost" },
{
"nvim-neo-tree/neo-tree.nvim",
version = "v3.x",
dependencies = { "MunifTanjim/nui.nvim" },
"folke/snacks.nvim",
priority = 1000,
lazy = false,
},
{ "taybart/b64.nvim", event = "VeryLazy" },
{ "tenxsoydev/karen-yank.nvim", event = "VeryLazy", config = true },
@ -318,6 +316,6 @@ require("lazy").setup({
},
},
},
{ "towolf/vim-helm", ft = "helm" },
{ "robbles/logstash.vim" },
}, lazy_opts)

View File

@ -17,7 +17,7 @@ bufferline.setup({
close_command = "Bdelete! %d",
right_mouse_command = "Bdelete! %d",
offsets = {
{ filetype = "neo-tree", text = "", padding = 1 },
{ filetype = "snacks_picker_list", text = "", padding = 1 },
{ filetype = "dapui_scopes", text = "", padding = 1 },
},
indicator = {
@ -30,10 +30,7 @@ bufferline.setup({
custom_areas = {
left = function()
local text = ""
if not is_buffer_loaded("neo-tree") then
text = "" .. string.gsub(vim.loop.cwd(), "^" .. os.getenv("HOME"), "~") .. ""
end
local text = "" .. string.gsub(vim.loop.cwd(), "^" .. os.getenv("HOME"), "~") .. ""
return { { text = text, fg = "#adbac7" } }
end,

View File

@ -6,7 +6,7 @@ require("illuminate").configure({
"avante",
"lspsagafinder",
"mason",
"neo-tree",
"snacks_picker_list",
"packer",
"starter",
},

View File

@ -1,23 +0,0 @@
require("ibl").setup({
indent = {
char = "",
tab_char = "",
},
scope = {
enabled = true,
show_start = false,
show_end = false,
},
exclude = {
filetypes = {
"help",
"mini.starter",
"neo-tree",
"Trouble",
"trouble",
"lazy",
"mason",
"notify",
},
},
})

View File

@ -1,17 +1,14 @@
require("plugins.snacks")
require("plugins.blink")
require("plugins.copilot")
require("plugins.avante")
require("plugins.telescope")
require("plugins.mini-animate")
require("plugins.mini-comment")
require("plugins.mini-pairs")
require("plugins.mini-starter")
require("plugins.mini-surround")
require("plugins.treesitter")
require("plugins.gitsigns")
require("plugins.neo-tree")
require("plugins.illuminate")
require("plugins.indentline")
require("plugins.lsp")
require("plugins.go")
require("plugins.typescript")

View File

@ -6,21 +6,15 @@ require("plugins.lsp.lsp-saga")
local win = require("lspconfig.ui.windows")
win.default_options.border = "rounded"
local signs = {
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "" },
{ name = "DiagnosticSignInfo", text = "" },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
local config = {
virtual_text = false,
signs = {
active = signs,
text = {
[vim.diagnostic.severity.ERROR] = "",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "",
},
},
update_in_insert = true,
underline = true,
@ -34,15 +28,4 @@ local config = {
prefix = "",
},
}
vim.diagnostic.config(config)
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded",
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded",
})
vim.diagnostic.config(config)

View File

@ -6,7 +6,7 @@ local diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
symbols = { error = "", warn = "!" },
symbols = { error = "", warn = "" },
colored = false,
always_visible = true,
}
@ -84,7 +84,7 @@ require("lualine").setup({
path = 1,
cond = function()
if
vim.bo.filetype == "neo-tree"
vim.bo.filetype == "snacks_picker_list"
or vim.bo.filetype == "mason"
or vim.bo.filetype == "lazy"
or vim.bo.filetype == "help"

View File

@ -1,34 +0,0 @@
local mouse_scrolled = false
for _, scroll in ipairs({ "Up", "Down" }) do
local key = "<ScrollWheel" .. scroll .. ">"
vim.keymap.set({ "", "i" }, key, function()
mouse_scrolled = true
return key
end, { expr = true })
end
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = { "grug-far", "ministarter", "neo-tree" },
callback = function()
vim.b.minianimate_disable = true
end,
})
local animate = require("mini.animate")
animate.setup({
resize = {
timing = animate.gen_timing.linear({ duration = 50, unit = "total" }),
},
scroll = {
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
subscroll = animate.gen_subscroll.equal({
predicate = function(total_scroll)
if mouse_scrolled then
mouse_scrolled = false
return false
end
return total_scroll > 1
end,
}),
},
})

View File

@ -1,37 +0,0 @@
local starter = require("mini.starter")
local pad = string.rep(" ", 4)
local new_section = function(name, action, section)
return { name = name, action = action, section = pad .. section }
end
local logo = table.concat({
"",
"",
"",
"",
"███╗ ██╗██╗ ██╗██╗███╗ ███╗",
"████╗ ██║██║ ██║██║████╗ ████║",
"██╔██╗██║╚██╗ ██╔╝██║██╔████╔██║",
"██║╚████║ ╚████╔╝ ██║██║╚██╔╝██║",
"██║ ╚███║ ╚██╔╝ ██║██║ ╚═╝ ██║",
"╚═╝ ╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝",
}, "\n")
starter.setup({
evaluate_single = true,
header = logo,
footer = "",
items = {
new_section("Projects", "Telescope neovim-project discover", "Telescope"),
new_section("Recent files", "Telescope oldfiles", "Telescope"),
new_section("New file", "ene | startinsert", "Built-in"),
new_section("Quit", "qa", "Built-in"),
new_section("Lazy", "Lazy", "Config"),
new_section("Mason", "Mason", "Config"),
new_section("Tree-sitter", "TSUpdate", "Config"),
},
content_hooks = {
starter.gen_hook.adding_bullet(pad .. " ", false),
starter.gen_hook.aligning("center", "top"),
},
})

View File

@ -1,69 +0,0 @@
vim.g.neo_tree_remove_legacy_commands = true
require("neo-tree").setup({
close_if_last_window = true,
auto_clean_after_session_restore = true,
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "starter" },
popup_border_style = "rounded",
default_component_configs = {
indent = {
padding = 0,
with_expanders = false,
},
icon = {
folder_closed = "",
folder_open = "",
folder_empty = "",
default = "",
},
git_status = {
symbols = {
added = "",
deleted = "",
modified = "",
renamed = "",
untracked = "",
ignored = "",
unstaged = "",
staged = "",
conflict = "",
},
},
},
window = {
width = 40,
mappings = {
["o"] = "open",
["Z"] = "expand_all_nodes",
},
},
filesystem = {
filtered_items = {
visible = false,
hide_dotfiles = false,
hide_gitignored = false,
hide_by_name = {
"__pycache__",
".git",
},
},
follow_current_file = {
enabled = true,
},
hijack_netrw_behavior = "open_current",
use_libuv_file_watcher = true,
},
git_status = {
window = {
position = "float",
},
},
event_handlers = {
{
event = "neo_tree_buffer_enter",
handler = function(_)
vim.opt_local.signcolumn = "auto"
end,
},
},
})

View File

@ -14,7 +14,7 @@ require("neovim-project").setup({
filetype_autocmd_timeout = 0,
session_manager_opts = {
autosave_ignore_filetypes = {
"neo-tree",
"snacks_picker_list",
"trouble",
"grug-far",
"copilot-chat",

View File

@ -53,17 +53,5 @@ require("noice").setup({
},
opts = { skip = true },
},
{
view = "popup",
filter = {
find = "File larger than",
},
opts = {
size = {
width = 100,
height = 4,
},
},
},
},
})

View File

@ -0,0 +1,42 @@
require("snacks").setup({
animate = {},
bigfile = {},
explorer = {},
indent = {
indent = { char = "" },
scope = { char = "" },
},
scroll = {},
gitbrowse = {},
image = {},
dashboard = {
sections = {
{ section = "header" },
{ icon = "", desc = "Projects", action = ":Telescope neovim-project", key = "p", padding = 1 },
{ icon = "", key = "n", desc = "New File", action = ":ene | startinsert" },
{
icon = "",
desc = "Recent Files",
action = ":lua Snacks.dashboard.pick('oldfiles')",
key = "r",
},
{ icon = "", key = "q", desc = "Quit", action = ":qa", padding = 1 },
{ icon = "", title = "Config" },
{
icon = "󰒲",
desc = "Lazy",
action = ":Lazy",
enabled = package.loaded.lazy ~= nil,
key = "l",
indent = 2,
},
{ icon = "", desc = "Mason", action = ":Mason", key = "m", indent = 2 },
{ icon = "", desc = "Tree-sitter", action = ":TSUpdate", key = "t", indent = 2, padding = 2 },
{ section = "startup" },
},
},
})