diff options
| author | Thomas Schmucker <ts@its1.de> | 2026-03-06 12:26:49 +0100 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2026-03-06 12:26:49 +0100 |
| commit | 0b97925fb8e916e14635c6ece5138a3008e7f8d3 (patch) | |
| tree | 3192884ba1fcee89b6639b82e466ec4e4bf90a7f | |
| parent | aaf120060e61be46255506576674a5aa06f57192 (diff) | |
| download | dotfiles-0b97925fb8e916e14635c6ece5138a3008e7f8d3.tar.gz dotfiles-0b97925fb8e916e14635c6ece5138a3008e7f8d3.tar.bz2 dotfiles-0b97925fb8e916e14635c6ece5138a3008e7f8d3.zip | |
neovim: calender kann nun auch das Datum aktualisieren
| -rw-r--r-- | nvim/lua/plugins/ui.lua | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua index 502c271..22c0c3a 100644 --- a/nvim/lua/plugins/ui.lua +++ b/nvim/lua/plugins/ui.lua | |||
| @@ -64,18 +64,41 @@ return { | |||
| 64 | "mattn/calendar-vim", | 64 | "mattn/calendar-vim", |
| 65 | config = function() | 65 | config = function() |
| 66 | vim.cmd([[ | 66 | vim.cmd([[ |
| 67 | function! CalendarInsertDate(day, month, year, week, dir) | 67 | function! CalendarInsertDate(day, month, year, week, dir) |
| 68 | let date = printf("%04d-%02d-%02d", a:year, a:month, a:day) | 68 | let date = printf("%04d-%02d-%02d", a:year, a:month, a:day) |
| 69 | wincmd q | ||
| 70 | wincmd p | ||
| 71 | execute "normal! a" . date | ||
| 72 | endfunction | ||
| 73 | let calendar_action = 'CalendarInsertDate' | ||
| 74 | 69 | ||
| 75 | let g:calendar_monday = 1 | 70 | " Kalenderfenster schließen und zum vorherigen Fenster zurück |
| 76 | let g:calendar_wruler = 'So Mo Di Mi Do Fr Sa' | 71 | wincmd q |
| 77 | let g:calendar_mruler = 'Jan,Feb,Mär,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez' | 72 | wincmd p |
| 78 | let g:calendar_weeknm = 4 | 73 | |
| 74 | let pattern = '\v\d{4}-\d{2}-\d{2}' | ||
| 75 | let line = getline('.') | ||
| 76 | let col = col('.') | ||
| 77 | |||
| 78 | " Prüfen ob Cursor innerhalb eines Datums steht | ||
| 79 | let start = match(line, pattern) | ||
| 80 | |||
| 81 | while start >= 0 | ||
| 82 | let end = start + strlen(matchstr(line[start:], pattern)) | ||
| 83 | if col >= start + 1 && col <= end | ||
| 84 | " Datum ersetzen | ||
| 85 | call setline('.', line[:start-1] . date . line[end:]) | ||
| 86 | call cursor('.', start + strlen(date)) | ||
| 87 | return | ||
| 88 | endif | ||
| 89 | let start = match(line, pattern, end) | ||
| 90 | endwhile | ||
| 91 | |||
| 92 | " Kein Datum unter Cursor → wie bisher einfügen | ||
| 93 | execute "normal! a" . date | ||
| 94 | endfunction | ||
| 95 | |||
| 96 | let calendar_action = 'CalendarInsertDate' | ||
| 97 | |||
| 98 | let g:calendar_monday = 1 | ||
| 99 | let g:calendar_wruler = 'So Mo Di Mi Do Fr Sa' | ||
| 100 | let g:calendar_mruler = 'Jan,Feb,Mär,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez' | ||
| 101 | let g:calendar_weeknm = 4 | ||
| 79 | ]]) | 102 | ]]) |
| 80 | end, | 103 | end, |
| 81 | }, | 104 | }, |
