dotfiles/.config/nvim/lua/keybindings.lua
Tanguy Herbron f02cdb1f1e feat(vim): Migration configuration to Lua
Every configuration file related to Neovim has been moved to Lua.
This comes with a variety of updatly around theming and implementation for better compatiblity accross the environment.
2023-04-07 18:24:48 +02:00

50 lines
1.3 KiB
Lua

local function map(mode, combo, mapping, opts)
local options = {noremap = true}
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.api.nvim_set_keymap(mode, combo, mapping, options)
end
vim.g.mapleader = ' '
-- Navigate through panes using lead key and vim direction
map('', '<leader>h', ':wincmd h<CR>')
map('', '<leader>j', ':wincmd j<CR>')
map('', '<leader>k', ':wincmd k<CR>')
map('', '<leader>l', ':wincmd l<CR>')
-- Move to tab using lead key plus number
map('', '<leader>1', '1gt')
map('', '<leader>2', '2gt')
map('', '<leader>3', '3gt')
map('', '<leader>4', '4gt')
map('', '<leader>5', '5gt')
map('', '<leader>6', '6gt')
map('', '<leader>7', '7gt')
map('', '<leader>8', '8gt')
map('', '<leader>9', '9gt')
map('', '<leader>0', '10gt')
-- Open undotree panel
map('', '<leader>u', ':UndotreeToggle<CR>')
-- Open lazy.nvim
map('', '<leader>p', ':Lazy home<CR>')
--- Telescope ---
-- List project files
vim.keymap.set('', '<C-p>', function() require("telescope-config").project_files() end)
-- Grep through files in project
vim.keymap.set('', '<C-f>', ":Telescope live_grep<CR>")
--- Miscellaneous
-- Toggle line wrap
vim.keymap.set('', '<leader>w', function()
vim.cmd("set wrap! linebreak! nolist!")
end)
-- Format markdown tables
map('', '<leader>t', ":TableFormat")