mfussenegger / nvim-fzy

Fuzzy picker & vim.ui.select implementation via fzy for neovim
GNU General Public License v3.0
55 stars 4 forks source link

how can i replace current buffer when finding files? #5

Closed zzzeyez closed 3 years ago

zzzeyez commented 3 years ago

awesome plugin btw. very speedy, just wished it didn't create new buffers

mfussenegger commented 3 years ago

awesome plugin btw. very speedy, just wished it didn't create new buffers

You could create your custom callback function.

Create a ~/.config/nvim/lua/util.lua with:


local M = {}

function M.edit_file(filename)
  if filename and filename ~= '' then
    vim.cmd('bd! | e ' .. filename)
  end
end

return M

And then adapt your mapping:

lua fzy = require('fzy')
nnoremap <silent><leader>ff :lua fzy.execute('fd', require('util').edit_file)<CR>

You can change the name of util / util.lua to anything else, but it shouldn't conflict with a plugin.

zzzeyez commented 3 years ago

awesome, that works perfectly. thanks so much