<commit_before>" vimtex - LaTeX plugin for Vim
"
" Maintainer: <NAME>
" Email:      <EMAIL>
"

function! vimtex#fold#init_options() " {{{1
  call vimtex#util#set_default('g:vimtex_fold_enabled', 1)
  if !g:vimtex_fold_enabled | return | endif

  call vimtex#util#set_default('g:vimtex_fold_automatic', 0)
  call vimtex#util#set_default('g:vimtex_fold_preamble', 1)
  call vimtex#util#set_default('g:vimtex_fold_envs', 1)
  call vimtex#util#set_default('g:vimtex_fold_parts',
        \ [
        \   'part',
        \   'appendix',
        \   'frontmatter',
        \   'mainmatter',
        \   'backmatter',
        \ ])
  call vimtex#util#set_default('g:vimtex_fold_sections',
        \ [
        \   'chapter',
        \   'section',
        \   'subsection',
        \   'subsubsection',
        \ ])
endfunction

" }}}1
function! vimtex#fold#init_script() " {{{1
  if !g:vimtex_fold_enabled | return | endif

  " Define some script variables
  let s:parts = '\v^\s*(\\|\% Fake)(' . join(g:vimtex_fold_parts, '|') . ')>'
  let s:secs  = '\v^\s*(\\|\% Fake)(' . join(g:vimtex_fold_sections,  '|') . ')>'
endfunction

" }}}1
function! vimtex#fold#init_buffer() " {{{1
  if !g:vimtex_fold_enabled | return | endif

  " Don't apply fold settings during diff
  if &diff | return | endif

  " Don't override modeline settings
  if s:check_modeline() | return | endif

  " Set fold options
  setlocal foldmethod=expr
  setlocal foldexpr=vimtex#fold#level(v:lnum)
  setlocal foldtext=vimtex#fold#text()

  " Remap zx to refresh fold levels
  nnoremap <silent><buffer> zx :call vimtex#fold#refresh('zx')<cr>
  nnoremap <silent><buffer> zX :call vimtex#fold#refresh('zX')<cr>

  " Define commands
  command! -buffer VimtexRefreshFolds call vimtex#fold#refresh('zx')

  " Set options for automatic/manual folding mode
  if g:vimtex_fold_automatic
    nnoremap <silent><buffer> u :call FdmSave()<cr>u:call FdmRestore()<cr>

    " For automatic folding with foldmethod=expr:
    "   The foldexpr function returns "=" for most lines, which means it can
    "   become slow for large files.  The following is a hack that is based on<commit_msg>Disable vimtex folding for vimdiff<commit_after>" vimtex - LaTeX plugin for Vim
"
" Maintainer: <NAME>
" Email:      <EMAIL>
"

function! vimtex#fold#init_options() " {{{1
  call vimtex#util#set_default('g:vimtex_fold_enabled', ! &diff)
  if !g:vimtex_fold_enabled | return | endif

  call vimtex#util#set_default('g:vimtex_fold_automatic', 0)
  call vimtex#util#set_default('g:vimtex_fold_preamble', 1)
  call vimtex#util#set_default('g:vimtex_fold_envs', 1)
  call vimtex#util#set_default('g:vimtex_fold_parts',
        \ [
        \   'part',
        \   'appendix',
        \   'frontmatter',
        \   'mainmatter',
        \   'backmatter',
        \ ])
  call vimtex#util#set_default('g:vimtex_fold_sections',
        \ [
        \   'chapter',
        \   'section',
        \   'subsection',
        \   'subsubsection',
        \ ])
endfunction

" }}}1
function! vimtex#fold#init_script() " {{{1
  if !g:vimtex_fold_enabled | return | endif

  " Define some script variables
  let s:parts = '\v^\s*(\\|\% Fake)(' . join(g:vimtex_fold_parts, '|') . ')>'
  let s:secs  = '\v^\s*(\\|\% Fake)(' . join(g:vimtex_fold_sections,  '|') . ')>'
endfunction

" }}}1
function! vimtex#fold#init_buffer() " {{{1
  if !g:vimtex_fold_enabled | return | endif

  " Don't override modeline settings
  if s:check_modeline() | return | endif

  " Set fold options
  setlocal foldmethod=expr
  setlocal foldexpr=vimtex#fold#level(v:lnum)
  setlocal foldtext=vimtex#fold#text()

  " Remap zx to refresh fold levels
  nnoremap <silent><buffer> zx :call vimtex#fold#refresh('zx')<cr>
  nnoremap <silent><buffer> zX :call vimtex#fold#refresh('zX')<cr>

  " Define commands
  command! -buffer VimtexRefreshFolds call vimtex#fold#refresh('zx')

  " Set options for automatic/manual folding mode
  if g:vimtex_fold_automatic
    nnoremap <silent><buffer> u :call FdmSave()<cr>u:call FdmRestore()<cr>

    " For automatic folding with foldmethod=expr:
    "   The foldexpr function returns "=" for most lines, which means it can
    "   become slow for large files.  The following is a hack that is based on
{'fraction_non_alphanumeric': 0.14180871212121213, 'fraction_numerical': 0.004024621212121212, 'mean_word_length': 3.5332618025751072, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3360570', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1529, 'n_words': 329}