From 7c77d3a8ddce91ab4a84cf5d5394861bfc227f79 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Wed, 24 Aug 2022 14:29:04 +0300 Subject: [PATCH] Modified a bunch of stuff to work with the native vim.keymap.set function --- dotfiles/neovim/lua/my/keymaps.lua | 8 +-- dotfiles/neovim/lua/my/plugins/fzf-lua.lua | 20 +++---- dotfiles/neovim/lua/my/plugins/init.lua | 2 - .../neovim/lua/my/plugins/lh-brackets.lua | 59 +++++++++---------- dotfiles/neovim/lua/my/plugins/nvim-tree.lua | 8 +-- .../lua/my/plugins/vim-tmux-navigator.lua | 15 ----- 6 files changed, 45 insertions(+), 67 deletions(-) delete mode 100644 dotfiles/neovim/lua/my/plugins/vim-tmux-navigator.lua diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua index bdf671b..e73518b 100644 --- a/dotfiles/neovim/lua/my/keymaps.lua +++ b/dotfiles/neovim/lua/my/keymaps.lua @@ -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") -- Save and quit + vim.keymap.set("n", "qq", ":wq") -- Save and quit -- Create chords if arpeggio ~= nil then diff --git a/dotfiles/neovim/lua/my/plugins/fzf-lua.lua b/dotfiles/neovim/lua/my/plugins/fzf-lua.lua index 837e251..2248a0b 100644 --- a/dotfiles/neovim/lua/my/plugins/fzf-lua.lua +++ b/dotfiles/neovim/lua/my/plugins/fzf-lua.lua @@ -1,20 +1,18 @@ -local mapSilent = require("my.keymaps").mapSilent - local M = {} local bindings = { - -- Open files with control + P - files = "", - -- See diagnostics with space + d - lsp_document_diagnostics = "d", - lsp_workspace_diagnostics = "D" + -- Open files with control + P + files = "", + -- See diagnostics with space + d + lsp_document_diagnostics = "d", + lsp_workspace_diagnostics = "D" } function M.setup() - for action, keybind in pairs(bindings) do - -- Maps the keybind to the action - mapSilent('n', keybind, "lua require('fzf-lua')." .. action .. "()") - 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 diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua index cd97c0f..d84c2aa 100644 --- a/dotfiles/neovim/lua/my/plugins/init.lua +++ b/dotfiles/neovim/lua/my/plugins/init.lua @@ -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() diff --git a/dotfiles/neovim/lua/my/plugins/lh-brackets.lua b/dotfiles/neovim/lua/my/plugins/lh-brackets.lua index 778b64a..f54977d 100644 --- a/dotfiles/neovim/lua/my/plugins/lh-brackets.lua +++ b/dotfiles/neovim/lua/my/plugins/lh-brackets.lua @@ -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", 'MarkersJumpF') - arpeggio.chord("nv", "sk", 'MarkersJumpB') - arpeggio.chord("nv", "mi", 'MarkersMark') - arpeggio.chord("nv", "ml", 'MarkersCloseAllAndJumpToLast') - arpeggio.chord("nv", "mo", 'MarkersJumpOutside') + arpeggio.chord("nv", "sj", 'MarkersJumpF') + arpeggio.chord("nv", "sk", 'MarkersJumpB') + arpeggio.chord("nv", "mi", 'MarkersMark') + arpeggio.chord("nv", "ml", 'MarkersCloseAllAndJumpToLast') + arpeggio.chord("nv", "mo", '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 diff --git a/dotfiles/neovim/lua/my/plugins/nvim-tree.lua b/dotfiles/neovim/lua/my/plugins/nvim-tree.lua index 63e5c05..92e415f 100644 --- a/dotfiles/neovim/lua/my/plugins/nvim-tree.lua +++ b/dotfiles/neovim/lua/my/plugins/nvim-tree.lua @@ -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", "", ":NvimTreeToggle") + require 'nvim-tree'.setup() + -- Toggle nerdtree with Control-n + vim.keymap.set("n", "", ":NvimTreeToggle") end return M diff --git a/dotfiles/neovim/lua/my/plugins/vim-tmux-navigator.lua b/dotfiles/neovim/lua/my/plugins/vim-tmux-navigator.lua deleted file mode 100644 index ab8b77b..0000000 --- a/dotfiles/neovim/lua/my/plugins/vim-tmux-navigator.lua +++ /dev/null @@ -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", "", ":TmuxNavigateLeft") - map("n", "", ":TmuxNavigateDown") - map("n", "", ":TmuxNavigateUp") - map("n", "", ":TmuxNavigateRight") -end - -return M