add support for memories to keep track of stuff like installing lua

This commit is contained in:
2026-06-01 17:26:22 +03:00
parent df5a87965e
commit d72fa0690a
3 changed files with 70 additions and 1 deletions

View File

@@ -5,6 +5,9 @@ enable_rebuild_indicator = true
[workspace]
paths = ["$HOME/projects", "$HOME/personal", "$HOME/Documents", "$HOME/"]
[memories]
path = "$HOME/personal/grimoire/memories/"
[system]
rpms_path = "$HOME/rpms"
packages = '''

View File

@@ -673,6 +673,70 @@ vim.api.nvim_create_autocmd({ 'VimEnter', 'BufWritePost' }, {
end,
})
----------------------------------------------------------------------------
-- NOTE: utility to create a new "k memory"
----------------------------------------------------------------------------
local function create_and_or_open_memory()
vim.ui.input({ prompt = 'Enter title: ' }, function(title)
if not title or title == '' then
return
end
local sanitized_title = title:gsub('%s+', '-')
local cmd = { 'k', 'memory', sanitized_title, '--output-path', '--edit=false', '--no-rebuild-self' }
local output_lines = {}
vim.notify('Memory command: ' .. vim.inspect(cmd))
vim.fn.jobstart(cmd, {
stdout_buffered = true,
stderr_buffered = true,
on_stdout = function(_, data)
if data then
for _, line in ipairs(data) do
if line ~= '' then
table.insert(output_lines, line)
end
end
end
end,
on_stderr = function(_, data)
if data then
for _, line in ipairs(data) do
if line ~= '' then
table.insert(output_lines, line)
end
end
end
end,
on_exit = function(_, exit_code)
if exit_code == 0 then
local target_file = output_lines[#output_lines]
vim.notify(vim.inspect(output_lines))
if target_file and target_file ~= '' then
-- Trim any trailing carriage returns or spaces
target_file = target_file:gsub('%s+$', '')
vim.schedule(function()
vim.cmd('edit ' .. vim.fn.fnameescape(target_file))
end)
else
vim.notify('Error: CLI succeeded but stdout was empty!', vim.log.levels.ERROR)
end
else
vim.api.nvim_err_writeln("Error: 'k memory' failed with exit code " .. exit_code)
end
end,
})
end)
end
-- 5. Create the Neovim user command (:MyCliCreate)
vim.api.nvim_create_user_command('KMemory', create_and_or_open_memory, {})
----------------------------------------------------------------------------
-- NOTE:
----------------------------------------------------------------------------

View File

@@ -183,5 +183,7 @@ vim.keymap.set('n', '<A-t>', test, { desc = '[T]est Project' })
vim.keymap.set('n', '<A-s>', function()
Run_nvim_lua()
vim.notify("Reloaded .nvim.lua")
vim.notify('Reloaded .nvim.lua')
end, { desc = '[S]ource .nvim.lua' })
vim.keymap.set('n', '<leader>cm', '<cmd>KMemory<cr>', { desc = '[C]reate [M]emory' })