Skip to content

feat!: Load ruler file dynamically#2338

Merged
joelim-work merged 6 commits into
gokcehan:masterfrom
joelim-work:rulerfile
Jan 12, 2026
Merged

feat!: Load ruler file dynamically#2338
joelim-work merged 6 commits into
gokcehan:masterfrom
joelim-work:rulerfile

Conversation

@joelim-work

Copy link
Copy Markdown
Collaborator

No description provided.

@joelim-work joelim-work added the breaking Pull requests that introduce breaking changes label Jan 9, 2026
@joelim-work joelim-work added this to the r41 milestone Jan 9, 2026

@CatsDeservePets CatsDeservePets left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me.
The only thing I'd suggest is also updating the help for statfmt, something along the lines of:

This option has no effect unless `rulerfmt` is also set.
Using `rulerfile` is preferred and this option is provided for backwards compatibility.

Also, don't forget updating https://github.com/gokcehan/lf/wiki/Ruler after this is merged (it still states rulerfile being experimental).

@joelim-work

Copy link
Copy Markdown
Collaborator Author

Thanks, I have updated the documentation for statfmt as well, and removed the experimental notice from the wiki.

@joelim-work joelim-work merged commit 8ed089c into gokcehan:master Jan 12, 2026
32 checks passed
@joelim-work joelim-work deleted the rulerfile branch January 12, 2026 06:48
@eeeXun

eeeXun commented Apr 30, 2026

Copy link
Copy Markdown

May I ask what's the consideration for loading ruler file dynamically but not set a default path? colors and icons have their default path under ~/.conf/lf. Why not have default for ruler?

@CatsDeservePets

Copy link
Copy Markdown
Collaborator

May I ask what's the consideration for loading ruler file dynamically but not set a default path? colors and icons have their default path under ~/.conf/lf. Why not have default for ruler?

Currently, colors and icons cannot be changed or re-sourced at runtime. lf checks whether they exist in one of its recognised configuration directories. You can read more about these locations and their resolution order here.

When introduced in r39, rulerfile behaved just like icons and colors (i.e. having a fixed name and location). With the release of r41, the option changed from a boolean toggle to a path string instead, just like previewer and cleaner. This allows users to change the design of the ruler on the fly.

Resolving rulerfile, previewer and cleaner relative to the config directory was already brought up in #2418. I am not against this idea.

@eeeXun

eeeXun commented May 2, 2026

Copy link
Copy Markdown

just like previewer and cleaner. This allows users to change the design of the ruler on the fly

The file of previewer and cleaner are executable files. Which means that I can put this file in the $PATH. So, I can simply set it to the file name, but not the absolute path nor the relative path.

Thus, I think the situation of rulerfile is more like icons and colors. They are not executable files. And they have default path.

I'm not strongly against loading it dynamically. But just a little bit confused by the config style.

@CatsDeservePets

Copy link
Copy Markdown
Collaborator

Thus, I think the situation of rulerfile is more like icons and colors. They are not executable files. And they have default path.

The icons and colors files either exist in their pre-defined locations or not. Unlike these, rulefile does not have a default path or file name. Realistically, most people will use ~/.config/lf/ruler but it could be named anything. Not having a fixed location is required to make rulerfile load dynamically.

Imagine developing a plugin for Vim that uses lf as a file picker. It might make sense to change the appearance of the ruler. Before there was rulerfile, plugins could just change rulerfmt and statfmt like this lf -command 'set rulerfmt foo; set statfmt bar' or this lf -config vim_lfrc. How would you do this now, if the path of the ruler was hardcoded? Backup the existing ruler file inside the config dir, replace it with yours, launch lf and after that delete the new ruler file and restore the previous one? Instead, you can just do lf -command 'set rulerfile vim_ruler'.

@eeeXun

eeeXun commented May 2, 2026

Copy link
Copy Markdown

Before there was rulerfile, plugins could just change rulerfmt and statfmt like this lf -command 'set rulerfmt foo; set statfmt bar' or this lf -config vim_lfrc. How would you do this now, if the path of the ruler was hardcoded? Backup the existing ruler file inside the config dir, replace it with yours, launch lf and after that delete the new ruler file and restore the previous one? Instead, you can just do lf -command 'set rulerfile vim_ruler'.

Oh, this make more sense to me. Thanks for your reply

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

Labels

breaking Pull requests that introduce breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants