From 256d021ab4b8f3b49dba327eb6b639466d58e02d Mon Sep 17 00:00:00 2001 From: Chris Griffing Date: Sun, 6 Nov 2022 13:18:38 -0800 Subject: [PATCH] fix: pass bufnr through to all usages of should_decorate and transform_text --- lua/nvim-biscuits/init.lua | 2 +- lua/nvim-biscuits/languages.lua | 8 ++++---- lua/nvim-biscuits/languages/javascript.lua | 4 ++-- lua/nvim-biscuits/languages/python.lua | 6 +----- lua/nvim-biscuits/languages/vue.lua | 4 ++-- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lua/nvim-biscuits/init.lua b/lua/nvim-biscuits/init.lua index 84bc976..59a393e 100644 --- a/lua/nvim-biscuits/init.lua +++ b/lua/nvim-biscuits/init.lua @@ -145,7 +145,7 @@ nvim_biscuits.setup = function(user_config) if user_config == nil then user_config = {} end - + final_config = utils.merge_tables(final_config, user_config) if user_config.default_config then diff --git a/lua/nvim-biscuits/languages.lua b/lua/nvim-biscuits/languages.lua index 7520faa..ce51552 100644 --- a/lua/nvim-biscuits/languages.lua +++ b/lua/nvim-biscuits/languages.lua @@ -13,19 +13,19 @@ local handled_languages = { python = python } -languages.should_decorate = function(language_name, ts_node, text) +languages.should_decorate = function(language_name, ts_node, text, bufnr) local language = handled_languages[language_name] if language == nil then return true end - return language.should_decorate(ts_node, text) + return language.should_decorate(ts_node, text, bufnr) end -languages.transform_text = function(language_name, ts_node, text) +languages.transform_text = function(language_name, ts_node, text, bufnr) local language = handled_languages[language_name] if language == nil then return text end - return language.transform_text(ts_node, text) + return language.transform_text(ts_node, text, bufnr) end return languages diff --git a/lua/nvim-biscuits/languages/javascript.lua b/lua/nvim-biscuits/languages/javascript.lua index d5a85fb..a294fe7 100644 --- a/lua/nvim-biscuits/languages/javascript.lua +++ b/lua/nvim-biscuits/languages/javascript.lua @@ -10,7 +10,7 @@ language.should_decorate = function(ts_node, text, bufnr) local should_decorate = true if utils.list_contains(elements, type) then - should_decorate = html.should_decorate(ts_node, text) + should_decorate = html.should_decorate(ts_node, text, bufnr) end local ignored_element_types = { @@ -26,7 +26,7 @@ language.should_decorate = function(ts_node, text, bufnr) end language.transform_text = function(ts_node, text, bufnr) - text = html.transform_text(ts_node, text) + text = html.transform_text(ts_node, text, bufnr) return utils.trim(text) end diff --git a/lua/nvim-biscuits/languages/python.lua b/lua/nvim-biscuits/languages/python.lua index f1bac2d..01f4a2a 100644 --- a/lua/nvim-biscuits/languages/python.lua +++ b/lua/nvim-biscuits/languages/python.lua @@ -9,10 +9,6 @@ language.should_decorate = function(ts_node, text, bufnr) end language.transform_text = function(ts_node, text, bufnr) - - -- Dev.console_log("Node") - -- Dev.console_log(ts_node) - local start_line, start_col, end_line, end_col = ts_utils.get_node_range(ts_node) local parent_start_line, parent_start_col, parent_end_line, parent_end_col = @@ -28,7 +24,7 @@ language.transform_text = function(ts_node, text, bufnr) false) local text = lines[1] - -- text = html.transform_text(ts_node, text) + -- text = html.transform_text(ts_node, text, bufnr) return utils.trim(text) end diff --git a/lua/nvim-biscuits/languages/vue.lua b/lua/nvim-biscuits/languages/vue.lua index 8211b7a..983bfac 100644 --- a/lua/nvim-biscuits/languages/vue.lua +++ b/lua/nvim-biscuits/languages/vue.lua @@ -5,12 +5,12 @@ local html = require("nvim-biscuits.languages.html") local language = {} language.should_decorate = function(ts_node, text, bufnr) - local should_decorate = html.should_decorate(ts_node, text) + local should_decorate = html.should_decorate(ts_node, text, bufnr) return should_decorate end language.transform_text = function(ts_node, text, bufnr) - text = html.transform_text(ts_node, text) + text = html.transform_text(ts_node, text, bufnr) return utils.trim(text) end