robin/laufey

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

robinmerge: 1dc9728daa1d8a2702

master
2.4 KiB105 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 command = n.command
6local api = n.api
7local fn = n.fn
8local eval = n.eval
9local feed = n.feed
10local clear = n.clear
11local eq = t.eq
12local neq = t.neq
13
14describe('optwin.lua', function()
15  before_each(clear)
16
17  it(':options shows options UI', function()
18    command 'options'
19
20    command '/^ 1'
21    local lnum = fn.line('.')
22    feed('<CR>')
23    neq(lnum, fn.line('.'))
24
25    n.add_builddir_to_rtp()
26    command '/^startofline'
27    local win = api.nvim_get_current_win()
28    feed('<CR>')
29    neq(win, api.nvim_get_current_win())
30    eq('help', eval('&filetype'))
31    api.nvim_win_close(0, true)
32    eq(win, api.nvim_get_current_win())
33
34    command '/^ \t'
35    local opt_value = eval('&startofline')
36    local line = api.nvim_get_current_line()
37    feed('<CR>')
38    neq(opt_value, eval('&startofline'))
39    neq(line, api.nvim_get_current_line())
40
41    command('set startofline!')
42    neq(line, api.nvim_get_current_line())
43    feed('<space>')
44    eq(line, api.nvim_get_current_line())
45
46    command 'wincmd j'
47    command 'wincmd k'
48    command '/^number'
49    command '/^ \t'
50    line = api.nvim_get_current_line()
51    feed('<CR>')
52    neq(line, api.nvim_get_current_line())
53    command 'wincmd o'
54    feed('<CR>')
55    eq(line, api.nvim_get_current_line())
56    feed('<CR>')
57    neq(line, api.nvim_get_current_line())
58  end)
59
60  it(':options shows all options', function()
61    local ignore = {
62      -- These options are removed/unused/deprecated
63      'compatible',
64      'paste',
65      'highlight',
66      'terse',
67      'aleph',
68      'encoding',
69      'termencoding',
70      'maxcombine',
71      'secure',
72      'prompt',
73      'edcompatible',
74      'gdefault',
75      'guioptions',
76      'guitablabel',
77      'guitabtooltip',
78      'insertmode',
79      'magic',
80      'mouseshape',
81      'imcmdline',
82      'imdisable',
83      'pastetoggle',
84      'langnoremap',
85      'opendevice',
86      'remap',
87      'hkmap',
88      'hkmapp',
89
90      -- These options are read-only
91      'channel',
92    }
93
94    command 'options'
95
96    local options = ignore
97    for _, line in ipairs(api.nvim_buf_get_lines(0, 0, -1, true)) do
98      if line:match('^[a-z]') then
99        table.insert(options, line:match('^[a-z]+'))
100      end
101    end
102
103    eq(fn.sort(vim.tbl_keys(api.nvim_get_all_options_info())), fn.sort(options))
104  end)
105end)