1
Fork 0

Modified a bunch of stuff to work with the native vim.keymap.set function

This commit is contained in:
Matei Adriel 2022-08-24 14:29:04 +03:00
parent cc6a209d8d
commit 7c77d3a8dd
6 changed files with 45 additions and 67 deletions

View file

@ -3,11 +3,11 @@ local arpeggio = require("my.plugins.arpeggio")
local M = {}
function M.map(mode, lhs, rhs, opts)
local function map(mode, lhs, rhs, opts)
if string.len(mode) > 1 then
for i = 1, #mode do
local c = mode:sub(i, i)
M.map(c, lhs, rhs, opts)
map(c, lhs, rhs, opts)
end
else
local options = helpers.mergeTables(opts, { noremap = true })
@ -17,11 +17,11 @@ end
function M.mapSilent(mode, lhs, rhs, opts)
local options = helpers.mergeTables(opts, { silent = true })
M.map(mode, lhs, rhs, options)
map(mode, lhs, rhs, options)
end
function M.setup()
M.map("n", "qq", ":wq<cr>") -- Save and quit
vim.keymap.set("n", "qq", ":wq<cr>") -- Save and quit
-- Create chords
if arpeggio ~= nil then

View file

@ -1,20 +1,18 @@
local mapSilent = require("my.keymaps").mapSilent
local M = {}
local bindings = {
-- Open files with control + P
files = "<c-P>",
-- See diagnostics with space + d
lsp_document_diagnostics = "<space>d",
lsp_workspace_diagnostics = "<space>D"
-- Open files with control + P
files = "<c-P>",
-- See diagnostics with space + d
lsp_document_diagnostics = "<space>d",
lsp_workspace_diagnostics = "<space>D"
}
function M.setup()
for action, keybind in pairs(bindings) do
-- Maps the keybind to the action
mapSilent('n', keybind, "<cmd>lua require('fzf-lua')." .. action .. "()<CR>")
end
for action, keybind in pairs(bindings) do
-- Maps the keybind to the action
vim.keymap.set('n', keybind, require('fzf-lua')[action])
end
end
return M

View file

@ -5,7 +5,6 @@ function M.setup()
require('nvim-autopairs').setup()
require "gitlinker".setup()
vscode.unless(function()
require("presence"):setup({})
require("my.plugins.dashboard").setup()
@ -20,7 +19,6 @@ function M.setup()
require("my.plugins.vimux").setup()
end)
require("my.plugins.vim-tmux-navigator").setup()
require("my.plugins.neogit").setup()
require("my.plugins.comment").setup()
require("my.plugins.telescope").setup()

View file

@ -1,54 +1,53 @@
local A = require("my.helpers.augroup")
local map = require("my.keymaps").mapSilent
local arpeggio = require("my.plugins.arpeggio")
local M = {}
local extraBrackets = {
lean = {{"", ""}}, -- lean
all = {
-- {"(", ")"}, {"[", "]"}, {"'", "'"}, {'"', '"'}, {"{", "}"}, {"`", "`"}
} -- more general stuff
lean = { { "", "" } }, -- lean
all = {
-- {"(", ")"}, {"[", "]"}, {"'", "'"}, {'"', '"'}, {"{", "}"}, {"`", "`"}
} -- more general stuff
}
function M.createBracketCommand(lhs, rhs, isGlobal, opts)
local suffix = ""
if isGlobal then suffix = "!" end
local suffix = ""
if isGlobal then suffix = "!" end
return ":Brackets" .. suffix .. " " .. lhs .. " " .. rhs .. " " ..
(opts or "")
return ":Brackets" .. suffix .. " " .. lhs .. " " .. rhs .. " " ..
(opts or "")
end
function M.createBracket(lhs, rhs, isGlobal, opts)
vim.cmd(M.createBracketCommand(lhs, rhs, isGlobal, opts))
vim.cmd(M.createBracketCommand(lhs, rhs, isGlobal, opts))
end
function M.setup()
if arpeggio == nil then return end
if arpeggio == nil then return end
vim.g.marker_define_jump_mappings = 0 -- disable automatic binding of marker jumping (conflicts with tmux-vim-navigator)
vim.g.marker_define_jump_mappings = 0 -- disable automatic binding of marker jumping (conflicts with tmux-vim-navigator)
arpeggio.chord("nv", "sj", '<Plug>MarkersJumpF')
arpeggio.chord("nv", "sk", '<Plug>MarkersJumpB')
arpeggio.chord("nv", "mi", '<Plug>MarkersMark')
arpeggio.chord("nv", "ml", '<Plug>MarkersCloseAllAndJumpToLast')
arpeggio.chord("nv", "mo", '<Plug>MarkersJumpOutside')
arpeggio.chord("nv", "sj", '<Plug>MarkersJumpF')
arpeggio.chord("nv", "sk", '<Plug>MarkersJumpB')
arpeggio.chord("nv", "mi", '<Plug>MarkersMark')
arpeggio.chord("nv", "ml", '<Plug>MarkersCloseAllAndJumpToLast')
arpeggio.chord("nv", "mo", '<Plug>MarkersJumpOutside')
for key, brackets in pairs(extraBrackets) do
A.augroup('custom-brackets' .. key, function()
for _, v in ipairs(brackets) do
local action = M.createBracketCommand(v[1], v[2], 0, v[3] or "")
local glob = '*.' .. key
for key, brackets in pairs(extraBrackets) do
A.augroup('custom-brackets' .. key, function()
for _, v in ipairs(brackets) do
local action = M.createBracketCommand(v[1], v[2], 0, v[3] or "")
local glob = '*.' .. key
if key == "all" then
-- The all key just matches everything
glob = "*"
end
if key == "all" then
-- The all key just matches everything
glob = "*"
end
A.autocmd('BufEnter', glob, action)
end
end)
end
A.autocmd('BufEnter', glob, action)
end
end)
end
end
return M

View file

@ -1,11 +1,9 @@
local mapSilent = require("my.keymaps").mapSilent
local M = {}
function M.setup()
require'nvim-tree'.setup()
-- Toggle nerdtree with Control-t
mapSilent("n", "<C-n>", ":NvimTreeToggle<CR>")
require 'nvim-tree'.setup()
-- Toggle nerdtree with Control-n
vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>")
end
return M

View file

@ -1,15 +0,0 @@
local map = require("my.keymaps").map
local M = {}
-- For some reason the default mappings do not work for me
function M.setup()
vim.g.tmux_navigator_no_mappings = 1
map("n", "<C-h>", ":TmuxNavigateLeft<cr>")
map("n", "<C-j>", ":TmuxNavigateDown<cr>")
map("n", "<C-k>", ":TmuxNavigateUp<cr>")
map("n", "<C-l>", ":TmuxNavigateRight<cr>")
end
return M