vim: add plugin 'monaqa/dial.nvim'
This commit is contained in:
parent
d7de20a635
commit
890d2def13
2 changed files with 56 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"dial.nvim": { "branch": "master", "commit": "27eb570085db2ef44bff4f620d3806039184651c" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" },
|
||||
"fidget.nvim": { "branch": "legacy", "commit": "2f7c08f45639a64a5c0abcf67321d52c3f499ae6" },
|
||||
"git-messenger.vim": { "branch": "master", "commit": "8a61bdfa351d4df9a9118ee1d3f45edbed617072" },
|
||||
|
|
55
config/nvim/lua/fschauen/plugins/dial.lua
Normal file
55
config/nvim/lua/fschauen/plugins/dial.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
local M = { 'monaqa/dial.nvim' }
|
||||
|
||||
---Create a right hand side for `dial` key maps.
|
||||
---@param cmd string: name of a function from `dial.map`.
|
||||
---@param suffix? string: keys to add after `dial`s mapping.
|
||||
---@return function
|
||||
local dial_cmd = function(cmd, suffix)
|
||||
suffix = suffix or ''
|
||||
return function()
|
||||
return require('dial.map')[cmd]() .. suffix
|
||||
end
|
||||
end
|
||||
|
||||
---Make a new augent that cycles over the given elements.
|
||||
---@param elements string[]: the elements to cycle.
|
||||
---@return table: @see `dial.types.Augend`
|
||||
local cyclic_augend = function(elements)
|
||||
return require('dial.augend').constant.new {
|
||||
elements = elements,
|
||||
word = true,
|
||||
cyclic = true
|
||||
}
|
||||
end
|
||||
|
||||
M.keys = {
|
||||
{ '<c-a>', dial_cmd('inc_normal'), expr = true, desc = ' Increment' },
|
||||
{ '<c-x>', dial_cmd('dec_normal'), expr = true, desc = ' Decrement' },
|
||||
|
||||
{ '<c-a>', dial_cmd('inc_visual', 'gv'), expr = true, desc = ' Increment', mode = 'v' },
|
||||
{ '<c-x>', dial_cmd('dec_visual', 'gv'), expr = true, desc = ' Decrement', mode = 'v' },
|
||||
|
||||
{ 'g<c-a>', dial_cmd('inc_gvisual', 'gv'), expr = true, desc = ' Increment', mode = 'v' },
|
||||
{ 'g<c-x>', dial_cmd('dec_gvisual', 'gv'), expr = true, desc = ' Decrement', mode = 'v' },
|
||||
}
|
||||
|
||||
M.config = function()
|
||||
local augend = require('dial.augend')
|
||||
require('dial.config').augends:register_group {
|
||||
default = {
|
||||
augend.integer.alias.decimal_int,
|
||||
augend.integer.alias.hex,
|
||||
augend.integer.alias.binary,
|
||||
augend.constant.alias.bool,
|
||||
augend.semver.alias.semver,
|
||||
augend.date.alias['%Y-%m-%d'],
|
||||
augend.date.alias['%d/%m/%Y'],
|
||||
augend.date.alias['%d.%m.%Y'],
|
||||
cyclic_augend { 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' },
|
||||
cyclic_augend { 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' },
|
||||
cyclic_augend { 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su' },
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Reference in a new issue