nvchad/lua/mappings.lua
Paul Trowbridge 544da2dadc add td time-tracking module and keymaps
lua/td.lua wraps the `td` CLI (from setup_env dotfiles/bin/td) and
adds auto-tid generation: <leader>ts on a todo line appends
^tid-YYYYMMDD-HHMMSS, writes the buffer, then starts the timer.
<leader>tp stops, <leader>tr shows a floating-window report.
Also exposes :TdStart/:TdStop/:TdReport user commands.

Vault root is detected by walking up from the buffer file looking
for time.csv or .obsidian/, so the CSV is written at the vault
root regardless of the buffer's depth.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 21:01:41 -04:00

76 lines
3.3 KiB
Lua

require "nvchad.mappings"
-- add yours here
local map = vim.keymap.set
map("n", ";", ":", { desc = "CMD enter command mode" })
map("i", "jk", "<ESC>")
-- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>")
-- local custom_telescope = require('custom_telescope')
-- Add a keybinding for searching Markdown tasks
vim.api.nvim_set_keymap('n', '<leader>mt', ':lua require("custom_telescope").search_markdown_tasks()<CR>', { noremap = true, silent = true })
-- Add a keybinding for calling ObsidianTag
vim.api.nvim_set_keymap('n', '<leader>tt', ':ObsidianTag<CR>', { noremap = true, silent = true })
-- Add a keybinding for calling ObsidianBacklinks
vim.api.nvim_set_keymap('n', '<leader>lb', ':ObsidianBacklinks<CR>', { noremap = true, silent = true })
-- Add a keybinding for calling ObsidianLink
vim.api.nvim_set_keymap('v', '<leader>fl', ':ObsidianLink<CR>', { noremap = true, silent = true })
-- priority task
vim.api.nvim_set_keymap("n", "<leader>p1", "A 🔼<Esc>", { noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "<leader>p2", "A ⏫<Esc>", { noremap = true, silent = true })
-- Live grep all files (including gitignored and hidden files)
vim.keymap.set("n", "<leader>fW", function()
require('telescope.builtin').live_grep({
additional_args = function()
return { "--hidden", "--no-ignore" }
end
})
end, { desc = "telescope live grep all files" })
-- make leader-e toggle the tree view as opposed to just setting focus
vim.api.nvim_set_keymap('n', '<leader>e', ':NvimTreeToggle<CR>', {noremap = true, silent = true})
-- move the whole page without moving the cursor
vim.api.nvim_set_keymap('n', 'J', '<C-e>', { noremap = true })
vim.keymap.set('n', '<leader>j', 'J', { remap = false, desc = "Join lines" })
vim.api.nvim_set_keymap('n', 'K', '<C-y>', { noremap = true })
-- Resize windows
vim.api.nvim_set_keymap('n', '<Up>', '5<C-w>+', { silent = true })
vim.api.nvim_set_keymap('n', '<Down>', '5<C-w>-', { silent = true })
vim.api.nvim_set_keymap('n', '<Right>', '10<C-w>>', { silent = true })
vim.api.nvim_set_keymap('n', '<Left>', '10<C-w><', { silent = true })
-- wrap selected text in single quotes
vim.keymap.set('x', "<leader>'", function()
local text = vim.fn.getreg('"') -- Get the visually selected text
vim.cmd("normal! c'" .. text .. "'")
end, { desc = "Wrap selected text in single quotes" })
-- wrap selected text in double quotes
vim.keymap.set('x', '<leader>"', function()
local text = vim.fn.getreg('"') -- Get the visually selected text
vim.cmd('normal! c"' .. text .. '"')
end, { desc = "Wrap selected text in double quotes" })
-- Gitsigns blame current line
vim.keymap.set("n", "<leader>gb", ":Gitsigns blame_line<CR>", { noremap = true, silent = true, desc = "Git blame line" })
-- Disable alt+h and alt+v terminal toggles
vim.keymap.del({ "n", "t" }, "<A-h>")
vim.keymap.del({ "n", "t" }, "<A-v>")
-- td: time-track markdown todos (see ~/.local/bin/td and ~/.config/nvim/lua/td.lua)
local td = require("td")
vim.api.nvim_create_user_command("TdStart", td.start, {})
vim.api.nvim_create_user_command("TdStop", td.stop, {})
vim.api.nvim_create_user_command("TdReport", td.report, {})
vim.keymap.set("n", "<leader>ts", td.start, { desc = "td: start timer on current task" })
vim.keymap.set("n", "<leader>tp", td.stop, { desc = "td: stop (pause) timer" })
vim.keymap.set("n", "<leader>tr", td.report, { desc = "td: report floating window" })