diff options
Diffstat (limited to 'init.lua')
| -rw-r--r-- | init.lua | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..9cdeddf --- /dev/null +++ b/init.lua @@ -0,0 +1,88 @@ +require("config.lazy") +require("config.terminal") + +vim.g.have_nerd_font = true +vim.g.loaded_node_provider = 0 +vim.g.loaded_perl_provider = 0 +vim.g.loaded_python3_provider = 0 +vim.g.loaded_ruby_provider = 0 + +-- Set the terminal window title to the filename being edited. +-- This helps with using ROFI to find the vim window. +vim.o.title = true + +vim.o.writebackup = false +vim.o.undofile = true +vim.o.undodir = vim.fn.expand("~/.local/share/nvim-v2/undodir") + +vim.o.colorcolumn = "125" +vim.o.showmode = false +vim.o.showtabline = 2 + +vim.wo.signcolumn = "yes" +vim.wo.cursorline = true +vim.wo.cursorcolumn = false + +vim.keymap.set("n", "<Leader>uc", "<CMD>set cursorcolumn!<CR>", { desc = "Toggle cursor column" }) + +vim.opt.number = true +vim.opt.relativenumber = true + +vim.o.expandtab = true + +-- Automatic toggling between line number modes +-- Source: https://jeffkreeftmeijer.com/vim-number/ +vim.cmd [[ +augroup NumberToggle + autocmd! + autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif + autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif +augroup END +]] + +vim.opt.splitright = true +vim.opt.splitbelow = true +vim.opt.scrolloff = 4 +vim.opt.list = true +vim.opt.listchars = { tab = "▸ ", trail = "·", precedes = "←", extends = "→" } +vim.opt.hlsearch = true +vim.opt.smartcase = true +vim.opt.smartindent = true +vim.opt.shiftwidth = 2 + +vim.keymap.set("n", "<ESC>", "<CMD>nohlsearch<CR>") + +-- When I forgot that vim is o insert mode. +vim.keymap.set("i", "jj", "<ESC>") + +if vim.fn.has("termguicolors") then + vim.o.termguicolors = true +end + +-- External Clipboard +vim.keymap.set("v", "<Leader>y", '"+y', { desc = "Copy to system clipboard register" }) +vim.keymap.set("n", "<Leader>p", '"+p', { desc = "Paste from system clipboard register" }) + +vim.keymap.set("n", "<Leader>q", "<CMD>bprevious | bdelete #<CR>", { desc = "Close current buffer" }) + +vim.keymap.set("n", "<A-p>", "<CMD>bprevious<CR>", { desc = "Previous buffer" }) +vim.keymap.set("n", "<A-n>", "<CMD>bnext<CR>", { desc = "Next buffer" }) + +vim.keymap.set("n", "<C-s>", "<CMD>silent! update | redraw<CR>", { desc = "Save" }) +vim.keymap.set({ "i", "x" }, "<C-s>", "<ESC><CMD>silent! update | redraw<CR>", { desc = "Save and go to Normal mode" }) + +vim.keymap.set("n", "<Leader>-", "<CMD>Oil<CR>", { desc = "Open Oil" }) + +vim.api.nvim_create_autocmd("TextYankPost", { desc = "Highlight when yanking text", + group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +vim.api.nvim_create_user_command("CopyPath", function() + local path = vim.fn.expand("%:p") + vim.fn.setreg("+", path) + vim.notify("Copied '" .. path .. "' to the clipboard.") +end, { desc = "Copy current buffer file path to the clipboard." }) +vim.keymap.set("n", "<C-c>", "<CMD>CopyPath<CR>") |
