Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 116 forks source link

Excluded Regions for TeX Math #277

Open avonmoll opened 5 years ago

avonmoll commented 5 years ago

In TeX, I'm using things like \left( x + 2 \right) often. I'm using UltiSnips to create the left-right pairs. I would like for delimitMate to ignore the \left( and not try to automatically close the parenthesis. From the tex syntax definition I discerned that things like \left( and \biggl( are in something like texMathDelimGroup or just texMathDelim. I tried this setting in my .vimrc:

let delimitMate_excluded_regions = "texMathDelim,texMathDelimGroup"

However, I'm still getting autoclosing when I type \left(.

BTW, I also have let delimitMate_smart_matchpairs = ''.

samoshkin commented 5 years ago

Same issue. Trying to avoid autoclosing pairs for "String" and "Comment" syntax groups, as described in a doc. Unfortunately, it does not work, autoclosing behavior is still in action.

let delimitMate_excluded_regions = "Comment,String"

Then I check my highlight groups for "Comment" and "String". As I'm using "vim-dracula" theme, those syntax groups are linked to Dracula internal groups.

:hi String
String         xxx links to DraculaYellow

:hi Comment
Comment        xxx term=bold ctermfg=14 guifg=#80a0ff
                   links to DraculaComment

Then, I tweaked a config to refer those "Dracula" highlight groups instead. And it works!!!

let delimitMate_excluded_regions = "DraculaComment,DraculaYellow"

AFAIK, in Vim syntax group name (String, Comment) and highlight group are separate concepts. Syntax group indicates a particular token in a text, and can be linked to a highlight group to apply colours.

But turns out this plugin relies upon highlight groups rather than syntax group names. If you're not using any theme, String and Comment group names would work just fine. However, if they are linked by a theme plugin (my case), you have to use aforementioned workaround. Be aware, that this solution makes your vimrc more fragile by putting implicit extra dependency to your current vim theme.