Coder Social home page Coder Social logo

dial.nvim's People

Contributors

3719e04 avatar colinkennedy avatar f1rstlady avatar gegoune avatar ktakayama avatar leiserfg avatar liquid-system avatar monaqa avatar ryota2357 avatar thomasfaivre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dial.nvim's Issues

Lua map api not working

Nvim version:

NVIM v0.7.0-dev+1258-gbef7552f7
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compilado por runner@fv-az242-546

Features: +acl +iconv +tui
See ":help feature-compile"

     archivo "vimrc" del sistema: "$VIM/sysinit.vim"
            predefinido para $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

Minimal conifg:

  • Using packer
  use { -- Only works for booleans
    "monaqa/dial.nvim",
    config = function()
      local augend = require("dial.augend")
      require("dial.config").augends:register_group{
        -- default augends used when no group name is specified
        default = {
          augend.integer.alias.decimal,   -- nonnegative decimal number (0, 1, 2, 3, ...)
          augend.integer.alias.hex,       -- nonnegative hex number  (0x01, 0x1a1f, etc.)
          augend.date.alias["%Y/%m/%d"],  -- date (2022/02/19, etc.)
        },

        -- augends used when group with name `mygroup` is specified
        mygroup = {
          augend.integer.alias.decimal,
          augend.constant.alias.bool,    -- boolean value (true <-> false)
          augend.date.alias["%m/%d/%Y"], -- date (02/19/2022, etc.)
        }
      }
    end,
  }

-- After plugin setup
vim.api.nvim_set_keymap("n", "<Leader>adf", '<cmd>lua require("dial.map").inc_normal()<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "<Leader>adb", '<cmd>lua require("dial.map").dec_normal()<cr>', { noremap = true, silent = true })

Expected behaviour:

  1. Enter a buffer
  2. Type the number 1
  3. Position cursor over the number 1
  4. In normal mode press <Leader>adf
  5. Get number 2

Actual behaviour:

  1. Enter a buffer
  2. Type the number 1
  3. Position cursor over the number 1
  4. In normal mode press <Leader>adf
  5. The number remains unchained

When i wanna create many custom augends, it there a way to avoid writing `table.insert...` over and over again?

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")
....
....
....

[Feature Request] Option to only inc/dec when augend is under cursor

Problem:

Right now I have this in my config:

        augend.constant.new { elements = { 'on', 'off' }, word = false, cyclic = true, },

I have word = false, since I wanna allow for cases where 'on'/'off' is part of an identifier like 'turn_on` etc.

Now the problem with that is, that I get a ton of false positives when I wanna increment something else in the line. I use <c-a> and it jumps to an occurrence of "on" as part of another word since those 2 letters appear everywhere in the English language apparently.

So then I turned "on" to "off" unintentionally in some word and have to decrement again, to finally jump to the actual place I where wanted to increment something.

Solution:

An option in the augends, that allows to turn off the jumping/seeking for this particular augend, would be great. Eg:

        augend.constant.new { elements = { 'on', 'off' }, word = false, cyclic = true, jumpTo = false},

In that case, the increment would only work, if it matches something right under the cursor.

[question] difference between `gnormal` and `normal`

Hello,

thank you for this awesome plugin. I have one question:

Whats the difference between:

require("dial.map").manipulate("increment", "gnormal") 

-- and

require("dial.map").manipulate("increment", "normal")

I unserstand gvisual can increment the block:

1
1
1

to

2
3
4

but whats the purpose of the g prefix in normal mode?

Thank you

Date decreasing issue

I'm using the most simple config possible, the mappings and a single augend

augend.date.alias["%Y-%m-%d"]

It works fine for most dates, but for some like 2022-10-30 and 2022-09-30, it does not decrease (I'm calling it with the cursor over the day).

Enhancement: Extending dial with support for conversions

Hi, I was just exploring this great plugin, which does an amazing job at extending the base inc/dec features of vim, and i was reminded of a vim based plugin called vim-radical (https://github.com/glts/vim-radical) which allows the user to convert the underlying number under the cursor into another representation. To me that seems like an interesting idea. Can be useful for things like dates or time formats - converting from one date/time format to another, numbers - same idea as radical (convert decimal to hex, binary or octal etc). Or even allowing a custom conversion from one type to another, which can be defined by the user. It seems that dial already has the internal support to understand the text objects it works with anyway (dates, numbers etc.), is that a feasible improvement ?

Wrong date format

Hi, got a date in DD/MM/YY format, but dial treats it as if it was MM/DD/YY, so first field I can only increment to 12, while incrementing middle one past 30-31 (depending on month) bumps first field by one.

I am not seeing MM/DD/YY format in readme, not sure where it's coming from. How can I disable that date format altogether?

Please explain that you cannot configure your plugin with Vimscript

My understanding from reading through your Readme and your doc is that it is only possible to configure your plugin in Lua. If I'm right, could you please add a line in your readme and doc to mention this in the beginning, in order to prevent other people (like me) reading the doc for quite some time before realizing this ?

Thank you for your work btw :)

Edit: I've seen the

lua << EOF
...
EOF

trick, but mentioning something about this in the beginning would make it much clearer to Nvim users using old school config

Can't seem to get dial.nvim to function?

While reading the Readme, its a little unclear how to get started before diving directly into all the configurations I know nothing about. The readme reads with a bit too much assumed knowledge (IMO).

As an example, I am using the below configuration

-- minimal.lua
require('packer').startup(function(use)
    use 'monaqa/dial.nvim'
    if packer_bootstrap then
        require('packer').sync()
    end
end)

As a test, I open up an unnamed buffer and enter in the following text

1
2
3
4

Entering normal mode, I hover over the first line (1) and use the following command
:lua require("dial.map").inc_normal()

I assume I am doing something wrong but the readme doesn't call out a "here is how to get started" so I'm not really sure what I am doing wrong.

Edit: Some basic troubleshooting info

NVIM v0.8.0-dev+494-ge2f9d0332
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az21-224

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

:checkhealth

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $SSH_TTY='/dev/pts/2'

## tmux
  - OK: escape-time: 10
  - INFO: Checking stuff
  - OK: focus-events: on
  - INFO: $TERM: xterm-256color
  - INFO: default-terminal: tmux-256color
  - ERROR: $TERM differs from the tmux `default-terminal` setting. Colors might look wrong.
    - ADVICE:
      - $TERM may have been set by some rc (.bashrc, .zshrc, ...).
  - WARNING: Neither Tc nor RGB capability set. True colors are disabled. |'termguicolors'| won't work properly.
    - ADVICE:
      - Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
          set-option -sa terminal-overrides ',XXX:RGB'
      - For older tmux versions use this instead:
          set-option -ga terminal-overrides ',XXX:Tc'

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: osc52

## Python 3 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - WARNING: Could not load Python 3:
    /usr/bin/python3 is Python 3.6 and cannot provide Python >= 3.7.
    python3.10 not found in search path or not executable.
    python3.9 not found in search path or not executable.
    /usr/bin/python3.8 does not have the "neovim" module.
    python3.7 not found in search path or not executable.
    /usr/bin/python is Python 3.6 and cannot provide Python >= 3.7.
    - ADVICE:
      - See :help |provider-python| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
  - INFO: Executable: Not found

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.
      - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

## Node.js provider (optional)
  - INFO: Node.js: v14.18.1
  - INFO: Nvim node.js host: /home/miversen/.config/yarn/global//node_modules/neovim/bin/cli.js
  - WARNING: Package "neovim" is out-of-date. Installed: 4.10.0, latest: 4.10.1
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

## Perl provider (optional)
  - WARNING: "Neovim::Ext" cpan module is not installed
    - ADVICE:
      - See :help |provider-perl| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

Issue with setting up plugin

I'm just setting up this plugin with the following in my config:

local opts = {silent = true, noremap=false}
vim.api.nvim_set_keymap('n', '<C-a>', '<Plug>(dial-increment)', opts)
vim.api.nvim_set_keymap('n', '<C-x>', '<Plug>(dial-decrement)', opts)
vim.api.nvim_set_keymap('v', '<C-a>', '<Plug>(dial-increment)', opts)
vim.api.nvim_set_keymap('v', '<C-x>', '<Plug>(dial-decrement)', opts)
vim.api.nvim_set_keymap('v', 'g<C-a>', '<Plug>(dial-increment-additional)', opts)
vim.api.nvim_set_keymap('v', 'g<C-x>', '<Plug>(dial-decrement-additional)', opts)

However for example if I do <C-x> on 2021-03-22 then with my cursor on the first character I just get 2020-03-22 instead of 2021-03-21 which is what I would have expected.

If I understood it correctly it should work by default on dates right? Or do I need to add that to the searchlist?

Markdown heading augend

Hi, just wondering if there are plans to add back markup#markdown#header to dial v0.3, since it was one of my favourite and most used augends with this plugin.

Plugin stopped working after first use?

I installed this plugin and tested it by configuring a single keymap and testing it with a date.

I wrote out (2022/11/01) and observed that incrementing the 11 to 13 would instead roll the year around to (2023/01/01).

Eager at the success, I added the rest of the keymaps and tried them out, only to find out that the plugin had stopped working entirely.

Now when I manually run DialIncrement when my cursor is over the 11 in (2022/11/01), it simply increments the year to (2023/11/01) instead of the month to (2022/12/01).

My keybinds are defined as follows:

utility remap function (imported into map config file)

function M.nmap(lhs, rhs, opts)
    local options = {noremap = false}
    if opts then options = vim.tbl_extend('force', options, opts) end
    api.nvim_set_keymap('n', lhs, rhs, options)
end

vmap is also imported from this utility file

map configs here

nmap("<C-a>", "<Plug>(dial-increment)")
nmap("<C-x>", "<Plug>(dial-decrement)")
nmap("g<C-a>", "g<Plug>(dial-increment)")
nmap("g<C-x>", "g<Plug>(dial-decrement)")
vmap("<C-a>", "<Plug>(dial-increment)")
vmap("<C-x>", "<Plug>(dial-decrement)")
vmap("g<C-a>", "g<Plug>(dial-increment)")
vmap("g<C-x>", "g<Plug>(dial-decrement)")

Pressing Ctrl+a on a boolean, date, or other non-regular incrementable item simply does nothing. It seriously worked the first time I booted up neovim with the plugin installed!!

Keeping cursor in place

Often you just want to change something quick in the middle of the line without actually doing something else there. 90% of the time I use dial I find myself just jumping back to my starting position after my cursor moves to the thing I want to increment. The best thing about dial is that I dont have to go to the number in order to change it, so it feels unessesary to jump there anyway. It would be nice to have an option to keep the cursor in place while incrementing the target.

Issue with prent.new

If I understand dial correctly, below config

  use { -- increse decrease numbers but also datas, true to false etc
    "monaqa/dial.nvim",
    config = function()
      local augend = require "dial.augend"
      require("dial.config").augends:register_group {
        -- default augends used when no group name is specified
        default = {

          augend.paren.new {
            elements = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "A", "B", "C", "D", "E", "F"},
            word = false,
            cyclic = true,
          },
        },

      }
      vim.api.nvim_set_keymap("n", "<C-a>", require("dial.map").inc_normal(), { noremap = true })
      vim.api.nvim_set_keymap("n", "<C-x>", require("dial.map").dec_normal(), { noremap = true })
      vim.api.nvim_set_keymap("v", "<C-a>", require("dial.map").inc_visual(), { noremap = true })
      vim.api.nvim_set_keymap("v", "<C-x>", require("dial.map").dec_visual(), { noremap = true })
      vim.api.nvim_set_keymap("v", "g<C-a>", require("dial.map").inc_gvisual(), { noremap = true })
      vim.api.nvim_set_keymap("v", "g<C-x>", require("dial.map").dec_gvisual(), { noremap = true })
    end,
  }

Should allow me to increase number which is directly under cursor, right?
The problem is - for string "123" - dial just changes quotes from " to ' in loop. Can someone confirm this?

delimited hex and binary integer augend do not work

Hello, first of all thank you for this amazing plugin.

I've ran into an issue when trying to define number dial augends for hex and binary numbers with delimiters. When trying to increment or even decrement hex numbers, 2 leading zeroes are added every time. When trying to increment a binary number, I get an error message.
Dials with radix = 10 work perfectly.
Here is a screencap:
augen_hex_binary_with_delimiter

I've reduced the config to the following lines. I am using ' as a separator here, for c++, but the same issues happen when using '_' for rust.

local augend = require("dial.augend")
require("dial.config").augends:register_group({
    default = {
        augend.integer.new({
            radix = 16,
            prefix = "0x",
            case = "lower",
            delimiter = "'",
            delimiter_digits = 2,
        }),
        augend.integer.new({
            radix = 2,
            prefix = "0b",
            delimiter = "'",
            delimiter_digits = 4,
        }),
    },
})

Here is the error message I received:

E5108: Error executing lua: .../AppData/Local/nvim-data/lazy/dial.nvim/lua/dial/map.lua:49: function dial#operator#increment_normal, line 1: Vim(lua):E5108: Error executing lua ...cal/nvim-data/lazy/dial.nvim/lua/dial/augend/integer.lua:184: attempt to perform arithmetic on local 'd' (a nil value)
stack traceback:
	...cal/nvim-data/lazy/dial.nvim/lua/dial/augend/integer.lua:184: in function 'to_string'
	...cal/nvim-data/lazy/dial.nvim/lua/dial/augend/integer.lua:303: in function 'add'
	...pData/Local/nvim-data/lazy/dial.nvim/lua/dial/handle.lua:208: in function 'operate'
	...Data/Local/nvim-data/lazy/dial.nvim/lua/dial/command.lua:120: in function 'operator_normal'
	[string ":lua"]:1: in main chunk
	[C]: in function 'normal'
	.../AppData/Local/nvim-data/lazy/dial.nvim/lua/dial/map.lua:49: in function 'manipulate'
	C:/Users/alex-/AppData/Local/nvim/lua/plugins/dial.lua:7: in function <C:/Users/alex-/AppData/Local/nvim/lua/plugins/dial.lua:6>
stack traceback:
	[C]: in function 'normal'
	.../AppData/Local/nvim-data/lazy/dial.nvim/lua/dial/map.lua:49: in function 'manipulate'
	C:/Users/alex-/AppData/Local/nvim/lua/plugins/dial.lua:7: in function <C:/Users/alex-/AppData/Local/nvim/lua/plugins/dial.lua:6>

Increment/decrement on fooBar1 while cursor is over the 1

Description: The increment/decrement operation is performed on the whole word. In case the word contains a number AND the cursor is on that number, I would expect that the operation is only performed on the respective number, not on the whole word before the number.

Situation to reproduce:

Expected result:

  • fooBar0

Actual result:

  • FOO_BAR1

Note that it works as expected for words that are only lower-cased letters, e.g. word1 becomes word0.

I am not sure if you will regard it as a real issue or if it's a wontfix situation. The main issue with this issue is that I can't use <C-a>/<C-x> anymore as without the plugin. My workaround will probably be to map dial's functionality to <leader><C-a> and <leader><C-x>.

How to increase all the numbers in the line

Let's assume I have a list like this:
fn - 1 : yabai -m space --focus 1
fn - 1 : yabai -m space --focus 1
fn - 1 : yabai -m space --focus 1
fn - 1 : yabai -m space --focus 1
fn - 1 : yabai -m space --focus 1
fn - 1 : yabai -m space --focus 1
fn - 1 : yabai -m space --focus 1
fn - 1 : yabai -m space --focus 1

I would like to increase both, the first 1 and the second 1 in the same line. But when I do g it increases the first 1. Is it possible to increase both numbers?

Question on aligning (string formatting) date augend

Hi, got a usage question, not an issue. Hope you don't mind, it might even turn into feature request. :)

I have a need to keep 'dialed' object right space aligned, that is I always want text I am changing to occupy given number of columns (think ('%-19s <-'):format(os.date '%d/%m/%y %A')). It it possible to achieve that with date augend?

Currently that errors, but would solve my issue:

    augend.date.new {
      pattern = '%d/%m/%y %-9A',
      default_kind = 'day',
      only_valid = true,
      word = false,
    },

Thanks!

Enhancement: Add case-insensitive cycling

I recently discovered this plugin and I'm really fond of the extension of the c-a and c-x functionality, it's a great idea!

One feature I miss in the definition of the custom cycling groups is to have case-insensitive cycling, e.g.

augend.constant.new({
	elements = { "left", "right" },
	word = true,
	cyclic = true,
        case_sensitive = false,
})

could be used to turn left into right and Left into Right. A more common use case is the true/false tuple, which in some languages like python is True/False.

Feature request: Support for sequences

I would like to switch from vim-visual-increment to dial.nvim, but the one thing I'm missing is support for sequences. This example from the vim-visual-increment README should illustrate what I mean:

For example, we have an array of 5 items and we would like to define them:

 example[0] = 'e';
 example[0] = 'e';
 example[0] = 'e';
 example[0] = 'e';
 example[0] = 'e';

Press at the first index and select all the index columns on multiple lines, press <C-A>:

 example[0] = 'e';
 example[1] = 'e';
 example[2] = 'e';
 example[3] = 'e';
 example[4] = 'e';

The order of elements

This was something that confused me for a bit, but the order of elements is important.
I'd like the strings I defined in elements to all be matched before an inc/decrement takes place.
Right now, it finds the first match and applies that.

Example that's much clearer:
I wanted a toggle between <, <=, >, and >=

local non_word_pattern = "\\C\\M\\(%s\\)"
augend.constant.new({
  elements = { "<", "<=", ">", ">=" },
  pattern_regexp = non_word_pattern,
}),

However, with this:

  1. original: 1 <= 2
  2. incremented:1 <== 2

I would like the result to be 1 > 2

What I first though:

This is because the < in <= is detected and the element next to < is <=, resulting in an extra =.

My workaround for now is to order the elements in such a way that this can not happen, the different order is a minor annoyance

augend.constant.new({
  elements = { "<=", ">=", "<", ">" },
  pattern_regexp = non_word_pattern,
}),

What I think now:

I have to tweak the pattern_regexp somehow, but I don't know enough regex to get it to behave the way I want.

So my question is: How can I change this behaviour, and can the current behaviour be documented please?
(If it already is, I apologize, I missed it)

Sumneko warning

With folke's new neodev.nvim I receive several warnings with my configuration. As I assume that the warnings are not "serious" and that everything runs just fine, I just silenced them like this.

{
    "monaqa/dial.nvim",
    event = "BufRead",
    config = function()
        local augend = require("dial.augend")
        require("dial.config").augends:register_group(
            {
                default = {
                    augend.integer.alias.decimal,
                    augend.integer.alias.hex,
                    augend.integer.alias.binary,
                    ---@diagnostic disable-next-line
                    augend.date.alias["%Y/%m/%d"],
                    ---@diagnostic disable-next-line
                    augend.date.alias["%d.%m.%y"],
                    augend.semver.alias.semver
                }
            }
        )
    end
}

Without the "silencing" I receive the following warning on each of the two lines:

Cannot assign `AugendDate` to `Augend`.- `AugendDate` cannot match `Augend`- Type `AugendDate` cannot match `Augend` Lua Diagnostics. (assign-type-mismatch) [390, 21]

It might be a good idea if you could check this "warning" whether it has any bad consequences.

Feel free to close this issue, if you think that this isn't important.

Dot doesn't repeat operation on targets

Repeat is not working on targets. If I press <C-a> or <C-x> after setting the mappings with:

vim.api.nvim_set_keymap("n", "<C-a>", "<Plug>(dial-increment)", {noremap = false, silent = true})
vim.api.nvim_set_keymap("n", "<C-x>", "<Plug>(dial-decrement)", {noremap = false, silent = true})
vim.api.nvim_set_keymap("v", "<C-a>", "<Plug>(dial-increment)", {noremap = false, silent = true})
vim.api.nvim_set_keymap("v", "<C-x>", "<Plug>(dial-decrement)", {noremap = false, silent = true})
vim.api.nvim_set_keymap("v", "g<C-a>", "<Plug>(dial-increment-additional)", {noremap = false, silent = true})
vim.api.nvim_set_keymap("v", "g<C-x>", "<Plug>(dial-decrement-additional)", {noremap = false, silent = true})

then the dot (repeat) operation doesn't work on targets.

Date pattern like %-m don't work.

Indefinite length patterns such as %-m and %-d in the date cannot work.

For example, this is setting:

default = {
    augend.date.alias["%-m/%-d"],
},
or
default = {
    augend.date.new {
        pattern = "%-m/%-d",
        default_kind = "day",
        only_valid = true,
        word = false,
    },
},

And this is text:

1/1

Then I can't get the two 1 to increment or decrement.

Patterns without %-m, %-d etc work.

Is there something wrong with my usage?

Can't get plugin to work

I can't get this plugin to work. This is my minimal init.vim:

call plug#begin('~/.config/nvim/packages/')
Plug 'monaqa/dial.nvim'
call plug#end()

lua << EOF
vim.api.nvim_set_keymap('n', '<C-a>',  '<Plug>(dial-increment)',            {noremap = true})
vim.api.nvim_set_keymap('n', '<C-x>',  '<Plug>(dial-decrement)',            {noremap = true})
vim.api.nvim_set_keymap('v', '<C-a>',  '<Plug>(dial-increment)',            {noremap = true})
vim.api.nvim_set_keymap('v', '<C-x>',  '<Plug>(dial-decrement)',            {noremap = true})
vim.api.nvim_set_keymap('v', 'g<C-a>', '<Plug>(dial-increment-additional)', {noremap = true})
vim.api.nvim_set_keymap('v', 'g<C-x>', '<Plug>(dial-decrement-additional)', {noremap = true})

local dial = require("dial")

dial.config.searchlist.normal = {
  "number#decimal",
  "number#hex",
  "number#binary",
  "date#[%Y/%m/%d]",
  "markup#markdown#header",
}
EOF

When pressing <C-a> on a decimal number for instance, nothing happens.

default to normal <c-a>

I love this plugin but this missing (and easy to implement feature) has really been bugging me.

If I open up a new file a.txt:

1

I can increment the 1 normally with <c-a>. However, that doesn't work with dial because dial doesn't have any groups associated with a random text file.

How can I configure dial to default to the builtin mapping if dial doesn't do anything? Should this be a default?

Thanks for the awesome plugin.

Fallback to native c-x/c-a.

3a

I can't change 3a to 3b in normal mode at cursor 'a'.
Can we fallback to vim's native <c-x>/<c-a>, if there's no match?

Thanks for the plugin.

Buildin support for filetype specific augend?

Right now it takes a lot of boilerplate code to add keymaps for filetype specific augend.

If I want to lazy load the plugin on a keymap with lazy.nvim and have all the keymaps with which-key, then I have to do pretty much the same thing.

return {
	'monaqa/dial.nvim',
	event = 'VeryLazy',
	keys = {
		{
			'<C-a>',
			M.manupilate('increment', 'normal'),
			desc = 'Increment',
			mode = 'n',
		},
		{
			'<c-x>',
			M.manupilate('decrement', 'normal'),
			desc = 'Decrement',
			mode = 'n',
		},
		{
			'g<C-a>',
			M.manupilate('increment', 'gnormal'),
			desc = 'Increment',
			mode = 'n',
		},
		{
			'g<C-x>',
			M.manupilate('decrement', 'gnormal'),
			desc = 'Decrement',
			mode = 'n',
		},

		{
			'<C-a>',
			M.manupilate('increment', 'visual'),
			desc = 'Visual Increment',
			mode = 'v',
		},
		{
			'<C-x>',
			M.manupilate('decrement', 'visual'),
			desc = 'Visual Decrement',
			mode = 'v',
		},
		{
			'g<C-a>',
			M.manupilate('increment', 'gvisual'),
			desc = 'Visual Increment',
			mode = 'v',
		},
		{
			'g<C-x>',
			M.manupilate('decrement', 'gvisual'),
			desc = 'Visual Decrement',
			mode = 'v',
		},
	},

To get it working with filetypes with the groups, I have to do following.

local group = vim.api.nvim_create_augroup('dial', {})

local M = {}

function M.setup()
	local languages = {
		'lua',
	}

	for _, language in ipairs(languages) do
		vim.api.nvim_create_autocmd('FileType', {
			pattern = { language },
			group = group,
			callback = function()
				local wk = require('which-key')

				wk.register({
					['<c-a>'] = {
						helper.manupilate('increment', 'normal', language),
						'Increment',
					},
					['<c-x>'] = {
						helper.manupilate('decrement', 'normal', language),
						'Decrement',
					},
					['g<c-a>'] = {
						helper.manupilate('increment', 'gnormal', language),
						'Increment',
					},
					['g<c-x>'] = {
						helper.manupilate('decrement', 'gnormal', language),
						'Decrement',
					},
				}, {
					mode = 'n',
				})

				wk.register({
					['<C-a>'] = {
						helper.manupilate('increment', 'visual', language),
						'Visual Increment',
					},
					['<C-x>'] = {
						helper.manupilate('decrement', 'visual', language),
						'Visual Decrement',
					},
					['g<C-a>'] = {
						helper.manupilate('increment', 'gvisual', language),
						'Visual Increment',
					},
					['g<C-x>'] = {
						helper.manupilate('decrement', 'gvisual', language),
						'Visual Decrement',
					},
				}, {
					mode = 'v',
				})
			end,
		})
	end
end

All this would be way more easier if it's possible to load augends on filetype. Something like below will not break existing config I think.

require('dial.config').augends:register_group({
	default = common,
	filetype = {
		lua = {
			augend.constant.new({
				elements = { 'and', 'or' },
				word = true,
				cyclic = true,
			})
		}
	}
})

Augends group implementation

Based on the documentation, I'm inclined to believe that when you call require("dial.map").[inc|dec]_normal() is like calling it passing the default group as the argument.

On my understanding this means that you have to specify each augend for each group that you create. Wouldn't it be more intuitive that the default group always gets applied and it's just extended by the named group that is passed as an argument?

Other wise it lends it self for a lot of code duplication if you are a heavy named groups user. Especially if you are defining new augends that you want every group to share.

Please confirm if this is the intended behavior and if there is any plan for change

Custom Checkbox augend

I was attempting to implement an increment/decrement function for a checkbox,
however the following doesn't appear to work the way it does for the true/false
function in the readme. Do the brackets need to be escaped, or am I missing
something different?

dial.augends["custom#check"] = dial.common.enum_cyclic{
    name = "check",
    strlist = {"[ ]", "[x]"},
}

`g<C-A>` not working

It seems g<C-A> is not working. If I select the ones in the example below using visual block mode and press g<C-A>, nothing happens:

1.
1.
1.
1.
1.

If I run :vunmap g<C-A> and reselect the same area in visual block mode, pressing g<C-A> yields the following result:

2.
3.
4.
5.
6.

Not sure what's causing this. I'm using the following spec with lazy.nvim to load dial.nvim, if that matters:

return {
  "monaqa/dial.nvim",
  keys = {
    { "<C-a>", "<Plug>(dial-increment)", mode = { "n", "v" } },
    { "<C-x>", "<Plug>(dial-decrement)", mode = { "n", "v" } },
    { "g<C-a>", "g<Plug>(dial-increment)", mode = { "n", "v" } },
    { "g<C-x>", "g<Plug>(dial-decrement)", mode = { "n", "v" } },
  },
  config = function()
    local augend = require("dial.augend")
    require("dial.config").augends:register_group({
      -- default augends used when no group name is specified
      default = {
        augend.integer.alias.decimal, -- nonnegative decimal number (0, 1, 2, 3, ...)
        augend.integer.alias.hex, -- nonnegative hex number  (0x01, 0x1a1f, etc.)
        augend.constant.alias.bool, -- boolean value (true <-> false)
        augend.date.alias["%Y/%m/%d"], -- date (2022/02/18, etc.)
        augend.date.alias["%m/%d/%Y"], -- date (02/19/2022)
        -- augend.date.alias["%m-%d-%Y"], -- date (02-19-2022)
        -- augend.date.alias["%Y-%m-%d"], -- date (02-19-2022)
        augend.date.new({
          pattern = "%m.%d.%Y",
          default_kind = "day",
          only_valid = true,
          word = false,
        }),
        augend.misc.alias.markdown_header,
      },
    })
  end,
}

Couple of issues

Hi, I've encountered two issues from the recent release:

  1. augend.paren.alias.lua_str_literal doesn't seem to include the single quote character
  2. Quote and bracket priority doesn't seem to be respected (e.g. ("") with cursor on first quote will target brackets instead of quote).

Feature - change quote/brackets - with matching

I think it would be cool if by changing opening/closing bracket, matching bracket would be changed too e. g.:
test[x] - to: test(x)
Could work on "" and other characters (maybe user defined).

`PascalCase` matches one word

The help says Currently, this augend does NOT recognize identifiers that consist of only one word., but PascalCase matches to the word starts with capital letter like 'Word' and 'WORD'.

This is a minimum setting to reproduce ↓

lua << EOF
local augend = require("dial.augend")
require("dial.config").augends:register_group{
  default = {
    augend.case.new{
      types = {"camelCase", "PascalCase"},
    },
  },
}
EOF

In this GIF, dial.nvim thinks that 'EOF' is PascalCase ↓

画面収録 2022-06-18 22 03 08

Provide a lua API instead of a string command

Hi! Thanks for this awesome plugin!
I set up this plugin in my config and found a little inconvenience. Readme suggests to set up keybindings this way:

vim.keymap.set("n", "<C-a>", require("dial.map").inc_normal(), {noremap = true})

As I understand inc_normal returns a strings instead of actually executing a command. But it does not play well with Packer's lazy loading, because it requires dial to load at the beginning.
I tried to wrap it with a function calling vim.command(...) and using keys entry in Packer triggers, but none of that worked.
The most reliable way I found is using module trigger and then calling dial inside some function. But this requies inc_normal to be an action.
So, is it possible to provide such interface?

Visual block mode increment

When using visual block mode and incrementing with <C-a>, the following error occurs:

E5108: Error executing lua ...site/pack/packer/opt/dial.nvim/lua/dial/augend/paren.lua:45: attempt to compare nil with number
stack traceback:
        ...site/pack/packer/opt/dial.nvim/lua/dial/augend/paren.lua:45: in function 'find_nested_paren'
        ...site/pack/packer/opt/dial.nvim/lua/dial/augend/paren.lua:147: in function 'find'
        .../nvim/site/pack/packer/opt/dial.nvim/lua/dial/handle.lua:167: in function <.../nvim/site/pack/packer/opt/dial.nvim/lua/dial/handle.lua:163>
        .../nvim/site/pack/packer/opt/dial.nvim/lua/dial/handle.lua:179: in function 'select_augend_visual'
        ...nvim/site/pack/packer/opt/dial.nvim/lua/dial/command.lua:84: in function 'select_augend_visual'

An example I was testing this on can be found below, with visual block mode on the numbers on each line:

1,hello
2,hi
3,hey

Workflow proposal

I don't know of a better place to write this so I'm doing it here but feel free to redirect me.

It will be nice if the groups are inherited from "default" so one can just add some augends for certain filetypes without having to duplicate the default group.
It will be also nice to make dial to use the group with the name of the filetype if it exists otherwise use 'default', that way instead of having several maps one could use the same and profit.

If you are ok with those, please, let me know. We could discuss the api and I could implement the requested changes.

By now I think both could be accomplished with this api:

 -- This one is a function I also think deal should have, probably with another name
local function words(vals)
     return augend.constant.new {
        elements = vals,
        word = true,
        cyclic = true,
        }
end

  require("dial.config").augends:register_group {
        default = {
          augend.date.alias["%Y-%m-%d"],
          ...
          },
          python = {
             words { "False", " True"  },
             extending="default" -- Or maybe true if it's from default, so less typing
            }
   }
   
   vim.keymap.set("n", "<C-A>", dm.inc_normal(filetype=true), { noremap = true })
   ...

Attempt to call method 'find' error

Whenever I press <C-A> I get the following error:

E5108: Error executing lua ...vim/site/pack/packer/start/dial.nvim/lua/dial/handle.lua:136: attempt to call method 'find' (a nil value)
stack traceback:
        ...vim/site/pack/packer/start/dial.nvim/lua/dial/handle.lua:136: in function <...vim/site/pack/packer/start/dial.nvim/lua/dial/handle.lua:132>
        ...vim/site/pack/packer/start/dial.nvim/lua/dial/handle.lua:148: in function 'select_augend'
        ...im/site/pack/packer/start/dial.nvim/lua/dial/command.lua:33: in function 'select_augend_normal'
        [string ":lua"]:1: in main chunk

nvim -v:

NVIM v0.8.0-dev-1202-g33dd917d7
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/cmake.config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az489-299

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Packer config:

use {
    "monaqa/dial.nvim",
    config = function()
        local augend = require("dial.augend")
        require("dial.config").augends:register_group({
            default = {
                augend.integer.alias.decimal,
                augend.integer.alias.hex,
                augend.hexcolor.new({
                    case = "upper",
                }),
                augend.semver,
                augend.date.alias["%Y/%m/%d"],
            },
        })
    end,
}

Key map (using legendary.nvim):

{
    "<c-a>", require("dial.map").inc_normal(),
    mode = { "n", "o" },
    description = "Increase next item under cursor or available",
},
{
    "<c-x>", require("dial.map").dec_normal(),
    mode = { "n", "o" },
    description = "Decrease next item under cursor or available",
},

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.