Skip to content

Commit

Permalink
fix(latex): Removed unnecessary feature brackets
Browse files Browse the repository at this point in the history
Since () & [] already exists in LaTeX. It isn't necessary to show {}
as brackets. So, this feature is removed.
  • Loading branch information
OXY2DEV committed Sep 23, 2024
1 parent 077951b commit eeb2bde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 46 deletions.
26 changes: 4 additions & 22 deletions lua/markview/latex_renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1413,30 +1413,12 @@ latex.render_brackets = function (buffer, content, user_config)
end

vim.api.nvim_buf_set_extmark(buffer, latex.namespace, content.row_start, content.col_start, {
virt_text_pos = "overlay",
virt_text = {
user_config.opening[utils.clamp(content.level, 1, #user_config.opening)]
},

hl_mode = "combine"
end_col = content.col_start + 1,
conceal = ""
});
vim.api.nvim_buf_set_extmark(buffer, latex.namespace, content.row_end, content.col_end - 1, {
virt_text_pos = "overlay",
virt_text = {
user_config.closing[utils.clamp(content.level, 1, #user_config.closing)]
},

hl_mode = "combine"
});

if not user_config.scope or #user_config.scope == 0 then
return;
end

vim.api.nvim_buf_set_extmark(buffer, latex.namespace, content.row_start, content.col_start, {
hl_group = set_hl(user_config.scope[utils.clamp(content.level, 1, #user_config.scope)]),
end_row = content.row_end,
end_col = content.col_end
end_col = content.col_end,
conceal = ""
});
end

Expand Down
24 changes: 0 additions & 24 deletions lua/markview/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1038,34 +1038,10 @@ parser.latex = function (buffer, TStree, from, to)
goto invalidBracket;
end

local node = capture_node;
local level = 1;

-- Need more efficiency
while node do
local foundSubNode = false;

for sub_node in node:iter_children() do
if sub_node:type() == "curly_group" then
level = level + 1;
node = sub_node;

foundSubNode = true;
break;
end
end

if foundSubNode == false then
break;
end
end

table.insert(parser.parsed_content, {
node = capture_node,
type = "latex_bracket",

level = level,

row_start = row_start,
row_end = row_end,

Expand Down

0 comments on commit eeb2bde

Please sign in to comment.