tex.vim 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. " Vim compiler file
  2. " Compiler: TeX
  3. " Maintainer: Artem Chuprina <ran@ran.pp.ru>
  4. " Contributors: Enno Nagel
  5. " Last Change: 2024 Mar 29
  6. " 2024 Apr 03 by the Vim Project (removed :CompilerSet definition)
  7. " 2024 Apr 05 by the Vim Project (avoid leaving behind g:makeprg)
  8. " 2024 Nov 19 by the Vim Project (properly escape makeprg setting)
  9. if exists("current_compiler")
  10. finish
  11. endif
  12. let s:keepcpo= &cpo
  13. set cpo&vim
  14. " If makefile exists and we are not asked to ignore it, we use standard make
  15. " (do not redefine makeprg)
  16. if exists('b:tex_ignore_makefile') || exists('g:tex_ignore_makefile') ||
  17. \(!filereadable('Makefile') && !filereadable('makefile'))
  18. " If buffer-local variable 'tex_flavor' exists, it defines TeX flavor,
  19. " otherwise the same for global variable with same name, else it will be
  20. " LaTeX
  21. if exists("b:tex_flavor")
  22. let current_compiler = b:tex_flavor
  23. elseif exists("g:tex_flavor")
  24. let current_compiler = g:tex_flavor
  25. else
  26. let current_compiler = "latex"
  27. endif
  28. let s:makeprg=current_compiler .. ' -interaction=nonstopmode'
  29. execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' \|"')
  30. else
  31. let current_compiler = 'make'
  32. endif
  33. " Value errorformat are taken from vim help, see :help errorformat-LaTeX, with
  34. " addition from Srinath Avadhanula <srinath@fastmail.fm>
  35. CompilerSet errorformat=%E!\ LaTeX\ %trror:\ %m,
  36. \%E!\ %m,
  37. \%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#,
  38. \%+W%.%#\ at\ lines\ %l--%*\\d,
  39. \%WLaTeX\ %.%#Warning:\ %m,
  40. \%Cl.%l\ %m,
  41. \%+C\ \ %m.,
  42. \%+C%.%#-%.%#,
  43. \%+C%.%#[]%.%#,
  44. \%+C[]%.%#,
  45. \%+C%.%#%[{}\\]%.%#,
  46. \%+C<%.%#>%.%#,
  47. \%C\ \ %m,
  48. \%-GSee\ the\ LaTeX%m,
  49. \%-GType\ \ H\ <return>%m,
  50. \%-G\ ...%.%#,
  51. \%-G%.%#\ (C)\ %.%#,
  52. \%-G(see\ the\ transcript%.%#),
  53. \%-G\\s%#,
  54. \%+O(%*[^()])%r,
  55. \%+O%*[^()](%*[^()])%r,
  56. \%+P(%f%r,
  57. \%+P\ %\\=(%f%r,
  58. \%+P%*[^()](%f%r,
  59. \%+P[%\\d%[^()]%#(%f%r,
  60. \%+Q)%r,
  61. \%+Q%*[^()])%r,
  62. \%+Q[%\\d%*[^()])%r
  63. let &cpo = s:keepcpo
  64. unlet s:keepcpo