mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00

Problem: Default color scheme is suboptimal. Solution: Start using new color scheme. Introduce new `vim` color scheme for opt-in backward compatibility. ------ Main design ideas - Be "Neovim branded". - Be minimal for 256 colors with a bit more shades for true colors. - Be accessible through high enough contrast ratios. - Be suitable for dark and light backgrounds via exchange of dark and light palettes. ------ Palettes - Have dark and light variants. Implemented through exporeted `NvimDark*` and `NvimLight*` hex colors. - Palettes have 4 shades of grey for UI elements and 6 colors (red, yellow, green, cyan, blue, magenta). - Actual values are computed procedurally in Oklch color space based on a handful of hyperparameters. - Each color has a 256 colors variant with perceptually closest color. ------ Highlight groups Use: - Grey shades for general UI according to their design. - Bold text for keywords (`Statement` highlight group). This is an important choice to increase accessibility for people with color deficiencies, as it doesn't rely on actual color. - Green for strings, `DiffAdd` (as background), `DiagnosticOk`, and some minor text UI elements. - Cyan as main syntax color, i.e. for function usage (`Function` highlight group), `DiffText`, `DiagnosticInfo`, and some minor text UI elements. - Red to generally mean high user attention, i.e. errors; in particular for `ErrorMsg`, `DiffDelete`, `DiagnosticError`. - Yellow very sparingly only with true colors to mean mild user attention, i.e. warnings. That is, `DiagnosticWarn` and `WarningMsg`. - Blue very sparingly only with true colors as `DiagnosticHint` and some additional important syntax group (like `Identifier`). - Magenta very carefully (if at all). ------ Notes - To make tests work without relatively larege updates, each one is prepended with an equivalent of the call `:colorscheme vim`. Plus some tests which spawn new Neovim instances also now use 'vim' color scheme. In some cases tests are updated to fit new default color scheme.
144 lines
5.5 KiB
Lua
144 lines
5.5 KiB
Lua
local luv = require('luv')
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local eq = helpers.eq
|
|
local matches = helpers.matches
|
|
local feed = helpers.feed
|
|
local eval = helpers.eval
|
|
local clear = helpers.clear
|
|
local funcs = helpers.funcs
|
|
local nvim_prog_abs = helpers.nvim_prog_abs
|
|
local write_file = helpers.write_file
|
|
local is_os = helpers.is_os
|
|
local skip = helpers.skip
|
|
|
|
describe('command-line option', function()
|
|
describe('-s', function()
|
|
local fname = 'Xtest-functional-core-main-s'
|
|
local fname_2 = fname .. '.2'
|
|
local nonexistent_fname = fname .. '.nonexistent'
|
|
local dollar_fname = '$' .. fname
|
|
|
|
before_each(function()
|
|
clear()
|
|
os.remove(fname)
|
|
os.remove(dollar_fname)
|
|
end)
|
|
|
|
after_each(function()
|
|
os.remove(fname)
|
|
os.remove(dollar_fname)
|
|
end)
|
|
|
|
it('treats - as stdin', function()
|
|
eq(nil, luv.fs_stat(fname))
|
|
funcs.system(
|
|
{nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless',
|
|
'--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
|
|
'-s', '-', fname},
|
|
{':call setline(1, "42")', ':wqall!', ''})
|
|
eq(0, eval('v:shell_error'))
|
|
local attrs = luv.fs_stat(fname)
|
|
eq(#('42\n'), attrs.size)
|
|
end)
|
|
|
|
it('does not expand $VAR', function()
|
|
eq(nil, luv.fs_stat(fname))
|
|
eq(true, not not dollar_fname:find('%$%w+'))
|
|
write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n')
|
|
funcs.system(
|
|
{nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless',
|
|
'--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
|
|
'-s', dollar_fname, fname})
|
|
eq(0, eval('v:shell_error'))
|
|
local attrs = luv.fs_stat(fname)
|
|
eq(#('100500\n'), attrs.size)
|
|
end)
|
|
|
|
it('does not crash after reading from stdin in non-headless mode', function()
|
|
skip(is_os('win'))
|
|
local screen = Screen.new(40, 8)
|
|
screen:attach()
|
|
local args = {
|
|
nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE',
|
|
'--cmd', '"set noswapfile shortmess+=IFW fileformats=unix"',
|
|
'-s', '-'
|
|
}
|
|
|
|
-- Need to explicitly pipe to stdin so that the embedded Nvim instance doesn't try to read
|
|
-- data from the terminal #18181
|
|
funcs.termopen(string.format([[echo "" | %s]], table.concat(args, " ")))
|
|
screen:expect([[
|
|
{1:^ }|
|
|
{2:~ }|
|
|
{2:~ }|
|
|
{2:~ }|
|
|
{2:~ }|
|
|
{3:[No Name] 0,0-1 All}|
|
|
{1: }|
|
|
|
|
|
]], {
|
|
[1] = {bg_indexed = true, foreground = Screen.colors.Grey91, background = tonumber('0x161616'), fg_indexed = true},
|
|
[2] = {bg_indexed = true, foreground = Screen.colors.Gray30, background = tonumber('0x161616'), fg_indexed = true},
|
|
[3] = {bg_indexed = true, foreground = tonumber('0xd2d2d2'), background = Screen.colors.Black , fg_indexed = true},
|
|
})
|
|
feed('i:cq<CR>')
|
|
screen:expect([[
|
|
|
|
|
[Process exited 1] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- TERMINAL -- |
|
|
]])
|
|
--[=[ Example of incorrect output:
|
|
screen:expect([[
|
|
^nvim: /var/tmp/portage/dev-libs/libuv-1.|
|
|
10.2/work/libuv-1.10.2/src/unix/core.c:5|
|
|
19: uv__close: Assertion `fd > STDERR_FI|
|
|
LENO' failed. |
|
|
|
|
|
[Process exited 6] |
|
|
|
|
|
|
|
|
]])
|
|
]=]
|
|
end)
|
|
|
|
it('errors out when trying to use nonexistent file with -s', function()
|
|
eq(
|
|
'Cannot open for reading: "'..nonexistent_fname..'": no such file or directory\n',
|
|
funcs.system(
|
|
{nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless',
|
|
'--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
|
|
'--cmd', 'language C',
|
|
'-s', nonexistent_fname}))
|
|
eq(2, eval('v:shell_error'))
|
|
end)
|
|
|
|
it('errors out when trying to use -s twice', function()
|
|
write_file(fname, ':call setline(1, "1")\n:wqall!\n')
|
|
write_file(dollar_fname, ':call setline(1, "2")\n:wqall!\n')
|
|
eq(
|
|
'Attempt to open script file again: "-s '..dollar_fname..'"\n',
|
|
funcs.system(
|
|
{nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless',
|
|
'--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
|
|
'--cmd', 'language C',
|
|
'-s', fname, '-s', dollar_fname, fname_2}))
|
|
eq(2, eval('v:shell_error'))
|
|
eq(nil, luv.fs_stat(fname_2))
|
|
end)
|
|
end)
|
|
|
|
it('nvim -v, :version', function()
|
|
matches('Run ":verbose version"', funcs.execute(':version'))
|
|
matches('Compilation: .*Run :checkhealth', funcs.execute(':verbose version'))
|
|
matches('Run "nvim %-V1 %-v"', funcs.system({nvim_prog_abs(), '-v'}))
|
|
matches('Compilation: .*Run :checkhealth', funcs.system({nvim_prog_abs(), '-V1', '-v'}))
|
|
end)
|
|
end)
|