neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

optwin_spec.lua (2350B)


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