From efce15ecd472b6fe61f8781497804a5ade6d62d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Joly?= Date: Thu, 15 Jun 2023 21:14:21 +0000 Subject: [PATCH] fix: Visual & Select mode mappings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, Visual mappings are defined using “v”, which according to `map-table`: Mode | Norm | Ins | Cmd | Vis | Sel | Opr | Term | Lang | Command +------+-----+-----+-----+-----+-----+------+------+ [nore]map | yes | - | - | yes | yes | yes | - | - | n[nore]map | yes | - | - | - | - | - | - | - | [nore]map! | - | yes | yes | - | - | - | - | - | i[nore]map | - | yes | - | - | - | - | - | - | c[nore]map | - | - | yes | - | - | - | - | - | v[nore]map | - | - | - | yes | yes | - | - | - | <-- x[nore]map | - | - | - | yes | - | - | - | - | <-- s[nore]map | - | - | - | - | yes | - | - | - | o[nore]map | - | - | - | - | - | yes | - | - | t[nore]map | - | - | - | - | - | - | yes | - | l[nore]map | - | yes | yes | - | - | - | - | yes | This means that we define mappings for both the Visual and the Select mode. This however pollutes the Select mode and violates the intent behind the mode. Quoting the documentation: > Users will expect printable characters to replace the selected area. > Therefore avoid mapping printable characters in Select mode. :h Select-mode-mapping Using “x”, we will only map for Visual mode. --- doc/bepo-nvim.txt | 60 ++++++++++++++++++++++----------------------- fnl/bepo.fnl | 6 ++--- lua/bepo.lua | 2 +- scripts/gen_doc.fnl | 6 ++--- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/doc/bepo-nvim.txt b/doc/bepo-nvim.txt index cead316..d85ea0f 100644 --- a/doc/bepo-nvim.txt +++ b/doc/bepo-nvim.txt @@ -43,34 +43,6 @@ only the “window” and “movement” groups of mapping, use this instead of The following subsections go into details of exactly what mappings are in each group. “Modes” have the same meaning as in the |map-table|. --------------------------------------------------------------------------------- -require("bepo").movement() *bepo.nvim-movement* -on préserve {hjkl} pour les directions - - Modes Bepo Qwerty - nx c h - nx t j - nx s k - nx r l - nx C H - nx T J - nx S K - nx R L - nx gt gj - nx gs gk - nx zT zt - nx zt zj - nx zk zs - nx zs zk - nx h t - nx H T - nx l c - nx L C - nx j r - nx J R - nx k s - nx K S - -------------------------------------------------------------------------------- require("bepo").tabs() *bepo.nvim-tabs* le couple [gb]/[gé] agit sur les tabs @@ -101,14 +73,42 @@ require("bepo").window() *bepo.nvim-windo n wé t n wÉ T +-------------------------------------------------------------------------------- +require("bepo").movement() *bepo.nvim-movement* +on préserve {hjkl} pour les directions + + Modes Bepo Qwerty + nx c h + nx t j + nx s k + nx r l + nx C H + nx T J + nx S K + nx R L + nx gt gj + nx gs gk + nx zT zt + nx zt zj + nx zk zs + nx zs zk + nx h t + nx H T + nx l c + nx L C + nx j r + nx J R + nx k s + nx K S + -------------------------------------------------------------------------------- require("bepo").easy_access() *bepo.nvim-easy_access* Modes Bepo Qwerty n « < - v « - v » >gv + x » >gv nx g, g; nx g; g, nx é w diff --git a/fnl/bepo.fnl b/fnl/bepo.fnl index 53c0f46..0a41e96 100644 --- a/fnl/bepo.fnl +++ b/fnl/bepo.fnl @@ -22,8 +22,8 @@ nil) (fn map-visual [key target] - "For normal mode mappings" - (vim.api.nvim_set_keymap :v key target {:noremap true}) + "For visual mode mappings" + (vim.api.nvim_set_keymap :x key target {:noremap true}) nil) (fn map-normal [key target] @@ -45,7 +45,7 @@ "Converts a function to the modes it sets mappings for" (match (tostring fun) :map-text-object :ox - :map-visual :v + :map-visual :x :map-normal :n :map-all :nx other (error (.. "Unsupported function " other)))) diff --git a/lua/bepo.lua b/lua/bepo.lua index 600be63..021f77b 100644 --- a/lua/bepo.lua +++ b/lua/bepo.lua @@ -4,7 +4,7 @@ local function map_text_object(key, target) return nil end local function map_visual(key, target) - vim.api.nvim_set_keymap("v", key, target, {noremap = true}) + vim.api.nvim_set_keymap("x", key, target, {noremap = true}) return nil end local function map_normal(key, target) diff --git a/scripts/gen_doc.fnl b/scripts/gen_doc.fnl index 054574c..2cc8fcc 100644 --- a/scripts/gen_doc.fnl +++ b/scripts/gen_doc.fnl @@ -38,9 +38,9 @@ (fn print-mapping-struct [struct] (match struct - {: bepo : modes : qwerty} - (let [qw (if (= ">" qwerty) "> " qwerty)] - (print (.. (right-align modes 6) " " (left-align bepo 4) " " qw))) + {: bepo : modes : qwerty} (let [qw (if (= ">" qwerty) "> " qwerty)] + (print (.. (right-align modes 6) " " + (left-align bepo 4) " " qw))) _ (error (.. "Received an invalid struct" (fennel.view struct))))) (fn print-lua-import [name]