blob: c283e699be1b5ebc1d94dcaac47b619d1960121f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
function! GetMainDoc()
let l:maindoc = search('\\begin{document}', "cnw")
if l:maindoc > 0
return '%'
else
" Find the main document file
" Must be in the same folder of the current file
let l:maindocs = split(system("grep -lE '\\\\begin{document}' " . expand('%:h') . "/*.tex"), '\n')
if len(l:maindocs) > 0
" Use the first document containing `begin{document}`
return l:maindocs[0]
else
return ""
endif
endif
endfunction
function! CompileMainDoc()
let l:latexcmd ='autocmd BufWritePost <buffer> !
\ latexrun --latex-args="-synctex=1 -interaction=nonstopmode" '
execute(l:latexcmd . GetMainDoc())
endfunction
function! Synctex()
" remove 'silent' for debugging
let l:doc = GetMainDoc()
execute "silent !mv -u latex.out/" . substitute(l:doc, '\.tex', '') . ".synctex.gz ."
execute "silent !zathura --synctex-forward " . line('.') . ":" . col('.') . ":" . bufname('%') . " " . expand('%:t:r') . ".pdf"
redraw!
endfunction
imap <buffer> FTT \texttt{}<Esc>i
imap <buffer> FBF \textbf{}<Esc>i
imap <buffer> FIT \textit{}<Esc>i
imap <buffer> FSC \textsc{}<Esc>i
imap <buffer> MTT \mathtt{}<Esc>i
imap <buffer> MBF \mathbf{}<Esc>i
imap <buffer> MIT \mathit{}<Esc>i
imap <buffer> MSC \mathsc{}<Esc>i
imap <buffer> MCC \mathcal{}<++><Esc>T{i
inoremap <buffer> <C-j> <Esc>/<++><CR>cf>
noremap <buffer> <C-j> /<++><CR>cf>
vnoremap <buffer> `it <ESC>`>a}<ESC>`<i\textit{<ESC>
vnoremap <buffer> `bf <ESC>`>a}<ESC>`<i\textbf{<ESC>
vnoremap <buffer> `tt <ESC>`>a}<ESC>`<i\texttt{<ESC>
vnoremap <buffer> `mi <ESC>`>a}<ESC>`<i\mathit{<ESC>
vnoremap <buffer> `mb <ESC>`>a}<ESC>`<i\mathbf{<ESC>
vnoremap <buffer> `mt <ESC>`>a}<ESC>`<i\mathtt{<ESC>
" put \begin{} \end{} tags tags around the current word
vnoremap <C-B> YpkI\begin{<ESC>A}<ESC>jI\end{<ESC>A}<esc>kA
nmap <C-M> :call Synctex()<CR>
"setlocal spell spelllang=en_US
call CompileMainDoc()
" autocmd BufRead *.tex imap /\ \land
" autocmd BufRead *.tex imap \/ \lor
" autocmd BufRead *.tex imap -> \rightarrow
" autocmd BufRead *.tex imap ~~ \neg
|