1

title:

"The wrong keymap is used for the first typed character"

summary:

When entering a snippet my nvim seems to assume the keymap for the fist "typed" character is qwerty, and then on subsequent typed characters it switches back to my configured keymap which I have set to colemak by vim.opt.keymap=my_colemak_for_insert.

So im always misstyping the first character when executing an LSP snippet or my own custom snippets.

AFAIK the mode one enters upon snippet initialization is called ”select mode” - I believe this is something builtin to neovim and not specific to Luasnip, my snippet engine, because IIRC I have seen references to this "s" mode in other plugins dealing with keybings as well. So, I am wondering if there is a specific keymap that one should set for this select mode or if this is some kind of bug that I have encountered, AND if this bug would be pertaining to Neovim itself or maybe LuaSnip.

system info:

my nvim version:

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

keymap file:

let b:keymap_name = "INSERT_COLEMAK"

loadkeymap
a a
b v
...
...

and it is loaded in my config with:

vim.opt.keymap = "INSERT_COLEMAK"

snippet engine:

L3MON4D3/LuaSnip

The issue seems to occur with both my older forked branch and current master.

The issue occurs for:

  1. For my own snippets following the luasnip definitions.
  2. LSP snippets - by this I mean completions from my LSP.
  3. Snippets that come with plugins I have installed, eg. rafamadriz/friendly-snippets.

Should I ask L3MONAD3?

Does it seem like this is something I should reach out to the Luasnip maintainer about? Having thought a bit more about this issue it seems more and more logical that this is an issue pertaining to LuaSnip, hmmm.


Why do I do this:

In order to keep the muscle memory of qwerty on my machine but I write long form with a more ergonomic keymap

3
  • It would be helpful if you could give an example of what you have tried, the expected behavior and the observed behavior. It will help us to reproduce the problem and to provide some guidance (if this is not a bug in Neovim ;-)) Commented Apr 8 at 8:54
  • It would be nice to have a minimal version of your my_colemak_for_insert.vim file. The snippet engine you are using (Ultisnip, LuaSnip) and the definition of your snippet. Since keymap are only supposed to be used insert mode it is only half a surprise that you have odd behavior :-| Commented Apr 8 at 9:20
  • 1
    Thanks for listing these issues with my post - I shall come back later today and edit the post with further details to make my issue more clear. Initially, I did not realize what would be relevant useful information to add but now you have helped me with this so allow me a little time and I will make my post clearer :)
    – molleweide
    Commented Apr 8 at 9:25

1 Answer 1

1

When you insert text (Insert mode, Replace mode, Searching submode, Search editing window, Command editing window).

But not when you are in:

  • Normal mode
  • Select modes
  • Visual modes Or when you are in Command mode editing a command.

More information in :help mbyte-keymap

If LuaSnip enters in Select mode the keymap is not active.

It is somehow a "feature".

2
  • 1
    Thanks for replying Vivian - I will read up on this and get back to here. Now I also saw that there is a specific help file for "select-mode" but I could not find it easilly before. If this is a feature then I have to find out wheter or not this can be done on a custom basis somehow.
    – molleweide
    Commented Apr 8 at 15:35
  • @molleweide Hacky, but maybe snoremap (I can’t remember if that exists).
    – D. Ben Knoble
    Commented Apr 8 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.