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/lua/plugin_settings.lua | 1 + .config/nvim/my_snippets/tex.snippets | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to '.config') diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua index 5b999fe..56612f5 100644 --- a/.config/nvim/lua/plugin_settings.lua +++ b/.config/nvim/lua/plugin_settings.lua @@ -254,6 +254,7 @@ require 'nvim-treesitter.configs'.setup { ensure_installed = "maintained", highlight = { enable = true, + disable = { "latex" }, additional_vim_regex_highlighting = false, }, incremental_selection = { 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