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
Improve oldfiles finder #657
Improve oldfiles finder #657
Conversation
Instead of filereadable, vim.loop.fs_lstat is faster. if not vim.loop.fs_lstat(file) then
print("file do 'not' exist")
end Additionally, there is a vim.loop function to get current working directory, I believe it's Other then that the pr LGTM, very smart and useful feature, well done 👍🏻 |
Haha, pardon my VimL, still learning the Neovim ropes! I understand the difference between Anyway, thank you for the kind words ❤️ |
|
I agree current session should br included by default but we should have an option to disable it if for some reason others would like to only browse old sessions files |
Cool. One more thought... As soon as you open a file, it gets added to the finder. I'm just realizing that fzf's Maybe I should do the same here? I don't see how showing the current/active file in this finder is useful, since it's not 'old' if it's 'active'. If the user quits Vim, it'll still be tracked by |
Yah it does not make sense to me as well. One last thing before we merge, conni told that fs_lstat might break for symlinks so we need to use |
@jesseleite I'm testing it our right now and for some reason I see files I never opened with the same directory. Can you check please |
@tami5
Or maybe I'm misunderstanding, which files are you seeing that you never opened? |
Oh sorry my bad, I did open those files, and I forgot. Okay, so the issue now is when I run Does it make sense? |
Sorry, I don't understand. The whole finder orders the exact same way as If you use the Maybe we can do a screen call or something for me to better understand your issue? I'm on the Telescope Gitter as well if you want to DM me there! |
Whats missing here? Does anyone need something from me? Code looks good to me (first glance) :) |
Sorry, couldn't test today and I'm about to sleep. It looks good but I'm quite unsure if it will introduce undesirable experience. Last time I tested it, I had an issue with the order in which files get sorted. I noticed it doesn't get sorted based on recently opened files, rather somehow prompting current directory files. Conni can you please test, and check is this still the case? Basically, checkout the pr -> open few files in specific order , close them (maybe restart neovim) and launch oldfiles picker. Thanks |
@tami5 I'm still not sure what you mean here, but I'm all for another set of eyes and thorough testing 🙂 @Conni2461 I'd be glad to answer any questions, screenshare, DM on gitter, whatever is helpful 👍 |
Well done @jesseleite |
Thank you for help and encouragement 🙌 |
@jesseleite I was testing this today, and I still don't like the idea of showing buffers that are not listed. For example I'm using https://github.com/tpope/vim-dadbod and it creates some temporary files that prints out the results, or some scratch buffers that I don't really need. Could we add an option to hide the buffers that are not listed? |
@kristijanhusak I do have a Try this...
If we hide unlisted files, then it presents a new bug, which is the same bug that fzf's That said, I'd rather show dadbod files, than hide the user's actual project files that SHOULD be in the list when the user has closed those buffers. Nawmean? |
@jesseleite it does create files, in tmp folder, but buffers created for those files are scratch buffers. Once neovim is restarted, those files are gone, since they were created in another neovim session, and tmp folders are created per session. |
@kristijanhusak I think the fix may then be to ignore scratch files in the tmp folder, rather than ignore all unlisted buffers (which again includes valid user project files that they recently edited and closed). Looking into this! 👍 Maybe we ignore scratch/tmp files by default, and add an option like |
I think that setting is too specific. I believe most of the people who comes from FZF will expect this to work as it worked there. I never had a problem from missing buffers after I delete them, probably because I got used to it in FZF. |
I don't see why it would ever be desirable to open |
Habit. I'm used to see only things that I'm working with. You could say I'm using this as a buffer switcher, but I need MRU sort. |
Why not then use |
Because it's not really sorting the whole list by MRU. It just preselects alternate buffer differently. |
What you are describing then sounds like a possible PR to the
|
Yeah, i guess it needs to be something like that. It's up to telescope collaborators to decide. |
I really don't like this new changes, I'm trying to open recent file in the current directory and I can't see it. I just see ALL files in current directory. Is it possible that files get add oldfiles when previewing them. Is it possible that files is merged into oldfiles? |
@tami5 What do you mean you see ALL files in current directory? |
I mean like what you would expect find_files to return. Okay it's seems to be an issue with my confing. hmmmmmmmmm wired issue. maybe I should delete shada file |
@tami5 I did mention to you in gitter DM the other day about the LSP related issue I found, which lists files I never opened when certain LSPs crawl my files. Not sure if this is a Neovim bug. That said, I think I have a solution I'm going to PR shortly. Could you try something for me though? If you disable all your LSP stuff and delete your shada file, does |
@jesseleite oh yes indeed, I wasn't expecting that bug to be related to this issue. Yah it's a lsp thing for sure, lua lsp seems to causing this from time to time. That would be awesome thanks @jesseleite |
Is there a way to also include other entries from other file pickers, e.g.
This would be a way to inject MRU behavior into other file pickers. |
@YodaEmbedding That might get weird IMO, as many finders aren't file based (ie. command finder, etc). This oldfiles finder is pretty coupled to the concept of |
Did you manage to PR your solution for the LSP crawling issue? I suffer from this as well as pyright indexes all 200+ py files and completely overwrites my dear oldfiles picker :( |
@thraizz, I keep meaning to PR a bugfix for this. Curious for you though, which LSP(s) is/are doing it for you? |
pyright, i fixed it by changing |
This adds options to the
oldfiles
finder to make it optionally more useful as a MRU (most recently used) finder.include_current_session
v:oldfiles
only lists files from past vim sessions. This option will include recently accessed files in the current vim session using:buffers! t
(the!
bang shows unlisted buffers after they are closed, and thet
modifier sorts the list by MRU).cwd_only
At the moment both options don't change default
oldfiles
finder behaviour, as they are both opt-in. I might argue makinginclude_current_session=true
a default, having to restart vim to see new entries populated intov:oldfiles
is kind of weird. Either way though, it'd just be nice to have the option!PS. I know there was an issue/discussion at #433 around MRU pickers that was closed because of the (very cool) frecency extension, but I'd argue that MRU and frecency are different things: