1

Update generated neovim config

This commit is contained in:
2024-08-15 14:28:54 +02:00
parent 07409c223d
commit 25cfcf2941
3809 changed files with 351157 additions and 0 deletions

View File

@ -0,0 +1,12 @@
#!/usr/bin/env -S nvim -l
vim.env.LAZY_STDPATH = ".tests"
vim.env.LAZY_PATH = vim.fs.normalize("~/projects/lazy.nvim")
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
-- Setup lazy.nvim
require("lazy.minit").setup({
spec = {
{ dir = vim.uv.cwd(), opts = {} },
},
})

View File

@ -0,0 +1,95 @@
local Parser = require("trouble.config.parser")
describe("Input is parsed correctly", function()
local tests = {
{
input = [[a = "b" foo = true bar=1 c = "g"]],
expected = { opts = { a = "b", foo = true, bar = 1, c = "g" }, errors = {}, args = {} },
},
{
input = [[key="value with spaces"]],
expected = { opts = { key = "value with spaces" }, errors = {}, args = {} },
},
{
input = [[arr={one, two}]],
expected = { opts = { arr = { "one", "two" } }, errors = {}, args = {} },
},
{
input = [[a.b = "c"]],
expected = { opts = { a = { b = "c" } }, errors = {}, args = {} },
},
{
input = [[vim=vim.diagnostic.severity.ERROR]],
expected = { opts = { vim = vim.diagnostic.severity.ERROR }, errors = {}, args = {} },
},
{
input = [[x.y.z = "value" a.b = 2]],
expected = { opts = { x = { y = { z = "value" } }, a = { b = 2 } }, errors = {}, args = {} },
},
{
input = [[test="hello world"]],
expected = { opts = { test = "hello world" }, errors = {}, args = {} },
},
{
input = [[one.two.three.four = 4]],
expected = { opts = { one = { two = { three = { four = 4 } } } }, errors = {}, args = {} },
},
{
input = [[a="b" c="d" e.f="g" h.i.j="k"]],
expected = { opts = { a = "b", c = "d", e = { f = "g" }, h = { i = { j = "k" } } }, errors = {}, args = {} },
},
{
input = [[empty = "" nonempty="not empty"]],
expected = { opts = { empty = "", nonempty = "not empty" }, errors = {}, args = {} },
},
{
input = [[win.position="right" win.relative="win"]],
expected = { opts = { win = { position = "right", relative = "win" } }, errors = {}, args = {} },
},
{
input = [[a.b="c" a = "b"]],
expected = { opts = { a = "b" }, errors = {}, args = {} }, -- This test is tricky as it will overwrite the first value of 'a'
},
{
input = [[a="b" a.b="c"]],
expected = { opts = { a = { b = "c" } }, errors = {}, args = {} }, -- This test is tricky as it will overwrite the first value of 'a'
},
{
input = [[a_b = 1]],
expected = { opts = { a_b = 1 }, errors = {}, args = {} },
},
{
input = "foo=bar bar=baz",
expected = { opts = { foo = "bar", bar = "baz" }, errors = {}, args = {} },
},
{
input = "foo=bar bar={ one, two, three} ",
expected = { opts = { foo = "bar", bar = { "one", "two", "three" } }, errors = {}, args = {} },
},
{
input = [[a.x = 1 a.y = 2 a = {z =3}]],
expected = { opts = { a = { z = 3 } }, errors = {}, args = {} },
},
{
input = [[ a = {z =3} a.x = 1 a.y = 2]],
expected = { opts = { a = { x = 1, y = 2, z = 3 } }, errors = {}, args = {} },
},
{
input = "foo",
expected = { opts = {}, errors = {}, args = { "foo" } },
},
{ input = "foo bar", expected = { opts = {}, errors = {}, args = { "foo", "bar" } } },
{
input = "foo bar baz",
expected = { opts = {}, errors = {}, args = { "foo", "bar", "baz" } },
},
}
for _, test in ipairs(tests) do
it("parses " .. test.input, function()
local actual = Parser.parse(test.input)
assert.same(test.expected, actual)
end)
end
return tests
end)

View File

@ -0,0 +1,97 @@
local Spec = require("trouble.spec")
describe("parses specs", function()
it("parses a sort spec", function()
local f1 = function() end
---@type ({input:trouble.Sort.spec, output:trouble.Sort})[]
local tests = {
{
input = "foo",
output = { { field = "foo" } },
},
{
input = { "foo", "bar" },
output = { { field = "foo" }, { field = "bar" } },
},
{
input = { "foo", "-bar" },
output = { { field = "foo" }, { field = "bar", desc = true } },
},
{ input = f1, output = { { sorter = f1 } } },
{ input = { buf = 0 }, output = { { filter = { buf = 0 } } } },
{ input = { { buf = 0 } }, output = { { filter = { buf = 0 } } } },
{ input = { f1, "foo" }, output = { { sorter = f1 }, { field = "foo" } } },
}
for _, test in ipairs(tests) do
assert.same(test.output, Spec.sort(test.input))
end
end)
it("parses a group spec", function()
---@type ({input:trouble.Group.spec, output:trouble.Group})[]
local tests = {
{
input = "foo",
output = { fields = { "foo" }, format = "{foo}" },
},
{
input = "foo",
output = { fields = { "foo" }, format = "{foo}" },
},
{
input = { "foo", "bar" },
output = { fields = { "foo", "bar" }, format = "{foo} {bar}" },
},
{
input = { "foo", "bar" },
output = { fields = { "foo", "bar" }, format = "{foo} {bar}" },
},
{
input = { "foo", "bar" },
output = { fields = { "foo", "bar" }, format = "{foo} {bar}" },
},
{
input = {
"directory",
format = "{kind_icon} {symbol.name} {text:Comment} {pos}",
},
output = {
directory = true,
format = "{kind_icon} {symbol.name} {text:Comment} {pos}",
},
},
}
for _, test in ipairs(tests) do
assert.same(test.output, Spec.group(test.input))
end
end)
it("parses a section spec", function()
local tests = {
{
input = {
-- error from all files
source = "diagnostics",
groups = { "filename" },
filter = {
severity = 1,
},
sort = { "filename", "-pos" },
},
output = {
events = {},
source = "diagnostics",
groups = { { fields = { "filename" }, format = "{filename}" } },
sort = { { field = "filename" }, { field = "pos", desc = true } },
filter = { severity = 1 },
format = "{filename} {pos}",
},
},
}
for _, test in ipairs(tests) do
assert.same(test.output, Spec.section(test.input))
end
end)
end)