diff options
Diffstat (limited to 'nvim')
| -rw-r--r-- | nvim/lua/plugins/ui.lua | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua index 70140d8..7b5791e 100644 --- a/nvim/lua/plugins/ui.lua +++ b/nvim/lua/plugins/ui.lua | |||
| @@ -69,22 +69,14 @@ return { | |||
| 69 | vim.cmd("wincmd q") | 69 | vim.cmd("wincmd q") |
| 70 | vim.cmd("wincmd p") | 70 | vim.cmd("wincmd p") |
| 71 | 71 | ||
| 72 | local row, col = unpack(vim.api.nvim_win_get_cursor(0)) | ||
| 72 | local line = vim.api.nvim_get_current_line() | 73 | local line = vim.api.nvim_get_current_line() |
| 73 | local col = vim.api.nvim_win_get_cursor(0)[2] + 1 | ||
| 74 | 74 | ||
| 75 | local start = 1 | 75 | for s, _, e in line:gmatch("()(%d%d%d%d%-%d%d%-%d%d)()") do |
| 76 | while true do | 76 | if col + 1 >= s and col + 1 <= e - 1 then |
| 77 | local s, e = string.find(line, "%d%d%d%d%-%d%d%-%d%d", start) | 77 | vim.api.nvim_buf_set_text(0, row - 1, s - 1, row - 1, e - 1, { date }) |
| 78 | if not s then break end | ||
| 79 | |||
| 80 | if col >= s and col <= e then | ||
| 81 | local new = line:sub(1, s - 1) .. date .. line:sub(e + 1) | ||
| 82 | vim.api.nvim_set_current_line(new) | ||
| 83 | vim.api.nvim_win_set_cursor(0, { vim.fn.line("."), s + #date - 1 }) | ||
| 84 | return | 78 | return |
| 85 | end | 79 | end |
| 86 | |||
| 87 | start = e + 1 | ||
| 88 | end | 80 | end |
| 89 | 81 | ||
| 90 | vim.api.nvim_put({ date }, "c", true, true) | 82 | vim.api.nvim_put({ date }, "c", true, true) |
