annotate runtime/syntax/dot.vim @ 33399:95db67c7b754 v9.0.1958

patch 9.0.1958: cannot complete option values Commit: https://github.com/vim/vim/commit/900894b09a95398dfc75599e9f0aa2ea25723384 Author: Yee Cheng Chin <ychin.git@gmail.com> Date: Fri Sep 29 20:42:32 2023 +0200 patch 9.0.1958: cannot complete option values Problem: cannot complete option values Solution: Add completion functions for several options Add cmdline tab-completion for setting string options Add tab-completion for setting string options on the cmdline using `:set=` (along with `:set+=` and `:set-=`). The existing tab completion for setting options currently only works when nothing is typed yet, and it only fills in with the existing value, e.g. when the user does `:set diffopt=<Tab>` it will be completed to `set diffopt=internal,filler,closeoff` and nothing else. This isn't too useful as a user usually wants auto-complete to suggest all the possible values, such as 'iblank', or 'algorithm:patience'. For set= and set+=, this adds a new optional callback function for each option that can be invoked when doing completion. This allows for each option to have control over how completion works. For example, in 'diffopt', it will suggest the default enumeration, but if `algorithm:` is selected, it will further suggest different algorithm types like 'meyers' and 'patience'. When using set=, the existing option value will be filled in as the first choice to preserve the existing behavior. When using set+= this won't happen as it doesn't make sense. For flag list options (e.g. 'mouse' and 'guioptions'), completion will take into account existing typed values (and in the case of set+=, the existing option value) to make sure it doesn't suggest duplicates. For set-=, there is a new `ExpandSettingSubtract` function which will handle flag list and comma-separated options smartly, by only suggesting values that currently exist in the option. Note that Vim has some existing code that adds special handling for 'filetype', 'syntax', and misc dir options like 'backupdir'. This change preserves them as they already work, instead of converting to the new callback API for each option. closes: #13182 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Fri, 29 Sep 2023 20:45:04 +0200
parents 4ab4ef0c48b1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Language: Dot
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Filenames: *.dot
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 20
diff changeset
3 " Maintainer: Markus Mottl <markus.mottl@gmail.com>
d6a69271cb9a updated for version 7.0194
vimboss
parents: 20
diff changeset
4 " URL: http://www.ocaml.info/vim/syntax/dot.vim
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
5 " Last Change: 2021 Mar 24 - better attr + escape string matching, new keywords (Farbod Salamat-Zadeh)
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
6 " 2011 May 17 - improved identifier matching + two new keywords
20
4ac1dce8dd5e updated for version 7.0012
vimboss
parents: 7
diff changeset
7 " 2001 May 04 - initial version
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
9 " For version 5.x: Clear all syntax items
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
10 " For version 6.x: Quit when a syntax file was already loaded
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
11 if version < 600
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
12 syntax clear
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
13 elseif exists("b:current_syntax")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
17 let s:keepcpo = &cpo
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
18 set cpo&vim
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
19
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 " Errors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 syn match dotParErr ")"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 syn match dotBrackErr "]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 syn match dotBraceErr "}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " Enclosing delimiters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 syn region dotEncl transparent matchgroup=dotParEncl start="(" matchgroup=dotParEncl end=")" contains=ALLBUT,dotParErr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 syn region dotEncl transparent matchgroup=dotBrackEncl start="\[" matchgroup=dotBrackEncl end="\]" contains=ALLBUT,dotBrackErr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 syn region dotEncl transparent matchgroup=dotBraceEncl start="{" matchgroup=dotBraceEncl end="}" contains=ALLBUT,dotBraceErr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " Comments
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 syn region dotComment start="//" end="$" contains=dotComment,dotTodo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 syn region dotComment start="/\*" end="\*/" contains=dotComment,dotTodo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 syn keyword dotTodo contained TODO FIXME XXX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " Strings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 syn region dotString start=+"+ skip=+\\\\\|\\"+ end=+"+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
38 " Escape strings
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
39 syn match dotEscString /\v\\(N|G|E|T|H|L)/ containedin=dotString
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
40 syn match dotEscString /\v\\(n|l|r)/ containedin=dotString
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
42 " General keywords
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
43 syn keyword dotKeyword graph digraph subgraph node edge strict
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
45 " Node, edge and graph attributes
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
46 syn keyword dotType _background area arrowhead arrowsize arrowtail bb bgcolor
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
47 \ center charset class clusterrank color colorscheme comment compound
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
48 \ concentrate constraint Damping decorate defaultdist dim dimen dir
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
49 \ diredgeconstraints distortion dpi edgehref edgetarget edgetooltip
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
50 \ edgeURL epsilon esep fillcolor fixedsize fontcolor fontname fontnames
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
51 \ fontpath fontsize forcelabels gradientangle group head_lp headclip
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
52 \ headhref headlabel headport headtarget headtooltip headURL height href
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
53 \ id image imagepath imagepos imagescale inputscale K label label_scheme
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
54 \ labelangle labeldistance labelfloat labelfontcolor labelfontname
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
55 \ labelfontsize labelhref labeljust labelloc labeltarget labeltooltip
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
56 \ labelURL landscape layer layerlistsep layers layerselect layersep
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
57 \ layout len levels levelsgap lhead lheight lp ltail lwidth margin
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
58 \ maxiter mclimit mindist minlen mode model mosek newrank nodesep
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
59 \ nojustify normalize notranslate nslimit nslimit1 ordering orientation
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
60 \ outputorder overlap overlap_scaling overlap_shrink pack packmode pad
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
61 \ page pagedir pencolor penwidth peripheries pin pos quadtree quantum
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
62 \ rank rankdir ranksep ratio rects regular remincross repulsiveforce
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
63 \ resolution root rotate rotation samehead sametail samplepoints scale
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
64 \ searchsize sep shape shapefile showboxes sides size skew smoothing
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
65 \ sortv splines start style stylesheet tail_lp tailclip tailhref
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
66 \ taillabel tailport tailtarget tailtooltip tailURL target tooltip
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
67 \ truecolor URL vertices viewport voro_margin weight width xdotversion
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
68 \ xlabel xlp z
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " Special chars
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 syn match dotKeyChar "="
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 syn match dotKeyChar ";"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 syn match dotKeyChar "->"
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
74 syn match dotKeyChar "--"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " Identifier
2833
c869ff170ddc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 659
diff changeset
77 syn match dotIdentifier /\<\w\+\(:\w\+\)\?\>/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 " Synchronization
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 syn sync minlines=50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 syn sync maxlines=500
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 " Define the default highlighting.
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
84 " For version 5.7 and earlier: only when not done already
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
85 " For version 5.8 and later: only when an item doesn't have highlighting yet
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
86 if version >= 508 || !exists("did_dot_syntax_inits")
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
87 if version < 508
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
88 let did_dot_syntax_inits = 1
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
89 command -nargs=+ HiLink hi link <args>
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
90 else
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
91 command -nargs=+ HiLink hi def link <args>
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
92 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
94 HiLink dotParErr Error
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
95 HiLink dotBraceErr Error
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
96 HiLink dotBrackErr Error
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
98 HiLink dotComment Comment
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
99 HiLink dotTodo Todo
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
100
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
101 HiLink dotParEncl Keyword
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
102 HiLink dotBrackEncl Keyword
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
103 HiLink dotBraceEncl Keyword
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
105 HiLink dotKeyword Keyword
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
106 HiLink dotType Type
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
107 HiLink dotKeyChar Keyword
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
109 HiLink dotString String
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
110 HiLink dotEscString Keyword
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
111 HiLink dotIdentifier Identifier
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
113 delcommand HiLink
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
114 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 let b:current_syntax = "dot"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
24278
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
118 let &cpo = s:keepcpo
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
119 unlet s:keepcpo
4ab4ef0c48b1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
120
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 " vim: ts=8