annotate runtime/autoload/context.vim @ 30007:4123e4bd1708 v9.0.0341

patch 9.0.0341: mapset() does not restore <Nop> mapping properly Commit: https://github.com/vim/vim/commit/92a3d20682d46359bb50a452b4f831659e799155 Author: zeertzjq <zeertzjq@outlook.com> Date: Wed Aug 31 16:40:17 2022 +0100 patch 9.0.0341: mapset() does not restore <Nop> mapping properly Problem: mapset() does not restore <Nop> mapping properly. Solution: Use an empty string for <Nop>. (closes https://github.com/vim/vim/issues/11022)
author Bram Moolenaar <Bram@vim.org>
date Wed, 31 Aug 2022 17:45:03 +0200
parents 2acb87ee55fc
children 1e91e26ceebf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
1 vim9script
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
3 # Language: ConTeXt typesetting engine
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
4 # Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
5 # Former Maintainers: Nikolai Weibull <now@bitwi.se>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
6 # Latest Revision: 2022 Aug 12
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
8 # Typesetting {{{
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
9 import autoload './typeset.vim'
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
11 export def ConTeXtCmd(path: string): list<string>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
12 return ['mtxrun', '--script', 'context', '--nonstopmode', '--autogenerate', path]
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
13 enddef
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
15 export def Typeset(bufname: string, env = {}, Cmd = ConTeXtCmd): bool
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
16 return typeset.TypesetBuffer(bufname, Cmd, env, 'ConTeXt')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
17 enddef
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
19 export def JobStatus()
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
20 typeset.JobStatus('ConTeXt')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
21 enddef
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
23 export def StopJobs()
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
24 typeset.StopJobs('ConTeXt')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
25 enddef
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
27 export def Log(bufname: string)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
28 execute 'edit' typeset.LogPath(bufname)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
29 enddef
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
30 # }}}
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
32 # Completion {{{
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
33 def BinarySearch(base: string, keywords: list<string>): list<string>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
34 const pat = '^' .. base
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
35 const len = len(keywords)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
36 var res = []
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
37 var lft = 0
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
38 var rgt = len
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
40 # Find the leftmost index matching base
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
41 while lft < rgt
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
42 var i = (lft + rgt) / 2
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
43 if keywords[i] < base
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
44 lft = i + 1
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
45 else
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
46 rgt = i
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
47 endif
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
48 endwhile
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
50 while lft < len && keywords[lft] =~ pat
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
51 add(res, keywords[lft])
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
52 lft += 1
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
53 endwhile
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
55 return res
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
56 enddef
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
58 var isMetaPostBlock = false
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
60 var MP_KEYWORDS: list<string> = []
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
61 var CTX_KEYWORDS: list<string> = []
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
63 # Complete only MetaPost keywords in MetaPost blocks, and complete only
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
64 # ConTeXt keywords otherwise.
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
65 export def Complete(findstart: number, base: string): any
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
66 if findstart == 1
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
67 if len(synstack(line("."), 1)) > 0 && synIDattr(synstack(line("."), 1)[0], "name") ==# 'contextMPGraphic'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
68 isMetaPostBlock = true
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
69 return match(getline('.'), '\S\+\%' .. col('.') .. 'c')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
70 endif
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
72 # Complete only \commands starting with a backslash
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
73 isMetaPostBlock = false
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
74 var pos = match(getline('.'), '\\\zs\S\+\%' .. col('.') .. 'c')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
75 return (pos == -1) ? -3 : pos
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 endif
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
77
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
78 if isMetaPostBlock
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
79 if empty(MP_KEYWORDS)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
80 MP_KEYWORDS = sort(syntaxcomplete#OmniSyntaxList(['mf\w\+', 'mp\w\+']))
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
81 endif
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
82 return BinarySearch(base, MP_KEYWORDS)
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 endif
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
85 if empty(CTX_KEYWORDS)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
86 CTX_KEYWORDS = sort(syntaxcomplete#OmniSyntaxList([
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
87 'context\w\+', 'texAleph', 'texEtex', 'texLuatex', 'texOmega',
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
88 'texPdftex', 'texTex', 'texXeTeX'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
89 ]))
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
90 endif
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
91 return BinarySearch(base, CTX_KEYWORDS)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
92 enddef
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
93 # }}}
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10301
diff changeset
95 # vim: sw=2 fdm=marker