feat(todo): add onlyTodo option

This commit is contained in:
Thomas Lambert
2022-09-28 22:25:51 +02:00
parent 31af52ed76
commit 74636e7416
3 changed files with 40 additions and 27 deletions

View File

@@ -112,32 +112,32 @@ of being able to edit it.
<!-- vim-markdown-toc GFM --> <!-- vim-markdown-toc GFM -->
* [0. Install and setup](#0-install-and-setup) - [0. Install and setup](#0-install-and-setup)
* [0.0 Prerequisites](#00-prerequisites) - [0.0 Prerequisites](#00-prerequisites)
* [0.0.1 Telescope](#001-telescope) - [0.0.1 Telescope](#001-telescope)
* [0.0.2 calendar-vim Plugin (optional)](#002-calendar-vim-plugin-optional) - [0.0.2 calendar-vim Plugin (optional)](#002-calendar-vim-plugin-optional)
* [0.0.3 For pasting images: xclip (optional)](#003-for-pasting-images-xclip-optional) - [0.0.3 For pasting images: xclip (optional)](#003-for-pasting-images-xclip-optional)
* [0.0.4 For image previews: telescope-media-files.nvim (optional)](#004-for-image-previews-telescope-media-filesnvim-optional) - [0.0.4 For image previews: telescope-media-files.nvim (optional)](#004-for-image-previews-telescope-media-filesnvim-optional)
* [catimg](#catimg) - [catimg](#catimg)
* [viu](#viu) - [viu](#viu)
* [telescope-media-files.nvim](#telescope-media-filesnvim) - [telescope-media-files.nvim](#telescope-media-filesnvim)
* [0.1 Install the plugin](#01-install-the-plugin) - [0.1 Install the plugin](#01-install-the-plugin)
* [0.1.0 Other useful plugins](#010-other-useful-plugins) - [0.1.0 Other useful plugins](#010-other-useful-plugins)
* [0.2 Configure telekasten.nvim](#02-configure-telekastennvim) - [0.2 Configure telekasten.nvim](#02-configure-telekastennvim)
* [0.3 Configure your own colors](#03-configure-your-own-colors) - [0.3 Configure your own colors](#03-configure-your-own-colors)
* [1. Get Help](#1-get-help) - [1. Get Help](#1-get-help)
* [2. Use it](#2-use-it) - [2. Use it](#2-use-it)
* [2.0 Telekasten command](#20-telekasten-command) - [2.0 Telekasten command](#20-telekasten-command)
* [2.1 Telekasten command palette](#21-telekasten-command-palette) - [2.1 Telekasten command palette](#21-telekasten-command-palette)
* [2.2 Telekasten lua functions](#22-telekasten-lua-functions) - [2.2 Telekasten lua functions](#22-telekasten-lua-functions)
* [2.3 Link notation](#23-link-notation) - [2.3 Link notation](#23-link-notation)
* [2.4 Tag notation](#24-tag-notation) - [2.4 Tag notation](#24-tag-notation)
* [2.5 Note templates](#25-note-templates) - [2.5 Note templates](#25-note-templates)
* [2.5.1 Template files](#251-template-files) - [2.5.1 Template files](#251-template-files)
* [2.6 Using the calendar](#26-using-the-calendar) - [2.6 Using the calendar](#26-using-the-calendar)
* [2.7 Using the telescope pickers](#27-using-the-telescope-pickers) - [2.7 Using the telescope pickers](#27-using-the-telescope-pickers)
* [3. Bind it](#3-bind-it) - [3. Bind it](#3-bind-it)
* [4. The hardcoded stuff](#4-the-hardcoded-stuff) - [4. The hardcoded stuff](#4-the-hardcoded-stuff)
<!-- vim-markdown-toc --> <!-- vim-markdown-toc -->
@@ -661,6 +661,8 @@ The plugin defines the following functions:
- this function accepts a parameter `{i}`. If `true`, it will enter input mode by pressing the 'A' key. This is - this function accepts a parameter `{i}`. If `true`, it will enter input mode by pressing the 'A' key. This is
useful when being used in a simple `inoremap` key mapping like shown in [Bind it](#3-bind-it). useful when being used in a simple `inoremap` key mapping like shown in [Bind it](#3-bind-it).
- example: `toggle_todo({ i=true })` - example: `toggle_todo({ i=true })`
- this function has also a `{onlyTodo}` parameter. If `true`, this will
avoid circling back to a regular list (`-`).
- this function can also be used in `visual` mode to toggle the status of multiple lines. - this function can also be used in `visual` mode to toggle the status of multiple lines.
- if using a keymapping to `toggle_todo` in visual mode, make sure to use `:Telekasten toggle_todo<CR>` - if using a keymapping to `toggle_todo` in visual mode, make sure to use `:Telekasten toggle_todo<CR>`
instead of `<cmd>Telekasten toggle_todo<CR>` to avoid neovim sending the wrong visual selection to instead of `<cmd>Telekasten toggle_todo<CR>` to avoid neovim sending the wrong visual selection to

View File

@@ -663,6 +663,13 @@ telekasten.toggle_todo({opts})~
Default: `nil` Default: `nil`
onlyTodo:
If true, it will avoid circling back to a regular list - when toggle_todo
is called on - [x] items.
Default: nil
*telekasten.show_backlinks()* *telekasten.show_backlinks()*
telekasten.show_backlinks()~ telekasten.show_backlinks()~
Opens a telescope search for notes that `[[link]]` back to the current note. Opens a telescope search for notes that `[[link]]` back to the current note.

View File

@@ -2736,7 +2736,11 @@ local function ToggleTodo(opts)
repline = curline:gsub("%- %[ %]", "- [x]", 1) repline = curline:gsub("%- %[ %]", "- [x]", 1)
else else
if vim.startswith(stripped, "- [x]") then if vim.startswith(stripped, "- [x]") then
if opts.onlyTodo then
repline = curline:gsub("%- %[x%]", "- [ ]", 1)
else
repline = curline:gsub("%- %[x%]", "-", 1) repline = curline:gsub("%- %[x%]", "-", 1)
end
else else
repline = curline:gsub("(%S)", "- [ ] %1", 1) repline = curline:gsub("(%S)", "- [ ] %1", 1)
end end