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/screen_basic_spec.lua | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 7cc1accd3f..4ef7565ec5 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -8,9 +8,15 @@ local funcs, meths = helpers.funcs, helpers.meths describe('screen', function() local screen - local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', - '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', - '--embed'} + local nvim_argv = { + helpers.nvim_prog, + '-u', 'NONE', + '-i', 'NONE', + '-N', + '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', + '--cmd', 'colorscheme vim', + '--embed', + } before_each(function() local screen_nvim = spawn(nvim_argv) @@ -997,9 +1003,15 @@ describe('Screen default colors', function() local function startup(light, termcolors) local extra = (light and ' background=light') or '' - local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', - '--cmd', 'set shortmess+=I noswapfile belloff= noshowcmd noruler'..extra, - '--embed'} + local nvim_argv = { + helpers.nvim_prog, + '-u', 'NONE', + '-i', 'NONE', + '-N', + '--cmd', 'set shortmess+=I noswapfile belloff= noshowcmd noruler'..extra, + '--cmd', 'colorscheme vim', + '--embed', + } local screen_nvim = spawn(nvim_argv) set_session(screen_nvim) screen = Screen.new() @@ -1017,7 +1029,7 @@ describe('Screen default colors', function() it('can be set to light', function() startup(true, false) screen:expect{condition=function() - eq({rgb_fg=Screen.colors.White, rgb_bg=0, rgb_sp=Screen.colors.Red, + eq({rgb_bg=Screen.colors.White, rgb_fg=0, rgb_sp=Screen.colors.Red, cterm_bg=0, cterm_fg=0}, screen.default_colors) end} end) -- cgit From c84af395e88ba143c19f7e34674bd222622e08ee Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 6 Dec 2023 07:11:36 -0800 Subject: test: 'nofsync' with deadly signal #26415 Problem: The test for 'nofsync' swapfile preservation on a deadly signal, does not actually assert anything. followup to 1fd29a28841dee3d25ff079eb24fc160eb02cb3c Solution: Check that swapfile contents are present after getting SIGTERM. TODO: this doesn't really verify that 'fsync' was called; it still passes with this patch: diff --git a/src/nvim/main.c b/src/nvim/main.c index 216e39f3e81c..7a635520401d 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -838,7 +838,7 @@ void preserve_exit(const char *errmsg) if (errmsg != NULL) { os_errmsg("Vim: preserving files...\r\n"); } - ml_sync_all(false, false, true); // preserve all swap files + ml_sync_all(false, false, false); // preserve all swap files break; } } However it correctly fails with this patch, at least: diff --git a/src/nvim/main.c b/src/nvim/main.c index 216e39f3e81c..f2306c310ddc 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -838,7 +838,6 @@ void preserve_exit(const char *errmsg) if (errmsg != NULL) { os_errmsg("Vim: preserving files...\r\n"); } - ml_sync_all(false, false, true); // preserve all swap files break; } } --- test/functional/ui/screen_basic_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 4ef7565ec5..0406cc9771 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -12,7 +12,7 @@ describe('screen', function() helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', - '-N', + '-n', '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', '--cmd', 'colorscheme vim', '--embed', -- 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/screen_basic_spec.lua | 408 ++++--------------------------- 1 file changed, 48 insertions(+), 360 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 0406cc9771..e1358a0335 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -30,19 +30,9 @@ describe('screen', function() end) it('default initial screen', function() - screen:expect([[ + screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | ]]) @@ -125,17 +115,7 @@ local function screen_tests(linegrid) command('set laststatus=2') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | ]]) @@ -143,17 +123,7 @@ local function screen_tests(linegrid) feed('') screen:expect{grid=[[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | ]], reset=true} @@ -161,17 +131,10 @@ local function screen_tests(linegrid) command('split') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) @@ -179,17 +142,10 @@ local function screen_tests(linegrid) feed('') screen:expect{grid=[[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]], reset=true} @@ -202,17 +158,10 @@ local function screen_tests(linegrid) command('sp') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) @@ -223,17 +172,10 @@ local function screen_tests(linegrid) command('resize 8') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 {1:[No Name] }| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| | ]]) @@ -245,34 +187,20 @@ local function screen_tests(linegrid) command('vsp') screen:expect([[ ^ │ │ | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] }{3:[No Name] [No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) insert('hello') screen:expect([[ hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] [+] }| | ]]) @@ -288,17 +216,10 @@ local function screen_tests(linegrid) insert('hello') screen:expect([[ hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] [+] }| | ]]) @@ -308,33 +229,17 @@ local function screen_tests(linegrid) screen:expect([[ {4: }{5:4}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}| hell^o2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) command('tabprevious') screen:expect([[ {2: }{6:4}{2:+ [No Name] }{4: + [No Name] }{3: }{4:X}| hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:[No Name] [+] }| | ]]) @@ -345,34 +250,14 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) feed(':echo "'..string.rep('x\\n', 11)..'"') screen:expect([[ {1: }| - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | + x |*11 | {7:Press ENTER or type command to continue}^ | ]]) @@ -381,34 +266,13 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) feed(':echo "'..string.rep('x\\n', 12)..'"') screen:expect([[ - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | + x |*12 | {7:Press ENTER or type command to continue}^ | ]]) @@ -417,17 +281,7 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) @@ -439,17 +293,7 @@ local function screen_tests(linegrid) command('vsplit') screen:expect([[ ^foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | + foo │foo |*11 {1:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -457,17 +301,8 @@ local function screen_tests(linegrid) feed('') screen:expect([[ ^foo │foo | - foo │foo | - foo │foo | - foo │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | + foo │foo |*3 + bar │foo |*8 {1:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -475,17 +310,8 @@ local function screen_tests(linegrid) screen:expect([[ {4: }{5:2}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}| ^foo | - foo | - foo | - foo | - bar | - bar | - bar | - bar | - bar | - bar | - bar | - bar | + foo |*3 + bar |*8 | ]]) end) @@ -497,17 +323,7 @@ local function screen_tests(linegrid) screen:expect([[ {2: + [No Name] }{4: [No Name] }{3: }{4:X}| hell^o | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) @@ -515,17 +331,7 @@ local function screen_tests(linegrid) screen:expect([[ {4: + [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) end) @@ -538,16 +344,7 @@ local function screen_tests(linegrid) line 1 | line 2 | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 {2:-- INSERT --} | ]]) end) @@ -563,17 +360,7 @@ local function screen_tests(linegrid) screen:expect([[ 0123^456 | 789 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 1,5 All | ]]) end) @@ -584,18 +371,7 @@ local function screen_tests(linegrid) feed(':ls') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 :ls^ | ]]) end) @@ -604,15 +380,7 @@ local function screen_tests(linegrid) feed(':ls') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 {1: }| :ls | 1 %a "[No Name]" line 1 | @@ -789,9 +557,7 @@ local function screen_tests(linegrid) feed('iresize') screen:expect([[ resize^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {2:-- INSERT --} | ]]) end) @@ -821,17 +587,14 @@ local function screen_tests(linegrid) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) screen:try_resize(30, 6) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) eq(29, meths.get_var('echospace')) @@ -840,15 +603,7 @@ local function screen_tests(linegrid) it('messages from the same Ex command as resize are visible #22225', function() feed(':set columns=20 | call') screen:expect([[ - | - | - | - | - | - | - | - | - | + |*9 {1: }| {8:E471: Argument requi}| {8:red} | @@ -858,27 +613,12 @@ local function screen_tests(linegrid) feed('') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 | ]]) feed(':set columns=0') screen:expect([[ - | - | - | - | - | + |*5 {1: }| {8:E594: Need a}| {8:t least 12 c}| @@ -892,18 +632,7 @@ local function screen_tests(linegrid) feed('') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 | ]]) end) @@ -915,15 +644,7 @@ local function screen_tests(linegrid) feed(':ls') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 {1: }| :ls | 1 %a "[No Name]" line 1 | @@ -932,18 +653,7 @@ local function screen_tests(linegrid) feed('') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 TEST | ]]) end) @@ -956,35 +666,13 @@ local function screen_tests(linegrid) feed('ifooj') screen:expect([[ foo^j | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 {2:-- INSERT --} | ]]) feed('k') screen:expect([[ fo^o | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 | ]]) end) -- cgit From 547ccc2681b204b3cb37b1b1fbe72baf21ca6660 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Sat, 23 Dec 2023 10:56:58 +0600 Subject: refactor(options): remove side effects from `check_num_option_bounds()` --- test/functional/ui/screen_basic_spec.lua | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index e1358a0335..b4ab3f54ca 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -618,22 +618,20 @@ local function screen_tests(linegrid) ]]) feed(':set columns=0') screen:expect([[ - |*5 - {1: }| - {8:E594: Need a}| - {8:t least 12 c}| - {8:olumns: colu}| - {8:mns=0} | - {7:Press ENTER }| - {7:or type comm}| - {7:and to conti}| - {7:nue}^ | + | + {0:~ }|*7 + {1: }| + {8:E594: Need at least }| + {8:12 columns: columns=}| + {8:0} | + {7:Press ENTER or type }| + {7:command to continue}^ | ]]) feed('') screen:expect([[ - ^ | - {0:~ }|*12 - | + ^ | + {0:~ }|*12 + | ]]) end) end) -- 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/screen_basic_spec.lua | 150 ++++++++++++++++++++----------- 1 file changed, 97 insertions(+), 53 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index b4ab3f54ca..4ee2438f88 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -10,11 +10,15 @@ describe('screen', function() local screen local nvim_argv = { helpers.nvim_prog, - '-u', 'NONE', - '-i', 'NONE', + '-u', + 'NONE', + '-i', + 'NONE', '-n', - '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', - '--cmd', 'colorscheme vim', + '--cmd', + 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', + '--cmd', + 'colorscheme vim', '--embed', } @@ -23,10 +27,10 @@ describe('screen', function() set_session(screen_nvim) screen = Screen.new() screen:attach() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {bold=true, reverse=true}, - } ) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { bold = true, reverse = true }, + }) end) it('default initial screen', function() @@ -45,18 +49,23 @@ local function screen_tests(linegrid) before_each(function() clear() screen = Screen.new() - screen:attach({rgb=true,ext_linegrid=linegrid}) - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {bold=true, reverse=true}, - [2] = {bold=true}, - [3] = {reverse=true}, - [4] = {background = Screen.colors.LightGrey, underline = true}, - [5] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Fuchsia}, - [6] = {bold = true, foreground = Screen.colors.Fuchsia}, - [7] = {bold = true, foreground = Screen.colors.SeaGreen}, - [8] = {foreground = Screen.colors.White, background = Screen.colors.Red}, - } ) + screen:attach({ rgb = true, ext_linegrid = linegrid }) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { bold = true, reverse = true }, + [2] = { bold = true }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.LightGrey, underline = true }, + [5] = { + background = Screen.colors.LightGrey, + underline = true, + bold = true, + foreground = Screen.colors.Fuchsia, + }, + [6] = { bold = true, foreground = Screen.colors.Fuchsia }, + [7] = { bold = true, foreground = Screen.colors.SeaGreen }, + [8] = { foreground = Screen.colors.White, background = Screen.colors.Red }, + }) end) describe('bell/visual bell', function() @@ -79,7 +88,7 @@ local function screen_tests(linegrid) describe(':set title', function() it('is forwarded to the UI', function() local expected = 'test-title' - command('set titlestring='..expected) + command('set titlestring=' .. expected) command('set title') screen:expect(function() eq(expected, screen.title) @@ -96,7 +105,7 @@ local function screen_tests(linegrid) describe(':set icon', function() it('is forwarded to the UI', function() local expected = 'test-icon' - command('set iconstring='..expected) + command('set iconstring=' .. expected) command('set icon') screen:expect(function() eq(expected, screen.icon) @@ -121,12 +130,15 @@ local function screen_tests(linegrid) ]]) feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {0:~ }|*11 {1:[No Name] }| | - ]], reset=true} + ]], + reset = true, + } command('split') screen:expect([[ @@ -140,7 +152,8 @@ local function screen_tests(linegrid) ]]) feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {0:~ }|*5 {1:[No Name] }| @@ -148,7 +161,9 @@ local function screen_tests(linegrid) {0:~ }|*4 {3:[No Name] }| | - ]], reset=true} + ]], + reset = true, + } end) end) @@ -254,7 +269,7 @@ local function screen_tests(linegrid) | ]]) - feed(':echo "'..string.rep('x\\n', 11)..'"') + feed(':echo "' .. string.rep('x\\n', 11) .. '"') screen:expect([[ {1: }| x |*11 @@ -270,7 +285,7 @@ local function screen_tests(linegrid) | ]]) - feed(':echo "'..string.rep('x\\n', 12)..'"') + feed(':echo "' .. string.rep('x\\n', 12) .. '"') screen:expect([[ x |*12 | @@ -284,7 +299,6 @@ local function screen_tests(linegrid) {0:~ }|*11 | ]]) - end) it('redraws properly with :tab split right after scroll', function() @@ -676,11 +690,11 @@ local function screen_tests(linegrid) end) end -describe("Screen (char-based)", function() +describe('Screen (char-based)', function() screen_tests(false) end) -describe("Screen (line-based)", function() +describe('Screen (line-based)', function() screen_tests(true) end) @@ -691,45 +705,73 @@ describe('Screen default colors', function() local nvim_argv = { helpers.nvim_prog, - '-u', 'NONE', - '-i', 'NONE', + '-u', + 'NONE', + '-i', + 'NONE', '-N', - '--cmd', 'set shortmess+=I noswapfile belloff= noshowcmd noruler'..extra, - '--cmd', 'colorscheme vim', + '--cmd', + 'set shortmess+=I noswapfile belloff= noshowcmd noruler' .. extra, + '--cmd', + 'colorscheme vim', '--embed', } local screen_nvim = spawn(nvim_argv) set_session(screen_nvim) screen = Screen.new() - screen:attach(termcolors and {rgb=true,ext_termcolors=true} or {rgb=true}) + screen:attach(termcolors and { rgb = true, ext_termcolors = true } or { rgb = true }) end it('are dark per default', function() startup(false, false) - screen:expect{condition=function() - eq({rgb_bg=0, rgb_fg=Screen.colors.White, rgb_sp=Screen.colors.Red, - cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq({ + rgb_bg = 0, + rgb_fg = Screen.colors.White, + rgb_sp = Screen.colors.Red, + cterm_bg = 0, + cterm_fg = 0, + }, screen.default_colors) + end, + } end) it('can be set to light', function() startup(true, false) - screen:expect{condition=function() - eq({rgb_bg=Screen.colors.White, rgb_fg=0, rgb_sp=Screen.colors.Red, - cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq({ + rgb_bg = Screen.colors.White, + rgb_fg = 0, + rgb_sp = Screen.colors.Red, + cterm_bg = 0, + cterm_fg = 0, + }, screen.default_colors) + end, + } end) it('can be handled by external terminal', function() startup(false, true) - screen:expect{condition=function() - eq({rgb_bg=-1, rgb_fg=-1, rgb_sp=-1, cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq( + { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 }, + screen.default_colors + ) + end, + } startup(true, true) - screen:expect{condition=function() - eq({rgb_bg=-1, rgb_fg=-1, rgb_sp=-1, cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq( + { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 }, + screen.default_colors + ) + end, + } end) end) @@ -770,13 +812,15 @@ it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", f clear() local screen = Screen.new(30, 2) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, + [0] = { bold = true, foreground = Screen.colors.Blue }, }) screen:attach() command('set showcmd redrawdebug=compositor') feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | d | - ]]} + ]], + } 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/screen_basic_spec.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 4ee2438f88..3089690f0a 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -597,7 +597,7 @@ local function screen_tests(linegrid) command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) - meths.set_option_value('showtabline', 2, {}) + meths.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | @@ -611,7 +611,7 @@ local function screen_tests(linegrid) {0:~ }|*3 | ]]) - eq(29, meths.get_var('echospace')) + eq(29, meths.nvim_get_var('echospace')) end) it('messages from the same Ex command as resize are visible #22225', function() @@ -779,9 +779,9 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() clear() local screen = Screen.new(100, 100) screen:attach() - eq(100, meths.get_option_value('lines', {})) - eq(99, meths.get_option_value('window', {})) - eq(99, meths.win_get_height(0)) + eq(100, meths.nvim_get_option_value('lines', {})) + eq(99, meths.nvim_get_option_value('window', {})) + eq(99, meths.nvim_win_get_height(0)) feed('1000o') eq(903, funcs.line('w0')) feed('') @@ -794,9 +794,9 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() eq(903, funcs.line('w0')) feed('G') screen:try_resize(50, 50) - eq(50, meths.get_option_value('lines', {})) - eq(49, meths.get_option_value('window', {})) - eq(49, meths.win_get_height(0)) + eq(50, meths.nvim_get_option_value('lines', {})) + eq(49, meths.nvim_get_option_value('window', {})) + eq(49, meths.nvim_win_get_height(0)) eq(953, funcs.line('w0')) feed('') eq(906, funcs.line('w0')) -- 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/screen_basic_spec.lua | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 3089690f0a..42e2b4d4b5 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -4,7 +4,7 @@ local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.cl local feed, command = helpers.feed, helpers.command local insert = helpers.insert local eq = helpers.eq -local funcs, meths = helpers.funcs, helpers.meths +local fn, api = helpers.fn, helpers.api describe('screen', function() local screen @@ -597,7 +597,7 @@ local function screen_tests(linegrid) command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) - meths.nvim_set_option_value('showtabline', 2, {}) + api.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | @@ -611,7 +611,7 @@ local function screen_tests(linegrid) {0:~ }|*3 | ]]) - eq(29, meths.nvim_get_var('echospace')) + eq(29, api.nvim_get_var('echospace')) end) it('messages from the same Ex command as resize are visible #22225', function() @@ -779,33 +779,33 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() clear() local screen = Screen.new(100, 100) screen:attach() - eq(100, meths.nvim_get_option_value('lines', {})) - eq(99, meths.nvim_get_option_value('window', {})) - eq(99, meths.nvim_win_get_height(0)) + eq(100, api.nvim_get_option_value('lines', {})) + eq(99, api.nvim_get_option_value('window', {})) + eq(99, api.nvim_win_get_height(0)) feed('1000o') - eq(903, funcs.line('w0')) + eq(903, fn.line('w0')) feed('') - eq(806, funcs.line('w0')) + eq(806, fn.line('w0')) feed('') - eq(709, funcs.line('w0')) + eq(709, fn.line('w0')) feed('') - eq(806, funcs.line('w0')) + eq(806, fn.line('w0')) feed('') - eq(903, funcs.line('w0')) + eq(903, fn.line('w0')) feed('G') screen:try_resize(50, 50) - eq(50, meths.nvim_get_option_value('lines', {})) - eq(49, meths.nvim_get_option_value('window', {})) - eq(49, meths.nvim_win_get_height(0)) - eq(953, funcs.line('w0')) + eq(50, api.nvim_get_option_value('lines', {})) + eq(49, api.nvim_get_option_value('window', {})) + eq(49, api.nvim_win_get_height(0)) + eq(953, fn.line('w0')) feed('') - eq(906, funcs.line('w0')) + eq(906, fn.line('w0')) feed('') - eq(859, funcs.line('w0')) + eq(859, fn.line('w0')) feed('') - eq(906, funcs.line('w0')) + eq(906, fn.line('w0')) feed('') - eq(953, funcs.line('w0')) + eq(953, fn.line('w0')) end) it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", function() -- cgit