Comments (9)
BTW, suggest support none-word character custom augends like "++, --", ">=, <=", ....
from dial.nvim.
Thank you, there was a bug that some characters (such as +
, .
) was treated as special characters of Lua.
I fixed it and now (3b70b2a) the following config should work as expected.
local non_word_pattern = "\\C\\M\\(%s\\)"
local custom_augends = {
selfIncrementBy = dial.common.enum_cyclic({
strlist = { "+=", "-=", "*=", "/=", "//=", "%=" },
ptn_format = non_word_pattern,
}),
selfIncrementOne = dial.common.enum_cyclic({ strlist = { "++", "--" }, ptn_format = non_word_pattern }),
}
And I decided to reimplement the functionality of dps-dial in Lua and release it as a new version of dial.nvim.
I will update dial.nvim soon to support new features such as dot-repeat.
from dial.nvim.
A new version has been released with a completely new configuration interface. So this issue is now closed.
If you have any problems with the new interface, please open a new issue.
from dial.nvim.
There are two steps you need to take to add a custom augend:
- register the augends you want to add in
dial.augends
. - list the augends you want to enable in
dial.config.searchlist.normal
/dial.config.searchlist.visual
.
For example, you can do the following
dial.config.searchlist.normal = { "custom#boolean", "custom#direction" }
(but the default augends will not work in this case).
from dial.nvim.
It is a little trouble. But i think the plugin you devepled is very general and can be the best Ctrl-A/X plugin. Hope the more extensible way of custom augends.
from dial.nvim.
@AstroShen you can use vim.list_extend
to avoid repeated table.insert
calls, for example:
local dial = require("dial")
local extra_augends = {
"markup#markdown#header",
"date#[%H:%M:%S]",
}
local custom_augends = {
boolean = dial.common.enum_cyclic({ strlist = { "true", "false" } }),
Boolean = dial.common.enum_cyclic({ strlist = { "True", "False" } }),
-- on = dial.common.enum_cyclic({ strlist = { "on", "off" } }),
-- ON = dial.common.enum_cyclic({ strlist = { "ON", "OFF" } }),
-- On = dial.common.enum_cyclic({ strlist = { "On", "Off" } }),
-- direction = dial.common.enum_cyclic({ strlist = { "north", "south", "west", "east" } }),
-- Direction = dial.common.enum_cyclic({ strlist = { "North", "South", "West", "East" } }),
greater = dial.common.enum_cyclic({ strlist = { ">", "<" } }),
-- equal = dial.common.enum_cyclic({ strlist = { "==", "!=" } }),
-- Equal = dial.common.enum_cyclic({ strlist = { "===", "!==" } }),
-- greaterEqual = dial.common.enum_cyclic({ strlist = { ">=", "<=" } }),
-- selfAdd = dial.common.enum_cyclic({ strlist = { "++", "--" } }),
}
-- register custom augends
for k, v in pairs(custom_augends) do
local augend_name = "custom#" .. k
dial.augends[augend_name] = v
table.insert(extra_augends, augend_name)
end
-- extend capabilities
vim.list_extend(dial.config.searchlist.normal, extra_augends)
vim.list_extend(dial.config.searchlist.visual, extra_augends)
Unfortunately for me, my "greater", "equal", "Equal", "greaterEqual", "selfAdd" custom augments aren't working as expected, not sure why though..
For example:
Incrementing 1 < 2
with cursor on <
will move the cursor to 2
and increment that number to 3
, but incrementing a < b
with cursor on <
will do nothing.
I'm on nvim v0.6.1. Also, I see there hasn't been any updates to this plugin for a while. Is dps-dial.vim a replacement for this plugin?
Btw +1 to AstroShen's suggestion for supporting these extra augends as well :)
from dial.nvim.
@AstroShen @axieax I am sorry for late response, and thank you for your suggestions!
Recently, I've been fascinated by denops.vim, which can create plugins using TypeScript, and dps-dial.vim is a product of that. dps-dial.vim supports dot-repeat and is very versatile, but it requires Deno runtime to be installed.
To be honest, I am undecided which one I should focus on, dial.nvim or dps-dial.vim, because both of them have their advantages.
By the way, you can add non-word augends like this:
local custom_augends = {
greater = dial.common.enum_cyclic({ strlist = { ">", "<" }, ptn_format = "\\C\\M\\(%s\\)" }),
}
from dial.nvim.
Interesting I see now! Is the functionality similar for both versions, other than dot-repeat and case switching (this sounds so cool!)? I'm curious as to what advantages each have over the other (definitely compatibility for Lua, speed and development should still be quite good as well tho?).
Thanks for the non-word augends guide btw! Most of them work now, except for the self increment ones (+=, ++) for some reason. This is what I'm currently using:
local non_word_pattern = "\\C\\M\\(%s\\)"
local custom_augends = {
selfIncrementBy = dial.common.enum_cyclic({
strlist = { "+=", "-=", "*=", "/=", "//=", "%=" },
ptn_format = non_word_pattern,
}),
selfIncrementOne = dial.common.enum_cyclic({ strlist = { "++", "--" }, ptn_format = non_word_pattern }),
}
from dial.nvim.
Ahh this explains the bugged behaviour! Thanks for the fix :)
Looking forward to the new version!!
from dial.nvim.
Related Issues (20)
- Couple of issues HOT 5
- Question on aligning (string formatting) date augend HOT 2
- Attempt to call method 'find' error HOT 2
- Visual block mode increment HOT 3
- Sumneko warning HOT 3
- Date decreasing issue HOT 5
- Workflow proposal HOT 14
- Provide a lua API instead of a string command HOT 1
- Feature request: Support for sequences HOT 2
- lazy.nvim: Failed to run config for dial.nvim: module 'dial' not found HOT 2
- Date pattern like %-m don't work. HOT 15
- Increment/decrement on fooBar1 while cursor is over the 1 HOT 3
- Plugin stopped working after first use? HOT 4
- `g<C-A>` not working HOT 5
- Please explain that you cannot configure your plugin with Vimscript HOT 2
- Buildin support for filetype specific augend? HOT 1
- default to normal <c-a> HOT 6
- Powerful alternatives HOT 2
- [question] difference between `gnormal` and `normal` HOT 2
- delimited hex and binary integer augend do not work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dial.nvim.