Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rmagatti/alternate-toggler
A very small plugin for toggling alternate "boolean" values.
https://github.com/rmagatti/alternate-toggler
hacktoberfest lua neovim neovim-plugin
Last synced: 3 days ago
JSON representation
A very small plugin for toggling alternate "boolean" values.
- Host: GitHub
- URL: https://github.com/rmagatti/alternate-toggler
- Owner: rmagatti
- License: mit
- Created: 2021-03-12T05:44:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-04T16:46:08.000Z (6 months ago)
- Last Synced: 2024-08-07T18:38:58.153Z (3 months ago)
- Topics: hacktoberfest, lua, neovim, neovim-plugin
- Language: Lua
- Homepage:
- Size: 20.5 KB
- Stars: 68
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Alternate Toggler
Alternate Toggler is a _very_ small plugin for toggling alternate "boolean" values.![](https://github.com/rmagatti/readme-assets/blob/main/alternate-toggler.gif)
# Usage
`:ToggleAlternate` toggles the current word () based on a pre-defined map of alternates.# Installation
Any plugin manager should do, I use [Packer](https://github.com/wbthomason/packer.nvim).```lua
use {
'rmagatti/alternate-toggler',
config = function()
require("alternate-toggler").setup {
alternates = {
["=="] = "!="
}
}
vim.keymap.set(
"n",
"", --
"lua require('alternate-toggler').toggleAlternate()"
)
end,
event = { "BufReadPost" }, -- lazy load after reading a buffer
}
```# Configuration
### Defaults
This plugin provides a few pre-defined alternate mappings.
```lua
{
["true"] = "false",
["True"] = "False",
["TRUE"] = "FALSE",
["Yes"] = "No",
["YES"] = "NO",
["1"] = "0",
["<"] = ">",
["("] = ")",
["["] = "]",
["{"] = "}",
['"'] = "'",
['""'] = "''",
["+"] = "-",
["==="] = "!=="
}
```### Custom
You can add more alternates through a global config variable:
```viml
let g:at_custom_alternates = {'===': '!=='}
```Or through calling the `setup` method of the plugin passing in an `alternates` table in the config.
```lua
require("alternate-toggler").setup {
alternates = {
["==="] = "!==",
["=="] = "!=",
}
}
```
:warning: WARNING: anything added here will override existing values if the key of the dict/table is the same as any of the defaults.# Commands
Alternate Toggler exposes a single `:ToggleAlternate` command.**Example mappings:**
```viml
nnoremap ta :ToggleAlternate
```
**OR**
```viml
augroup AlternateToggles
au!
au FileType typescript,viml,lua nnoremap :ToggleAlternate
augroup end
```
This allows for merely hitting the enter key to toggle an alternate, the caveat is having to specify supported file types manually.# Compatibility
Neovim > 0.5Tested with:
```
NVIM v0.5.0-dev+a1ec36f
Build type: Release
LuaJIT 2.1.0-beta3
```