From 5f8e237669c6c2248f032a311cb3cba9797ff772 Mon Sep 17 00:00:00 2001 From: Simon Lasbrugnas Date: Fri, 11 Aug 2023 14:40:39 +0200 Subject: [PATCH] feat: add vim-bujo keybindings (todo-list management) --- lua/default/remap.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/default/remap.lua b/lua/default/remap.lua index 0b5d280..3a77a59 100644 --- a/lua/default/remap.lua +++ b/lua/default/remap.lua @@ -52,6 +52,20 @@ vim.keymap.set("n", "bp", function() vim.cmd("bp") end, {}) +-- vim-bujo keybindings +local function toggleTodo() + local line = vim.fn.getline(".") + if vim.fn.match(line, "- \\[ \\]") ~= -1 then + vim.fn.setline(".", vim.fn.substitute(line, "- \\[ \\]", "- [x]", "")) + else + vim.fn.setline(".", vim.fn.substitute(line, "- \\[x\\]", "- [ ]", "")) + end +end +vim.keymap.set("n", "", "i- [ ] ") +vim.keymap.set("i", "", "- [ ] ") +vim.keymap.set("n", "", function() toggleTodo() end) +vim.keymap.set("i", "", function() toggleTodo() end) + -- Define a function to execute the appropriate program based on file type vim.keymap.set("n", "/", function() local filetype = vim.bo.filetype