summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/plugin/optwin_spec.lua
blob: 2e9a990fee600bf5f671cb47ad5834318fc49e35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
local t = require('test.testutil')
local n = require('test.functional.testnvim')()

local command = n.command
local api = n.api
local fn = n.fn
local eval = n.eval
local feed = n.feed
local clear = n.clear
local eq = t.eq
local neq = t.neq

describe('optwin.lua', function()
  before_each(clear)

  it(':options shows options UI', function()
    command 'options'

    command '/^ 1'
    local lnum = fn.line('.')
    feed('<CR>')
    neq(lnum, fn.line('.'))

    n.add_builddir_to_rtp()
    command '/^startofline'
    local win = api.nvim_get_current_win()
    feed('<CR>')
    neq(win, api.nvim_get_current_win())
    eq('help', eval('&filetype'))
    api.nvim_win_close(0, true)
    eq(win, api.nvim_get_current_win())

    command '/^ \t'
    local opt_value = eval('&startofline')
    local line = api.nvim_get_current_line()
    feed('<CR>')
    neq(opt_value, eval('&startofline'))
    neq(line, api.nvim_get_current_line())

    command('set startofline!')
    neq(line, api.nvim_get_current_line())
    feed('<space>')
    eq(line, api.nvim_get_current_line())

    command 'wincmd j'
    command 'wincmd k'
    command '/^number'
    command '/^ \t'
    line = api.nvim_get_current_line()
    feed('<CR>')
    neq(line, api.nvim_get_current_line())
    command 'wincmd o'
    feed('<CR>')
    neq(line, api.nvim_get_current_line())
  end)

  it(':options shows all options', function()
    local ignore = {
      -- These options are removed/unused/deprecated
      'compatible',
      'paste',
      'highlight',
      'terse',
      'aleph',
      'encoding',
      'termencoding',
      'maxcombine',
      'secure',
      'prompt',
      'edcompatible',
      'gdefault',
      'guioptions',
      'guitablabel',
      'guitabtooltip',
      'insertmode',
      'magic',
      'mouseshape',
      'imcmdline',
      'imdisable',
      'pastetoggle',
      'langnoremap',
      'opendevice',
      'remap',
      'hkmap',
      'hkmapp',

      -- These options are read-only
      'channel',
    }

    command 'options'

    local options = ignore
    for _, line in ipairs(api.nvim_buf_get_lines(0, 0, -1, true)) do
      if line:match('^[a-z]') then
        table.insert(options, line:match('^[a-z]+'))
      end
    end

    eq(fn.sort(vim.tbl_keys(api.nvim_get_all_options_info())), fn.sort(options))
  end)
end)