Closed MasouShizuka closed 1 year ago
Cannot reproduce 🤔 Could you show me a small reproducible vimrc?
I retested again, and this time commented out all my neovim settings, and it still didn't work, suggesting it had nothing to do with my settings.
It was tested on windows
before.
Then I copied my settings to neovim in wsl2
and it worked!
This is very strange that it doesn't work on windows.
Is it possible that <C-a>
key is being taken by the terminal?
No. <C-a>
works.
The setting is as below:
default = {
augend.date.alias["%m/%d"],
augend.date.alias["%-m/%-d"],
},
Then I can change text:
01/01
But I can't change text:
1/1
By the way, both can work in wsl2
.
Could you show me a small, entire, reproducible vimrc?
I don't have a windows environment so I don't think I can reproduce it, but it might give me some clues.
I just install it with lazy.nvim
.
Like I said before, I commented out all the other settings to no avail.
If you absolutely need it, here's reproducible code in init.lua
:
local plugin_list = {
{
"monaqa/dial.nvim",
config = function()
vim.keymap.set("n", "<C-a>", require("dial.map").inc_normal(), { silent = true })
vim.keymap.set("n", "<C-x>", require("dial.map").dec_normal(), { silent = true })
vim.keymap.set("x", "<C-a>", require("dial.map").inc_visual(), { silent = true })
vim.keymap.set("x", "<C-x>", require("dial.map").dec_visual(), { silent = true })
vim.keymap.set("x", "g<C-a>", require("dial.map").inc_gvisual(), { silent = true })
vim.keymap.set("x", "g<C-x>", require("dial.map").dec_gvisual(), { silent = true })
local augend = require("dial.augend")
require("dial.config").augends:register_group {
default = {
augend.date.alias["%m/%d"],
augend.date.alias["%-m/%-d"],
},
}
end,
},
}
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
return require("lazy").setup(plugin_list)
By the way, my neovim's version is 0.8.3
both on windows
and wsl2
.
Thanks. I confirmed that there seems to be no problem with the configuration.
Unfortunately, I still could not reproduce it in my environment (macOS). It seems to be environment-dependent as you say, but I have no idea why.
I tested some more, hope it helps, as follows:
windows | pattern | text before | cursor | text after |
---|---|---|---|---|
%-m/%-d | 1/4 | 1 or 4 | 1/4 | |
%-d.%-m. | 4.1. | 4 or 1 | 4.1. | |
%Y年%-m月%-d日 | 2021年1月4日 | 4 | 2021年1609804800月1609804800日 | |
%Y年%-m月%-d日 | 2021年1月4日 | 1 | 2021年1612396800月1612396800日 | |
%Y年%-m月%-d日(%ja) | 2021年1月4日(月) | 4 | 2021年1609804800月1609804800日(火) | |
%Y年%-m月%-d日(%ja) | 2021年1月4日(月) | 1 | 2021年1612396800月1612396800日(木) | |
%-y/%m/%d | 9/01/04 | 9 | 9/01/04 | |
%-H:%-M:%-S | 12:2:3 | 12 or 2 or 3 | 12:2:3 | |
%-I:%-M:%-S | 12:2:3 | 12 or 2 or 3 | 12:2:3 |
Among them, the result of %Y年%-m月%-d日
is very abnormal.
By the way, wsl2 | pattern | text before | cursor | text after |
---|---|---|---|---|
%-m/%-d | 1/4 | 4 | 1/5 | |
%-m/%-d | 1/4 | 1 | 2/4 | |
%-d.%-m. | 4.1. | 4 | 5.1. | |
%-d.%-m. | 4.1. | 1 | 4.2. | |
%Y年%-m月%-d日 | 2021年1月4日 | 4 | 2021年1月5日 | |
%Y年%-m月%-d日 | 2021年1月4日 | 1 | 2021年2月4日 | |
%Y年%-m月%-d日(%ja) | 2021年1月4日(月) | 4 | 2021年1月5日(火) | |
%Y年%-m月%-d日(%ja) | 2021年1月4日(月) | 1 | 2021年2月4日(木) | |
%-y/%m/%d | 9/01/04 | 9 | 10/01/04 | |
%-H:%-M:%-S | 12:2:3 | 12 | 13:2:3 | |
%-H:%-M:%-S | 12:2:3 | 2 | 12:3:3 | |
%-H:%-M:%-S | 12:2:3 | 3 | 12:2:4 | |
%-I:%-M:%-S | 12:2:3 | 12 | 1:2:3 | |
%-I:%-M:%-S | 12:2:3 | 2 | 12:3:3 | |
%-I:%-M:%-S | 12:2:3 | 3 | 12:2:4 |
@MasouShizuka Thank you for the further research. It is very helpful.
With some help, we finally found the cause: some os.date
results seem to be different on Windows than others.
(Thank you, @yuys13 !)
I have created a PR (#65) to fix the issue. Could you try this?
Now the test result is: | pattern | text before | cursor | text after |
---|---|---|---|---|
%-m/%-d | 1/4 | 1 | 1/5 | |
%-m/%-d | 1/4 | 4 | 2/4 | |
%-d.%-m. | 4.1. | 4 | 5.1. | |
%-d.%-m. | 4.1. | 1 | 4.2. | |
%Y年%-m月%-d日 | 2021年1月4日 | 4 | 2021年1月5日 | |
%Y年%-m月%-d日 | 2021年1月4日 | 1 | 2021年2月4日 | |
%Y年%-m月%-d日(%ja) | 2021年1月4日(月) | 4 | 2021年1月5日(火) | |
%Y年%-m月%-d日(%ja) | 2021年1月4日(月) | 1 | 2021年2月4日(木) | |
%-y/%m/%d | 9/01/04 | 9 | 9/01/04 | |
%-H:%-M:%-S | 12:2:3 | 12 or 2 or 3 | 12:2:3 | |
%-I:%-M:%-S | 12:2:3 | 12 or 2 or 3 | 12:2:3 |
Looks like %-y didn't fix it, and %-H, %-I, %-M, %-S didn't work
Oh, augend.date.alias["%-H:%-M:%-S"]
doesn't work, but
augend.date.new {
pattern = "%-H:%-M:%-S",
default_kind = "day",
only_valid = true,
word = false,
},
work.
I fixed about the %-y
.
Date alias "%-H:%-M:%-S"
does not exist, so please try examples such as:
dial_config.augends:register_group {
default = {
augend.date.new {
pattern = "%-H:%-M:%-S",
default_kind = "sec",
only_valid = false,
},
augend.date.new {
pattern = "%-I:%-M",
default_kind = "min",
only_valid = false,
},
},
}
I roughly tested it, it should be fine.
Okay, I'll merge #65 and close this issue. Feel free to reopen this / create a new issue if you encounter strange behavior.
Indefinite length patterns such as %-m and %-d in the date cannot work.
For example, this is setting:
And this is text:
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?