From f4acc06bd37d6e3fca9c2f3426cbec56cbe612e6 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Mon, 10 Jun 2024 07:31:46 -0400 Subject: [PATCH] feat(fuzzy-finder): add `fzf-lua` --- .../fuzzy-finder/fzf-lua/README.md | 5 ++ .../fuzzy-finder/fzf-lua/init.lua | 67 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 lua/astrocommunity/fuzzy-finder/fzf-lua/README.md create mode 100644 lua/astrocommunity/fuzzy-finder/fzf-lua/init.lua diff --git a/lua/astrocommunity/fuzzy-finder/fzf-lua/README.md b/lua/astrocommunity/fuzzy-finder/fzf-lua/README.md new file mode 100644 index 000000000..7da3189a2 --- /dev/null +++ b/lua/astrocommunity/fuzzy-finder/fzf-lua/README.md @@ -0,0 +1,5 @@ +# fzf-lua + +Improved fzf.vim written in lua + +**Repository:** diff --git a/lua/astrocommunity/fuzzy-finder/fzf-lua/init.lua b/lua/astrocommunity/fuzzy-finder/fzf-lua/init.lua new file mode 100644 index 000000000..67c9689bb --- /dev/null +++ b/lua/astrocommunity/fuzzy-finder/fzf-lua/init.lua @@ -0,0 +1,67 @@ +return { + { "nvim-telescope/telescope.nvim", enabled = false }, + { "nvim-telescope/telescope-fzf-native.nvim", enabled = false }, + { "stevearc/dressing.nvim", optional = true, opts = { select = { backend = { "fzf_lua" } } } }, + { + "ibhagwan/fzf-lua", + cmd = "FzfLua", + dependencies = { + { + "AstroNvim/astrocore", + opts = function(_, opts) + local maps = opts.mappings + maps.n["f"] = vim.tbl_get(opts, "_map_sections", "f") + if vim.fn.executable "git" == 1 then + maps.n["g"] = vim.tbl_get(opts, "_map_sections", "g") + maps.n["gb"] = { function() require("fzf-lua").git_branches() end, desc = "Git branches" } + maps.n["gc"] = + { function() require("fzf-lua").git_commits() end, desc = "Git commits (repository)" } + maps.n["gC"] = + { function() require("fzf-lua").git_bcommits() end, desc = "Git commits (current file)" } + maps.n["gt"] = { function() require("fzf-lua").git_status() end, desc = "Git status" } + end + maps.n["f"] = { function() require("fzf-lua").resume() end, desc = "Resume previous search" } + maps.n["f'"] = { function() require("fzf-lua").marks() end, desc = "Find marks" } + maps.n["f/"] = + { function() require("fzf-lua").lgrep_curbuf() end, desc = "Find words in current buffer" } + maps.n["fa"] = { + function() require("fzf-lua").files { prompt = "Config> ", cwd = vim.fn.stdpath "config" } end, + desc = "Find AstroNvim config files", + } + maps.n["fb"] = { function() require("fzf-lua").buffers() end, desc = "Find buffers" } + maps.n["fc"] = { function() require("fzf-lua").grep_cword() end, desc = "Find word under cursor" } + maps.n["fC"] = { function() require("fzf-lua").commands() end, desc = "Find commands" } + maps.n["ff"] = { function() require("fzf-lua").files() end, desc = "Find files" } + maps.n["fh"] = { function() require("fzf-lua").helptags() end, desc = "Find help" } + maps.n["fk"] = { function() require("fzf-lua").keymaps() end, desc = "Find keymaps" } + maps.n["fm"] = { function() require("fzf-lua").manpages() end, desc = "Find man" } + maps.n["fo"] = { function() require("fzf-lua").oldfiles() end, desc = "Find history" } + maps.n["fr"] = { function() require("fzf-lua").registers() end, desc = "Find registers" } + maps.n["ft"] = { function() require("fzf-lua").colorschemes() end, desc = "Find themes" } + if vim.fn.executable "rg" == 1 or vim.fn.executable "grep" == 1 then + maps.n["fw"] = { function() require("fzf-lua").live_grep_native() end, desc = "Find words" } + end + maps.n["ls"] = { function() require("fzf-lua").lsp_document_symbols() end, desc = "Search symbols" } + end, + }, + }, + opts = { "default-title" }, + }, + { + "AstroNvim/astrolsp", + optional = true, + opts = function(_, opts) + if require("astrocore").is_available "fzf-lua" then + local maps = opts.mappings + maps.n["lD"] = { function() require("fzf-lua").diagnostics_document() end, desc = "Search diagnostics" } + if maps.n.gd then maps.n.gd[1] = function() require("fzf-lua").lsp_definitions() end end + if maps.n.gI then maps.n.gI[1] = function() require("fzf-lua").lsp_implementations() end end + if maps.n["lR"] then maps.n["lR"][1] = function() require("fzf-lua").lsp_references() end end + if maps.n.gy then maps.n.gy[1] = function() require("fzf-lua").lsp_typedefs() end end + if maps.n["lG"] then + maps.n["lG"][1] = function() require("fzf-lua").lsp_workspace_symbols() end + end + end + end, + }, +}