Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/al-ce/opptogg.nvim
Neovim plugin to toggle a word under the cursor to its 'opposite' value
https://github.com/al-ce/opptogg.nvim
Last synced: 2 days ago
JSON representation
Neovim plugin to toggle a word under the cursor to its 'opposite' value
- Host: GitHub
- URL: https://github.com/al-ce/opptogg.nvim
- Owner: al-ce
- License: mit
- Created: 2022-08-08T03:00:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-09T03:35:01.000Z (about 2 years ago)
- Last Synced: 2024-12-24T00:56:03.823Z (3 days ago)
- Language: Lua
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OppTogg
Toggle a word under the cursor to its 'opposite value', e.g. `True` -> `False`.
## Installation and Setup
With packer:
```lua
use({
"al-ce/opptogg.nvim",
config = function()
require('opptogg').setup({
-- config or leave empty for defaults
})
end
})
```## Usage
Set the cursor over a word in OppTogg's table and execute `:OppTogg` to
substitute its 'opposite'. The cursor remains in its current position.
Example (where `*` denotes cursor position):```
Before | After
------------------|--------------------
if foo == tr*ue: | if foo == fa*lse:
```## Configuration
This shows the default configuration. Passing a new table to `opp_table` will
override the default table completely.No mapping is set by default. Set a mapping for `:OppTogg` on your own or set
a string value in `mapping` to have the config do it for you.```lua
require('opptogg').setup({
opp_table = {
["True"] = "False",
["true"] = "false",
["0"] = "1",
["yes"] = "no",
["Yes"] = "No",
["foo"] = "bar",
["var1"] = "var2",
},
mapping = '', -- I use ` since ` toggles upper/lower case.
})
```## Known Issues
Currently, only words with characters matched by the regex `\k` can be toggled.
This excludes symbols like `+-*/=~!` and spaces.## Acknowledgements
[cursor-word.nvim](https://github.com/xiyaowong/nvim-cursorword/blob/master/plugin/nvim-cursorword.lua) for the code to match the word under the cursor.