-- Abbreviations local opt = vim.opt local map = vim.keymap.set local cmd = vim.cmd -- [[ OPTIONS ]] -- -- Line numbers opt.number = true opt.relativenumber = true -- Block cursor opt.guicursor = "" -- File options opt.undofile = true opt.undodir = os.getenv("HOME") .. "/.vim/nvim_undodir" opt.swapfile = false opt.backup = false opt.fixendofline = false -- Tabs opt.tabstop = 4 opt.softtabstop = 4 opt.shiftwidth = 4 opt.expandtab = true opt.breakindent = true -- Search opt.ignorecase = true opt.smartcase = true opt.incsearch = true map("n", "", "nohlsearch") -- Columns opt.signcolumn = "yes" opt.textwidth = 78 -- RFC 5322 opt.colorcolumn = "79" -- Auto complete opt.completeopt = { "menuone", "popup" --[[, "noselect" ]] } -- Window border opt.winborder = "rounded" -- [[ KEYMAPS ]] -- -- Leader key vim.g.mapleader = " " vim.g.maplocalleader = " " -- Clipboard map({ "n", "v" }, "y", "\"+y") -- Deletions map({ "n", "v" }, "d", "\"_d") map("n", "dm", ":delmarks!") -- Commands map("n", "x", ":!chmod +x %") map("n", "cd", ":cd %:h | pwd") -- Tabs map("n", "tt", ":tabnew") map("n", "tw", ":tabclose") map("n", "tn", ":tabnext") map("n", "tp", ":tabprevious") map("n", "tf", ":tabfirst") map("n", "tl", ":tablast") -- Buffers map("n", "bc", ":enew") map("n", "bd", ":bdelete") map("n", "", ":bnext") map("n", "", ":bprevious") map("n", "\\", ":buffer term") map("t", "", "") -- Indentation in visual mode map("v", "<", "", ">gv") -- Move text in visual mode map("v", "J", ":move '>+1gv=gv") map("v", "K", ":move '<-2gv=gv") -- Run last command in terminal map("n", "r", ":buffer termi") -- Window movement map("n", "", "h") map("n", "", "j") map("n", "", "k") map("n", "", "l") map("t", "", "wincmd h") map("t", "", "wincmd j") map("t", "", "wincmd k") map("t", "", "wincmd l") -- Window resizing map("n", "", "resize -2") map("n", "", "resize +2") map("n", "", "vertical resize -2") map("n", "", "resize +2") -- Listchars local listchars = { -- eol = "$", tab = "» ", space = "·", trail = "-" } opt.listchars = listchars vim.api.nvim_set_hl(0, "NonText", { fg = "#303030" }) vim.api.nvim_set_hl(0, "Whitespace", { fg = "#303030" }) cmd.match([[TrailingWhitespace /\s\+$/]]) -- Toggle listchars map("n", "lc", function() vim.wo.list = not vim.wo.list if vim.wo.list then vim.api.nvim_set_hl(0, "TrailingWhitespace", { link = "Error" }) else vim.api.nvim_set_hl(0, "TrailingWhitespace", { link = "Whitespace" }) end end) vim.api.nvim_create_autocmd({ "InsertEnter", "TermEnter" }, { callback = function() opt.listchars.trail = nil vim.api.nvim_set_hl(0, "TrailingWhitespace", { link = "Whitespace" }) end }) vim.api.nvim_create_autocmd({ "InsertLeave", "TermLeave" }, { callback = function() opt.listchars.trail = listchars.space vim.api.nvim_set_hl(0, "TrailingWhitespace", { link = "Error" }) end }) -- [[ PLUGINS ]] -- -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) end end opt.rtp:prepend(lazypath) -- Plugins require("lazy").setup({ -- Colorscheme { "blazkowolf/gruber-darker.nvim", opts = { italic = { strings = false, comments = false, } } }, -- Fuzzy finder { "echasnovski/mini.pick", opts = {} }, -- Advanced undo tree { "mbbill/undotree" }, -- Git integration { "tpope/vim-fugitive" }, { "lewis6991/gitsigns.nvim", opts = {} } }) -- Plugin keymaps map("n", "f", ":Pick files") map("n", "u", ":UndotreeToggle") map("n", "gs", ":Git") map("n", "gt", ":Gitsigns toggle_signs") map("n", "gp", ":Gitsigns preview_hunk") map("n", "gb", ":Gitsigns toggle_current_line_blame") -- Colorscheme cmd.colorscheme("gruber-darker")