SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.56k stars 691 forks source link

Snippet doesn't load anymore. #1299

Closed TornaxO7 closed 4 years ago

TornaxO7 commented 4 years ago

Expected behavior: That my snippet expands.

Actual behavior: It doesn't expand: GIF

Steps to reproduce This is at the top of my ~/.config/nvim/UltiSnips/tex.snippets file:

(...)
extends latex/math
(...)

And this is in my ~/.config/nvim/UltiSnips/latex/math.snippets:

global !p
texMathZones = [
    'texMathZone' + x for x in [
        'A',
        'AS',
        'B',
        'BS',
        'C',
        'CS',
        'D',
        'DS',
        'E',
        'ES',
        'F',
        'FS',
        'G',
        'GS',
        'H',
        'HS',
        'I',
        'IS',
        'J',
        'JS',
        'K',
        'KS',
        'L',
        'LS',
        'DS',
        'V',
        'W',
        'X',
        'Y',
        'Z',
        'AmsA',
        'AmsB',
        'AmsC',
        'AmsD',
        'AmsE',
        'AmsF',
        'AmsG',
        'AmsAS',
        'AmsBS',
        'AmsCS',
        'AmsDS',
        'AmsES',
        'AmsFS',
        'AmsGS' 
        ]
    ]
texIgnoreMathZones = ['texMathText']
texMathZoneIds = vim.eval('map(' + str(texMathZones) + ", 'hlID(v:val)')")
texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')")

ignore = texIgnoreMathZoneIds[0]

def math():
    synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))")
    try:
        first = next(i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds)
        return first != ignore
    except StopIteration:
        return False
endglobal

(...)

context "math()"
snippet frac "\frac{}{}" wA
\frac{$1}{$2}$0
endsnippet

Hint:

It worked before but I don't know exactly when it started to break.

Tongzhoutz commented 4 years ago

@TornaxO7 I have resolved this issue. Maybe you want to take a look at this : https://github.com/lervag/vimtex/issues/1863#issuecomment-733124368

TornaxO7 commented 4 years ago

@Tongzhoutz thank you very much! It's working now :)