" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve LervÄg " Email: karl.yngve@gmail.com " if exists('b:did_indent') finish endif let b:did_indent = 1 let b:did_vimtex_indent = 1 call vimtex#util#set_default('g:vimtex_indent_enabled', 1) if !g:vimtex_indent_enabled | finish | endif let s:cpo_save = &cpo set cpo&vim setlocal autoindent setlocal indentexpr=VimtexIndent() setlocal indentkeys& setlocal indentkeys+=[,(,{,),},],\&,=item function! VimtexIndent() " {{{1 " Find a non-blank non-comment line above the current line let l:nprev = prevnonblank(v:lnum - 1) while l:nprev != 0 && getline(l:nprev) =~# '^\s*%' let l:nprev = prevnonblank(l:nprev - 1) endwhile if l:nprev == 0 return 0 endif " Get current and previous line and remove comments let l:cur = substitute(getline(v:lnum), '\\\@= 0 let sum += 1 let match = matchstr(a:line, a:pattern, indx) let indx += len(match) let indx = match(a:line, a:pattern, indx) endwhile return sum endfunction " }}}1 let &cpo = s:cpo_save unlet s:cpo_save " vim: fdm=marker sw=2