50 lines
1.8 KiB
Lua
50 lines
1.8 KiB
Lua
|
-- [[ Basic Keymaps ]]
|
||
|
|
||
|
-- Keymaps for better default experience
|
||
|
-- See `:help vim.keymap.set()`
|
||
|
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { 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 })
|
||
|
|
||
|
-- Remap for vertical navigation
|
||
|
vim.keymap.set('n', '<C-d>', '<C-d>zz', { noremap = true, silent = true })
|
||
|
vim.keymap.set('n', '<C-u>', '<C-u>zz', { noremap = true, silent = true })
|
||
|
vim.keymap.set('n', 'n', 'nzzzv', { noremap = true, silent = true })
|
||
|
vim.keymap.set('n', 'N', 'Nzzzv', { noremap = true, silent = true })
|
||
|
|
||
|
-- [[ 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 = '*',
|
||
|
})
|
||
|
|
||
|
-- Diagnostic keymaps
|
||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
||
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
|
||
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
|
||
|
|
||
|
-- terminal keymaps
|
||
|
function _G.set_terminal_keymaps()
|
||
|
local opts = { buffer = 0 }
|
||
|
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
|
||
|
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
||
|
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
||
|
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
||
|
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
||
|
end
|
||
|
|
||
|
--
|
||
|
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
|
||
|
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
||
|
|
||
|
|
||
|
return {}
|