Skip to content

Commit

Permalink
feat: adding tasks with quotes
Browse files Browse the repository at this point in the history
in case you want to add a task with `:Do {task}` but the task starts
with a command word (status, done, add, edit, toggle), add the task with
`:Do "{task}"`instead.

also minor docs tweaks
  • Loading branch information
Hashino committed Jan 5, 2025
1 parent e4639e8 commit 752d5d4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,29 @@ this plugin was originally a fork of [nocksock/do.nvim](https://github.com/nocks

![doing](https://raw.githubusercontent.com/Hashino/doing.nvim/main/demo.gif)

## Usage
## Commands

### Adding Tasks

- `:Do add {task}`
- `:Do {task}`
- `:Do "{task}"`

will all add `{task}` to the end of the tasklist

- `:Do! add {task}`
- `:Do! {task}`
- `:Do! "{task}"`

will all add `{task}` to the start of the tasklist

### Other Commands

- `:Do add {task}` add a {task} to the end of the list
- `:Do! add {task}` add a {task} to the front of list
- `:Do status` shows notification with current task/message (even if toggled off)
- `:Do done` remove the first task from the list
- `:Do edit` edit the tasklist in a floating window
- `:Do toggle` toggle the display (winbar and status)

> [!NOTE]
> if the command is unrecognized it defaults to `add`. so `Do {task}` and
> `Do! {task}` are equivalent to `Do add {task}` and `Do! add {task}`
## Installation

lazy.nvim:
Expand All @@ -38,11 +48,13 @@ lazy.nvim:

## Configuration

this plugin sets no keymaps by itself. an example on how to set them is given
below
### Default Configs

[see the source code for default configs](https://github.com/Hashino/doing.nvim/blob/e4639e848b1503c14a591e3bfc6862560eeccefb/lua/doing/state.lua#L18-L45)

### Example Config

```lua
-- example configuration
{
"Hashino/doing.nvim",
config = function()
Expand All @@ -52,8 +64,8 @@ below
doing_prefix = "Doing: ",

-- doesn"t display on buffers that match filetype/filename/filepath to
-- entries can be either a string array or a function that returns a
-- string array filepath can be relative or absolute
-- entries. can be either a string array or a function that returns a
-- string array. filepath can be relative to cwd or absolute
ignored_buffers = { "NvimTree" },

-- if should append "+n more" to the status when there's tasks remaining
Expand Down
12 changes: 8 additions & 4 deletions lua/doing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ function Doing.add(task, to_front)
Doing.setup()
end

if task == nil then
if task then
if task:sub(1,1) == '"' and task:sub(-1,-1) == '"' then
task = task:sub(2, -2)
end

state.tasks:add(task, to_front)
utils.task_modified()
else
vim.ui.input({ prompt = "Enter the new task: ", }, function(input)
state.tasks:add(input, to_front)
utils.task_modified()
end)
else
state.tasks:add(task, to_front)
utils.task_modified()
end
end

Expand Down
1 change: 1 addition & 0 deletions lua/doing/api.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vim.deprecate( 'require("doing.api")', 'require("doing")', "0.2.0", "doing.nvim")

return require("doing")

0 comments on commit 752d5d4

Please sign in to comment.