From 825d798d2a1f3d718ed723f730b2c5a022aaaefa Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 11 May 2023 17:30:35 +0300 Subject: [PATCH] add terminal mode keymaps and lua abbr --- lua/bindings.lua | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lua/bindings.lua b/lua/bindings.lua index 43c0568..8ca543e 100644 --- a/lua/bindings.lua +++ b/lua/bindings.lua @@ -5,12 +5,12 @@ local silent = {silent = true} -- Disable Ex mode map('n', 'Q', '') --- Escape from terminal easier -map('t', '', '') - -- Save file map('n', '', ':w') +-- Paste from register and not replace it +-- map('x', 'p', '"_dP') + -- Window movement map('n', '', 'h') map('n', '', 'j') @@ -37,3 +37,23 @@ map('n', '', ':m .+1==', silent) map('n', '', ':m .-2==', silent) map('v', '', ":m '>+1gv=gv", silent) map('v', '', ":m '<-2gv=gv", silent) + +-- Move between windows easier in terminal windows +function _G.set_terminal_keymaps() + local opts = {buffer = 0} + vim.keymap.set('t', '', [[]], opts) + vim.keymap.set('t', '', [[wincmd h]], opts) + vim.keymap.set('t', '', [[wincmd j]], opts) + vim.keymap.set('t', '', [[wincmd k]], opts) + vim.keymap.set('t', '', [[wincmd l]], opts) +end +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +-- Add abbreviation for != => ~= in lua files +vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("MyTermOpen", { clear = true }), + pattern = "*.lua", + callback = function() + vim.api.nvim_cmd({ cmd = "abb", args = {"!=", "~="}}, {}) + end +})