Update UltiSnips snippets and Vim config

This commit is contained in:
foo-dogsquared 2019-08-22 20:25:27 +08:00
parent 2d208252e3
commit ac4951378e
3 changed files with 378 additions and 211 deletions

View File

@ -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 # Text formatting
snippet "h(\d)" "Quick header snippet" biw snippet "h(\d)" "Quick header snippet" biw
`!p `!p
@ -9,6 +22,22 @@ snip.rv = "#" * header_level if legit_header_level else ""
$0 $0
endsnippet 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 snippet dt "Definition term" bi
${1:<term>}:: ${1:<term>}::
${2:<definition>} ${2:<definition>}
@ -55,7 +84,7 @@ $1
$0 $0
endsnippet endsnippet
# Images # Multimedia blocks
snippet figure "Image block with caption" bi snippet figure "Image block with caption" bi
.${2:<caption>} .${2:<caption>}
image::${1:<image path>}[${3:width=100%,height=100%}] image::${1:<image path>}[${3:width=100%,height=100%}]
@ -66,7 +95,6 @@ snippet -figure "Inline image" i
image:${1:<image path>}[${2}] $0 image:${1:<image path>}[${2}] $0
endsnippet endsnippet
# Video blocks
snippet video "Video block" bi snippet video "Video block" bi
video::${1:<image path>}[$2] video::${1:<image path>}[$2]
$0 $0
@ -82,6 +110,11 @@ video::${1:<Vimeo video ID>}[vimeo]
$0 $0
endsnippet endsnippet
snippet audio "Audio block" bi
audio::${1:<image path>}[`!p snip.rv=smart_space(t[2], "options=", loose=True)`$2]
$0
endsnippet
# Other features # Other features
snippet incl "Include document" bi snippet incl "Include document" bi
include::${1:<file path>}[${2:<options>}] include::${1:<file path>}[${2:<options>}]

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@ let g:UltiSnipsSnippetDirectories = [$HOME . "/.vim/own-snippets"]
let g:UltiSnipsExpandTrigger="<tab>" let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>" let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>" let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsEditSplit="context"
Plug 'scrooloose/nerdtree' Plug 'scrooloose/nerdtree'
@ -51,7 +52,7 @@ set number relativenumber
set cursorline set cursorline
" set tab to enter spaces, instead " set tab to enter spaces, instead
set expandtab tabstop=4 shiftwidth=4 smartindent set expandtab
let template_list = [ let template_list = [
\ ["_minted-", ""], \ ["_minted-", ""],