fix(anki): reload nvim buffer on anki id update

This commit is contained in:
arne314
2025-03-19 13:10:44 +01:00
parent 69a3ec4757
commit ca3fcec66c
2 changed files with 7 additions and 2 deletions

View File

@@ -17,7 +17,10 @@ local function run_typstar_anki(args)
anki_key, anki_key,
args args
) )
utils.run_shell_command(cmd, true) local handle_output = function(msg)
if string.match(msg, 'Done') then vim.cmd('checktime') end
end
utils.run_shell_command(cmd, true, handle_output)
end end
function M.scan() run_typstar_anki('') end function M.scan() run_typstar_anki('') end

View File

@@ -26,10 +26,12 @@ function M.insert_text_block(snip)
vim.api.nvim_buf_set_lines(vim.api.nvim_get_current_buf(), line_num, line_num, false, lines) vim.api.nvim_buf_set_lines(vim.api.nvim_get_current_buf(), line_num, line_num, false, lines)
end end
function M.run_shell_command(cmd, show_output) function M.run_shell_command(cmd, show_output, extra_handler)
extra_handler = extra_handler or function(msg) end
local handle_output = function(data, err) local handle_output = function(data, err)
local msg = table.concat(data, '\n') local msg = table.concat(data, '\n')
if not string.match(msg, '^%s*$') then if not string.match(msg, '^%s*$') then
extra_handler(msg)
local level = err and vim.log.levels.ERROR or vim.log.levels.INFO local level = err and vim.log.levels.ERROR or vim.log.levels.INFO
vim.notify(msg, level) vim.notify(msg, level)
end end