From 6fe5826a29fe17ed9c80659c825a49d8bf0df09d Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 4 Apr 2022 10:01:13 +0300 Subject: [PATCH] feat: fixed leader not working --- dotfiles/neovim/README.md | 41 +++++++++++++++---- dotfiles/neovim/lua/my/keymaps.lua | 4 +- dotfiles/neovim/lua/my/options.lua | 2 +- dotfiles/neovim/lua/my/plugins/arpeggio.lua | 16 +++++--- .../neovim/lua/my/plugins/lh-brackets.lua | 30 ++++++++++---- dotfiles/neovim/lua/my/plugins/telescope.lua | 16 ++++---- 6 files changed, 79 insertions(+), 30 deletions(-) diff --git a/dotfiles/neovim/README.md b/dotfiles/neovim/README.md index cb826f2..20d21c1 100644 --- a/dotfiles/neovim/README.md +++ b/dotfiles/neovim/README.md @@ -5,14 +5,40 @@ Table of my own keybinds. Here as documentation for myself. I am yet to include any of the keybinds for the lspconfig, telescope or cmp here. > Things written using italics are chords +> (aka all the keys need to be pressed at the same time) -| Keybind | Description | Plugins | -| ---------------- | -------------------------------- | --------------- | -| vv | Create vertical split | | -| \\ | Save | | -| jj | Exit insert mode | | -| _vp_ | Run command in another tmux pane | vimux, arpeggio | -| C-n | Open tree | nvim-tree | +| Keybind | Description | Plugins | +| ---------------- | ------------------------------------------- | ------------------ | +| vv | Create vertical split | | +| \\ | Save | | +| jj | Exit insert mode | | +| C-n | Open tree | nvim-tree | +| _vp_ | Run command in another tmux pane | vimux, arpeggio | +| _k_ | Insert digraph | | +| _a_ | Swap last 2 used buffers | | +| _sk_ | Move to previous lh-bracket marker | lh-brackets | +| _sj_ | Move to next lh-bracket marker | lh-brackets | +| _mo_ | Move outside the current brackets | lh-brackets | +| _ml_ | Remove all markers and move to the last one | lh-brackets | +| C-hjkl | Navigation between vim & tmux panes | vim-tmux-navigator | + +### Idris + +> The idris and arpeggio plugins are implicit here + +| Keybind | Description | +| ------- | ------------------- | +| _sc_ | Case split | +| _mc_ | Make case | +| _ml_ | Make lemma | +| _es_ | Expression search | +| _gd_ | Generate definition | +| _rh_ | Refine hole | +| _ac_ | Add clause | + +### Lean + +- Extra brackets: ⟨⟩ ## Some cool vim keybinds I sometimes forget about @@ -21,6 +47,5 @@ Documentation for myself | Keybind | Description | Plugins | | ------- | ----------------------- | ------------ | | zz | Center the current line | | -| C-w C-r | Swap 2 splits | | | gcc | Comment line | nvim-comment | | gc | Comment selection | nvim-comment | diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua index 8fcbe5f..5a0b41c 100644 --- a/dotfiles/neovim/lua/my/keymaps.lua +++ b/dotfiles/neovim/lua/my/keymaps.lua @@ -27,8 +27,10 @@ function M.setup() if arpeggio ~= nil then -- Create chords - arpeggio.chord("i", "k", "C-k") -- Rebind digraph insertion to leader+k + arpeggio.chord("i", "k", "") -- Rebind digraph insertion to leader+k + arpeggio.chord("inv", "a", "") -- Rebind switching to the last pane using leader+a end + end return M diff --git a/dotfiles/neovim/lua/my/options.lua b/dotfiles/neovim/lua/my/options.lua index ff25353..7113aad 100644 --- a/dotfiles/neovim/lua/my/options.lua +++ b/dotfiles/neovim/lua/my/options.lua @@ -30,7 +30,7 @@ function M.setup() opt.completeopt = {"menu", "menuone", "noselect"} -- Set leader - helpers.global("mapleader", "") + helpers.global("mapleader", " ") -- Import other options require("my.options.folding").setup() diff --git a/dotfiles/neovim/lua/my/plugins/arpeggio.lua b/dotfiles/neovim/lua/my/plugins/arpeggio.lua index 8e98120..6b5a33e 100644 --- a/dotfiles/neovim/lua/my/plugins/arpeggio.lua +++ b/dotfiles/neovim/lua/my/plugins/arpeggio.lua @@ -4,13 +4,19 @@ local arpeggio = vim.fn["arpeggio#map"] local M = {} function M.chord(mode, lhs, rhs, opts) - local options = helpers.mergeTables(opts, {noremap = true}) + if string.len(mode) > 1 then + for i = 1, #mode do + local c = mode:sub(i, i) + M.chord(c, lhs, rhs, opts) + end + else + local options = helpers.mergeTables(opts, {noremap = true}) + local settings = "" - local settings = "" + if options.silent then settings = settings .. "s" end - if options.silent then settings = settings .. "s" end - - arpeggio(mode, settings, options.noremap, lhs, rhs) + arpeggio(mode, settings, options.noremap, lhs, rhs) + end end function M.chordSilent(mode, lhs, rhs, opts) diff --git a/dotfiles/neovim/lua/my/plugins/lh-brackets.lua b/dotfiles/neovim/lua/my/plugins/lh-brackets.lua index 9580c9d..4deaa3e 100644 --- a/dotfiles/neovim/lua/my/plugins/lh-brackets.lua +++ b/dotfiles/neovim/lua/my/plugins/lh-brackets.lua @@ -1,8 +1,14 @@ local A = require("my.helpers.augroup") local map = require("my.keymaps").mapSilent +local arpeggio = require("my.plugins.arpeggio") local M = {} -local extraBrackets = {lean = {{"⟨", "⟩"}}} +local extraBrackets = { + lean = {{"⟨", "⟩"}}, -- lean + all = { + {"(", ")"}, {"[", "]"}, {"'", "'"}, {'"', '"'}, {"{", "}"}, {"`", "`"} + } -- more general stuff +} function M.createBracketCommand(lhs, rhs, isGlobal, opts) local suffix = "" @@ -17,19 +23,29 @@ function M.createBracket(lhs, rhs, isGlobal, opts) end function M.setup() + + if arpeggio == nil then return end + vim.g.marker_define_jump_mappings = 0 -- disable automatic binding of marker jumping (conflicts with tmux-vim-navigator) - map("inv", "sf", 'MarkersJumpF') - map("inv", "fs", 'MarkersJumpB') - map("inv", "mi", 'MarkersMark') - map("inv", "ml", 'MarkersCloseAllAndJumpToLast') - map("inv", "mo", 'MarkersJumpOutside') + arpeggio.chord("inv", "sj", 'MarkersJumpF') + arpeggio.chord("inv", "sk", 'MarkersJumpB') + arpeggio.chord("inv", "mi", 'MarkersMark') + arpeggio.chord("inv", "ml", 'MarkersCloseAllAndJumpToLast') + arpeggio.chord("inv", "mo", 'MarkersJumpOutside') for key, brackets in pairs(extraBrackets) do for _, v in ipairs(brackets) do A.augroup('custom-brackets' .. key, function() local action = M.createBracketCommand(v[1], v[2], 0, v[3] or "") - A.autocmd('BufEnter', '*.' .. key, action) + local glob = '*.' .. key + + if key == "all" then + -- The all key just matches everything + glob = "*" + end + + A.autocmd('BufEnter', glob, action) end) end end diff --git a/dotfiles/neovim/lua/my/plugins/telescope.lua b/dotfiles/neovim/lua/my/plugins/telescope.lua index c31326d..155bdaf 100644 --- a/dotfiles/neovim/lua/my/plugins/telescope.lua +++ b/dotfiles/neovim/lua/my/plugins/telescope.lua @@ -12,21 +12,21 @@ local bindings = { live_grep = "", -- See diagnostics with space + d - lsp_document_diagnostics = "d", - lsp_workspace_diagnostics = "wd", - lsp_code_actions = "ca", + lsp_document_diagnostics = "d", + lsp_workspace_diagnostics = "wd", + lsp_code_actions = "ca", -- Open a list with all the pickers - builtin = "t", + builtin = "t", -- List function, var names etc - treesitter = "s", + treesitter = "s", -- Git stuff - git_commits = "gj", - git_branches = "gk" + git_commits = "gj", + git_branches = "gk" }, - ["extensions.file_browser.file_browser"] = "p", + ["extensions.file_browser.file_browser"] = "p", extensions = { unicode = {picker = {mode = "i", kind = "dropdown", key = "uu"}} }