Skip to content

Commit

Permalink
fix: pass bufnr through to all usages of should_decorate and transfor…
Browse files Browse the repository at this point in the history
…m_text
  • Loading branch information
cmgriffing committed Nov 6, 2022
1 parent 5257ea2 commit 256d021
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lua/nvim-biscuits/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lua/nvim-biscuits/languages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lua/nvim-biscuits/languages/javascript.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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

Expand Down
6 changes: 1 addition & 5 deletions lua/nvim-biscuits/languages/python.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lua/nvim-biscuits/languages/vue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 256d021

Please sign in to comment.