echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.45k stars 171 forks source link

feat(extra): add flag 'current_dir' to `oldfiles()` picker #997

Closed abeldekat closed 4 days ago

abeldekat commented 4 days ago

Reference: This discussion

In my workflow, each project is opened in a tmux session. As such, when querying oldfiles, I am mostly interested in files inside the current working directory.

MiniExtra.pickers.oldfiles() currently does not filter on cwd

This PR adds flag "current_dir" to MiniExtra.pickers.oldfiles()

abeldekat commented 4 days ago

Remarks:

The name current_dir: Only the value of variable current_dir indicates that this is a boolean.

System call vim.loop.os_uname() is always executed, also when current_dir is not supplied. Would this approach be appropriate?

echasnovski commented 4 days ago

Thanks for the PR!

I appreciate the exact copy of the approach from 'mini.starter' (I'd usually do that too), however I think the better approach here is to use plain vim.startswith() with cwd .. '/'. As far as I remember, built-in paths coming from Neovim always use forward slash. If not, we'll wait for a Windows user to report.

I've merged in the temporary branch to polish up a bit.

echasnovski commented 4 days ago

Thanks again for following through!

This should now be part of latest main.

abeldekat commented 4 days ago

Thank you!