Regenerate nvim config
This commit is contained in:
35
config/neovim/store/lazy-plugins/noice.nvim/tests/init.lua
Normal file
35
config/neovim/store/lazy-plugins/noice.nvim/tests/init.lua
Normal file
@ -0,0 +1,35 @@
|
||||
local M = {}
|
||||
|
||||
function M.root(root)
|
||||
local f = debug.getinfo(1, "S").source:sub(2)
|
||||
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "")
|
||||
end
|
||||
|
||||
---@param plugin string
|
||||
function M.load(plugin)
|
||||
local name = plugin:match(".*/(.*)")
|
||||
local package_root = M.root(".tests/site/pack/deps/start/")
|
||||
if not vim.loop.fs_stat(package_root .. name) then
|
||||
print("Installing " .. plugin)
|
||||
vim.fn.mkdir(package_root, "p")
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth=1",
|
||||
"https://github.com/" .. plugin .. ".git",
|
||||
package_root .. "/" .. name,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
||||
vim.opt.runtimepath:append(M.root())
|
||||
vim.opt.packpath = { M.root(".tests/site") }
|
||||
|
||||
M.load("MunifTanjim/nui.nvim")
|
||||
M.load("nvim-lua/plenary.nvim")
|
||||
M.load("rcarriga/nvim-notify")
|
||||
end
|
||||
|
||||
M.setup()
|
||||
3
config/neovim/store/lazy-plugins/noice.nvim/tests/run
Executable file
3
config/neovim/store/lazy-plugins/noice.nvim/tests/run
Executable file
@ -0,0 +1,3 @@
|
||||
#!/nix/store/306znyj77fv49kwnkpxmb0j2znqpa8bj-bash-5.2p26/bin/sh
|
||||
|
||||
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
|
||||
@ -0,0 +1,213 @@
|
||||
local Markdown = require("noice.text.markdown")
|
||||
|
||||
local M = {}
|
||||
|
||||
local ns = vim.api.nvim_create_namespace("noice_test")
|
||||
|
||||
function M.test()
|
||||
describe("markdown", function()
|
||||
it("parse", function()
|
||||
for _, test in ipairs(M.tests) do
|
||||
assert.same(test.output, Markdown.parse(test.input))
|
||||
end
|
||||
end)
|
||||
|
||||
it("conceal escape characters", function()
|
||||
local chars = "\\`*_{}[]()#+-.!"
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
|
||||
---@type string[]
|
||||
local lines = {}
|
||||
for i = 1, #chars do
|
||||
local char = chars:sub(i, i)
|
||||
table.insert(lines, "\\" .. char)
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
|
||||
|
||||
Markdown.conceal_escape_characters(buf, ns, { 0, 0, #lines - 1, 1 })
|
||||
local extmarks = vim.api.nvim_buf_get_extmarks(buf, ns, 0, -1, {})
|
||||
assert.equal(chars:len(), #extmarks)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
M.tests = {
|
||||
{
|
||||
input = [[
|
||||
|
||||
|
||||
|
||||
foo
|
||||
|
||||
]],
|
||||
output = {
|
||||
{ line = " foo" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
bar
|
||||
|
||||
|
||||
---
|
||||
|
||||
foo
|
||||
|
||||
]],
|
||||
output = {
|
||||
{ line = " bar" },
|
||||
{ line = "---" },
|
||||
{ line = " foo" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
```lua
|
||||
local a
|
||||
```
|
||||
|
||||
foo
|
||||
|
||||
```lua
|
||||
local b
|
||||
```
|
||||
]],
|
||||
output = {
|
||||
{ code = { "local a" }, lang = "lua" },
|
||||
{ line = "" },
|
||||
{ line = "foo" },
|
||||
{ line = "" },
|
||||
{ code = { "local b" }, lang = "lua" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
|
||||
```lua
|
||||
local a
|
||||
```
|
||||
```lua
|
||||
local b
|
||||
```
|
||||
]],
|
||||
output = {
|
||||
{ code = { "local a" }, lang = "lua" },
|
||||
{ line = "" },
|
||||
{ code = { "local b" }, lang = "lua" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
|
||||
<foo
|
||||
]],
|
||||
output = {
|
||||
{ line = "<foo" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
|
||||
```lua
|
||||
local a
|
||||
```
|
||||
|
||||
]],
|
||||
output = {
|
||||
{ code = { "local a" }, lang = "lua" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
|
||||
```lua
|
||||
local a
|
||||
local b
|
||||
]],
|
||||
output = {
|
||||
{ code = { "local a", "local b", "" }, lang = "lua" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
|
||||
***
|
||||
|
||||
```lua
|
||||
local a
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
]],
|
||||
output = {
|
||||
{ line = "---" },
|
||||
{ code = { "local a" }, lang = "lua" },
|
||||
{ line = "---" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
|
||||
***
|
||||
|
||||
``` lua
|
||||
local a
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
]],
|
||||
output = {
|
||||
{ line = "---" },
|
||||
{ code = { "local a" }, lang = "lua" },
|
||||
{ line = "---" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
|
||||
```lua
|
||||
local a
|
||||
```
|
||||
|
||||
foo
|
||||
|
||||
bar
|
||||
|
||||
```
|
||||
local b
|
||||
```
|
||||
|
||||
]],
|
||||
output = {
|
||||
{ code = { "local a" }, lang = "lua" },
|
||||
{ line = "" },
|
||||
{ line = "foo" },
|
||||
{ line = "" },
|
||||
{ line = "bar" },
|
||||
{ line = "" },
|
||||
{ code = { "local b" }, lang = "text" },
|
||||
},
|
||||
},
|
||||
{
|
||||
input = [[
|
||||
|
||||
1 < 2
|
||||
3 > 2
|
||||
"quoted"
|
||||
'apos'
|
||||
  indented
|
||||
&
|
||||
]],
|
||||
output = {
|
||||
{ line = "1 < 2" },
|
||||
{ line = "3 > 2" },
|
||||
{ line = '"quoted"' },
|
||||
{ line = "'apos'" },
|
||||
{ line = " indented" },
|
||||
{ line = "&" },
|
||||
},
|
||||
},
|
||||
}
|
||||
M.test()
|
||||
@ -0,0 +1,7 @@
|
||||
local lazy = require("noice.util.lazy")
|
||||
|
||||
describe("ffi", function()
|
||||
it("cmdpreview is false", function()
|
||||
assert(lazy("noice.util.ffi").cmdpreview == false)
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,12 @@
|
||||
local View = require("noice.view")
|
||||
local Config = require("noice.config")
|
||||
Config.setup()
|
||||
|
||||
describe("checking views", function()
|
||||
it("view is loaded only once", function()
|
||||
local opts = { enter = true, format = "details" }
|
||||
local view1 = View.get_view("split", opts)
|
||||
local view2 = View.get_view("split", opts)
|
||||
assert.equal(view1, view2)
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user