From 9ed884fdac4324581adb26c2d21f9b1707ecac7d Mon Sep 17 00:00:00 2001 From: arne314 <73391160+arne314@users.noreply.github.com> Date: Sat, 14 Dec 2024 23:22:12 +0100 Subject: [PATCH] docs: add README --- README.md | 56 ++++++++++++++++++++++++++++++++++++++++++ lua/typstar/config.lua | 4 +-- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..1d70afc --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Typstar +Neovim plugin for efficient note taking in typst + +## Features +- Powerful autosnippets using [LuaSnip](https://github.com/L3MON4D3/LuaSnip/) and [Tree-sitter](https://tree-sitter.github.io/) (inspired by [fastex.nvim](https://github.com/lentilus/fastex.nvim)) +- Easy insertion of drawings using [Obsidian Excalidraw](https://github.com/zsviczian/obsidian-excalidraw-plugin) +- \[WIP\] Export of [Anki](https://apps.ankiweb.net/) flashcards + +## Usage + +### Snippets +Use `:TypstarToggleSnippets` to toggle all snippets at any time. +Available snippets can mostly be intuitively derived from [here](././lua/typstar/snippets), they include: + +- Alphanumeric characters: `:` → `$$ ` in markup (e.g. `:X` → `$X$ `, `:5` → `$5$ `) +- Greek letters: `;` → `` in math and `$$ ` in markup (e.g. `;a` → `alpha`/`$alpha$ `) +- Common indices (numbers and letters `i-m`): `` → `_` in math and `$$ ` → `$_$ ` in markup (e.g `A314` → `A_314`, `$alpha$n ` → `$alpha_n$ `) +- Wrapping of any mathematical expression (see [operations](./lua/typstar/snippets/visual.lua), works nested, multiline and in visual mode via the [selection key](#installation)): `` → `()` (e.g. `(a^2+b^2)rt` → `sqrt(a^2+b^2)`, `lambdatd` → `tilde(lambda)`, `(1+1)sQ` → `[1+1]`, `(1+1)sq` → `[(1+1)]`) +- Matrices: `ma` and `lma` (e.g. `23ma` → 2x3 matrix) +- [ctheorems shorthands](./lua/typstar/snippets/document.lua) (e.g. `tem` → empty theorem, `exa` → empty example) +- [Many shorthands](./lua/typstar/snippets/math.lua) for mathematical expressions + +Note that you can enable and disable collections of snippets in the [config](#configuration). + +### Excalidraw +Use `:TypstarInsertExcalidraw` to create a new drawing using the configured template, insert a figure displaying it and open it in Obsidian. +To open an inserted drawing in Obsidian, simply run `:TypstarOpenExcalidraw` while your cursor is on a line referencing the drawing. + +### Anki +WIP + +## Installation +Install the plugin in neovim and set the `typstarRoot` config or alternatively clone typstar into `~/typstar`. +```lua +require('typstar').setup({ + typstarRoot = '/path/to/typstar/repo' -- depending on your nvim plugin system +}) +``` + +### Snippets +1. Install [LuaSnip](https://github.com/L3MON4D3/LuaSnip/), set `enable_autosnippets = true` and set a visual mode selection key (e.g. `store_selection_keys = ''`) in the configuration +2. Install [jsregexp](https://github.com/kmarius/jsregexp) as described [here](https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#transformations) (running `:lua require('jsregexp')` in nvim should not result in an error) +3. Install [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) and run `:TSInstall typst` +4. Optional: Setup [ctheorems](https://typst.app/universe/package/ctheorems/) with names like [here](./lua/typstar/snippets/document.lua) + +### Excalidraw +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`) +3. Have the `xdg-open` command working or set a different command at `uriOpenCommand` in the [config](#configuration) + +### Anki +WIP + +## Configuration +Configuration options can be intuitively derived from the table [here](./lua/typstar/config.lua). + diff --git a/lua/typstar/config.lua b/lua/typstar/config.lua index 44fd604..3890c5d 100644 --- a/lua/typstar/config.lua +++ b/lua/typstar/config.lua @@ -7,12 +7,12 @@ local default_config = { filename = 'drawing-%Y-%m-%d-%H-%M-%S', fileExtension = '.excalidraw.md', fileExtensionInserted = '.excalidraw.svg', - uriOpenCommand = 'xdg-open', + uriOpenCommand = 'xdg-open', -- set depending on OS templatePath = nil, }, snippets = { enable = true, - modules = { + modules = { -- enable modules from ./snippets 'document', 'letters', 'math',