local telescope = require('telescope.builtin') local M = {} local function vault_root() local path = vim.fn.expand('%:p:h') local home = vim.fn.expand('~') while path ~= home and path ~= '/' do if vim.fn.filereadable(path .. '/time.csv') == 1 or vim.fn.isdirectory(path .. '/.obsidian') == 1 then return path end path = vim.fn.fnamemodify(path, ':h') end return vim.fn.getcwd() end -- all open tasks vault-wide (equivalent to tdo shell alias) function M.open_tasks() telescope.grep_string({ prompt_title = "Open Tasks", search = "\\- \\[[^x~]\\]", use_regex = true, cwd = vault_root(), }) end -- priority open tasks vault-wide (equivalent to tdop shell alias) function M.priority_tasks() telescope.grep_string({ prompt_title = "Priority Tasks", search = "\\- \\[[^x~]\\].*(🔼|⏫)", use_regex = true, cwd = vault_root(), }) end return M