Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<Esc> doesn't quit immidietly insert mode when b:lexima_disabled = 1 #88

Open
doronbehar opened this issue Jul 10, 2019 · 6 comments
Open

Comments

@doronbehar
Copy link

Hey,

I'm really enjoying lexima and I almost never complain. It's also a much better alternative to @tpope's "endwise" which doesn't seem as configurable as this one. However, I'm having a rather annoying small inconvenience with it which I've successfully tracked down to this plugin. I'll explain:

When I first started using Vim, I noticed there is a delay between when I press <Esc> and when I actually see the mode indicator changing at the bottom. Thankfully, many people have encountered this weird default setting and have wrote about this.

Through out the years, after I changed some mappings in my init.vim, Sometimes I suddenly started noticing that my <Esc> doesn't make me leave insert mode immediately as I'm used to yet I could always track this down to clashing mappings I defined by myself e.g:

tnoremap <c-\> <c-\><c-n>
nnoremap <c-\> :SomeCommand

The issue I'm having with lexima, is that with some filetypes, where I let b:lexima_disabled = 1 and only inside these buffers, I experience that annoying lag after pressing <Esc>.

Anyway I was hoping you could help me out figure this out.

@cohama
Copy link
Owner

cohama commented Jul 11, 2019

Thank you for your feedback.
I am sorry I cannot reproduce this problem.

Please tell me some information

  • vim or nvim?
  • terminal or GUI?
  • what version?
  • result of :imap <Esc> command. (It will show existing mapping for <Esc>)
  • minimal vimrc (init.nvim) file if you know

@doronbehar
Copy link
Author

You are right. Here's some basic information:

  • Neovim it is
  • Terminal
  • Version:
NVIM v0.3.7
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: 
Compiled by nixbld

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/ir2fjws49ak1v12yh64cjbcifly7lm14-neovim-unwrapped-0.3.7/share/nvim"

Run :checkhealth for more info

Minimal setup I've tested to reproduce the issue:

mkdir -p test-config/nvim/{pack/test/start,ftplugin}
cd test-config
git clone https://github.com/cohama/lexima.vim nvim/pack/test/start/lexima
echo 'let b:lexima_disabled = 1' > nvim/ftplugin/text.vim
env XDG_CONFIG_HOME=$PWD nvim test.txt

Please test this and see I'm right. I think the issue is that I use ftplugin/text.vim and not an autocmd straight in init.vim. Also, in that case, imap <Esc> reports:

i  <Esc><Esc>  * <Esc>

While (I assume you'd expect) in a buffer where b:lexima_disabled is undefined, the result of imap <Esc> is:

i  <Esc>       *@<C-R>=lexima#insmode#escape()<CR><Esc>
i  <Esc><Esc>  * <Esc>

And that esc timeout issue doesn't occur.

I'll add to that, that if I use instead of let b:lexima_disabled = 1 in ftplugin/text.vim the following in init.vim:

autocmd FileType text let b:lexima_disabled = 1

As you propose in the help file, the issue persists.

@doronbehar
Copy link
Author

doronbehar commented Jul 16, 2019

Hey,

While trying to workaround this, I discovered that running iunmap <Esc> in a buffer where b:lexima_disabled is 1 fixes the issue. The following patch fixes this:

diff --git i/plugin/lexima.vim w/plugin/lexima.vim
index f7b377d..4f83d7a 100644
--- i/plugin/lexima.vim
+++ w/plugin/lexima.vim
@@ -20,6 +20,7 @@ endif
 
 function! s:setup_insmode()
   if get(b:, 'lexima_disabled', 0)
+    silent! iunmap <esc>
     return
   endif

I'd have opened a PR but I have no idea why exactly this is needed and I don't understand the overall design of the whole insert mode autocmds etc.

@doronbehar
Copy link
Author

What say you @cohama ?

@cohama
Copy link
Owner

cohama commented Aug 24, 2020

I'm sorry for slow response.
It is caused by your imap <Esc><Esc> <Esc> mapping, not by lexima.vim.
Please remove this mapping and try again.

@doronbehar
Copy link
Author

@cohama did you manage to reproduce the issue with the steps I gave you in my comment? I updated lexima now, and checked these steps once more and they still prove the issue.

doronbehar added a commit to doronbehar/.config_nvim that referenced this issue Oct 27, 2020
Since it has smart pairing and lexima has the annoying esc bug[1], it's
a better alternative.

[1]: cohama/lexima.vim#88
doronbehar added a commit to doronbehar/lexima.vim that referenced this issue Nov 14, 2020
doronbehar added a commit to doronbehar/lexima.vim that referenced this issue Nov 21, 2020
doronbehar added a commit to doronbehar/lexima.vim that referenced this issue Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants