{"id":25217147,"url":"https://github.com/tigion/nvim-opposites","last_synced_at":"2025-04-05T09:21:37.593Z","repository":{"id":276542314,"uuid":"928903272","full_name":"tigion/nvim-opposites","owner":"tigion","description":"A Neovim plugin to quickly switch a word to its opposite word.","archived":false,"fork":false,"pushed_at":"2025-02-16T21:41:58.000Z","size":29,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T15:00:07.213Z","etag":null,"topics":["lua","neovim","neovim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tigion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-07T12:57:46.000Z","updated_at":"2025-03-27T03:55:30.000Z","dependencies_parsed_at":"2025-02-16T22:21:22.550Z","dependency_job_id":null,"html_url":"https://github.com/tigion/nvim-opposites","commit_stats":null,"previous_names":["tigion/nvim-opposites"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigion%2Fnvim-opposites","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigion%2Fnvim-opposites/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigion%2Fnvim-opposites/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigion%2Fnvim-opposites/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tigion","download_url":"https://codeload.github.com/tigion/nvim-opposites/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247313231,"owners_count":20918591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","neovim","neovim-plugin"],"created_at":"2025-02-10T20:12:58.855Z","updated_at":"2025-04-05T09:21:37.585Z","avatar_url":"https://github.com/tigion.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nvim-opposites\n\nA Neovim plugin to quickly switch the word under the cursor to its opposite word.\n\nFor example, if the cursor is on `enable` and you press `\u003cLeader\u003ei` it will\nswitch to `disable` and vice versa.\n\n\u003e [!WARNING]\n\u003e This plugin is based on my personal needs. Work in progress. 🚀\n\nOther similar plugins are:\n\n- [nguyenvukhang/nvim-toggler](https://github.com/nguyenvukhang/nvim-toggler)\n\n## Features\n\n- Searches for the configured words and opposite words in the current line\n  under the cursor.\n- Switches the found word to its opposite word.\n- The found word can also be a part of another word.\n  - e.g. _enabled_ with the cursor in `enable` becomes _disabled_.\n- Adapts the capitalization of the replaced word.\n  - e.g. `true`, `True`, `TRUE` -\u003e `false`, `False`, `FALSE`.\n- The opposite words can be file type specific.\n- Optionally notifies when the word is found or not.\n- If several results are found, the user is asked which result to switch to.\n\n## Requirements\n\n- Neovim \u003e= 0.10\n\n## Installation\n\n### [lazy.nvim]\n\n[lazy.nvim]: https://github.com/folke/lazy.nvim\n\n```lua\nreturn {\n  'tigion/nvim-opposites',\n  -- event = { 'BufReadPost', 'BufNewFile' },\n  keys = {\n    { '\u003cLeader\u003ei', function() require('opposites').switch() end, desc = 'Switch to opposite word' },\n  },\n  ---@type opposites.Config\n  opts = {},\n}\n```\n\n## Usage\n\nCall `require('opposites').switch()` to switch to the opposite word under the\ncursor.\n\nTo add more words to the opposites list, add them to the `opposites` or\n`opposites_by_ft` table in the `opposites.Config` table.\n\n\u003e [!NOTE]\n\u003e Redundant opposite words are removed automatically.\n\nIf `use_default_opposites` and `use_default_opposites_by_ft` is set to `false`,\nonly the user defined words will be used.\n\n```lua\nopts = {\n  opposites = {\n    ['angel'] = 'devil', -- Adds a new default.\n    ['yes'] = 'ja',      -- Replaces the default `['yes'] = 'no'`.\n    ['min'] = nil,       -- Removes a default.\n  },\n  opposites_by_ft = {\n    ['lua'] = {\n      ['=='] = '~=',     -- Replaces the default `['=='] = '!='` for lua files.\n    },\n    ['sql'] = {\n      ['AND'] = 'OR',  -- Adds a new for SQL files.\n    },\n  },\n}\n```\n\n\u003e [!TIP]\n\u003e It doesn't have to be opposites words that are exchanged.\n\n### Case sensitive mask\n\nFlexible word recognition can be used to avoid having to configure every\nvariant of capitalization. Activated by default.\nThis means that variants with capital letters are also found for lower-case\nwords and the replaced opposite word adapts the capitalization.\n\nRules:\n\n- If the word is uppercase, the mask is upper case.\n- If the word is lowercase, the mask is lower case.\n- If the word is mixed case, the mask is a string to represent the case. Longer\n  words are masked at the end with lower case letters.\n\nDeactivate this behavior by setting `use_case_sensitive_mask = false`.\n\n\u003e [!IMPORTANT]\n\u003e If a configured word or his opposite word contains capital letters, then for\n\u003e this words no mask is used.\n\nExample with `['enable'] = 'disable'`:\n\n- found: `enable`, `Enable`, `EnAbLe` and `ENABLE`\n- replaced with: `disable`, `Disable`, `diSAble` and `DISABLE`\n\nExample with `['enable'] = 'Disable'`:\n\n- found: `enable`\n- replaced with: `Disable`\n\n## Configuration\n\nThe default options are:\n\n```lua\n---@class opposites.Config -- opposites.config.config\n---@field max_line_length? integer The maximum line length to search.\n---@field use_case_sensitive_mask? boolean Whether to use a case sensitive mask.\n---@field use_default_opposites? boolean Whether to use the default opposites.\n---@field use_default_opposites_by_ft? boolean Whether to use the default opposites.\n---@field opposites? opposites.Config.opposites The words with their opposite.\n---@field opposites_by_ft? opposites.Config.opposites_by_ft The file type specific words with their opposite.\n---@field notify? opposites.Config.notify The notifications to show.\n\n---@alias opposites.Config.opposites table\u003cstring, string\u003e\n---@alias opposites.Config.opposites_by_ft table\u003cstring, opposites.Config.opposites\u003e\n\n---@class opposites.Config.notify\n---@field found? boolean Whether to notify when a word is found.\n---@field not_found? boolean Whether to notify when no word is found.\n\n---@type opposites.Config\n{\n  max_line_length = 1000,\n  use_case_sensitive_mask = true,\n  use_default_opposites = true,\n  use_default_opposites_by_ft = true,\n  opposites = {\n    ['enable'] = 'disable',\n    ['true'] = 'false',\n    ['yes'] = 'no',\n    ['on'] = 'off',\n    ['left'] = 'right',\n    ['up'] = 'down',\n    ['min'] = 'max',\n    ['=='] = '!=',\n    ['\u003c='] = '\u003e=',\n    ['\u003c'] = '\u003e',\n  },\n  opposites_by_ft = {\n    ['lua'] = {\n      ['=='] = '~=',\n    },\n    ['sql'] = {\n      ['asc'] = 'desc',\n    },\n  },\n  notify = {\n    found = false,\n    not_found = true,\n  },\n}\n```\n\nFor other plugin manager, call the setup function\n`require('opposites').setup({ ... })` directly.\n\n## TODO\n\n- [ ] Limit and check the user configuration.\n- [x] Use `vim.ui.select` instead of `vim.fn.inputlist`.\n- [x] Refactoring of the first quickly written code.\n- [x] Adapt the capitalization of the words to reduce words like `true`,\n      `True`, `tRUe` and `TRUE`.\n- [x] Add file type specific opposites.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigion%2Fnvim-opposites","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftigion%2Fnvim-opposites","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigion%2Fnvim-opposites/lists"}