-- Leader vim.g.mapleader = " " -- Guard (Linters + Formatters) vim.g.guard_config = { fmt_on_save = true, lsp_as_default_formatter = true, save_on_fmt = true, } -- Sync system clipboard and neovim register vim.opt.clipboard = { "unnamedplus" } -- Save undo history vim.opt.undofile = true -- -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term vim.opt.ignorecase = true vim.opt.smartcase = true -- Remove sign column (LSP gutter on the left) vim.opt.signcolumn = "yes" -- Line Numbers vim.opt.number = true vim.opt.relativenumber = true -- Tabs vim.o.tabstop = 4 -- A TAB character looks like 4 spaces vim.o.expandtab = true -- Pressing the TAB key will insert spaces instead of a TAB character vim.o.softtabstop = 4 -- Number of spaces inserted instead of a TAB character vim.o.shiftwidth = 4 -- Number of spaces inserted when indenting -- Modules -- -- Lazy = Package Manager -- 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 vim.opt.rtp:prepend(lazypath) require("lazy").setup("plugins") -- LSP Ignore error for _, method in ipairs({ "textDocument/diagnostic", "workspace/diagnostic" }) do local default_diagnostic_handler = vim.lsp.handlers[method] vim.lsp.handlers[method] = function(err, result, context, config) if err ~= nil and err.code == -32802 then return end return default_diagnostic_handler(err, result, context, config) end end -- Mappings -- Save -- vim.keymap.set("n", "", "w") -- Split navigation -- vim.keymap.set("n", "", "h") vim.keymap.set("n", "", "j") vim.keymap.set("n", "", "k") vim.keymap.set("n", "", "l") -- Buffers -- vim.keymap.set("n", "x", "bd") -- Telescope Mappings -- local builtin = require("telescope.builtin") vim.keymap.set("n", "ff", builtin.find_files, { desc = "Telescope find files" }) vim.keymap.set("n", "fw", builtin.live_grep, { desc = "Telescope live grep" }) vim.keymap.set("n", "fb", builtin.buffers, { desc = "Telescope live buffers" }) -- Neo Tree -- vim.keymap.set("n", "", " Neotree toggle ") vim.keymap.set("n", "e", " Neotree focus ") -- LSP -- vim.keymap.set("n", "gd", vim.lsp.buf.definition) vim.keymap.set("n", "ca", vim.lsp.buf.code_action) vim.keymap.set("n", "ra", vim.lsp.buf.rename) vim.keymap.set("n", "lf", vim.diagnostic.open_float) vim.keymap.set("n", "gr", vim.lsp.buf.references) -- Search -- vim.keymap.set("n", "", " noh ") -- Tmux navigator -- vim.keymap.set("n", "", "TmuxNavigateLeft") vim.keymap.set("n", "", "TmuxNavigateDown") vim.keymap.set("n", "", "TmuxNavigateUp") vim.keymap.set("n", "", "TmuxNavigateRight") vim.keymap.set("n", "", "TmuxNavigatePrevious") -- Floating Terminal -- vim.keymap.set("n", "", "ToggleTerm direction=float") vim.keymap.set("t", "", "ToggleTerm direction=float")