A pretty search & replace plugin for Neovim.
dragonfly.nvim
comes with the following features:
- 🔍 (Prettier) single file search and replace
- 📁 Project-wide search and replace
- ✅ Toggles for case sensitivity, regular expression searching, and whole-word-only matching
- 🚫 Optional ignoring for gitignored files, dotfiles, etc.
- ⚡ Rapid performance with ripgrep
It's required to install ripgrep before using dragonfly.nvim
.
Basic installation expample (with lazy.nvim
):
{
"vi013t/dragonfly.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {},
keys = {
{ "/", "<cmd>DragonflyBuffer<cr>" },
{ "?", "<cmd>DragonflyBufferReplace<cr>" },
{ "<C-/>", "<cmd>DragonflyProject<cr>" },
{ "<C-?>", "<cmd>DragonflyProjectReplace<cr>" },
}
}
Default Configuration
{
"vi013t/dragonfly.nvim",
opts = {
-- Function to call when the project window is opened
on_open = function() end,
-- Function to call when the project window is closed
on_close = function() end,
-- Default options when searching for the first time since opening Neovim
default_search_options = {
-- Whether searches are case-sensitive by default
case_sensitive = true,
-- Whether searches use regular expressions by default
regex = false,
-- Whether searches match whole-words only by default
whole_word = false,
},
-- Types of files to ignore by default. Currently only supports "gitignored" and "dotfiles".
ignore = {
-- Ignore files not tracked by Git
"gitignored",
-- Ignore hidden files such as dotfiles
"dotfiles",
},
-- Highlight options
highlights = {
-- Highlight for "active" or "foreground" text
active = { link = "@type" },
-- Highlight for "inactive" or "background" text
inactive = { link = "@comment" },
}
},
keys = {
{ "/", "<cmd>DragonflyBuffer<cr>" },
{ "?", "<cmd>DragonflyBufferReplace<cr>" },
{ "<C-/>", "<cmd>DragonflyProject<cr>" },
{ "<C-?>", "<cmd>DragonflyProjectReplace<cr>" },
}
}
Example of replacing Neo-Tree
{
"vi013t/dragonfly.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {
-- Close Neotree when opening Dragonfly
on_open = function()
if vim.fn.exists(":NeoTreeClose") == 2 then vim.cmd("NeoTreeClose") end
end,
-- Reopen Neotree when closing Dragonfly
on_close = function()
local has_neotree = pcall(function() require("neo-tree") end)
if has_neotree then vim.cmd("Neotree") end
end,
},
keys = {
{ "/", "<cmd>DragonflyBuffer<cr>" },
{ "?", "<cmd>DragonflyBufferReplace<cr>" },
{ "<C-/>", "<cmd>DragonflyProject<cr>" },
{ "<C-?>", "<cmd>DragonflyProjectReplace<cr>" },
}
},
Example config for `bufferline.nvim` title (like in demo)
{
"akinsho/bufferline.nvim",
config = function()
-- Create highlight group
local bg = vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("NormalFloat")), "bg#")
local fg = vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("@type")), "fg#")
vim.api.nvim_set_hl(0, "BufferlineDragonflyOffset", { bg = bg, fg = fg })
-- Set up bufferline
bufferline.setup({
options = {
offsets = {
{
filetype = "dragonfly",
text = " Dragonfly",
highlight = "BufferlineDragonflyOffset"
}
}
},
})
end
}
dragonfly.nvim
provides a prettier single-buffer search and replace. :DragonflyBuffer
will open a single-buffer search, and :DragonflyBufferReplace
will open a single-buffer search and replace.
In a search or search-and-replace, pressing escape
will close and cancel the search/replace. Pressing enter will perform the search/replace.
Use tab
and shift + tab
to navigate to the next and previous input boxes, respectively.
Search matches are automatically highlighted, but switching into insert or command mode will unhighlight them all.
dragonfly.nvim
provides a pretty project-wide search and replace. :DragonflyProject
will open a project-wide search, and :DragonflyProjectReplace
will open a project-wide search and replace.
In a search or search-and-replace, pressing escape will unfocus the window and return focus to the previous window.
Use tab
and shift + tab
to navigate to the next and previous input boxes, respectively.
Pressing enter
on a search match will jump you to that match.
- Why use
dragonfly.nvim
over built-in Vim searching?dragonfly.nvim
features project-wide searching that can respect.gitignore
, among other things.
- Why use
dragonfly.nvim
overnvim-spectre
/fzf-lua
/ etc.?- Up to you. This plugin was designed to be tightly focused with a simple and intuitive UI.
- Why is it called
dragonfly.nvim
?- Dragonflies are the best hunters of any creatures. This plugin helps you hunt down strings rapidly.