@@ -115,8 +115,8 @@ type FunctionOptions struct {
115
115
// expression for the function
116
116
//
117
117
// func example(eval *struct{
118
- // GOPATH string `eval:"$GOPATH"`
119
- // Cwd string `eval:"getcwd()"`
118
+ // GOPATH string `eval:"$GOPATH"`
119
+ // Cwd string `eval:"getcwd()"`
120
120
// })
121
121
//
122
122
// is
@@ -125,11 +125,11 @@ type FunctionOptions struct {
125
125
func (p * Plugin ) HandleFunction (options * FunctionOptions , fn interface {}) {
126
126
m := make (map [string ]string )
127
127
if options .Eval != "" {
128
- m [" eval" ] = eval (options .Eval , fn )
128
+ m [` eval` ] = eval (options .Eval , fn )
129
129
}
130
130
p .handle (fn , & pluginSpec {
131
- sm : " 0:function:" + options .Name ,
132
- Type : " function" ,
131
+ sm : ` 0:function:` + options .Name ,
132
+ Type : ` function` ,
133
133
Name : options .Name ,
134
134
Sync : isSync (fn ),
135
135
Opts : m ,
@@ -228,45 +228,45 @@ func (p *Plugin) HandleCommand(options *CommandOptions, fn interface{}) {
228
228
m := make (map [string ]string )
229
229
230
230
if options .NArgs != "" {
231
- m [" nargs" ] = options .NArgs
231
+ m [` nargs` ] = options .NArgs
232
232
}
233
233
234
234
if options .Range != "" {
235
- if options .Range == "." {
235
+ if options .Range == `.` {
236
236
options .Range = ""
237
237
}
238
- m [" range" ] = options .Range
238
+ m [` range` ] = options .Range
239
239
} else if options .Count != "" {
240
- m [" count" ] = options .Count
240
+ m [` count` ] = options .Count
241
241
}
242
242
243
243
if options .Bang {
244
- m [" bang" ] = ""
244
+ m [` bang` ] = ""
245
245
}
246
246
247
247
if options .Register {
248
- m [" register" ] = ""
248
+ m [` register` ] = ""
249
249
}
250
250
251
251
if options .Eval != "" {
252
- m [" eval" ] = eval (options .Eval , fn )
252
+ m [` eval` ] = eval (options .Eval , fn )
253
253
}
254
254
255
255
if options .Addr != "" {
256
- m [" addr" ] = options .Addr
256
+ m [` addr` ] = options .Addr
257
257
}
258
258
259
259
if options .Bar {
260
- m [" bar" ] = ""
260
+ m [` bar` ] = ""
261
261
}
262
262
263
263
if options .Complete != "" {
264
- m [" complete" ] = options .Complete
264
+ m [` complete` ] = options .Complete
265
265
}
266
266
267
267
p .handle (fn , & pluginSpec {
268
- sm : " 0:command:" + options .Name ,
269
- Type : " command" ,
268
+ sm : ` 0:command:` + options .Name ,
269
+ Type : ` command` ,
270
270
Name : options .Name ,
271
271
Sync : isSync (fn ),
272
272
Opts : m ,
@@ -310,31 +310,31 @@ func (p *Plugin) HandleAutocmd(options *AutocmdOptions, fn interface{}) {
310
310
pattern := ""
311
311
m := make (map [string ]string )
312
312
if options .Group != "" {
313
- m [" group" ] = options .Group
313
+ m [` group` ] = options .Group
314
314
}
315
315
if options .Pattern != "" {
316
- m [" pattern" ] = options .Pattern
316
+ m [` pattern` ] = options .Pattern
317
317
pattern = options .Pattern
318
318
}
319
319
if options .Nested {
320
- m [" nested" ] = "1"
320
+ m [` nested` ] = "1"
321
321
}
322
322
if options .Once {
323
- m [" once" ] = "1"
323
+ m [` once` ] = "1"
324
324
}
325
325
if options .Eval != "" {
326
- m [" eval" ] = eval (options .Eval , fn )
326
+ m [` eval` ] = eval (options .Eval , fn )
327
327
}
328
328
329
329
// Compute unique path for event and pattern.
330
330
ep := options .Event + ":" + pattern
331
331
i := p .eventPathCounts [ep ]
332
332
p .eventPathCounts [ep ] = i + 1
333
- sm := fmt .Sprintf (" %d:autocmd:%s" , i , ep )
333
+ sm := fmt .Sprintf (` %d:autocmd:%s` , i , ep )
334
334
335
335
p .handle (fn , & pluginSpec {
336
336
sm : sm ,
337
- Type : " autocmd" ,
337
+ Type : ` autocmd` ,
338
338
Name : options .Event ,
339
339
Sync : isSync (fn ),
340
340
Opts : m ,
@@ -350,16 +350,17 @@ func (p *Plugin) RegisterForTests() error {
350
350
}
351
351
const host = "nvim-go-test"
352
352
for path , specs := range specs {
353
- if err := p .Nvim .Call (" remote#host#RegisterPlugin" , nil , host , path , specs ); err != nil {
353
+ if err := p .Nvim .Call (` remote#host#RegisterPlugin` , nil , host , path , specs ); err != nil {
354
354
return err
355
355
}
356
356
}
357
- err := p .Nvim .Call ("remote#host#Register" , nil , host , "x" , p .Nvim .ChannelID ())
357
+ err := p .Nvim .Call (`remote#host#Register` , nil , host , `x` , p .Nvim .ChannelID ())
358
+
358
359
return err
359
360
}
360
361
361
362
func eval (eval string , f interface {}) string {
362
- if eval != "*" {
363
+ if eval != `*` {
363
364
return eval
364
365
}
365
366
ft := reflect .TypeOf (f )
@@ -403,11 +404,11 @@ func structEval(t reflect.Type) string {
403
404
}
404
405
405
406
buf = append (buf , sep ... )
406
- buf = append (buf , "'" ... )
407
+ buf = append (buf , `'` ... )
407
408
buf = append (buf , name ... )
408
- buf = append (buf , "': " ... )
409
+ buf = append (buf , `':` ... )
409
410
buf = append (buf , eval ... )
410
- sep = ", "
411
+ sep = `, `
411
412
}
412
413
buf = append (buf , '}' )
413
414
return string (buf )
@@ -424,25 +425,25 @@ func (p *Plugin) Manifest(host string) []byte {
424
425
425
426
// Sort for consistent order on output.
426
427
sort .Sort (byServiceMethod (p .pluginSpecs ))
427
- escape := strings .NewReplacer ("'" , "''" ).Replace
428
+ escape := strings .NewReplacer (`'` , `''` ).Replace
428
429
429
430
prevPath := ""
430
431
for _ , spec := range p .pluginSpecs {
431
432
path := spec .path ()
432
433
if path != prevPath {
433
434
if prevPath != "" {
434
- fmt .Fprintf (& buf , " \\ )" )
435
+ fmt .Fprintf (& buf , ` \\ )` )
435
436
}
436
- fmt .Fprintf (& buf , " call remote#host#RegisterPlugin('%s', '%s', [\n " , host , path )
437
+ fmt .Fprintf (& buf , ` call remote#host#RegisterPlugin('%s', '%s', [\n` , host , path )
437
438
prevPath = path
438
439
}
439
440
440
- sync := "0"
441
+ sync := `0`
441
442
if spec .Sync {
442
- sync = "1"
443
+ sync = `1`
443
444
}
444
445
445
- fmt .Fprintf (& buf , " \\ {'type': '%s', 'name': '%s', 'sync': %s, 'opts': {" , spec .Type , spec .Name , sync )
446
+ fmt .Fprintf (& buf , ` \\ {'type': '%s', 'name': '%s', 'sync': %s, 'opts': {` , spec .Type , spec .Name , sync )
446
447
447
448
var keys []string
448
449
for k := range spec .Opts {
@@ -452,14 +453,14 @@ func (p *Plugin) Manifest(host string) []byte {
452
453
453
454
optDelim := ""
454
455
for _ , k := range keys {
455
- fmt .Fprintf (& buf , " %s'%s': '%s'" , optDelim , k , escape (spec .Opts [k ]))
456
- optDelim = ", "
456
+ fmt .Fprintf (& buf , ` %s'%s': '%s'` , optDelim , k , escape (spec .Opts [k ]))
457
+ optDelim = `,`
457
458
}
458
459
459
- fmt .Fprintf (& buf , " }},\n " )
460
+ fmt .Fprintf (& buf , ` }},\n` )
460
461
}
461
462
if prevPath != "" {
462
- fmt .Fprintf (& buf , " \\ ])\n " )
463
+ fmt .Fprintf (& buf , ` \\ ])\n` )
463
464
}
464
465
return buf .Bytes ()
465
466
}
0 commit comments