Skip to content

Commit

Permalink
docs: write them
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Jun 4, 2024
1 parent ba8909f commit 68a728b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,28 @@ A modern substitute for vim's `:substitute` using `ripgrep`.
<!-- tocstop -->

## Features
-
- Search and replace using `ripgrep` – no more esoteric vim regex to learn.
- Incremental preview of matches and replacements.
- Popup window instead of command line. This means:
+ Syntax highlighting of the regex.
+ Editing with vim motions.
+ No more delimiters decreasing readability.
- Sensible defaults: searches the entire buffer (`%`), all matches in a line
(`/g`), case-sensitive (`/I`).
- Automatic prefill of the search term: cursorword (normal mode), selected text
(visual mode).
- Notification on how many replacements were made (optional).

## Installation
**Requirements**
- `ripgrep`
- nvim >= 0.10
- `:TSInstall regex` (optional, but recommended)

```lua
-- lazy.nvim
{
"chrisgrieser/rip-substitute",
"chrisgrieser/nvim-rip-substitute",
keys = {
{
"<leader>fs",
Expand All @@ -44,7 +58,7 @@ A modern substitute for vim's `:substitute` using `ripgrep`.

-- packer
use {
"chrisgrieser/rip-substitute",
"chrisgrieser/nvim-rip-substitute",
}
```

Expand All @@ -53,7 +67,7 @@ use {
```lua
-- default settings
require("rip-substitute").setup {
window = {
popupWin = {
width = 40,
border = "single",
},
Expand All @@ -62,11 +76,11 @@ require("rip-substitute").setup {
abort = "q",
},
regexOptions = {
-- enables lookarounds and backreferences, but slower performance
-- pcre2 enables lookarounds and backreferences, but performs slower.
pcre2 = true,
-- By default, rg treats `$1a` as the named capture group "1a". When set
-- to `true`, and `$1a` is automatically changed to `${1}a` to ensure the
-- capture group is correctly determined. Disable this setting, if you
-- to `true`, `$1a` is automatically changed to `${1}a` to ensure the
-- capture group is correctly determined. Disable this setting if you
-- plan an using named capture groups.
autoBraceSimpleCaptureGroups = true,
},
Expand All @@ -83,8 +97,8 @@ require("rip-substitute").sub()
```

## Limitations
- `--multiline` is not supported yet.
- Various flags are not supported yet.
- `--multiline` and various other flags are not supported yet.
- The incremental preview does not support *hiding* the search terms.

<!-- vale Google.FirstPerson = NO -->
## About the developer
Expand Down
8 changes: 4 additions & 4 deletions lua/rip-substitute/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local M = {}

---@class ripSubstituteConfig
local defaultConfig = {
window = {
popupWin = {
width = 40,
border = "single",
},
Expand All @@ -12,11 +12,11 @@ local defaultConfig = {
abort = "q",
},
regexOptions = {
-- enables lookarounds and backreferences, but slower performance
-- pcre2 enables lookarounds and backreferences, but performs slower.
pcre2 = true,
-- By default, rg treats `$1a` as the named capture group "1a". When set
-- to `true`, and `$1a` is automatically changed to `${1}a` to ensure the
-- capture group is correctly determined. Disable this setting, if you
-- to `true`, `$1a` is automatically changed to `${1}a` to ensure the
-- capture group is correctly determined. Disable this setting if you
-- plan an using named capture groups.
autoBraceSimpleCaptureGroups = true,
},
Expand Down
6 changes: 3 additions & 3 deletions lua/rip-substitute/popup-win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ function M.substitute()
local rgWin = vim.api.nvim_open_win(state.rgBuf, true, {
relative = "win",
row = vim.api.nvim_win_get_height(0) - 4,
col = vim.api.nvim_win_get_width(0) - config.window.width - scrollbarOffset - 2,
width = config.window.width,
col = vim.api.nvim_win_get_width(0) - config.popupWin.width - scrollbarOffset - 2,
width = config.popupWin.width,
height = 2,
style = "minimal",
border = config.window.border,
border = config.popupWin.border,
title = "  rip substitute ",
title_pos = "center",
zindex = 1, -- below nvim-notify
Expand Down

0 comments on commit 68a728b

Please sign in to comment.