fix: Visual & Select mode mappings

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.
This commit is contained in:
Clément Joly 2023-06-15 21:14:21 +00:00
parent 6580e65ca2
commit efce15ecd4
4 changed files with 37 additions and 37 deletions

View File

@ -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é <C-w>t
n wÉ <C-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 « <gv
x « <gv
n » >
v » >gv
x » >gv
nx g, g;
nx g; g,
nx é w

View File

@ -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))))

2
lua/bepo.lua generated
View File

@ -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)

View File

@ -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]