test: add a test for input highlighting

This commit is contained in:
Steven Arcangeli 2021-12-04 12:50:09 -08:00
parent 8a75a7ba1b
commit 3c01f6bf79
1 changed files with 30 additions and 0 deletions

30
test/manual/highlight.lua Normal file
View File

@ -0,0 +1,30 @@
-- Run this test with :source %
vim.cmd([[
highlight RBP1 guibg=Red ctermbg=red
highlight RBP2 guibg=Yellow ctermbg=yellow
highlight RBP3 guibg=Green ctermbg=green
highlight RBP4 guibg=Blue ctermbg=blue
]])
local rainbow_levels = 4
local function rainbow_hl(cmdline)
local ret = {}
local lvl = 0
for i = 1, string.len(cmdline) do
local char = string.sub(cmdline, i, i)
if char == "(" then
table.insert(ret, { i - 1, i, string.format("RBP%d", (lvl % rainbow_levels) + 1) })
lvl = lvl + 1
elseif char == ")" then
lvl = lvl - 1
table.insert(ret, { i - 1, i, string.format("RBP%d", (lvl % rainbow_levels) + 1) })
end
end
return ret
end
vim.ui.input({
prompt = "Rainbow: ",
default = "((()(())))",
highlight = rainbow_hl,
}, function() end)