From 9189537120511cc6d4b6b9ea622a87832ca0bc65 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Fri, 15 Mar 2024 09:21:36 -0500 Subject: [PATCH] fix: Deal with some edge cases --- custom-snippets/tex.snippets | 7 +++++-- vimrc.vim | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/custom-snippets/tex.snippets b/custom-snippets/tex.snippets index 8f00d11..43c594d 100644 --- a/custom-snippets/tex.snippets +++ b/custom-snippets/tex.snippets @@ -3,7 +3,10 @@ global !p # def math(): # return vim.eval('vimtex#syntax#in_mathzone()') == '1' def itemize_like(): - return get_env() in ["itemize", "enumerate"] + try: + return get_env() in ["itemize", "enumerate"] + except: + return False def get_env(): return vim.eval('vimtex#env#get_inner()["name"]') @@ -20,7 +23,7 @@ snippet "\\item\s*\S+.*" "create next item" rb endsnippet context itemize_like() -pre_expand "del snip.buffer[snip.line]; snip.cursor.set(snip.line, len(snip.buffer[snip.line+1])+1)" +pre_expand "del snip.buffer[snip.line]; snip.cursor.set(snip.line, len(snip.buffer[snip.line]))" snippet "\\item\s*$" "exit itemize_like envs" rb $0 endsnippet diff --git a/vimrc.vim b/vimrc.vim index 1ea416c..0496458 100644 --- a/vimrc.vim +++ b/vimrc.vim @@ -58,7 +58,7 @@ let g:loaded_node_provider=0 let g:loaded_ruby_provider=0 " Change the leader and localleader -let mapleader = "," +let mapleader="," let maplocalleader=';' " Use ,dd for deleting without putting into buffer