From 1ab229c2a682987f4260b946320f1393e9fa3119 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Thu, 19 Sep 2024 11:05:51 -0400 Subject: [PATCH] feat(grug-far-nvim): add integration with `neo-tree` --- .../search/grug-far-nvim/init.lua | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lua/astrocommunity/search/grug-far-nvim/init.lua b/lua/astrocommunity/search/grug-far-nvim/init.lua index 89b85f04a..ccbc0df12 100644 --- a/lua/astrocommunity/search/grug-far-nvim/init.lua +++ b/lua/astrocommunity/search/grug-far-nvim/init.lua @@ -81,10 +81,34 @@ return { opts.disable.ft = require("astrocore").list_insert_unique(opts.disable.ft, { "grug-far" }) end, }, + { + "nvim-neo-tree/neo-tree.nvim", + optional = true, + opts = { + commands = { + grug_far_replace = function(state) + local node = state.tree:get_node() + local prefills = { paths = node:get_id() } + if node.type ~= "directory" then prefills.paths = vim.fn.fnamemodify(prefills.paths, ":h") end + local grug_far = require "grug-far" + if not grug_far.has_instance "tree" then + grug_far.open { instanceName = "tree", prefills = prefills, staticTitle = "Find and Replace from Tree" } + else + grug_far.open_instance "tree" + grug_far.update_instance_prefills("tree", prefills, false) + end + end, + }, + window = { + mappings = { + gs = "grug_far_replace", + }, + }, + }, + }, }, ---@param opts GrugFarOptionsOverride opts = function(_, opts) - opts.windowCreationCommand = "split" if not opts.icons then opts.icons = {} end opts.icons.enabled = vim.g.icons_enabled if not vim.g.icons_enabled then