From 3ad93531b57805e6c3c344e1b2a2963e43886635 Mon Sep 17 00:00:00 2001 From: ray-x Date: Wed, 15 Jun 2022 19:34:17 +1000 Subject: [PATCH] unit tests for treesitter --- lua/navigator/treesitter.lua | 2 +- tests/treesitter_spec.lua | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/navigator/treesitter.lua b/lua/navigator/treesitter.lua index bc33f62..4af6409 100644 --- a/lua/navigator/treesitter.lua +++ b/lua/navigator/treesitter.lua @@ -422,6 +422,7 @@ local function get_all_nodes(bufnr, filter, summary) if #parents > 1 then indent = string.rep(' ', #parents - 1) .. ' ' end + item.indent = indent item.text = string.format(' %s %s%-10s\t %s', item.kind, indent, item.node_text, item.full_text) if #item.text > length then @@ -437,7 +438,6 @@ local function get_all_nodes(bufnr, filter, summary) if should_unload then vim.api.nvim_buf_delete(bufnr, { unload = true }) end - lprint(all_nodes) return all_nodes, length end diff --git a/tests/treesitter_spec.lua b/tests/treesitter_spec.lua index f9ac0d7..81e805e 100644 --- a/tests/treesitter_spec.lua +++ b/tests/treesitter_spec.lua @@ -17,6 +17,7 @@ local golden_result = { }, }, node_text = 'main', + indent = '', range = { ['end'] = { character = 12, @@ -38,6 +39,7 @@ local golden_result = { full_text = 'func interfaceTest()', kind = ' ', lnum = 5, + indent = '', node_scope = { ['end'] = { character = 1, @@ -80,6 +82,8 @@ local golden_result = { line = 4, }, }, + + indent = ' ', node_text = 'r', range = { ['end'] = { @@ -113,6 +117,7 @@ local golden_result = { }, }, node_text = 'c', + indent = ' ', range = { ['end'] = { character = 2, @@ -134,6 +139,7 @@ local golden_result = { full_text = 'd := circle{radius: 10}', kind = ' ', lnum = 10, + indent = ' ', node_scope = { ['end'] = { character = 1,