summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-09-12 23:33:16 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-09-12 23:33:16 +0200
commit78d2f88b3207f00cac1d5cbe21e00286dec417e8 (patch)
tree7dc06adbc96bf2cbc7627e5f83a1a5fe9783aa97 /.config
parent30543e85eeae846b83146279e18d00da6c8473a4 (diff)
nvim: Move ‘remap()’ to mango.lib
Diffstat (limited to '.config')
-rw-r--r--.config/nvim/after/plugin/fugitive.lua4
-rw-r--r--.config/nvim/after/plugin/lsp.lua10
-rw-r--r--.config/nvim/after/plugin/telescope.lua5
-rw-r--r--.config/nvim/after/plugin/undotree.lua4
-rw-r--r--.config/nvim/lua/mango/lib.lua10
-rw-r--r--.config/nvim/lua/mango/remap.lua6
6 files changed, 25 insertions, 14 deletions
diff --git a/.config/nvim/after/plugin/fugitive.lua b/.config/nvim/after/plugin/fugitive.lua
index 6e1b92d..39f7df6 100644
--- a/.config/nvim/after/plugin/fugitive.lua
+++ b/.config/nvim/after/plugin/fugitive.lua
@@ -1 +1,3 @@
-vim.keymap.set('n', '<leader>gs', vim.cmd.Git)
+local lib = require('mango.lib')
+
+lib.remap('n', '<leader>gs', vim.cmd.Git)
diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua
index 6891256..27703fa 100644
--- a/.config/nvim/after/plugin/lsp.lua
+++ b/.config/nvim/after/plugin/lsp.lua
@@ -1,4 +1,5 @@
local lsp = require('lsp-zero')
+local lib = require('mango.lib')
lsp.preset('recommended')
lsp.ensure_installed({
@@ -30,11 +31,10 @@ lsp.setup_nvim_cmp({
lsp.on_attach(function(_, bufnr)
local opts = {buffer = bufnr, remap = false}
- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
- vim.keymap.set('n', '<leader>la', vim.lsp.buf.code_action, opts)
- vim.keymap.set('n', '<leader>lr', vim.lsp.buf.rename, opts)
- vim.keymap.set('n', '<leader>l=', vim.lsp.buf.format, opts)
- vim.keymap.set('i', '<C-h>', vim.lsp.buf.signature_help, opts)
+ lib.remap('n', 'gd', vim.lsp.buf.definition, opts)
+ lib.remap('n', '<leader>la', vim.lsp.buf.code_action, opts)
+ lib.remap('n', '<leader>lr', vim.lsp.buf.rename, opts)
+ lib.remap('n', '<leader>l=', vim.lsp.buf.format, opts)
end)
lsp.setup()
diff --git a/.config/nvim/after/plugin/telescope.lua b/.config/nvim/after/plugin/telescope.lua
index a9d9225..fa355e1 100644
--- a/.config/nvim/after/plugin/telescope.lua
+++ b/.config/nvim/after/plugin/telescope.lua
@@ -1,8 +1,9 @@
local builtin = require('telescope.builtin')
+local lib = require('mango.lib')
--vim.keymap.set('n', '<leader>pf', builtin.git_files, {})
-vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
-vim.keymap.set('n', '<leader>ps', function()
+lib.remap('n', '<leader>pf', builtin.find_files)
+lib.remap('n', '<leader>ps', function()
builtin.grep_string({ search = vim.fn.input('Grep > ') })
end)
diff --git a/.config/nvim/after/plugin/undotree.lua b/.config/nvim/after/plugin/undotree.lua
index a346462..ff5625d 100644
--- a/.config/nvim/after/plugin/undotree.lua
+++ b/.config/nvim/after/plugin/undotree.lua
@@ -1 +1,3 @@
-vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle)
+local lib = require('mango.lib')
+
+lib.remap('n', '<leader>u', vim.cmd.UndotreeToggle)
diff --git a/.config/nvim/lua/mango/lib.lua b/.config/nvim/lua/mango/lib.lua
index 71fbc08..4c38986 100644
--- a/.config/nvim/lua/mango/lib.lua
+++ b/.config/nvim/lua/mango/lib.lua
@@ -8,4 +8,14 @@ function M.set_tab_width(tw, localp)
opt.shiftwidth = tw
end
+function M.remap(modes, from, to, opts)
+ local ct = {}
+
+ modes:gsub('.', function(c)
+ table.insert(ct, c)
+ end)
+
+ vim.keymap.set(ct, from, to, opts)
+end
+
return M
diff --git a/.config/nvim/lua/mango/remap.lua b/.config/nvim/lua/mango/remap.lua
index 46e2bc2..bcc34f3 100644
--- a/.config/nvim/lua/mango/remap.lua
+++ b/.config/nvim/lua/mango/remap.lua
@@ -1,8 +1,4 @@
-local function remap(modes, from, to)
- modes:gsub('.', function(c)
- vim.keymap.set(c, from, to)
- end)
-end
+local remap = require('mango.lib').remap
vim.g.mapleader = ' '