From bf18b5eb7b8775f5dce13060f5cf2cfcf4e7f20c Mon Sep 17 00:00:00 2001 From: Lifepillar Date: Wed, 4 Feb 2026 16:31:05 +0000 Subject: [PATCH] runtime(context): fix issue with SyncTeX and update command Remove `--nonstopmode` because (a) ConTeXt always stops anyway, and (b) `--nonstopmode` disables SyncTeX unconditionally. Add `--paranoid`, which prevents the command to descend to `..` and `../..`. Pass the typesetting command only the name of the input file rather than its full path, as that is more compatible with ConTeXt's syncing mechanism. closes: #19323 Signed-off-by: Lifepillar Signed-off-by: Christian Brabandt --- runtime/autoload/context.vim | 4 ++-- runtime/autoload/typeset.vim | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/runtime/autoload/context.vim b/runtime/autoload/context.vim index df418bf139..5736406a8d 100644 --- a/runtime/autoload/context.vim +++ b/runtime/autoload/context.vim @@ -3,13 +3,13 @@ vim9script # Language: ConTeXt typesetting engine # Maintainer: Nicola Vitacolonna # Former Maintainers: Nikolai Weibull -# Latest Revision: 2026 Jan 10 +# Latest Revision: 2026 Feb 03 # Typesetting {{{ import autoload './typeset.vim' export def ConTeXtCmd(path: string): list - var cmd = ['mtxrun', '--script', 'context', '--nonstopmode', '--autogenerate'] + var cmd = ['mtxrun', '--script', 'context', '--paranoid', '--autogenerate'] if !empty(get(g:, 'context_extra_options', '')) cmd += g:context_extra_options endif diff --git a/runtime/autoload/typeset.vim b/runtime/autoload/typeset.vim index ed808a817e..aba8474658 100644 --- a/runtime/autoload/typeset.vim +++ b/runtime/autoload/typeset.vim @@ -2,7 +2,7 @@ vim9script # Language: Generic TeX typesetting engine # Maintainer: Nicola Vitacolonna -# Latest Revision: 2026 Jan 10 +# Latest Revision: 2026 Feb 03 # Constants and helpers {{{ const SLASH = !exists("+shellslash") || &shellslash ? '/' : '\' @@ -203,6 +203,7 @@ export def Typeset( env: dict = {} ): bool var fp = fnamemodify(path, ':p') + var name = fnamemodify(fp, ':t') var wd = fnamemodify(fp, ':h') var qfid = NewQuickfixList(fp) @@ -216,7 +217,11 @@ export def Typeset( return false endif - var jobid = job_start(Cmd(path), { + # Make sure to pass only the base name of the path to Cmd as this usually + # works better with TeX commands (note that the command is executed inside + # the file's directory). For instance, ConTeXt writes the path in .synctex + # files, and full paths break syncing from the editor to the viewer. + var jobid = job_start(Cmd(name), { env: env, cwd: wd, in_io: "null", -- 2.47.3