Compare commits
3 Commits
master
...
issue-643/
Author | SHA1 | Date | |
---|---|---|---|
|
1290aa5a56 | ||
|
185b129886 | ||
|
62340124d1 |
@ -15,6 +15,7 @@ if !g:vimtex_indent_enabled | finish | endif
|
|||||||
call vimtex#util#set_default('g:vimtex_indent_ignored_envs', [
|
call vimtex#util#set_default('g:vimtex_indent_ignored_envs', [
|
||||||
\ 'document',
|
\ 'document',
|
||||||
\])
|
\])
|
||||||
|
call vimtex#util#set_default('g:vimtex_indent_delims_type', 'simple')
|
||||||
|
|
||||||
let s:cpo_save = &cpoptions
|
let s:cpo_save = &cpoptions
|
||||||
set cpoptions&vim
|
set cpoptions&vim
|
||||||
@ -56,7 +57,8 @@ function! VimtexIndent(lnum) " {{{1
|
|||||||
" Indent environments, delimiters, and tikz
|
" Indent environments, delimiters, and tikz
|
||||||
let l:ind = indent(l:prev_lnum)
|
let l:ind = indent(l:prev_lnum)
|
||||||
let l:ind += s:indent_envs(l:line, l:prev_line)
|
let l:ind += s:indent_envs(l:line, l:prev_line)
|
||||||
let l:ind += s:indent_delims(l:line, a:lnum, l:prev_line, l:prev_lnum)
|
let l:ind += s:indent_delims_{g:vimtex_indent_delims_type}(
|
||||||
|
\ l:line, a:lnum, l:prev_line, l:prev_lnum)
|
||||||
let l:ind += s:indent_tikz(l:prev_lnum, l:prev_line)
|
let l:ind += s:indent_tikz(l:prev_lnum, l:prev_line)
|
||||||
return l:ind
|
return l:ind
|
||||||
endfunction
|
endfunction
|
||||||
@ -110,7 +112,48 @@ let s:envs_begitem = s:envs_item . '\|' . s:envs_beglist
|
|||||||
let s:envs_enditem = s:envs_item . '\|' . s:envs_endlist
|
let s:envs_enditem = s:envs_item . '\|' . s:envs_endlist
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! s:indent_delims(line, lnum, prev_line, prev_lnum) " {{{1
|
function! s:indent_delims_simple(line, lnum, prev_line, prev_lnum) " {{{1
|
||||||
|
if empty(s:re_delims) | return 0 | endif
|
||||||
|
|
||||||
|
return &sw*( max([ s:count(a:prev_line, s:re_open)
|
||||||
|
\ - s:count(a:prev_line, s:re_close), 0])
|
||||||
|
\ - max([ s:count(a:line, s:re_close)
|
||||||
|
\ - s:count(a:line, s:re_open), 0]))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let s:delims_open = [
|
||||||
|
\ '\(',
|
||||||
|
\ '\[',
|
||||||
|
\ '\\\{',
|
||||||
|
\ '\\langle',
|
||||||
|
\ '\\lvert',
|
||||||
|
\ '\\lfloor',
|
||||||
|
\ '\\lceil',
|
||||||
|
\ '\\ulcorner',
|
||||||
|
\]
|
||||||
|
let s:delims_close = [
|
||||||
|
\ '\)',
|
||||||
|
\ '\]',
|
||||||
|
\ '\\\}',
|
||||||
|
\ '\\rangle',
|
||||||
|
\ '\\rvert',
|
||||||
|
\ '\\rfloor',
|
||||||
|
\ '\\rceil',
|
||||||
|
\ '\\urcorner',
|
||||||
|
\]
|
||||||
|
let s:re_open = '\v'
|
||||||
|
\ . '%(\\left|\\[bB]igg?l?)\s*%(' . join(s:delims_open, '|') . ')'
|
||||||
|
\ . '|\\left\s*\.'
|
||||||
|
\ . '|\{'
|
||||||
|
\ . '|\\\['
|
||||||
|
let s:re_close = '\v'
|
||||||
|
\ . '%(\\right|\\[bB]igg?r?)\s*%(' . join(s:delims_close, '|') . ')'
|
||||||
|
\ . '|\\right\s*\.'
|
||||||
|
\ . '|\}'
|
||||||
|
\ . '|\\\]'
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
function! s:indent_delims_complex(line, lnum, prev_line, prev_lnum) " {{{1
|
||||||
if empty(s:re_delims) | return 0 | endif
|
if empty(s:re_delims) | return 0 | endif
|
||||||
|
|
||||||
let l:pre = s:split(a:prev_line, a:prev_lnum)
|
let l:pre = s:split(a:prev_line, a:prev_lnum)
|
||||||
@ -132,6 +175,8 @@ endfunction
|
|||||||
" s:re_delims[1] == math close
|
" s:re_delims[1] == math close
|
||||||
" s:re_delims[2] == text open
|
" s:re_delims[2] == text open
|
||||||
" s:re_delims[3] == text close
|
" s:re_delims[3] == text close
|
||||||
|
" s:re_delims[4] == math open only with modifier
|
||||||
|
" s:re_delims[5] == math close only with modifier
|
||||||
"
|
"
|
||||||
let s:re_delims = vimtex#delim#get_delim_regexes()
|
let s:re_delims = vimtex#delim#get_delim_regexes()
|
||||||
|
|
||||||
|
1
test/issues/643/run_test.sh
Executable file
1
test/issues/643/run_test.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
time vim -Nu test.vim
|
1110
test/issues/643/test.tex
Normal file
1110
test/issues/643/test.tex
Normal file
File diff suppressed because it is too large
Load Diff
15
test/issues/643/test.vim
Normal file
15
test/issues/643/test.vim
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
set nocompatible
|
||||||
|
let &rtp = '~/.vim/bundle/vimtex,' . &rtp
|
||||||
|
let &rtp .= ',~/.vim/bundle/vimtex/after'
|
||||||
|
filetype plugin indent on
|
||||||
|
syntax enable
|
||||||
|
|
||||||
|
" let g:vimtex_indent_delims_type = 'complex'
|
||||||
|
|
||||||
|
silent edit test.tex
|
||||||
|
profile start test.log
|
||||||
|
profile func *
|
||||||
|
profile file *
|
||||||
|
silent! normal! gg=G
|
||||||
|
profile pause
|
||||||
|
quit!
|
Loading…
Reference in New Issue
Block a user