Skip to content

feat(compiler): add TeXpresso integration#3267

Open
SeniorMars wants to merge 4 commits into
lervag:masterfrom
SeniorMars:texpresso-integration
Open

feat(compiler): add TeXpresso integration#3267
SeniorMars wants to merge 4 commits into
lervag:masterfrom
SeniorMars:texpresso-integration

Conversation

@SeniorMars
Copy link
Copy Markdown

@SeniorMars SeniorMars commented May 14, 2026

Add a VimTeX compiler backend for TeXpresso, a live-rendering LaTeX tool that updates the preview incrementally as the buffer changes. The backend communicates with TeXpresso through its JSON protocol over stdio and supports SyncTeX forward/inverse search, quickfix integration, and live buffer synchronization. Neovim buffer synchronization is handled through lua/vimtex/compiler/texpresso.lua.

This revives the work from PR #2975 and addresses the main review comments from that discussion:

  • Move the Neovim buffer-attach Lua code to lua/vimtex/compiler/texpresso.lua, with type annotations and a defensive check for compiler state during shutdown or reload.
  • Add documentation in doc/vimtex.txt modeled on the existing compiler backend sections, including a Requirements block and option docs.
  • Internalize the required -json and -lines flags so users cannot accidentally break the protocol by editing g:vimtex_compiler_texpresso.
  • Normalize passed_options spacing in __build_cmd with trim() so the function is robust regardless of whether the caller includes a leading space.
  • Add a stdin_pipe flag to the compiler template so that only TeXpresso enables stdin piping for its job, rather than changing the default for all continuous compiler backends.
  • Register texpresso in the valid compiler methods list in compiler.vim.
  • Add tests (test/test-compiler-texpresso/):
    • Unit tests (make / make vim) verify stdin_pipe, continuous mode, __build_cmd output, and passed_options spacing without requiring TeXpresso to be installed. These run under both Neovim and Vim.
    • Integration smoke test (make integration) starts a real TeXpresso process under Neovim, sends a reload message, and verifies that it stops cleanly.

Note: I'm a bit unfamiliar with the vim codebase, so additional tests may be needed; however, neovim has been tested.

Co-Authored-By: Tsung-Ju Chiang 71379180+tsung-ju@users.noreply.github.com

tsung-ju and others added 4 commits May 14, 2026 02:34
Add a VimTeX compiler backend for TeXpresso, a live-rendering LaTeX
tool that updates the preview incrementally as the buffer changes. The
backend communicates with TeXpresso through its JSON protocol over stdio
and supports SyncTeX forward/inverse search, quickfix integration, and
live buffer synchronization. Neovim buffer synchronization is handled
through lua/vimtex/compiler/texpresso.lua.

This revives the work from PR lervag#2975 and addresses the main review
comments from that discussion:

- Move the Neovim buffer-attach Lua code to
  lua/vimtex/compiler/texpresso.lua, with type annotations and a
  defensive check for compiler state during shutdown or reload.
- Add documentation in doc/vimtex.txt modeled on the existing compiler
  backend sections, including a Requirements block and option docs.
- Internalize the required -json and -lines flags so users cannot
  accidentally break the protocol by editing g:vimtex_compiler_texpresso.
- Normalize passed_options spacing in __build_cmd with trim() so the
  function is robust regardless of whether the caller includes a leading
  space.
- Add a stdin_pipe flag to the compiler template so that only TeXpresso
  enables stdin piping for its job, rather than changing the default for
  all continuous compiler backends.
- Register texpresso in the valid compiler methods list in compiler.vim.
- Add tests (test/test-compiler-texpresso/):
  - Unit tests (`make` / `make vim`) verify stdin_pipe, continuous mode,
    __build_cmd output, and passed_options spacing without requiring
    TeXpresso to be installed. These run under both Neovim and Vim.
  - Integration smoke test (`make integration`) starts a real TeXpresso
    process under Neovim, sends a reload message, and verifies that it
    stops cleanly.

Note: I'm a bit unfamiliar with the vim codebase, so additional tests
may be needed; however, neovim has been tested.

Co-Authored-By: Tsung-Ju Chiang <71379180+tsung-ju@users.noreply.github.com>
Copy link
Copy Markdown
Owner

@lervag lervag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This seems to be a good PR, and I only have a couple of minor code comments.

Note: I'm a bit unfamiliar with the vim codebase, so additional tests may be needed; however, neovim has been tested.

Thanks! I can probably test this with Vim when I get the time. I'm assuming that it should be easy to install texpresso on Arch Linux (which seems to be the case).

Is there anything specific you would advice me to test before accepting this?

Comment thread doc/vimtex.txt
Compiler backend ~

VimTeX uses `latexmk`, `latexrun`, `tectonic` or `arara` to compile the LaTeX document.
VimTeX uses `latexmk`, `latexrun`, `tectonic`, `arara` or `texpresso` to compile the LaTeX document.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restrict to 79 characters per row in this file.

augroup END

if has('nvim')
let self.nvim_detach = s:nvim_attach()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why don't we inline the luaeval here instead of running it in line 44 at module load time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants