init commit with keymaps brought over from previous, lunar nvim config
This commit is contained in:
parent
773e482d4b
commit
67a71e32af
99
init.lua
99
init.lua
|
@ -83,6 +83,10 @@ I hope you enjoy your Neovim journey,
|
||||||
|
|
||||||
P.S. You can delete this when you're done too. It's your config now! :)
|
P.S. You can delete this when you're done too. It's your config now! :)
|
||||||
--]]
|
--]]
|
||||||
|
--
|
||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
-- Shorten function name
|
||||||
|
local keymap = vim.keymap.set
|
||||||
|
|
||||||
-- Set <space> as the leader key
|
-- Set <space> as the leader key
|
||||||
-- See `:help mapleader`
|
-- See `:help mapleader`
|
||||||
|
@ -91,7 +95,7 @@ vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
-- Set to true if you have a Nerd Font installed
|
-- Set to true if you have a Nerd Font installed
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = true
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
-- See `:help vim.opt`
|
-- See `:help vim.opt`
|
||||||
|
@ -159,13 +163,13 @@ vim.opt.scrolloff = 10
|
||||||
|
|
||||||
-- Set highlight on search, but clear on pressing <Esc> in normal mode
|
-- Set highlight on search, but clear on pressing <Esc> in normal mode
|
||||||
vim.opt.hlsearch = true
|
vim.opt.hlsearch = true
|
||||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
keymap('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||||
|
|
||||||
-- Diagnostic keymaps
|
-- Diagnostic keymaps
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
|
keymap('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
|
keymap('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
|
||||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
|
keymap('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
keymap('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||||
|
|
||||||
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
||||||
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
|
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
|
||||||
|
@ -173,22 +177,59 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
|
||||||
--
|
--
|
||||||
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
|
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
|
||||||
-- or just use <C-\><C-n> to exit terminal mode
|
-- or just use <C-\><C-n> to exit terminal mode
|
||||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
keymap('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
||||||
|
|
||||||
-- TIP: Disable arrow keys in normal mode
|
-- TIP: Disable arrow keys in normal mode
|
||||||
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
|
-- keymap('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
|
||||||
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
|
-- keymap('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
|
||||||
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
|
-- keymap('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
|
||||||
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
|
-- keymap('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
|
||||||
|
--
|
||||||
|
-- Resize with arrows
|
||||||
|
keymap('n', '<C-Up>', ':resize -2<CR>', opts)
|
||||||
|
keymap('n', '<C-Down>', ':resize +2<CR>', opts)
|
||||||
|
keymap('n', '<C-Left>', ':vertical resize -2<CR>', opts)
|
||||||
|
keymap('n', '<C-Right>', ':vertical resize +2<CR>', opts)
|
||||||
|
|
||||||
|
-- Navigate buffers
|
||||||
|
keymap('n', '<S-l>', ':bnext<CR>', opts)
|
||||||
|
keymap('n', '<S-h>', ':bprevious<CR>', opts)
|
||||||
|
keymap('n', '<leader>c', ':bd<CR>', opts)
|
||||||
|
|
||||||
|
-- Move text up and down
|
||||||
|
keymap('n', '<A-j>', ':m .+1<CR>==', opts)
|
||||||
|
keymap('n', '<A-k>', ':m .-2<CR>==', opts)
|
||||||
|
|
||||||
|
-- Insert --
|
||||||
|
-- Press jk fast to exit insert mode
|
||||||
|
keymap('i', 'jk', '<ESC>', opts)
|
||||||
|
keymap('i', 'kj', '<ESC>', opts)
|
||||||
|
|
||||||
|
-- Visual --
|
||||||
|
-- Stay in indent mode
|
||||||
|
keymap('v', '<', '<gv^', opts)
|
||||||
|
keymap('v', '>', '>gv^', opts)
|
||||||
|
|
||||||
|
-- Move text up and down
|
||||||
|
keymap('v', '<A-j>', ":m '>+1<CR>gv=gv", opts)
|
||||||
|
keymap('v', '<A-k>', ":m '<-2<CR>gv=gv", opts)
|
||||||
|
keymap('v', 'p', '"_dP', opts)
|
||||||
|
|
||||||
|
-- Visual Block --
|
||||||
|
-- Move text up and down
|
||||||
|
keymap('x', 'J', ":m '>+1<CR>gv=gv", opts)
|
||||||
|
keymap('x', 'K', ":m '<-2<CR>gv=gv", opts)
|
||||||
|
keymap('x', '<A-j>', ":m '>+1<CR>gv=gv", opts)
|
||||||
|
keymap('x', '<A-k>', ":m '<-2<CR>gv=gv", opts)
|
||||||
|
|
||||||
-- Keybinds to make split navigation easier.
|
-- Keybinds to make split navigation easier.
|
||||||
-- Use CTRL+<hjkl> to switch between windows
|
-- Use CTRL+<hjkl> to switch between windows
|
||||||
--
|
--
|
||||||
-- See `:help wincmd` for a list of all window commands
|
-- See `:help wincmd` for a list of all window commands
|
||||||
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
|
keymap('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
|
||||||
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
|
keymap('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
|
||||||
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
keymap('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
||||||
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
keymap('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
||||||
|
|
||||||
-- [[ Basic Autocommands ]]
|
-- [[ Basic Autocommands ]]
|
||||||
-- See `:help lua-guide-autocommands`
|
-- See `:help lua-guide-autocommands`
|
||||||
|
@ -366,19 +407,19 @@ require('lazy').setup({
|
||||||
|
|
||||||
-- See `:help telescope.builtin`
|
-- See `:help telescope.builtin`
|
||||||
local builtin = require 'telescope.builtin'
|
local builtin = require 'telescope.builtin'
|
||||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
keymap('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
||||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
keymap('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
||||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
keymap('n', '<leader>f', builtin.find_files, { desc = '[S]earch [F]iles' })
|
||||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
keymap('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
||||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
keymap('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
||||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
keymap('n', '<leader>F', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
||||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
keymap('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
keymap('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
keymap('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
keymap('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||||
|
|
||||||
-- Slightly advanced example of overriding default behavior and theme
|
-- Slightly advanced example of overriding default behavior and theme
|
||||||
vim.keymap.set('n', '<leader>/', function()
|
keymap('n', '<leader>/', function()
|
||||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||||
winblend = 10,
|
winblend = 10,
|
||||||
|
@ -388,7 +429,7 @@ require('lazy').setup({
|
||||||
|
|
||||||
-- It's also possible to pass additional configuration options.
|
-- It's also possible to pass additional configuration options.
|
||||||
-- See `:help telescope.builtin.live_grep()` for information about particular keys
|
-- See `:help telescope.builtin.live_grep()` for information about particular keys
|
||||||
vim.keymap.set('n', '<leader>s/', function()
|
keymap('n', '<leader>s/', function()
|
||||||
builtin.live_grep {
|
builtin.live_grep {
|
||||||
grep_open_files = true,
|
grep_open_files = true,
|
||||||
prompt_title = 'Live Grep in Open Files',
|
prompt_title = 'Live Grep in Open Files',
|
||||||
|
@ -396,7 +437,7 @@ require('lazy').setup({
|
||||||
end, { desc = '[S]earch [/] in Open Files' })
|
end, { desc = '[S]earch [/] in Open Files' })
|
||||||
|
|
||||||
-- Shortcut for searching your Neovim configuration files
|
-- Shortcut for searching your Neovim configuration files
|
||||||
vim.keymap.set('n', '<leader>sn', function()
|
keymap('n', '<leader>sn', function()
|
||||||
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
||||||
end, { desc = '[S]earch [N]eovim files' })
|
end, { desc = '[S]earch [N]eovim files' })
|
||||||
end,
|
end,
|
||||||
|
@ -457,7 +498,7 @@ require('lazy').setup({
|
||||||
-- In this case, we create a function that lets us more easily define mappings specific
|
-- In this case, we create a function that lets us more easily define mappings specific
|
||||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||||
local map = function(keys, func, desc)
|
local map = function(keys, func, desc)
|
||||||
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
|
keymap('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Jump to the definition of the word under your cursor.
|
-- Jump to the definition of the word under your cursor.
|
||||||
|
|
Loading…
Reference in New Issue