neovim/lua/core/keymaps.lua

42 lines
916 B
Lua
Raw Normal View History

-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required
-- (otherwise wrong leader will be used)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
-- Unmap the space key (to No operation)
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 }
)
-- [[ 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 = '*',
})