cohama / lexima.vim

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

Put closing triple backticks on a line below the cursor #121

Closed erikw closed 2 years ago

erikw commented 2 years ago

First, thanks for this great plugin!

Secondly, I would like to ask if it's already possible to configure this plugin with custom rules to get the following behaviors below. If this is not possible with custom rules, maybe it could be added in the plugin itself? :)

When typing ```<enter> (at least in a Markdown file) it would be great if the closing backtickets ended up on a new line, as this is typically how they are used i.e.

|

The current behavior of ```<enter> is:

|```


As it's common to specify a filetype for syntax highlight, it would be great if this worked also for e.g. ` ```python<enter> `:
|
cohama commented 2 years ago

Can you try bellow setting?

call lexima#add_rule({'at': '^```\(\S*\)\%#```', 'char': '<CR>', 'input': '<CR>', 'input_after': '<CR>'})
cohama commented 2 years ago

If you want to activate this rule on only markdown file, add 'filetype': ['markdown'] into dict.

erikw commented 2 years ago

@cohama it works perfectly actually! I tried in both vim and nvim both at latest versions. Many thanks :)

As this is such a useful improvement, maybe it could even go in to the plugin itself as a standard feature. Or at least mention it in the README under CUSTOMIZATION?

cohama commented 2 years ago

OK, I will add this rule as the default rule in next update.