aboutsummaryrefslogtreecommitdiffstats
path: root/nvim/lua/keymap.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nvim/lua/keymap.lua')
-rw-r--r--nvim/lua/keymap.lua43
1 files changed, 10 insertions, 33 deletions
diff --git a/nvim/lua/keymap.lua b/nvim/lua/keymap.lua
index e28c003..b816776 100644
--- a/nvim/lua/keymap.lua
+++ b/nvim/lua/keymap.lua
@@ -1,42 +1,19 @@
--- Provides convienent lua methods for binding keys
--- Source: Primeagen
local M = {}
-local function bind(op, outer_opts)
- outer_opts = outer_opts or {noremap = true}
- return function(lhs, rhs, opts)
- opts = vim.tbl_extend("force",
- outer_opts,
- opts or {}
- )
- vim.keymap.set(op, lhs, rhs, opts)
+local cmd_pcall = function (string)
+ local success, msg = pcall(function() vim.cmd(string) end)
+ if not success then
+ msg = string.match(tostring(msg), "E%d+.*")
+ vim.api.nvim_err_writeln(msg)
end
end
-M.nmap = bind("n", {noremap = false})
-M.nnoremap = bind("n")
-M.vnoremap = bind("v")
-M.xnoremap = bind("x")
-M.inoremap = bind("i")
-
-M.nnoremap("gf", function() vim.cmd([[:e <cfile>]]) end)
-M.nnoremap("<Leader>q", function() vim.cmd(':botright cope') end)
-M.nnoremap("<Leader>l", function()
- local success, err_msg = pcall(function()
- vim.cmd(':aboveleft lope')
- end)
- if not success then
- err_msg = string.match(tostring(err_msg), "E%d+.*")
- vim.api.nvim_err_writeln(err_msg)
- end
-end)
+vim.keymap.set('n', 'gf', function() cmd_pcall(':e <cfile>') end, {noremap = true})
+vim.keymap.set('n', "<Leader>q", function() vim.cmd(':botright cope') end)
+vim.keymap.set('n', "<Leader>l", function() cmd_pcall(':aboveleft lope') end)
-M.nnoremap("<leader>ef", function()
- vim.cmd('Lexplore')
-end)
+vim.keymap.set('n',"<Leader>k", function() vim.cmd("make") end)
-M.nnoremap("<Leader>k", function()
- vim.cmd("make")
-end)
+vim.keymap.set('t', "<ESC><ESC>", "<c-\\><c-n>")
return M