An open API service indexing awesome lists of open source software.

https://github.com/phrmendes/todotxt.nvim

A todo.txt plugin for Neovim.
https://github.com/phrmendes/todotxt.nvim

Last synced: 3 months ago
JSON representation

A todo.txt plugin for Neovim.

Awesome Lists containing this project

README

          

# todotxt.nvim

A lua version of [`todotxt.vim`](https://github.com/freitass/todo.txt-vim) with enhanced functionality for managing todo.txt files in Neovim.

## Features

- **File Management**: Toggle between todo.txt and done.txt files in floating windows
- **Task Operations**: Mark tasks as complete/incomplete, cycle task priorities (A-C)
- **New Task Creation**: Quick task capture with automatic date formatting
- **Task Organization**: Multiple sorting options (priority, context, project, due date)
- **Task Movement**: Automatically move completed tasks to done.txt file
- **Ghost Text**: Visual priority hints with customizable mappings and toggle support
- **Treesitter Support**: Enhanced syntax highlighting with todotxt parser

## Installation

Using [`mini.deps`](https://github.com/echasnovski/mini.deps):

```lua
MiniDeps.now(function()
MiniDeps.add({ source = "phrmendes/todotxt.nvim" })

require("todotxt").setup({
todotxt = vim.env.HOME .. "/Documents/notes/todo.txt",
donetxt = vim.env.HOME .. "/Documents/notes/done.txt",
ghost_text = {
enable = true,
mappings = {
["(A)"] = "now",
["(B)"] = "next",
["(C)"] = "today",
},
},
})
end)
```

Using [`lazy.nvim`](https://lazy.folke.io/installation):

```lua
return {
"phrmendes/todotxt.nvim",
cmd = { "TodoTxt", "DoneTxt" },
opts = {
todotxt = "path/to/the/todo.txt",
donetxt = "path/to/the/done.txt",
ghost_text = {
enable = true,
mappings = {
["(A)"] = "now",
["(B)"] = "next",
["(C)"] = "today",
},
},
},
}
```

Add these options:

```lua
vim.filetype.add({
filename = {
["todo.txt"] = "todotxt",
["done.txt"] = "todotxt",
},
})
```

Suggested keybindings:

```lua
vim.keymap.set("n", "tn", "TodoTxt new", { desc = "New todo entry" })
vim.keymap.set("n", "tt", "TodoTxt", { desc = "Toggle todo.txt" })
vim.keymap.set("n", "td", "DoneTxt", { desc = "Toggle done.txt" })
vim.keymap.set("n", "tg", "TodoTxt ghost", { desc = "Toggle ghost text" })
vim.keymap.set("n", "", "(TodoTxtToggleState)", { desc = "Toggle task state" })
vim.keymap.set("n", "n", "(TodoTxtCyclePriority)", { desc = "Cycle priority" })
vim.keymap.set("n", "tm", "(TodoTxtMoveDone)", { desc = "Move done tasks" })
vim.keymap.set("n", "tss", "(TodoTxtSortTasks)", { desc = "Sort tasks (default)" })
vim.keymap.set("n", "tsp", "(TodoTxtSortByPriority)", { desc = "Sort by priority" })
vim.keymap.set("n", "tsc", "(TodoTxtSortByContext)", { desc = "Sort by context" })
vim.keymap.set("n", "tsP", "(TodoTxtSortByProject)", { desc = "Sort by project" })
vim.keymap.set("n", "tsd", "(TodoTxtSortByDueDate)", { desc = "Sort by due date" })
```

This plugin works without dependencies, but for enhanced functionality (like syntax highlighting), the [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter) plugin with the [`todotxt`](https://github.com/arnarg/tree-sitter-todotxt) parser is recommended:

```lua
require("nvim-treesitter.configs").setup({
ensure_installed = { "todotxt" },
highlight = { enable = true },
})
```

The default path for `todo.txt` is `~/Documents/todo.txt`. Check the [help file](./doc/todotxt.txt) for more information.

## Ghost Text Feature

The ghost text feature displays visual hints next to tasks based on their priority levels. This can be customized with your own mappings:

```lua
ghost_text = {
enable = true,
mappings = {
["(A)"] = "now", -- High priority tasks
["(B)"] = "next", -- Medium priority tasks
["(C)"] = "today", -- Lower priority tasks
["(D)"] = "tomorrow", -- Even lower priority
["(E)"] = "this week",
["(F)"] = "next week",
},
prefix = " ", -- Text prefix
highlight = "Comment", -- Highlight group
}
```

You can toggle ghost text on/off using `:TodoTxt ghost` or the suggested keybinding.

## Commands

- `:TodoTxt` - Toggle todo.txt file in floating window
- `:TodoTxt new` - Create a new todo entry
- `:TodoTxt ghost` - Toggle ghost text display
- `:DoneTxt` - Toggle done.txt file in floating window

## References

- [`todo.txt`](https://github.com/todotxt/todo.txt)