Update Vim and UltiSnips config

This commit is contained in:
foo-dogsquared 2019-08-21 20:33:45 +08:00
parent 2d56ab9509
commit 720317032e
3 changed files with 127 additions and 5 deletions

View File

@ -0,0 +1,112 @@
# Text formatting
snippet "h(\d)" "Quick header snippet" biw
`!p
header_level = int(match.group(1))
legit_header_level = True if header_level >= 1 and header_level <= 6 else False
snip.rv = "#" * header_level if legit_header_level else ""
`
$0
endsnippet
snippet dt "Definition term" bi
${1:<term>}::
${2:<definition>}
$0
endsnippet
snippet ul "Unordered list item" bi
* ${1:<list item>}
$0
endsnippet
snippet ol "Ordered list item" bi
. ${1:<list item>}
$0
endsnippet
snippet -ol "Reversed ordered list (use it only once in a list)" bi
[%reversed]
. ${1:<list item>}
endsnippet
snippet bquote "Blockquote" bi
----
$1
----
$0
endsnippet
snippet src "Source code listings" bi
[source,${1:<language>}]
----
${2:<source code>}
----
$0
endsnippet
snippet "-table (\d+)-" "Make a quick table" bir
[cols="`!p snip.rv = match.group(1)`*"]
|===
$1
|===
$0
endsnippet
# Images
snippet figure "Image block with caption" bi
.${2:<caption>}
image::${1:<image path>}[${3:width=100%,height=100%}]
$0
endsnippet
snippet -figure "Inline image" i
image:${1:<image path>}[${2}] $0
endsnippet
# Video blocks
snippet video "Video block" bi
video::${1:<image path>}[$2]
$0
endsnippet
snippet youtube "YouTube video block" bi
video::${1:<YouTube video ID>}[youtube]
$0
endsnippet
snippet vimeo "Vimeo video block" bi
video::${1:<Vimeo video ID>}[vimeo]
$0
endsnippet
# Other features
snippet incl "Include document" bi
include::${1:<file path>}[${2:<options>}]
$0
endsnippet
snippet oblock "Open block" bi
--
$1
--
$0
endsnippet
snippet sidebar "Sidebar as an open block" bi
[sidebar]
.${1:<title>}
--
$2
--
$0
endsnippet
snippet abstract "Abstract block" bi
[abstract]
== ${1:Summary}
$0
endsnippet

View File

@ -199,12 +199,11 @@ snippet plot "Quickly plot a graph" bi
xlabel=$x$,
ylabel=$y$,
xmin= ${2:-10}, xmax= ${3:10},
ymin= ${4:-10}, ymax = ${5:10},
axis lines = middle,
grid=major,
axis equal=false,
major tick style=thick,
scale only axis,
tick style={very thick},
major tick style=thick,`!p snip.rv = smart_space(t[4], "\n\t")`$4
]
\addplot[domain=$2:$3, samples=${6: `!p snip.rv = add_variable_numbers(t[2], t[3], absolute=True)`}]{$7};
\end{axis}

View File

@ -51,7 +51,7 @@ set number relativenumber
set cursorline
" set tab to enter spaces, instead
set expandtab tabstop=4 shiftwidth=4
set expandtab tabstop=4 shiftwidth=4 smartindent
let template_list = [
\ ["_minted-", ""],
@ -83,6 +83,17 @@ augroup END
" open nerd-tree at the start of each file opening
autocmd vimenter * NERDTree
" set list and other listing characters (:h listchars)
set list listchars=tab:→\ ,trail
" show leading spaces
" SOURCE: https://www.reddit.com/r/vim/comments/5fxsfy/show_leading_spaces/
hi Conceal guibg=NONE ctermbg=NONE ctermfg=DarkGrey
autocmd BufWinEnter * setl conceallevel=2 concealcursor=nv
autocmd BufWinEnter * syn match LeadingSpace /\(^ *\)\@<= / containedin=ALL conceal cchar=·
autocmd BufReadPre * setl conceallevel=2 concealcursor=nv
autocmd BufReadPre * syn match LeadingSpace /\(^ *\)\@<= / containedin=ALL conceal cchar=·
" spell checker (for your local language, anyway)
setlocal spell
set spelllang=en_gb