quangnguyen30192 / cmp-nvim-ultisnips

nvim-cmp source for ultisnips
Apache License 2.0
144 stars 19 forks source link

broken UltiSnips #53

Closed mathjiajia closed 2 years ago

mathjiajia commented 2 years ago

After this new PR #50, my UltiSnips is broken for tex file: UltiSnips cannot be triggered.

Before:

Screenshot 2021-12-15 at 6 19 33 PM

After:

Screenshot 2021-12-15 at 6 18 33 PM

It does not change even if I add filetype_source = "treesitter" in the config of cmp-nvim-ultisnips. Could you help me?

More information:

Inspired by Gilles Castel, I am using VimTeX and UltiSnips to writing LaTeX documents. Based on UltiSnips context function, I add below to my tex snippets.

global !p
def math():
    return vim.eval('vimtex#syntax#in_mathzone()') == '1'
endglobal

Clearly, this math() function used syntax from VimTeX. So, in order to get "correct" context, I used additional_vim_regex_highlighting for latex. Below is (part of) my configuration of nvim-treesitter.

highlight = {
enable = true,
additional_vim_regex_highlighting = "latex"
}
smjonas commented 2 years ago

Oh man, this is not good, sorry for that :/ By the way, do you have nvim_treesitter installed? I just created a fix that improves things when that plugin is not installed. It is possible that the latest commit fixes this for you.

mathjiajia commented 2 years ago

Oh man, this is not good, sorry for that :/ By the way, do you have nvim_treesitter installed? I just created a fix that improves things when that plugin is not installed. It is possible that the latest commit fixes this for you.

Thanks. I have installed nvim-treesitter.

As a workaround, I used the last commit of cmp-nvim-ultisnips. So, still works.

smjonas commented 2 years ago

I could reproduce it and know what the problem is: UltiSnips uses tex, treesitter returns latex... Working on a fix.

smjonas commented 2 years ago

Hope everything is working again now :)

mathjiajia commented 2 years ago

You are so fast 👍.

Thank you. It was fixed now and worked great with PR #50.

smjonas commented 2 years ago

Awesome, I am glad everything is working as expected now!😄