Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic configuration #2047

Open
sxyazi opened this issue Dec 15, 2024 · 0 comments
Open

Dynamic configuration #2047

sxyazi opened this issue Dec 15, 2024 · 0 comments
Labels
feature New feature request

Comments

@sxyazi
Copy link
Owner

sxyazi commented Dec 15, 2024

This issue tracks and explores the possibility of adding dynamic configuration support in Yazi.

The goal is to allow part or all of the configuration to be applied dynamically either through command-line arguments, environment variables before Yazi starts, or via Lua API, commands while Yazi is running, without modifying the toml configuration files.

For optimal performance, Yazi currently reads and parses the configuration file only once at startup, marking the parsed configuration as statically read-only.

This allows the configuration to be safely shared across multiple threads (&'static), and also enables optimizations like storing a reference to the icon configuration in each File structure:

pub icon: SyncCell<IconCache>,

This avoids redundant icon matching for the same file when rendering the file list, since the reference is just a pointer and doesn't require including the full icon information, thus saving memory.

Due to the immutability of the configuration, Yazi only serializes the configuration into Lua once at startup, supporting dynamic configuration would also mean re-serializing the configuration whenever it changes, and serialization is a relatively expensive operation, which could lead to performance degradation.

Dynamic configuration was deliberately omitted from Yazi's original design, and implementing it would require substantial changes to the architecture, likely at the cost of performance and increased project complexity.

Therefore, this feature may ultimately not be implemented unless the following obstacles can be addressed:

  • How should it be supported? Command-line arguments, environment variables, Lua API, or commands? In what format (TOML, JSON, or custom format)?
  • Which configurations need to be dynamic? yazi.toml, keymap.toml, theme.toml?
  • What would its behavior be like? Would it override or append to the existing configuration? What would the user interface look like when using it?
  • How can thread safety be ensured with dynamic configurations? Would the existing optimizations be compromised?
  • How can changes to the configuration be efficiently synchronized with Lua?
  • What impact would it have on performance and project complexity? Is the cost worth it?
  • Is there anyone willing to invest time and effort into pushing this feature to completion?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

1 participant