Skip to content

feat(config): allow the configuration of filename modifiers#983

Open
ffknob wants to merge 1 commit intofolke:mainfrom
ffknob:feature/allow-config-of-filename-modifiers
Open

feat(config): allow the configuration of filename modifiers#983
ffknob wants to merge 1 commit intofolke:mainfrom
ffknob:feature/allow-config-of-filename-modifiers

Conversation

@ffknob
Copy link
Copy Markdown

@ffknob ffknob commented May 20, 2025

Description

Just a tweak I've came up with. I work in some Java projects in which my files are stored deeply in the directories structure. When triggering the buffers UI in my Lazyvim (<leader>b) I'm not able to see the filename because it is hidden by the UI's width limitation.

I discovered that the filename used in the buffers list is actually defined through the fnamemodify() Vim function, which takes a string as argument with some pattern that will convert the full path of the file in many ways, including just the filename, which is what I prefer.

The PR changes the defaults config object so a new filename_modifier parameter could be set by the user. This value will then be used in the bufname() function, keeping the current ":~:." pattern as a default.

After changing the plugin's code I'm now able to have the following config customization file in my Lazyvim:

{
    "folke/which-key.nvim",
    opts = { filename_modifier = ":t." },
  },
}

Now instead of having this in my buffers menu...

0 src/main/java/br/rs/gov/
1 src/main/java/br/rs/gov/
2 src/main/java/br/rs/gov/
...

...I can easily identify the buffers by its names:

0 FileA.java
1 FileB.java
2 FileC.java
...

I don't know if there was another easier way to achieve the same thing, just went ahead with this tweak and it'sworking for me.

Related Issue(s)

Screenshots

@ffknob ffknob changed the title Allow the configuration of filename modifiers feat: Allow the configuration of filename modifiers May 20, 2025
@ffknob ffknob changed the title feat: Allow the configuration of filename modifiers feat(config): Allow the configuration of filename modifiers May 20, 2025
@ffknob ffknob changed the title feat(config): Allow the configuration of filename modifiers feat(config): allow the configuration of filename modifiers May 20, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity.

@github-actions github-actions bot added the stale This issue or PR has been inactive for a while label Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue or PR has been inactive for a while

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant