-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When i wanna create many custom augends, it there a way to avoid writing table.insert...
over and over again?
#9
Comments
There are two steps you need to take to add a custom augend:
For example, you can do the following
(but the default augends will not work in this case). |
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. |
BTW, suggest support none-word character custom augends like "++, --", ">=, <=", .... |
@AstroShen you can use 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: 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 :) |
@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. By the way, you can add non-word augends like this:
|
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 }),
} |
Thank you, there was a bug that some characters (such as
And I decided to reimplement the functionality of dps-dial in Lua and release it as a new version of dial.nvim. |
Ahh this explains the bugged behaviour! Thanks for the fix :) |
A new version has been released with a completely new configuration interface. So this issue is now closed. |
dial.augends["custom#boolean"] = dial.common.enum_cyclic{ strlist = {"true", "false"} }
dial.augends["custom#direction"] = dial.common.enum_cyclic{ strlist = {"North", "South", "West", "East"} }
dial.augends["custom#great"] = dial.common.enum_cyclic{ strlist = {">", "<"} }
dial.augends["custom#greatequal"] = dial.common.enum_cyclic{ strlist = {">=", "<="} }
dial.augends["custom#selfadd"] = dial.common.enum_cyclic{ strlist = {"++", "--"} }
table.insert(dial.config.searchlist.normal, "custom#boolean")
....
....
....
The text was updated successfully, but these errors were encountered: