diff --git a/README.md b/README.md index 2072ccd..874c91c 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,11 @@ return { vim.keymap.set("n", "nfj", "ObsNvimFindInJournal") vim.keymap.set("n", "nff", "ObsNvimFindNote") vim.keymap.set("n", "nfg", "ObsNvimFindInNotes") + vim.keymap.set( + "n", + "nft", + "ObsNvimFindTodosInNotes" + ) end, }, } @@ -96,7 +101,8 @@ Example mappings configuration may be found [here](https://github.com/IlyasYOY/d - *Opens daily note.* `:ObsNvimDailyNote` creates one if doesn't exist. - *Telescope find notes.* `:ObsNvimFindNote`. - *Telescope find journal notes.* `:ObsNvimFindInJournal`. -- *Telescope live-grep through notes.* `:ObsNvimFinInNotes`. +- *Telescope live-grep through notes.* `:ObsNvimFindInNotes`. +- *Telescope live-grep through tasks prepared search.* `:ObsNvimFindTodosInNotes`. - *Telescope through back-links.* `:ObsNvimBacklinks`. - *Renames current note.* `:ObsNvimRename` updates links to the note. I advice you to rename notes inside **Obsidian** for important notes with lots of back-links. - *Move note to directory from search.* `:ObsNvimMove` launches telescope to find directory to move current note to. diff --git a/lua/obs/init.lua b/lua/obs/init.lua index 76bac2b..40189b3 100644 --- a/lua/obs/init.lua +++ b/lua/obs/init.lua @@ -69,6 +69,12 @@ end, { desc = "Find in notes", }) +vim.api.nvim_create_user_command("ObsNvimFindTodosInNotes", function() + obs.vault:find_todos() +end, { + desc = "Find todos in notes", +}) + vim.api.nvim_create_user_command("ObsNvimBacklinks", function() obs.vault:run_if_note(function() obs.vault:find_current_note_backlinks() diff --git a/lua/obs/telescope.lua b/lua/obs/telescope.lua index a395507..cff03c8 100644 --- a/lua/obs/telescope.lua +++ b/lua/obs/telescope.lua @@ -43,13 +43,15 @@ end ---@param title string ---@param path string to search files at ---@param type_filter string? file type, check rg docs typelist on the matter -function M.grep_files(title, path, type_filter) +---@param default_text string? default query to run search with +function M.grep_files(title, path, type_filter, default_text) if type_filter == nil then type_filter = "md" end return builtin.live_grep { cwd = path, + default_text = default_text, prompt_title = title, type_filter = type_filter, } diff --git a/lua/obs/vault.lua b/lua/obs/vault.lua index 1210a8a..566c072 100644 --- a/lua/obs/vault.lua +++ b/lua/obs/vault.lua @@ -158,6 +158,11 @@ function Vault:find_note() obs_telescope.find_files("Find notes", self._home_path:expand()) end +function Vault:find_todos() + local request_string = "- \\[[x ]\\]" + obs_telescope.grep_files("Find TODOs", self._home_path:expand(), nil, request_string) +end + function Vault:find_current_note_backlinks() local current_note = File:new(core.current_working_file()) self:find_backlinks(current_note:name())