0

I am trying to use the snippets in math context inside vimwiki filetypes. The math contextual snippets are working fine for ".tex" files, but not for ".wiki" files. However all the non contextual snippets are behaving correctly in both ".tex" and in ".wiki" files.

I am using vimwiki as note making tool. I will provide the functions used in "init.vim" file and in "vimwiki.snippet" file:

Below function is defined in init.vim file:

function! InsideMathZone()
  for id in synstack(line("."), col("."))
    if synIDattr(id, "name") == "textSnipTEX" || synIDattr(id,"name")=="VimwikiMath"
      return 1
    endif
  endfor
  return 0
endfunction

I have this in my vimwiki.snippets file:

global !p

def math():
    return vim.eval('InsideMathZone()') == '1'
endglobal

This is the example snippet I am using:

priority 10
context "math()"
snippet "bar" "bar" riA
\overline{$1}$0
endsnippet

This is the code for LaTeX, which I found on vimwiki/syntax/vimwiki.vim file

" LaTex: Load
if !empty(globpath(&runtimepath, 'syntax/tex.vim'))
  execute 'syntax include @textGrouptex syntax/tex.vim'
endif
if !empty(globpath(&runtimepath, 'after/syntax/tex.vim'))
  execute 'syntax include @textGrouptex after/syntax/tex.vim'
endif

" LaTeX: Block
call vimwiki#base#nested_syntax('tex',
      \ vimwiki#vars#get_syntaxlocal('rxMathStart').'\%(.*[[:blank:][:punct:]]\)\?'.
      \ '\%([[:blank:][:punct:]].*\)\?',
      \ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')

" LaTeX: Inline
for u in syntax_dic.typeface.eq
  execute 'syntax region textSnipTEX  matchgroup=texSnip'
        \ . ' start="'.u[0].'" end="'.u[1].'"'
        \ . ' contains=@texMathZoneGroup'
        \ . ' keepend oneline '. b:vimwiki_syntax_concealends
endfor

" Emoji: :dog: (after tags to take precedence, after nested to not be reset)
if and(vimwiki#vars#get_global('emoji_enable'), 1) != 0 && has('conceal')
  call vimwiki#emoji#apply_conceal()
  exe 'syn iskeyword '.&iskeyword.',-,:'
endif

I added following in my init.vim

nnoremap <F1> <Cmd>echo synIDattr(synID(line("."), col("."), 1), "name")<CR>

I have just updated all plugins, I could not find more than two groups for pressing F1 key in normal mode:

  1. textSnipTEX (for inside the
 1.{{$ ..
...
    }}$.
 
  1. VimwikiMath
Inside linear block {{$  ...   }}$).

I could not find the syntax highlighting group named VimwikiEqIn using the key.

I have tried calling the function itself

:echo InsideMathZone()

Could some one help?

Thanks in advance. I tried to follow the similar problem discussed here: [1]: https://www.reddit.com/r/vim/comments/xh15lq/comment/iovfv9o/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.