mirror of
https://github.com/Ascyii/typstar.git
synced 2026-01-01 05:24:24 -05:00
33 lines
765 B
Lua
33 lines
765 B
Lua
local M = {}
|
|
local config = require('typstar.config')
|
|
local utils = require('typstar.utils')
|
|
|
|
local cfg = config.config.anki
|
|
|
|
|
|
local function run_typstar_anki(args)
|
|
local cwd = vim.fn.getcwd()
|
|
local anki_key = ''
|
|
if cfg.ankiKey ~= nil then
|
|
anki_key = ' --anki-key ' .. cfg.ankiKey
|
|
end
|
|
local cmd = string.format(
|
|
'%s --root-dir %s --typst-cmd %s --anki-url %s %s %s',
|
|
cfg.typstarAnkiCmd, cwd, cfg.typstCmd, cfg.ankiUrl, anki_key, args)
|
|
utils.run_shell_command(cmd, true)
|
|
end
|
|
|
|
function M.scan()
|
|
run_typstar_anki('')
|
|
end
|
|
|
|
function M.scan_force()
|
|
run_typstar_anki('--force-scan ' .. vim.fn.getcwd())
|
|
end
|
|
|
|
function M.scan_force_current()
|
|
run_typstar_anki('--force-scan ' .. vim.fn.expand('%:p'))
|
|
end
|
|
|
|
return M
|