Changes

Jump to navigation Jump to search
183 bytes added ,  18:42, 25 August 2022
Update the page to reflect the features of the new runtime scripts in Vim
Nikolai Weibull was the first one who wrote <tt>context.vim</tt> files and submitted them to the official Vim repository.
They are part of the official Vim 7, and were expanded and improved in Vim 8. Starting with Vim 9.0.0218, the scripts supporting ConTeXt in Vim have been rewritten in Vim 9 script and they can be integrated with (the new Vim's scripting language). For the syntax files generated by complete documentation, see <tt>mtxrun:help ft-context</tt>. You may add the additional syntax files as follows:  mkdir -p ~/.vim/syntax/shared cd ~/.vim/syntax/shared mtxrun --script interface --vim The above assumes that your Vim configuration is in the `~/.vim` directory, of course. Adding those files is not mandatory, but they will add lots of keywords for auto-completion and will improve the syntax coloring for MetaFun code.
=== Asciicast ===
to compile the document in the current buffer.
Typesetting happens in the background,
so you may continue working on your document. If there are errors, the quickfix window opens will open automaticallyto show the errors (one per line). The cursor stays will stay in the main document, so your typing workflow is will notbe disrupted. You may use standard quickfix commands to jump between errors: <tt>:cfirst</tt>, <tt>:cprev</tt>,
<tt>:cnext</tt>, etc… (see <tt>:help quickfix</tt>). See below for useful mappings for these commands.
running jobs with <tt>:ConTeXtStopJobs</tt>.
An alternative way to typeset === Setting a document custom typesetting engine === The <tt>:ConTeXt</tt> command invokes the <tt>mtxrun</tt> script that is to use found in <tt>:make$PATH</tt>. Set For more fine grained control over the current workingcommand and its environment, you may invoke `context.Typeset()` directly (or `context#Typeset()` from legacy Vim script). For instance, if you have installed a version of ConTeXt in <tt>$HOME/context</tt> (where <tt>$HOME</tt> is the path to your home directory ), you may define a function to use it similar to the directory of following (you may put the current buffer, then execute following code in <tt>:make~/.vim/after/ftplugin/context.vim</tt>, creating the file and the directories if they do not exist)import autoload 'context.vim'  def MyConTeXt() const env = {'PATH':lcd printf("%s/pathcontext/totex/mytexmf-<os>-<arch>/projectbin:%s", $HOME, $PATH)} context.Typeset("%", env) enddef and perhaps use it with a mapping:makeIf a nnoremap <silent><buffer><ttleader>Makefilet </ttscriptcmd> exists in the working directory, it is used MyConTeXt(see below for a sample Makefile).<cr> You may <tt>let g:context_ignore_makefile=1context.Typeset()</tt> accepts a third optional argument to ignore an existing Makefilespecify a customtypesetting command. That must be a function that takes a path and returns thecommand as a List.For example:If no Makefile is found, def ConTeXtCustomCommand(path: string): list<ttstring> return ['mtxrun</tt> will be invoked directly', '--script', 'context', '--nonstopmode, path] enddef  context.ConTeXtTypeset("%", v:none, ConTeXtCustomCommand)Note that === Working with large projects === Large projects are often organized as a root document and various chapterfiles. When editing a chapter file, it is convenient to invoke <tt>:makeConTeXt</tt> always performs synchronous typesettingdirectly on it, rather than having to switch to the root file. AlsoA “magic line”can be added at the beginning of each chapter file, which specifies therelative path to the root file. For instance:  % !TEX root = ../MyRoot.tex Vim searches for the magic line in the first ten lines of the current buffer:if there areerrorsit is found, the quickfix list document specified by that line is populated, but you typeset rather than theone in the current buffer. The root document does not have to open it manually with <tt>:copen</tt>be opened inVim.
It is recommended that you map === Updating the above commands. For example, you may add nnoremap <silent> <leader>tt :<c-u>update<cr>:ConTeXt<cr>to your <tt>vimrc</tt>, or (better) nnoremap <buffer> <silent> <leader>tt :<c-u>update<cr>:ConTeXt<cr>to <tt>~/.vim/after/ftplugin/context.vim</tt>, after which pressing <tt>\tt</tt> (where <tt>\</tt> is your leader key)will save and compile the file.syntax files ===
You may customize the path to the Vim includes syntax files generated by <tt>mtxrun</tt> executable by setting <tt>g:context_mtxrun</tt>.For example, if If you want to use more up-to-date files, overriding those distributed with Vim, you may proceed as follows. Assuming your ConTeXt Beta installation at Vim configuration lives in <tt>~/Applications/ConTeXt-Beta.vim</tt>,and you are using macOS, you may set the variable as follows: let g:context_mtxrun = 'PATH=$HOME/Applications/ConTeXt-Beta/tex/texmf-osx-64/bintype:$PATH mtxrun'
To enable mkdir -p ~/disable SyncTeX, use <tt>\setupsynctex[state=start]<.vim/syntax/tt> and <tt>\setupsynctex[state=stop]<shared cd ~/tt>, respectively, in your document.vim/syntax/shared mtxrun --script interface --vim
You may pass <tt>mtxrun</tt> additional options by putting them in <tt>g:context_extra_options</tt>.For example: let g:context_extra_options = '--arrange --autopdf'The <tt>--autogenerate</tt> and <tt>--nonstopmode</tt> options are always included in last command will create thecommand.following syntax files:
Finally, for each of the above variables, a corresponding buffer-local variable with the same name<tt>context-data-context.vim</tt>;may be defined, whose value takes precedence over the global value- <tt>context-data-interfaces.vim</tt>;- <tt>context-data-metafun.vim</tt>;- <tt>context-data-tex.vim</tt>.
=== Editing features ===
Vim offers excellent support for editing METAFONT and MetaPost documents (<tt>mf</tt> and <tt>mp</tt> filetypes).
See <tt>:help ft-metapost</tt> for the details.
Most of the features of such filetypes work also inside ConTeXt's MetaPost environments,
such as <tt>\startMPpage… \stopMPpage</tt>.
=== TODO ===
* Extract data from texweb and create syntax highlighting definitions for ConTeXt.
* Some essential math support.
* Proper URL highlighting ('%' doesn't start a comment, ...) [request by VnPenguin].
134

edits

Navigation menu