What am I doing with my life...

This commit is contained in:
2026-05-22 08:02:56 +02:00
parent 456c2593a4
commit 1eed4b819a
7 changed files with 156 additions and 47 deletions
+3 -1
View File
@@ -3,6 +3,7 @@ map = vim.keymap.set
vim.g.mapleader = " "
vim.g.termguicolors = true
-- mini.basics sets defaults see plugin folder for more
vim.o.swapfile = false
vim.o.winborder = "single"
vim.o.winblend = 0
vim.o.pumblend = 0
@@ -30,9 +31,10 @@ map("v", "J", ":m '>+1<CR>gv=gv")
map("v", "K", ":m '<-2<CR>gv=gv")
map("v", "<S-Tab>", "<gv")
map("v", "<Tab>" , ">gv")
map("n", "<leader>p", ":b#<CR>")
map("n", "<leader>l", ":b#<CR>")
map("n", "<leader>e", ":Ex<CR>")
map("n", "<leader>x", ":bd<CR>")
require("autocmds")
require("terminal")
require("plugins")
+10 -1
View File
@@ -1,5 +1,14 @@
-- Terminals should open with insert mode
vim.api.nvim_create_autocmd("BufEnter", { pattern = "term://*", callback = function() vim.cmd("startinsert") end })
vim.api.nvim_create_autocmd({ "BufEnter", "TermEnter", "WinEnter" }, {
pattern = "term://*",
callback = function()
if vim.bo.buftype == "terminal" then
vim.schedule(function()
vim.cmd("startinsert")
end)
end
end
})
-- Start treesitter
vim.api.nvim_create_autocmd('FileType', {
+52 -17
View File
@@ -13,19 +13,53 @@ require('nvim-highlight-colors').setup()
require("mini.extra").setup()
require("mini.pairs").setup()
require('mini.surround').setup()
require('mini.sessions').setup()
require("mini.statusline").setup()
require('mini.basics').setup({options = { extra_ui = true }})
require('mini.completion').setup({lsp_completion = { auto_setup = true }})
require("mini.pick").setup({
window = { config = function()
local height = math.floor(0.50 * vim.o.lines)
local width = math.floor(0.50 * vim.o.columns)
return {
anchor = 'NW', height = height, width = width,
row = math.floor(0.5 * (vim.o.lines - height)),
col = math.floor(0.5 * (vim.o.columns - width)),
window = {
config = function()
local height = math.floor(0.50 * vim.o.lines)
local width = math.floor(0.50 * vim.o.columns)
return {
anchor = 'NW', height = height, width = width,
row = math.floor(0.5 * (vim.o.lines - height)),
col = math.floor(0.5 * (vim.o.columns - width)),
}
end
},
-- Add global mappings here
mappings = {
delete_buffer = {
char = '<C-d>',
func = function()
local pick = require('mini.pick')
local current_match = pick.get_picker_matches().current
-- Safety check: only attempt deletion if the item has a valid buffer number
if current_match and current_match.bufnr then
local bufnr = current_match.bufnr
-- Safely delete the buffer
vim.api.nvim_buf_delete(bufnr, {})
-- Instantly remove it from the visible picker list
local buffer_items = pick.get_picker_items()
for i = #buffer_items, 1, -1 do
if buffer_items[i].bufnr == bufnr then
table.remove(buffer_items, i)
break
end
end
pick.set_picker_items(buffer_items)
else
vim.notify("Current item is not a buffer", vim.log.levels.WARN)
end
end
}
end }
}
})
vim.cmd(":HighlightColors Off")
@@ -44,13 +78,14 @@ map("n", "<leader>h", ":lua MiniPick.builtin.help()<CR>")
map("n", "<leader>d", ":lua MiniExtra.pickers.diagnostic()<CR>")
map("n", "<leader>ss", ":lua MiniPick.builtin.grep_live()<CR>")
map("n", "<leader>tc", ":HighlightColors Toggle<CR>")
map("n", "<leader>pp", ":lua MiniSessions.select()<CR>")
map('n', '<leader>pa',
function()
-- Get the tail (:t) of the current working directory path (the folder name)
local session_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':t')
-- Highlight Overrides
-- local bg = "#1b1b1b"
-- local border = "#96A6C8"
-- vim.api.nvim_set_hl(0, "MiniPickBorder", { bg = bg, fg = border })
-- vim.api.nvim_set_hl(0, "MiniPickNormal", { bg = bg })
-- Completion popup background
-- vim.api.nvim_set_hl(0, "Pmenu", { bg = bg })
-- vim.api.nvim_set_hl(0, "NormalFloat", { bg = bg })
-- vim.api.nvim_set_hl(0, 'FloatBorder', { bg = bg, fg = border })
-- Create/overwrite the session silently
require('mini.sessions').write(session_name)
print("Session '" .. session_name .. "' saved!")
end
)
+63
View File
@@ -0,0 +1,63 @@
local term_win = nil
local term_buf = nil
local function toggle_term()
if term_win and vim.api.nvim_win_is_valid(term_win) then
vim.api.nvim_win_close(term_win, false)
term_win = nil
else
vim.cmd('botright vsplit')
term_win = vim.api.nvim_get_current_win()
if term_buf and vim.api.nvim_buf_is_valid(term_buf) then
vim.api.nvim_win_set_buf(term_win, term_buf)
else
vim.cmd('terminal')
term_buf = vim.api.nvim_get_current_buf()
end
vim.api.nvim_win_set_width(term_win, math.floor(vim.o.columns * 0.35))
vim.cmd('startinsert')
end
end
-- Jump to previous non-terminal buffer
local function prev_non_term_buf()
local cur = vim.api.nvim_get_current_buf()
local bufs = vim.fn.getbufinfo({ buflisted = 1 })
-- Walk buffer list in reverse to find last non-terminal buffer that isn't current
local history = vim.fn.execute('ls t') -- 't' flag = sort by last used time
local candidates = {}
for _, info in ipairs(bufs) do
local bufnr = info.bufnr
if bufnr ~= cur
and bufnr ~= term_buf
and vim.bo[bufnr].buftype ~= 'terminal'
then
table.insert(candidates, { bufnr = bufnr, lastused = info.lastused })
end
end
if #candidates == 0 then
print('No previous non-terminal buffer')
return
end
-- Sort by lastused descending, pick the most recently used
table.sort(candidates, function(a, b) return a.lastused > b.lastused end)
vim.api.nvim_set_current_buf(candidates[1].bufnr)
end
-- Overrides init binding
map('n', '<leader>l', prev_non_term_buf, { desc = 'Go to previous non-terminal buffer' })
map('n', '<C-o>', function()
if term_buf and vim.api.nvim_buf_is_valid(term_buf) then
vim.api.nvim_set_current_buf(term_buf)
else
print('No terminal buffer open yet')
end
end)
map('n', '<C-j>', toggle_term, { desc = 'Toggle terminal' })
-- terminal mode binds
map('t', '<C-j>', toggle_term, { desc = 'Toggle terminal' })
map('t', '<C-o>', '<C-\\><C-n><C-^>', { desc = 'Go to last buffer' })