Closed kvalv closed 3 years ago
If you think it's worth fixing, I could actually try to fix it myself. I don't have much experience with lua, but this doesn't seem to be too hard to fix.
Idea is to have
As you said, Vim automatically finds first number and increases it. I don't think there's a way to prevent it from doing that.
Workaround is to bind date increment/decrement to another mapping, for example +/-:
require('orgmode').setup({
mappings = {
org = {
org_increase_date = '+',
org_decrease_date = '+'
}
}
})
That way
Workaround is to bind date increment/decrement to another mapping, for example +/-:
I tried what you suggested, but it seemed to give the same behaviour as <C-a>
/ <C-x>
, probably because the fallback is sent to nvim here: https://github.com/kristijanhusak/orgmode.nvim/blob/master/lua/orgmode/org/mappings.lua#L118
So I guess what I'm asking for is that <C-a>
will first move to the date context (similar to how <C-a>
is moving to the closest number) and then increase the date by one. Alternatively, it does not do anything if it's not on a date context. I think the current behaviour is not so intuitive, even though it makes sense by how vim's <C-a>
and org-mode's <C-a>
work
Oh, right, I need to fix that fallback to fallback to the defined mapping.
We could handle it by jumping to next number manually and then re-checking if it's date or not. Thanks for suggestion, I'll try to fix it.
@kvalv I pushed a fix for this.
Let me know if it works as expected.
Hey, nice to hear you worked on this!
OK, so the way I understood it, if the cursor is on the beginning of the line and I hit <C-a>
it should move to the next date object and increase it by 1 day. On the video, if I hit do that, nothing happens. (which is still much better than increasing the year)
Perhaps an unexpected side-effect of the change is that if I now type <C-a>
without next dates, it moves to the nearest number (in this case 2
), which I think also is not intended.
https://user-images.githubusercontent.com/9867901/124020825-18b52a00-d9eb-11eb-92bd-87ea5cccb691.mp4
Do you have default mappings set for this? It's not behaving same for you like it is for me. Here's gif how it works for me:
Hey, yes you are right about that. I added this to the config:
mappings = {
org = {
org_increase_date = '+',
org_decrease_date = '+'
}
and after removing that mapping it works as expected. Really nice, thank you very much! I guess this can be closed then.
Hey, this is a really nice project and I'm happy to see such active development on this. It already looks promising!
Describe the bug Using
<C-a>
when the cursor is not on the date will increment the year, and thereafter it'll work properly.To Reproduce Steps to reproduce the behavior:
:now:
and exit insert mode.0
(zero) )<C-a>
<C-a>
the day increases, as expected.Expected behavior The date should increase by one day when I type
<C-a>
, even if the cursor is not on the date object.Screenshots
https://user-images.githubusercontent.com/9867901/123950229-be44ab00-d9a3-11eb-95b0-9049920026c8.mp4
System information:
Additional context
<C-a>
normally finds the closest number and increase it, so it makes sense that the first<C-a>
increase the year (that's vim builtin behaviour). Subsequently the cursor is on the date object, and orgmode<C-a>
functionality takes precedence and increase the day. However, I consider this a bug because the expected behaviour is that<C-a>
should "do the right thing" and increase the date immediately.I guess also
<C-x>
have the same issue.