From 07fd9c5f4f905fd1335846eb8acfe815f9261504 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 14 Nov 2021 02:50:23 +0300 Subject: nvim: latex snippets, treesitter was bad --- .config/nvim/my_snippets/tex.snippets | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to '.config/nvim/my_snippets') diff --git a/.config/nvim/my_snippets/tex.snippets b/.config/nvim/my_snippets/tex.snippets index 503221f..ea34781 100644 --- a/.config/nvim/my_snippets/tex.snippets +++ b/.config/nvim/my_snippets/tex.snippets @@ -1,6 +1,11 @@ # vim:ft=snippets: # https://castel.dev/post/lecture-notes-1/ +global !p +def math(): + return vim.eval('vimtex#syntax#in_mathzone()') == '1' +endglobal + snippet template "Basic template" b \documentclass[a4paper]{article} @@ -96,14 +101,17 @@ ${1:${VISUAL}} .\] $0 endsnippet +context "math()" snippet '([A-Za-z])(\d)' "auto subscript" wrA `!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)` endsnippet +context "math()" snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA `!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`} endsnippet +context "math()" snippet // "Fraction" iA \\frac{$1}{$2}$0 endsnippet -- cgit v1.2.3-70-g09d2