feat: get plugin directory from lua debug

This commit is contained in:
arne314
2025-01-18 19:58:43 +01:00
parent 169714435e
commit 4ac566945e
2 changed files with 8 additions and 4 deletions

View File

@@ -72,10 +72,10 @@ To render the flashcard in your document as well add some code like this
## Installation ## Installation
Install the plugin in Neovim and set the `typstarRoot` config or alternatively clone typstar into `~/typstar`. Install the plugin in Neovim and run the plugin setup.
```lua ```lua
require('typstar').setup({ require('typstar').setup({ -- depending on your neovim plugin system
typstarRoot = '/path/to/typstar/repo' -- depending on your nvim plugin system -- your typstar config goes here
}) })
``` ```
@@ -89,6 +89,7 @@ require('typstar').setup({
1. Install [Obsidian](https://obsidian.md/) and create a vault in your typst note taking directory 1. Install [Obsidian](https://obsidian.md/) and create a vault in your typst note taking directory
2. Install the [obsidian-excalidraw-plugin](https://github.com/zsviczian/obsidian-excalidraw-plugin) and enable `Auto-export SVG` (in plugin settings at `Embedding Excalidraw into your Notes and Exporting > Export Settings > Auto-export Settings`) 2. Install the [obsidian-excalidraw-plugin](https://github.com/zsviczian/obsidian-excalidraw-plugin) and enable `Auto-export SVG` (in plugin settings at `Embedding Excalidraw into your Notes and Exporting > Export Settings > Auto-export Settings`)
3. Have the `xdg-open` command working or set a different command at `uriOpenCommand` in the [config](#configuration) 3. Have the `xdg-open` command working or set a different command at `uriOpenCommand` in the [config](#configuration)
4. If you encounter issues try cloning the repo into `~/typstar` or setting the `typstarRoot` config accordingly, feel free to open an issue
### Anki ### Anki
0. Typst version `0.12.0` or higher is required 0. Typst version `0.12.0` or higher is required

View File

@@ -1,7 +1,7 @@
local M = {} local M = {}
local default_config = { local default_config = {
typstarRoot = '~/typstar', typstarRoot = nil,
anki = { anki = {
typstarAnkiCmd = 'typstar-anki', typstarAnkiCmd = 'typstar-anki',
typstCmd = 'typst', typstCmd = 'typst',
@@ -30,6 +30,9 @@ local default_config = {
function M.merge_config(args) function M.merge_config(args)
M.config = vim.tbl_deep_extend('force', default_config, args or {}) M.config = vim.tbl_deep_extend('force', default_config, args or {})
M.config.typstarRoot = M.config.typstarRoot
or debug.getinfo(1).source:match('^@(.*)/lua/typstar/config%.lua$')
or '~/typstar'
M.config.excalidraw.templatePath = M.config.excalidraw.templatePath M.config.excalidraw.templatePath = M.config.excalidraw.templatePath
or { or {
['%.excalidraw%.md$'] = M.config.typstarRoot .. '/res/excalidraw_template.excalidraw.md', ['%.excalidraw%.md$'] = M.config.typstarRoot .. '/res/excalidraw_template.excalidraw.md',