From 00e90cfcd8e907b779599fc6e5fdbfd3af995b6c Mon Sep 17 00:00:00 2001 From: Aaron Sullivan Date: Wed, 18 Dec 2024 06:30:36 -0800 Subject: [PATCH] Add back convenience imports having util hang around everywhere is germane to my development experience. I use util.log a lot, heh. Also the previous commit breaks the tests by altering a fixture file, which should never be altered. --- lua/treewalker/init.lua | 5 ++++- lua/treewalker/strategies.lua | 1 + tests/fixtures/lua.lua | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/treewalker/init.lua b/lua/treewalker/init.lua index a827cf1..72410ec 100644 --- a/lua/treewalker/init.lua +++ b/lua/treewalker/init.lua @@ -1,4 +1,5 @@ local nodes = require('treewalker.nodes') +local util = require('treewalker.util') local ops = require('treewalker.ops') local lines = require('treewalker.lines') local strategies = require('treewalker.strategies') @@ -16,7 +17,9 @@ Treewalker.opts = { ---@param opts Opts | nil function Treewalker.setup(opts) - Treewalker.opts = vim.tbl_deep_extend('force', Treewalker.opts, opts or {}) + if opts then + Treewalker.opts = vim.tbl_deep_extend('force', Treewalker.opts, opts) + end end ---@return nil diff --git a/lua/treewalker/strategies.lua b/lua/treewalker/strategies.lua index b418985..0a3956a 100644 --- a/lua/treewalker/strategies.lua +++ b/lua/treewalker/strategies.lua @@ -1,5 +1,6 @@ local lines = require('treewalker.lines') local nodes = require('treewalker.nodes') +local util = require('treewalker.util') ---@alias Dir "up" | "down" diff --git a/tests/fixtures/lua.lua b/tests/fixtures/lua.lua index 6688b8a..02a2ce5 100644 --- a/tests/fixtures/lua.lua +++ b/tests/fixtures/lua.lua @@ -1,3 +1,5 @@ +local util = require('treewalker.util') + local M = {} local NON_TARGET_NODE_MATCHERS = { @@ -26,7 +28,7 @@ local function is_jump_target(node) end local function is_descendant_jump_target(node) - return vim.list_contains(TARGET_DESCENDANT_TYPES, node:type()) + return util.contains(TARGET_DESCENDANT_TYPES, node:type()) end ---Do the nodes have the same starting point