commit 33cf3d7c2319fe8d8d7550a678ffe2b3cdd80991
parent 6fed37ecc326e3e253ef1e2f36b69e59837dbeff
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Thu, 4 Apr 2019 02:04:23 +0200
Vim ultisnips+vimtex
Former-commit-id: 4ce50f61cdf0e8973f0e794b4fabffede43c9a5d
Diffstat:
3 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/vim/map.vimrc b/vim/map.vimrc
@@ -32,9 +32,9 @@ if !exists("g:loaded_cool")
nnoremap <leader>/ :noh<CR>
endif
-" Tab completion
-inoremap <expr> <tab> InsertTabWrapper()
-inoremap <s-tab> <c-p>
+" Tab completion (disabled because of ultisnips)
+" inoremap <expr> <tab> InsertTabWrapper()
+" inoremap <s-tab> <c-p>
" Retain visual mode after > and <
vnoremap < <gv
diff --git a/vim/plugins.vimrc b/vim/plugins.vimrc
@@ -134,4 +134,21 @@ Plug 'romainl/vim-cool'
" but leaving in case I need it sometime.
" Plug 'dhruvasagar/vim-table-mode'
+" Vimtex {{{
+Plug 'lervag/vimtex'
+let g:tex_flavor='latex'
+let g:vimtex_view_method='general'
+let g:vimtex_quickfix_mode=0
+let g:tex_conceal='abdmg'
+" }}}
+
+" Ultisnips {{{
+Plug 'SirVer/ultisnips'
+let g:UltiSnipsExpandTrigger = '<tab>'
+let g:UltiSnipsJumpForwardTrigger = '<tab>'
+let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
+let g:UltiSnipsSnippetDirectories = [$CONF_DIR.'/vim/ultisnips']
+let g:UltiSnipsEditSplit = "vertical"
+" }}}
+
call plug#end()
diff --git a/vim/ultisnips/tex.snippets b/vim/ultisnips/tex.snippets
@@ -0,0 +1,35 @@
+snippet beg "begin{} / end{}" bA
+\begin{$1}
+ $0
+\end{$1}
+endsnippet
+snippet mk "Math" wA
+$${1}$`!p
+if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
+ snip.rv = ' '
+else:
+ snip.rv = ''
+`$2
+endsnippet
+snippet dm "Math" wA
+\[
+$1
+.\] $0
+endsnippet
+snippet '([A-Za-z])(\d)' "auto subscript" wrA
+`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
+endsnippet
+
+snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA
+`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}
+endsnippet
+snippet // "Fraction" iA
+\\frac{$1}{$2}$0
+endsnippet
+snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA
+\\frac{`!p snip.rv = match.group(1)`}{$1}$0
+endsnippet
+snippet title "Title and author"
+\title{$1}
+\author{$2}
+endsnippet