summaryrefslogtreecommitdiff
path: root/.config/nvim/init.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/init.lua')
-rw-r--r--.config/nvim/init.lua68
1 files changed, 62 insertions, 6 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index f100cd6..2c7e130 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -1,5 +1,5 @@
------------------------------------------------------------
--- Filip's neovim config
+-- Filip's config for the Zoomer Editor
------------------------------------------------------------
------------------------------------------------------------
@@ -16,7 +16,6 @@ vim.opt.ruler = true
vim.opt.cursorline = true
-- Modern / visual quality
-vim.opt.termguicolors = true
vim.opt.signcolumn = "yes"
vim.opt.pumblend = 10
vim.opt.winblend = 10
@@ -27,6 +26,17 @@ vim.opt.winblend = 10
vim.opt.splitbelow = true
vim.opt.splitright = true
+-- Preferred width and height for automatic window resizing
+vim.opt.winwidth = 10
+vim.opt.winheight = 10
+
+-- Minimum width and height a window can shrink to
+vim.opt.winminwidth = 10
+vim.opt.winminheight = 10
+
+-- Automatically balance windows when opening/closing
+vim.opt.equalalways = true
+
------------------------------------------------------------
-- Timing & performance related
------------------------------------------------------------
@@ -82,10 +92,13 @@ vim.opt.termguicolors = true
vim.cmd.colorscheme("pablo")
-- Transparency
-vim.api.nvim_set_hl(0, "Normal", { bg = "none", ctermbg = "none" })
-vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none", ctermbg = "none" })
-vim.api.nvim_set_hl(0, "SignColumn", { bg = "none" })
-vim.api.nvim_set_hl(0, "FoldColumn", { bg = "none" })
+local function transparent_hl(group)
+ vim.api.nvim_set_hl(0, group, { bg = "none", ctermbg = "none" })
+end
+
+for _, group in ipairs({ "Normal", "NormalFloat", "SignColumn", "FoldColumn" }) do
+ transparent_hl(group)
+end
------------------------------------------------------------
-- Autocommands
@@ -114,6 +127,28 @@ vim.api.nvim_create_autocmd("BufWritePre", {
end,
})
+vim.api.nvim_create_autocmd("BufUnload", {
+ pattern = "*.tex",
+ callback = function()
+ -- Get the full path of the file being closed
+ local file = vim.fn.expand("%:p")
+
+ -- Check if the file actually exists (to avoid errors on temporary buffers)
+ if file ~= "" then
+ -- Pass the file path as the first argument to the script
+ vim.fn.jobstart({ "texclear", file })
+ end
+ end,
+})
+
+-- Make help windows vertical splits
+vim.api.nvim_create_autocmd("FileType", {
+ pattern = "help",
+ callback = function()
+ vim.cmd("wincmd L")
+ end,
+})
+
------------------------------------------------------------
-- Key mappings
------------------------------------------------------------
@@ -160,6 +195,27 @@ map("v", "<C-j>", '"+y', { desc = "Yank selection to system clipboard" })
-- Toggle buffers
map("n", "<Tab><Tab>", "<C-^>", { desc = "Toggle last / alternate buffer" })
+-- Split window vertically
+map("n", "vv", "<C-w>v", { desc = "Split the current window vertically" })
+
+-- Pressing <leader>h will prompt for a help topic and open it in vsplit
+map("n", "<leader>h", ":vert help ", { desc = "Open help vertically" })
+
+-- Open messages in vplit
+map("n", "<leader>m", ":vnew | put =execute('messages')<CR>", { desc = "Open messages in vsplit" })
+
+-- Repeat action on visual block
+map("v", ".", ":normal .<CR>", { desc = "Repeat action on visual block" })
+
+-- Force write with sudo
+vim.cmd([[cabbrev w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!]])
+
+-- Resize windows
+map("n", "<C-Up>", ":resize +2<CR>", { desc = "Increase window height" })
+map("n", "<C-Down>", ":resize -2<CR>", { desc = "Decrease window height" })
+map("n", "<C-Left>", ":vertical resize +2<CR>", { desc = "Increase window width" })
+map("n", "<C-Right>", ":vertical resize -2<CR>", { desc = "Decrease window width" })
+
------------------------------------------------------------
-- Tabs & indentation
------------------------------------------------------------