jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.09k stars 373 forks source link

Add support to add custom languajes + tags from given file #339

Closed Carlosmape closed 2 years ago

Carlosmape commented 2 years ago

As in variable allPairs in function AutoPairsDefaultPairs() it should be a good idea to allow users to has it owns "tagfile" and add to the plugin. e.g:

AutoPairAddCustom('html', 'html5filetags')

I have already created an HTML5 tags and I am having troubles to add to these map allPairs. I tried to edit the plugin adding:

source html5.vim where I defined a map containing all tag pairs and then trying to add to these allPairs like this: let allPairs = { \ 'vim': {'\v^\s*\zs"': ''}, \ 'rust': {'\w\zs<': '>', '&\zs''': ''}, \ 'php': {'<?': '?>//k]', '<?php': '?>//k]'}, \ 'html' : items(html5map), \ } But NVim allways is outputting errors. definitively IDK how to modify a vimrc script 😓

LunarWatcher commented 2 years ago

Well, yes. items() returns an array and not a map, and bad things happen when the method iterating allPairs gets an array instead of a map.

Shameless plug for my fork though, where there's both fancy assignment, and the variable for language-specific pairs has been exposed.

And obligatory disclaimer that depending on what's in html5map, you may be better off with something dedicated to [xht]+ml tags than trying to brute-force HTML into the plugin with an enormous dictionary of applicable tags. Neither jiangmiao's original auto-pairs, nor my fork is able to do contextual substitutions at this time

Carlosmape commented 2 years ago

Thx for your reply. Okay I will take a look to your fork! The alvan/vim-closetag Sound like good approach to solve that issue, I will check it too. I tried to assign withou items() too but keep giving me errors. I guess this issue can be closed 😄