Auto sync: 2025-09-09 18:42:47 (4 files changed)

M  lazy-lock.json

M  lua/custom/chadrc.lua

M  lua/custom/plugins.lua

M  lua/custom/taskwarrior.lua
This commit is contained in:
Dane Sabo 2025-09-09 18:42:47 -04:00
parent bc253d49c2
commit e064cecd90
4 changed files with 200 additions and 69 deletions

View File

@ -22,6 +22,7 @@
"nvim-dap": { "branch": "master", "commit": "7891b01beedc37cef4eaf2e92563bd0a5b6e9c58" }, "nvim-dap": { "branch": "master", "commit": "7891b01beedc37cef4eaf2e92563bd0a5b6e9c58" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
"nvim-lspconfig": { "branch": "master", "commit": "a3deebbd110016f50cc66b7b256120072f3804db" }, "nvim-lspconfig": { "branch": "master", "commit": "a3deebbd110016f50cc66b7b256120072f3804db" },
"nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" },
"nvim-tree.lua": { "branch": "master", "commit": "fefa335f1c8f690eb668a1efd18ee4fc6d64cd3e" }, "nvim-tree.lua": { "branch": "master", "commit": "fefa335f1c8f690eb668a1efd18ee4fc6d64cd3e" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-web-devicons": { "branch": "master", "commit": "f66cdfef5e84112045b9ebc3119fee9bddb3c687" }, "nvim-web-devicons": { "branch": "master", "commit": "f66cdfef5e84112045b9ebc3119fee9bddb3c687" },

View File

@ -7,8 +7,8 @@ M.ui = {
hl_add = {}, hl_add = {},
hl_override = {}, hl_override = {},
changed_themes = {}, changed_themes = {},
theme_toggle = { "falcon", "one_light" }, theme_toggle = { "tokyodark", "one_light" },
theme = "falcon", -- default theme theme = "tokyodark", -- default theme
transparency = false, transparency = false,
lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens

View File

@ -108,7 +108,7 @@ local plugins = {
lazy = false, lazy = false,
keys = { keys = {
-- Will use Telescope if installed or a vim.ui.select picker otherwise -- Will use Telescope if installed or a vim.ui.select picker otherwise
{ "<leader>fs", "<cmd>SessionSearch<CR>", desc = "Session search" }, { "<leader>fs", "<cmd>AutoSession search<CR>", desc = "Session search" },
{ {
"<leader>ws", "<leader>ws",
function() function()
@ -118,14 +118,14 @@ local plugins = {
-- optionally check if the user provided something -- optionally check if the user provided something
if session_name ~= nil and session_name ~= "" then if session_name ~= nil and session_name ~= "" then
-- construct the command with the chosen name -- construct the command with the chosen name
vim.cmd("SessionSave " .. session_name) vim.cmd("AutoSession save " .. session_name)
else else
print "No session name given. Session not saved." print "No session name given. Session not saved."
end end
end, end,
desc = "Save session (prompts for name)", desc = "Save session (prompts for name)",
}, },
{ "<leader>wa", "<cmd>SessionToggleAutoSave<CR>", desc = "Toggle autosave" }, { "<leader>wa", "<cmd>AutoSession ToggleAutoSave<CR>", desc = "Toggle autosave" },
}, },
---enables autocomplete for opts ---enables autocomplete for opts
---@module "auto-session" ---@module "auto-session"
@ -195,6 +195,13 @@ local plugins = {
lazy = true, lazy = true,
ft = { "markdown", "tex" }, -- load only when editing Markdown/TeX ft = { "markdown", "tex" }, -- load only when editing Markdown/TeX
}, },
{
"rcarriga/nvim-notify",
lazy = false,
config = function()
vim.notify = require "notify"
end,
},
} }
return plugins return plugins

View File

@ -1,31 +1,89 @@
-- Taskwarrior integration for Neovim -- Taskwarrior integration for Neovim with clean notifications
-- Add this to your ~/.config/nvim/init.lua or create a separate plugin file -- Add this to your ~/.config/nvim/init.lua or create a separate plugin file
-- Helper function for clean error handling with notifications
local function run_task_command(cmd, success_msg, error_prefix)
local result = vim.fn.system(cmd)
if vim.v.shell_error == 0 then
if success_msg then
vim.notify(success_msg, vim.log.levels.INFO)
end
return true, result
else
vim.notify((error_prefix or "Error") .. ": " .. vim.trim(result), vim.log.levels.ERROR)
return false, result
end
end
-- Basic task management commands -- Basic task management commands
vim.api.nvim_create_user_command("TaskAdd", function(opts) vim.api.nvim_create_user_command("TaskAdd", function(opts)
local task_desc = opts.args local task_desc = opts.args
if task_desc == "" then if task_desc == "" then
task_desc = vim.fn.input "Task description: " task_desc = vim.fn.input "Task description: "
end end
vim.fn.system("task add " .. vim.fn.shellescape(task_desc)) if task_desc ~= "" then
print("Task added: " .. task_desc) run_task_command("task add " .. task_desc, "Task added successfully", "Error adding task")
end
end, { nargs = "*", desc = "Add a new task" }) end, { nargs = "*", desc = "Add a new task" })
vim.api.nvim_create_user_command("TaskList", function() vim.api.nvim_create_user_command("TaskList", function()
local output = vim.fn.system "task list" local success, output = run_task_command("task list", nil, "Error listing tasks")
vim.cmd "new" if success then
vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.split(output, "\n")) vim.cmd "new"
vim.bo.buftype = "nofile" vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.split(output, "\n"))
vim.bo.bufhidden = "wipe" vim.bo.buftype = "nofile"
vim.bo.modifiable = false vim.bo.bufhidden = "wipe"
vim.wo.number = false vim.bo.modifiable = false
vim.wo.relativenumber = false vim.wo.number = false
end, { desc = "Show task list in new buffer" }) vim.wo.relativenumber = false
-- Set a descriptive buffer name
vim.api.nvim_buf_set_name(0, "TaskWarrior List (All)")
end
end, { desc = "Show all pending tasks in new buffer" })
vim.api.nvim_create_user_command("TaskNext", function() vim.api.nvim_create_user_command("TaskNext", function()
local output = vim.fn.system "task next" local success, output = run_task_command("task next limit:10", nil, "Error getting next tasks")
print(vim.trim(output)) if success then
end, { desc = "Show next tasks" }) local lines = vim.split(vim.trim(output), "\n")
-- Filter out empty lines
local clean_lines = {}
for _, line in ipairs(lines) do
if line ~= "" and not line:match "^%s*$" then
table.insert(clean_lines, line)
end
end
if #clean_lines > 0 then
-- Create floating window for next tasks
local width = math.min(math.max(80, vim.o.columns - 20), 120)
local height = math.min(#clean_lines + 2, 25)
local row = math.floor((vim.o.lines - height) / 2)
local col = math.floor((vim.o.columns - width) / 2)
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, clean_lines)
local opts = {
relative = "editor",
width = width,
height = height,
row = row,
col = col,
style = "minimal",
border = "rounded",
title = " Next Tasks ",
title_pos = "center",
}
vim.api.nvim_open_win(buf, true, opts)
vim.bo[buf].modifiable = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = buf })
vim.keymap.set("n", "<Esc>", "<cmd>close<cr>", { buffer = buf })
else
vim.notify("No pending tasks", vim.log.levels.WARN)
end
end
end, { desc = "Show next 10 highest priority tasks in floating window" })
vim.api.nvim_create_user_command("TaskEdit", function(opts) vim.api.nvim_create_user_command("TaskEdit", function(opts)
local task_id = opts.args local task_id = opts.args
@ -33,8 +91,7 @@ vim.api.nvim_create_user_command("TaskEdit", function(opts)
task_id = vim.fn.input "Task ID to edit: " task_id = vim.fn.input "Task ID to edit: "
end end
if task_id ~= "" then if task_id ~= "" then
vim.fn.system("task " .. task_id .. " edit") run_task_command("task " .. task_id .. " edit", "Edited task " .. task_id, "Error editing task")
print("Edited task " .. task_id)
end end
end, { nargs = "?", desc = "Edit a task by ID" }) end, { nargs = "?", desc = "Edit a task by ID" })
@ -44,8 +101,7 @@ vim.api.nvim_create_user_command("TaskDone", function(opts)
task_id = vim.fn.input "Task ID to complete: " task_id = vim.fn.input "Task ID to complete: "
end end
if task_id ~= "" then if task_id ~= "" then
vim.fn.system("task " .. task_id .. " done") run_task_command("task " .. task_id .. " done", "Task " .. task_id .. " completed!", "Error completing task")
print("Task " .. task_id .. " completed!")
end end
end, { nargs = "?", desc = "Mark task as done" }) end, { nargs = "?", desc = "Mark task as done" })
@ -55,30 +111,85 @@ vim.api.nvim_create_user_command("TaskModify", function(opts)
local task_id = vim.fn.input "Task ID: " local task_id = vim.fn.input "Task ID: "
local modification = vim.fn.input "Modification (e.g., 'priority:H', '+urgent'): " local modification = vim.fn.input "Modification (e.g., 'priority:H', '+urgent'): "
if task_id ~= "" and modification ~= "" then if task_id ~= "" and modification ~= "" then
vim.fn.system("task " .. task_id .. " modify " .. modification) run_task_command(
print("Modified task " .. task_id) "task " .. task_id .. " modify " .. modification,
"Modified task " .. task_id,
"Error modifying task"
)
end end
else else
local task_id = args[1] local task_id = args[1]
local modification = table.concat(args, " ", 2) local modification = table.concat(args, " ", 2)
vim.fn.system("task " .. task_id .. " modify " .. modification) run_task_command(
print("Modified task " .. task_id .. " with: " .. modification) "task " .. task_id .. " modify " .. modification,
"Modified task " .. task_id,
"Error modifying task"
)
end end
end, { nargs = "*", desc = "Modify a task" }) end, { nargs = "*", desc = "Modify a task" })
vim.api.nvim_create_user_command("TaskStart", function(opts)
local task_id = opts.args
if task_id == "" then
task_id = vim.fn.input "Task ID to start: "
end
if task_id ~= "" then
run_task_command("task " .. task_id .. " start", "Started task " .. task_id, "Error starting task")
end
end, { nargs = "?", desc = "Start working on a task" })
vim.api.nvim_create_user_command("TaskStop", function(opts)
local task_id = opts.args
if task_id == "" then
-- If no ID provided, stop the active task
local success, active_output = run_task_command("task +ACTIVE ids", nil, "Error finding active tasks")
if success then
local active_id = vim.trim(active_output)
if active_id ~= "" then
run_task_command("task " .. active_id .. " stop", "Stopped active task " .. active_id, "Error stopping task")
else
vim.notify("No active task to stop", vim.log.levels.WARN)
end
end
else
run_task_command("task " .. task_id .. " stop", "Stopped task " .. task_id, "Error stopping task")
end
end, { nargs = "?", desc = "Stop working on a task" })
vim.api.nvim_create_user_command("TaskActive", function()
local success, output = run_task_command("task +ACTIVE list", nil, "Error getting active tasks")
if success then
if vim.trim(output) == "" or output:match "No matches" then
vim.notify("No active tasks", vim.log.levels.WARN)
else
vim.cmd "new"
vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.split(output, "\n"))
vim.bo.buftype = "nofile"
vim.bo.bufhidden = "wipe"
vim.bo.modifiable = false
vim.wo.number = false
vim.wo.relativenumber = false
end
end
end, { desc = "Show active tasks" })
-- Project and context commands -- Project and context commands
vim.api.nvim_create_user_command("TaskProject", function(opts) vim.api.nvim_create_user_command("TaskProject", function(opts)
local project = opts.args local project = opts.args
if project == "" then if project == "" then
local output = vim.fn.system "task projects" local success, output = run_task_command("task projects", nil, "Error listing projects")
print(output) if success then
vim.notify(output, vim.log.levels.INFO)
end
else else
local output = vim.fn.system("task project:" .. project .. " list") local success, output = run_task_command("task project:" .. project .. " list", nil, "Error filtering by project")
vim.cmd "new" if success then
vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.split(output, "\n")) vim.cmd "new"
vim.bo.buftype = "nofile" vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.split(output, "\n"))
vim.bo.bufhidden = "wipe" vim.bo.buftype = "nofile"
vim.bo.modifiable = false vim.bo.bufhidden = "wipe"
vim.bo.modifiable = false
end
end end
end, { nargs = "?", desc = "Show projects or filter by project" }) end, { nargs = "?", desc = "Show projects or filter by project" })
@ -88,14 +199,15 @@ vim.keymap.set("v", "<leader>ta", function()
local end_pos = vim.fn.getpos "'>" local end_pos = vim.fn.getpos "'>"
local lines = vim.api.nvim_buf_get_lines(0, start_pos[2] - 1, end_pos[2], false) local lines = vim.api.nvim_buf_get_lines(0, start_pos[2] - 1, end_pos[2], false)
local selected_text = table.concat(lines, " "):gsub("%s+", " ") local selected_text = table.concat(lines, " "):gsub("%s+", " ")
vim.fn.system("task add " .. vim.fn.shellescape(selected_text)) if selected_text ~= "" then
print("Task added from selection: " .. selected_text) run_task_command("task add " .. selected_text, "Task added from selection", "Error adding task from selection")
end
end, { desc = "Add task from visual selection" }) end, { desc = "Add task from visual selection" })
-- Key mappings (using <leader>t prefix for taskwarrior) -- Key mappings (using <leader>t prefix for taskwarrior)
vim.keymap.set("n", "<leader>ta", ":TaskAdd<CR>", { desc = "Add task" }) vim.keymap.set("n", "<leader>ta", ":TaskAdd<CR>", { desc = "Add task" })
vim.keymap.set("n", "<leader>tl", ":TaskList<CR>", { desc = "List tasks" }) vim.keymap.set("n", "<leader>tl", ":TaskList<CR>", { desc = "List all tasks" })
vim.keymap.set("n", "<leader>tn", ":TaskNext<CR>", { desc = "Show next tasks" }) vim.keymap.set("n", "<leader>tn", ":TaskNext<CR>", { desc = "Show next 10 tasks" })
vim.keymap.set("n", "<leader>te", ":TaskEdit<CR>", { desc = "Edit task" }) vim.keymap.set("n", "<leader>te", ":TaskEdit<CR>", { desc = "Edit task" })
vim.keymap.set("n", "<leader>td", ":TaskDone<CR>", { desc = "Mark task done" }) vim.keymap.set("n", "<leader>td", ":TaskDone<CR>", { desc = "Mark task done" })
vim.keymap.set("n", "<leader>tm", ":TaskModify<CR>", { desc = "Modify task" }) vim.keymap.set("n", "<leader>tm", ":TaskModify<CR>", { desc = "Modify task" })
@ -108,50 +220,61 @@ vim.keymap.set("n", "<leader>tA", ":TaskActive<CR>", { desc = "Show active tasks
vim.keymap.set("n", "<leader>tH", function() vim.keymap.set("n", "<leader>tH", function()
local task_id = vim.fn.input "Task ID for high priority: " local task_id = vim.fn.input "Task ID for high priority: "
if task_id ~= "" then if task_id ~= "" then
vim.fn.system("task " .. task_id .. " modify priority:H") run_task_command(
print("Set task " .. task_id .. " to high priority") "task " .. task_id .. " modify priority:H",
"Set task " .. task_id .. " to high priority",
"Error setting priority"
)
end end
end, { desc = "Set task to high priority" }) end, { desc = "Set task to high priority" })
vim.keymap.set("n", "<leader>tu", function() vim.keymap.set("n", "<leader>tu", function()
local task_id = vim.fn.input "Task ID to add urgent tag: " local task_id = vim.fn.input "Task ID to add urgent tag: "
if task_id ~= "" then if task_id ~= "" then
vim.fn.system("task " .. task_id .. " modify +urgent") run_task_command(
print("Added urgent tag to task " .. task_id) "task " .. task_id .. " modify +urgent",
"Added urgent tag to task " .. task_id,
"Error adding urgent tag"
)
end end
end, { desc = "Add urgent tag to task" }) end, { desc = "Add urgent tag to task" })
-- Show task summary in statusline or floating window -- Show task summary in floating window
vim.api.nvim_create_user_command("TaskSummary", function() vim.api.nvim_create_user_command("TaskSummary", function()
local output = vim.fn.system "task summary" local success, output = run_task_command("task summary", nil, "Error getting task summary")
local lines = vim.split(output, "\n") if success then
local lines = vim.split(output, "\n")
-- Create floating window -- Create floating window
local width = 60 local width = 60
local height = #lines + 2 local height = math.min(#lines + 2, 20)
local row = math.floor((vim.o.lines - height) / 2) local row = math.floor((vim.o.lines - height) / 2)
local col = math.floor((vim.o.columns - width) / 2) local col = math.floor((vim.o.columns - width) / 2)
local buf = vim.api.nvim_create_buf(false, true) local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
local opts = { local opts = {
relative = "editor", relative = "editor",
width = width, width = width,
height = height, height = height,
row = row, row = row,
col = col, col = col,
style = "minimal", style = "minimal",
border = "rounded", border = "rounded",
title = " Task Summary ", title = " Task Summary ",
title_pos = "center", title_pos = "center",
} }
vim.api.nvim_open_win(buf, true, opts) vim.api.nvim_open_win(buf, true, opts)
vim.bo[buf].modifiable = false vim.bo[buf].modifiable = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = buf }) vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = buf })
end
end, { desc = "Show task summary in floating window" }) end, { desc = "Show task summary in floating window" })
vim.keymap.set("n", "<leader>ts", ":TaskSummary<CR>", { desc = "Show task summary" }) vim.keymap.set("n", "<leader>ts", ":TaskSummary<CR>", { desc = "Show task summary" })
print "Taskwarrior integration loaded! Use <leader>t* commands or :Task* commands" -- Use a timer to show the load message after everything initializes
vim.defer_fn(function()
vim.notify("Taskwarrior integration loaded! Use <leader>t* commands", vim.log.levels.INFO)
end, 100)