L3MON4D3 / LuaSnip

Snippet Engine for Neovim written in Lua.
Apache License 2.0
3.44k stars 243 forks source link

Having remappings in the visual layer prevents LuaSnip from accepting text #918

Closed Zeioth closed 1 year ago

Zeioth commented 1 year ago

How to reproduce

How to solve the bug

Workarounds

Deleting my mappings of the visual layer fixes the issue. But then I don't have mappings in the visual layer.

screenshot_2023-06-12_05-18-35_331844180

Zeioth commented 1 year ago

Tested with the next mappings:

-- This is AstroNvim, sorry for the weird syntax

-- colemak-dh remaps (visual) -----------------------------------------------
-- These remaps exchange the position of some keys

-- movement keys
maps.v["m"]     = { "h", desc = "Movement left (colemak-dh remap)" }
maps.v["n"]     = { "j", desc = "Movement down (colemak-dh remap)" }
maps.v["e"]     = { "k", desc = "Movement up (colemak-dh remap)" }
maps.v["i"]     = { "l", desc = "Movement right (colemak-dh remap)" }
maps.v["M"]     = { "H", desc = "Movement left (colemak-dh remap)" }
maps.v["N"]     = { "J", desc = "Movement down (colemak-dh remap)" }
maps.v["E"]     = { "K", desc = "Movement up (colemak-dh remap)" }
maps.v["I"]     = { "L", desc = "Movement right (colemak-dh remap)" }

-- insert
maps.v["o"]     = { "i", desc = "Insert (colemak-dh remap)" }
maps.v["O"]     = { "I", desc = "Insert (colemak-dh remap)" }

-- substitute
maps.v["j"]     = { "s", desc = "Substitute (colemak-dh remap)" }
maps.v["J"]     = { "S", desc = "Substitute (colemak-dh remap)" }

-- marker
maps.v["w"]     = { "m", desc = "Marker (colemak-dh remap)" }
maps.v["W"]     = { "M", desc = "Marker (colemak-dh remap)" }

-- next word first char
maps.v["b"]     = { "w", desc = "Next word first char (colemak-dh remap)" }
maps.v["B"]     = { "W", desc = "Next word first char (colemak-dh remap)" }

-- search next
maps.v["k"]     = { "n", desc = "Search next (colemak-dh remap)" }
maps.v["K"]     = { "N", desc = "Search prev (colemak-dh remap)" }

-- next word
maps.v["t"]     = { "e", desc = "Next word (colemak-dh remap)" }
maps.v["T"]     = { "E", desc = "Next word (colemak-dh remap)" }

-- prev word
maps.v["s"]     = { "b", desc = "Prev word (colemak-dh remap)" }
maps.v["S"]     = { "B", desc = "Prev word (colemak-dh remap)" }

-- find till
maps.v["h"]     = { "t", desc = "Find untill (colemak-dh remap)" }
maps.v["H"]     = { "T", desc = "Find untill (colemak-dh remap)" }
L3MON4D3 commented 1 year ago

We use select, not visual! Check :h for the different modes a key can be mapped in, v combines visual and select, but there's also one which only applies to visual (and if you use that one, the issue should disappear)

Zeioth commented 1 year ago

Sorry for the delay. I confirm that mapping to x instead of v fixed the issue. I leave this here for future reference:

--   MAPPINGS REFERENCE
--   -------------------------------------------------------------------
--   |        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  |
--   -------------------------------------------------------------------