iurimateus / luasnip-latex-snippets.nvim

A port of Gilles Castel's UltiSnip snippets for LuaSnip.
Apache License 2.0
146 stars 64 forks source link

Cache "is_math" state #11

Open mscott99 opened 1 year ago

mscott99 commented 1 year ago

I think the code was checking whether is_math for each snippet for which this was a condition. This pr changes that behaviour so that is_math is a local variable that updates anytime the buffer is modified, and then the is_math condition on the snippets will read off this local variable.

iurimateus commented 1 year ago

Have you checked this works for all buffers (i.e. newly created)? I get the impression that on_attach will be called only once, for a single buffer.

mscott99 commented 1 year ago

Oh it seems that you are correct. Sometimes on_attach is not called. I have now fixed this, the buf_attach is now called with an autocommand each time we have a BufEnter or BufWinEnter. Also the is_math variable is now local to each buffer.

iurimateus commented 1 year ago

Do you have any profiling/benchmark? I'm curious on how many calls we're saving.

mscott99 commented 1 year ago

I don't, but I could run a quick check with some print statements or a counter to check the number of calls. I wont be able to do that right away though, probably in a week or so