nvim/lua/plugins/fzf.lua

51 lines
1.5 KiB
Lua

return {
-- auto-cd to root of git project
-- 'airblade/vim-rooter'
{
"notjedi/nvim-rooter.lua",
config = function()
require("nvim-rooter").setup()
end,
},
{
"junegunn/fzf.vim",
dependencies = {
{ "junegunn/fzf", dir = "~/.fzf", build = "./install --all" },
},
config = function()
-- stop putting a giant window over my editor
vim.g.fzf_layout = { down = "~20%" }
-- when using :Files, pass the file list through
--
-- !!!! https://github.com/jonhoo/proximity-sort
--
-- to prefer files closer to the current file.
function list_cmd()
local base = vim.fn.fnamemodify(vim.fn.expand("%"), ":h:.:S")
if base == "." then
-- if there is no current file,
-- proximity-sort can't do its thing
return "fd --type file --follow"
else
return vim.fn.printf(
"fd --type file --follow | proximity-sort %s",
vim.fn.shellescape(vim.fn.expand("%"))
)
end
end
-- vim.keymap.set("n", "<leader>ps", function()
-- builtin.grep_string({ search = vim.fn.input("Grep > ") })
-- end)
vim.api.nvim_create_user_command("MyFiles", function(arg)
vim.fn["fzf#vim#files"](arg.qargs, { source = list_cmd(), options = "--tiebreak=index" }, arg.bang)
end, { bang = true, nargs = "?", complete = "dir" })
-- vim.keymap.set("n", "<leader>pf", "<cmd>MyFiles<CR>")
-- vim.keymap.set("n", "<leader>fg", "<cmd>GFiles<CR>")
-- vim.keymap.set("n", "<leader>bb", "<cmd>Buffers<CR>")
-- vim.keymap.set("n", "<leader>ps", ":Rg ")
end,
},
}