From 8a428f027be7589b65beec4e5f2392c3c0c34ea3 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Mon, 27 May 2024 15:29:45 +0300 Subject: [PATCH] refactor: clean up --- lua/regexplainer.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lua/regexplainer.lua b/lua/regexplainer.lua index 265bd93..79b6a83 100644 --- a/lua/regexplainer.lua +++ b/lua/regexplainer.lua @@ -4,8 +4,9 @@ local utils = require 'regexplainer.utils' local Buffers = require 'regexplainer.buffers' local defer = require 'regexplainer.utils.defer' -local get_node_text = vim.treesitter.get_node_text or vim.treesitter.query.get_node_text +local get_node_text = vim.treesitter.get_node_text local extend = vim.tbl_deep_extend +local buf_delete = vim.api.nvim_buf_delete local ag = vim.api.nvim_create_augroup local au = vim.api.nvim_create_autocmd @@ -102,14 +103,10 @@ local function show_for_real(options) renderer = require'regexplainer.renderers.debug' end - Buffers.render(buffer, - renderer, - components, - options, - { - full_regexp_text = get_node_text(node, scratchnr), - }) - vim.api.nvim_buf_delete(scratchnr, { force = true }) + local state = { full_regexp_text = get_node_text(node, scratchnr) } + + Buffers.render(buffer, renderer, components, options, state) + buf_delete(scratchnr, { force = true }) else Buffers.hide_all() end