|
| 1 | +-- Set <space> as the leader key |
| 2 | +-- See `:help mapleader` |
| 3 | +-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) |
| 4 | +vim.g.mapleader = ' ' |
| 5 | +vim.g.maplocalleader = ' ' |
| 6 | + |
| 7 | +-- Set to true if you have a Nerd Font installed and selected in the terminal |
| 8 | +vim.g.have_nerd_font = true |
| 9 | + |
| 10 | +-- [[ Setting options ]] |
| 11 | +-- See `:help vim.opt` |
| 12 | +-- NOTE: You can change these options as you wish! |
| 13 | +-- For more options, you can see `:help option-list` |
| 14 | + |
| 15 | +-- Make line numbers default |
| 16 | +vim.opt.number = true |
| 17 | +-- You can also add relative line numbers, to help with jumping. |
| 18 | +-- Experiment for yourself to see if you like it! |
| 19 | +vim.opt.relativenumber = true |
| 20 | + |
| 21 | +-- Enable mouse mode, can be useful for resizing splits for example! |
| 22 | +vim.opt.mouse = 'a' |
| 23 | + |
| 24 | +-- Don't show the mode, since it's already in the status line |
| 25 | +vim.opt.showmode = false |
| 26 | + |
| 27 | +-- Sync clipboard between OS and Neovim. |
| 28 | +-- Remove this option if you want your OS clipboard to remain independent. |
| 29 | +-- See `:help 'clipboard'` |
| 30 | +vim.opt.clipboard = 'unnamedplus' |
| 31 | + |
| 32 | +-- Enable break indent |
| 33 | +vim.opt.breakindent = true |
| 34 | + |
| 35 | +-- Save undo history |
| 36 | +vim.opt.undofile = true |
| 37 | + |
| 38 | +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term |
| 39 | +vim.opt.ignorecase = true |
| 40 | +vim.opt.smartcase = true |
| 41 | + |
| 42 | +-- Keep signcolumn on by default |
| 43 | +vim.opt.signcolumn = 'yes' |
| 44 | + |
| 45 | +-- Decrease update time |
| 46 | +vim.opt.updatetime = 250 |
| 47 | + |
| 48 | +-- Decrease mapped sequence wait time |
| 49 | +-- Displays which-key popup sooner |
| 50 | +vim.opt.timeoutlen = 300 |
| 51 | + |
| 52 | +-- Configure how new splits should be opened |
| 53 | +vim.opt.splitright = true |
| 54 | +vim.opt.splitbelow = true |
| 55 | + |
| 56 | +-- Sets how neovim will display certain whitespace characters in the editor. |
| 57 | +-- See `:help 'list'` |
| 58 | +-- and `:help 'listchars'` |
| 59 | +vim.opt.list = true |
| 60 | +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } |
| 61 | + |
| 62 | +-- Preview substitutions live, as you type! |
| 63 | +vim.opt.inccommand = 'split' |
| 64 | + |
| 65 | +-- Show which line your cursor is on |
| 66 | +vim.opt.cursorline = true |
| 67 | + |
| 68 | +-- Minimal number of screen lines to keep above and below the cursor. |
| 69 | +vim.opt.scrolloff = 10 |
| 70 | + |
| 71 | +-- Disable swapfiles |
| 72 | +vim.opt.swapfile = false |
| 73 | + |
| 74 | +vim.opt.termguicolors = true |
| 75 | + |
| 76 | +-- [[ Basic Keymaps ]] |
| 77 | +-- See `:help vim.keymap.set()` |
| 78 | + |
| 79 | +-- Set highlight on search, but clear on pressing <Esc> in normal mode |
| 80 | +vim.opt.hlsearch = true |
| 81 | +vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') |
| 82 | + |
| 83 | +-- Diagnostic keymaps |
| 84 | +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) |
| 85 | +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) |
| 86 | +vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) |
| 87 | +vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) |
| 88 | + |
| 89 | +-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier |
| 90 | +-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which |
| 91 | +-- is not what someone will guess without a bit more experience. |
| 92 | +-- |
| 93 | +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping |
| 94 | +-- or just use <C-\><C-n> to exit terminal mode |
| 95 | +vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }) |
| 96 | + |
| 97 | +-- TIP: Disable arrow keys in normal mode |
| 98 | +-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>') |
| 99 | +-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>') |
| 100 | +-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>') |
| 101 | +-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>') |
| 102 | + |
| 103 | +-- Keybinds to make split navigation easier. |
| 104 | +-- Use CTRL+<hjkl> to switch between windows |
| 105 | +-- |
| 106 | +-- See `:help wincmd` for a list of all window commands |
| 107 | +vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' }) |
| 108 | +vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' }) |
| 109 | +vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' }) |
| 110 | +vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) |
| 111 | + |
| 112 | +vim.keymap.set('n', '<leader>qq', '<cmd>qa<CR>', { desc = 'Quit all' }) |
| 113 | + |
| 114 | +-- Tab control; Tab buffer display in mini |
| 115 | +vim.keymap.set('n', '<Tab>', '<cmd>bnext<CR>', { desc = 'Next buffer' }) |
| 116 | +vim.keymap.set('n', '<S-Tab>', '<cmd>bprev<CR>', { desc = 'Previous buffer' }) |
| 117 | +vim.keymap.set('n', '<leader>x', '<cmd>bd<CR>', { desc = 'Delete current buffer' }) |
| 118 | + |
| 119 | +-- [[ Basic Autocommands ]] |
| 120 | +-- See `:help lua-guide-autocommands` |
| 121 | + |
| 122 | +-- Highlight when yanking (copying) text |
| 123 | +-- Try it with `yap` in normal mode |
| 124 | +-- See `:help vim.highlight.on_yank()` |
| 125 | +vim.api.nvim_create_autocmd('TextYankPost', { |
| 126 | + desc = 'Highlight when yanking (copying) text', |
| 127 | + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), |
| 128 | + callback = function() |
| 129 | + vim.highlight.on_yank() |
| 130 | + end, |
| 131 | +}) |
0 commit comments