40 lines
2.2 KiB
Lua
40 lines
2.2 KiB
Lua
-- Typing in the installed IDE, headless: the completion menu opens from the buffer's words, and
|
|
-- the keys are the ones the README promises.
|
|
-- llembas-ide --headless -c "luafile ide/tests/typing.lua"
|
|
local function finish(problems)
|
|
vim.g.llembas_ide_no_session = true
|
|
io.stdout:write("\n")
|
|
for _, p in ipairs(problems) do io.stdout:write("FAIL " .. p .. "\n") end
|
|
io.stdout:write(("ide-typing: %s\n"):format(#problems == 0 and "the menu opens, <Tab> is not the menu's" or #problems .. " failed"))
|
|
vim.cmd(#problems == 0 and "qa!" or "cquit 1")
|
|
end
|
|
|
|
vim.schedule(function()
|
|
vim.cmd("enew")
|
|
vim.api.nvim_buf_set_lines(0, 0, -1, false, { "alphabet_soup = 1", "alphabet_city = 2", "" })
|
|
vim.api.nvim_win_set_cursor(0, { 3, 0 })
|
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("ialph", true, false, true), "tx!", false)
|
|
end)
|
|
|
|
local waited = 0
|
|
local function look()
|
|
waited = waited + 200
|
|
local blink = require("blink.cmp")
|
|
if not blink.is_visible() and waited < 6000 then return vim.defer_fn(look, 200) end
|
|
local problems = {}
|
|
if not blink.is_visible() then table.insert(problems, "the completion menu did not open on typed text") end
|
|
local items = require("blink.cmp.completion.list").items or {}
|
|
local labels = {}
|
|
for _, item in ipairs(items) do labels[item.label] = true end
|
|
if not (labels.alphabet_soup and labels.alphabet_city) then table.insert(problems, "the buffer's words are not offered: " .. vim.inspect(vim.tbl_keys(labels))) end
|
|
if require("blink.cmp.completion.list").selected_item_idx ~= nil then table.insert(problems, "an entry is chosen before the person moved") end
|
|
local tab = vim.fn.maparg("<Tab>", "i", false, true)
|
|
if tab.buffer == 1 then table.insert(problems, "<Tab> is mapped in the buffer while only the menu is showing: " .. vim.inspect(tab.desc)) end
|
|
if vim.fn.maparg("<CR>", "i", false, true).buffer ~= 1 or vim.fn.maparg("<C-y>", "i", false, true).buffer ~= 1 then
|
|
table.insert(problems, "the menu's <CR> and <C-y> are not mapped")
|
|
end
|
|
if vim.api.nvim_buf_get_lines(0, 2, 3, false)[1] ~= "alph" then table.insert(problems, "the typed text was changed: " .. vim.api.nvim_buf_get_lines(0, 2, 3, false)[1]) end
|
|
finish(problems)
|
|
end
|
|
vim.defer_fn(look, 200)
|