Git Product home page Git Product logo

fzf-mru.vim's Introduction

FZF ❤️ MRU

Project Status: Active - The project has reached a stable, usable state and is being actively developed.

Vim plugin that allows using awesome CtrlP MRU plugin with even more amazing fzf

I love FZF fuzzy search algorithm and CtrlP Mru tracking - I'm using it often to jump between two files (yes, I'm aware of <c-^>). The way how fzf-vim's :History works was not the best solution for me that's why I decided to create this plugin. It requires fzf.

Instalation

Using vim-plug:

Plug 'junegunn/fzf'

Plug 'pbogut/fzf-mru.vim'

Using Vundle:

Plugin 'junegunn/fzf'

Plugin 'pbogut/fzf-mru.vim'

Basic Usage

  • You can run :FZFMru, :FZFMru [search-query] or :FZFMru [fzf-command-options].
  • For example: :FZFMru --prompt "Sup? " -q "notmuch" or :FZFMru readme
  • You can also map it to a shortcut with map <leader>p :FZFMru<cr>.
  • Set let g:fzf_mru_relative = 1 to only list files within current directory.
  • Set let g:fzf_mru_store_relative_dirs = ['/path/to/code'] to store files as relative paths, as opposed to as absolute ones. FZF-MRU will use the elements in this list as patterns to match the path against to see if it qualifies. This is useful if you have multiple copies of a repository on your computer that you switch between, and want to keep your MRU cache consistent between them.
  • Set let g:fzf_mru_no_sort = 1 to prevent fzf from sorting list while typing, it will keep list sorted by recency.
  • Set let g:fzf_mru_exclude_current_file = 0 to include the current file in the list since it's excluded by default.

FZF Options/Preview

You could pass FZF options and/or enable the file preview like this:

command! -bang -nargs=? FZFMru call fzf_mru#actions#mru(<q-args>,
    \{
        \'window': {'width': 0.9, 'height': 0.8},
        \'options': [
            \'--preview', 'cat {}',
            \'--preview-window', 'up:60%',
            \'--bind', 'ctrl-_:toggle-preview'
        \]
    \}
\)

nnoremap <Leader>fm :FZFMru<CR>

If bat is installed, which is the recommended previewer, you could replace the cat line in the command above:

            \'--preview', 'bat --style=numbers --color=always {}',

Telescope integration

Because why not?

Set up telescope extension

Add following to your init file to load the extension:

require('telescope').load_extension('fzf_mru')

Telescope usage:

  • :Telescope fzf_mru - Display MRU list as it would be display with :FZFMru
  • :Telescope fzf_mru current_path - List MRU files that are within current path (ignores g:fzf_mru_relative option).
  • :Telescope fzf_mru all - List all MRU files (ignores g:fzf_mru_relative option).

Todo

  • Move CtrlP MRU functionality to the plugin itself
  • Make fzf.vim optional dependency
  • Add Vim help

Credits

99% of MRU engine has been taken from CtrlP.

Contribution

Always welcome.

License

MIT License; The software is provided "as is", without warranty of any kind.

fzf-mru.vim's People

Contributors

dlee avatar kovasap avatar pbogut avatar ranelpadon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fzf-mru.vim's Issues

Have a way to only list files inside current project

Is there a way to make the MRU only list files from the current project?
I'm working on multiple projects right now, and the MRU is showing files across projects, whereas I would prefer to have each vim session only show the files of that project.

Question: comparison with `:History`

Hi,
Thank you for this plugin which I've been using for a long time!

In your README.md, you mention fzf.vim's : History doesn't work for you. I'm curious, would you mind sharing how CtrlP is different from : History, and specifically the use cases you found missing?

Thanks much!

Blend MRU with FZF results

Apologies if this is possible already and I've missed it in the documentation.

What I would like is to have all of the current directory FZF results available, but sorted by recency first, then FZF sort order afterwards; so that I can find any file in my project that I'm looking for, but have the most recent available first.

Is this possible?

Would be great to exclude files by mask

Me, I use Vim for composing emails with Mutt. And all those temporary files /private/var/folders/something/something/T/mutt-* also do appear in the MRU listing :)

Set max number of files kept in MRU source

Is there a hardcoded value for how many files are kept in the MRU source fed to fzf? I'd like to be able to set this to be infinitely large - I'm seeing some files I opened recently are not showing up after I opened a couple hundred new files yesterday. Thanks!

Add an MRU option to support selecting multiple files

Hi,

I was wondering if it would be okay to add a global variable like g:fzf_mru_multi or something similar to allow selection of multiple files. I don't want rely on adding --multi option to the global FZF options, since that breaks some of the other commands like Ctrl-r recent commands history.

I would be ready to create a PR to add this support if you think this is a valid request.

Thanks,
Anirudh

Doesn't update cache file if CtrlP is installed

I've been using this plugin for a while. Then yesterday I (re)installed ctrlp.vim to check something, and I noticed that fzf-mru.vim stopped adding new files to its cache. When I removed ctrlp.vim, it started updating again. Not sure where the conflict is.

Remove duplicates from MRU list?

I've noticed that there are duplicates in the file list displayed when there is a case difference. In my case it could just be the drive letter (C: vs c:) on Windows.

Obviously, some OSs have case-sensitive file names but even those it would be unusual to differentiate two files just by case!

However, to cater for both groups, please could you add (if it's not already there!), a variable to allow or disallow duplicates.

Question: how to use g:fzf_mru_store_relative_dirs?

Hey all,

I'm trying to have a shared MRU cache between 3 of my workspaces (all of which are git checkouts of the same repository), which live in the following folders:

  • /path/to/workspace1/src
  • /path/to/workspace2/src
  • /path/to/workspace3/src

Based on the documentation I tried to use g:fzf_mru_store_relative_dirs like this:

let g:fzf_mru_store_relative_dirs = [ 
      \ '/path/to/workspace1/src',
      \ '/path/to/workspace2/src',
      \ '/path/to/workspace3/src'
      \ ]

but that simply seems to break the MRU functionality.

Could anyone here help me understand how to get this to work?

Thanks in advance!

Jeroen

Make FZFMru command accept parameters similar to other FZF commands

I am trying to pass some setting/window size options to FZFMru, following the convention I have found on main fzf page

However I can't seem to make it work and looking at the source code of this plugin, it seems it's not possible to modify FZFMru command to accept additional arguments.

For example, I have something like this in my init.vim:

command! -bang -nargs=? Files call fzf#vim#files(<q-args>,
    \  {'window': {'width': 0.9, 'height': 0.6},
    \  'options': ['--reverse']}, <bang>0)

Is it possible to change the behavior of FZFMru to accept arguments like that?

File names doesn't stay sorted by recency as user starts typing.

The MRU files are originally sorted by recency, which is great. But as I start typing, the file list no longer stay sorted by recency, but is seemingly randomly sorted (probably by some FZF algorithm). This isn't very helpful because i'd still like the files i most recently opened to show up top on the MRU list if they are a match.

I think this can be easily fixed by adding a "--no-sort" param here:
https://github.com/pbogut/fzf-mru.vim/blob/master/plugin/fzf_mru.vim#L32

I'm happy to send a PR if we agree this is a better user experience. :)

File [Read error] - possibly related to `fugitive-vim'

Steps to reproduce:

  1. install https://github.com/tpope/vim-fugitive
  2. install this fzf-mru.vim
  3. open vim in a non git controlled dir
  4. call FZFMru
    Result:
  • File is opened with [Read error], needing to use ! to write it (call :file command in vim to see)
  • This error is shown:
Error detected while processing function 268[30]..<SNR>70_callback[23]..function 268[30]..<SNR>70_callback:
line   21:
Vim(return):E700: Unknown function: <SNR>70_repo_dir

See this screencast for visual detail:
https://asciinema.org/a/OOScgha5Lk4t7V0cwq9Z8MzSu

Removing vim-fugitive removes this eror.

MRU List is not being refreshed unless Neovim is closed

Similar to #6.

I opened/edited the apps/backoffice/generic/views/event.py file, but when I run :FZFMru it's not included in the list:
Screen Shot 2021-11-13 at 6 07 39 AM

But, it's already in the .cache/fzf_mru/cache.txt entries:
Screen Shot 2021-11-13 at 6 10 41 AM

and the fzf.vim's :History detected it as well:
Screen Shot 2021-11-13 at 6 07 53 AM

It will only be detected when I exit Neovim and open Neovim again. When is the MRU List being updated? Why it's working in fzf.vim but not in this plugin? Maybe need to double-check/compare the mechanisms?

Setup:

  • Mac OS - Mojave
  • Neovim 0.6

BTW, thanks for this plugin. It really has some convenient options. Although this issue is kinda big deal to me since the user would want to query also the recently closed file without exiting Neovim. :)

Documentation is lacking

There is not proper documentation. Optimal solution is to add a doc/fzf-mru.txt file in Vim help format, but I would propose a minimal solution is to update the README to document everyhing.

An example of something that is missing: the g:fzf_mru_exclude option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.