A simple neovim plug-in for replacing the word under the cursor with its antonym.
With lazy.nvim
return {
'gczcn/antonym.nvim',
cmd = 'AntonymWord',
config = function()
require('antonym').setup({})
end
}
With packer.nvim
use {
'gczcn/antonym.nvim',
cmd = 'AntonymWord',
config = function()
require('antonym').setup({})
end
}
With vim-plug
call plug#begin()
" ...
Plug 'gczcn/antonym.nvim'
" ...
call plug#end()
lua << EOF
require('antonym').setup({})
EOF
The plug-in provides a command AntonymWord
, through which you can replace the word under the cursor with the matching word in the replacement list.
There is no default mapping for this plugin, you can set it using vim.keymap.set
:
vim.keymap.set('n', '<leader>wa', '<cmd>AntonymWord<CR>') -- Change '<leader>wa' to your key
Or, if you don't use lazy loading, you can do this (not recommended):
require('antonym').setup({
key = '<leader>wa' -- Change '<leader>wa' to your key
})
Default replacement list:
word_a | word_b |
---|---|
acquire | release |
add | remove |
advance | retreat |
allocate | deallocate |
allow | deny |
assemble | disassemble |
assign | deassign |
associate | dissociate |
attach | detach |
begin | end |
bind | unbind |
commit | rollback |
compile | decompile |
compose | parse |
compress | decompress |
connect | disconnect |
construct | destruct |
create | destroy |
do | undo |
enable | disable |
encode | decode |
encrypt | decrypt |
enqueue | dequeue |
enter | leave |
expand | collapse |
first | last |
freeze | unfreeze |
front | back |
get | set |
grant | revoke |
head | tail |
high | low |
import | export |
include | exclude |
increase | decrease |
increment | decrement |
indent | dedent |
inflate | deflate |
inject | eject |
input | output |
insert | delete |
install | uninstall |
left | right |
Left | Right |
link | unlink |
load | unload |
lock | unlock |
maximum | minimum |
new | old |
next | previous |
open | close |
off | on |
paste | cut |
push | pop |
read | write |
reference | dereference |
register | deregister |
resume | suspend |
select | deselect |
send | receive |
serialize | deserialize |
set | unset |
show | hide |
start | stop |
true | false |
True | False |
TRUE | FALSE |
1 | 0 |
yes | no |
Yes | No |
YES | NO |
up | down |
Up | Down |
upper | lower |
If you want to view the value corresponding to a certain word, you can use:
require('antonym').dictionary['word'] -- 'word' is the word you want to find.
If you need to add a group of words, you can do this:
The following is an example of adding the correspondence between a
and b
:
require('antonym').add_dictionary({{'a', 'b'}})
If you just want to add a single word replacement, do this:
The following is an example of changing the corresponding value of true
to 0
without changing the value of false
.
require('antonym').add_dictionary({{'true', '0', mode = 'single'}})
To delete a relationship or a set of correspondences, you can do this:
The following is an example of deleting the corresponding relationship between true
and false
require('antonym').del_dictionary({{'true', 'false'}})
The plugin has the following settings available:
require('antonym').setup({
antonyms = {
-- Add or override matches here.
-- For example:
{ 'worda', 'wordb' }
-- Can also be used to delete
{ 'worda', 'wordb', del = true }
},
-- When the plug-in is loaded, this item is used to set a shortcut key for replacing the word.
-- This method is not recommended!
key = '<leader>wa' -- Change '<leader>wa' to your key.
})