diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2025-02-21 02:02:32 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2025-02-26 23:06:22 +0100 |
commit | be1fbe38b31b6046d396407c4efbf238941c6b08 (patch) | |
tree | 697a429f5ac903d766c2faaf5044fa7a16eeea77 /test/functional/treesitter | |
parent | f4921e2b7deb4812414998a521c33f920f571c20 (diff) | |
download | rneovim-be1fbe38b31b6046d396407c4efbf238941c6b08.tar.gz rneovim-be1fbe38b31b6046d396407c4efbf238941c6b08.tar.bz2 rneovim-be1fbe38b31b6046d396407c4efbf238941c6b08.zip |
feat(lua): vim.text.indent()
Problem:
Indenting text is a common task in plugins/scripts for
presentation/formatting, yet vim has no way of doing it (especially
"dedent", and especially non-buffer text).
Solution:
Introduce `vim.text.indent()`. It sets the *exact* indentation because
that's a more difficult (and thus more useful) task than merely
"increasing the current indent" (which is somewhat easy with a `gsub()`
one-liner).
Diffstat (limited to 'test/functional/treesitter')
-rw-r--r-- | test/functional/treesitter/highlight_spec.lua | 16 | ||||
-rw-r--r-- | test/functional/treesitter/node_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/treesitter/query_spec.lua | 28 |
3 files changed, 24 insertions, 24 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua index 6d59368a24..f3a321aa88 100644 --- a/test/functional/treesitter/highlight_spec.lua +++ b/test/functional/treesitter/highlight_spec.lua @@ -786,9 +786,9 @@ describe('treesitter highlighting (C)', function() screen:expect({ grid = [[ - {26:int x = 4;} | - {26:int y = 5;} | - {26:int z = 6;} | + {26:int x = 4;} | + {26:int y = 5;} | + {26:int z = 6;} | ^ | {1:~ }|*13 | @@ -815,7 +815,7 @@ describe('treesitter highlighting (C)', function() screen:expect({ grid = [[ - void foo(int {15:*}{25:bar}); | + void foo(int {15:*}{25:bar}); | ^ | {1:~ }|*15 | @@ -883,8 +883,8 @@ describe('treesitter highlighting (lua)', function() screen:expect({ grid = [[ - {15:local} {25:ffi} {15:=} {16:require(}{26:'ffi'}{16:)} | - {25:ffi}{16:.}{25:cdef}{16:(}{26:"}{16:int}{26: }{16:(}{15:*}{26:fun}{16:)(int,}{26: }{16:char}{26: }{15:*}{16:);}{26:"}{16:)} | + {15:local} {25:ffi} {15:=} {16:require(}{26:'ffi'}{16:)} | + {25:ffi}{16:.}{25:cdef}{16:(}{26:"}{16:int}{26: }{16:(}{15:*}{26:fun}{16:)(int,}{26: }{16:char}{26: }{15:*}{16:);}{26:"}{16:)} | ^ | {1:~ }|*14 | @@ -1185,7 +1185,7 @@ printf('Hello World!'); {18:```}{15:c} | {25:printf}{16:(}{26:'Hello World!'}{16:);} | {18:```} | - ^ | + ^ | | ]], }) @@ -1271,7 +1271,7 @@ printf('Hello World!'); {8:120 }{25:printf}{16:(}{26:'Hello World!'}{16:);} | {8:122 } | {8:124 }{25:printf}{16:(}{26:'Hello World!'}{16:);} | - {8:126 } ^ | + {8:126 }^ | | ]]) end) diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua index 2a1fa497af..2f6f810ef2 100644 --- a/test/functional/treesitter/node_spec.lua +++ b/test/functional/treesitter/node_spec.lua @@ -82,7 +82,7 @@ describe('treesitter node API', function() ]]) exec_lua(function() - local parser = vim.treesitter.get_parser(0, 'c') + local parser = assert(vim.treesitter.get_parser(0, 'c')) local tree = parser:parse()[1] _G.root = tree:root() vim.treesitter.language.inspect('c') @@ -92,7 +92,7 @@ describe('treesitter node API', function() end end) - exec_lua 'node = root:descendant_for_range(0, 11, 0, 16)' + exec_lua 'node = root:descendant_for_range(0, 9, 0, 14)' eq('int x', lua_eval('node_text(node)')) exec_lua 'node = node:next_sibling()' diff --git a/test/functional/treesitter/query_spec.lua b/test/functional/treesitter/query_spec.lua index 6db0ffe5a0..be9c60b8ad 100644 --- a/test/functional/treesitter/query_spec.lua +++ b/test/functional/treesitter/query_spec.lua @@ -386,8 +386,8 @@ void ui_refresh(void) [[((primitive_type) @c-keyword (#any-of? @c-keyword "int" "float"))]] ) eq({ - { 'c-keyword', 'primitive_type', { 2, 2, 2, 5 }, 'int' }, - { 'c-keyword', 'primitive_type', { 3, 4, 3, 7 }, 'int' }, + { 'c-keyword', 'primitive_type', { 2, 0, 2, 3 }, 'int' }, + { 'c-keyword', 'primitive_type', { 3, 2, 3, 5 }, 'int' }, }, res0) local res1 = exec_lua( @@ -401,9 +401,9 @@ void ui_refresh(void) ]] ) eq({ - { 'fizzbuzz-strings', 'string_literal', { 6, 15, 6, 38 }, '"number= %d FizzBuzz\\n"' }, - { 'fizzbuzz-strings', 'string_literal', { 8, 15, 8, 34 }, '"number= %d Fizz\\n"' }, - { 'fizzbuzz-strings', 'string_literal', { 10, 15, 10, 34 }, '"number= %d Buzz\\n"' }, + { 'fizzbuzz-strings', 'string_literal', { 6, 13, 6, 36 }, '"number= %d FizzBuzz\\n"' }, + { 'fizzbuzz-strings', 'string_literal', { 8, 13, 8, 32 }, '"number= %d Fizz\\n"' }, + { 'fizzbuzz-strings', 'string_literal', { 10, 13, 10, 32 }, '"number= %d Buzz\\n"' }, }, res1) end) @@ -608,9 +608,9 @@ void ui_refresh(void) eq( { - { 0, 2, 0, 8 }, - { 1, 2, 1, 8 }, - { 2, 2, 2, 8 }, + { 0, 0, 0, 6 }, + { 1, 0, 1, 6 }, + { 2, 0, 2, 6 }, }, test( [[ @@ -636,9 +636,9 @@ void ui_refresh(void) eq( { - { 0, 2, 0, 7 }, - { 1, 2, 1, 8 }, - { 2, 2, 2, 7 }, + { 0, 0, 0, 5 }, + { 1, 0, 1, 6 }, + { 2, 0, 2, 5 }, }, test( [[ @@ -675,9 +675,9 @@ void ui_refresh(void) end) eq({ - { 0, 2, 0, 12 }, - { 1, 2, 1, 12 }, - { 2, 2, 2, 12 }, + { 0, 0, 0, 10 }, + { 1, 0, 1, 10 }, + { 2, 0, 2, 10 }, }, result) end) |