Mercurial > vim
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 |
rev | line source |
---|---|
29756 | 1 vim9script |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
29756 | 3 # Language: ConTeXt typesetting engine |
4 # Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> | |
5 # Former Maintainers: Nikolai Weibull <now@bitwi.se> | |
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 | 8 # Typesetting {{{ |
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 | 11 export def ConTeXtCmd(path: string): list<string> |
12 return ['mtxrun', '--script', 'context', '--nonstopmode', '--autogenerate', path] | |
13 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 |
29756 | 15 export def Typeset(bufname: string, env = {}, Cmd = ConTeXtCmd): bool |
16 return typeset.TypesetBuffer(bufname, Cmd, env, 'ConTeXt') | |
17 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 |
29756 | 19 export def JobStatus() |
20 typeset.JobStatus('ConTeXt') | |
21 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 |
29756 | 23 export def StopJobs() |
24 typeset.StopJobs('ConTeXt') | |
25 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 |
29756 | 27 export def Log(bufname: string) |
28 execute 'edit' typeset.LogPath(bufname) | |
29 enddef | |
30 # }}} | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 |
29756 | 32 # Completion {{{ |
33 def BinarySearch(base: string, keywords: list<string>): list<string> | |
34 const pat = '^' .. base | |
35 const len = len(keywords) | |
36 var res = [] | |
37 var lft = 0 | |
38 var rgt = len | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
29756 | 40 # Find the leftmost index matching base |
41 while lft < rgt | |
42 var i = (lft + rgt) / 2 | |
43 if keywords[i] < base | |
44 lft = i + 1 | |
45 else | |
46 rgt = i | |
47 endif | |
48 endwhile | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
29756 | 50 while lft < len && keywords[lft] =~ pat |
51 add(res, keywords[lft]) | |
52 lft += 1 | |
53 endwhile | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 |
29756 | 55 return res |
56 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 |
29756 | 58 var isMetaPostBlock = false |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 |
29756 | 60 var MP_KEYWORDS: list<string> = [] |
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 | 63 # Complete only MetaPost keywords in MetaPost blocks, and complete only |
64 # ConTeXt keywords otherwise. | |
65 export def Complete(findstart: number, base: string): any | |
66 if findstart == 1 | |
67 if len(synstack(line("."), 1)) > 0 && synIDattr(synstack(line("."), 1)[0], "name") ==# 'contextMPGraphic' | |
68 isMetaPostBlock = true | |
69 return match(getline('.'), '\S\+\%' .. col('.') .. 'c') | |
70 endif | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 |
29756 | 72 # Complete only \commands starting with a backslash |
73 isMetaPostBlock = false | |
74 var pos = match(getline('.'), '\\\zs\S\+\%' .. col('.') .. 'c') | |
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 | 77 |
78 if isMetaPostBlock | |
79 if empty(MP_KEYWORDS) | |
80 MP_KEYWORDS = sort(syntaxcomplete#OmniSyntaxList(['mf\w\+', 'mp\w\+'])) | |
81 endif | |
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 | 85 if empty(CTX_KEYWORDS) |
86 CTX_KEYWORDS = sort(syntaxcomplete#OmniSyntaxList([ | |
87 'context\w\+', 'texAleph', 'texEtex', 'texLuatex', 'texOmega', | |
88 'texPdftex', 'texTex', 'texXeTeX' | |
89 ])) | |
90 endif | |
91 return BinarySearch(base, CTX_KEYWORDS) | |
92 enddef | |
93 # }}} | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 |
29756 | 95 # vim: sw=2 fdm=marker |