diff --git a/lua/nvim-biscuits/init.lua b/lua/nvim-biscuits/init.lua index 56c17c1..8a60bc0 100644 --- a/lua/nvim-biscuits/init.lua +++ b/lua/nvim-biscuits/init.lua @@ -20,7 +20,7 @@ local make_biscuit_hl_group_name = nvim_biscuits.decorate_nodes = function(bufnr, lang) if config.get_language_config(final_config, lang, "disabled") then return end - utils.console_log("decorating nodes") + utils.console_log("decorating nodes for " .. lang) local parser = ts_parsers.get_parser(bufnr, lang) @@ -121,11 +121,10 @@ nvim_biscuits.decorate_nodes = function(bufnr, lang) vim.api.nvim_buf_clear_namespace(bufnr, biscuit_highlight_group, end_line, end_line + 1) - vim.api.nvim_buf_set_extmark(bufnr, biscuit_highlight_group, end_line, 0, { + vim.api.nvim_buf_set_extmark(bufnr, biscuit_highlight_group, + end_line, 0, { virt_text_pos = "eol", - virt_text = { - {text, biscuit_highlight_group_name} - }, + virt_text = {{text, biscuit_highlight_group_name}}, hl_mode = "combine" }) end diff --git a/lua/nvim-biscuits/languages.lua b/lua/nvim-biscuits/languages.lua index 2ebdab3..7520faa 100644 --- a/lua/nvim-biscuits/languages.lua +++ b/lua/nvim-biscuits/languages.lua @@ -2,6 +2,7 @@ local html = require("nvim-biscuits.languages.html") local vue = require("nvim-biscuits.languages.vue") local javascript = require("nvim-biscuits.languages.javascript") local python = require("nvim-biscuits.languages.python") +local utils = require("nvim-biscuits.utils") local languages = {} @@ -14,6 +15,7 @@ local handled_languages = { languages.should_decorate = function(language_name, ts_node, text) local language = handled_languages[language_name] + if language == nil then return true end return language.should_decorate(ts_node, text) diff --git a/lua/nvim-biscuits/languages/html.lua b/lua/nvim-biscuits/languages/html.lua index c87ef6c..cb1102a 100644 --- a/lua/nvim-biscuits/languages/html.lua +++ b/lua/nvim-biscuits/languages/html.lua @@ -30,12 +30,18 @@ language.should_decorate = function(ts_node, text, bufnr) if text == end_string then return false end end - if ts_node:type() == "element" then return true end + local elements = { + "element", "jsx_element", "self_closing_element", + "jsx_self_closing_element" + } + + if utils.list_contains(elements, ts_node:type()) then return true end return false end language.transform_text = function(ts_node, text, bufnr) + local end_string = get_node_last_line(ts_node) end_string = string.gsub(end_string, '/', '') end_string = string.gsub(end_string, '>', '') @@ -45,7 +51,20 @@ language.transform_text = function(ts_node, text, bufnr) text = string.gsub(text, '>', '') text = string.gsub(text, ' ', ' ') - return utils.trim(text) + text = utils.trim(text) + + if text == '