diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-02-23 17:05:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-23 17:05:20 +0000 |
commit | 1df3f5ec6aca24cbe7b78ead5c37ad06a65c84e8 (patch) | |
tree | d1523f1b7ef2a813859572ba0bdce2874de82699 /test/functional/treesitter/parser_spec.lua | |
parent | 8c339aa04b2a1ca99a297b2eada8ebc6218f5f1c (diff) | |
download | rneovim-1df3f5ec6aca24cbe7b78ead5c37ad06a65c84e8.tar.gz rneovim-1df3f5ec6aca24cbe7b78ead5c37ad06a65c84e8.tar.bz2 rneovim-1df3f5ec6aca24cbe7b78ead5c37ad06a65c84e8.zip |
feat(treesitter): upstream foldexpr from nvim-treesitter
Diffstat (limited to 'test/functional/treesitter/parser_spec.lua')
-rw-r--r-- | test/functional/treesitter/parser_spec.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua index fdd6403859..67aad4d1b7 100644 --- a/test/functional/treesitter/parser_spec.lua +++ b/test/functional/treesitter/parser_spec.lua @@ -871,4 +871,38 @@ int x = INT_MAX; end) end) end) + + it("can fold via foldexpr", function() + insert(test_text) + exec_lua([[vim.treesitter.get_parser(0, "c")]]) + + local levels = exec_lua([[ + local res = {} + for i = 1, vim.api.nvim_buf_line_count(0) do + res[i] = vim.treesitter.foldexpr(i) + end + return res + ]]) + + eq({ + [1] = '>1', + [2] = '1', + [3] = '1', + [4] = '1', + [5] = '>2', + [6] = '2', + [7] = '2', + [8] = '1', + [9] = '1', + [10] = '>2', + [11] = '2', + [12] = '2', + [13] = '2', + [14] = '2', + [15] = '>3', + [16] = '3', + [17] = '3', + [18] = '2', + [19] = '1' }, levels) + end) end) |