LucHermitte / lh-brackets

LH's bracketing system for vim
Other
51 stars 2 forks source link

Weird behaviour when using Latex-suite #25

Open hadr1an opened 4 years ago

hadr1an commented 4 years ago

Not sure if it is my fault or a general thing but when I do not edit Latex files the plugin seems to be working normally. When I edit Latex files (with latex-suite) the closing bracket appears correctly with the placeholder but if I type the closing bracket, another placeholder appears with a second closing bracket. When I hit only the character before the cursor gets deleted. Any help will be appreciated, Thanks.

LucHermitte commented 4 years ago

vim-latex requires a special attention. Normally lh-brackets is written to be compatible with vim-latex. Could you described more precisely what you do and what you observe.

For instance. When vim-latex is installed, if in insert mode I type ) when the cursor in within (|)<++>, the cursor is moved after the ) and the placeholder is removed.

I can check that the insertion is given to vim-latex with:

:imap )

that prints

i  )           * <C-R>=<SNR>192_LookupCharacter(")")<CR>

instead of the following when vim-latex isn't loaded.

 i  )           * lh#brackets#closer(")",")","")

Also, vim-latex (through plugin/imaps.vim) has registered the following:

:echo strtrans(IMAP_list(')'))

displays

rhs = ^R=lh#brackets#closer(")",")","")^M place holders = <+ and +>

This is what you should observe.

LucHermitte commented 4 years ago

I observe the problem with the latest version on vim-latex. I'll try to investigate what is wrong. It's not necessarily on lh-brackets side.

hadr1an commented 4 years ago

Alright at least, if you can reproduce it, is not related to wrong configuration on my side.

LucHermitte commented 4 years ago

It looks like that somewhere someone has registered () to expand into (<++>)<++>. IMO, this mapping isn't really ergonomic.

:echo strtrans(IMAP_list('()'))

In the previous versions of vim-latex, this association didn't exist. It's done in ftplugin/latex-suite/main.vim. May be you could request to have a way to inhibit these mappings as you have another pairing/bracketing plugin that inserts the complete pair when typing the opening part.

Ideally they should detect whether the closing character is after the cursor to move over it instead of triggering an expansion. This would be a complex change, I doubt they would do it. Also, other conflicts would appear on (( for instance.

I see two paths from here:

LucHermitte commented 4 years ago

My mistake. The definitions have been here for a long time, but they did not cause any conflict.

hadr1an commented 4 years ago

I solved it after spotting the location of it. Thanks for walking me through this.

LucHermitte commented 4 years ago

You're welcome. I keep the issue open for the moment to to not forget to document this compatibility issue somewhere.