Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielpoca/replacer.nvim
A powerful refactoring tool for nvim.
https://github.com/gabrielpoca/replacer.nvim
Last synced: about 14 hours ago
JSON representation
A powerful refactoring tool for nvim.
- Host: GitHub
- URL: https://github.com/gabrielpoca/replacer.nvim
- Owner: gabrielpoca
- Created: 2020-12-04T00:50:49.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-22T16:03:50.000Z (about 1 year ago)
- Last Synced: 2024-11-07T04:12:19.926Z (8 days ago)
- Language: Lua
- Homepage:
- Size: 10.9 MB
- Stars: 289
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# replacer.nvim
replacer.nvim makes quickfix windows editable, allowing changes to both the
content of a file and its path. You can use this to rename variables and files
easily. When moving a file around, if the origin folder gets empty, it's
deleted.See the example below.
https://github.com/gabrielpoca/replacer.nvim/assets/934580/ad87499c-5699-4544-a458-9329593eff0a
## Using the plugin
First, populate a quickfix window with the lines and files you want to
change. If you don't know how, try the `:Rg` command from [fzf.vim](https://github.com/junegunn/fzf.vim).Now, inside the quickfix window, execute `:lua require("replacer").run()`.
You can also map it to a shortcut, for instance in lua:```lua
api.nvim_set_keymap('n', 'h', ':lua require("replacer").run()', { silent = true })
```Or in VimScript:
```
nmap h :lua require("replacer").run()
```Your quickfix window will change and now you can edit the lines and
move/rename the files.Save the buffer when you're done. That's it.
### Renaming files
Renaming/moving files is enabled by default. To disable this functionality, set
the option `rename_files`. For instance:```lua
api.nvim_set_keymap('n', 'h', ':lua require("replacer").run({ rename_files = false })', { silent = true })
```### Saving the changes
By default, changes are saved when you write the buffer. To disable this
functionality and instead set a custom shortcut to save the changes, set the
`save_on_write` option and execute the `save` function. For instance:```lua
local opts = { save_on_write = false, rename_files = false }api.nvim_set_keymap('n', 'h', ':lua require("replacer").run(opts)', { silent = true })
api.nvim_set_keymap('n', 'H', ':lua require("replacer").save(opts)', { silent = true })
```Notice that the options are sent to both `run` and `save`. This is important
for consistent behavior.### Global options
You can also use the `setup` function to set global options. For instance, with
lazy.nvim you can do something like this:```lua
{
dir = 'gabrielpoca/replacer.nvim',
opts = {rename_files = false},
keys = {
{
'h',
function() require('replacer').run() end,
desc = "run replacer.nvim"
}
}
}
```The `rename_files` will be set to `false` by default in every execution
of the functions `run` and `save`.