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

View file

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

View file

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

View file

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

View file

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