vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

ft_context.txt (5479B)


      1 *ft_context.txt*	For Vim version 9.2.  Last change: 2026 Feb 14
      2 
      3 This is the documentation for the ConTeXt filetype plugin.
      4 
      5 NOTE: the plugin requires |+vim9script|.
      6 
      7 ==============================================================================
      8 CONTENTS						*context.vim* *ft-context*
      9 
     10 1. Introduction				|ft-context-intro|
     11 2. Commands				|ft-context-commands|
     12 3. Settings				|ft-context-settings|
     13 4. Mappings				|ft-context-mappings|
     14 
     15 ==============================================================================
     16 							*ft-context-intro*
     17 Introduction ~
     18 
     19 ConTeXt, similarly to LaTeX, is a macro-based typesetting system built on TeX:
     20 >
     21 	https://wiki.contextgarden.net
     22 	https://wiki.contextgarden.net/Input_and_compilation/Text_editors/Vim
     23 <
     24 The ConTeXt plugin provides syntax highlighting, completion and support for
     25 typesetting ConTeXt documents. The recommended way to typeset a document is to
     26 use |:ConTeXt|, which invokes the `mtxrun` script that is found in $PATH.
     27 
     28 For more fine grained control over the command and its environment,
     29 `context.Typeset()` can be used directly (or `context#Typeset()` from legacy
     30 Vim script). For instance, if a version of ConTeXt is installed in
     31 `~/context`, you may define a function to use it similar to the following:
     32 >
     33 	import autoload 'context.vim'
     34 
     35 	var os = "linux"    # Update to match your system
     36 	var arch = "arm64"  # Update to match your system
     37 
     38 	def MyConTeXt()
     39 	  var env = {
     40 	    'PATH': $'{$HOME}/context/tex/texmf-{os}-{arch}/bin:{$PATH}'
     41 	  }
     42 	  context.Typeset("%", env)
     43 	enddef
     44 
     45 	nnoremap <silent><buffer><leader>t <scriptcmd>MyConTeXt()<cr>
     46 <
     47 This code should go in `~/.vim/after/ftplugin/context.vim`.
     48 
     49 `context.Typeset()` accepts a third optional argument to specify a custom
     50 typesetting command. That must be a function that takes a path and returns the
     51 command as a |list|. For example:
     52 >
     53 	def ConTeXtCustomCommand(path: string): list<string>
     54 	  return ['mtxrun', '--script', 'context', '--nonstopmode', path]
     55 	enddef
     56 
     57 	def MyContext()
     58 	    context.Typeset("%", v:none, ConTeXtCustomCommand)
     59 	enddef
     60 <
     61 Large projects are often organized as a root document and various chapter
     62 files. When editing a chapter file, it is convenient to invoke |:ConTeXt|
     63 directly on it, rather than having to switch to the root file. A "magic line"
     64 can be added at the beginning of each chapter file, which specifies the
     65 relative path to the root file. For instance:
     66 >
     67 	% !TEX root = ../MyRoot.tex
     68 <
     69 Vim searches for the magic line in the first ten lines of the current buffer:
     70 if it is found, the document specified by that line is typeset rather than the
     71 one in the current buffer. The root document does not have to be opened in
     72 Vim.
     73 
     74 To extend completion and syntax highlighting, you may generate supporting
     75 files using ConTeXt and add them to your configuration. If your configuration
     76 resides in `~/.vim`, you may use these commands:
     77 >
     78 	mkdir -p ~/.vim/syntax/shared
     79 	cd ~/.vim/syntax/shared
     80 	mtxrun --script interface --vim
     81 <
     82 The last command will create the following syntax files:
     83 
     84 - `context-data-context.vim`;
     85 - `context-data-interfaces.vim`;
     86 - `context-data-metafun.vim`;
     87 - `context-data-tex.vim`.
     88 
     89 If present, such files will be automatically loaded to enhance syntax
     90 highlighting. The same command can be used to update those syntax files.
     91 
     92 							*ft-context-commands*
     93 Commands ~
     94 					*:ConTeXt*
     95 Start a background |job| to typeset the document in the current buffer. The
     96 command accepts an optional buffer's name, if you want to typeset a document
     97 that is in a different buffer.
     98 
     99 					*:ConTeXtLog*
    100 Edit the log file corresponding to the source in the current buffer.
    101 
    102 					*:ConTeXtJobsStatus*
    103 Echo the number of jobs currently running in the background.
    104 
    105 					*:ConTeXtStopJobs*
    106 Stop all the ConTeXt jobs currently running in the background.
    107 
    108 							*ft-context-settings*
    109 Settings ~
    110 					*'b:context_ignore_makefile'*
    111 					*'g:context_ignore_makefile'*
    112 |:make| can be used to (synchronously) typeset a document. If a Makefile exists
    113 and this option is not set, standard `make` is used. If this option is set,
    114 `mtxrun` is invoked instead, even if a Makefile exists.
    115 >
    116 	g:context_ignore_makefile = 0
    117 <
    118 NOTE: before using |:make|, ensure that the working directory of the buffer is
    119 set to the directory of the file you want to typeset. Additionally, be aware
    120 that |:make| searches for `mtxrun` in $PATH.
    121 
    122 					*'g:context_extra_options'*
    123 A list of additional options to pass to `mtxrun`.
    124 >
    125 	g:context_extra_options = []
    126 <
    127 					*'b:context_include'*
    128 					*'g:context_include'*
    129 Dictionary of filetype/GROUP pairs for which syntax highlighting should be
    130 activated between \startGROUP and \stopGROUP. The default is to highlight XML
    131 between `\startXML` and `\stopXML`.
    132 >
    133 	g:context_include = {'xml': 'XML'}
    134 
    135 NOTE: Lua and MetaPost are always highlighted within the respective blocks.
    136 
    137 					*'g:no_context_maps'*
    138 When set, do not define any mappings.
    139 >
    140 	g:no_context_maps = 0
    141 <
    142 							*ft-context-mappings*
    143 Mappings ~
    144 
    145 tp			"reflow TeX paragraph" (motion).
    146 
    147 i$			"inside inline math block" (text object selection).
    148 
    149 a$			"around inline math block" (text object selection).
    150 
    151 ]]			[count] start of sections forward.
    152 
    153 [[			[count] start of sections backward.
    154 
    155 ][			[count] end sections forward.
    156 
    157 []			[count] end of sections backward.
    158 
    159 ]}			[count] end of blocks (\stop..., \setup...,
    160 			\define...) forward.
    161 
    162 [{			[count] begin of blocks (\start..., \setup...,
    163 			\define...) backward.
    164 
    165  vim:tw=78:sw=4:ts=8:noet:ft=help:norl: