Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# 🎚️ relative-toggle.nvim

Automatically toggling smoothly between relative and absolute line numbers in various Neovim events. This is useful when you want to take advantage of the information on those types of numbers in different situations.
Automatically toggles smoothly between relative and absolute line numbers on various Neovim events. This is useful when you want to take advantage of both types of line numbers in different situations.

![demo](https://user-images.githubusercontent.com/42694704/227732590-e95d94e9-6c06-45dd-91aa-b419525df295.mov)

## 📦 Installation
## 🚀 Installation

```lua
use "cpea2506/relative-toggle.nvim"
{
"cpea2506/relative-toggle.nvim"
}
```

### Requirements
Expand All @@ -16,20 +18,20 @@ use "cpea2506/relative-toggle.nvim"

## ⚙️ Setup

After installed, this plugin will automatically active so no setup statement is required unless you want to custom some options.
Once installed, this plugin is activated automatically. No setup is required unless you want to customize the options.

### Options
### Available Options

| Option | Description | Type | Note |
| ------------ | ----------------------------------------- | -------------- | -------------------- |
| `pattern` | pattern where the plugin should be enable | `string/table` | `:h autocmd-pattern` |
| `events.on` | event to toggle relative number on | `string/table` | `:h autocmd-events` |
| `events.off` | event to toggle relative number off | `string/table` | `:h autocmd-events` |
| Option | Description | Type | Note |
| ------------ | ------------------------------------------- | --------------- | -------------------- |
| `pattern` | Patterns where the plugin should be enabled | `string\|table` | `:h autocmd-pattern` |
| `events.on` | Events that turn relative numbers on | `string\|table` | `:h autocmd-events` |
| `events.off` | Events that turn relative numbers off | `string\|table` | `:h autocmd-events` |

#### Default
### Default Configuration

```lua
require("relative-toggle").setup ({
require("relative-toggle").setup({
pattern = "*",
events = {
on = { "BufEnter", "FocusGained", "InsertLeave", "WinEnter", "CmdlineLeave" },
Expand All @@ -40,36 +42,34 @@ require("relative-toggle").setup ({

## 💡 Tips

1. The keymap `Ctrl-C` does not trigger the `InsertLeave` event (`:h i_CTRL-C`) so you need to use another keymap that has a capability to do it. For ex:
1. The keymap `Ctrl-C` does **not** trigger the `InsertLeave` event (`:h i_CTRL-C`), so you’ll need to use another keymap that does. For example:

- Builtin keymap: `Esc`, `Ctrl-[`, `Ctrl-o`,...
- Escape mapping plugins: [better-escape][better-escape], [houdini][houdini],...
- Built-in keymaps: `Esc`, `Ctrl-[`, `Ctrl-o`, ...
- Escape-mapping plugins: [better-escape][better-escape], [houdini][houdini], ...

2. To make sure the numbers really **toggle** (lol), when you define an event in `events.on` table, you should define its opposite event in `events.off` table. For ex: `BufEnter - BufLeave`, `VimEnter - VimLeave`,...
2. To ensure the numbers actually **toggle** (lol), when you define an event in the `events.on` table, you should also define its corresponding "off" event in the `events.off` table. For example: `BufEnter` - `BufLeave`, `VimEnter` - `VimLeave`, ...

3. The `relativenumber` is always on by default. So based on the value of `vim.opt.number`, the displayed number to be
relative to the cursor will be changed as follows (`:h number_relativenumber`):
3. The `relativenumber` option is always enabled by default. So, based on the value of `vim.opt.number`, the line numbers displayed relative to the cursor will change as follows (`:h number_relativenumber`):

```nvim
'nonu' 'nu'
'rnu' 'rnu'
'nonu' 'nu'
'rnu' 'rnu'

| 2 apple | 2 apple
| 1 pear | 1 pear
|0 nobody |3 nobody
| 1 there | 1 there
| 2 apple | 2 apple
| 1 pear | 1 pear
|0 nobody |3 nobody
| 1 there | 1 there
```

## Inspiration
## :eyes: Inspiration

- [nvim-numbertoggle](https://github.com/sitiom/nvim-numbertoggle)

## Contribution
## :scroll: Contribution

Please see [the contributing guidelines](CONTRIBUTING.md) for detailed
instructions on how to contribute to this project.
For detailed instructions on how to contribute to this plugin, please see [the contributing guidelines](CONTRIBUTING.md).

<!--- references --->
<!--- References --->

[better-escape]: https://github.com/max397574/better-escape.nvim
[houdini]: https://github.com/TheBlob42/houdini.nvim
Loading