Skip to content

Commit

Permalink
feat: Ability to disable hybrid modes behavior when inside specific n…
Browse files Browse the repository at this point in the history
…odes

Closes #154
  • Loading branch information
OXY2DEV committed Oct 5, 2024
1 parent 9c15e30 commit 7b913f9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
---@field horizontal_rules markview.conf.hrs
---@field html markview.conf.html
---@field hybrid_modes? string[] Modes where hybrid mode should be enabled
---@field ignore_nodes? string[] Tree-sitter nodes to ignore when using hybrid modes
---@field initial_state boolean Whether to show the preview at start or not
---@field injections markview.conf.injections
---@field inline_codes markview.conf.inline_codes
Expand Down
2 changes: 2 additions & 0 deletions lua/markview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ markview.configuration = {

hybrid_modes = nil,

ignore_nodes = nil,
initial_state = true,

max_file_length = 1000,
modes = { "n", "no", "c" },
render_distance = 100,
Expand Down
2 changes: 1 addition & 1 deletion markview.nvim.wiki
10 changes: 10 additions & 0 deletions plugin/markview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ local buf_render = function (buffer)

-- Get the cursor
local cursor = vim.api.nvim_win_get_cursor(win or 0);
local node = vim.treesitter.get_node({ bufnr = buffer, pos = { cursor[1] - 1, cursor[2]} });

--- Don't hide stuff on specific nodes
while node:parent() do
if vim.list_contains(markview.configuration.ignore_nodes or {}, node:type()) then
return;
end

node = node:parent();
end

-- Range to start & stop parsing
local start = math.max(0, cursor[1] - 1);
Expand Down

0 comments on commit 7b913f9

Please sign in to comment.