mirror of
https://github.com/vim/vim.git
synced 2026-04-11 14:43:54 +02:00
This update is meant to be included in the upcoming 9.2 release.
**New**
- Support ConTeXt's convention to optionally specify an output directory
in a comment line at the beginning of a source file.
- If a log file is not found, Vim does not create a new buffer.
- Removed `syntax/shared` files for the following reasons:
- they are not necessary for the plugin to work (they only improve
over existing syntax highlighting);
- they are relative large;
- they can be automatically (re)generated by users at any time using
ConTeXt (explained in the doc);
- since ConTeXt is updated frequently, they quickly become obsolete.
**Minor**
- Prefer `var` to `const` inside functions.
- Prefer `$`-interpolation to `printf()`.
- All revision dates set to the same date for consistency.
- Updated the error format.
- Various tweaks to the documentation, but nothing disruptive or new.
closes: #19148
Signed-off-by: Lifepillar <lifepillar@lifepillar.me>
Signed-off-by: Christian Brabandt <cb@256bit.org>
66 lines
1.7 KiB
VimL
66 lines
1.7 KiB
VimL
vim9script
|
|
|
|
# Language: ConTeXt typesetting engine
|
|
# Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
|
# Former Maintainers: Nikolai Weibull <now@bitwi.se>
|
|
# Latest Revision: 2026 Jan 10
|
|
|
|
if exists("b:did_indent")
|
|
finish
|
|
endif
|
|
|
|
# Load MetaPost indentation script (this will also set b:did_indent)
|
|
runtime! indent/mp.vim
|
|
|
|
setlocal indentexpr=ConTeXtIndent()
|
|
|
|
b:undo_indent = "setl indentexpr<"
|
|
|
|
def PrevNotComment(l: number): number
|
|
var prevlnum = prevnonblank(l)
|
|
|
|
while prevlnum > 0 && getline(prevlnum) =~# '^\s*%'
|
|
prevlnum = prevnonblank(prevlnum - 1)
|
|
endwhile
|
|
|
|
return prevlnum
|
|
enddef
|
|
|
|
def FindPair(pstart: string, pmid: string, pend: string): number
|
|
cursor(v:lnum, 1)
|
|
return indent(searchpair(pstart, pmid, pend, 'bWn',
|
|
'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
|
|
enddef
|
|
|
|
def ConTeXtIndent(): number
|
|
# Use MetaPost rules inside MetaPost graphic environments
|
|
if len(synstack(v:lnum, 1)) > 0 &&
|
|
synIDattr(synstack(v:lnum, 1)[0], "name") ==# 'contextMPGraphic'
|
|
return g:MetaPostIndent()
|
|
endif
|
|
|
|
var prevlnum = PrevNotComment(v:lnum - 1)
|
|
var prevind = indent(prevlnum)
|
|
var prevline = getline(prevlnum)
|
|
var currline = getline(v:lnum)
|
|
|
|
# If the current line starts with ], match indentation.
|
|
if currline =~# '^\s*\]'
|
|
return FindPair('\[', '', '\]')
|
|
endif
|
|
|
|
# If the current line starts with }, match indentation.
|
|
if currline =~# '^\s*}'
|
|
return FindPair('{', '', '}')
|
|
endif
|
|
|
|
# If the previous line ends with [ or { (possibly followed by a comment) then indent.
|
|
if prevline =~# '[{[]\s*\%(%.*\)\=$'
|
|
return prevind + shiftwidth()
|
|
endif
|
|
|
|
return -1
|
|
enddef
|
|
|
|
# vim: sw=2 fdm=marker
|