mirror of
https://github.com/Ascyii/typstar.git
synced 2025-12-31 21:14:25 -05:00
feat(draw): manually choose program to open file
This commit is contained in:
@@ -37,7 +37,8 @@ Note that you can [customize](#custom-snippets) (enable, disable and modify) eve
|
||||
create a new drawing using the [configured](#configuration) template,
|
||||
insert a figure displaying it and open it in Obsidian/Rnote.
|
||||
- To open an inserted drawing in Obsidian/Rnote,
|
||||
simply run `:TypstarOpenDrawing` while your cursor is on a line referencing the drawing.
|
||||
simply run `:TypstarOpenDrawing` (or `:TypstarOpenExcalidraw`/`:TypstarOpenRnote` if you are using the same file extension for both)
|
||||
while your cursor is on a line referencing the drawing.
|
||||
|
||||
### Anki
|
||||
Use the `flA` snippet to create a new flashcard
|
||||
|
||||
@@ -85,11 +85,8 @@ local rnote = {
|
||||
}
|
||||
local providers = { excalidraw, rnote }
|
||||
|
||||
function M.insert_obsidian_excalidraw() insert_drawing(excalidraw) end
|
||||
function M.insert_rnote() insert_drawing(rnote) end
|
||||
|
||||
function M.open_drawing()
|
||||
for _, provider in pairs(providers) do
|
||||
local open_drawing = function(prov)
|
||||
for _, provider in ipairs(prov) do
|
||||
local cfg = provider[1]
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
local filename = line:match('"(.*)' .. string.gsub(cfg.fileExtensionInserted, '%.', '%%%.'))
|
||||
@@ -102,4 +99,10 @@ function M.open_drawing()
|
||||
end
|
||||
end
|
||||
|
||||
function M.insert_obsidian_excalidraw() insert_drawing(excalidraw) end
|
||||
function M.insert_rnote() insert_drawing(rnote) end
|
||||
function M.open_obsidian_excalidraw() open_drawing({ excalidraw }) end
|
||||
function M.open_rnote() open_drawing({ rnote }) end
|
||||
function M.open_drawing() open_drawing(providers) end
|
||||
|
||||
return M
|
||||
|
||||
@@ -15,6 +15,8 @@ M.setup = function(args)
|
||||
|
||||
vim.api.nvim_create_user_command('TypstarInsertExcalidraw', drawings.insert_obsidian_excalidraw, {})
|
||||
vim.api.nvim_create_user_command('TypstarInsertRnote', drawings.insert_rnote, {})
|
||||
vim.api.nvim_create_user_command('TypstarOpenExcalidraw', drawings.open_obsidian_excalidraw, {})
|
||||
vim.api.nvim_create_user_command('TypstarOpenRnote', drawings.open_rnote, {})
|
||||
vim.api.nvim_create_user_command('TypstarOpenDrawing', drawings.open_drawing, {})
|
||||
|
||||
vim.api.nvim_create_user_command('TypstarAnkiScan', anki.scan, {})
|
||||
|
||||
Reference in New Issue
Block a user