Regenerate nvim config
This commit is contained in:
@ -0,0 +1,6 @@
|
||||
class x: # Ignore comment
|
||||
|
||||
class y:
|
||||
def z(): # Ignore comment
|
||||
|
||||
class t:
|
||||
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<body>
|
||||
<!-- This file deliberately contains trailing whitespace -->
|
||||
<!-- Don't remove them -->
|
||||
<div>
|
||||
a
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,18 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
-- local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
local runner = Runner:new(it, "tests/indent/algorithm", {
|
||||
tabstop = 4,
|
||||
shiftwidth = 4,
|
||||
softtabstop = 4,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("test indent algorithm: ", function()
|
||||
describe("new line:", function()
|
||||
runner:new_line("trailing.py", { on_line = 1, text = "x: str", indent = 4 }, "indent next line, ignore comment")
|
||||
runner:new_line("trailing.py", { on_line = 4, text = "pass", indent = 8 }, "indent next line, ignore comment")
|
||||
runner:new_line("trailing.py", { on_line = 6, text = "pass", indent = 4 }, "indent next line, ignore whitespace")
|
||||
runner:new_line("trailing_whitespace.html", { on_line = 9, text = "x", indent = 8 }, "not ignore @indent.end")
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,7 @@
|
||||
void foo(int a,
|
||||
int b,
|
||||
int c);
|
||||
|
||||
void foo(int a,
|
||||
int b
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
int x[] = {
|
||||
1, 2, 3,
|
||||
4, 5,
|
||||
6
|
||||
};
|
||||
|
||||
int y[][2] = {
|
||||
{0, 1},
|
||||
{1, 2},
|
||||
{
|
||||
2,
|
||||
3
|
||||
},
|
||||
};
|
||||
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Function foo
|
||||
* @param[out] x output
|
||||
* @param[in] x input
|
||||
*/
|
||||
void foo(int *x, int y) {
|
||||
*x = y;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
struct foo {
|
||||
int x, y;
|
||||
};
|
||||
|
||||
struct foo bar(int x, int y) {
|
||||
return (struct foo) {
|
||||
.x = x,
|
||||
.y = y
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
void foo(int x)
|
||||
{
|
||||
if (x > 10) {
|
||||
return;
|
||||
} else if (x < -10) {
|
||||
x = -10;
|
||||
} else {
|
||||
x = -x;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
enum foo {
|
||||
A = 1,
|
||||
B,
|
||||
C,
|
||||
};
|
||||
@ -0,0 +1,12 @@
|
||||
void foo(int x, int y)
|
||||
{
|
||||
if ((x*x - y*y > 0) ||
|
||||
(x == 1 || y == 1) &&
|
||||
(x != 2 && y != 2)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
int z = (x + y) *
|
||||
(x - y);
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
int f1(int x) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int f2(int x)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int f3(
|
||||
int x
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int f4(
|
||||
int x,
|
||||
int y
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int f5(int x,
|
||||
int y)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
f6(int x, int y)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
int foo(int x){
|
||||
if (x > 10)
|
||||
return 10;
|
||||
|
||||
if (x > 10)
|
||||
return 10;
|
||||
else
|
||||
return 10;
|
||||
|
||||
if (x > 20)
|
||||
return 20;
|
||||
else if (x > 15)
|
||||
return 15;
|
||||
else
|
||||
return 10;
|
||||
}
|
||||
|
||||
int bar(int x){
|
||||
if (x > 20)
|
||||
return 10;
|
||||
else {
|
||||
return 10;
|
||||
}
|
||||
|
||||
if (x > 20)
|
||||
return 10;
|
||||
else if (x > 10) {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
int baz(int x){
|
||||
if (x > 20)
|
||||
return x;
|
||||
else if(x > 10) {
|
||||
if(x > 10) {
|
||||
if(x > 10)
|
||||
return 10;
|
||||
if(x > 5) {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x > 20)
|
||||
if (x > 19)
|
||||
if(x > 18)
|
||||
return x;
|
||||
|
||||
if (x > 20)
|
||||
return x;
|
||||
else if (x > 19) {
|
||||
if (x > 18)
|
||||
return x;
|
||||
else
|
||||
x++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
int main() {
|
||||
if (1) {
|
||||
foobar();
|
||||
} else {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
statement;
|
||||
statement;
|
||||
@ -0,0 +1,7 @@
|
||||
int main(){
|
||||
for(;;)
|
||||
}
|
||||
|
||||
int foo(){
|
||||
while(1)
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
int main(){
|
||||
if(1){
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *a = "a" "b" "c" D;
|
||||
|
||||
static int a, b, c;
|
||||
a = b = c = 0;
|
||||
|
||||
static int d = 0, e = 0, f = 0;
|
||||
|
||||
int main(void) {
|
||||
printf("String" PRIu64 "\n", (uint64_t)0);
|
||||
printf("String" AND_ERROR_NODE "and string");
|
||||
fflush(stdout);
|
||||
a = 0; b = 0; c = 0;
|
||||
int x = 0; int y = 0; int z = 0;
|
||||
foo(1, 2);
|
||||
x++;
|
||||
a = b
|
||||
= c
|
||||
= d;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
int foo(int x)
|
||||
{
|
||||
goto error;
|
||||
return 0;
|
||||
error:
|
||||
return 1;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
void foo(int x)
|
||||
{
|
||||
while (x > 0) {
|
||||
x--;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
x++;
|
||||
} while (x < 0);
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
int foo(int x) {
|
||||
if (x > 10)
|
||||
return 10;
|
||||
else
|
||||
return x;
|
||||
|
||||
while (1)
|
||||
x++;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
x--;
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
void foo(int x)
|
||||
{
|
||||
x = x + 1;
|
||||
#if 1
|
||||
x = x + 2;
|
||||
#else
|
||||
x = x + 3;
|
||||
#endif
|
||||
x = x + 4;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
#define FOO(x) do { \
|
||||
x = x + 1; \
|
||||
x = x / 2; \
|
||||
} while (x > 0);
|
||||
|
||||
void foo(int x)
|
||||
{
|
||||
FOO(x);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
const char *a = "hello \
|
||||
world";
|
||||
|
||||
const char *b = "hello "
|
||||
"world";
|
||||
@ -0,0 +1,11 @@
|
||||
struct foo {
|
||||
int a;
|
||||
struct bar {
|
||||
int x;
|
||||
} b;
|
||||
};
|
||||
|
||||
union baz {
|
||||
struct foo;
|
||||
int x;
|
||||
};
|
||||
@ -0,0 +1,16 @@
|
||||
void foo(int x) {
|
||||
switch (x) {
|
||||
case 1:
|
||||
x += 1;
|
||||
break;
|
||||
case 2: x += 2;
|
||||
break;
|
||||
case 3: x += 3; break;
|
||||
case 4: {
|
||||
x += 4;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
x = -x;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
void foo(int x)
|
||||
{
|
||||
int y = (x > 10) ? 10
|
||||
: (x < -10) ? -10
|
||||
: x;
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
/*
|
||||
*
|
||||
@ -0,0 +1,93 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
local runner = Runner:new(it, "tests/indent/c", {
|
||||
tabstop = 4,
|
||||
shiftwidth = 4,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent C:", function()
|
||||
describe("whole file:", function()
|
||||
runner:whole_file(".", {
|
||||
expected_failures = {
|
||||
"./preproc_func.c",
|
||||
"./unfinished_comment.c",
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
runner:new_line("array.c", { on_line = 2, text = "0,", indent = 4 })
|
||||
runner:new_line("compound_lit.c", { on_line = 7, text = ".z = 5,", indent = 8 })
|
||||
runner:new_line("cond.c", { on_line = 3, text = "x++;", indent = 8 })
|
||||
runner:new_line("cond.c", { on_line = 6, text = "x++;", indent = 8 })
|
||||
runner:new_line("cond.c", { on_line = 8, text = "x++;", indent = 8 })
|
||||
runner:new_line("cond.c", { on_line = 9, text = "x++;", indent = 4 })
|
||||
runner:new_line("expr.c", { on_line = 10, text = "2 *", indent = 8 })
|
||||
runner:new_line("func.c", { on_line = 17, text = "int z,", indent = 4 })
|
||||
runner:new_line("label.c", { on_line = 3, text = "normal:", indent = 0 })
|
||||
runner:new_line("loop.c", { on_line = 3, text = "x++;", indent = 8 })
|
||||
runner:new_line("preproc_cond.c", { on_line = 5, text = "x++;", indent = 4 })
|
||||
runner:new_line("preproc_func.c", { on_line = 3, text = "x++; \\", indent = 8 }, "expected failure", XFAIL)
|
||||
runner:new_line("string.c", { on_line = 1, text = "brave new \\", indent = 0 })
|
||||
runner:new_line("string.c", { on_line = 4, text = '"brave new "', indent = 4 })
|
||||
runner:new_line("struct.c", { on_line = 4, text = "int y;", indent = 8 })
|
||||
runner:new_line("switch.c", { on_line = 3, text = "x++;", indent = 12 })
|
||||
runner:new_line("ternary.c", { on_line = 4, text = ": (x == 0) : 0", indent = 8 })
|
||||
runner:new_line("issue-1568.c", { on_line = 4, text = "x++;", indent = 8 })
|
||||
runner:new_line("issue-2086.c", { on_line = 3, text = "}", indent = 0 })
|
||||
runner:new_line("issue-4079.c", { on_line = 2, text = "return;", indent = 8 })
|
||||
runner:new_line("issue-4079.c", { on_line = 2, text = "{", indent = 4 })
|
||||
runner:new_line("issue-4079.c", { on_line = 6, text = "{", indent = 4 })
|
||||
runner:new_line("issue-4117.c", { on_line = 3, text = "else", indent = 4 })
|
||||
-- the line after inserted one will be left with wrong indent but we only care about the inserted one
|
||||
for _, line in ipairs { 2, 4, 7, 10 } do
|
||||
runner:new_line("no_braces.c", { on_line = line, text = "x++;", indent = 8 })
|
||||
end
|
||||
for _, line in ipairs { 2, 5, 7, 10, 12, 14, 20, 22, 25, 27, 28, 33 } do
|
||||
runner:new_line("if_else.c", { on_line = line, text = "x++;", indent = 8 })
|
||||
end
|
||||
for _, line in ipairs { 3, 6, 8, 13, 15, 20, 23 } do
|
||||
runner:new_line("if_else.c", { on_line = line, text = "else", indent = 4 })
|
||||
end
|
||||
for _, info in ipairs {
|
||||
{ 36, 12 },
|
||||
{ 37, 16 },
|
||||
{ 38, 12 },
|
||||
{ 39, 16 },
|
||||
{ 41, 12 },
|
||||
{ 42, 8 },
|
||||
{ 45, 8 },
|
||||
{ 46, 12 },
|
||||
{ 47, 16 },
|
||||
{ 48, 4 },
|
||||
{ 52, 8 },
|
||||
{ 53, 12 },
|
||||
{ 54, 12 },
|
||||
} do
|
||||
runner:new_line("if_else.c", { on_line = info[1], text = "x++;", indent = info[2] })
|
||||
end
|
||||
-- dedent braces on new line
|
||||
for _, line in ipairs { 10, 12, 14 } do
|
||||
runner:new_line("if_else.c", { on_line = line, text = "{}", indent = 4 })
|
||||
end
|
||||
|
||||
for _, info in ipairs {
|
||||
{ 8, 0 },
|
||||
{ 10, 0 },
|
||||
{ 13, 4 },
|
||||
{ 14, 4 },
|
||||
{ 15, 4 },
|
||||
{ 16, 4 },
|
||||
{ 17, 4 },
|
||||
{ 18, 4 },
|
||||
{ 20, 8 },
|
||||
{ 21, 8 },
|
||||
{ 22, 4 },
|
||||
} do
|
||||
runner:new_line("issue-4525.c", { on_line = info[1], text = "x++;", indent = info[2] })
|
||||
end
|
||||
end)
|
||||
end)
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local run = Runner:new(it, "tests/indent/capnp", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent Cap'n Proto:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("test.capnp", { on_line = 31, text = "foo @0;", indent = 2 })
|
||||
run:new_line("test.capnp", { on_line = 96, text = "boolField = true,", indent = 4 })
|
||||
run:new_line("test.capnp", { on_line = 340, text = "grault @7 :UInt64;", indent = 8 })
|
||||
run:new_line("test.capnp", {
|
||||
on_line = 573,
|
||||
text = "call @0 Inner2(Text) -> (qux :Qux, gen :TestGenerics(TestAllTypes, TestAnyPointer));",
|
||||
indent = 4,
|
||||
})
|
||||
run:new_line("test.capnp", { on_line = 617, text = "foo @0 :Foo;", indent = 4 })
|
||||
run:new_line("test.capnp", { on_line = 654, text = "foo = (int16Field = 123),", indent = 4 })
|
||||
run:new_line("test.capnp", { on_line = 695, text = 'textField = "nested",', indent = 6 })
|
||||
run:new_line("test.capnp", { on_line = 970, text = "testTailCaller @4;", indent = 4 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,202 @@
|
||||
local M = {}
|
||||
|
||||
local assert = require "luassert"
|
||||
local say = require "say"
|
||||
local scan_dir = require("plenary.scandir").scan_dir
|
||||
local Path = require "plenary.path"
|
||||
|
||||
M.XFAIL = "xfail"
|
||||
|
||||
local function same_indent(state, arguments)
|
||||
local before = arguments[1]
|
||||
local after = arguments[2]
|
||||
|
||||
local ok = true
|
||||
local errors = { before = {}, after = {} }
|
||||
for line = 1, #before do
|
||||
if #string.match(before[line], "^%s*") ~= #string.match(after[line], "^%s*") then
|
||||
if before[line] and after[line] then
|
||||
-- store the actual indentation length for each line
|
||||
errors.before[line] = #string.match(before[line], "^%s*")
|
||||
errors.after[line] = #string.match(after[line], "^%s*")
|
||||
end
|
||||
ok = false
|
||||
end
|
||||
end
|
||||
|
||||
-- we will always use only a single argument, passing the other one in fmtargs
|
||||
arguments.fmtargs = { { errors = errors, other = after } }
|
||||
arguments.fmtargs[2] = { errors = errors, other = after }
|
||||
|
||||
return ok
|
||||
end
|
||||
|
||||
local function format_indent(arg, fmtargs)
|
||||
if not arg or not fmtargs then
|
||||
return
|
||||
end
|
||||
-- find minimal width if any line is longer
|
||||
local width = 40
|
||||
for _, line in ipairs(fmtargs.other) do
|
||||
width = #line > width and #line or width
|
||||
end
|
||||
|
||||
width = width + 3
|
||||
local header_fmt = "%8s %2s%-" .. tostring(width + 1) .. "s %s"
|
||||
local fmt = "%8s %2s |%-" .. tostring(width) .. "s |%s"
|
||||
|
||||
local output = { header_fmt:format("", "", "Found:", "Expected:") }
|
||||
|
||||
for i, line in ipairs(arg) do
|
||||
if fmtargs.errors.before[i] then
|
||||
local indents = string.format("%d vs %d", fmtargs.errors.after[i], fmtargs.errors.before[i])
|
||||
table.insert(output, fmt:format(indents, "=>", fmtargs.other[i], line))
|
||||
else
|
||||
table.insert(output, fmt:format("", "", fmtargs.other[i], line))
|
||||
end
|
||||
end
|
||||
|
||||
return table.concat(output, "\n")
|
||||
end
|
||||
|
||||
say:set_namespace "en"
|
||||
say:set("assertion.same_indent.positive", "Incorrect indentation\n%s")
|
||||
say:set("assertion.same_indent.negative", "Incorrect indentation\n%s")
|
||||
assert:register(
|
||||
"assertion",
|
||||
"same_indent",
|
||||
same_indent,
|
||||
"assertion.same_indent.positive",
|
||||
"assert.same_indent.negative"
|
||||
)
|
||||
|
||||
-- Custom assertion better suited for indentation diffs
|
||||
local function compare_indent(before, after, xfail)
|
||||
assert:add_formatter(format_indent)
|
||||
if xfail then
|
||||
io.stdout:write "Warning! Known failure of this test! Please help to fix it! "
|
||||
assert.is_not.same_indent(before, after)
|
||||
else
|
||||
assert.is.same_indent(before, after)
|
||||
end
|
||||
assert:remove_formatter(format_indent)
|
||||
end
|
||||
|
||||
local function set_buf_indent_opts(opts)
|
||||
local optnames = { "tabstop", "shiftwidth", "softtabstop", "expandtab", "filetype", "lispoptions" }
|
||||
for _, opt in ipairs(optnames) do
|
||||
if opts[opt] ~= nil then
|
||||
vim.bo[opt] = opts[opt]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.run_indent_test(file, runner, opts)
|
||||
assert.are.same(1, vim.fn.filereadable(file), string.format('File "%s" not readable', file))
|
||||
|
||||
-- load reference file
|
||||
vim.cmd(string.format("edit %s", file))
|
||||
vim.bo.indentexpr = "nvim_treesitter#indent()"
|
||||
local before = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
|
||||
assert.are.same("nvim_treesitter#indent()", vim.bo.indentexpr)
|
||||
set_buf_indent_opts(opts)
|
||||
|
||||
-- perform the test
|
||||
runner()
|
||||
|
||||
-- get file content after the test
|
||||
local after = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
|
||||
-- clear any changes to avoid 'No write since last change (add ! to override)'
|
||||
vim.cmd "edit!"
|
||||
|
||||
return before, after
|
||||
end
|
||||
|
||||
function M.indent_whole_file(file, opts, xfail)
|
||||
local before, after = M.run_indent_test(file, function()
|
||||
vim.cmd "silent normal gg=G"
|
||||
end, opts)
|
||||
|
||||
compare_indent(before, after, xfail)
|
||||
end
|
||||
|
||||
-- Open a file, use `normal o` to insert a new line and compare results
|
||||
-- @param file path to the initial file
|
||||
-- @param spec a table with keys:
|
||||
-- on_line: line on which `normal o` is executed
|
||||
-- text: text inserted in the new line
|
||||
-- indent: expected indent before the inserted text (string or int)
|
||||
-- @param opts buffer options passed to set_buf_indent_opts
|
||||
function M.indent_new_line(file, spec, opts, xfail)
|
||||
local before, after = M.run_indent_test(file, function()
|
||||
-- move to the line and input the new one
|
||||
vim.cmd(string.format("normal! %dG", spec.on_line))
|
||||
vim.cmd(string.format("normal! o%s", spec.text))
|
||||
end, opts)
|
||||
|
||||
local indent = type(spec.indent) == "string" and spec.indent or string.rep(" ", spec.indent)
|
||||
table.insert(before, spec.on_line + 1, indent .. spec.text)
|
||||
|
||||
compare_indent(before, after, xfail)
|
||||
|
||||
before, after = M.run_indent_test(file, function()
|
||||
-- move to the line and input the new one
|
||||
vim.cmd(string.format("normal! %dG$", spec.on_line))
|
||||
vim.cmd(string.format(vim.api.nvim_replace_termcodes("normal! a<cr>%s", true, true, true), spec.text))
|
||||
end, opts)
|
||||
|
||||
indent = type(spec.indent) == "string" and spec.indent or string.rep(" ", spec.indent)
|
||||
table.insert(before, spec.on_line + 1, indent .. spec.text)
|
||||
|
||||
compare_indent(before, after, xfail)
|
||||
end
|
||||
|
||||
local Runner = {}
|
||||
Runner.__index = Runner
|
||||
|
||||
-- Helper to avoid boilerplate when defining tests
|
||||
-- @param it the "it" function that busted defines globally in spec files
|
||||
-- @param base_dir all other paths will be resolved relative to this directory
|
||||
-- @param buf_opts buffer options passed to set_buf_indent_opts
|
||||
function Runner:new(it, base_dir, buf_opts)
|
||||
local runner = {}
|
||||
runner.it = it
|
||||
runner.base_dir = Path:new(base_dir)
|
||||
runner.buf_opts = buf_opts
|
||||
return setmetatable(runner, self)
|
||||
end
|
||||
|
||||
function Runner:whole_file(dirs, opts)
|
||||
opts = opts or {}
|
||||
local expected_failures = opts.expected_failures or {}
|
||||
expected_failures = vim.tbl_map(function(f)
|
||||
return Path:new(f):make_relative(self.base_dir.filename)
|
||||
end, expected_failures)
|
||||
dirs = type(dirs) == "table" and dirs or { dirs }
|
||||
dirs = vim.tbl_map(function(dir)
|
||||
dir = self.base_dir / Path:new(dir)
|
||||
assert.is.same(1, vim.fn.isdirectory(dir.filename))
|
||||
return dir.filename
|
||||
end, dirs)
|
||||
local files = require("nvim-treesitter.compat").flatten(vim.tbl_map(scan_dir, dirs))
|
||||
for _, file in ipairs(files) do
|
||||
local relpath = Path:new(file):make_relative(self.base_dir.filename)
|
||||
self.it(relpath, function()
|
||||
M.indent_whole_file(file, self.buf_opts, vim.tbl_contains(expected_failures, relpath))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function Runner:new_line(file, spec, title, xfail)
|
||||
title = title and title or tostring(spec.on_line)
|
||||
self.it(string.format("%s[%s]", file, title), function()
|
||||
local path = self.base_dir / file
|
||||
M.indent_new_line(path.filename, spec, self.buf_opts, xfail)
|
||||
end)
|
||||
end
|
||||
|
||||
M.Runner = Runner
|
||||
|
||||
return M
|
||||
@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
public:
|
||||
int x;
|
||||
private:
|
||||
int y;
|
||||
};
|
||||
@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
int x;
|
||||
class Bar {
|
||||
int y;
|
||||
};
|
||||
Bar z;
|
||||
};
|
||||
@ -0,0 +1,9 @@
|
||||
class Foo
|
||||
{
|
||||
int x;
|
||||
class Bar
|
||||
{
|
||||
int y;
|
||||
};
|
||||
Bar z;
|
||||
};
|
||||
@ -0,0 +1,17 @@
|
||||
class Foo {
|
||||
|
||||
Foo(int a, int b, int c, int d)
|
||||
: m_a(a)
|
||||
, m_b(b)
|
||||
, m_c(c)
|
||||
, m_d(d) {}
|
||||
|
||||
Foo(int a, int b, int c) :
|
||||
m_a(a),
|
||||
m_b(b),
|
||||
m_c(c)
|
||||
{}
|
||||
|
||||
int m_a, m_b, m_c, m_d;
|
||||
};
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
void foo(int x) {
|
||||
std::cout << x
|
||||
<< x + 1
|
||||
<< x + 2;
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
-- will use both c/ and cpp/
|
||||
local run = Runner:new(it, "tests/indent", {
|
||||
tabstop = 4,
|
||||
shiftwidth = 4,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
filetype = "cpp",
|
||||
})
|
||||
|
||||
describe("indent C++:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file({ "c/", "cpp/" }, {
|
||||
expected_failures = {
|
||||
-- C
|
||||
"c/preproc_func.c",
|
||||
"c/unfinished_comment.c",
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("cpp/access.cpp", { on_line = 3, text = "protected:", indent = 0 })
|
||||
run:new_line("cpp/class.cpp", { on_line = 2, text = "using T = int;", indent = 4 })
|
||||
run:new_line("cpp/stream.cpp", { on_line = 5, text = "<< x + 3", indent = 8 })
|
||||
|
||||
-- TODO: find a clean way to import these from c_spec.lua
|
||||
run:new_line("c/array.c", { on_line = 2, text = "0,", indent = 4 })
|
||||
run:new_line("c/cond.c", { on_line = 3, text = "x++;", indent = 8 })
|
||||
run:new_line("c/cond.c", { on_line = 6, text = "x++;", indent = 8 })
|
||||
run:new_line("c/cond.c", { on_line = 8, text = "x++;", indent = 8 })
|
||||
run:new_line("c/cond.c", { on_line = 9, text = "x++;", indent = 4 })
|
||||
run:new_line("c/expr.c", { on_line = 10, text = "2 *", indent = 8 })
|
||||
run:new_line("c/func.c", { on_line = 17, text = "int z,", indent = 4 })
|
||||
run:new_line("c/label.c", { on_line = 3, text = "normal:", indent = 0 })
|
||||
run:new_line("c/loop.c", { on_line = 3, text = "x++;", indent = 8 })
|
||||
run:new_line("c/preproc_cond.c", { on_line = 5, text = "x++;", indent = 4 })
|
||||
run:new_line("c/preproc_func.c", { on_line = 3, text = "x++; \\", indent = 8 }, "expected failure", XFAIL)
|
||||
run:new_line("c/string.c", { on_line = 1, text = "brave new \\", indent = 0 })
|
||||
run:new_line("c/string.c", { on_line = 4, text = '"brave new "', indent = 4 })
|
||||
run:new_line("c/struct.c", { on_line = 4, text = "int y;", indent = 8 })
|
||||
run:new_line("c/switch.c", { on_line = 3, text = "x++;", indent = 12 })
|
||||
run:new_line("c/ternary.c", { on_line = 4, text = ": (x == 0) : 0", indent = 8 })
|
||||
-- the line after inserted one will be left with wrong indent but we only care about the inserted one
|
||||
run:new_line("c/no_braces.c", { on_line = 4, text = "x++;", indent = 8 })
|
||||
run:new_line("c/no_braces.c", { on_line = 7, text = "x++;", indent = 8 })
|
||||
run:new_line("c/no_braces.c", { on_line = 10, text = "x++;", indent = 8 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,3 @@
|
||||
.testo {
|
||||
color: green;
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
.testo {
|
||||
@ -0,0 +1,22 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local run = Runner:new(it, "tests/indent/css", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent CSS:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("open_block.css", { on_line = 1, text = "}", indent = 0 })
|
||||
run:new_line("open_block.css", { on_line = 1, text = "color: green;", indent = 2 })
|
||||
run:new_line("next_rule.css", { on_line = 3, text = ".next {", indent = 0 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,8 @@
|
||||
void main() {
|
||||
}
|
||||
|
||||
class Test {
|
||||
List<String> get progress => [
|
||||
'0',
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
class Something {
|
||||
final int number;
|
||||
final Function(int) write;
|
||||
|
||||
Something(this.number, this.write);
|
||||
}
|
||||
|
||||
void test() {
|
||||
Something(
|
||||
1,
|
||||
(int number) {
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
// Example method that causes an issue with indentation on usage
|
||||
void someMethod(
|
||||
void onSuccess(),
|
||||
void onError(Exception ex, StackTrace stackTrace),
|
||||
) {
|
||||
try {} catch (_, __) {}
|
||||
}
|
||||
|
||||
void main() {
|
||||
someMethod(() {
|
||||
}, (Exception ex, StackTrace stackTrace) {
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
void test() {
|
||||
switch(a) {
|
||||
case 1:
|
||||
}
|
||||
}
|
||||
|
||||
void test() {
|
||||
switch(a) {
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
void test_break_dedent() {
|
||||
switch(x) {
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
switch(y) {
|
||||
case 2:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_multi_case() {
|
||||
switch(x) {
|
||||
case 1:
|
||||
case 2:
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
void test() {
|
||||
try{
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #4632
|
||||
class Test {
|
||||
void test(){
|
||||
try {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
local run = Runner:new(it, "tests/indent/dart", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 2,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent Lua:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {
|
||||
"./multiple_arguments.dart",
|
||||
"./class.dart",
|
||||
"./class_function_argument.dart",
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("class.dart", { on_line = 4, text = "int five;", indent = 2 })
|
||||
run:new_line("class.dart", { on_line = 6, text = "'100'", indent = 8 }, "expected failure", XFAIL)
|
||||
run:new_line("class.dart", { on_line = 7, text = "int five = 5", indent = 2 }, "expected failure", XFAIL)
|
||||
run:new_line("try.dart", { on_line = 2, text = "var x;", indent = 4 })
|
||||
for _, content in ipairs { "var x;", "var x" } do
|
||||
run:new_line("try.dart", { on_line = 10, text = content, indent = 6 })
|
||||
end
|
||||
run:new_line("switch.dart", { on_line = 3, text = "x = 1;", indent = 6 })
|
||||
run:new_line("switch.dart", { on_line = 9, text = "x = 1;", indent = 6 })
|
||||
run:new_line("switch.dart", { on_line = 3, text = "case 2:", indent = 4 })
|
||||
run:new_line("switch.dart", { on_line = 16, text = "abc;", indent = 4 })
|
||||
run:new_line("switch.dart", { on_line = 20, text = "abc;", indent = 4 })
|
||||
run:new_line("switch.dart", { on_line = 28, text = "y++;", indent = 6 })
|
||||
|
||||
run:new_line("multiple_arguments.dart", { on_line = 10, text = "var x;", indent = 4 })
|
||||
run:new_line(
|
||||
"multiple_arguments.dart",
|
||||
{ on_line = 11, text = "var x;", indent = 4 },
|
||||
"expected failure issue #4637",
|
||||
XFAIL
|
||||
)
|
||||
run:new_line("class_function_argument.dart", { on_line = 11, text = "}", indent = 4 })
|
||||
end)
|
||||
@ -0,0 +1,8 @@
|
||||
digraph {
|
||||
node [
|
||||
shape=ellipse,
|
||||
];
|
||||
subgraph sub {
|
||||
a1 -> a2 -> a3;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local run = Runner:new(it, "tests/indent/dot", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent dot:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("test.dot", { on_line = 1, text = "node [", indent = 2 })
|
||||
run:new_line("test.dot", { on_line = 2, text = "shape=ellipse,", indent = 4 })
|
||||
run:new_line("test.dot", { on_line = 4, text = "subgraph sub {", indent = 2 })
|
||||
run:new_line("test.dot", { on_line = 5, text = "a1 -> a2 -> a3;", indent = 4 })
|
||||
run:new_line("test.dot", { on_line = 6, text = "}", indent = 2 })
|
||||
run:new_line("test.dot", { on_line = 7, text = "}", indent = 0 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,2 @@
|
||||
let a = [
|
||||
]
|
||||
@ -0,0 +1,4 @@
|
||||
if_this_is_correct &&
|
||||
run_this_thing()
|
||||
.filter()
|
||||
.map()
|
||||
@ -0,0 +1,6 @@
|
||||
const itemById = Array.from(
|
||||
new Set()
|
||||
).reduce((byId, item) => {
|
||||
byId[item.id] = item
|
||||
return result;
|
||||
}, {})
|
||||
@ -0,0 +1,20 @@
|
||||
class IndentTest {
|
||||
async isEqual(paramOne, paramTwo) {
|
||||
if (paramOne === paramTwo) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
async isNotEqual(
|
||||
paramOne,
|
||||
paramTwo,
|
||||
) {
|
||||
if (paramOne !== paramTwo) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
const arrow_func = (
|
||||
a,
|
||||
b,
|
||||
c
|
||||
) => {
|
||||
log(a, b, c)
|
||||
}
|
||||
|
||||
const arrow_func_without_brace = (a, b, c) =>
|
||||
log(
|
||||
a,
|
||||
b,
|
||||
c
|
||||
)
|
||||
|
||||
function func_def(
|
||||
a,
|
||||
b,
|
||||
{ c = '' }
|
||||
) {
|
||||
log(a, b, c)
|
||||
}
|
||||
|
||||
func_call(
|
||||
a,
|
||||
(b) => b
|
||||
)
|
||||
|
||||
chained_func_call()
|
||||
.map()
|
||||
.filter()
|
||||
|
||||
func_call(
|
||||
chained_func_call()
|
||||
.map()
|
||||
.filter()
|
||||
)
|
||||
|
||||
function prepare_list_fetcher(filter) {
|
||||
return Object.assign(
|
||||
async () =>
|
||||
(
|
||||
await http.get('/list', {
|
||||
params: {
|
||||
filter: filter,
|
||||
},
|
||||
})
|
||||
).data,
|
||||
{ key: ['/list', filter] }
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
if (cond1) {
|
||||
do_1()
|
||||
|
||||
if (cond1a) {
|
||||
do_1a()
|
||||
} else {
|
||||
do_1_fallback()
|
||||
}
|
||||
} else if (cond2) {
|
||||
do_2()
|
||||
} else {
|
||||
do_fallback()
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
function test() {
|
||||
return [
|
||||
{
|
||||
test: "test",
|
||||
test_one: "test",
|
||||
},
|
||||
{
|
||||
test: "test",
|
||||
test_one: "test",
|
||||
},
|
||||
{
|
||||
test: "test",
|
||||
test_one: "test",
|
||||
},
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
class A {
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
const obj = {
|
||||
a: 1,
|
||||
b: "2",
|
||||
["c"]: `three`
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
switch (variable) {
|
||||
case 'case1':
|
||||
foo();
|
||||
break;
|
||||
|
||||
default:
|
||||
bar();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
const value =
|
||||
condition
|
||||
? typeof number === 'string'
|
||||
? Number(number)
|
||||
: number
|
||||
: null;
|
||||
@ -0,0 +1,8 @@
|
||||
try {
|
||||
throw Error()
|
||||
} catch (err) {
|
||||
throw error
|
||||
} finally {
|
||||
console.log("42")
|
||||
}
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
let a =
|
||||
if_this_is_right() && then_this()
|
||||
|
||||
a = func_call()
|
||||
.map()
|
||||
.filter()
|
||||
@ -0,0 +1,16 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
var x := 2
|
||||
for i in range(x):
|
||||
prints(i)
|
||||
|
||||
while x > 0:
|
||||
print(x)
|
||||
|
||||
if x > 0:
|
||||
print("if test")
|
||||
elif x < 0:
|
||||
print("if test")
|
||||
else:
|
||||
print("if test")
|
||||
@ -0,0 +1,20 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local run = Runner:new(it, "tests/indent/gdscript", {
|
||||
tabstop = 4,
|
||||
shiftwidth = 4,
|
||||
softtabstop = 0,
|
||||
expandtab = false,
|
||||
})
|
||||
|
||||
describe("indent GDScript:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("basic_blocks.gd", { on_line = 1, text = "var member := 0", indent = 0 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,7 @@
|
||||
fn() {
|
||||
fn() {
|
||||
fn() {
|
||||
True
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
pub fn main() {
|
||||
assert Ok(i) =
|
||||
parse_int("123")
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
pub fn main() {
|
||||
True &&
|
||||
False
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
pub fn main() {
|
||||
case 1 {
|
||||
1 -> "One"
|
||||
2 -> {
|
||||
case 2 {
|
||||
2 -> "Two"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
pub const foo =
|
||||
"bar"
|
||||
@ -0,0 +1,15 @@
|
||||
import gleam/io
|
||||
|
||||
pub fn main() {
|
||||
io.println("Hello from main!")
|
||||
}
|
||||
|
||||
fn hidden() {
|
||||
io.println("Hello from hidden!")
|
||||
}
|
||||
|
||||
pub external fn inspect(a) -> a =
|
||||
"Elixir.IO" "inspect"
|
||||
|
||||
external fn inspect(a) -> a =
|
||||
"Elixir.IO" "inspect"
|
||||
@ -0,0 +1,4 @@
|
||||
import foo.{
|
||||
Bar,
|
||||
baz,
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
pub fn main() {
|
||||
let string =
|
||||
"string"
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
pub fn main() {
|
||||
[
|
||||
a,
|
||||
..[
|
||||
b,
|
||||
..[
|
||||
c,
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
pub fn main() {
|
||||
one()
|
||||
|> two()
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
pub fn main() {
|
||||
todo(
|
||||
"Foo"
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
pub fn main() {
|
||||
#(
|
||||
a,
|
||||
#(
|
||||
b,
|
||||
#(
|
||||
c
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
pub type Cat {
|
||||
Cat(name: String, cuteness: Int)
|
||||
}
|
||||
|
||||
type User {
|
||||
LoggedIn(name: String)
|
||||
Guest
|
||||
}
|
||||
|
||||
pub opaque type Counter {
|
||||
Counter(value: Int)
|
||||
}
|
||||
|
||||
pub type Headers =
|
||||
List(#(String, String))
|
||||
|
||||
type Headers =
|
||||
List(#(String, String))
|
||||
@ -0,0 +1,127 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local run = Runner:new(it, "tests/indent/gleam", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 2,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent Gleam:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file "."
|
||||
end)
|
||||
describe("new line:", function()
|
||||
run:new_line("type.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 2, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 3, text = "//", indent = 0 })
|
||||
run:new_line("type.gleam", { on_line = 4, text = "//", indent = 0 })
|
||||
run:new_line("type.gleam", { on_line = 5, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 6, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 7, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 8, text = "//", indent = 0 })
|
||||
run:new_line("type.gleam", { on_line = 9, text = "//", indent = 0 })
|
||||
run:new_line("type.gleam", { on_line = 10, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 11, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 12, text = "//", indent = 0 })
|
||||
run:new_line("type.gleam", { on_line = 13, text = "//", indent = 0 })
|
||||
run:new_line("type.gleam", { on_line = 14, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 15, text = "//", indent = 0 })
|
||||
run:new_line("type.gleam", { on_line = 16, text = "//", indent = 0 })
|
||||
run:new_line("type.gleam", { on_line = 17, text = "//", indent = 2 })
|
||||
run:new_line("type.gleam", { on_line = 18, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("function.gleam", { on_line = 1, text = "//", indent = 0 })
|
||||
run:new_line("function.gleam", { on_line = 2, text = "//", indent = 0 })
|
||||
run:new_line("function.gleam", { on_line = 3, text = "//", indent = 2 })
|
||||
run:new_line("function.gleam", { on_line = 4, text = "//", indent = 2 })
|
||||
run:new_line("function.gleam", { on_line = 5, text = "//", indent = 0 })
|
||||
run:new_line("function.gleam", { on_line = 6, text = "//", indent = 0 })
|
||||
run:new_line("function.gleam", { on_line = 7, text = "//", indent = 2 })
|
||||
run:new_line("function.gleam", { on_line = 8, text = "//", indent = 2 })
|
||||
run:new_line("function.gleam", { on_line = 9, text = "//", indent = 0 })
|
||||
run:new_line("function.gleam", { on_line = 10, text = "//", indent = 0 })
|
||||
run:new_line("function.gleam", { on_line = 11, text = "//", indent = 2 })
|
||||
run:new_line("function.gleam", { on_line = 12, text = "//", indent = 2 })
|
||||
run:new_line("function.gleam", { on_line = 13, text = "//", indent = 2 })
|
||||
run:new_line("function.gleam", { on_line = 14, text = "//", indent = 2 })
|
||||
run:new_line("function.gleam", { on_line = 15, text = "//", indent = 2 })
|
||||
|
||||
run:new_line("list.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("list.gleam", { on_line = 2, text = "//", indent = 4 })
|
||||
run:new_line("list.gleam", { on_line = 3, text = "//", indent = 4 })
|
||||
run:new_line("list.gleam", { on_line = 4, text = "//", indent = 6 })
|
||||
run:new_line("list.gleam", { on_line = 5, text = "//", indent = 6 })
|
||||
run:new_line("list.gleam", { on_line = 6, text = "//", indent = 8 })
|
||||
run:new_line("list.gleam", { on_line = 7, text = "//", indent = 8 })
|
||||
run:new_line("list.gleam", { on_line = 8, text = "//", indent = 6 })
|
||||
run:new_line("list.gleam", { on_line = 9, text = "//", indent = 4 })
|
||||
run:new_line("list.gleam", { on_line = 10, text = "//", indent = 2 })
|
||||
run:new_line("list.gleam", { on_line = 11, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("tuple.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("tuple.gleam", { on_line = 2, text = "//", indent = 4 })
|
||||
run:new_line("tuple.gleam", { on_line = 3, text = "//", indent = 4 })
|
||||
run:new_line("tuple.gleam", { on_line = 4, text = "//", indent = 6 })
|
||||
run:new_line("tuple.gleam", { on_line = 5, text = "//", indent = 6 })
|
||||
run:new_line("tuple.gleam", { on_line = 6, text = "//", indent = 8 })
|
||||
run:new_line("tuple.gleam", { on_line = 7, text = "//", indent = 8 })
|
||||
run:new_line("tuple.gleam", { on_line = 8, text = "//", indent = 6 })
|
||||
run:new_line("tuple.gleam", { on_line = 9, text = "//", indent = 4 })
|
||||
run:new_line("tuple.gleam", { on_line = 10, text = "//", indent = 2 })
|
||||
run:new_line("tuple.gleam", { on_line = 11, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("case.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("case.gleam", { on_line = 2, text = "//", indent = 4 })
|
||||
run:new_line("case.gleam", { on_line = 3, text = "//", indent = 4 })
|
||||
run:new_line("case.gleam", { on_line = 4, text = "//", indent = 6 })
|
||||
run:new_line("case.gleam", { on_line = 5, text = "//", indent = 8 })
|
||||
run:new_line("case.gleam", { on_line = 6, text = "//", indent = 8 })
|
||||
run:new_line("case.gleam", { on_line = 7, text = "//", indent = 6 })
|
||||
run:new_line("case.gleam", { on_line = 8, text = "//", indent = 4 })
|
||||
run:new_line("case.gleam", { on_line = 9, text = "//", indent = 2 })
|
||||
run:new_line("case.gleam", { on_line = 10, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("let.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("let.gleam", { on_line = 2, text = "//", indent = 4 })
|
||||
run:new_line("let.gleam", { on_line = 3, text = "//", indent = 4 })
|
||||
run:new_line("let.gleam", { on_line = 4, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("pipe.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("pipe.gleam", { on_line = 2, text = "//", indent = 2 })
|
||||
run:new_line("pipe.gleam", { on_line = 3, text = "//", indent = 2 })
|
||||
run:new_line("pipe.gleam", { on_line = 4, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("binary_expression.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("binary_expression.gleam", { on_line = 2, text = "//", indent = 4 })
|
||||
run:new_line("binary_expression.gleam", { on_line = 3, text = "//", indent = 4 })
|
||||
run:new_line("binary_expression.gleam", { on_line = 4, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("import.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("import.gleam", { on_line = 2, text = "//", indent = 2 })
|
||||
run:new_line("import.gleam", { on_line = 3, text = "//", indent = 2 })
|
||||
run:new_line("import.gleam", { on_line = 4, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("constant.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("constant.gleam", { on_line = 2, text = "//", indent = 2 })
|
||||
|
||||
run:new_line("assert.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("assert.gleam", { on_line = 2, text = "//", indent = 4 })
|
||||
run:new_line("assert.gleam", { on_line = 3, text = "//", indent = 2 })
|
||||
run:new_line("assert.gleam", { on_line = 4, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("todo.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("todo.gleam", { on_line = 2, text = "//", indent = 4 })
|
||||
run:new_line("todo.gleam", { on_line = 3, text = "//", indent = 4 })
|
||||
run:new_line("todo.gleam", { on_line = 4, text = "//", indent = 2 })
|
||||
run:new_line("todo.gleam", { on_line = 5, text = "//", indent = 0 })
|
||||
|
||||
run:new_line("anonymous_function.gleam", { on_line = 1, text = "//", indent = 2 })
|
||||
run:new_line("anonymous_function.gleam", { on_line = 2, text = "//", indent = 4 })
|
||||
run:new_line("anonymous_function.gleam", { on_line = 3, text = "//", indent = 6 })
|
||||
run:new_line("anonymous_function.gleam", { on_line = 4, text = "//", indent = 6 })
|
||||
run:new_line("anonymous_function.gleam", { on_line = 5, text = "//", indent = 4 })
|
||||
run:new_line("anonymous_function.gleam", { on_line = 6, text = "//", indent = 2 })
|
||||
run:new_line("anonymous_function.gleam", { on_line = 7, text = "//", indent = 0 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
const (
|
||||
ExampleOne = iota
|
||||
ExampleTwo
|
||||
ExampleThree
|
||||
)
|
||||
@ -0,0 +1,8 @@
|
||||
// https://github.com/nvim-treesitter/nvim-treesitter/issues/2369
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func new_line() {
|
||||
fmt.Println("Hello, World!")
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
// https://github.com/nvim-treesitter/nvim-treesitter/issues/2369
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func goodIndent(param string) {
|
||||
fmt.Println("typing o here works as expected")
|
||||
}
|
||||
|
||||
func badIndent(
|
||||
param string, // this is the difference
|
||||
) {
|
||||
fmt.Println("typing o here triggers bad indent")
|
||||
foo(bar,
|
||||
baz,
|
||||
call,
|
||||
stop,
|
||||
please)
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
func correct(word string) {
|
||||
switch word {
|
||||
|
||||
} // <---
|
||||
select {
|
||||
|
||||
} // <---
|
||||
}
|
||||
|
||||
func test() {
|
||||
cases := []struct {
|
||||
first, second string
|
||||
} {
|
||||
{"Hello", "World"},
|
||||
}
|
||||
|
||||
for range cases {
|
||||
println("random stuff")
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
var (
|
||||
thing = 1
|
||||
thingTwo = 2
|
||||
) // <-- This paren should be at 0 instead of indented
|
||||
|
||||
var (
|
||||
thing = 1
|
||||
thingTwo = 2
|
||||
)
|
||||
|
||||
func main() {
|
||||
// It should be
|
||||
var (
|
||||
thing = 1
|
||||
thingTwo = 2
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
// issue #4248
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func test(ch byte) {
|
||||
ctx := context.TODO()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
fmt.Println("indentation")
|
||||
default:
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
// issue #2166
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func test(ch byte) {
|
||||
fmt.Println("hey!")
|
||||
switch ch {
|
||||
case 'l':
|
||||
return
|
||||
}
|
||||
|
||||
var i interface{}
|
||||
switch i.(type) {
|
||||
case int:
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
--local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
local run = Runner:new(it, "tests/indent/go", {
|
||||
tabstop = 4,
|
||||
shiftwidth = 4,
|
||||
softtabstop = 4,
|
||||
expandtab = false,
|
||||
})
|
||||
|
||||
describe("indent Go:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new lines:", function()
|
||||
run:new_line("issue-2369.go", { on_line = 13, text = "// some comment", indent = 1 })
|
||||
run:new_line("issue-2369-newline.go", { on_line = 8, text = "// comment", indent = 0 })
|
||||
run:new_line("const_declaration.go", { on_line = 3, text = "Constant", indent = 1 })
|
||||
run:new_line("const_declaration.go", { on_line = 7, text = "func main() {", indent = 0 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,6 @@
|
||||
query Me {
|
||||
me {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
--local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
local run = Runner:new(it, "tests/indent/graphql", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent GraphQL:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function() end)
|
||||
end)
|
||||
@ -0,0 +1,4 @@
|
||||
<div>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,12 @@
|
||||
<head>
|
||||
<style>
|
||||
a {
|
||||
stroke-linecap: round;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const foo = "bar"
|
||||
</script>
|
||||
</body>
|
||||
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<br/>
|
||||
<button
|
||||
id = "123"
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,8 @@
|
||||
<meta charset="UTF-8">
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta
|
||||
charset="UTF-8"
|
||||
</head>
|
||||
</html>
|
||||
@ -0,0 +1,28 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
local runner = Runner:new(it, "tests/indent/html", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent HTML:", function()
|
||||
describe("whole file:", function()
|
||||
runner:whole_file "."
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
runner:new_line("start_tag.html", { on_line = 1, text = "anything", indent = 0 })
|
||||
runner:new_line("start_tag.html", { on_line = 4, text = "anything", indent = 4 })
|
||||
runner:new_line("start_tag.html", { on_line = 6, text = "charset = utf-8", indent = 6 })
|
||||
runner:new_line("start_tag.html", { on_line = 6, text = ">", indent = 4 })
|
||||
runner:new_line("start_tag.html", { on_line = 6, text = "/>", indent = 4 })
|
||||
runner:new_line("issue-3986.html", { on_line = 3, text = "indent once", indent = 2 })
|
||||
runner:new_line("self_closing_tag.html", { on_line = 10, text = "Something", indent = 4 })
|
||||
runner:new_line("self_closing_tag.html", { on_line = 12, text = "disabled", indent = 6 })
|
||||
runner:new_line("self_closing_tag.html", { on_line = 12, text = "/>", indent = 4 })
|
||||
runner:new_line("script_style.html", { on_line = 5, text = "body", indent = 2 })
|
||||
runner:new_line("script_style.html", { on_line = 6, text = "<div></div>", indent = 2 })
|
||||
runner:new_line("script_style.html", { on_line = 9, text = "const x = 1", indent = 2 })
|
||||
runner:new_line("script_style.html", { on_line = 11, text = "Text", indent = 2 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,3 @@
|
||||
abstract public @interface Foo {
|
||||
abstract public String Bar();
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
@ContextConfiguration(
|
||||
classes = {
|
||||
WireMockConfig.class,
|
||||
}
|
||||
)
|
||||
public class Foo {
|
||||
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
@Nothing
|
||||
public class Testo {
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
public class Testo {
|
||||
public Testo(
|
||||
String a
|
||||
) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
public enum Foo {
|
||||
THING_A,
|
||||
THING_C;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
@Nothing
|
||||
public enum Testo {
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
public interface Foo {
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
// https://github.com/nvim-treesitter/nvim-treesitter/issues/2571
|
||||
class Testo {
|
||||
void foo() {
|
||||
System.out.println("foo");
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user