Skip to content

Commit

Permalink
Merge pull request #2 from adrianvalenz/optimize/reset-time-index
Browse files Browse the repository at this point in the history
Optimize/reset time index
  • Loading branch information
adrianvalenz authored Sep 28, 2023
2 parents 2b809c3 + 6724cd5 commit 2b40425
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ return {

## How to use

Just hit `<C-q>` repeatedly (while in insert mode) until you come across a date you like.
Just hit `<C-t>` repeatedly (while in insert mode) until you come across a date you like.

## Configuration

No real configuration. Right now the function just a keymap that calls the function.
Can be overridden pretty easily.
No real configuration. A keymap that calls the function to cycle through the time.

Place something like this in your `keymaps.lua` or where ever you keep your mappings:
To override, place something like this in your `keymaps.lua` or where ever you keep your mappings:

```
# To override just pass in the keymap of your choice. Like if it is: <C-t>
vim.keymap.set("i", "<C-t>", "<Cmd>lua cycle_date_format()<CR>", { noremap = true })
# This changed the keymap to <C-o> and enables it in normal mode
vim.keymap.set("n", "<C-o>", "<Cmd>lua cycle_date_format()<CR>", { noremap = true })
```

## Why this plugin?
Expand Down
8 changes: 5 additions & 3 deletions plugin/chronos.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
print("Chronos loaded in due time")
print("Chronos loaded in just in time")

local date_formats = {
"%Y-%m-%d",
"%Y/%m/%d",
"%d/%m/%Y",
"%m-%d-%Y",
"%m/%d/%Y",
}

local current_format_index = 1
Expand All @@ -27,9 +28,10 @@ function cycle_date_format()
end

function reset_feature()
current_format_index = 1
last_inserted_text = ""
end

vim.keymap.set("i", "<C-q>", "<Cmd>lua cycle_date_format()<CR>", { noremap = true })
vim.keymap.set("i", "<C-t>", "<Cmd>lua cycle_date_format()<CR>", { noremap = true })
vim.cmd("autocmd InsertCharPre * lua reset_feature()")

0 comments on commit 2b40425

Please sign in to comment.