Skip to content

fix(actions): persist per-buffer render config across re-renders#477

Open
NeOzay wants to merge 2 commits intoOXY2DEV:mainfrom
NeOzay:main
Open

fix(actions): persist per-buffer render config across re-renders#477
NeOzay wants to merge 2 commits intoOXY2DEV:mainfrom
NeOzay:main

Conversation

@NeOzay
Copy link

@NeOzay NeOzay commented Mar 16, 2026

Hi,
When a custom config is passed to actions.render(), store it as a buffer variable so that subsequent automatic re-renders (triggered by autocmds like ModeChanged, CursorMoved) reuse it instead of falling back to the global config.

When a custom config is passed to actions.render(), store it as a
buffer variable so that subsequent automatic re-renders (triggered
by autocmds like ModeChanged, CursorMoved) reuse it instead of
falling back to the global config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 16, 2026 14:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates actions.render() so that when a custom render config is provided, it is remembered per-buffer and reused on subsequent automatic re-renders (e.g., from autocmds), instead of falling back to the global config.

Changes:

  • Persist _config passed to actions.render() into a per-buffer variable.
  • When _config is omitted on later calls, retrieve the stored per-buffer config and apply it via spec.tmp_setup().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@OXY2DEV
Copy link
Owner

OXY2DEV commented Mar 16, 2026

@NeOzay what's the use case for this?

Also, why buffer local variable? Shouldn't it be window local(some of the rendering logic is affected by window options) variable?

@NeOzay
Copy link
Author

NeOzay commented Mar 18, 2026

@OXY2DEV
Hi, I'm using the Snacks notifier and Markview with a different configuration than the global one to render the notification.
But when I focus on the notification, Markview re-renders it with the global configuration.

I'm doing it with this code, maybe I'm doing it wrong.

require("markview.actions").render(self.buf, nil, {                      
	markdown = {                                                           
		list_items = { indent_size = 1, shift_width = 1 },                   
		code_blocks = {                                                      
			label_direction = "right",
			style = "simple",                                                  
		},                                                                   
	},                                                                     
})

@NeOzay
Copy link
Author

NeOzay commented Mar 18, 2026

Also, my PR is more of a draft, I'm sure it's possible to implement this more cleanly.

@OXY2DEV
Copy link
Owner

OXY2DEV commented Mar 18, 2026

@NeOzay isn't the notification buffer a nofile buffer, so it shouldn't be rendered by default.

Also, if for whatever reason you have ignore_buftypes = {}, you can still use preview.condition to stop markview from rendering in buffers you don't want it to render in.

@NeOzay
Copy link
Author

NeOzay commented Mar 18, 2026

I'm already using ignore_buftypes = {}.

To make it work, I'm using vim.treesitter.language.register("markdown", ft) to force the notifier to use the parser.

My problem is how I can specify a local configuration for a window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants