nguyenvukhang / nvim-toggler Goto Github PK
View Code? Open in Web Editor NEWinvert text in vim, purely with lua.
License: MIT License
invert text in vim, purely with lua.
License: MIT License
Is it possible to toggle - [ ]
and - [x]
?
Is it possible to support three string to switch each other, like vim -> emacs -> vscode -> vim
After commit 2ce3146 the plugin notify [nvim-toggler] conflicts found in inverse config.
six times.
Currently the plugin checks for the <cword>
under the cursor. This will not work for e.g. ==
inside this line if (foo == bar) {
. The detected cword when on the equality operator is bar
. I have not yet completely understood the behavior. From :h word
:
A word consists of a sequence of letters, digits and underscores, or a
sequence of other non-blank characters, separated with white space (spaces,
tabs, <EOL>). This can be changed with the 'iskeyword' option. An empty line
is also considered to be a word.
So I guess when there is an alphanum+underscore word after ==
it will detect that, otherwise it falls back to a sequence of non-blank characters and finds ==
.
There is also <cWORD>
which will detect ==
, but also fails to detect true
when e.g. wrapped like this: "true"
. That's because cWORD only takes non-blank character sequences (see :h WORD
).
One idea would be to first match against cword and then against cWORD, but this will fail in a situation like the following: if (my_var == true)
. Here cword will match with true
and replace the equality operator with the inverse, false
(as can be seen in the video).
Another one would be to match each key in the lookup-table against cWORD and only toggle the matched part of the cWORD. But again, what about a situation where one has <
and <<
in the lookup table? Would it toggle the first occurrence? All occurrences? Is it correct by accident?
Finally, it is possible to modify what counts as a word via the iskeyword
option. However, this may have unwanted side-effects and should therefore probably only be done by the users themselves.
I have no solution for this yet, will investigate further.
PS: @nguyenvukhang I will continue posting issues that others might encounter here if you don't mind, for documentation purposes. Of course, only issues that happen with the base repo, not just in my fork 👍
There is currently no way to truly remap the default keybinding of <Leader>i
. The option mentioned in the README will create an additional keybinding, but the default one will still persist.
I recommend support the letters case of the word
E.g. in Python you wish to switch between True
and False
, in javascript its true
, and false
, in some other cases its TRUE
and FALSE
.
One could added extra pairs for each situation, but I think the following would be better:
stANge
and weIRD
, then not handle toggling casingIf a user has inverses
!= and ==
true and false
then toggling on =
in
SWITCH==true
will result in
SWITCHfalsetrue
This is currently because nvim-toggler
recognizes all characters in an user's inverse table as a valid character for a vim word. So commands like cw
acts differently based on the user's inverse table.
The project name should be self-explanatory, in my opinion. Because of this I propose to you a project name that I had come up with while watching the demonstration video found in the README of this project:
nvim-antonym
antonym.nvim
or something of that sort.
Hi, love the plugin! However, after the latest update, I start getting the following error:
/Users/nmadnani/work/nlpdemos/showcase
Error detected while processing /Users/nmadnani/.config/nvim/init.lua:
E5113: Error while calling lua chunk: ...pack/packer/start/nvim-toggler/lua/nvim-toggler/init.lua:20: attempt to index local 'opts' (a nil value)
stack traceback:
...pack/packer/start/nvim-toggler/lua/nvim-toggler/init.lua:20: in function 'setup'
/Users/nmadnani/.config/nvim/lua/user/toggler.lua:6: in main chunk
[C]: in function 'require'
/Users/nmadnani/.config/nvim/init.lua:39: in main chunk
I tried reinstalling and installing the plugin but it's the same issue. I am using neovim 0.7.2 on macOS 12.5.1.
Here's what my nvim-toggler
configuration looks like (I am using the default options):
local status_ok, toggler = pcall(require, "nvim-toggler")
if not status_ok then
return
end
toggler.setup()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.