cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
1.01k stars 46 forks source link

Global except rule to prevent autoclose when next character is non-whitespace #51

Closed HenryMarshall closed 8 years ago

HenryMarshall commented 8 years ago

In sublime and textmate (as well as the vim plugin snipmate which lacks repeat support), if the character after the cursor is non-whitespace, the closing brace is not automatically inserted:

foo |bar + ( => foo (bar

In lexima the brace is always inserted:

foo |bar + ( => foo ()bar

I prefer the sublime behavior. My reading of the documentation is an "except" rule is applied locally to a single rule.

Is there a way to add a global except rule that affects all default rules? Would my best bet be to set g:lexima_no_default_rules = 0 and then respecify them all in my vimrc? Would you be open to having the behavior I describe be toggleable with a variable?

Love the plugin, auto-closing braces are great, and repeat is even better.

cohama commented 8 years ago

It is difficult to modify the default rule but you can override it.

Please add the following script in your vimrc.

call lexima#add_rule({'at': '\%#\w', 'char': '(', 'input': '('})

This means that if your cursor is before a word character and press ( key then input (. According to lexima's priority rule, above rule overrides the default one. (See :h lexima-priorities)

Please note that \w represents the word character ([0-9A-Za-z_]).

HenryMarshall commented 8 years ago

Thanks muchly that's just what I was looking for.