neovim

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

quickfix_spec.lua (6810B)


      1 local n = require('test.functional.testnvim')()
      2 local Screen = require('test.functional.ui.screen')
      3 
      4 local clear, feed, api = n.clear, n.feed, n.api
      5 local insert, command = n.insert, n.command
      6 
      7 describe('quickfix', function()
      8  local screen
      9 
     10  before_each(function()
     11    clear()
     12    screen = Screen.new(25, 10)
     13    screen:add_extra_attr_ids({
     14      [100] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.WebGreen },
     15      [101] = { foreground = Screen.colors.Brown, background = Screen.colors.WebGreen },
     16      [102] = { background = Screen.colors.WebGreen },
     17      [103] = { background = Screen.colors.Red, foreground = Screen.colors.SlateBlue },
     18      [104] = { background = Screen.colors.Red, foreground = Screen.colors.Brown },
     19      [105] = { background = Screen.colors.Fuchsia },
     20      [106] = { foreground = Screen.colors.Red, background = Screen.colors.Fuchsia },
     21      [107] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Fuchsia },
     22      [108] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia },
     23    })
     24 
     25    api.nvim_set_option_value('errorformat', '%m %l', {})
     26    command('syntax on')
     27    command('highlight Search guibg=Green')
     28 
     29    insert([[
     30    Line 1
     31    Line 2
     32    Line 3
     33    Line 4
     34    Line 5
     35    ]])
     36 
     37    command('cad')
     38    feed('gg')
     39 
     40    screen:expect([[
     41      ^Line 1                   |
     42      Line 2                   |
     43      Line 3                   |
     44      Line 4                   |
     45      Line 5                   |
     46                               |
     47      {1:~                        }|*3
     48                               |
     49    ]])
     50  end)
     51 
     52  it('Search selection highlight', function()
     53    command('copen')
     54 
     55    screen:expect([[
     56      Line 1                   |
     57      {2:[No Name] [+]            }|
     58      {100:^|}{101:1}{100:|}{102: Line                 }|
     59      {16:|}{8:2}{16:|} Line                 |
     60      {16:|}{8:3}{16:|} Line                 |
     61      {16:|}{8:4}{16:|} Line                 |
     62      {16:|}{8:5}{16:|} Line                 |
     63      {16:||}                       |
     64      {3:[Quickfix List] [-]      }|
     65                               |
     66    ]])
     67 
     68    command('cnext')
     69 
     70    screen:expect([[
     71      Line 1                   |
     72      {2:[No Name] [+]            }|
     73      {16:|}{8:1}{16:|} Line                 |
     74      {100:^|}{101:2}{100:|}{102: Line                 }|
     75      {16:|}{8:3}{16:|} Line                 |
     76      {16:|}{8:4}{16:|} Line                 |
     77      {16:|}{8:5}{16:|} Line                 |
     78      {16:||}                       |
     79      {3:[Quickfix List] [-]      }|
     80                               |
     81    ]])
     82  end)
     83 
     84  it('QuickFixLine selection highlight', function()
     85    command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
     86 
     87    command('copen')
     88 
     89    screen:expect([[
     90      Line 1                   |
     91      {2:[No Name] [+]            }|
     92      {103:^|}{104:1}{103:|}{30: Line                 }|
     93      {16:|}{8:2}{16:|} Line                 |
     94      {16:|}{8:3}{16:|} Line                 |
     95      {16:|}{8:4}{16:|} Line                 |
     96      {16:|}{8:5}{16:|} Line                 |
     97      {16:||}                       |
     98      {3:[Quickfix List] [-]      }|
     99                               |
    100    ]])
    101 
    102    command('cnext')
    103 
    104    screen:expect([[
    105      Line 1                   |
    106      {2:[No Name] [+]            }|
    107      {16:|}{8:1}{16:|} Line                 |
    108      {103:^|}{104:2}{103:|}{30: Line                 }|
    109      {16:|}{8:3}{16:|} Line                 |
    110      {16:|}{8:4}{16:|} Line                 |
    111      {16:|}{8:5}{16:|} Line                 |
    112      {16:||}                       |
    113      {3:[Quickfix List] [-]      }|
    114                               |
    115    ]])
    116  end)
    117 
    118  it('selection highlight combines with CursorLine', function()
    119    command('set cursorline')
    120    command('highlight QuickFixLine guifg=Red guibg=NONE gui=NONE')
    121    command('highlight CursorLine guibg=Fuchsia')
    122 
    123    command('copen')
    124 
    125    screen:expect([[
    126      {105:Line 1                   }|
    127      {2:[No Name] [+]            }|
    128      {106:^|1| Line                 }|
    129      {16:|}{8:2}{16:|} Line                 |
    130      {16:|}{8:3}{16:|} Line                 |
    131      {16:|}{8:4}{16:|} Line                 |
    132      {16:|}{8:5}{16:|} Line                 |
    133      {16:||}                       |
    134      {3:[Quickfix List] [-]      }|
    135                               |
    136    ]])
    137 
    138    feed('j')
    139 
    140    screen:expect([[
    141      {105:Line 1                   }|
    142      {2:[No Name] [+]            }|
    143      {19:|1| Line                 }|
    144      {107:^|}{108:2}{107:|}{105: Line                 }|
    145      {16:|}{8:3}{16:|} Line                 |
    146      {16:|}{8:4}{16:|} Line                 |
    147      {16:|}{8:5}{16:|} Line                 |
    148      {16:||}                       |
    149      {3:[Quickfix List] [-]      }|
    150                               |
    151    ]])
    152  end)
    153 
    154  it('QuickFixLine selection highlight background takes precedence over CursorLine', function()
    155    command('set cursorline')
    156    command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
    157    command('highlight CursorLine guibg=Fuchsia')
    158 
    159    command('copen')
    160 
    161    screen:expect([[
    162      {105:Line 1                   }|
    163      {2:[No Name] [+]            }|
    164      {103:^|}{104:1}{103:|}{30: Line                 }|
    165      {16:|}{8:2}{16:|} Line                 |
    166      {16:|}{8:3}{16:|} Line                 |
    167      {16:|}{8:4}{16:|} Line                 |
    168      {16:|}{8:5}{16:|} Line                 |
    169      {16:||}                       |
    170      {3:[Quickfix List] [-]      }|
    171                               |
    172    ]])
    173 
    174    feed('j')
    175 
    176    screen:expect([[
    177      {105:Line 1                   }|
    178      {2:[No Name] [+]            }|
    179      {103:|}{104:1}{103:|}{30: Line                 }|
    180      {107:^|}{108:2}{107:|}{105: Line                 }|
    181      {16:|}{8:3}{16:|} Line                 |
    182      {16:|}{8:4}{16:|} Line                 |
    183      {16:|}{8:5}{16:|} Line                 |
    184      {16:||}                       |
    185      {3:[Quickfix List] [-]      }|
    186                               |
    187    ]])
    188  end)
    189 
    190  it('does not inherit from non-current floating window', function()
    191    api.nvim_open_win(0, true, { width = 6, height = 2, relative = 'win', bufpos = { 3, 0 } })
    192    api.nvim_set_option_value('rightleft', true, { win = 0 })
    193    command('wincmd w | copen')
    194    screen:expect([[
    195      Line 1                   |
    196      {2:[No Name] [+]            }|
    197      {100:^|}{101:1}{100:|}{102: Line                 }|
    198      {16:|}{8:2}{16:|} Line           {4:1 eniL}|
    199      {16:|}{8:3}{16:|} Line           {4:2 eniL}|
    200      {16:|}{8:4}{16:|} Line                 |
    201      {16:|}{8:5}{16:|} Line                 |
    202      {16:||}                       |
    203      {3:[Quickfix List] [-]      }|
    204                               |
    205    ]])
    206  end)
    207 end)