diff --git a/vim/.vim/own-snippets/asciidoc.snippets b/vim/.vim/own-snippets/asciidoc.snippets index c3c9dc4..39cf314 100644 --- a/vim/.vim/own-snippets/asciidoc.snippets +++ b/vim/.vim/own-snippets/asciidoc.snippets @@ -1,3 +1,16 @@ +global !p +def smart_space(next_str, auto_str=" ", loose=False): + next_word = "" + + if next_str: + if loose == True: + next_word = auto_str + elif next_str[0] in [",", ".", "-", "!", "?", " "]: + next_word = auto_str + + return next_word +endglobal + # Text formatting snippet "h(\d)" "Quick header snippet" biw `!p @@ -9,6 +22,22 @@ snip.rv = "#" * header_level if legit_header_level else "" $0 endsnippet +snippet tt "Monospace" biw +`$1` $0 +endsnippet + +snippet hl "Highlighted text" biw +#$1# $0 +endsnippet + +snippet sp "Superscript" biw +^$1^ $0 +endsnippet + +snippet sb "Subscript" biw +~$1~ $0 +endsnippet + snippet dt "Definition term" bi ${1:}:: ${2:} @@ -55,7 +84,7 @@ $1 $0 endsnippet -# Images +# Multimedia blocks snippet figure "Image block with caption" bi .${2:} image::${1:}[${3:width=100%,height=100%}] @@ -66,7 +95,6 @@ snippet -figure "Inline image" i image:${1:}[${2}] $0 endsnippet -# Video blocks snippet video "Video block" bi video::${1:}[$2] $0 @@ -82,6 +110,11 @@ video::${1:}[vimeo] $0 endsnippet +snippet audio "Audio block" bi +audio::${1:}[`!p snip.rv=smart_space(t[2], "options=", loose=True)`$2] +$0 +endsnippet + # Other features snippet incl "Include document" bi include::${1:}[${2:}] diff --git a/vim/.vim/own-snippets/tex.snippets b/vim/.vim/own-snippets/tex.snippets index e0a1ecb..a47445e 100644 --- a/vim/.vim/own-snippets/tex.snippets +++ b/vim/.vim/own-snippets/tex.snippets @@ -8,11 +8,28 @@ texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)') ignore = texIgnoreMathZoneIds[0] -def smart_space(next_str, auto_str=" "): - if next_str and next_str[0] in [",", ".", "-", "!", "?", " "]: - snip.rv = auto_str - else: - snip.rv = "" +def math(): + synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))") + try: + first = next( + i for i in reversed(synstackids) + if i in texIgnoreMathZoneIds or i in texMathZoneIds + ) + return first != ignore + except StopIteration: + return False + + +def smart_space(next_str, auto_str=" ", loose=False): + next_word = "" + + if next_str: + if loose == True: + next_word = auto_str + elif next_str[0] in [",", ".", "-", "!", "?", " "]: + next_word = auto_str + + return next_word def add_variable_numbers(*inputs, **kwargs): absolute = kwargs.pop("absolute", False) @@ -37,8 +54,6 @@ snippet template "Main template (that should work without relying with style fil % all of the packages to be used \usepackage[nocomments]{standalone} -\usepackage{chngcntr} -\usepackage{import} \usepackage[utf8]{inputenc} \usepackage{fontawesome} \usepackage[english]{babel} @@ -129,28 +144,28 @@ $0 endsnippet # Common commands -snippet pack "Use package command" i -\usepackage`!p smart_space(t[2], "[")`$2`!p smart_space(t[2], "]")`{$1} +snippet pack "Use package command" bis +\usepackage`!p snip.rv=smart_space(t[2], "[",loose=True)`$2`!p snip.rv=smart_space(t[2], "]",loose=True)`{$1} $0 endsnippet -snippet letter "Make at letter block" i +snippet letter "Make at letter block" bis \makeatletter $1 \makeatother $0 endsnippet -snippet label "Create a label" i +snippet label "Create a label" bi \label{$1} $0 endsnippet -snippet ref "Create a reference for a label" i +snippet ref "Create a reference for a label" bi \ref{${1: