fix: Updates to telekasten to use the built in toggle_todo function

instead of the custom one (works well enough), removing lazy loading of
the plugin to allow calling from telekasten commands from nvim load, and
adding ZSH functions to open a new note or today's note immediately.
This commit is contained in:
2026-04-02 06:23:43 -05:00
parent 30b85110ee
commit a519618e20
2 changed files with 29 additions and 24 deletions

View File

@@ -2,28 +2,28 @@ function string.insert(str1, str2, pos)
return str1:sub(1, pos) .. str2 .. str1:sub(pos + 1) return str1:sub(1, pos) .. str2 .. str1:sub(pos + 1)
end end
function toggleTODO(current_line) -- function ToggleTODO(current_line)
local todo_str = '%- %[ %] ' -- local todo_str = '%- %[ %] '
local todo_checked_str = '%- %[x%] ' -- local todo_checked_str = '%- %[x%] '
if current_line:find(todo_str, 1) then -- if current_line:find(todo_str, 1) then
return string.gsub(current_line, todo_str, '', 1) -- return string.gsub(current_line, todo_str, '', 1)
elseif current_line:find(todo_checked_str, 1) then -- elseif current_line:find(todo_checked_str, 1) then
return string.gsub(current_line, todo_checked_str, '', 1) -- return string.gsub(current_line, todo_checked_str, '', 1)
else -- else
local first_idx = current_line:find('[%-%w]', 1) - 1 -- local first_idx = current_line:find('[%-%w]', 1) - 1
return string.insert(current_line, '- [ ] ', first_idx) -- return string.insert(current_line, '- [ ] ', first_idx)
end -- end
end -- end
vim.api.nvim_create_user_command('ToggleTODO', function() -- vim.api.nvim_create_user_command('ToggleTODO', function()
local current_line = vim.api.nvim_get_current_line() -- local current_line = vim.api.nvim_get_current_line()
local row, _ = unpack(vim.api.nvim_win_get_cursor(0)) -- local row, _ = unpack(vim.api.nvim_win_get_cursor(0))
local new_line = toggleTODO(current_line) -- local new_line = ToggleTODO(current_line)
vim.api.nvim_buf_set_lines(0, row - 1, row, true, { new_line }) -- vim.api.nvim_buf_set_lines(0, row - 1, row, true, { new_line })
end, {}) -- end, {})
return { return {
'renerocksai/telekasten.nvim', 'renerocksai/telekasten.nvim',
@@ -49,10 +49,11 @@ return {
vim.api.nvim_set_hl(0, 'tkTag', { ctermfg = 'gray', fg = 'gray' }) vim.api.nvim_set_hl(0, 'tkTag', { ctermfg = 'gray', fg = 'gray' })
end, end,
keys = { keys = {
{ '<leader>tt', ':Telekasten toggle_todo<CR>' },
{ '<leader>zfn', ':Telekasten find_notes<CR>' },
{ '<leader>zft', ':Telekasten show_tags<CR>' },
{ '<leader>zn', ':Telekasten new_note<CR>' },
{ '<leader>zp', ':Telekasten panel<CR>' }, { '<leader>zp', ':Telekasten panel<CR>' },
{ '<leader>zn', ':Telekasten find_notes<CR>' },
{ '<leader>zt', ':Telekasten show_tags<CR>' },
{ '<leader>tt', ':ToggleTODO<CR>' },
}, },
-- lazy = false lazy = false
} }

View File

@@ -17,8 +17,12 @@ function rmv() {
find ./* -depth -type d -empty -exec rmdir "{}" \; find ./* -depth -type d -empty -exec rmdir "{}" \;
} }
function new_note() { function note() {
nvim nvim -c ":Telekasten new_note"
}
function today() {
nvim -c ":Telekasten goto_today"
} }
function path() { function path() {