mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 06:12:34 +00:00
Re-arrange neovim config
This commit is contained in:
62
nvim/m-housh/lua/user/mappings.lua
Normal file
62
nvim/m-housh/lua/user/mappings.lua
Normal file
@@ -0,0 +1,62 @@
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
local default_options = {noremap = true, silent = true}
|
||||
-- local expr_options = {noremap = true, expr = true, silent = true}
|
||||
|
||||
-- easier escape key mapping
|
||||
keymap('i', 'jk', '<ESC>', default_options)
|
||||
|
||||
keymap('n', '<c-s>', ':w<CR>', default_options)
|
||||
keymap('i', '<c-s>', '<ESC>:w<CR>a', default_options)
|
||||
|
||||
-- paste over currently selected text without yanking it
|
||||
keymap("v", "p", "\"_dP", default_options)
|
||||
|
||||
-- buffer focus
|
||||
keymap('n', '<c-j>', '<c-w>j', default_options)
|
||||
keymap('n', '<c-h>', '<c-w>h', default_options)
|
||||
keymap('n', '<c-k>', '<c-w>k', default_options)
|
||||
keymap('n', '<c-l>', '<c-w>l', default_options)
|
||||
|
||||
-- Resizing panes
|
||||
keymap("n", "<Left>", ":vertical resize +1<CR>", default_options)
|
||||
keymap("n", "<Right>", ":vertical resize -1<CR>", default_options)
|
||||
keymap("n", "<Up>", ":resize -1<CR>", default_options)
|
||||
keymap("n", "<Down>", ":resize +1<CR>", default_options)
|
||||
|
||||
-- Move selected line / block of text in visual mode
|
||||
keymap("x", "K", ":move '<-2<CR>gv-gv", default_options)
|
||||
keymap("x", "J", ":move '>+1<CR>gv-gv", default_options)
|
||||
|
||||
-- Toggle neo-tree open or closed
|
||||
keymap("n", "<c-n>", "<CMD>:Neotree toggle<CR>", default_options)
|
||||
|
||||
-- LuaSnip Keymaps
|
||||
local ls = require('luasnip')
|
||||
|
||||
-- <c-k> to expand snippets.
|
||||
-- This will expand the snippet or jump to the next item within the snippet.
|
||||
vim.keymap.set({ "i", "s" }, "<c-k>", function()
|
||||
if ls.expand_or_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
|
||||
-- <c-j>
|
||||
-- This will jump backwards in the snippet.
|
||||
vim.keymap.set({ "i", "s" }, "<c-j>", function()
|
||||
if ls.jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
-- <c-l>
|
||||
-- This is for selecting withing a list of options.
|
||||
vim.keymap.set("i", "<c-l>", function()
|
||||
if ls.choice_active() then
|
||||
ls.change_choice(1)
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
-- Reload the snippets.
|
||||
vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/m-housh/lua/snippets/init.lua<cr>")
|
||||
Reference in New Issue
Block a user