ft_context.txt 5.0 KB

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