Coder Social home page Coder Social logo

Comments (9)

AstroShen avatar AstroShen commented on August 27, 2024 1

BTW, suggest support none-word character custom augends like "++, --", ">=, <=", ....

from dial.nvim.

monaqa avatar monaqa commented on August 27, 2024 1

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.

monaqa avatar monaqa commented on August 27, 2024 1

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.

monaqa avatar monaqa commented on August 27, 2024

There are two steps you need to take to add a custom augend:

  1. register the augends you want to add in dial.augends.
  2. 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.

AstroShen avatar AstroShen commented on August 27, 2024

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.

axieax avatar axieax commented on August 27, 2024

@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.

monaqa avatar monaqa commented on August 27, 2024

@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.

axieax avatar axieax commented on August 27, 2024

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.

axieax avatar axieax commented on August 27, 2024

Ahh this explains the bugged behaviour! Thanks for the fix :)
Looking forward to the new version!!

from dial.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.