Cleanup + improvements

This commit is contained in:
2026-04-16 14:57:33 -07:00
parent a26ee483d9
commit b53f4a2a3c
6 changed files with 15 additions and 214 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ opt.autoindent = true
-- UI
opt.number = true
opt.relativenumber = true
opt.relativenumber = false
opt.termguicolors = true
opt.laststatus = 3
opt.wrap = false
+2 -2
View File
@@ -9,7 +9,6 @@ vim.pack.add({
{ src = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" },
{ src = "https://github.com/wakatime/vim-wakatime" },
{ src = "https://github.com/nvim-lua/plenary.nvim" },
{ src = "https://github.com/ThePrimeagen/harpoon", version = "harpoon2" },
{ src = "https://github.com/romgrk/barbar.nvim" },
{ src = "https://github.com/stevearc/oil.nvim" },
@@ -46,6 +45,7 @@ vim.pack.add({
-- Local dev plugins
vim.opt.rtp:prepend(vim.fn.expand("~/Projects/timmypidashev/verse.nvim"))
vim.opt.rtp:prepend(vim.fn.expand("~/Projects/homze/calculator/editors/neovim"))
require("timmypidashev.plugins.darkbox")
require("timmypidashev.plugins.lualine")
@@ -55,7 +55,6 @@ require("timmypidashev.plugins.mason")
require("timmypidashev.plugins.blink")
require("timmypidashev.plugins.lsp")
require("timmypidashev.plugins.starter")
require("timmypidashev.plugins.harpoon")
require("timmypidashev.plugins.barbar")
require("timmypidashev.plugins.oil")
require("timmypidashev.plugins.fzf")
@@ -73,3 +72,4 @@ require("timmypidashev.plugins.camouflage")
require("timmypidashev.plugins.videre")
require("timmypidashev.plugins.tinyglimmer")
require("timmypidashev.plugins.render-markdown")
require("timmypidashev.plugins.calc")
+10 -68
View File
@@ -4,14 +4,11 @@ require("barbar").setup({
animation = true,
auto_hide = false,
tabpages = true,
exclude_ft = { "dashboard", "oil" },
exclude_ft = { "oil", "dashboard" },
icons = {
buffer_index = true,
button = false, -- hide the close × on tabs
button = false,
filetype = { enabled = true },
-- Barbar's default preset uses a different separator glyph for inactive
-- tabs (▎ vs │), which visibly shifts the pipe when switching tabs.
-- Explicitly set all states to the same glyph.
separator = { left = "", right = "" },
inactive = { separator = { left = "", right = "" } },
visible = { separator = { left = "", right = "" } },
@@ -22,74 +19,19 @@ require("barbar").setup({
},
})
-- Personal barbar highlight tweaks on top of darkbox:
-- 1. All separator pipes share one muted color (matches WinSeparator).
-- 2. Active tab's index number is green so the selected tab pops.
local function barbar_highlights()
local bg = vim.api.nvim_get_hl(0, { name = "Normal", link = false }).bg
local win_sep = vim.api.nvim_get_hl(0, { name = "WinSeparator", link = false })
local sep_fg = win_sep and win_sep.fg
if sep_fg then
for _, group in ipairs({
"BufferCurrentSign",
"BufferVisibleSign",
"BufferInactiveSign",
"BufferAlternateSign",
}) do
vim.api.nvim_set_hl(0, group, { fg = sep_fg, bg = bg })
end
end
local green = vim.api.nvim_get_hl(0, { name = "DarkboxGreen", link = false }).fg
if green then
vim.api.nvim_set_hl(0, "BufferCurrentIndex", { fg = green, bg = bg, bold = true })
end
end
barbar_highlights()
vim.api.nvim_create_autocmd("ColorScheme", {
callback = barbar_highlights,
})
local map = vim.keymap.set
local opts = { silent = true }
-- If the current window is the oil sidebar, refocus the main editor window
-- first. Otherwise barbar commands (BufferGoto, BufferClose, etc.) act on the
-- oil window instead of the file area.
local function focus_main()
if vim.bo.filetype ~= "oil" then return end
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
local buf = vim.api.nvim_win_get_buf(win)
if vim.bo[buf].filetype ~= "oil" then
vim.api.nvim_set_current_win(win)
return
end
end
end
local function barbar_cmd(cmd)
return function()
focus_main()
vim.cmd(cmd)
end
end
-- Leader + N → jump to tab N
for i = 1, 9 do
map("n", "<leader>" .. i, barbar_cmd("BufferGoto " .. i), opts)
map("n", "<leader>" .. i, "<cmd>BufferGoto " .. i .. "<CR>", opts)
end
map("n", "<leader>0", barbar_cmd("BufferLast"), opts)
map("n", "<leader>0", "<cmd>BufferLast<CR>", opts)
-- Navigation
map("n", "<leader>,", barbar_cmd("BufferPrevious"), opts)
map("n", "<leader>.", barbar_cmd("BufferNext"), opts)
map("n", "<leader>,", "<cmd>BufferPrevious<CR>", opts)
map("n", "<leader>.", "<cmd>BufferNext<CR>", opts)
-- Reorder
map("n", "<leader><", barbar_cmd("BufferMovePrevious"), opts)
map("n", "<leader>>", barbar_cmd("BufferMoveNext"), opts)
map("n", "<leader><", "<cmd>BufferMovePrevious<CR>", opts)
map("n", "<leader>>", "<cmd>BufferMoveNext<CR>", opts)
-- Close
map("n", "<leader>c", barbar_cmd("BufferClose"), opts)
map("n", "<leader>bp", barbar_cmd("BufferPin"), opts)
map("n", "<leader>c", "<cmd>BufferClose<CR>", opts)
map("n", "<leader>bp", "<cmd>BufferPin<CR>", opts)
+1
View File
@@ -0,0 +1 @@
require("calc").setup()
-15
View File
@@ -1,15 +0,0 @@
local harpoon = require("harpoon")
harpoon:setup()
local map = vim.keymap.set
map("n", "<leader>a", function() harpoon:list():add() end, { desc = "Harpoon add file" })
map("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, { desc = "Harpoon menu" })
map("n", "<C-1>", function() harpoon:list():select(1) end, { desc = "Harpoon slot 1" })
map("n", "<C-2>", function() harpoon:list():select(2) end, { desc = "Harpoon slot 2" })
map("n", "<C-3>", function() harpoon:list():select(3) end, { desc = "Harpoon slot 3" })
map("n", "<C-4>", function() harpoon:list():select(4) end, { desc = "Harpoon slot 4" })
map("n", "<C-S-N>", function() harpoon:list():next() end, { desc = "Harpoon next" })
map("n", "<C-S-P>", function() harpoon:list():prev() end, { desc = "Harpoon prev" })
+1 -128
View File
@@ -5,133 +5,6 @@ require("oil").setup({
view_options = {
show_hidden = true,
},
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = {
desc = "Open in main window if sidebar, else select",
callback = function()
local oil = require("oil")
local entry = oil.get_cursor_entry()
if not entry then return end
-- If this oil window isn't a sidebar, use default behavior.
if not vim.wo.winfixwidth then
oil.select()
return
end
-- Directory: navigate within sidebar.
if entry.type == "directory" then
oil.select()
return
end
-- File: find a non-oil window to open in.
local main_win
for _, w in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
local b = vim.api.nvim_win_get_buf(w)
if vim.bo[b].filetype ~= "oil" then
main_win = w
break
end
end
local path = oil.get_current_dir() .. entry.name
if main_win then
vim.api.nvim_set_current_win(main_win)
vim.cmd("edit " .. vim.fn.fnameescape(path))
else
vim.cmd("rightbelow vsplit " .. vim.fn.fnameescape(path))
end
end,
},
["<C-s>"] = { "actions.select", opts = { vertical = true } },
["<C-h>"] = { "actions.select", opts = { horizontal = true } },
["<C-t>"] = { "actions.select", opts = { tab = true } },
["<C-p>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-r>"] = "actions.refresh",
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = { "actions.cd", opts = { scope = "tab" } },
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
["g\\"] = "actions.toggle_trash",
},
use_default_keymaps = false,
})
local SIDEBAR_WIDTH = 30
-- Fish-style shortened cwd: ~/P/t/neovimrc
local function fish_cwd()
local cwd = vim.fn.getcwd()
local home = vim.env.HOME or ""
if home ~= "" and cwd:sub(1, #home) == home then
cwd = "~" .. cwd:sub(#home + 1)
end
local parts = vim.split(cwd, "/", { plain = true })
for i = 1, #parts - 1 do
local p = parts[i]
if p ~= "" and p ~= "~" then
parts[i] = p:sub(1, 1)
end
end
return table.concat(parts, "/")
end
local function find_sidebar()
for _, win in ipairs(vim.api.nvim_list_wins()) do
local buf = vim.api.nvim_win_get_buf(win)
if vim.bo[buf].filetype == "oil" and vim.api.nvim_win_get_config(win).relative == "" then
return win
end
end
end
local function set_offset(width)
local ok, api = pcall(require, "barbar.api")
if ok then api.set_offset(width, fish_cwd()) end
end
local function open_sidebar()
local existing = find_sidebar()
if existing then
vim.api.nvim_set_current_win(existing)
return
end
-- Suppress redraw so we don't flash the parent window's buffer in the new
-- split before :Oil takes over.
local save_lazyredraw = vim.o.lazyredraw
vim.o.lazyredraw = true
vim.cmd("topleft vsplit | vertical resize " .. SIDEBAR_WIDTH .. " | Oil")
vim.wo.number = false
vim.wo.relativenumber = false
vim.wo.signcolumn = "no"
vim.wo.winfixwidth = true
set_offset(SIDEBAR_WIDTH)
vim.o.lazyredraw = save_lazyredraw
vim.cmd("redraw")
end
local function close_sidebar()
local existing = find_sidebar()
if existing then
vim.api.nvim_win_close(existing, true)
set_offset(0)
end
end
-- Keep the barbar label in sync with cwd changes.
vim.api.nvim_create_autocmd("DirChanged", {
callback = function()
if find_sidebar() then set_offset(SIDEBAR_WIDTH) end
end,
})
vim.keymap.set("n", "-", "<cmd>Oil<CR>", { desc = "Oil parent dir (current window)" })
vim.keymap.set("n", "<leader>e", open_sidebar, { desc = "Open / focus Oil sidebar" })
vim.keymap.set("n", "<leader>E", close_sidebar, { desc = "Close Oil sidebar" })
vim.keymap.set("n", "<leader>o", "<C-w>w", { desc = "Cycle windows" })
vim.keymap.set("n", "<leader>e", "<cmd>Oil<CR>", { desc = "Open Oil" })