From 64a14026d76ba1798d91e15a941fcb6af7cbc5ad Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Wed, 29 Nov 2023 22:16:09 +0200 Subject: feat(highlight): update default color scheme 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. --- test/functional/ui/cursor_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 05057ca080..7bec5eaac6 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -215,7 +215,7 @@ describe('ui/cursor', function() m.hl_id = 64 m.attr = {background = Screen.colors.DarkGray} end - if m.id_lm then m.id_lm = 67 end + if m.id_lm then m.id_lm = 69 end end -- Assert the new expectation. -- cgit From 1037ce2e461034a20e35ad59969fd05d5ad68b91 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 9 Dec 2023 20:42:00 +0800 Subject: test: avoid repeated screen lines in expected states This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g --- test/functional/ui/cursor_spec.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 7bec5eaac6..2b8dc0fe19 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -186,9 +186,7 @@ describe('ui/cursor', function() command("echo 'test'") screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | + ~ |*3 test | ]], condition=function() eq(nil, screen._mode_info) @@ -255,9 +253,7 @@ describe('ui/cursor', function() end screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | + ~ |*3 test | ]], condition=function() eq(expected_mode_info, screen._mode_info) -- cgit From 574519d9d68f7f28a868e95ef0d081cbae6ddec4 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 12 Dec 2023 18:07:45 +0200 Subject: feat(highlight): tweak default color scheme Problem: Updating default color scheme produced some feedback. Solution: Address the feedback. Outline of the changes: - Colors `Grey1` and `Grey2` are made a little bit more extreme (dark - darker, light - lighter) to increase overall contrast. - `gui` colors are treated as base with `cterm` colors falling back to using 0-15 colors which come from terminal emulator. - Update highlight group definition to not include attribute definition if it is intended to staty uncolored. - Tweak some specific highlight groups. - Add a list of Neovim specific highlight groups which are now defined differently in a breaking way. - Minor tweaks in several other places related to default color scheme. --- test/functional/ui/cursor_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 2b8dc0fe19..7f4d167c41 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -213,7 +213,7 @@ describe('ui/cursor', function() m.hl_id = 64 m.attr = {background = Screen.colors.DarkGray} end - if m.id_lm then m.id_lm = 69 end + if m.id_lm then m.id_lm = 70 end end -- Assert the new expectation. -- cgit From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/ui/cursor_spec.lua | 137 ++++++++++++++++++++++++------------- 1 file changed, 91 insertions(+), 46 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 7f4d167c41..9b3de1e108 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -27,7 +27,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'n' }, + short_name = 'n', + }, [2] = { blinkoff = 0, blinkon = 0, @@ -40,7 +41,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'v' }, + short_name = 'v', + }, [3] = { blinkoff = 0, blinkon = 0, @@ -53,7 +55,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'i' }, + short_name = 'i', + }, [4] = { blinkoff = 0, blinkon = 0, @@ -66,7 +69,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'r' }, + short_name = 'r', + }, [5] = { blinkoff = 0, blinkon = 0, @@ -79,7 +83,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'c' }, + short_name = 'c', + }, [6] = { blinkoff = 0, blinkon = 0, @@ -92,7 +97,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'ci' }, + short_name = 'ci', + }, [7] = { blinkoff = 0, blinkon = 0, @@ -105,7 +111,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'cr' }, + short_name = 'cr', + }, [8] = { blinkoff = 0, blinkon = 0, @@ -118,7 +125,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'o' }, + short_name = 'o', + }, [9] = { blinkoff = 0, blinkon = 0, @@ -131,35 +139,43 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 've' }, + short_name = 've', + }, [10] = { name = 'cmdline_hover', mouse_shape = 0, - short_name = 'e' }, + short_name = 'e', + }, [11] = { name = 'statusline_hover', mouse_shape = 0, - short_name = 's' }, + short_name = 's', + }, [12] = { name = 'statusline_drag', mouse_shape = 0, - short_name = 'sd' }, + short_name = 'sd', + }, [13] = { name = 'vsep_hover', mouse_shape = 0, - short_name = 'vs' }, + short_name = 'vs', + }, [14] = { name = 'vsep_drag', mouse_shape = 0, - short_name = 'vd' }, + short_name = 'vd', + }, [15] = { name = 'more', mouse_shape = 0, - short_name = 'm' }, + short_name = 'm', + }, [16] = { name = 'more_lastline', mouse_shape = 0, - short_name = 'ml' }, + short_name = 'ml', + }, [17] = { blinkoff = 0, blinkon = 0, @@ -171,8 +187,9 @@ describe('ui/cursor', function() id_lm = 0, attr = {}, attr_lm = {}, - short_name = 'sm' }, - } + short_name = 'sm', + }, + } screen:expect(function() -- Default 'guicursor', published on startup. @@ -184,36 +201,55 @@ describe('ui/cursor', function() -- Event is published ONLY if the cursor style changed. screen._mode_info = nil command("echo 'test'") - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | ~ |*3 test | - ]], condition=function() - eq(nil, screen._mode_info) - end} + ]], + condition = function() + eq(nil, screen._mode_info) + end, + } -- Change the cursor style. helpers.command('hi Cursor guibg=DarkGray') - helpers.command('set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr-o:hor20' - ..',a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor' - ..',sm:block-blinkwait175-blinkoff150-blinkon175') + helpers.command( + 'set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr-o:hor20' + .. ',a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor' + .. ',sm:block-blinkwait175-blinkoff150-blinkon175' + ) -- Update the expected values. for _, m in ipairs(expected_mode_info) do if m.name == 'showmatch' then - if m.blinkon then m.blinkon = 175 end - if m.blinkoff then m.blinkoff = 150 end - if m.blinkwait then m.blinkwait = 175 end + if m.blinkon then + m.blinkon = 175 + end + if m.blinkoff then + m.blinkoff = 150 + end + if m.blinkwait then + m.blinkwait = 175 + end else - if m.blinkon then m.blinkon = 250 end - if m.blinkoff then m.blinkoff = 400 end - if m.blinkwait then m.blinkwait = 700 end + if m.blinkon then + m.blinkon = 250 + end + if m.blinkoff then + m.blinkoff = 400 + end + if m.blinkwait then + m.blinkwait = 700 + end end if m.hl_id then - m.hl_id = 64 - m.attr = {background = Screen.colors.DarkGray} + m.hl_id = 64 + m.attr = { background = Screen.colors.DarkGray } + end + if m.id_lm then + m.id_lm = 70 end - if m.id_lm then m.id_lm = 70 end end -- Assert the new expectation. @@ -230,10 +266,10 @@ describe('ui/cursor', function() -- Update the expected values. for _, m in ipairs(expected_mode_info) do if m.hl_id then - m.attr = {background = Screen.colors.Red} + m.attr = { background = Screen.colors.Red } end if m.id_lm then - m.attr_lm = {background = Screen.colors.Green} + m.attr_lm = { background = Screen.colors.Green } end end -- Assert the new expectation. @@ -248,21 +284,27 @@ describe('ui/cursor', function() for _, m in ipairs(expected_mode_info) do if m.hl_id then - m.attr = {background = Screen.colors.Red, blend = 100} + m.attr = { background = Screen.colors.Red, blend = 100 } end end - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | ~ |*3 test | - ]], condition=function() - eq(expected_mode_info, screen._mode_info) - end + ]], + condition = function() + eq(expected_mode_info, screen._mode_info) + end, } -- Another cursor style. - meths.set_option_value('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' - ..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', {}) + meths.set_option_value( + 'guicursor', + 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' + .. ',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', + {} + ) screen:expect(function() local named = {} for _, m in ipairs(screen._mode_info) do @@ -284,9 +326,13 @@ describe('ui/cursor', function() end) -- If there is no setting for guicursor, it becomes the default setting. - meths.set_option_value('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', {}) + meths.set_option_value( + 'guicursor', + 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', + {} + ) screen:expect(function() - for _,m in ipairs(screen._mode_info) do + for _, m in ipairs(screen._mode_info) do if m.name ~= 'normal' then eq('block', m.cursor_shape or 'block') eq(0, m.blinkon or 0) @@ -314,5 +360,4 @@ describe('ui/cursor', function() end end) end) - end) -- cgit From c30f2e3182e3b50e7c03932027ac55edfc8ada4a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 12:44:54 +0000 Subject: test: typing for helpers.meths --- test/functional/ui/cursor_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 9b3de1e108..601d242de0 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -299,7 +299,7 @@ describe('ui/cursor', function() } -- Another cursor style. - meths.set_option_value( + meths.nvim_set_option_value( 'guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' .. ',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', @@ -326,7 +326,7 @@ describe('ui/cursor', function() end) -- If there is no setting for guicursor, it becomes the default setting. - meths.set_option_value( + meths.nvim_set_option_value( 'guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', {} @@ -346,7 +346,7 @@ describe('ui/cursor', function() end) it("empty 'guicursor' sets cursor_shape=block in all modes", function() - meths.set_option_value('guicursor', '', {}) + meths.nvim_set_option_value('guicursor', '', {}) screen:expect(function() -- Empty 'guicursor' sets enabled=false. eq(false, screen._cursor_style_enabled) -- cgit From 795f896a5772d5e0795f86642bdf90c82efac45c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 17:59:57 +0000 Subject: test: rename (meths, funcs) -> (api, fn) --- test/functional/ui/cursor_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 601d242de0..8d58c11302 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, meths = helpers.clear, helpers.meths +local clear, api = helpers.clear, helpers.api local eq = helpers.eq local command = helpers.command @@ -299,7 +299,7 @@ describe('ui/cursor', function() } -- Another cursor style. - meths.nvim_set_option_value( + api.nvim_set_option_value( 'guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' .. ',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', @@ -326,7 +326,7 @@ describe('ui/cursor', function() end) -- If there is no setting for guicursor, it becomes the default setting. - meths.nvim_set_option_value( + api.nvim_set_option_value( 'guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', {} @@ -346,7 +346,7 @@ describe('ui/cursor', function() end) it("empty 'guicursor' sets cursor_shape=block in all modes", function() - meths.nvim_set_option_value('guicursor', '', {}) + api.nvim_set_option_value('guicursor', '', {}) screen:expect(function() -- Empty 'guicursor' sets enabled=false. eq(false, screen._cursor_style_enabled) -- cgit From d4bd6b1eaab3729d70304d0e163df4eb141099b3 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Thu, 25 Jan 2024 11:33:15 +0200 Subject: fix(colorscheme): use explicit normal foreground in syntax groups Problem: Some core syntax highlight groups are cleared with intention to always be shown without additional highlighting. This doesn't always work as intended, especially with fallback mechanism of @-groups. Example: `Statement`/`Keyword` group shown in help code blocks (`@markup.raw`) is shown as bold (from `Statement`) cyan (from `@markup.raw`) instead of bold grey. Solution: Explicitly use normal grey foreground in syntax groups where it was previously implicitly assumed. --- test/functional/ui/cursor_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 8d58c11302..871e9a0790 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -248,7 +248,7 @@ describe('ui/cursor', function() m.attr = { background = Screen.colors.DarkGray } end if m.id_lm then - m.id_lm = 70 + m.id_lm = 69 end end -- cgit