diff options
Diffstat (limited to 'lua')
53 files changed, 0 insertions, 885 deletions
diff --git a/lua/tests/indent/c/array.c b/lua/tests/indent/c/array.c deleted file mode 100644 index 5bb67c2c8..000000000 --- a/lua/tests/indent/c/array.c +++ /dev/null @@ -1,14 +0,0 @@ -int x[] = { - 1, 2, 3, - 4, 5, - 6 -}; - -int y[][2] = { - {0, 1}, - {1, 2}, - { - 2, - 3 - }, -}; diff --git a/lua/tests/indent/c/comment.c b/lua/tests/indent/c/comment.c deleted file mode 100644 index b32de8218..000000000 --- a/lua/tests/indent/c/comment.c +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Function foo - * @param[out] x output - * @param[in] x input - */ -void foo(int *x, int y) { - *x = y; -} diff --git a/lua/tests/indent/c/cond.c b/lua/tests/indent/c/cond.c deleted file mode 100644 index 1ecb22d98..000000000 --- a/lua/tests/indent/c/cond.c +++ /dev/null @@ -1,10 +0,0 @@ -void foo(int x) -{ - if (x > 10) { - return; - } else if (x < -10) { - x = -10; - } else { - x = -x; - } -} diff --git a/lua/tests/indent/c/enum.c b/lua/tests/indent/c/enum.c deleted file mode 100644 index bb6b0dc30..000000000 --- a/lua/tests/indent/c/enum.c +++ /dev/null @@ -1,5 +0,0 @@ -enum foo { - A = 1, - B, - C, -}; diff --git a/lua/tests/indent/c/expr.c b/lua/tests/indent/c/expr.c deleted file mode 100644 index cafb11120..000000000 --- a/lua/tests/indent/c/expr.c +++ /dev/null @@ -1,12 +0,0 @@ -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); -} diff --git a/lua/tests/indent/c/func.c b/lua/tests/indent/c/func.c deleted file mode 100644 index c188acc01..000000000 --- a/lua/tests/indent/c/func.c +++ /dev/null @@ -1,33 +0,0 @@ -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; -} diff --git a/lua/tests/indent/c/label.c b/lua/tests/indent/c/label.c deleted file mode 100644 index 36b40e23a..000000000 --- a/lua/tests/indent/c/label.c +++ /dev/null @@ -1,7 +0,0 @@ -int foo(int x) -{ - goto error; - return 0; -error: - return 1; -} diff --git a/lua/tests/indent/c/loop.c b/lua/tests/indent/c/loop.c deleted file mode 100644 index facaebb6b..000000000 --- a/lua/tests/indent/c/loop.c +++ /dev/null @@ -1,16 +0,0 @@ -void foo(int x) -{ - while (x > 0) { - x--; - continue; - } - - for (int i = 0; i < 5; ++i) { - x++; - break; - } - - do { - x++; - } while (x < 0); -} diff --git a/lua/tests/indent/c/no_braces.c b/lua/tests/indent/c/no_braces.c deleted file mode 100644 index 544ac01d0..000000000 --- a/lua/tests/indent/c/no_braces.c +++ /dev/null @@ -1,12 +0,0 @@ -int foo(int x) { - if (x > 10) - return 10; - else - return x; - - while (1) - x++; - - for (int i = 0; i < 3; ++i) - x--; -} diff --git a/lua/tests/indent/c/preproc_cond.c b/lua/tests/indent/c/preproc_cond.c deleted file mode 100644 index b85440aa9..000000000 --- a/lua/tests/indent/c/preproc_cond.c +++ /dev/null @@ -1,10 +0,0 @@ -void foo(int x) -{ - x = x + 1; -#if 1 - x = x + 2; -#else - x = x + 3; -#endif - x = x + 4; -} diff --git a/lua/tests/indent/c/preproc_func.c b/lua/tests/indent/c/preproc_func.c deleted file mode 100644 index f1f38feb9..000000000 --- a/lua/tests/indent/c/preproc_func.c +++ /dev/null @@ -1,9 +0,0 @@ -#define FOO(x) do { \ - x = x + 1; \ - x = x / 2; \ - } while (x > 0); - -void foo(int x) -{ - FOO(x); -} diff --git a/lua/tests/indent/c/string.c b/lua/tests/indent/c/string.c deleted file mode 100644 index 2d5177e00..000000000 --- a/lua/tests/indent/c/string.c +++ /dev/null @@ -1,5 +0,0 @@ -const char *a = "hello \ -world"; - -const char *b = "hello " - "world"; diff --git a/lua/tests/indent/c/struct.c b/lua/tests/indent/c/struct.c deleted file mode 100644 index 8cc2b6b21..000000000 --- a/lua/tests/indent/c/struct.c +++ /dev/null @@ -1,11 +0,0 @@ -struct foo { - int a; - struct bar { - int x; - } b; -}; - -union baz { - struct foo; - int x; -}; diff --git a/lua/tests/indent/c/switch.c b/lua/tests/indent/c/switch.c deleted file mode 100644 index 4003bdb1d..000000000 --- a/lua/tests/indent/c/switch.c +++ /dev/null @@ -1,16 +0,0 @@ -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; - } -} diff --git a/lua/tests/indent/c/ternary.c b/lua/tests/indent/c/ternary.c deleted file mode 100644 index 2e40b382e..000000000 --- a/lua/tests/indent/c/ternary.c +++ /dev/null @@ -1,6 +0,0 @@ -void foo(int x) -{ - int y = (x > 10) ? 10 - : (x < -10) ? -10 - : x; -} diff --git a/lua/tests/indent/c_spec.lua b/lua/tests/indent/c_spec.lua deleted file mode 100644 index 2850023ab..000000000 --- a/lua/tests/indent/c_spec.lua +++ /dev/null @@ -1,49 +0,0 @@ -local whole_file = require('nvim-treesitter.test_utils').indent_whole_file -local new_line = require('nvim-treesitter.test_utils').indent_new_line -local scan_dir = require('plenary.scandir').scan_dir - -local opts = { - tabstop = 4, - shiftwidth = 4, - softtabstop = 0, - expandtab = true, -} - -describe('indent C:', function() - describe('whole file:', function() - local files = scan_dir('lua/tests/indent/c'); - for _, file in ipairs(files) do - it(vim.fn.fnamemodify(file, ':t'), function() - whole_file(file, opts) - end) - end - end) - - describe('new line:', function() - local run = function(file, spec, title) - title = title and title or tostring(spec.on_line) - it(string.format('%s[%s]', file, title), function() - new_line('lua/tests/indent/c/' .. file, spec, opts) - end) - end - - run('array.c', { on_line = 2, text = '0,', indent = 4 }) - run('cond.c', { on_line = 3, text = 'x++;', indent = 8 }) - run('cond.c', { on_line = 8, text = 'x++;', indent = 8 }) - run('expr.c', { on_line = 10, text = '2 *', indent = 8 }) - run('func.c', { on_line = 17, text = 'int z,', indent = 4 }) - run('label.c', { on_line = 3, text = 'normal:', indent = 0 }) - run('loop.c', { on_line = 3, text = 'x++;', indent = 8 }) - run('preproc_cond.c', { on_line = 5, text = 'x++;', indent = 4 }) - run('preproc_func.c', { on_line = 3, text = 'x++; \\', indent = 8 }) - run('string.c', { on_line = 1, text = 'brave new \\', indent = 0 }) - run('string.c', { on_line = 4, text = '"brave new "', indent = 4 }) - run('struct.c', { on_line = 4, text = 'int y;', indent = 8 }) - run('switch.c', { on_line = 3, text = 'x++;', indent = 12 }) - run('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('no_braces.c', { on_line = 4, text = 'x++;', indent = 8 }) - run('no_braces.c', { on_line = 7, text = 'x++;', indent = 8 }) - run('no_braces.c', { on_line = 10, text = 'x++;', indent = 8 }) - end) -end) diff --git a/lua/tests/indent/cpp/access.cpp b/lua/tests/indent/cpp/access.cpp deleted file mode 100644 index abdb846ce..000000000 --- a/lua/tests/indent/cpp/access.cpp +++ /dev/null @@ -1,6 +0,0 @@ -class Foo { -public: - int x; -private: - int y; -}; diff --git a/lua/tests/indent/cpp/class.cpp b/lua/tests/indent/cpp/class.cpp deleted file mode 100644 index cd8382190..000000000 --- a/lua/tests/indent/cpp/class.cpp +++ /dev/null @@ -1,7 +0,0 @@ -class Foo { - int x; - class Bar { - int y; - }; - Bar z; -}; diff --git a/lua/tests/indent/cpp/stream.cpp b/lua/tests/indent/cpp/stream.cpp deleted file mode 100644 index a619dfa69..000000000 --- a/lua/tests/indent/cpp/stream.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include <iostream> - -void foo(int x) { - std::cout << x - << x + 1 - << x + 2; -} diff --git a/lua/tests/indent/cpp_spec.lua b/lua/tests/indent/cpp_spec.lua deleted file mode 100644 index fd1f35799..000000000 --- a/lua/tests/indent/cpp_spec.lua +++ /dev/null @@ -1,62 +0,0 @@ -local whole_file = require('nvim-treesitter.test_utils').indent_whole_file -local new_line = require('nvim-treesitter.test_utils').indent_new_line -local scan_dir = require('plenary.scandir').scan_dir -local Path = require('plenary.path') - -local opts = { - tabstop = 4, - shiftwidth = 4, - softtabstop = 0, - expandtab = true, - filetype = 'cpp', -} - -local get_name = function(file) - return Path:new(file):make_relative('lua/tests/indent') -end - -describe('indent C++:', function() - describe('whole file:', function() - local files = scan_dir('lua/tests/indent/c'); - vim.list_extend(files, scan_dir('lua/tests/indent/cpp')) - - for _, file in ipairs(files) do - it(get_name(file), function() - whole_file(file, opts) - end) - end - end) - - describe('new line:', function() - local run = function(file, spec, title) - title = title and title or tostring(spec.on_line) - it(string.format('%s[%s]', get_name(file), title), function() - new_line(file, spec, opts) - end) - end - - run('lua/tests/indent/cpp/access.cpp', { on_line = 3, text = 'protected:', indent = 0 }) - run('lua/tests/indent/cpp/class.cpp', { on_line = 2, text = 'using T = int;', indent = 4 }) - run('lua/tests/indent/cpp/stream.cpp', { on_line = 5, text = '<< x + 3', indent = 8 }) - - -- TODO: find a clean way to import these from c_spec.lua - run('lua/tests/indent/c/array.c', { on_line = 2, text = '0,', indent = 4 }) - run('lua/tests/indent/c/cond.c', { on_line = 3, text = 'x++;', indent = 8 }) - run('lua/tests/indent/c/cond.c', { on_line = 8, text = 'x++;', indent = 8 }) - run('lua/tests/indent/c/expr.c', { on_line = 10, text = '2 *', indent = 8 }) - run('lua/tests/indent/c/func.c', { on_line = 17, text = 'int z,', indent = 4 }) - run('lua/tests/indent/c/label.c', { on_line = 3, text = 'normal:', indent = 0 }) - run('lua/tests/indent/c/loop.c', { on_line = 3, text = 'x++;', indent = 8 }) - run('lua/tests/indent/c/preproc_cond.c', { on_line = 5, text = 'x++;', indent = 4 }) - run('lua/tests/indent/c/preproc_func.c', { on_line = 3, text = 'x++; \\', indent = 8 }) - run('lua/tests/indent/c/string.c', { on_line = 1, text = 'brave new \\', indent = 0 }) - run('lua/tests/indent/c/string.c', { on_line = 4, text = '"brave new "', indent = 4 }) - run('lua/tests/indent/c/struct.c', { on_line = 4, text = 'int y;', indent = 8 }) - run('lua/tests/indent/c/switch.c', { on_line = 3, text = 'x++;', indent = 12 }) - run('lua/tests/indent/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('lua/tests/indent/c/no_braces.c', { on_line = 4, text = 'x++;', indent = 8 }) - run('lua/tests/indent/c/no_braces.c', { on_line = 7, text = 'x++;', indent = 8 }) - run('lua/tests/indent/c/no_braces.c', { on_line = 10, text = 'x++;', indent = 8 }) - end) -end) diff --git a/lua/tests/indent/lua/comment.lua b/lua/tests/indent/lua/comment.lua deleted file mode 100644 index 9f3624e1e..000000000 --- a/lua/tests/indent/lua/comment.lua +++ /dev/null @@ -1,7 +0,0 @@ --- some --- comment - ---[[ - another - comment ---]] diff --git a/lua/tests/indent/lua/cond.lua b/lua/tests/indent/lua/cond.lua deleted file mode 100644 index dfae37f05..000000000 --- a/lua/tests/indent/lua/cond.lua +++ /dev/null @@ -1,12 +0,0 @@ -local x = 10 - -if x > 3 then - x = 3 -elseif x < 3 then - x = -3 -else - if x > 0 then - x = 1 - end - x = 0 -end diff --git a/lua/tests/indent/lua/func.lua b/lua/tests/indent/lua/func.lua deleted file mode 100644 index 1f95ca97a..000000000 --- a/lua/tests/indent/lua/func.lua +++ /dev/null @@ -1,9 +0,0 @@ -function foo(x) - local bar = function(a, b, c) - return a + b + c - end - return bar( - x, - 1, - 2) -end diff --git a/lua/tests/indent/lua/loop.lua b/lua/tests/indent/lua/loop.lua deleted file mode 100644 index 7f5402d1e..000000000 --- a/lua/tests/indent/lua/loop.lua +++ /dev/null @@ -1,14 +0,0 @@ -local x = 1 - -while x < 10 do - x = x + 1 - break -end - -for i = 1,3 do - x = x + i -end - -repeat - x = x + 1 -until x > 100 diff --git a/lua/tests/indent/lua/string.lua b/lua/tests/indent/lua/string.lua deleted file mode 100644 index adfebf76a..000000000 --- a/lua/tests/indent/lua/string.lua +++ /dev/null @@ -1,5 +0,0 @@ -local s = [[ -a - multiline - string -]] diff --git a/lua/tests/indent/lua/table.lua b/lua/tests/indent/lua/table.lua deleted file mode 100644 index d53504b45..000000000 --- a/lua/tests/indent/lua/table.lua +++ /dev/null @@ -1,10 +0,0 @@ -local a = { - x = 1, - y = 2, - z = { - 1, 2, 3, - }, - ['hello world'] = { - 1, 2, 3 - } -} diff --git a/lua/tests/indent/lua_spec.lua b/lua/tests/indent/lua_spec.lua deleted file mode 100644 index 3a2a7cb7b..000000000 --- a/lua/tests/indent/lua_spec.lua +++ /dev/null @@ -1,48 +0,0 @@ -local whole_file = require('nvim-treesitter.test_utils').indent_whole_file -local new_line = require('nvim-treesitter.test_utils').indent_new_line -local scan_dir = require('plenary.scandir').scan_dir - -local opts = { - tabstop = 2, - shiftwidth = 2, - softtabstop = 0, - expandtab = true, -} - -describe('indent Lua:', function() - describe('whole file:', function() - local files = scan_dir('lua/tests/indent/lua'); - for _, file in ipairs(files) do - it(vim.fn.fnamemodify(file, ':t'), function() - whole_file(file, opts) - end) - end - end) - - describe('new line:', function() - local run = function(file, spec, title) - title = title and title or tostring(spec.on_line) - it(string.format('%s[%s]', file, title), function() - new_line('lua/tests/indent/lua/' .. file, spec, opts) - end) - end - - run('comment.lua', { on_line = 1, text = 'line', indent = '-- ' }) - run('comment.lua', { on_line = 5, text = 'multiline', indent = ' ' }) - run('func.lua', { on_line = 1, text = 'x = x + 1', indent = 2 }) - run('func.lua', { on_line = 2, text = 'y = y + 1', indent = 4 }) - run('func.lua', { on_line = 5, text = '3,', indent = 4 }) - run('string.lua', { on_line = 1, text = 'x', indent = 0 }) - run('string.lua', { on_line = 2, text = 'x', indent = 0 }) - run('string.lua', { on_line = 3, text = 'x', indent = 2 }) - run('string.lua', { on_line = 4, text = 'x', indent = 4 }) - run('table.lua', { on_line = 1, text = 'b = 0,', indent = 2 }) - run('table.lua', { on_line = 5, text = '4,', indent = 4 }) - run('table.lua', { on_line = 7, text = '4,', indent = 4 }) - run('loop.lua', { on_line = 4, text = 'x = x + 1', indent = 2 }) - run('cond.lua', { on_line = 5, text = 'x = x + 1', indent = 2 }) - run('cond.lua', { on_line = 7, text = 'x = x + 1', indent = 2 }) - run('cond.lua', { on_line = 8, text = 'x = x + 1', indent = 4 }) - end) -end) - diff --git a/lua/tests/indent/python/aligned_indent.py b/lua/tests/indent/python/aligned_indent.py deleted file mode 100644 index 2a4b827f4..000000000 --- a/lua/tests/indent/python/aligned_indent.py +++ /dev/null @@ -1,11 +0,0 @@ -def aligned_indent(arg1, - arg2): - pass - -aligned_indent(1, - 2) - - -aligned_indent(1, - 2 - ) diff --git a/lua/tests/indent/python/basic_blocks.py b/lua/tests/indent/python/basic_blocks.py deleted file mode 100644 index 4f36359bd..000000000 --- a/lua/tests/indent/python/basic_blocks.py +++ /dev/null @@ -1,14 +0,0 @@ -from os import ( - path, - name as OsName -) - -def foo(x): - pass - -class Foo: - def __init__(self): - pass - - def foo(self): - pass diff --git a/lua/tests/indent/python/basic_collections.py b/lua/tests/indent/python/basic_collections.py deleted file mode 100644 index 1582b9059..000000000 --- a/lua/tests/indent/python/basic_collections.py +++ /dev/null @@ -1,23 +0,0 @@ -# list -a = [ - 1, 2, - 3 -] - -# set -b = { - 3, - 4, -} - -# dict -c = { - 'a': 'b', - 'c': 1, -} - -# tuple -d = ( - 1, - 2, -) diff --git a/lua/tests/indent/python/branches.py b/lua/tests/indent/python/branches.py deleted file mode 100644 index 7ce106bd7..000000000 --- a/lua/tests/indent/python/branches.py +++ /dev/null @@ -1,27 +0,0 @@ -a = [ - 1, 2, 3] - -b = [ - x + 1 - for x in range(3)] - -c = [[[ - 1 -]]] - -d = [[[ - 4]]] - -e = [[ - 1], 2, 3] - -def foo(x, y): - pass - -foo( - a, - b) - -if (a and - b): - pass diff --git a/lua/tests/indent/python/comprehensions.py b/lua/tests/indent/python/comprehensions.py deleted file mode 100644 index 53c3961e1..000000000 --- a/lua/tests/indent/python/comprehensions.py +++ /dev/null @@ -1,25 +0,0 @@ -# list -a = [ - x + 1 for x in range(3) -] - -# dict -b = { - x: x + 1 for x in range(3) -} - -# generator -c = ( - x * x for x in range(3) -) - -# set -d = { - x + x for x in range(3) -} - -# other styles -e = [ - x + 1 for x - in range(3) -] diff --git a/lua/tests/indent/python/control_flow.py b/lua/tests/indent/python/control_flow.py deleted file mode 100644 index c8cd2541b..000000000 --- a/lua/tests/indent/python/control_flow.py +++ /dev/null @@ -1,22 +0,0 @@ -if a == a: - x = 1 -elif b: - x = 2 -else: - x = 3 - -while False: - pass - -for _ in range(3): - pass - -with open('/tmp/f', 'w') as f: - pass - -try: - pass -except: - pass -finally: - pass diff --git a/lua/tests/indent/python/hanging_indent.py b/lua/tests/indent/python/hanging_indent.py deleted file mode 100644 index 4d46ebed0..000000000 --- a/lua/tests/indent/python/hanging_indent.py +++ /dev/null @@ -1,6 +0,0 @@ -def hanging_indent( - arg1, arg2): - pass - -hanging_indent( - 1, 2) diff --git a/lua/tests/indent/python/join_lines.py b/lua/tests/indent/python/join_lines.py deleted file mode 100644 index 491b2cc37..000000000 --- a/lua/tests/indent/python/join_lines.py +++ /dev/null @@ -1,8 +0,0 @@ -a = 2 \ - + 2 - -b = 'hello' \ - 'world' - -c = lambda x: \ - x + 3 diff --git a/lua/tests/indent/python/nested_collections.py b/lua/tests/indent/python/nested_collections.py deleted file mode 100644 index 292a65a00..000000000 --- a/lua/tests/indent/python/nested_collections.py +++ /dev/null @@ -1,41 +0,0 @@ -a = [ - 1, - [ - 2, - [ - 3 - ] - ] -] - -b = [ - 1, [[ - 3 - ], - ] -] - -c = [[[ - 3 -]]] - -d = { - 'a': [ - 2, 3 - ], - 'c': ( - [1, 2, 3], - [ - 2, - 4 - ], { - 6, - 8 - } - ) -} - -e = (1, 2, - 3, 4, - 5, 6 - ) diff --git a/lua/tests/indent/python/strings.py b/lua/tests/indent/python/strings.py deleted file mode 100644 index 0eb088fa6..000000000 --- a/lua/tests/indent/python/strings.py +++ /dev/null @@ -1,17 +0,0 @@ -a = """ - String A -""" - -b = """ -String B -""" - -c = """ - String C - """ - -d = """ - String D -String D - String D - """ diff --git a/lua/tests/indent/python_spec.lua b/lua/tests/indent/python_spec.lua deleted file mode 100644 index 2927ad4e5..000000000 --- a/lua/tests/indent/python_spec.lua +++ /dev/null @@ -1,52 +0,0 @@ -local whole_file = require('nvim-treesitter.test_utils').indent_whole_file -local new_line = require('nvim-treesitter.test_utils').indent_new_line -local scan_dir = require('plenary.scandir').scan_dir - -local opts = { - tabstop = 4, - shiftwidth = 4, - softtabstop = 0, - expandtab = true, -} - -describe('indent Python:', function() - describe('whole file:', function() - local files = scan_dir('lua/tests/indent/python'); - for _, file in ipairs(files) do - it(vim.fn.fnamemodify(file, ':t'), function() - whole_file(file, opts) - end) - end - end) - - describe('new line:', function() - local run = function(file, spec, title) - title = title and title or tostring(spec.on_line) - it(string.format('%s[%s]', file, title), function() - new_line('lua/tests/indent/python/' .. file, spec, opts) - end) - end - - run('aligned_indent.py', { on_line = 1, text = 'arg3,', indent = 19 }) - run('basic_blocks.py', { on_line = 1, text = 'wait,', indent = 4 }) - run('basic_blocks.py', { on_line = 6, text = 'x += 1', indent = 4 }) - run('basic_blocks.py', { on_line = 10, text = 'x += 1', indent = 8 }) - run('basic_blocks.py', { on_line = 7, text = 'x += 1', indent = 4 }, '7, after last line of a block') - run('basic_blocks.py', { on_line = 11, text = 'x += 1', indent = 8 }, '11, after last line of a block') - run('basic_collections.py', { on_line = 3, text = '4,', indent = 4 }) - run('comprehensions.py', { on_line = 8, text = 'if x != 2', indent = 4 }) - run('control_flow.py', { on_line = 23, text = 'x = 4', indent = 4 }) - run('hanging_indent.py', { on_line = 1, text = 'arg0,', indent = 8 }) - run('hanging_indent.py', { on_line = 5, text = '0,', indent = 4 }) - run('join_lines.py', { on_line = 1, text = '+ 1 \\', indent = 4 }) - run('join_lines.py', { on_line = 4, text = '+ 1 \\', indent = 4 }) - run('join_lines.py', { on_line = 7, text = '+ 1 \\', indent = 4 }) - run('nested_collections.py', { on_line = 5, text = '0,', indent = 12 }) - run('nested_collections.py', { on_line = 6, text = ',0', indent = 12 }) - run('nested_collections.py', { on_line = 29, text = '[1, 2],', indent = 12 }) - run('nested_collections.py', { on_line = 39, text = '0,', indent = 5 }) - run('strings.py', { on_line = 14, text = 'x', indent = 4 }) - run('strings.py', { on_line = 15, text = 'x', indent = 0 }) - run('strings.py', { on_line = 16, text = 'x', indent = 8 }) - end) -end) diff --git a/lua/tests/indent/rust/array.rs b/lua/tests/indent/rust/array.rs deleted file mode 100644 index 68344e0ee..000000000 --- a/lua/tests/indent/rust/array.rs +++ /dev/null @@ -1,11 +0,0 @@ -const X: [i32; 2] = [ - 1, - 2, -]; - -fn foo() { - let _x = [ - 1, - 2, - ]; -} diff --git a/lua/tests/indent/rust/comment.rs b/lua/tests/indent/rust/comment.rs deleted file mode 100644 index 334793dfa..000000000 --- a/lua/tests/indent/rust/comment.rs +++ /dev/null @@ -1,7 +0,0 @@ -/// Function foo -/// -/// Description of -/// function foo. -fn foo(x: i32, y: i32) -> i32 { - x + y -} diff --git a/lua/tests/indent/rust/cond.rs b/lua/tests/indent/rust/cond.rs deleted file mode 100644 index eb96a48f7..000000000 --- a/lua/tests/indent/rust/cond.rs +++ /dev/null @@ -1,17 +0,0 @@ -fn foo(mut x: i32) -> i32 { - if x > 10 { - return 10; - } else if x == 10 { - return 9; - } else { - x += 10; - } - - if x < 0 { - if x == -1 { - return 0; - } - } - - 0 -} diff --git a/lua/tests/indent/rust/enum.rs b/lua/tests/indent/rust/enum.rs deleted file mode 100644 index 996f07d21..000000000 --- a/lua/tests/indent/rust/enum.rs +++ /dev/null @@ -1,11 +0,0 @@ -enum Foo { - X, - Y( - char, - char, - ), - Z { - x: u32, - y: u32, - }, -} diff --git a/lua/tests/indent/rust/func.rs b/lua/tests/indent/rust/func.rs deleted file mode 100644 index 4c9d40b26..000000000 --- a/lua/tests/indent/rust/func.rs +++ /dev/null @@ -1,10 +0,0 @@ -fn foo() -> i32 { - 1 -} - -fn foo( - x: i32, - y: i32 -) -> i32 { - x + y -} diff --git a/lua/tests/indent/rust/impl.rs b/lua/tests/indent/rust/impl.rs deleted file mode 100644 index 2525c2e5b..000000000 --- a/lua/tests/indent/rust/impl.rs +++ /dev/null @@ -1,7 +0,0 @@ -struct Foo; - -impl Foo { - fn foo() -> i32 { - 1 - } -} diff --git a/lua/tests/indent/rust/loop.rs b/lua/tests/indent/rust/loop.rs deleted file mode 100644 index eb845bc0f..000000000 --- a/lua/tests/indent/rust/loop.rs +++ /dev/null @@ -1,19 +0,0 @@ -fn foo(mut x: i32) { - while x > 0 { - x -= 1; - } - - for i in 0..3 { - x += 1; - } - - loop { - x += 1; - - if x < 100 { - continue; - } - - break; - } -} diff --git a/lua/tests/indent/rust/macro.rs b/lua/tests/indent/rust/macro.rs deleted file mode 100644 index 608e157fc..000000000 --- a/lua/tests/indent/rust/macro.rs +++ /dev/null @@ -1,13 +0,0 @@ -macro_rules! foo { - ($a:ident, $b:ident, $c:ident) => { - struct $a; - struct $b; - }, - ($a:ident) => { - struct $a; - }, -} - -foo! { - A -} diff --git a/lua/tests/indent/rust/match.rs b/lua/tests/indent/rust/match.rs deleted file mode 100644 index 438ba6d5f..000000000 --- a/lua/tests/indent/rust/match.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn foo(x: i32) -> i32 { - match x { - 0 => 1, - 1 => { - 2 - }, - 2 | 3 => { - 4 - } - } -} diff --git a/lua/tests/indent/rust/mod.rs b/lua/tests/indent/rust/mod.rs deleted file mode 100644 index cc7f2c8e6..000000000 --- a/lua/tests/indent/rust/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod foo { - const X: i32 = 1; - - mod bar { - - const Y: i32 = 1; - } -} diff --git a/lua/tests/indent/rust/string.rs b/lua/tests/indent/rust/string.rs deleted file mode 100644 index 4d60663dd..000000000 --- a/lua/tests/indent/rust/string.rs +++ /dev/null @@ -1,12 +0,0 @@ -fn foo() { - let a = "hello -world"; - - let b = "hello\ - world"; - - let c = r#" - hello - world - "#; -} diff --git a/lua/tests/indent/rust/struct.rs b/lua/tests/indent/rust/struct.rs deleted file mode 100644 index f3828977f..000000000 --- a/lua/tests/indent/rust/struct.rs +++ /dev/null @@ -1,4 +0,0 @@ -struct Foo { - x: u32, - y: u32, -} diff --git a/lua/tests/indent/rust/trait.rs b/lua/tests/indent/rust/trait.rs deleted file mode 100644 index fb5fc7ea8..000000000 --- a/lua/tests/indent/rust/trait.rs +++ /dev/null @@ -1,11 +0,0 @@ -struct Foo; - -trait Bar { - fn bar(); -} - -impl Bar for Foo { - fn bar() { - - } -} diff --git a/lua/tests/indent/rust/where.rs b/lua/tests/indent/rust/where.rs deleted file mode 100644 index 08c1b196d..000000000 --- a/lua/tests/indent/rust/where.rs +++ /dev/null @@ -1,21 +0,0 @@ -fn foo<T>(t: T) -> i32 -where - T: Debug, -{ - 1 -} - -fn foo<T>(t: T) -> i32 where - T: Debug, -{ - 1 -} - -struct Foo<T>(T); - -impl<T> Write for Foo<T> -where - T: Debug, -{ - -} diff --git a/lua/tests/indent/rust_spec.lua b/lua/tests/indent/rust_spec.lua deleted file mode 100644 index 120b6771b..000000000 --- a/lua/tests/indent/rust_spec.lua +++ /dev/null @@ -1,67 +0,0 @@ -local whole_file = require('nvim-treesitter.test_utils').indent_whole_file -local new_line = require('nvim-treesitter.test_utils').indent_new_line -local scan_dir = require('plenary.scandir').scan_dir - -local opts = { - tabstop = 4, - shiftwidth = 4, - softtabstop = 0, - expandtab = true, -} - -describe('indent Rust:', function() - describe('whole file:', function() - local files = scan_dir('lua/tests/indent/rust'); - for _, file in ipairs(files) do - it(vim.fn.fnamemodify(file, ':t'), function() - whole_file(file, opts) - end) - end - end) - - describe('new line:', function() - local run = function(file, spec, title) - title = title and title or tostring(spec.on_line) - it(string.format('%s[%s]', file, title), function() - new_line('lua/tests/indent/rust/' .. file, spec, opts) - end) - end - - run('array.rs', { on_line = 2, text = '0,', indent = 4 }) - run('array.rs', { on_line = 8, text = '0,', indent = 8 }) - run('comment.rs', { on_line = 3, text = 'a', indent = '/// ' }) - run('cond.rs', { on_line = 11, text = 'x += 1;', indent = 12 }) - run('cond.rs', { on_line = 2, text = 'x += 1;', indent = 8 }) - run('cond.rs', { on_line = 4, text = 'x += 1;', indent = 8 }) - run('cond.rs', { on_line = 6, text = 'x += 1;', indent = 8 }) - run('enum.rs', { on_line = 2, text = 'Q,', indent = 4 }) - run('enum.rs', { on_line = 4, text = 'i32,', indent = 8 }) - run('enum.rs', { on_line = 8, text = 'z: u32,', indent = 8 }) - run('func.rs', { on_line = 1, text = 'let _x = 1;', indent = 4 }) - run('func.rs', { on_line = 6, text = 'z: i32,', indent = 4 }) - run('impl.rs', { on_line = 3, text = 'const FOO: u32 = 1;', indent = 4 }) - run('impl.rs', { on_line = 4, text = 'let _x = 1;', indent = 8 }) - run('loop.rs', { on_line = 10, text = 'x += 1;', indent = 8 }) - run('loop.rs', { on_line = 2, text = 'x += 1;', indent = 8 }) - run('loop.rs', { on_line = 6, text = 'x += 1;', indent = 8 }) - run('macro.rs', { on_line = 1, text = '() => {},', indent = 4 }) - run('macro.rs', { on_line = 12, text = 'B C', indent = 4 }) - run('macro.rs', { on_line = 2, text = 'struct $c;', indent = 8 }) - run('match.rs', { on_line = 2, text = '-1 => -1,', indent = 8 }) - run('match.rs', { on_line = 7, text = 'let y = 1;', indent = 12 }) - run('mod.rs', { on_line = 1, text = 'const Z: i32 = 1;', indent = 4 }) - run('mod.rs', { on_line = 2, text = 'const Z: i32 = 1;', indent = 4 }) - run('mod.rs', { on_line = 6, text = 'const Z: i32 = 1;', indent = 8 }) - run('string.rs', { on_line = 2, text = 'brave new', indent = 0 }) - run('string.rs', { on_line = 5, text = 'brave new \\', indent = 8 }) - run('string.rs', { on_line = 9, text = 'brave new \\', indent = 8 }) - run('struct.rs', { on_line = 1, text = 'z: i32,', indent = 4 }) - run('struct.rs', { on_line = 2, text = 'z: i32,', indent = 4 }) - run('trait.rs', { on_line = 4, text = 'fn baz();', indent = 4 }) - run('trait.rs', { on_line = 7, text = 'fn baz();', indent = 4 }) - run('trait.rs', { on_line = 8, text = '()', indent = 8 }) - run('where.rs', { on_line = 17, text = 'T: Debug,', indent = 4 }) - run('where.rs', { on_line = 2, text = 'T: Debug,', indent = 4 }) - run('where.rs', { on_line = 9, text = 'T: Debug,', indent = 4 }) - end) -end) |
