robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
25.1 KiB765 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3
4local describe, it, before_each = t.describe, t.it, t.before_each
5local clear, eq, neq, eval = n.clear, t.eq, t.neq, n.eval
6local api = n.api
7local curbuf = n.api.nvim_get_current_buf
8local curwin = n.api.nvim_get_current_win
9local exec_capture = n.exec_capture
10local source, command = n.source, n.command
11
12local function declare_hook_function()
13  source([[
14    fu! AutoCommand(match, bufnr, winnr)
15      let l:acc = {
16      \   'option'   : a:match,
17      \   'oldval'   : v:option_old,
18      \   'oldval_l' : v:option_oldlocal,
19      \   'oldval_g' : v:option_oldglobal,
20      \   'newval'   : v:option_new,
21      \   'scope'    : v:option_type,
22      \   'cmd'      : v:option_command,
23      \   'attr'     : {
24      \     'bufnr' : a:bufnr,
25      \     'winnr' : a:winnr,
26      \   }
27      \ }
28      call add(g:ret, l:acc)
29    endfu
30  ]])
31end
32
33local function set_hook(pattern)
34  command(
35    'au OptionSet ' .. pattern .. ' :call AutoCommand(expand("<amatch>"), bufnr("%"), winnr())'
36  )
37end
38
39local function init_var()
40  command('let g:ret = []')
41end
42
43local function get_result()
44  local ret = api.nvim_get_var('ret')
45  init_var()
46  return ret
47end
48
49local function expected_table(option, oldval, oldval_l, oldval_g, newval, scope, cmd, attr)
50  return {
51    option = option,
52    oldval = oldval,
53    oldval_l = oldval_l,
54    oldval_g = oldval_g,
55    newval = newval,
56    scope = scope,
57    cmd = cmd,
58    attr = attr,
59  }
60end
61
62local function expected_combination(...)
63  local args = { ... }
64  local ret = get_result()
65
66  if not (#args == #ret) then
67    local expecteds = {}
68    for _, v in pairs(args) do
69      table.insert(expecteds, expected_table(unpack(v)))
70    end
71    eq(expecteds, ret)
72    return
73  end
74
75  for i, v in ipairs(args) do
76    local attr = v[8]
77    if not attr then
78      -- remove attr entries
79      ret[i].attr = nil
80    else
81      -- remove attr entries which are not required
82      for k in pairs(ret[i].attr) do
83        if not attr[k] then
84          ret[i].attr[k] = nil
85        end
86      end
87    end
88    eq(expected_table(unpack(v)), ret[i])
89  end
90end
91
92local function expected_empty()
93  eq({}, get_result())
94end
95
96local function make_buffer()
97  local old_buf = curbuf()
98  command('botright new')
99  local new_buf = curbuf()
100  command('wincmd p') -- move previous window
101
102  neq(old_buf, new_buf)
103  eq(old_buf, curbuf())
104
105  return new_buf
106end
107
108local function get_new_window_number()
109  local old_win = curwin()
110  command('botright new')
111  local new_win = curwin()
112  local new_winnr = exec_capture('echo winnr()')
113  command('wincmd p') -- move previous window
114
115  neq(old_win, new_win)
116  eq(old_win, curwin())
117
118  return new_winnr
119end
120
121describe('au OptionSet', function()
122  describe('with any option (*)', function()
123    before_each(function()
124      clear()
125      declare_hook_function()
126      init_var()
127      set_hook('*')
128    end)
129
130    it('should be called in setting number option', function()
131      command('set nu')
132      expected_combination({ 'number', false, false, false, true, 'global', 'set' })
133
134      command('setlocal nonu')
135      expected_combination({ 'number', true, true, '', false, 'local', 'setlocal' })
136
137      command('setglobal nonu')
138      expected_combination({ 'number', true, '', true, false, 'global', 'setglobal' })
139    end)
140
141    it('should be called in setting autoindent option', function()
142      command('setlocal ai')
143      expected_combination({ 'autoindent', false, false, '', true, 'local', 'setlocal' })
144
145      command('setglobal ai')
146      expected_combination({ 'autoindent', false, '', false, true, 'global', 'setglobal' })
147
148      command('set noai')
149      expected_combination({ 'autoindent', true, true, true, false, 'global', 'set' })
150    end)
151
152    it('should be called in inverting global autoindent option', function()
153      command('set ai!')
154      expected_combination({ 'autoindent', false, false, false, true, 'global', 'set' })
155    end)
156
157    it('should be called in being unset local autoindent option', function()
158      command('setlocal ai')
159      expected_combination({ 'autoindent', false, false, '', true, 'local', 'setlocal' })
160
161      command('setlocal ai<')
162      expected_combination({ 'autoindent', true, true, '', false, 'local', 'setlocal' })
163    end)
164
165    it('should be called in setting global list and number option at the same time', function()
166      command('set list nu')
167      expected_combination(
168        { 'list', false, false, false, true, 'global', 'set' },
169        { 'number', false, false, false, true, 'global', 'set' }
170      )
171    end)
172
173    it('should not print anything, use :noa', function()
174      command('noa set nolist nonu')
175      expected_empty()
176    end)
177
178    it('should be called in setting local acd', function()
179      command('setlocal acd')
180      expected_combination({ 'autochdir', false, false, '', true, 'local', 'setlocal' })
181    end)
182
183    it('should be called in setting autoread', function()
184      command('set noar')
185      expected_combination({ 'autoread', true, true, true, false, 'global', 'set' })
186
187      command('setlocal ar')
188      expected_combination({ 'autoread', false, false, '', true, 'local', 'setlocal' })
189    end)
190
191    it('should be called in inverting global autoread', function()
192      command('setglobal invar')
193      expected_combination({ 'autoread', true, '', true, false, 'global', 'setglobal' })
194    end)
195
196    it('should be called in setting backspace option through :let', function()
197      local oldval = eval('&backspace')
198
199      command('let &bs=""')
200      expected_combination({ 'backspace', oldval, oldval, oldval, '', 'global', 'set' })
201    end)
202
203    describe('being set by setbufvar()', function()
204      it('should not trigger because option name is invalid', function()
205        command('silent! call setbufvar(1, "&l:bk", 1)')
206        expected_empty()
207      end)
208
209      it('should trigger using correct option name', function()
210        command('call setbufvar(1, "&backup", 1)')
211        expected_combination({ 'backup', false, false, '', true, 'local', 'setlocal' })
212      end)
213
214      it('should trigger if the current buffer is different from the targeted buffer', function()
215        local new_buffer = make_buffer()
216        local new_bufnr = api.nvim_buf_get_number(new_buffer)
217
218        command('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")')
219        expected_combination({
220          'buftype',
221          '',
222          '',
223          '',
224          'nofile',
225          'local',
226          'setlocal',
227          { bufnr = new_bufnr },
228        })
229      end)
230    end)
231
232    it('with string global option', function()
233      local oldval = eval('&backupext')
234
235      command('set backupext=foo')
236      expected_combination({ 'backupext', oldval, oldval, oldval, 'foo', 'global', 'set' })
237
238      command('set backupext&')
239      expected_combination({ 'backupext', 'foo', 'foo', 'foo', oldval, 'global', 'set' })
240
241      command('setglobal backupext=bar')
242      expected_combination({ 'backupext', oldval, '', oldval, 'bar', 'global', 'setglobal' })
243
244      command('noa set backupext&')
245      -- As this is a global option this sets the global value even though :setlocal is used!
246      command('setlocal backupext=baz')
247      expected_combination({ 'backupext', oldval, oldval, '', 'baz', 'local', 'setlocal' })
248
249      command('noa setglobal backupext=ext_global')
250      command('noa setlocal backupext=ext_local') -- Sets the global(!) value
251      command('set backupext=foo')
252      expected_combination({
253        'backupext',
254        'ext_local',
255        'ext_local',
256        'ext_local',
257        'foo',
258        'global',
259        'set',
260      })
261    end)
262
263    it('with string global-local (to buffer) option', function()
264      local oldval = eval('&tags')
265
266      command('set tags=tagpath')
267      expected_combination({ 'tags', oldval, oldval, oldval, 'tagpath', 'global', 'set' })
268
269      command('set tags&')
270      expected_combination({ 'tags', 'tagpath', 'tagpath', 'tagpath', oldval, 'global', 'set' })
271
272      command('setglobal tags=tagpath1')
273      expected_combination({ 'tags', oldval, '', oldval, 'tagpath1', 'global', 'setglobal' })
274
275      command('setlocal tags=tagpath2')
276      expected_combination({ 'tags', 'tagpath1', 'tagpath1', '', 'tagpath2', 'local', 'setlocal' })
277
278      -- Note: v:option_old is the old global value for global-local options.
279      -- but the old local value for all other kinds of options.
280      command('noa setglobal tags=tag_global')
281      command('noa setlocal tags=tag_local')
282      command('set tags=tagpath')
283      expected_combination({
284        'tags',
285        'tag_global',
286        'tag_local',
287        'tag_global',
288        'tagpath',
289        'global',
290        'set',
291      })
292
293      -- Note: v:option_old is the old global value for global-local options.
294      -- but the old local value for all other kinds of options.
295      command('noa set tags=tag_global')
296      command('noa setlocal tags=')
297      command('set tags=tagpath')
298      expected_combination({
299        'tags',
300        'tag_global',
301        'tag_global',
302        'tag_global',
303        'tagpath',
304        'global',
305        'set',
306      })
307    end)
308
309    it('with string local (to buffer) option', function()
310      local oldval = eval('&spelllang')
311
312      command('set spelllang=elvish,klingon')
313      expected_combination({
314        'spelllang',
315        oldval,
316        oldval,
317        oldval,
318        'elvish,klingon',
319        'global',
320        'set',
321      })
322
323      command('set spelllang&')
324      expected_combination({
325        'spelllang',
326        'elvish,klingon',
327        'elvish,klingon',
328        'elvish,klingon',
329        oldval,
330        'global',
331        'set',
332      })
333
334      command('setglobal spelllang=elvish')
335      expected_combination({ 'spelllang', oldval, '', oldval, 'elvish', 'global', 'setglobal' })
336
337      command('noa set spelllang&')
338      command('setlocal spelllang=klingon')
339      expected_combination({ 'spelllang', oldval, oldval, '', 'klingon', 'local', 'setlocal' })
340
341      -- Note: v:option_old is the old global value for global-local options.
342      -- but the old local value for all other kinds of options.
343      command('noa setglobal spelllang=spellglobal')
344      command('noa setlocal spelllang=spelllocal')
345      command('set spelllang=foo')
346      expected_combination({
347        'spelllang',
348        'spelllocal',
349        'spelllocal',
350        'spellglobal',
351        'foo',
352        'global',
353        'set',
354      })
355    end)
356
357    it('with string global-local (to window) option', function()
358      local oldval = eval('&statusline')
359      local default_statusline = api.nvim_get_option_info2('statusline', {}).default
360
361      command('set statusline=foo')
362      expected_combination({
363        'statusline',
364        oldval,
365        oldval,
366        oldval,
367        'foo',
368        'global',
369        'set',
370      })
371
372      -- Note: v:option_old is the old global value for global-local options.
373      -- but the old local value for all other kinds of options.
374      command('set statusline&')
375      expected_combination({
376        'statusline',
377        'foo',
378        'foo',
379        'foo',
380        default_statusline,
381        'global',
382        'set',
383      })
384
385      command('setglobal statusline=bar')
386      expected_combination({
387        'statusline',
388        default_statusline,
389        '',
390        default_statusline,
391        'bar',
392        'global',
393        'setglobal',
394      })
395
396      command('noa set statusline&')
397      command('setlocal statusline=baz')
398      expected_combination({
399        'statusline',
400        default_statusline,
401        default_statusline,
402        '',
403        'baz',
404        'local',
405        'setlocal',
406      })
407
408      -- Note: v:option_old is the old global value for global-local options.
409      -- but the old local value for all other kinds of options.
410      command('noa setglobal statusline=bar')
411      command('noa setlocal statusline=baz')
412      command('set statusline=foo')
413      expected_combination({ 'statusline', 'bar', 'baz', 'bar', 'foo', 'global', 'set' })
414    end)
415
416    it('with string local (to window) option', function()
417      local oldval = eval('&foldignore')
418
419      command('set foldignore=fo')
420      expected_combination({ 'foldignore', oldval, oldval, oldval, 'fo', 'global', 'set' })
421
422      command('set foldignore&')
423      expected_combination({ 'foldignore', 'fo', 'fo', 'fo', oldval, 'global', 'set' })
424
425      command('setglobal foldignore=bar')
426      expected_combination({ 'foldignore', oldval, '', oldval, 'bar', 'global', 'setglobal' })
427
428      command('noa set foldignore&')
429      command('setlocal foldignore=baz')
430      expected_combination({ 'foldignore', oldval, oldval, '', 'baz', 'local', 'setlocal' })
431
432      command('noa setglobal foldignore=glob')
433      command('noa setlocal foldignore=loc')
434      command('set foldignore=fo')
435      expected_combination({ 'foldignore', 'loc', 'loc', 'glob', 'fo', 'global', 'set' })
436    end)
437
438    it('with number global option', function()
439      command('noa setglobal cmdheight=8')
440      command('noa setlocal cmdheight=1') -- Sets the global(!) value
441      command('setglobal cmdheight=2')
442      expected_combination({ 'cmdheight', 1, '', 1, 2, 'global', 'setglobal' })
443
444      command('noa setglobal cmdheight=8')
445      command('noa setlocal cmdheight=1') -- Sets the global(!) value
446      command('setlocal cmdheight=2')
447      expected_combination({ 'cmdheight', 1, 1, '', 2, 'local', 'setlocal' })
448
449      -- Note: v:option_old is the old global value for global-local options.
450      -- but the old local value for all other kinds of options.
451      command('noa setglobal cmdheight=8')
452      command('noa setlocal cmdheight=1') -- Sets the global(!) value
453      command('set cmdheight=2')
454      expected_combination({ 'cmdheight', 1, 1, 1, 2, 'global', 'set' })
455
456      -- Note: v:option_old is the old global value for global-local options.
457      -- but the old local value for all other kinds of options.
458      command('noa set cmdheight=8')
459      command('set cmdheight=2')
460      expected_combination({ 'cmdheight', 8, 8, 8, 2, 'global', 'set' })
461    end)
462
463    it('with number global-local (to buffer) option', function()
464      command('noa setglobal undolevels=8')
465      command('noa setlocal undolevels=1')
466      command('setglobal undolevels=2')
467      expected_combination({ 'undolevels', 8, '', 8, 2, 'global', 'setglobal' })
468
469      command('noa setglobal undolevels=8')
470      command('noa setlocal undolevels=1')
471      command('setlocal undolevels=2')
472      expected_combination({ 'undolevels', 1, 1, '', 2, 'local', 'setlocal' })
473
474      -- Note: v:option_old is the old global value for global-local options.
475      -- but the old local value for all other kinds of options.
476      command('noa setglobal undolevels=8')
477      command('noa setlocal undolevels=1')
478      command('set undolevels=2')
479      expected_combination({ 'undolevels', 8, 1, 8, 2, 'global', 'set' })
480
481      -- Note: v:option_old is the old global value for global-local options.
482      -- but the old local value for all other kinds of options.
483      command('noa set undolevels=8')
484      command('set undolevels=2')
485      expected_combination({ 'undolevels', 8, 8, 8, 2, 'global', 'set' })
486    end)
487
488    it('with number local (to buffer) option', function()
489      command('noa setglobal wrapmargin=8')
490      command('noa setlocal wrapmargin=1')
491      command('setglobal wrapmargin=2')
492      expected_combination({ 'wrapmargin', 8, '', 8, 2, 'global', 'setglobal' })
493
494      command('noa setglobal wrapmargin=8')
495      command('noa setlocal wrapmargin=1')
496      command('setlocal wrapmargin=2')
497      expected_combination({ 'wrapmargin', 1, 1, '', 2, 'local', 'setlocal' })
498
499      command('noa setglobal wrapmargin=8')
500      command('noa setlocal wrapmargin=1')
501      command('set wrapmargin=2')
502      expected_combination({ 'wrapmargin', 1, 1, 8, 2, 'global', 'set' })
503
504      command('noa set wrapmargin=8')
505      command('set wrapmargin=2')
506      expected_combination({ 'wrapmargin', 8, 8, 8, 2, 'global', 'set' })
507    end)
508
509    it('with number global-local (to window) option', function()
510      command('noa setglobal scrolloff=8')
511      command('noa setlocal scrolloff=1')
512      command('setglobal scrolloff=2')
513      expected_combination({ 'scrolloff', 8, '', 8, 2, 'global', 'setglobal' })
514
515      command('noa setglobal scrolloff=8')
516      command('noa setlocal scrolloff=1')
517      command('setlocal scrolloff=2')
518      expected_combination({ 'scrolloff', 1, 1, '', 2, 'local', 'setlocal' })
519
520      -- Note: v:option_old is the old global value for global-local options.
521      -- but the old local value for all other kinds of options.
522      command('noa setglobal scrolloff=8')
523      command('noa setlocal scrolloff=1')
524      command('set scrolloff=2')
525      expected_combination({ 'scrolloff', 8, 1, 8, 2, 'global', 'set' })
526
527      -- Note: v:option_old is the old global value for global-local options.
528      -- but the old local value for all other kinds of options.
529      command('noa set scrolloff=8')
530      command('set scrolloff=2')
531      expected_combination({ 'scrolloff', 8, 8, 8, 2, 'global', 'set' })
532    end)
533
534    it('with number local (to window) option', function()
535      command('noa setglobal foldcolumn=8')
536      command('noa setlocal foldcolumn=1')
537      command('setglobal foldcolumn=2')
538      expected_combination({ 'foldcolumn', '8', '', '8', '2', 'global', 'setglobal' })
539
540      command('noa setglobal foldcolumn=8')
541      command('noa setlocal foldcolumn=1')
542      command('setlocal foldcolumn=2')
543      expected_combination({ 'foldcolumn', '1', '1', '', '2', 'local', 'setlocal' })
544
545      command('noa setglobal foldcolumn=8')
546      command('noa setlocal foldcolumn=1')
547      command('set foldcolumn=2')
548      expected_combination({ 'foldcolumn', '1', '1', '8', '2', 'global', 'set' })
549
550      command('noa set foldcolumn=8')
551      command('set foldcolumn=2')
552      expected_combination({ 'foldcolumn', '8', '8', '8', '2', 'global', 'set' })
553    end)
554
555    it('with boolean global option', function()
556      command('noa setglobal nowrapscan')
557      command('noa setlocal wrapscan') -- Sets the global(!) value
558      command('setglobal nowrapscan')
559      expected_combination({ 'wrapscan', true, '', true, false, 'global', 'setglobal' })
560
561      command('noa setglobal nowrapscan')
562      command('noa setlocal wrapscan') -- Sets the global(!) value
563      command('setlocal nowrapscan')
564      expected_combination({ 'wrapscan', true, true, '', false, 'local', 'setlocal' })
565
566      command('noa setglobal nowrapscan')
567      command('noa setlocal wrapscan') -- Sets the global(!) value
568      command('set nowrapscan')
569      expected_combination({ 'wrapscan', true, true, true, false, 'global', 'set' })
570
571      command('noa set nowrapscan')
572      command('set wrapscan')
573      expected_combination({ 'wrapscan', false, false, false, true, 'global', 'set' })
574    end)
575
576    it('with boolean global-local (to buffer) option', function()
577      command('noa setglobal noautoread')
578      command('noa setlocal autoread')
579      command('setglobal autoread')
580      expected_combination({ 'autoread', false, '', false, true, 'global', 'setglobal' })
581
582      command('noa setglobal noautoread')
583      command('noa setlocal autoread')
584      command('setlocal noautoread')
585      expected_combination({ 'autoread', true, true, '', false, 'local', 'setlocal' })
586
587      -- Note: v:option_old is the old global value for global-local options.
588      -- but the old local value for all other kinds of options.
589      command('noa setglobal noautoread')
590      command('noa setlocal autoread')
591      command('set autoread')
592      expected_combination({ 'autoread', false, true, false, true, 'global', 'set' })
593
594      -- Note: v:option_old is the old global value for global-local options.
595      -- but the old local value for all other kinds of options.
596      command('noa set noautoread')
597      command('set autoread')
598      expected_combination({ 'autoread', false, false, false, true, 'global', 'set' })
599    end)
600
601    it('with boolean local (to buffer) option', function()
602      command('noa setglobal nocindent')
603      command('noa setlocal cindent')
604      command('setglobal cindent')
605      expected_combination({ 'cindent', false, '', false, true, 'global', 'setglobal' })
606
607      command('noa setglobal nocindent')
608      command('noa setlocal cindent')
609      command('setlocal nocindent')
610      expected_combination({ 'cindent', true, true, '', false, 'local', 'setlocal' })
611
612      command('noa setglobal nocindent')
613      command('noa setlocal cindent')
614      command('set cindent')
615      expected_combination({ 'cindent', true, true, false, true, 'global', 'set' })
616
617      command('noa set nocindent')
618      command('set cindent')
619      expected_combination({ 'cindent', false, false, false, true, 'global', 'set' })
620    end)
621
622    it('with boolean local (to window) option', function()
623      command('noa setglobal nocursorcolumn')
624      command('noa setlocal cursorcolumn')
625      command('setglobal cursorcolumn')
626      expected_combination({ 'cursorcolumn', false, '', false, true, 'global', 'setglobal' })
627
628      command('noa setglobal nocursorcolumn')
629      command('noa setlocal cursorcolumn')
630      command('setlocal nocursorcolumn')
631      expected_combination({ 'cursorcolumn', true, true, '', false, 'local', 'setlocal' })
632
633      command('noa setglobal nocursorcolumn')
634      command('noa setlocal cursorcolumn')
635      command('set cursorcolumn')
636      expected_combination({ 'cursorcolumn', true, true, false, true, 'global', 'set' })
637
638      command('noa set nocursorcolumn')
639      command('set cursorcolumn')
640      expected_combination({ 'cursorcolumn', false, false, false, true, 'global', 'set' })
641    end)
642  end)
643
644  describe('with specific option', function()
645    before_each(function()
646      clear()
647      declare_hook_function()
648      init_var()
649    end)
650
651    it('should be called iff setting readonly', function()
652      set_hook('readonly')
653
654      command('set nu')
655      expected_empty()
656
657      command('setlocal ro')
658      expected_combination({ 'readonly', false, false, '', true, 'local', 'setlocal' })
659
660      command('setglobal ro')
661      expected_combination({ 'readonly', false, '', false, true, 'global', 'setglobal' })
662
663      command('set noro')
664      expected_combination({ 'readonly', true, true, true, false, 'global', 'set' })
665    end)
666
667    describe('being set by setbufvar()', function()
668      it('should not trigger because option name does not match with backup', function()
669        set_hook('backup')
670
671        command('silent! call setbufvar(1, "&l:bk", 1)')
672        expected_empty()
673      end)
674
675      it('should trigger, use correct option name backup', function()
676        set_hook('backup')
677
678        command('call setbufvar(1, "&backup", 1)')
679        expected_combination({ 'backup', false, false, '', true, 'local', 'setlocal' })
680      end)
681
682      it('should trigger if the current buffer is different from the targeted buffer', function()
683        set_hook('buftype')
684
685        local new_buffer = make_buffer()
686        local new_bufnr = api.nvim_buf_get_number(new_buffer)
687
688        command('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")')
689        expected_combination({
690          'buftype',
691          '',
692          '',
693          '',
694          'nofile',
695          'local',
696          'setlocal',
697          { bufnr = new_bufnr },
698        })
699      end)
700    end)
701
702    describe('being set by setwinvar()', function()
703      it('should not trigger because option name does not match with backup', function()
704        set_hook('backup')
705
706        command('silent! call setwinvar(1, "&l:bk", 1)')
707        expected_empty()
708      end)
709
710      it('should trigger, use correct option name backup', function()
711        set_hook('backup')
712
713        command('call setwinvar(1, "&backup", 1)')
714        expected_combination({ 'backup', false, false, '', true, 'local', 'setlocal' })
715      end)
716
717      it(
718        'should not trigger if the current window is different from the targeted window',
719        function()
720          set_hook('cursorcolumn')
721
722          local new_winnr = get_new_window_number()
723
724          command('call setwinvar(' .. new_winnr .. ', "&cursorcolumn", 1)')
725          -- expected_combination({'cursorcolumn', false, true, 'local', {winnr = new_winnr}})
726          expected_empty()
727        end
728      )
729    end)
730
731    describe('being set by neovim api', function()
732      it('should trigger if a boolean option be set globally', function()
733        set_hook('autochdir')
734
735        api.nvim_set_option_value('autochdir', true, { scope = 'global' })
736        eq(true, api.nvim_get_option_value('autochdir', { scope = 'global' }))
737        expected_combination({ 'autochdir', false, '', false, true, 'global', 'setglobal' })
738      end)
739
740      it('should trigger if a number option be set globally', function()
741        set_hook('cmdheight')
742
743        api.nvim_set_option_value('cmdheight', 5, { scope = 'global' })
744        eq(5, api.nvim_get_option_value('cmdheight', { scope = 'global' }))
745        expected_combination({ 'cmdheight', 1, '', 1, 5, 'global', 'setglobal' })
746      end)
747
748      it('should trigger if a string option be set globally', function()
749        set_hook('ambiwidth')
750
751        api.nvim_set_option_value('ambiwidth', 'double', { scope = 'global' })
752        eq('double', api.nvim_get_option_value('ambiwidth', { scope = 'global' }))
753        expected_combination({
754          'ambiwidth',
755          'single',
756          '',
757          'single',
758          'double',
759          'global',
760          'setglobal',
761        })
762      end)
763    end)
764  end)
765end)