2024-01-06 11:07:40 -05:00
|
|
|
-- [[ Basic Keymaps ]]
|
|
|
|
|
|
|
|
-- Keymaps for better default experience
|
|
|
|
-- See `:help vim.keymap.set()`
|
|
|
|
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
|
|
|
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex)
|
|
|
|
|
|
|
|
-- Select and Drag
|
2024-01-19 00:14:15 -05:00
|
|
|
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
|
|
|
|
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")
|
2024-01-06 11:07:40 -05:00
|
|
|
|
|
|
|
-- J without moving cursor
|
|
|
|
vim.keymap.set('n', 'J', 'mzJ`z')
|
|
|
|
|
|
|
|
-- Center cursor when jumping
|
|
|
|
vim.keymap.set('n', '<C-d>', '<C-d>zz')
|
|
|
|
vim.keymap.set('n', '<C-u>', '<C-u>zz')
|
|
|
|
|
|
|
|
-- Center cursor during search
|
|
|
|
vim.keymap.set('n', 'n', 'nzzzv')
|
|
|
|
vim.keymap.set('n', 'N', 'Nzzzv')
|
|
|
|
|
|
|
|
-- Paste without yank
|
2024-01-19 00:14:15 -05:00
|
|
|
vim.keymap.set('x', '<leader>p', '"_dP')
|
2024-01-06 11:07:40 -05:00
|
|
|
|
|
|
|
-- Delete without yank
|
2024-01-19 00:14:15 -05:00
|
|
|
vim.keymap.set({ 'n', 'v' }, '<leader>d', '"_d')
|
2024-01-06 11:07:40 -05:00
|
|
|
|
|
|
|
-- no
|
|
|
|
vim.keymap.set('n', 'Q', '<nop>')
|
|
|
|
|
|
|
|
-- Format
|
|
|
|
vim.keymap.set('n', '<leader>f', function()
|
|
|
|
vim.lsp.buf.format()
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Super substitute
|
|
|
|
vim.keymap.set('n', '<leader>s', [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
|
|
|
|
|
|
|
-- make current script executable
|
|
|
|
vim.keymap.set('n', '<leader>x', '<cmd>!chmod +x %<CR>', { silent = true })
|
|
|
|
|
|
|
|
-- 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', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
|
|
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
|
|
|
|
|
|
|
-- [[ 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 = '*',
|
|
|
|
})
|
|
|
|
|
2024-01-09 07:53:34 -05:00
|
|
|
-- Git stuff
|
2024-01-19 00:14:15 -05:00
|
|
|
vim.keymap.set('n', '<leader>gs', ':G status<CR>')
|
|
|
|
vim.keymap.set('n', '<leader>ga', ':G add %<CR>')
|
2024-01-14 21:27:40 -05:00
|
|
|
vim.keymap.set('n', '<leader>gc', [[:G commit -m ""<Left>]])
|
2024-01-19 00:14:15 -05:00
|
|
|
vim.keymap.set('n', '<leader>gp', ':G push<CR>')
|
2024-01-09 07:53:34 -05:00
|
|
|
|
2024-01-06 11:07:40 -05:00
|
|
|
-- vim: ts=2 sts=2 sw=2 et
|