Change latex provider to luatex, closes #476

This commit is contained in:
Adam Stankiewicz
2020-04-25 21:30:46 +02:00
parent 8ec73a3a89
commit d757bfd643
125 changed files with 17923 additions and 3400 deletions

View File

@@ -0,0 +1,85 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
" vimtex - LaTeX plugin for Vim
"
" Maintainer: Karl Yngve Lervåg
" Email: karl.yngve@gmail.com
"
function! vimtex#text_obj#cmdtargets#new(args) " {{{1
return {
\ 'genFuncs': {
\ 'c': function('vimtex#text_obj#cmdtargets#current'),
\ 'n': function('vimtex#text_obj#cmdtargets#next'),
\ 'l': function('vimtex#text_obj#cmdtargets#last'),
\ },
\ 'modFuncs': {
\ 'i': [function('vimtex#text_obj#cmdtargets#inner'),
\ function('targets#modify#drop')],
\ 'a': [function('targets#modify#keep')],
\ 'I': [function('vimtex#text_obj#cmdtargets#inner'),
\ function('targets#modify#shrink')],
\ 'A': [function('targets#modify#expand')],
\ }}
endfunction
" }}}1
function! vimtex#text_obj#cmdtargets#current(args, opts, state) " {{{1
let target = s:select(a:opts.first ? 1 : 2)
call target.cursorE() " keep going from right end
return target
endfunction
" }}}1
function! vimtex#text_obj#cmdtargets#next(args, opts, state) " {{{1
if targets#util#search('\\\S*{', 'W') > 0
return targets#target#withError('no target')
endif
let oldpos = getpos('.')
let target = s:select(1)
call setpos('.', oldpos)
return target
endfunction
" }}}1
function! vimtex#text_obj#cmdtargets#last(args, opts, state) " {{{1
" Move to the last non-surrounding cmd
if targets#util#search('\\\S\+{\_.\{-}}', 'bWe') > 0
return targets#target#withError('no target')
endif
let oldpos = getpos('.')
let target = s:select(1)
call setpos('.', oldpos)
return target
endfunction
" }}}1
function! vimtex#text_obj#cmdtargets#inner(target, args) " {{{1
if a:target.state().isInvalid()
return
endif
call a:target.cursorS()
silent! normal! f{
call a:target.setS()
endfunction
" }}}1
function! s:select(count) " {{{1
" Try to select command
silent! execute 'keepjumps normal v'.a:count."\<Plug>(vimtex-ac)v"
let target = targets#target#fromVisualSelection()
if target.sc == target.ec && target.sl == target.el
return targets#target#withError('tex_cmd select')
endif
return target
endfunction
" }}}1
endif

View File

@@ -0,0 +1,110 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
" vimtex - LaTeX plugin for Vim
"
" Maintainer: Karl Yngve Lervåg
" Email: karl.yngve@gmail.com
"
function! vimtex#text_obj#envtargets#new(args) " {{{1
return {
\ 'genFuncs': {
\ 'c': function('vimtex#text_obj#envtargets#current'),
\ 'n': function('vimtex#text_obj#envtargets#next'),
\ 'l': function('vimtex#text_obj#envtargets#last'),
\ },
\ 'modFuncs': {
\ 'i': [function('vimtex#text_obj#envtargets#inner'), function('targets#modify#drop')],
\ 'a': [function('targets#modify#keep')],
\ 'I': [function('vimtex#text_obj#envtargets#inner'), function('targets#modify#shrink')],
\ 'A': [function('vimtex#text_obj#envtargets#expand')],
\ }}
endfunction
" }}}1
function! vimtex#text_obj#envtargets#current(args, opts, state) " {{{1
let target = s:select(a:opts.first ? 1 : 2)
call target.cursorE() " keep going from right end
return target
endfunction
" }}}1
function! vimtex#text_obj#envtargets#next(args, opts, state) " {{{1
if targets#util#search('\\begin{.*}', 'W') > 0
return targets#target#withError('no target')
endif
let oldpos = getpos('.')
let target = s:select(1)
call setpos('.', oldpos)
return target
endfunction
" }}}1
function! vimtex#text_obj#envtargets#last(args, opts, state) " {{{1
if targets#util#search('\\end{.*}', 'bW') > 0
return targets#target#withError('no target')
endif
let oldpos = getpos('.')
let target = s:select(1)
call setpos('.', oldpos)
return target
endfunction
" }}}1
function! vimtex#text_obj#envtargets#inner(target, args) " {{{1
call a:target.cursorS()
call a:target.searchposS('\\begin{.*}', 'Wce')
call a:target.cursorE()
call a:target.searchposE('\\end{.*}', 'bWc')
endfunction
" }}}1
function! vimtex#text_obj#envtargets#expand(target, args) " {{{1
" Based on targets#modify#expand() from
" $VIMMRUNTIME/autoload/targets/modify.vim
" Add outer whitespace
if a:0 == 0 || a:1 ==# '>'
call a:target.cursorE()
let [line, column] = searchpos('\S\|$', '')
if line > a:target.el || (line > 0 && column-1 > a:target.ec)
" non whitespace or EOL after trailing whitespace found
" not counting whitespace directly after end
return a:target.setE(line, column-1)
endif
endif
if a:0 == 0 || a:1 ==# '<'
call a:target.cursorS()
let [line, column] = searchpos('\S', 'b')
if line < a:target.sl
return a:target.setS(line+1, 0)
elseif line > 0
" non whitespace before leading whitespace found
return a:target.setS(line, column+1)
endif
" only whitespace in front of start
" include all leading whitespace from beginning of line
let a:target.sc = 1
endif
endfunction
" }}}1
function! s:select(count) " {{{1
" Try to select environment
silent! execute 'keepjumps normal v'.a:count."\<Plug>(vimtex-ae)v"
let target = targets#target#fromVisualSelection()
if target.sc == target.ec && target.sl == target.el
return targets#target#withError('tex_env select')
endif
return target
endfunction
" }}}1
endif

View File

@@ -0,0 +1,49 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
" vimtex - LaTeX plugin for Vim
"
" Maintainer: Karl Yngve Lervåg
" Email: karl.yngve@gmail.com
"
function! vimtex#text_obj#targets#enabled() abort " {{{1
return exists('g:loaded_targets')
\ && ( (type(g:loaded_targets) == type(0) && g:loaded_targets)
\ || (type(g:loaded_targets) == type('') && !empty(g:loaded_targets)))
\ && ( g:vimtex_text_obj_variant ==# 'auto'
\ || g:vimtex_text_obj_variant ==# 'targets')
endfunction
" }}}1
function! vimtex#text_obj#targets#init() abort " {{{1
let g:vimtex_text_obj_variant = 'targets'
" Create intermediate mappings
omap <expr> <plug>(vimtex-targets-i) targets#e('o', 'i', 'i')
xmap <expr> <plug>(vimtex-targets-i) targets#e('x', 'i', 'i')
omap <expr> <plug>(vimtex-targets-a) targets#e('o', 'a', 'a')
xmap <expr> <plug>(vimtex-targets-a) targets#e('x', 'a', 'a')
augroup vimtex_targets
autocmd!
autocmd User targets#sources call s:init_sources()
autocmd User targets#mappings#plugin call s:init_mappings()
augroup END
endfunction
" }}}1
function! s:init_mappings() abort " {{{1
call targets#mappings#extend({'e': {'tex_env': [{}]}})
call targets#mappings#extend({'c': {'tex_cmd': [{}]}})
endfunction
" }}}1
function! s:init_sources() abort " {{{1
call targets#sources#register('tex_env', function('vimtex#text_obj#envtargets#new'))
call targets#sources#register('tex_cmd', function('vimtex#text_obj#cmdtargets#new'))
endfunction
" }}}1
endif