Files
nvim-config/lua/plugins/editor.lua
2026-01-13 11:35:48 -07:00

123 lines
3.4 KiB
Lua

-- Editor enhancements - Snacks explorer configuration
-- Custom keybindings for file explorer (snacks.nvim built into LazyVim)
return {
-- Configure snacks.nvim explorer (already included in LazyVim)
{
"folke/snacks.nvim",
opts = {
explorer = {
replace_netrw = true,
},
lazygit = {
enabled = true,
},
picker = {
sources = {
explorer = {
-- Explorer picker configuration
hidden = true,
ignored = true, -- Show files ignored by .gitignore
follow_file = true,
-- Custom keymaps within the explorer
win = {
list = {
keys = {
-- Ctrl+Shift+v - Open in vertical split
["<C-S-v>"] = { "edit_vsplit", mode = { "n", "i" } },
-- Ctrl+Shift+h - Open in horizontal split
["<C-S-h>"] = { "edit_split", mode = { "n", "i" } },
-- Alternative mappings (in case terminal doesn't send Ctrl+Shift properly)
["<C-v>"] = { "edit_vsplit", mode = { "n", "i" } },
["<C-x>"] = { "edit_split", mode = { "n", "i" } },
},
},
},
},
},
},
},
keys = {
-- Ctrl+Shift+e - Toggle explorer
{ "<C-S-e>", function() Snacks.explorer() end, desc = "Toggle Explorer" },
-- Alternative binding if terminal doesn't handle Ctrl+Shift
{ "<leader>fe", function() Snacks.explorer() end, desc = "File Explorer" },
-- Lazygit
{ "<leader>gg", function() Snacks.lazygit() end, desc = "Lazygit" },
{ "<leader>gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log" },
{ "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit File History" },
},
},
-- Which-key for keybinding hints
{
"folke/which-key.nvim",
opts = {
spec = {
{ "<leader>a", group = "AI" },
{ "<leader>d", group = "Debug/Database" },
{ "<leader>g", group = "Git" },
{ "<leader>t", group = "Terminal" },
},
},
},
-- Color preview for CSS, HTML, etc.
{
"norcalli/nvim-colorizer.lua",
event = { "BufReadPre", "BufNewFile" },
opts = {
"css",
"scss",
"html",
"javascript",
"typescript",
"javascriptreact",
"typescriptreact",
"vue",
"svelte",
"lua",
"yaml",
"toml",
"conf",
css = { rgb_fn = true, hsl_fn = true },
scss = { rgb_fn = true, hsl_fn = true },
html = { names = false },
},
},
-- Better terminal integration
{
"akinsho/toggleterm.nvim",
version = "*",
opts = {
size = function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
open_mapping = [[<c-\>]],
hide_numbers = true,
shade_filetypes = {},
shade_terminals = true,
shading_factor = 2,
start_in_insert = true,
insert_mappings = true,
persist_size = true,
direction = "float",
close_on_exit = true,
shell = vim.o.shell,
float_opts = {
border = "curved",
winblend = 0,
highlights = {
border = "Normal",
background = "Normal",
},
},
},
},
}