Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add optional search and replace integration (grug-far.nvim) #250

Merged
merged 4 commits into from
Jul 24, 2024

Conversation

mikavilpas
Copy link
Owner

This commit adds an integration with grug-far.nvim, a plugin that provides a way to search and replace in the current working directory. It was recently added in LazyVim as the default, and it's really easy to use.

When you press the keybinding (default: <c-g>), yazi will close and grug-far.nvim will open with the current directory prefilled in the search field. This makes it easy to search and replace in that directory only. Note that this only seems to work when the target directory is under cwd, so it's not possible to search in a parent directory.

grug-far-integration.mov

The integration is added as a keymap in the config. The keymap is set to <c-g> by default, but it can be changed in the config.

To configure it, set one of these in your yazi.nvim config:

-- to disable using the keymap entirely
{
  keymaps = {
    replace_in_directory = false
  }
}

-- to change the keybinding to something else
{
  keymaps = {
    replace_in_directory = "<c-o>"
  }
}

-- advanced: to create a custom integration for yourself
{
  integrations = {
    replace_in_directory = function (directory)
      -- your custom implementation
    end
  },
}

https://github.com/MagicDuck/grug-far.nvim

This commit adds an integration with grug-far.nvim, a plugin that
provides a way to search and replace in the current working directory.
It was recently added in LazyVim as the default, and it's really easy to
use.

When you press the keybinding (default: `<c-g>`), yazi will close and
grug-far.nvim will open with the current directory prefilled in the
search field. This makes it easy to search and replace in that directory
only. Note that this only seems to work when the target directory is
under cwd, so it's not possible to search in a parent directory.

The integration is added as a keymap in the config. The keymap is set to
`<c-g>` by default, but it can be changed in the config.

To configure it, set one of these in your yazi.nvim config:

```lua
-- to disable using the keymap entirely
{
  keymaps = {
    replace_in_directory = false
  }
}

-- to change the keybinding to something else
{
  keymaps = {
    replace_in_directory = "<c-o>"
  }
}

-- advanced: to create a custom integration for yourself
{
  integrations = {
    replace_in_directory = function (directory)
      -- your custom implementation
    end
  },
}
```

<https://github.com/MagicDuck/grug-far.nvim>
@mikavilpas mikavilpas merged commit b512d38 into main Jul 24, 2024
14 checks passed
@mikavilpas mikavilpas deleted the grug-far-integration branch July 24, 2024 09:02
This was referenced Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant