From: Ruben Beltran del Rio Date: Mon, 4 Mar 2024 20:55:38 +0000 (+0100) Subject: Merge branch 'main' of git.sr.ht:~rbdr/dotfiles X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/commitdiff_plain/b662b6bcafaa991a0c1d470fb054dc5d88a58154?hp=07fd710d612c0e6b1bbf00d67f6a747e93991c13 Merge branch 'main' of git.sr.ht:~rbdr/dotfiles --- diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 49fedcc..674a55d 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -113,3 +113,4 @@ require('plugins') require('treesitter_config') require('lsp') require('dap_config') +require('calendar_tools') diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json index ba874a4..18ee0da 100644 --- a/config/nvim/lazy-lock.json +++ b/config/nvim/lazy-lock.json @@ -7,7 +7,7 @@ "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, "neodev.nvim": { "branch": "main", "commit": "84e0290f5600e8b89c0dfcafc864f45496a53400" }, "neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" }, - "nota.nvim": { "branch": "main", "commit": "503d09fc95a47c13141d097cf80dd243d1dce342" }, + "nota.nvim": { "branch": "main", "commit": "9e9e89d8556ecafa6b11ab21aa9ffab550f7f3ad" }, "nvim-dap": { "branch": "master", "commit": "fc880e82059eb21c0fa896be60146e5f17680648" }, "nvim-dap-ui": { "branch": "master", "commit": "9720eb5fa2f41988e8770f973cd11b76dd568a5d" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, @@ -20,4 +20,4 @@ "vim-fugitive": { "branch": "master", "commit": "2e88f14a585c014691904ba8fe39e6ea851c9422" }, "vim-indent-object": { "branch": "master", "commit": "8ab36d5ec2a3a60468437a95e142ce994df598c6" }, "vim-togglelist": { "branch": "master", "commit": "48f0d30292efdf20edc883e61b121e6123e03df7" } -} \ No newline at end of file +} diff --git a/config/nvim/lua/calendar_tools.lua b/config/nvim/lua/calendar_tools.lua new file mode 100644 index 0000000..2f8c602 --- /dev/null +++ b/config/nvim/lua/calendar_tools.lua @@ -0,0 +1,29 @@ +local function insert_agenda() + local clipboard_content = vim.fn.getreg('+') + + if not clipboard_content or clipboard_content == '' then + vim.api.nvim_err_writeln('This feature requires optional dependency fzf-lua') + end + + clipboard_content = clipboard_content:match('\n(.*)') + + local parts = vim.split(clipboard_content, '---', {plain = true, trimempty = true}) + + local agenda_text = {'# Agenda', ''} + for _, part in ipairs(parts) do + local trimmed_part = part:match('^%s*(.-)%s*$') + local lines = vim.split(trimmed_part, '\n', {trimempty = true}) + + if #lines >= 2 then + local date = lines[1] + local title = lines[2] + + table.insert(agenda_text, '[' .. date .. '] ' .. title) + end + end + local line = vim.api.nvim_win_get_cursor(0)[1] + vim.api.nvim_buf_set_lines(0, line, line, false, agenda_text) +end + +vim.api.nvim_create_user_command('InsertAgendaFromClipboard', insert_agenda, { nargs = 0 }) +vim.api.nvim_set_keymap('n', 'ia', 'InsertAgendaFromClipboard', { noremap = true, silent = true }) diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua index 24f77b5..15aeb95 100644 --- a/config/nvim/lua/plugins.lua +++ b/config/nvim/lua/plugins.lua @@ -77,6 +77,5 @@ require('lazy').setup({ 'tpope/vim-fugitive', 'milkypostman/vim-togglelist', - -- Notes - { dir = '~/projects/plugins/nota.nvim' } + 'https://git.sr.ht/~rbdr/nota.nvim' })