-- NOTE: These 2 need to be set up before any plugins are loaded. vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- [[ Setting options ]] -- See `:help vim.o` -- NOTE: You can change these options as you wish! -- Sets how neovim will display certain whitespace characters in the editor. -- See `:help 'list'` -- and `:help 'listchars'` vim.opt.list = true vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- Set highlight on search vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') -- Preview substitutions live, as you type! vim.opt.inccommand = 'split' -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 -- Make line numbers default vim.wo.number = true -- Enable mouse mode vim.o.mouse = 'a' -- Indent -- vim.o.smarttab = true vim.opt.cpoptions:append('I') vim.o.expandtab = true -- vim.o.smartindent = true -- vim.o.autoindent = true -- vim.o.tabstop = 4 -- vim.o.softtabstop = 4 -- vim.o.shiftwidth = 4 -- stops line wrapping from being confusing vim.o.breakindent = true -- Save undo history vim.o.undofile = true -- Case-insensitive searching UNLESS \C or capital in search vim.o.ignorecase = true vim.o.smartcase = true -- Keep signcolumn on by default vim.wo.signcolumn = 'yes' vim.wo.relativenumber = true -- Decrease update time vim.o.updatetime = 250 vim.o.timeoutlen = 300 -- Set completeopt to have a better completion experience vim.o.completeopt = 'menu,preview,noselect' -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true -- [[ Disable auto comment on enter ]] -- See :help formatoptions vim.api.nvim_create_autocmd("FileType", { desc = "remove formatoptions", callback = function() vim.opt.formatoptions:remove({ "c", "r", "o" }) end, }) -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) vim.api.nvim_create_autocmd('TextYankPost', { callback = function() vim.highlight.on_yank() end, group = highlight_group, pattern = '*', }) vim.g.netrw_liststyle=0 vim.g.netrw_banner=0 -- [[ Basic Keymaps ]] -- Keymaps for better default experience -- See `:help vim.keymap.set()` vim.keymap.set("v", "J", ":m '>+1gv=gv", { desc = 'Moves Line Down' }) vim.keymap.set("v", "K", ":m '<-2gv=gv", { desc = 'Moves Line Up' }) vim.keymap.set("n", "", "zz", { desc = 'Scroll Down' }) vim.keymap.set("n", "", "zz", { desc = 'Scroll Up' }) vim.keymap.set("n", "n", "nzzzv", { desc = 'Next Search Result' }) vim.keymap.set("n", "N", "Nzzzv", { desc = 'Previous Search Result' }) vim.keymap.set("n", "[", "bprev", { desc = 'Previous buffer' }) vim.keymap.set("n", "]", "bnext", { desc = 'Next buffer' }) vim.keymap.set("n", "l", "b#", { desc = 'Last buffer' }) vim.keymap.set("n", "d", "bdelete", { desc = 'delete buffer' }) -- see help sticky keys on windows vim.cmd([[command! W w]]) vim.cmd([[command! Wq wq]]) vim.cmd([[command! WQ wq]]) vim.cmd([[command! Q q]]) -- Remap for dealing with word wrap vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) -- kickstart.nvim starts you with this. -- But it constantly clobbers your system clipboard whenever you delete anything. -- Sync clipboard between OS and Neovim. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -- vim.o.clipboard = 'unnamedplus' -- You should instead use these keybindings so that they are still easy to use, but dont conflict vim.keymap.set({"v", "x", "n"}, 'y', '"+y', { noremap = true, silent = true, desc = 'Yank to clipboard' }) vim.keymap.set({"n", "v", "x"}, 'Y', '"+yy', { noremap = true, silent = true, desc = 'Yank line to clipboard' }) vim.keymap.set({"n", "v", "x"}, '', 'gg0vG$', { noremap = true, silent = true, desc = 'Select all' }) vim.keymap.set({'n', 'v', 'x'}, 'p', '"+p', { noremap = true, silent = true, desc = 'Paste from clipboard' }) vim.keymap.set('i', '', '+', { noremap = true, silent = true, desc = 'Paste from clipboard from within insert mode' }) vim.keymap.set("x", "P", '"_dP', { noremap = true, silent = true, desc = 'Paste over selection without erasing unnamed register' })