2018-01-30 12:05:59 -07:00
|
|
|
-- Test for scenarios involving 'spell'
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
2018-01-30 12:05:59 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
local clear = n.clear
|
|
|
|
local exec = n.exec
|
|
|
|
local feed = n.feed
|
|
|
|
local insert = n.insert
|
|
|
|
local api = n.api
|
2024-04-08 02:03:20 -07:00
|
|
|
local is_os = t.is_os
|
2018-01-30 12:05:59 -07:00
|
|
|
|
2018-02-11 05:03:24 -07:00
|
|
|
describe("'spell'", function()
|
2018-01-30 12:05:59 -07:00
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
2018-02-11 05:03:24 -07:00
|
|
|
clear()
|
2018-01-30 12:05:59 -07:00
|
|
|
screen = Screen.new(80, 8)
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[0] = { bold = true, foreground = Screen.colors.Blue },
|
2020-07-16 20:48:58 -07:00
|
|
|
[1] = { special = Screen.colors.Red, undercurl = true },
|
2023-04-30 21:30:55 -07:00
|
|
|
[2] = { special = Screen.colors.Blue, undercurl = true },
|
2022-09-28 06:55:22 -07:00
|
|
|
[3] = { foreground = tonumber('0x6a0dad') },
|
|
|
|
[4] = { foreground = Screen.colors.Magenta },
|
|
|
|
[5] = { bold = true, foreground = Screen.colors.SeaGreen },
|
|
|
|
[6] = { foreground = Screen.colors.Red },
|
2023-04-30 21:30:55 -07:00
|
|
|
[7] = { foreground = Screen.colors.Blue },
|
|
|
|
[8] = { foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true },
|
2023-05-24 11:41:58 -07:00
|
|
|
[9] = { bold = true },
|
2023-05-25 17:08:18 -07:00
|
|
|
[10] = { background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue },
|
2018-01-30 12:05:59 -07:00
|
|
|
})
|
|
|
|
end)
|
|
|
|
|
2018-02-11 05:03:24 -07:00
|
|
|
it('joins long lines #7937', function()
|
2022-11-21 17:13:30 -07:00
|
|
|
if is_os('openbsd') then
|
|
|
|
pending('FIXME #12104', function() end)
|
|
|
|
return
|
|
|
|
end
|
2023-05-24 10:50:01 -07:00
|
|
|
exec('set spell')
|
2018-02-11 05:03:24 -07:00
|
|
|
insert([[
|
2018-01-30 12:05:59 -07:00
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
|
|
|
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
|
|
|
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
|
|
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
|
|
|
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
|
|
|
|
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
|
|
]])
|
2018-02-11 05:03:24 -07:00
|
|
|
feed('ggJJJJJJ0')
|
2018-01-30 12:05:59 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1:^Lorem} {1:ipsum} dolor sit {1:amet}, {1:consectetur} {1:adipiscing} {1:elit}, {1:sed} do {1:eiusmod} {1:tempor} {1:i}|
|
2021-06-11 18:13:02 -07:00
|
|
|
{1:ncididunt} {1:ut} {1:labore} et {1:dolore} {1:magna} {1:aliqua}. {1:Ut} {1:enim} ad minim {1:veniam}, {1:quis} {1:nostru}|
|
2018-01-30 12:05:59 -07:00
|
|
|
{1:d} {1:exercitation} {1:ullamco} {1:laboris} {1:nisi} {1:ut} {1:aliquip} ex ea {1:commodo} {1:consequat}. {1:Duis} {1:aut}|
|
|
|
|
{1:e} {1:irure} dolor in {1:reprehenderit} in {1:voluptate} {1:velit} {1:esse} {1:cillum} {1:dolore} {1:eu} {1:fugiat} {1:n}|
|
|
|
|
{1:ulla} {1:pariatur}. {1:Excepteur} {1:sint} {1:occaecat} {1:cupidatat} non {1:proident}, {1:sunt} in culpa {1:qui}|
|
|
|
|
{1:officia} {1:deserunt} {1:mollit} {1:anim} id est {1:laborum}. |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2020-07-16 20:48:58 -07:00
|
|
|
|
2022-11-28 19:17:57 -07:00
|
|
|
-- oldtest: Test_spell_screendump()
|
2020-07-16 20:48:58 -07:00
|
|
|
it('has correct highlight at start of line', function()
|
2023-05-24 10:50:01 -07:00
|
|
|
exec([=[
|
|
|
|
call setline(1, [
|
|
|
|
\"This is some text without any spell errors. Everything",
|
|
|
|
\"should just be black, nothing wrong here.",
|
|
|
|
\"",
|
|
|
|
\"This line has a sepll error. and missing caps.",
|
|
|
|
\"And and this is the the duplication.",
|
|
|
|
\"with missing caps here.",
|
|
|
|
\])
|
|
|
|
set spell spelllang=en_nz
|
|
|
|
]=])
|
|
|
|
screen:expect([[
|
|
|
|
^This is some text without any spell errors. Everything |
|
|
|
|
should just be black, nothing wrong here. |
|
|
|
|
|
|
|
|
|
This line has a {1:sepll} error. {2:and} missing caps. |
|
|
|
|
{1:And and} this is {1:the the} duplication. |
|
|
|
|
{2:with} missing caps here. |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
2020-07-16 20:48:58 -07:00
|
|
|
]])
|
2023-05-24 10:50:01 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
-- oldtest: Test_spell_screendump_spellcap()
|
2023-05-25 17:08:18 -07:00
|
|
|
it('SpellCap highlight at start of line', function()
|
2023-05-24 10:50:01 -07:00
|
|
|
exec([=[
|
|
|
|
call setline(1, [
|
|
|
|
\" This line has a sepll error. and missing caps and trailing spaces. ",
|
|
|
|
\"another missing cap here.",
|
|
|
|
\"",
|
|
|
|
\"and here.",
|
|
|
|
\" ",
|
|
|
|
\"and here."
|
|
|
|
\])
|
|
|
|
set spell spelllang=en
|
|
|
|
]=])
|
2020-07-16 20:48:58 -07:00
|
|
|
screen:expect([[
|
2023-05-24 10:50:01 -07:00
|
|
|
^ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
|
|
|
|
{2:another} missing cap here. |
|
|
|
|
|
|
|
|
|
{2:and} here. |
|
|
|
|
|
|
|
|
|
{2:and} here. |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
2022-11-25 16:52:30 -07:00
|
|
|
]])
|
2023-05-24 11:13:11 -07:00
|
|
|
-- After adding word missing Cap in next line is updated
|
|
|
|
feed('3GANot<Esc>')
|
|
|
|
screen:expect([[
|
|
|
|
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
|
|
|
|
{2:another} missing cap here. |
|
|
|
|
No^t |
|
|
|
|
and here. |
|
|
|
|
|
|
|
|
|
{2:and} here. |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
2023-05-24 11:26:03 -07:00
|
|
|
-- Deleting a full stop removes missing Cap in next line
|
2023-05-25 17:08:18 -07:00
|
|
|
feed('5Gdd<C-L>k$x')
|
2023-05-24 11:26:03 -07:00
|
|
|
screen:expect([[
|
|
|
|
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
|
|
|
|
{2:another} missing cap here. |
|
|
|
|
Not |
|
|
|
|
and her^e |
|
|
|
|
and here. |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*2
|
2023-05-24 11:26:03 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- Undo also updates the next line (go to command line to remove message)
|
|
|
|
feed('u:<Esc>')
|
|
|
|
screen:expect([[
|
|
|
|
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
|
|
|
|
{2:another} missing cap here. |
|
|
|
|
Not |
|
|
|
|
and here^. |
|
|
|
|
{2:and} here. |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*2
|
2023-05-24 11:26:03 -07:00
|
|
|
|
|
|
|
|
]])
|
2023-05-25 17:08:18 -07:00
|
|
|
-- Folding an empty line does not remove Cap in next line
|
|
|
|
feed('uzfk:<Esc>')
|
|
|
|
screen:expect([[
|
|
|
|
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
|
|
|
|
{2:another} missing cap here. |
|
|
|
|
Not |
|
|
|
|
{10:^+-- 2 lines: and here.·························································}|
|
|
|
|
{2:and} here. |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*2
|
2023-05-25 17:08:18 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- Folding the end of a sentence does not remove Cap in next line
|
|
|
|
-- and editing a line does not remove Cap in current line
|
|
|
|
feed('Jzfkk$x')
|
|
|
|
screen:expect([[
|
|
|
|
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
|
|
|
|
{2:another} missing cap her^e |
|
|
|
|
{10:+-- 2 lines: Not·······························································}|
|
|
|
|
{2:and} here. |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*3
|
2023-05-25 17:08:18 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- Cap is correctly applied in the first row of a window
|
|
|
|
feed('<C-E><C-L>')
|
|
|
|
screen:expect([[
|
|
|
|
{2:another} missing cap her^e |
|
|
|
|
{10:+-- 2 lines: Not·······························································}|
|
|
|
|
{2:and} here. |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-05-25 17:08:18 -07:00
|
|
|
|
|
|
|
|
]])
|
2023-05-31 12:13:58 -07:00
|
|
|
-- Adding an empty line does not remove Cap in "mod_bot" area
|
|
|
|
feed('zbO<Esc>')
|
|
|
|
screen:expect([[
|
|
|
|
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
|
|
|
|
^ |
|
|
|
|
{2:another} missing cap here |
|
|
|
|
{10:+-- 2 lines: Not·······························································}|
|
|
|
|
{2:and} here. |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*2
|
2023-05-31 12:13:58 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- Multiple empty lines does not remove Cap in the line after
|
|
|
|
feed('O<Esc><C-L>')
|
|
|
|
screen:expect([[
|
|
|
|
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
|
|
|
|
^ |
|
|
|
|
|
|
|
|
|
{2:another} missing cap here |
|
|
|
|
{10:+-- 2 lines: Not·······························································}|
|
|
|
|
{2:and} here. |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
2020-07-16 20:48:58 -07:00
|
|
|
end)
|
2022-09-28 06:55:22 -07:00
|
|
|
|
2023-05-24 11:41:58 -07:00
|
|
|
-- oldtest: Test_spell_compatible()
|
|
|
|
it([[redraws properly when using "C" and "$" is in 'cpo']], function()
|
|
|
|
exec([=[
|
|
|
|
call setline(1, [
|
|
|
|
\ "test "->repeat(20),
|
|
|
|
\ "",
|
|
|
|
\ "end",
|
|
|
|
\ ])
|
|
|
|
set spell cpo+=$
|
|
|
|
]=])
|
|
|
|
feed('51|C')
|
|
|
|
screen:expect([[
|
|
|
|
{2:test} test test test test test test test test test ^test test test test test test |
|
|
|
|
test test test test$ |
|
|
|
|
|
|
|
|
|
{2:end} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*3
|
2023-05-24 11:41:58 -07:00
|
|
|
{9:-- INSERT --} |
|
|
|
|
]])
|
|
|
|
feed('x')
|
|
|
|
screen:expect([[
|
|
|
|
{2:test} test test test test test test test test test x^est test test test test test |
|
|
|
|
test test test test$ |
|
|
|
|
|
|
|
|
|
{2:end} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*3
|
2023-05-24 11:41:58 -07:00
|
|
|
{9:-- INSERT --} |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2023-04-30 21:30:55 -07:00
|
|
|
it('extmarks, "noplainbuffer" and syntax #20385 #23398', function()
|
2023-05-24 10:50:01 -07:00
|
|
|
exec('set filetype=c')
|
|
|
|
exec('syntax on')
|
|
|
|
exec('set spell')
|
2022-09-28 06:55:22 -07:00
|
|
|
insert([[
|
|
|
|
#include <stdbool.h>
|
2023-04-30 21:30:55 -07:00
|
|
|
bool func(void);
|
|
|
|
// I am a speling mistakke]])
|
|
|
|
feed('ge')
|
2022-09-28 06:55:22 -07:00
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
2023-04-30 21:30:55 -07:00
|
|
|
{5:bool} func({5:void}); |
|
|
|
|
{7:// I am a }{8:spelin^g}{7: }{8:mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed(']s')
|
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
|
|
|
{5:bool} func({5:void}); |
|
|
|
|
{7:// I am a }{8:speling}{7: }{8:^mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed(']s')
|
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
|
|
|
{5:bool} func({5:void}); |
|
|
|
|
{7:// I am a }{8:^speling}{7: }{8:mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
{6:search hit BOTTOM, continuing at TOP} |
|
|
|
|
]])
|
2023-05-24 10:50:01 -07:00
|
|
|
exec('echo ""')
|
2024-01-12 10:59:57 -07:00
|
|
|
local ns = api.nvim_create_namespace('spell')
|
2023-04-30 21:30:55 -07:00
|
|
|
-- extmark with spell=true enables spell
|
2024-01-12 10:59:57 -07:00
|
|
|
local id = api.nvim_buf_set_extmark(0, ns, 1, 4, { end_row = 1, end_col = 10, spell = true })
|
2023-04-30 21:30:55 -07:00
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
|
|
|
{5:bool} {1:func}({5:void}); |
|
|
|
|
{7:// I am a }{8:^speling}{7: }{8:mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2022-09-28 06:55:22 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('[s')
|
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
2023-04-30 21:30:55 -07:00
|
|
|
{5:bool} {1:^func}({5:void}); |
|
|
|
|
{7:// I am a }{8:speling}{7: }{8:mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
|
|
|
]])
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_buf_del_extmark(0, ns, id)
|
2023-04-30 21:30:55 -07:00
|
|
|
-- extmark with spell=false disables spell
|
2024-01-12 10:59:57 -07:00
|
|
|
id = api.nvim_buf_set_extmark(0, ns, 2, 18, { end_row = 2, end_col = 26, spell = false })
|
2023-04-30 21:30:55 -07:00
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
|
|
|
{5:bool} ^func({5:void}); |
|
|
|
|
{7:// I am a }{8:speling}{7: mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('[s')
|
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
|
|
|
{5:bool} func({5:void}); |
|
|
|
|
{7:// I am a }{8:^speling}{7: mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2022-09-28 06:55:22 -07:00
|
|
|
{6:search hit TOP, continuing at BOTTOM} |
|
|
|
|
]])
|
2023-05-24 10:50:01 -07:00
|
|
|
exec('echo ""')
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_buf_del_extmark(0, ns, id)
|
2023-04-30 21:30:55 -07:00
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
|
|
|
{5:bool} func({5:void}); |
|
|
|
|
{7:// I am a }{8:^speling}{7: }{8:mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed(']s')
|
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
|
|
|
{5:bool} func({5:void}); |
|
|
|
|
{7:// I am a }{8:speling}{7: }{8:^mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
|
|
|
]])
|
2022-09-28 06:55:22 -07:00
|
|
|
-- "noplainbuffer" shouldn't change spellchecking behavior with syntax enabled
|
2023-05-24 10:50:01 -07:00
|
|
|
exec('set spelloptions+=noplainbuffer')
|
2022-09-28 06:55:22 -07:00
|
|
|
screen:expect_unchanged()
|
2023-04-30 21:30:55 -07:00
|
|
|
feed('[s')
|
2022-09-28 06:55:22 -07:00
|
|
|
screen:expect([[
|
|
|
|
{3:#include }{4:<stdbool.h>} |
|
2023-04-30 21:30:55 -07:00
|
|
|
{5:bool} func({5:void}); |
|
|
|
|
{7:// I am a }{8:^speling}{7: }{8:mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
2022-09-28 06:55:22 -07:00
|
|
|
]])
|
|
|
|
-- no spellchecking with "noplainbuffer" and syntax disabled
|
2023-05-24 10:50:01 -07:00
|
|
|
exec('syntax off')
|
2022-09-28 06:55:22 -07:00
|
|
|
screen:expect([[
|
|
|
|
#include <stdbool.h> |
|
2023-04-30 21:30:55 -07:00
|
|
|
bool func(void); |
|
|
|
|
// I am a ^speling mistakke |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
2022-09-28 06:55:22 -07:00
|
|
|
]])
|
2023-04-30 21:30:55 -07:00
|
|
|
feed(']s')
|
2022-09-28 06:55:22 -07:00
|
|
|
screen:expect([[
|
|
|
|
#include <stdbool.h> |
|
2023-04-30 21:30:55 -07:00
|
|
|
bool func(void); |
|
|
|
|
// I am a ^speling mistakke |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
{6:search hit BOTTOM, continuing at TOP} |
|
2022-09-28 06:55:22 -07:00
|
|
|
]])
|
2023-05-24 10:50:01 -07:00
|
|
|
exec('echo ""')
|
2022-09-28 06:55:22 -07:00
|
|
|
-- everything is spellchecked without "noplainbuffer" with syntax disabled
|
2023-05-24 10:50:01 -07:00
|
|
|
exec('set spelloptions&')
|
2022-09-28 06:55:22 -07:00
|
|
|
screen:expect([[
|
|
|
|
#include <{1:stdbool}.h> |
|
2023-04-30 21:30:55 -07:00
|
|
|
{1:bool} {1:func}(void); |
|
|
|
|
// I am a {1:^speling} {1:mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
2022-09-28 06:55:22 -07:00
|
|
|
]])
|
2023-04-30 21:30:55 -07:00
|
|
|
feed('[s')
|
2022-09-28 06:55:22 -07:00
|
|
|
screen:expect([[
|
2023-04-30 21:30:55 -07:00
|
|
|
#include <{1:stdbool}.h> |
|
|
|
|
{1:bool} {1:^func}(void); |
|
|
|
|
// I am a {1:speling} {1:mistakke} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*4
|
2023-04-30 21:30:55 -07:00
|
|
|
|
|
2022-09-28 06:55:22 -07:00
|
|
|
]])
|
|
|
|
end)
|
2023-04-30 21:30:55 -07:00
|
|
|
|
2023-05-22 02:07:55 -07:00
|
|
|
it('and syntax does not clear extmark highlighting at the start of a word', function()
|
|
|
|
screen:try_resize(43, 3)
|
2023-05-24 10:50:01 -07:00
|
|
|
exec([[
|
2023-05-22 02:07:55 -07:00
|
|
|
set spell
|
|
|
|
syntax match Constant "^.*$"
|
|
|
|
call setline(1, "This is some text without any spell errors.")
|
|
|
|
]])
|
2024-01-12 10:59:57 -07:00
|
|
|
local ns = api.nvim_create_namespace('spell')
|
|
|
|
api.nvim_buf_set_extmark(0, ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 })
|
2023-05-22 02:07:55 -07:00
|
|
|
screen:expect([[
|
|
|
|
{6:^This is some text without any spell errors.}|
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2024-10-07 15:24:36 -07:00
|
|
|
|
|
|
|
it('overrides syntax when Visual selection is active', function()
|
|
|
|
screen:try_resize(43, 3)
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[0] = { bold = true, foreground = Screen.colors.Blue },
|
|
|
|
[1] = { foreground = Screen.colors.Blue },
|
|
|
|
[2] = { foreground = Screen.colors.Red },
|
|
|
|
[3] = { foreground = Screen.colors.Blue, underline = true },
|
|
|
|
[4] = { foreground = Screen.colors.Red, underline = true },
|
|
|
|
[5] = { bold = true },
|
|
|
|
})
|
|
|
|
exec([[
|
|
|
|
hi! Comment guibg=NONE guifg=Blue gui=NONE guisp=NONE
|
|
|
|
hi! SpellBad guibg=NONE guifg=Red gui=NONE guisp=NONE
|
|
|
|
hi! Visual guibg=NONE guifg=NONE gui=underline guisp=NONE
|
|
|
|
syn match Comment "//.*"
|
|
|
|
call setline(1, '// Here is a misspeld word.')
|
|
|
|
set spell
|
|
|
|
]])
|
|
|
|
screen:expect([[
|
|
|
|
{1:^// Here is a }{2:misspeld}{1: word.} |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('V')
|
|
|
|
screen:expect([[
|
|
|
|
{1:^/}{3:/ Here is a }{4:misspeld}{3: word.} |
|
|
|
|
{0:~ }|
|
|
|
|
{5:-- VISUAL LINE --} |
|
|
|
|
]])
|
|
|
|
end)
|
2024-10-21 20:34:09 -07:00
|
|
|
|
|
|
|
it("global value works properly for 'spelloptions'", function()
|
|
|
|
screen:try_resize(43, 3)
|
|
|
|
exec('set spell')
|
|
|
|
-- :setglobal applies to future buffers but not current buffer
|
|
|
|
exec('setglobal spelloptions=camel')
|
|
|
|
insert('Here is TheCamelWord being spellchecked')
|
|
|
|
screen:expect([[
|
|
|
|
Here is {1:TheCamelWord} being spellchecke^d |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
exec('enew')
|
|
|
|
insert('There is TheCamelWord being spellchecked')
|
|
|
|
screen:expect([[
|
|
|
|
There is TheCamelWord being spellchecke^d |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- :setlocal applies to current buffer but not future buffers
|
|
|
|
exec('setlocal spelloptions=')
|
|
|
|
screen:expect([[
|
|
|
|
There is {1:TheCamelWord} being spellchecke^d |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
exec('enew')
|
|
|
|
insert('What is TheCamelWord being spellchecked')
|
|
|
|
screen:expect([[
|
|
|
|
What is TheCamelWord being spellchecke^d |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- :set applies to both current buffer and future buffers
|
|
|
|
exec('set spelloptions=')
|
|
|
|
screen:expect([[
|
|
|
|
What is {1:TheCamelWord} being spellchecke^d |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
exec('enew')
|
|
|
|
insert('Where is TheCamelWord being spellchecked')
|
|
|
|
screen:expect([[
|
|
|
|
Where is {1:TheCamelWord} being spellchecke^d |
|
|
|
|
{0:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2018-01-30 12:05:59 -07:00
|
|
|
end)
|