File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
lua/luasnip-latex-snippets/util Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -49,8 +49,6 @@ function M.in_text(check_parent)
49
49
return true
50
50
end
51
51
52
- local in_mathzone = false
53
-
54
52
local function check_in_mathzone ()
55
53
local node = get_node_at_cursor ()
56
54
while node do
@@ -64,14 +62,21 @@ local function check_in_mathzone()
64
62
return false
65
63
end
66
64
67
- vim .api .nvim_buf_attach (0 , false , {
68
- on_lines = function (...)
69
- in_mathzone = check_in_mathzone ()
70
- end ,
71
- })
65
+ vim .api .nvim_create_autocmd ({" BufEnter" , " BufWinEnter" },
66
+ {pattern = {" *.md" },
67
+ callback = function ()
68
+ if not vim .b .tracking_math then
69
+ vim .api .nvim_buf_attach (0 , false , {on_lines = function (...)
70
+ vim .b .in_mathzone = check_in_mathzone ()
71
+ end })
72
+ vim .b .in_mathzone = false
73
+ vim .b .tracking_math = true
74
+ end
75
+ end
76
+ })
72
77
73
78
function M .in_mathzone ()
74
- return in_mathzone
79
+ return vim . b . in_mathzone
75
80
end
76
81
77
82
return M
You can’t perform that action at this time.
0 commit comments