Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure in Exapanding snippets/Ultisnips in inline math mode of vimwiki #1381

Open
vishalrao009 opened this issue Nov 19, 2023 · 0 comments
Open

Comments

@vishalrao009
Copy link

vishalrao009 commented Nov 19, 2023

Problem:

I am trying to expand the the UltiSnips within the math environment (I am using SirVer UltiSnips and honza/vim-snippets) but I could not do so inside the inline math mode, though I was able to expand the snippets of Ultisnips in display math mode of vimwiki. you can see that I have tried making a function to return 1 inside math environment. Function does return 1 most of the times inside inline math modes and display math modes and here is the setting in vimwiki.snippets file:

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

Here is the code I am using for example snippet

context "math()"                                         
snippet sr "^2" iA                                       
^2                                                           
endsnippet   

Here is the function included 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

Below is the outpur for :VimwikiShowVersion

Version: 2023.05.12
Os: Mac
Vim: 801
Branch: dev
Revision: 0bb1b49
Date: 2023-10-31 13:45:18 -0300

Below is the outpout for :version

:version
NVIM v0.10.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.1696795921
Run ":verbose version" for more info

Below is the vimwiki configuration snippet in init.vim of neovim:

let g:vimwiki_listsyms = '✗○◐●✓'
let g:vimwiki_list = [{'path': '/phd_work/notes/vimwiki', 'syntax': 'default', 'ext': '.wiki'}]
let g:vimwiki_html_header = '
/phd_work/notes/vimwiki_html'
let g:vimwiki_html_footer = '~/phd_work/notes/vimwiki_html'

au filetype vimwiki silent! iunmap

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

The F1 key then returns "textSnipTEX" inside math blocks of vimwiki (only when some text/number is written in this block):

{{$
any text
}}$

and $....$

Please note that the if I remove the context "math()" before snippet definition which are themselves defined in vimwiki.snippets file, then all snippets do expand without any math environment.

steps to reproduce the issue:

Install the plugin vimwiki/vimwiki ( I am using vim-plug) and try out if UltiSnips are working in math environment or not using the settings I provided and functions I am including.

@vishalrao009 vishalrao009 changed the title Exapanding snippets/Ultisnips in math mode of vimwiki Failure in Exapanding snippets/Ultisnips in inline math mode of vimwiki Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant