Skip to content

Commit

Permalink
Change latex provider to luatex, closes #476
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerun committed Apr 25, 2020
1 parent 8ec73a3 commit d757bfd
Show file tree
Hide file tree
Showing 125 changed files with 17,908 additions and 3,385 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [jsx](https://github.com/MaxMEllon/vim-jsx-pretty) (autoload, after)
- [julia](https://github.com/JuliaEditorSupport/julia-vim) (syntax, indent, autoload, ftplugin)
- [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent, ftplugin)
- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin)
- [latex](https://github.com/lervag/vimtex) (indent, compiler, autoload, ftplugin, syntax)
- [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin)
- [lilypond](https://github.com/anowlcalledjosh/vim-lilypond) (syntax, indent, compiler, ftplugin)
- [livescript](https://github.com/gkz/vim-ls) (syntax, indent, compiler, ftplugin)
Expand Down
20 changes: 20 additions & 0 deletions after/ftplugin/tex.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
"

if !get(g:, 'vimtex_enabled', 1)
finish
endif

if exists('b:did_ftplugin_vimtex')
finish
endif
let b:did_ftplugin_vimtex = 1

call vimtex#check_plugin_clash()

endif
14 changes: 6 additions & 8 deletions after/syntax/tex.vim
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1

" adds support for cleverref package
" \Cref, \cref, \cpageref, \labelcref, \labelcpageref
syn region texRefZone matchgroup=texStatement start="\\Cref{" end="}\|%stopzone\>" contains=@texRefGroup
syn region texRefZone matchgroup=texStatement start="\\\(label\|\)c\(page\|\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
" vimtex - LaTeX plugin for Vim
"
" Maintainer: Karl Yngve Lervåg
" Email: karl.yngve@gmail.com
"

" adds support for listings package
syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>"
syn match texInputFile "\\lstinputlisting\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
syn match texZone "\\lstinline\s*\(\[.*\]\)\={.\{-}}"
call vimtex#syntax#init()

endif
164 changes: 164 additions & 0 deletions autoload/health/vimtex.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1

function! health#vimtex#check() abort
call vimtex#init_options()

call health#report_start('vimtex')

call s:check_general()
call s:check_plugin_clash()
call s:check_view()
call s:check_compiler()
endfunction

function! s:check_general() abort " {{{1
if !has('nvim') || v:version < 800
call health#report_warn('vimtex works best with Vim 8 or neovim')
else
call health#report_ok('Vim version should have full support!')
endif

if !executable('bibtex')
call health#report_warn('bibtex is not executable, so bibtex completions are disabled.')
endif
endfunction

" }}}1

function! s:check_compiler() abort " {{{1
if !g:vimtex_compiler_enabled | return | endif

if !executable(g:vimtex_compiler_method)
let l:ind = ' '
call health#report_error(printf(
\ '|g:vimtex_compiler_method| (`%s`) is not executable!',
\ g:vimtex_compiler_method))
return
endif

let l:ok = 1
if !executable(g:vimtex_compiler_progname)
call health#report_warn(printf(
\ '|g:vimtex_compiler_progname| (`%s`) is not executable!',
\ g:vimtex_compiler_progname))
let l:ok = 0
endif

if has('nvim')
\ && fnamemodify(g:vimtex_compiler_progname, ':t') !=# 'nvr'
call health#report_warn('Compiler callbacks will not work!', [
\ '`neovim-remote` / `nvr` is required for callbacks to work with neovim',
\ "Please also set |g:vimtex_compiler_progname| = 'nvr'",
\ 'For more info, see :help |vimtex-faq-neovim|',
\])
let l:ok = 0
endif

if l:ok
call health#report_ok('Compiler should work!')
endif
endfunction

" }}}1

function! s:check_plugin_clash() abort " {{{1
let l:scriptnames = split(execute('scriptnames'), "\n")

let l:latexbox = !empty(filter(copy(l:scriptnames), "v:val =~# 'latex-box'"))
if l:latexbox
call health#report_warn('Conflicting plugin detected: LaTeX-Box')
call health#report_info('vimtex does not work as expected when LaTeX-Box is installed!')
call health#report_info('Please disable or remove it to use vimtex!')

let l:polyglot = !empty(filter(copy(l:scriptnames), "v:val =~# 'polyglot'"))
if l:polyglot
call health#report_info('LaTeX-Box is included with vim-polyglot and may be disabled with:')
call health#report_info('let g:polyglot_disabled = [''latex'']')
endif
endif
endfunction

" }}}1

function! s:check_view() abort " {{{1
call s:check_view_{g:vimtex_view_method}()

if executable('xdotool') && !executable('pstree')
call health#report_warn('pstree is not available',
\ 'vimtex#view#reverse_goto is better if pstree is available.')
endif
endfunction

" }}}1
function! s:check_view_general() abort " {{{1
if executable(g:vimtex_view_general_viewer)
call health#report_ok('General viewer should work properly!')
else
call health#report_error(
\ 'Selected viewer is not executable!',
\ '- Selection: ' . g:vimtex_view_general_viewer,
\ '- Please see :h g:vimtex_view_general_viewer')
endif
endfunction

" }}}1
function! s:check_view_zathura() abort " {{{1
let l:ok = 1

if !executable('zathura')
call health#report_error('Zathura is not executable!')
let l:ok = 0
endif

if !executable('xdotool')
call health#report_warn('Zathura requires xdotool for forward search!')
let l:ok = 0
endif

if l:ok
call health#report_ok('Zathura should work properly!')
endif
endfunction

" }}}1
function! s:check_view_mupdf() abort " {{{1
let l:ok = 1

if !executable('mupdf')
call health#report_error('MuPDF is not executable!')
let l:ok = 0
endif

if !executable('xdotool')
call health#report_warn('MuPDF requires xdotool for forward search!')
let l:ok = 0
endif

if !executable('synctex')
call health#report_warn('MuPDF requires synctex for forward search!')
let l:ok = 0
endif

if l:ok
call health#report_ok('MuPDF should work properly!')
endif
endfunction

" }}}1
function! s:check_view_skim() abort " {{{1
let l:cmd = join([
\ 'osascript -e ',
\ '''tell application "Finder" to POSIX path of ',
\ '(get application file id (id of application "Skim") as alias)''',
\])

if system(l:cmd)
call health#report_error('Skim is not installed!')
else
call health#report_ok('Skim viewer should work!')
endif
endfunction

" }}}1

endif
87 changes: 87 additions & 0 deletions autoload/unite/sources/vimtex.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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
"

let s:save_cpo = &cpo
set cpo&vim

let s:source = {
\ 'name' : 'vimtex',
\ 'sorters' : 'sorter_nothing',
\ 'default_kind' : 'jump_list',
\ 'syntax' : 'uniteSource__vimtex',
\ 'entries' : [],
\ 'maxlevel' : 1,
\ 'hooks' : {},
\}

function! s:source.gather_candidates(args, context) abort " {{{1
if exists('b:vimtex')
let s:source.entries = vimtex#parser#toc()
let s:source.maxlevel = max(map(copy(s:source.entries), 'v:val.level'))
endif
return map(copy(s:source.entries),
\ 's:create_candidate(v:val, s:source.maxlevel)')
endfunction

" }}}1
function! s:source.hooks.on_syntax(args, context) abort " {{{1
syntax match VimtexTocSecs /.* @\d$/
\ contains=VimtexTocNum,VimtexTocTag,@Tex
\ contained containedin=uniteSource__vimtex
syntax match VimtexTocSec0 /.* @0$/
\ contains=VimtexTocNum,VimtexTocTag,@Tex
\ contained containedin=uniteSource__vimtex
syntax match VimtexTocSec1 /.* @1$/
\ contains=VimtexTocNum,VimtexTocTag,@Tex
\ contained containedin=uniteSource__vimtex
syntax match VimtexTocSec2 /.* @2$/
\ contains=VimtexTocNum,VimtexTocTag,@Tex
\ contained containedin=uniteSource__vimtex
syntax match VimtexTocSec3 /.* @3$/
\ contains=VimtexTocNum,VimtexTocTag,@Tex
\ contained containedin=uniteSource__vimtex
syntax match VimtexTocSec4 /.* @4$/
\ contains=VimtexTocNum,VimtexTocTag,@Tex
\ contained containedin=uniteSource__vimtex
syntax match VimtexTocNum
\ /\%69v\%(\%([A-Z]\+\>\|\d\+\)\%(\.\d\+\)*\)\?\s*@\d$/
\ contains=VimtexTocLevel
\ contained containedin=VimtexTocSec[0-9*]
syntax match VimtexTocTag
\ /\[.\]\s*@\d$/
\ contains=VimtexTocLevel
\ contained containedin=VimtexTocSec[0-9*]
syntax match VimtexTocLevel
\ /@\d$/ conceal
\ contained containedin=VimtexTocNum,VimtexTocTag
endfunction

" }}}1

function! s:create_candidate(entry, maxlevel) abort " {{{1
let level = a:maxlevel - a:entry.level
let title = printf('%-65S%-10s',
\ strpart(repeat(' ', 2*level) . a:entry.title, 0, 60),
\ b:vimtex.toc.print_number(a:entry.number))
return {
\ 'word' : title,
\ 'abbr' : title . ' @' . level,
\ 'action__path' : a:entry.file,
\ 'action__line' : get(a:entry, 'line', 0),
\ }
endfunction

" }}}1

function! unite#sources#vimtex#define() abort
return s:source
endfunction

let &cpo = s:save_cpo

endif
Loading

0 comments on commit d757bfd

Please sign in to comment.