Skip to content

Updated Check for Math Zone #1880

@Konfekt

Description

@Konfekt

For reference: since the new syntax highlighting, a Vimscript function InMathZone() that checks whether the cursor is in a math zone now has to take account of the new highlighting groups texMathRegions (in addition to the built-in ones texMathZones), that is,

  let s:mathzones  = '\%(texMathZone\%([A-L]S\?\|[V-Z]\)\|texMathRegion\%(\|Ensured\|Env\|EnvStarred\|X\|XX\)\)'
  let s:textzones = 'texMathText\%(\|Arg\)'
  function! InMathZone()
    let ids   = reverse(map(synstack(line('.'), max([col('.') - 1, 1])), 'synIDattr(v:val, ''name'')'))
    let first = match(ids, '^' . s:mathzones . '\|' . s:textzones . '$')
    return (first >= 0 && match(ids[first], '^' . s:textzones . '$') == -1)
  endfunction

Edit: Take account of text zones in math zones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions