Files
neovim/test/functional/ui/quickfix_spec.lua
Justin M. Keyes 6d8c8b18d5 test(harness): migrate away from magic globals
Problem:
The magic globals `it`, `describe`, etc., are more trouble than they are
worth.

- Hooking into `after_each` requires `getfenv()` hacks.
- They confuse luals/emmylua, because the top-level `.luarc.json` isn't
  merged with `test/.luarc.json` (apparently a luals limitation?)
- They totally defeat discoverability because the user just has to
  "know" about the various magic symbols.

So they harm DX, which means they serve no purpose at all.

Solution:
- Expose the test API from `testutil`, so tests can call `t.it()`,
  `t.describe()`, etc., in the conventional way.
- Drop `getfenv()` hacks.
- Drop the `setfenv()` injection in `load_chunk`.
- Drop `test/_meta.lua`.
2026-07-21 13:22:39 +02:00

210 lines
6.7 KiB
Lua

local n = require('test.functional.testnvim')()
local t = require('test.testutil')
local Screen = require('test.functional.ui.screen')
local describe, it, before_each = t.describe, t.it, t.before_each
local clear, feed, api = n.clear, n.feed, n.api
local insert, command = n.insert, n.command
describe('quickfix', function()
local screen
before_each(function()
clear()
screen = Screen.new(25, 10)
screen:add_extra_attr_ids({
[100] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.WebGreen },
[101] = { foreground = Screen.colors.Brown, background = Screen.colors.WebGreen },
[102] = { background = Screen.colors.WebGreen },
[103] = { background = Screen.colors.Red, foreground = Screen.colors.SlateBlue },
[104] = { background = Screen.colors.Red, foreground = Screen.colors.Brown },
[105] = { background = Screen.colors.Fuchsia },
[106] = { foreground = Screen.colors.Red, background = Screen.colors.Fuchsia },
[107] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Fuchsia },
[108] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia },
})
api.nvim_set_option_value('errorformat', '%m %l', {})
command('syntax on')
command('highlight Search guibg=Green')
insert([[
Line 1
Line 2
Line 3
Line 4
Line 5
]])
command('cad')
feed('gg')
screen:expect([[
^Line 1 |
Line 2 |
Line 3 |
Line 4 |
Line 5 |
|
{1:~ }|*3
|
]])
end)
it('Search selection highlight', function()
command('copen')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{100:^|}{101:1}{100:|}{102: Line }|
{16:|}{8:2}{16:|} Line |
{16:|}{8:3}{16:|} Line |
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
command('cnext')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{16:|}{8:1}{16:|} Line |
{100:^|}{101:2}{100:|}{102: Line }|
{16:|}{8:3}{16:|} Line |
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
end)
it('QuickFixLine selection highlight', function()
command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
command('copen')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{103:^|}{104:1}{103:|}{30: Line }|
{16:|}{8:2}{16:|} Line |
{16:|}{8:3}{16:|} Line |
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
command('cnext')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{16:|}{8:1}{16:|} Line |
{103:^|}{104:2}{103:|}{30: Line }|
{16:|}{8:3}{16:|} Line |
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
end)
it('selection highlight combines with CursorLine', function()
command('set cursorline')
command('highlight QuickFixLine guifg=Red guibg=NONE gui=NONE')
command('highlight CursorLine guibg=Fuchsia')
command('copen')
screen:expect([[
{105:Line 1 }|
{2:[No Name] [+] }|
{106:^|1| Line }|
{16:|}{8:2}{16:|} Line |
{16:|}{8:3}{16:|} Line |
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
feed('j')
screen:expect([[
{105:Line 1 }|
{2:[No Name] [+] }|
{19:|1| Line }|
{107:^|}{108:2}{107:|}{105: Line }|
{16:|}{8:3}{16:|} Line |
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
end)
it('QuickFixLine selection highlight background takes precedence over CursorLine', function()
command('set cursorline')
command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
command('highlight CursorLine guibg=Fuchsia')
command('copen')
screen:expect([[
{105:Line 1 }|
{2:[No Name] [+] }|
{103:^|}{104:1}{103:|}{30: Line }|
{16:|}{8:2}{16:|} Line |
{16:|}{8:3}{16:|} Line |
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
feed('j')
screen:expect([[
{105:Line 1 }|
{2:[No Name] [+] }|
{103:|}{104:1}{103:|}{30: Line }|
{107:^|}{108:2}{107:|}{105: Line }|
{16:|}{8:3}{16:|} Line |
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
end)
it('does not inherit from non-current floating window', function()
api.nvim_open_win(0, true, { width = 6, height = 2, relative = 'win', bufpos = { 3, 0 } })
api.nvim_set_option_value('rightleft', true, { win = 0 })
command('wincmd w | copen')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{100:^|}{101:1}{100:|}{102: Line }|
{16:|}{8:2}{16:|} Line {4:1 eniL}|
{16:|}{8:3}{16:|} Line {4:2 eniL}|
{16:|}{8:4}{16:|} Line |
{16:|}{8:5}{16:|} Line |
{16:||} |
{3:[Quickfix List] [-] }|
|
]])
end)
end)