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

Lexima inserts piece of its own source-code into buffer on <CR> in neovim #67

Open
kballenegger opened this issue Mar 16, 2017 · 4 comments

Comments

@kballenegger
Copy link

After setting up Lexima, I've noticed a bizarre bug… when typing <CR> in insert mode, a lexima rule will automatically enter its own source code into the buffer. This happens on any filetypes repeatably.

The code in question is:

pumvisible() ? "\u" : lexima#expand('
', 'i')

I believe the culpable code is this:

if has('nvim') && a:rule.char == '<CR>'
execute printf("inoremap <expr><silent> %s pumvisible() ? \"\\<C-y>\" : lexima#expand(%s, 'i')",
\ a:rule.char,
\ string(lexima#string#to_mappable(a:rule.char))
\ )
else

    if has('nvim') && a:rule.char == '<CR>'
      execute printf("inoremap <expr><silent> %s pumvisible() ? \"\\<C-y>\" : lexima#expand(%s, 'i')",
                    \ a:rule.char,
                    \ string(lexima#string#to_mappable(a:rule.char))
                    \ )
    else

My guess is that the rule.char is interpreted as a newline in the command, breaking the command, instead of the characters <CR> indicating the carriage return.

@kballenegger
Copy link
Author

Okay… so, after a bit more digging I've narrowed down the cause of the issue to any of 3 custom rules I've added:

call lexima#add_rule({'char': '<', 'input_after': '>'})
call lexima#add_rule({'char': '>', 'at': '\%#>', 'leave': 1})
call lexima#add_rule({'char': '<BS>', 'at': '\<\%#\>', 'delete': 1})

Any of these rules seems to cause this behavior. The rules themselves work at adding the <> pair, but they do cause these issues as a result.

No amount of escaping the < and > characters seems to fix this.

@cohama
Copy link
Owner

cohama commented Mar 19, 2017

Thanks for reporing but I can not replicate it. Please tell me your neovim version. and minimal nvim/init.vim file.

@kballenegger
Copy link
Author

nvim --version

NVIM 0.1.7
Build type: RelWithDebInfo
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/tmp/neovim-20170116-138-1h33iaz/neovim-0.1.7/build/config -I/tmp/neovim-20170116-138-1h33iaz/neovim-0.1.7/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/usr/include -I/tmp/neovim-20170116-138-1h33iaz/neovim-0.1.7/build/src/nvim/auto -I/tmp/neovim-20170116-138-1h33iaz/neovim-0.1.7/build/include
Compiled by [email protected]

Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui      
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.1.7/share/nvim"

My .vimrc and entire vim configuration can be seen here: https://github.com/kballenegger/dotfiles

@cohama
Copy link
Owner

cohama commented Apr 15, 2017

Sorry I could not replicate this issue.
I found out you are using many plugins. https://github.com/kballenegger/dotfiles/tree/dotfiles/.vim/bundle
One of them might conflicts with lexima. (vim-endwise looks suspicious)

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