diff --git a/README.md b/README.md index 31aba32..4644e74 100644 --- a/README.md +++ b/README.md @@ -538,10 +538,6 @@ require("aerial").setup({ treesitter = { -- How long to wait (in ms) after a buffer change before updating update_delay = 300, - -- Experimental feature to navigate to symbol names instead of the declaration - -- See https://github.com/stevearc/aerial.nvim/issues/279 - -- If no bugs are reported for a time this will become the default - experimental_selection_range = false, }, markdown = { diff --git a/doc/aerial.txt b/doc/aerial.txt index 7891616..5e3714c 100644 --- a/doc/aerial.txt +++ b/doc/aerial.txt @@ -349,10 +349,6 @@ OPTIONS *aerial-option treesitter = { -- How long to wait (in ms) after a buffer change before updating update_delay = 300, - -- Experimental feature to navigate to symbol names instead of the declaration - -- See https://github.com/stevearc/aerial.nvim/issues/279 - -- If no bugs are reported for a time this will become the default - experimental_selection_range = false, }, markdown = { diff --git a/lua/aerial/backends/treesitter/extensions.lua b/lua/aerial/backends/treesitter/extensions.lua index c45ca81..fb60430 100644 --- a/lua/aerial/backends/treesitter/extensions.lua +++ b/lua/aerial/backends/treesitter/extensions.lua @@ -1,4 +1,3 @@ -local config = require("aerial.config") local helpers = require("aerial.backends.treesitter.helpers") local M = {} @@ -294,7 +293,7 @@ local function c_postprocess(bufnr, item, match) end end item.name = get_node_text(root, bufnr) or "" - if config.treesitter.experimental_selection_range and not item.selection_range then + if not item.selection_range then item.selection_range = helpers.range_from_nodes(root, root) end end diff --git a/lua/aerial/backends/treesitter/init.lua b/lua/aerial/backends/treesitter/init.lua index eee6713..6fed382 100644 --- a/lua/aerial/backends/treesitter/init.lua +++ b/lua/aerial/backends/treesitter/init.lua @@ -47,7 +47,6 @@ M.fetch_symbols_sync = function(bufnr) ) return end - local use_selection_range = config.treesitter.experimental_selection_range -- This will track a loose hierarchy of recent node+items. -- It is used to determine node parents for the tree structure. local stack = {} @@ -125,10 +124,8 @@ M.fetch_symbols_sync = function(bufnr) level = level, parent = parent_item, scope = match.scope, + selection_range = selection_range, } - if use_selection_range then - item.selection_range = selection_range - end for k, v in pairs(range) do item[k] = v end diff --git a/lua/aerial/config.lua b/lua/aerial/config.lua index 714a794..f36e2db 100644 --- a/lua/aerial/config.lua +++ b/lua/aerial/config.lua @@ -335,10 +335,6 @@ local default_options = { treesitter = { -- How long to wait (in ms) after a buffer change before updating update_delay = 300, - -- Experimental feature to navigate to symbol names instead of the declaration - -- See https://github.com/stevearc/aerial.nvim/issues/279 - -- If no bugs are reported for a time this will become the default - experimental_selection_range = false, }, markdown = { diff --git a/tests/navigation_spec.lua b/tests/navigation_spec.lua index 9e14fc8..ecc89ed 100644 --- a/tests/navigation_spec.lua +++ b/tests/navigation_spec.lua @@ -53,7 +53,7 @@ a.describe("navigation", function() vim.api.nvim_win_set_cursor(0, { 1, 0 }) aerial.select({ index = 2 }) local cursor = vim.api.nvim_win_get_cursor(0) - assert.are.same({ 3, 0 }, cursor) + assert.are.same({ 3, 1 }, cursor) end) a.it("in aerial window jumps to location", function() @@ -63,7 +63,7 @@ a.describe("navigation", function() assert.equals("aerial", vim.bo.filetype) aerial.select({ index = 2 }) local cursor = vim.api.nvim_win_get_cursor(0) - assert.are.same({ 3, 0 }, cursor) + assert.are.same({ 3, 1 }, cursor) end) a.it("in aerial window uses cursor position as index", function() @@ -75,7 +75,7 @@ a.describe("navigation", function() vim.api.nvim_win_set_cursor(0, { 3, 0 }) aerial.select() local cursor = vim.api.nvim_win_get_cursor(0) - assert.are.same({ 5, 0 }, cursor) + assert.are.same({ 5, 1 }, cursor) end) a.it("doesn't have to jump", function() @@ -92,7 +92,7 @@ a.describe("navigation", function() assert.equals("aerial", vim.bo.filetype) -- The source window cursor should be updated local cursor = vim.api.nvim_win_get_cursor(winid) - assert.are.same({ 5, 0 }, cursor) + assert.are.same({ 5, 1 }, cursor) end) a.it("can open a new split when jumping", function() @@ -111,55 +111,57 @@ a.describe("navigation", function() -- Source window cursor should be the same assert.are.same({ 1, 0 }, vim.api.nvim_win_get_cursor(winid)) -- Split window cursor should be updated - assert.are.same({ 5, 0 }, vim.api.nvim_win_get_cursor(0)) + assert.are.same({ 5, 1 }, vim.api.nvim_win_get_cursor(0)) end) end) a.describe("movement", function() a.it("can go to next symbol", function() create_md_buf(markdown_nested_content) - vim.api.nvim_win_set_cursor(0, { 1, 0 }) + vim.api.nvim_win_set_cursor(0, { 1, 2 }) + window.update_position() -- Not sure why the CursorMoved autocmd doesn't fire aerial.next() - assert.are.same({ 3, 0 }, vim.api.nvim_win_get_cursor(0)) + assert.are.same({ 3, 2 }, vim.api.nvim_win_get_cursor(0)) end) a.it("can go to next N symbol", function() create_md_buf(markdown_nested_content) - vim.api.nvim_win_set_cursor(0, { 1, 0 }) + vim.api.nvim_win_set_cursor(0, { 1, 2 }) + window.update_position() -- Not sure why the CursorMoved autocmd doesn't fire aerial.next(2) - assert.are.same({ 5, 0 }, vim.api.nvim_win_get_cursor(0)) + assert.are.same({ 5, 2 }, vim.api.nvim_win_get_cursor(0)) end) a.it("can go to prev symbol", function() create_md_buf(markdown_nested_content) - vim.api.nvim_win_set_cursor(0, { 3, 0 }) - window.update_position(0, 0) -- Not sure why the CursorMoved autocmd doesn't fire + vim.api.nvim_win_set_cursor(0, { 3, 2 }) + window.update_position() -- Not sure why the CursorMoved autocmd doesn't fire aerial.prev() - assert.are.same({ 1, 0 }, vim.api.nvim_win_get_cursor(0)) + assert.are.same({ 1, 1 }, vim.api.nvim_win_get_cursor(0)) end) a.it("can go to prev N symbol", function() create_md_buf(markdown_nested_content) - vim.api.nvim_win_set_cursor(0, { 5, 0 }) - window.update_position(0, 0) -- Not sure why the CursorMoved autocmd doesn't fire + vim.api.nvim_win_set_cursor(0, { 5, 2 }) + window.update_position() -- Not sure why the CursorMoved autocmd doesn't fire aerial.prev(2) - assert.are.same({ 1, 0 }, vim.api.nvim_win_get_cursor(0)) + assert.are.same({ 1, 1 }, vim.api.nvim_win_get_cursor(0)) end) a.it("can go up and backwards in the tree", function() create_md_buf(markdown_nested_content) - vim.api.nvim_win_set_cursor(0, { 5, 0 }) - window.update_position(0, 0) -- Not sure why the CursorMoved autocmd doesn't fire + vim.api.nvim_win_set_cursor(0, { 5, 2 }) + window.update_position() -- Not sure why the CursorMoved autocmd doesn't fire aerial.prev_up() - assert.are.same({ 1, 0 }, vim.api.nvim_win_get_cursor(0)) + assert.are.same({ 1, 1 }, vim.api.nvim_win_get_cursor(0)) end) a.it("can go up and forwards in the tree", function() create_md_buf(markdown_nested_content) - vim.api.nvim_win_set_cursor(0, { 3, 0 }) - window.update_position(0, 0) -- Not sure why the CursorMoved autocmd doesn't fire + vim.api.nvim_win_set_cursor(0, { 3, 2 }) + window.update_position() -- Not sure why the CursorMoved autocmd doesn't fire aerial.next_up() - assert.are.same({ 7, 0 }, vim.api.nvim_win_get_cursor(0)) + assert.are.same({ 7, 1 }, vim.api.nvim_win_get_cursor(0)) end) end) end) diff --git a/tests/test_util.lua b/tests/test_util.lua index 923d684..867c558 100644 --- a/tests/test_util.lua +++ b/tests/test_util.lua @@ -58,9 +58,6 @@ M.test_file_symbols = function(backend_name, filename, symbols_file) config.setup({ backends = { backend_name }, filter_kind = false, - treesitter = { - experimental_selection_range = true, - }, }) vim.cmd(string.format("edit %s", filename)) local backend = backends.get(0)