aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2026-03-06 14:18:54 +0100
committerThomas Schmucker <ts@its1.de>2026-03-06 14:18:54 +0100
commit98553652a155cf53dc4c9336e0ad282c6776cf5a (patch)
tree8e128a45b6af2de0edefd0e5c5b4d744d0e6604b
parentcd8bf02c387bc0b2a0142bd368dea1e586a51949 (diff)
downloaddotfiles-98553652a155cf53dc4c9336e0ad282c6776cf5a.tar.gz
dotfiles-98553652a155cf53dc4c9336e0ad282c6776cf5a.tar.bz2
dotfiles-98553652a155cf53dc4c9336e0ad282c6776cf5a.zip
neovim: kürzere und elegantere Version
-rw-r--r--nvim/lua/plugins/ui.lua16
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)