@@ -14,16 +14,21 @@ package main
14
14
// vim.c
15
15
16
16
// Exec executes Vimscript (multiline block of Ex-commands), like anonymous source.
17
+ // Exec executes Vimscript (multiline block of Ex-commands), like anonymous |:source|.
18
+ //
19
+ // Unlike Command, this function supports heredocs, script-scope (s:), etc.
20
+ //
21
+ // On execution error: fails with VimL error, does not update v:errmsg.
17
22
func Exec (src string , output bool ) (out string ) {
18
23
name (nvim_exec )
19
24
}
20
25
21
- // Command executes a single ex command.
26
+ // Command executes an ex- command.
22
27
func Command (cmd string ) {
23
28
name (nvim_command )
24
29
}
25
30
26
- // HLByID gets a highlight definition by id .
31
+ // HLByID gets a highlight definition by name .
27
32
func HLByID (id int , rgb bool ) (highlight HLAttrs ) {
28
33
name (nvim_get_hl_by_id )
29
34
returnPtr ()
@@ -34,7 +39,7 @@ func HLIDByName(name string) (highlightID int) {
34
39
name (nvim_get_hl_id_by_name )
35
40
}
36
41
37
- // HLByName gets a highlight definition by name .
42
+ // HLByName gets a highlight definition by id .
38
43
func HLByName (name string , rgb bool ) (highlight HLAttrs ) {
39
44
name (nvim_get_hl_by_name )
40
45
returnPtr ()
@@ -45,6 +50,11 @@ func HLByName(name string, rgb bool) (highlight HLAttrs) {
45
50
// name arg is highlight group name, like ErrorMsg.
46
51
//
47
52
// val arg is highlight definiton map, like HLByName.
53
+ //
54
+ // in addition the following keys are also recognized:
55
+ //
56
+ // default
57
+ // don't override existing definition, like `hi default`.
48
58
func SetHighlight (nsID int , name string , val * HLAttrs ) {
49
59
name (nvim_set_hl )
50
60
}
@@ -56,13 +66,21 @@ func SetHighlight(nsID int, name string, val *HLAttrs) {
56
66
// To start with SetDecorationProvider on_win and on_line callbacks
57
67
// are explicitly allowed to change the namespace during a redraw cycle.
58
68
//
59
- // The ` nsID` arg is the namespace to activate.
69
+ // The nsID arg is the namespace to activate.
60
70
func SetHighlightNameSpace (nsID int ) {
61
71
name (nvim_set_hl_ns )
62
72
}
63
73
64
- // FeedKeys Pushes keys to the Nvim user input buffer. Options can be a string
65
- // with the following character flags:
74
+ // FeedKeys sends input-keys to Nvim, subject to various quirks controlled by mode flags.
75
+ // This is a blocking call, unlike Input.
76
+ //
77
+ // On execution error: does not fail, but updates v:errmsg.
78
+ //
79
+ // If you need to input sequences like <C-o> use ReplaceTermcodes to
80
+ // replace the termcodes and then pass the resulting string to nvim_feedkeys.
81
+ // You'll also want to enable escape_csi.
82
+ //
83
+ // mode is following character flags:
66
84
//
67
85
// m
68
86
// Remap keys. This is default.
@@ -71,28 +89,30 @@ func SetHighlightNameSpace(nsID int) {
71
89
// t
72
90
// Handle keys as if typed; otherwise they are handled as if coming from a mapping.
73
91
// This matters for undo, opening folds, etc.
92
+ //
93
+ // The escape_csi arg is whether the escape K_SPECIAL/CSI bytes in keys arg.
74
94
func FeedKeys (keys , mode string , escapeCSI bool ) {
75
95
name (nvim_feedkeys )
76
96
}
77
97
78
- // Input pushes bytes to the Nvim low level input buffer .
98
+ // Input queues raw user- input.
79
99
//
80
- // Unlike FeedKeys, this uses the lowest level input buffer and the call is not
81
- // deferred. It returns the number of bytes actually written(which can be less
82
- // than what was requested if the buffer is full).
100
+ // Unlike FeedKeys, this uses a low-level input buffer and the call
101
+ // is non-blocking (input is processed asynchronously by the eventloop).
83
102
func Input (keys string ) (written int ) {
84
103
name (nvim_input )
85
104
}
86
105
87
106
// InputMouse send mouse event from GUI.
88
107
//
89
- // The call is non-blocking. It doesn't wait on any resulting action, but
108
+ // This API is non-blocking. It doesn't wait on any resulting action, but
90
109
// queues the event to be processed soon by the event loop.
91
110
func InputMouse (button , action , modifier string , grid , row , col int ) {
92
111
name (nvim_input_mouse )
93
112
}
94
113
95
- // ReplaceTermcodes replaces any terminal code strings by byte sequences.
114
+ // ReplaceTermcodes replaces terminal codes and |keycodes| (<CR>, <Esc>, ...) in a string with
115
+ // the internal representation.
96
116
//
97
117
// The returned sequences are Nvim's internal representation of keys, for example:
98
118
//
@@ -114,66 +134,56 @@ func CommandOutput(cmd string) (out string) {
114
134
deprecatedSince (7 )
115
135
}
116
136
117
- // Eval evaluates the expression expr using the Vim internal expression
118
- // evaluator.
137
+ // Eval evaluates a VimL expression.
138
+ //
139
+ // Dictionaries and Lists are recursively expanded.
119
140
//
120
141
// :help expression
121
142
func Eval (expr string ) (result interface {}) {
122
143
name (nvim_eval )
123
144
}
124
145
125
- // SetPumBounds tells Nvim the geometry of the popumenu, to align floating windows with an
126
- // external popup menu.
127
- //
128
- // Note that this method is not to be confused with SetPumHeight,
129
- // which sets the number of visible items in the popup menu, while this
130
- // function sets the bounding box of the popup menu, including visual
131
- // elements such as borders and sliders.
146
+ // StringWidth calculates the number of display cells occupied by `text`.
132
147
//
133
- // Floats need not use the same font size, nor be anchored to exact grid corners, so one can set floating-point
134
- // numbers to the popup menu geometry.
135
- func SetPumBounds (width , height , row , col float64 ) {
136
- name (nvim_ui_pum_set_bounds )
137
- }
138
-
139
- // StringWidth returns the number of display cells the string occupies. Tab is
140
- // counted as one cell.
148
+ // <Tab> counts as one cell.
141
149
func StringWidth (s string ) (width int ) {
142
150
name (nvim_strwidth )
143
151
}
144
152
145
- // RuntimePaths returns a list of paths contained in the runtimepath option .
153
+ // RuntimePaths gets the paths contained in ' runtimepath' .
146
154
func RuntimePaths () (paths []string ) {
147
155
name (nvim_list_runtime_paths )
148
156
}
149
157
150
158
// RuntimeFiles finds files in runtime directories and returns list of absolute paths to the found files.
151
159
//
152
160
// The name arg is can contain wildcards. For example,
161
+ //
153
162
// RuntimeFiles("colors/*.vim", true)
163
+ //
154
164
// will return all color scheme files.
155
165
//
156
166
// The all arg is whether to return all matches or only the first.
157
167
func RuntimeFiles (name string , all bool ) (files []string ) {
158
168
name (nvim_get_runtime_file )
159
169
}
160
170
161
- // SetCurrentDirectory changes the Vim working directory.
171
+ // SetCurrentDirectory changes the global working directory.
162
172
func SetCurrentDirectory (dir string ) {
163
173
name (nvim_set_current_dir )
164
174
}
165
175
166
- // CurrentLine gets the current line in the current buffer .
176
+ // CurrentLine gets the current line.
167
177
func CurrentLine () (line []byte ) {
168
178
name (nvim_get_current_line )
169
179
}
170
180
171
- // SetCurrentLine sets the current line in the current buffer .
181
+ // SetCurrentLine sets the current line.
172
182
func SetCurrentLine (line []byte ) {
173
183
name (nvim_set_current_line )
174
184
}
175
185
176
- // DeleteCurrentLine deletes the current line in the current buffer .
186
+ // DeleteCurrentLine deletes the current line.
177
187
func DeleteCurrentLine () {
178
188
name (nvim_del_current_line )
179
189
}
@@ -193,7 +203,7 @@ func DeleteVar(name string) {
193
203
name (nvim_del_var )
194
204
}
195
205
196
- // VVar gets a vim (v:) variable.
206
+ // VVar gets a v: variable.
197
207
func VVar (name string ) (value interface {}) {
198
208
name (nvim_get_vvar )
199
209
}
@@ -203,7 +213,7 @@ func SetVVar(name string, value interface{}) {
203
213
name (nvim_set_vvar )
204
214
}
205
215
206
- // Option gets an option.
216
+ // Option gets an option value string .
207
217
func Option (name string ) (option interface {}) {
208
218
name (nvim_get_option )
209
219
}
@@ -217,67 +227,89 @@ func Option(name string) (option interface{}) {
217
227
//
218
228
// name
219
229
// Name of the option (like 'filetype').
230
+ //
220
231
// shortname
221
232
// Shortened name of the option (like 'ft').
233
+ //
222
234
// type
223
235
// type of option ("string", "number" or "boolean").
236
+ //
224
237
// default
225
238
// The default value for the option.
239
+ //
226
240
// was_set
227
241
// Whether the option was set.
242
+ //
228
243
// last_set_sid
229
244
// Last set script id (if any).
245
+ //
230
246
// last_set_linenr
231
247
// line number where option was set.
248
+ //
232
249
// last_set_chan
233
250
// Channel where option was set (0 for local).
251
+ //
234
252
// scope
235
253
// one of "global", "win", or "buf".
254
+ //
236
255
// global_local
237
256
// whether win or buf option has a global value.
257
+ //
238
258
// commalist
239
259
// List of comma separated values.
260
+ //
240
261
// flaglist
241
262
// List of single char flags.
242
263
func AllOptionsInfo () (opinfo OptionInfo ) {
243
264
name (nvim_get_all_options_info )
244
265
returnPtr ()
245
266
}
246
267
247
- // OptionInfo Gets the option information for one option.
268
+ // OptionInfo gets the option information for one option.
248
269
//
249
270
// Resulting dictionary has keys:
250
271
//
251
272
// name
252
273
// Name of the option (like 'filetype').
274
+ //
253
275
// shortname
254
276
// Shortened name of the option (like 'ft').
277
+ //
255
278
// type
256
279
// type of option ("string", "number" or "boolean").
280
+ //
257
281
// default
258
282
// The default value for the option.
283
+ //
259
284
// was_set
260
285
// Whether the option was set.
286
+ //
261
287
// last_set_sid
262
288
// Last set script id (if any).
289
+ //
263
290
// last_set_linenr
264
291
// line number where option was set.
292
+ //
265
293
// last_set_chan
266
294
// Channel where option was set (0 for local).
295
+ //
267
296
// scope
268
297
// one of "global", "win", or "buf".
298
+ //
269
299
// global_local
270
300
// whether win or buf option has a global value.
301
+ //
271
302
// commalist
272
303
// List of comma separated values.
304
+ //
273
305
// flaglist
274
- // List of single char flags.
306
+ // List of single char flags.
275
307
func OptionInfo (name string ) (opinfo OptionInfo ) {
276
308
name (nvim_get_option_info )
277
309
returnPtr ()
278
310
}
279
311
280
- // SetOption sets an option.
312
+ // SetOption sets an option value .
281
313
func SetOption (name string , value interface {}) {
282
314
name (nvim_set_option )
283
315
}
@@ -506,10 +538,11 @@ func ColorMap() (colorMap map[string]int) {
506
538
// Context gets a map of the current editor state.
507
539
// This API still under development.
508
540
//
509
- // The `opts` is optional parameters.
541
+ // The opts arg is optional parameters.
542
+ // Key is `types`.
543
+ //
544
+ // List of context-types to gather, or empty for `all` context.
510
545
//
511
- // types
512
- // List of context-types to gather, or empty for all context.
513
546
// regs
514
547
// jumps
515
548
// bufs
@@ -525,7 +558,7 @@ func LoadContext(dict map[string]interface{}) (contextMap interface{}) {
525
558
name (nvim_load_context )
526
559
}
527
560
528
- // Mode gets Nvim's current mode.
561
+ // Mode gets the current mode.
529
562
func Mode () (mode Mode ) {
530
563
name (nvim_get_mode )
531
564
returnPtr ()
@@ -586,11 +619,14 @@ func APIInfo() (apiInfo []interface{}) {
586
619
name (nvim_get_api_info )
587
620
}
588
621
589
- // SetClientInfo identify the client for nvim.
622
+ // SetClientInfo self-identifies the client.
623
+ //
624
+ // The client/plugin/application should call this after connecting, to provide
625
+ // hints about its identity and purpose, for debugging and orchestration.
590
626
//
591
- // Can be called more than once, but subsequent calls will remove earlier info,
592
- // which should be resent if it is still valid. (This could happen if a library first identifies the channel,
593
- // and a plugin using that library later overrides that info.)
627
+ // Can be called more than once; the caller should merge old info if
628
+ // appropriate. Example: library first identifies the channel, then a plugin
629
+ // using that library later identifies itself.
594
630
func SetClientInfo (name string , version * ClientVersion , typ string , methods map [string ]* ClientMethod , attributes ClientAttributes ) {
595
631
name (nvim_set_client_info )
596
632
}
@@ -1213,3 +1249,17 @@ func TryResizeUIGrid(grid, width, height int) {
1213
1249
func SetPumHeight (height int ) {
1214
1250
name (nvim_ui_pum_set_height )
1215
1251
}
1252
+
1253
+ // SetPumBounds tells Nvim the geometry of the popumenu, to align floating windows with an
1254
+ // external popup menu.
1255
+ //
1256
+ // Note that this method is not to be confused with SetPumHeight,
1257
+ // which sets the number of visible items in the popup menu, while this
1258
+ // function sets the bounding box of the popup menu, including visual
1259
+ // elements such as borders and sliders.
1260
+ //
1261
+ // Floats need not use the same font size, nor be anchored to exact grid corners, so one can set floating-point
1262
+ // numbers to the popup menu geometry.
1263
+ func SetPumBounds (width , height , row , col float64 ) {
1264
+ name (nvim_ui_pum_set_bounds )
1265
+ }
0 commit comments