mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 18:28:02 +00:00
feat: convert editor READMEs to docs.typ (#498)
This commit is contained in:
parent
11f9965c48
commit
c4c3d6f3fa
13 changed files with 436 additions and 56 deletions
|
@ -139,7 +139,7 @@ impl TypliteWorker {
|
|||
LeftParen => Self::char('('),
|
||||
RightParen => Self::char(')'),
|
||||
Comma => Self::char(','),
|
||||
Semicolon => Self::char(';'),
|
||||
Semicolon => Ok(Value::None),
|
||||
Colon => Self::char(':'),
|
||||
Star => Self::char('*'),
|
||||
Underscore => Self::char('_'),
|
||||
|
@ -370,8 +370,8 @@ impl TypliteWorker {
|
|||
Ok(Value::Content(s))
|
||||
}
|
||||
|
||||
fn label(node: &SyntaxNode) -> Result<Value> {
|
||||
Self::str(node)
|
||||
fn label(_node: &SyntaxNode) -> Result<Value> {
|
||||
Result::Ok(Value::None)
|
||||
}
|
||||
|
||||
fn label_ref(node: &SyntaxNode) -> Result<Value> {
|
||||
|
|
|
@ -69,7 +69,7 @@ pub fn cross_link(mut args: Args) -> Result<Value> {
|
|||
|
||||
/// Evaluate a markdown alteration.
|
||||
pub fn md_alter(mut args: Args) -> Result<Value> {
|
||||
let _left = get_pos_named!(args, left: Content);
|
||||
let _: () = get_pos_named!(args, left: ());
|
||||
let right = get_pos_named!(args, right: LazyContent);
|
||||
|
||||
Ok(Value::Content(right.0))
|
||||
|
|
|
@ -136,6 +136,12 @@ pub trait Eval<'a>: Sized {
|
|||
fn eval(node: &'a SyntaxNode, vm: &mut TypliteWorker) -> Result<Self>;
|
||||
}
|
||||
|
||||
impl<'a> Eval<'a> for () {
|
||||
fn eval(_node: &'a SyntaxNode, _vm: &mut TypliteWorker) -> Result<Self> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Eval<'a> for &'a SyntaxNode {
|
||||
fn eval(node: &'a SyntaxNode, _vm: &mut TypliteWorker) -> Result<Self> {
|
||||
Ok(node)
|
||||
|
|
|
@ -14,7 +14,7 @@ Language service (LSP) features:
|
|||
- (Todo) Highlight all captures in a closure context.
|
||||
- (Todo) Highlight all occurrences of a symbol in a document.
|
||||
- #link("https://code.visualstudio.com/docs/getstarted/userinterface#_outline-view")[Document symbols]
|
||||
- Also known as "document outline" or "table of contents" **in Typst**.
|
||||
- Also known as "document outline" or "table of contents" *in Typst*.
|
||||
- #link("https://burkeholland.gitbook.io/vs-code-can-do-that/exercise-3-navigation-and-refactoring/folding-sections")[Folding ranges]
|
||||
- You can collapse code/content blocks and headings.
|
||||
- #link("https://code.visualstudio.com/api/language-extensions/programmatic-language-features#show-definitions-of-a-symbol")[Goto definitions]
|
||||
|
|
|
@ -1,5 +1,71 @@
|
|||
#import "mod.typ": *
|
||||
#import "/docs/tinymist/frontend/mod.typ": *
|
||||
|
||||
#show: book-page.with(title: "Tinymist Helix Extension")
|
||||
|
||||
#link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/helix")[Helix]
|
||||
Run and configure tinymist in helix for Typst.
|
||||
|
||||
== Features
|
||||
<features>
|
||||
See #link("https://github.com/Myriad-Dreamin/tinymist#features")[Tinymist Features] for a list of features.
|
||||
|
||||
== Finding Executable
|
||||
<finding-executable>
|
||||
To enable LSP, you must install `tinymist`. You can find `tinymist` on:
|
||||
|
||||
- Night versions available at #link("https://github.com/Myriad-Dreamin/tinymist/actions")[GitHub Actions];.
|
||||
- Stable versions available at #link("https://github.com/Myriad-Dreamin/tinymist/releases")[GitHub Releases];.
|
||||
|
||||
You can also compile and install *latest* `tinymist` by #link("https://www.rust-lang.org/tools/install")[Cargo];.
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist
|
||||
```
|
||||
|
||||
== Setup Server
|
||||
<setup-server>
|
||||
Update `.config/helix/languages.toml` to use tinymist.
|
||||
|
||||
```toml
|
||||
[language-server.tinymist]
|
||||
command = "tinymist"
|
||||
|
||||
[[language]]
|
||||
name = "typst"
|
||||
language-servers = ["tinymist"]
|
||||
```
|
||||
|
||||
== Tips
|
||||
<tips>
|
||||
=== Working with Multiple-File Projects
|
||||
<working-with-multiple-file-projects>
|
||||
There is a way in #link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/README.md#multiple-file-project-support")[Neovim];, but you cannot invoke related commands with arguments by #link("https://docs.helix-editor.com/commands.html")[:lsp-workspace-command] in helix. As a candidate solution, assuming your having following directory layout:
|
||||
|
||||
```plain
|
||||
├── .helix
|
||||
│ └── languages.toml
|
||||
└── main.typ
|
||||
```
|
||||
|
||||
You could create .helix/languages.toml in the project folder with the following contents:
|
||||
|
||||
```toml
|
||||
[language-server.tinymist.config]
|
||||
typstExtraArgs = ["main.typ"]
|
||||
```
|
||||
|
||||
Then all diagnostics and autocompletion will be computed according to the `main.typ`.
|
||||
|
||||
Note: With that configuration, if you’re seeing a file that is not reachable by `main.typ`, you will not get diagnostics and autocompletion correctly in that file.
|
||||
|
||||
== Extra Settings
|
||||
<extra-settings>
|
||||
To configure LSP server, you can edit the `language-server.tinymist` section. For example, if you want to export PDF on typing and output files in `$root_dir/target` directory:
|
||||
|
||||
```toml
|
||||
[language-server.tinymist]
|
||||
command = "tinymist"
|
||||
config = { exportPdf = "onType", outputPath = "$root/target/$dir/$name" }
|
||||
```
|
||||
|
||||
See #link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/Configuration.md")[Tinymist Server Configuration]
|
||||
for references.
|
||||
|
|
|
@ -1,5 +1,126 @@
|
|||
#import "mod.typ": *
|
||||
#import "/docs/tinymist/frontend/mod.typ": *
|
||||
|
||||
#show: book-page.with(title: "Tinymist Neovim Extension")
|
||||
|
||||
#link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim")[Neovim]
|
||||
Run and configure tinymist in neovim for Typst.
|
||||
|
||||
== Features
|
||||
<features>
|
||||
See #link("https://github.com/Myriad-Dreamin/tinymist#features")[Tinymist Features] for a list of features.
|
||||
|
||||
== Finding Executable
|
||||
<finding-executable>
|
||||
To enable LSP, you must install `tinymist`. You can find `tinymist` on:
|
||||
|
||||
- Night versions available at #link("https://github.com/Myriad-Dreamin/tinymist/actions")[GitHub Actions];.
|
||||
|
||||
- Stable versions available with #link("https://github.com/williamboman/mason.nvim")[mason.nvim];.
|
||||
|
||||
```lua
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"tinymist",
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
- Stable versions available at #link("https://github.com/Myriad-Dreamin/tinymist/releases")[GitHub Releases];.
|
||||
|
||||
You can also compile and install *latest* `tinymist` by #link("https://www.rust-lang.org/tools/install")[Cargo];.
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist
|
||||
```
|
||||
|
||||
== Minimal Setup: LazyVim as an Example
|
||||
<minimal-setup-lazyvim-as-an-example>
|
||||
This section shows you a minimal way to setup tinymist in Neovim (LazyVim).
|
||||
|
||||
+ Copy or merge the #link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/config/autocmds.lua")[Autocmds file] and #link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/plugins/tinymist.lua")[Plugin file] to corresponding paths into `~/.config/nvim/`.
|
||||
|
||||
+ Check and restart Neovim.
|
||||
|
||||
// todo: heading link support
|
||||
Please see #md-alter(link(<extra-settings>)[Extra Settings], () => link("#extra-settings")[Extra Settings]) for more configuration.
|
||||
|
||||
== Tips
|
||||
<tips>
|
||||
=== Working with Multiple-File Projects
|
||||
<working-with-multiple-file-projects>
|
||||
The solution is a bit internal, which should get further improvement, but you can pin a main file by command.
|
||||
|
||||
```lua
|
||||
-- pin the main file
|
||||
vim.lsp.buf.execute_command({ command = 'tinymist.pinMain', arguments = { vim.api.nvim_buf_get_name(0) } })
|
||||
-- unpin the main file
|
||||
vim.lsp.buf.execute_command({ command = 'tinymist.pinMain', arguments = { nil } })
|
||||
```
|
||||
|
||||
There is also a plan to support multiple-file project by workspace configuration, but I don’t know what is neovim’s way, so it needs further discussion.
|
||||
|
||||
== Troubleshooting
|
||||
<troubleshooting>
|
||||
=== tinymist does not start on creating/opening files
|
||||
<tinymist-does-not-start-on-creatingopening-files>
|
||||
First, please check that tinymist can start with manual file association.
|
||||
|
||||
```
|
||||
:set filetype=typst
|
||||
```
|
||||
|
||||
If tinymist starts, that means you have not made correct file association. If not, there should be some errors in your lspconfig.
|
||||
|
||||
Please associate `.typ` file extension to `typst` filetype to start tinymist on creating/opening file events.
|
||||
|
||||
```shell
|
||||
autocmd BufNewFile,BufRead *.typ setfiletype typst
|
||||
```
|
||||
|
||||
== Extra Settings
|
||||
<extra-settings>
|
||||
=== Configuring LSP Server
|
||||
<configuring-lsp-server>
|
||||
To configure LSP server, you can edit the `opts.servers.tinymist.settings`. For example, if you want to export PDF on typing and output files in `$root_dir/target` directory:
|
||||
|
||||
```lua
|
||||
return {
|
||||
-- add tinymist to lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
tinymist = {
|
||||
settings = {
|
||||
exportPdf = "onType",
|
||||
outputPath = "$root/target/$dir/$name",
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
See #link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/Configuration.md")[Tinymist Server Configuration] for references.
|
||||
|
||||
=== Configuring Folding Range for Neovim Client
|
||||
<configuring-folding-range-for-neovim-client>
|
||||
Enable LSP-based folding range with `kevinhwang91/nvim-ufo`:
|
||||
|
||||
```lua
|
||||
return {
|
||||
{ -- configure LSP servers
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = "kevinhwang91/nvim-ufo", -- enable LSP-based folds
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
You can copy or merge #link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/plugins/lsp-folding.lua")[lsp-folding.lua] to corresponding paths into `~/.config/nvim/` and restart Neovim.
|
||||
|
||||
== Contributing
|
||||
<contributing>
|
||||
You can submit issues or make PRs to #link("https://github.com/Myriad-Dreamin/tinymist")[GitHub];.
|
||||
|
|
|
@ -1,5 +1,169 @@
|
|||
#import "mod.typ": *
|
||||
#import "/docs/tinymist/frontend/mod.typ": *
|
||||
|
||||
#show: book-page.with(title: "Tinymist VS Code Extension")
|
||||
|
||||
#link("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/vscode")[VS Code]
|
||||
A VS Code or VS Codium extension for Typst. You can find the extension on:
|
||||
|
||||
- Night versions available at #link("https://github.com/Myriad-Dreamin/tinymist/actions")[GitHub Actions];.
|
||||
- Stable versions available at #link("https://marketplace.visualstudio.com/items?itemName=myriad-dreamin.tinymist")[Visual Studio Marketplace];.
|
||||
- Stable versions available at #link("https://open-vsx.org/extension/myriad-dreamin/tinymist")[Open VSX];.
|
||||
|
||||
== Features
|
||||
<features>
|
||||
See #link("https://github.com/Myriad-Dreamin/tinymist#features")[Tinymist Features] for a list of features.
|
||||
|
||||
== Usage Tips
|
||||
<usage-tips>
|
||||
=== Initializing with a Template
|
||||
<initializing-with-a-template>
|
||||
To initialize a Typst project:
|
||||
- Use command `Typst init template` (tinymist.initTemplate) to initialize a new Typst project based on a template.
|
||||
- Use command `Typst show template` (tinymist.showTemplateGallery) to show available Typst templates for picking up a template to initialize.
|
||||
|
||||
|
||||
🎉 If your template contains only a single file, you can also insert the template content in place with command:
|
||||
- Use command `Typst template in place` (tinymist.initTemplateInPlace) and input a template specifier for initialization.
|
||||
|
||||
=== Configuring LSP-enhanced formatters
|
||||
<configuring-lsp-enhanced-formatters>
|
||||
+ Open settings.
|
||||
+ Search for "Tinymist Formatter" and modify the value.
|
||||
- Use `"formatterMode": "typstyle"` for #link("https://github.com/Enter-tainer/typstyle")[typstyle];.
|
||||
- Use `"formatterMode": "typstfmt"` for #link("https://github.com/astrale-sharp/typstfmt")[typstfmt];.
|
||||
|
||||
Tips: to enable formatting on save, you should add extra settings for typst language:
|
||||
|
||||
```json
|
||||
{
|
||||
"[typst]": {
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
=== Configuring/Using Tinymist’s Activity Bar (Sidebar)
|
||||
<configuringusing-tinymists-activity-bar-sidebar>
|
||||
If you don’t like the activity bar, you can right-click on the activity bar and uncheck "Tinymist" to hide it.
|
||||
|
||||
==== Symbol View
|
||||
<symbol-view>
|
||||
- Search symbols by keywords, descriptions, or handwriting.
|
||||
- See symbols grouped by categories.
|
||||
- Click on a symbol, then it will be inserted into the editor.
|
||||
|
||||
==== Preview Command
|
||||
<preview-command>
|
||||
Open command palette (Ctrl+Shift+P), and type `>Typst Preview:`.
|
||||
|
||||
You can also use the shortcut (Ctrl+K V).
|
||||
|
||||
==== Theme-aware template (previewing)
|
||||
<theme-aware-template-previewing>
|
||||
In short, there is a `sys.inputs` item added to the compiler when your document is under the context of _user editing or previewing task_. You can use it to configure your template:
|
||||
|
||||
```typ
|
||||
#let preview-args = json.decode(sys.inputs.at("x-preview", default: "{}"))
|
||||
// One is previewing the document.
|
||||
#let is-preview = sys.inputs.has("x-preview")
|
||||
// `dark` or `light`
|
||||
#let preview-theme = preview-args.at("theme", default: "light")
|
||||
```
|
||||
|
||||
For details, please check #link("https://myriad-dreamin.github.io/tinymist/feature/preview.html#label-sys.inputs")[Preview’s sys.inputs];.
|
||||
|
||||
=== Configuring path to search fonts
|
||||
<configuring-path-to-search-fonts>
|
||||
To configure path to search fonts:
|
||||
+ Open settings.
|
||||
- File -\> Preferences -\> Settings (Linux, Windows).
|
||||
- Code -\> Preferences -\> Settings (Mac).
|
||||
+ Search for "Tinymist Font Paths" for providing paths to search fonts order-by-order.
|
||||
+ Search for "Tinymist No System Fonts" for disabling system fonts to be searched, which is useful for reproducible rendering your PDF documents.
|
||||
+ Reload the window or restart the vscode editor to make the settings take effect.
|
||||
|
||||
|
||||
*Note:* you must provide absolute paths.
|
||||
*Note:* you can use vscode variables in the settings, see #link("https://www.npmjs.com/package/vscode-variables")[vscode-variables] for more information.
|
||||
|
||||
=== Configuring path to root directory
|
||||
<configuring-path-to-root-directory>
|
||||
To configure the root path resolved for Typst compiler:
|
||||
+ Open settings.
|
||||
+ Search for "Tinymist Root Path" and modify the value.
|
||||
+ Reload the window or restart the vscode editor to make the settings take effect. *Note:* you must provide absolute paths.
|
||||
|
||||
=== Compiling PDF
|
||||
<compiling-pdf>
|
||||
This extension compiles to PDF, but it doesn’t have a PDF viewer yet. To view the output as you work, install a PDF viewer extension, such as `vscode-pdf`.
|
||||
|
||||
To find a way to compile PDF:
|
||||
- Click the code len `Export PDF` at the top of document, or use command `Typst Show PDF ...`, to show the current document to PDF.
|
||||
- Use command `Typst Export PDF` to export the current document to PDF.
|
||||
- There are code lens buttons at the start of the document to export your document to PDF or other formats.
|
||||
|
||||
To configure when PDFs are compiled:
|
||||
+ Open settings.
|
||||
+ Search for "Tinymist Export PDF".
|
||||
+ Change the "Export PDF" setting.
|
||||
- `onSave` makes a PDF after saving the Typst file.
|
||||
- `onType` makes PDF files live, as you type.
|
||||
- `never` disables PDF compilation.
|
||||
- `onDocumentHasTitle` makes a PDF when the document has a title and, as you save.
|
||||
|
||||
To configure where PDFs are saved:
|
||||
|
||||
+ Open settings.
|
||||
+ Search for "Tinymist Output Path".
|
||||
+ Change the "Output Path" setting. This is the path pattern to store
|
||||
artifacts, you can use `$root` or `$dir` or `$name` to do magic
|
||||
configuration
|
||||
- e.g. `$root/$dir/$name` (default) for `$root/path/to/main.pdf`.
|
||||
- e.g. `$root/target/$dir/$name` for `$root/target/path/to/main.pdf`.
|
||||
- e.g. `$root/target/foo` for `$root/target/foo.pdf`. This will ensure
|
||||
that the output is always output to `target/foo.pdf`.
|
||||
|
||||
*Note:* the output path should be substituted as an absolute path.
|
||||
|
||||
=== Exporting to Other Formats
|
||||
<exporting-to-other-formats>
|
||||
You can export your documents to various other formats by lsp as well.
|
||||
Currently, the following formats are supported:
|
||||
- Official svg, png, and pdf.
|
||||
- Unofficial html, md (typlite), and txt
|
||||
- Query Results (into json, yaml, or txt), and pdfpc (by `typst query --selector <pdfpc-file>`, for #link("https://touying-typ.github.io/touying/")[Touying];)
|
||||
|
||||
See
|
||||
#link("https://myriad-dreamin.github.io/tinymist/feature/export.html")[Docs: Exporting Documents]
|
||||
for more information.
|
||||
|
||||
=== Working with Multiple-File Projects
|
||||
<working-with-multiple-file-projects>
|
||||
You can pin a main file by command.
|
||||
- Use command `Typst Pin Main` (tinymist.pinMainToCurrent) to set the current file as the main file.
|
||||
- Use command `Typst Unpin Main` (tinymist.unpinMain) to unset the main file.
|
||||
|
||||
=== Passing Extra CLI Arguments
|
||||
<passing-extra-cli-arguments>
|
||||
There is a *global* configuration `tinymist.typstExtraArgs` to pass extra arguments to tinymist LSP, like what you usually do with `typst-cli` CLI. For example, you can set it to `["--input=awa=1", "--input=abaaba=2", "main.typ"]` to configure `sys.inputs` and entry for compiler, which is equivalent to make LSP run like a `typst-cli` with such arguments:
|
||||
|
||||
```
|
||||
typst watch --input=awa=1 --input=abaaba=2 main.typ
|
||||
```
|
||||
|
||||
Supported arguments:
|
||||
- entry file: The last string in the array will be treated as the entry file.
|
||||
- This is used to specify the *default* entry file for the compiler, which may be overridden by other settings.
|
||||
- `--input`: Add a string key-value pair visible through `sys.inputs`.
|
||||
- `--font-path` (environment variable: `TYPST_FONT_PATHS`), Font paths, maybe overriden by `tinymist.fontPaths`.
|
||||
- `--ignore-system-fonts`: Ensures system fonts won’t be searched, maybe overriden by `tinymist.systemFonts`.
|
||||
- `--creation-timestamp` (environment variable: `SOURCE_DATE_EPOCH`): The document’s creation date formatted as a #link("https://reproducible-builds.org/specs/source-date-epoch/")[UNIX timestamp];.
|
||||
|
||||
*Note:* Fix entry to `main.typ` may help multiple-file projects
|
||||
but you may loss diagnostics and autocompletions in unrelated files.
|
||||
|
||||
*Note:* the arguments has quite low priority, and that may be overridden
|
||||
by other settings.
|
||||
|
||||
== Contributing
|
||||
<contributing>
|
||||
You can submit issues or make PRs to #link("https://github.com/Myriad-Dreamin/tinymist")[GitHub];.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import "mod.typ": *
|
||||
#import "/docs/tinymist/frontend/mod.typ": *
|
||||
|
||||
#show: book-page.with(title: "Tinymist Neovim Extension")
|
||||
#show: book-page.with(title: "Tinymist Zed Extension")
|
||||
|
||||
See #link("https://github.com/WeetHet/typst.zed")[typst.zed];.
|
||||
|
||||
#link("https://github.com/WeetHet/typst.zed")[Zed]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by scripts/link-docs.mjs from docs/tinymist/frontend/helix.typ. Do not edit manually. -->
|
||||
# Tinymist Helix Support for Typst
|
||||
|
||||
Run and configure tinymist in helix for Typst.
|
||||
|
@ -16,7 +17,7 @@ To enable LSP, you must install `tinymist`. You can find `tinymist` on:
|
|||
You can also compile and install **latest** `tinymist` by [Cargo](https://www.rust-lang.org/tools/install).
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked
|
||||
cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist
|
||||
```
|
||||
|
||||
## Setup Server
|
||||
|
@ -36,7 +37,7 @@ language-servers = ["tinymist"]
|
|||
|
||||
### Working with Multiple-File Projects
|
||||
|
||||
There is a way in [Neovim](../neovim/README.md#multiple-file-project-support), but you cannot invoke related commands with arguments by [:lsp-workspace-command](https://docs.helix-editor.com/commands.html) in helix. As a candidate solution, assuming your having following directory layout:
|
||||
There is a way in [Neovim](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/README.md#multiple-file-project-support), but you cannot invoke related commands with arguments by [:lsp-workspace-command](https://docs.helix-editor.com/commands.html) in helix. As a candidate solution, assuming your having following directory layout:
|
||||
|
||||
```plain
|
||||
├── .helix
|
||||
|
@ -44,7 +45,6 @@ There is a way in [Neovim](../neovim/README.md#multiple-file-project-support), b
|
|||
└── main.typ
|
||||
```
|
||||
|
||||
|
||||
You could create .helix/languages.toml in the project folder with the following contents:
|
||||
|
||||
```toml
|
||||
|
@ -54,7 +54,7 @@ typstExtraArgs = ["main.typ"]
|
|||
|
||||
Then all diagnostics and autocompletion will be computed according to the `main.typ`.
|
||||
|
||||
Note: With that configuration, if you're seeing a file that is not reachable by `main.typ`, you will not get diagnostics and autocompletion correctly in that file.
|
||||
Note: With that configuration, if you’re seeing a file that is not reachable by `main.typ`, you will not get diagnostics and autocompletion correctly in that file.
|
||||
|
||||
## Extra Settings
|
||||
|
||||
|
@ -66,4 +66,5 @@ command = "tinymist"
|
|||
config = { exportPdf = "onType", outputPath = "$root/target/$dir/$name" }
|
||||
```
|
||||
|
||||
See [Tinymist Server Configuration](../neovim/Configuration.md) for references.
|
||||
See [Tinymist Server Configuration](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/Configuration.md)
|
||||
for references.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by scripts/link-docs.mjs from docs/tinymist/frontend/neovim.typ. Do not edit manually. -->
|
||||
# Tinymist Neovim Support for Typst
|
||||
|
||||
Run and configure tinymist in neovim for Typst.
|
||||
|
@ -11,6 +12,7 @@ See [Tinymist Features](https://github.com/Myriad-Dreamin/tinymist#features) for
|
|||
To enable LSP, you must install `tinymist`. You can find `tinymist` on:
|
||||
|
||||
- Night versions available at [GitHub Actions](https://github.com/Myriad-Dreamin/tinymist/actions).
|
||||
|
||||
- Stable versions available with [mason.nvim](https://github.com/williamboman/mason.nvim).
|
||||
|
||||
```lua
|
||||
|
@ -29,16 +31,17 @@ To enable LSP, you must install `tinymist`. You can find `tinymist` on:
|
|||
You can also compile and install **latest** `tinymist` by [Cargo](https://www.rust-lang.org/tools/install).
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked
|
||||
cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist
|
||||
```
|
||||
|
||||
## Minimal Setup: LazyVim as an Example
|
||||
|
||||
This section shows you a minimal way to setup tinymist in Neovim (LazyVim).
|
||||
|
||||
1. Copy or merge the [Autocmds file](./config/autocmds.lua) and [Plugin file](./plugins/tinymist.lua) to corresponding paths into `~/.config/nvim/`.
|
||||
1. Copy or merge the [Autocmds file](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/config/autocmds.lua) and [Plugin file](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/plugins/tinymist.lua) to corresponding paths into `~/.config/nvim/`.
|
||||
|
||||
1. Check and restart Neovim.
|
||||
|
||||
2. Check and restart Neovim.
|
||||
|
||||
Please see [Extra Settings](#extra-settings) for more configuration.
|
||||
|
||||
|
@ -49,13 +52,13 @@ Please see [Extra Settings](#extra-settings) for more configuration.
|
|||
The solution is a bit internal, which should get further improvement, but you can pin a main file by command.
|
||||
|
||||
```lua
|
||||
# pin the main file
|
||||
-- pin the main file
|
||||
vim.lsp.buf.execute_command({ command = 'tinymist.pinMain', arguments = { vim.api.nvim_buf_get_name(0) } })
|
||||
# unpin the main file
|
||||
-- unpin the main file
|
||||
vim.lsp.buf.execute_command({ command = 'tinymist.pinMain', arguments = { nil } })
|
||||
```
|
||||
|
||||
There is also a plan to support multiple-file project by workspace configuration, but I don't know what is neovim's way, so it needs further discussion.
|
||||
There is also a plan to support multiple-file project by workspace configuration, but I don’t know what is neovim’s way, so it needs further discussion.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
@ -71,7 +74,7 @@ If tinymist starts, that means you have not made correct file association. If no
|
|||
|
||||
Please associate `.typ` file extension to `typst` filetype to start tinymist on creating/opening file events.
|
||||
|
||||
```
|
||||
```shell
|
||||
autocmd BufNewFile,BufRead *.typ setfiletype typst
|
||||
```
|
||||
|
||||
|
@ -100,7 +103,7 @@ return {
|
|||
}
|
||||
```
|
||||
|
||||
See [Tinymist Server Configuration](./Configuration.md) for references.
|
||||
See [Tinymist Server Configuration](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/Configuration.md) for references.
|
||||
|
||||
### Configuring Folding Range for Neovim Client
|
||||
|
||||
|
@ -115,7 +118,7 @@ return {
|
|||
}
|
||||
```
|
||||
|
||||
You can copy or merge [lsp-folding.lua](./plugins/lsp-folding.lua) to corresponding paths into `~/.config/nvim/` and restart Neovim.
|
||||
You can copy or merge [lsp-folding.lua](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/plugins/lsp-folding.lua) to corresponding paths into `~/.config/nvim/` and restart Neovim.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by scripts/link-docs.mjs from docs/tinymist/frontend/vscode.typ. Do not edit manually. -->
|
||||
# Tinymist Typst VS Code Extension
|
||||
|
||||
A VS Code or VS Codium extension for Typst. You can find the extension on:
|
||||
|
@ -18,13 +19,14 @@ To initialize a Typst project:
|
|||
- Use command `Typst init template` (tinymist.initTemplate) to initialize a new Typst project based on a template.
|
||||
- Use command `Typst show template` (tinymist.showTemplateGallery) to show available Typst templates for picking up a template to initialize.
|
||||
|
||||
|
||||
🎉 If your template contains only a single file, you can also insert the template content in place with command:
|
||||
- Use command `Typst template in place` (tinymist.initTemplateInPlace) and input a template specifier for initialization.
|
||||
|
||||
### Configuring LSP-enhanced formatters
|
||||
|
||||
1. Open settings.
|
||||
2. Search for "Tinymist Formatter" and modify the value.
|
||||
1. Search for "Tinymist Formatter" and modify the value.
|
||||
- Use `"formatterMode": "typstyle"` for [typstyle](https://github.com/Enter-tainer/typstyle).
|
||||
- Use `"formatterMode": "typstfmt"` for [typstfmt](https://github.com/astrale-sharp/typstfmt).
|
||||
|
||||
|
@ -38,9 +40,9 @@ Tips: to enable formatting on save, you should add extra settings for typst lang
|
|||
}
|
||||
```
|
||||
|
||||
### Configuring/Using Tinymist's Activity Bar (Sidebar)
|
||||
### Configuring/Using Tinymist’s Activity Bar (Sidebar)
|
||||
|
||||
If you don't like the activity bar, you can right-click on the activity bar and uncheck "Tinymist" to hide it.
|
||||
If you don’t like the activity bar, you can right-click on the activity bar and uncheck "Tinymist" to hide it.
|
||||
|
||||
#### Symbol View
|
||||
|
||||
|
@ -56,7 +58,7 @@ You can also use the shortcut (Ctrl+K V).
|
|||
|
||||
#### Theme-aware template (previewing)
|
||||
|
||||
In short, there is a `sys.inputs` item added to the compiler when your document is under the context of *user editing or previewing task*. You can use it to configure your template:
|
||||
In short, there is a `sys.inputs` item added to the compiler when your document is under the context of _user editing or previewing task_. You can use it to configure your template:
|
||||
|
||||
```typ
|
||||
#let preview-args = json.decode(sys.inputs.at("x-preview", default: "{}"))
|
||||
|
@ -66,31 +68,32 @@ In short, there is a `sys.inputs` item added to the compiler when your document
|
|||
#let preview-theme = preview-args.at("theme", default: "light")
|
||||
```
|
||||
|
||||
For details, please check [Preview's sys.inputs](https://myriad-dreamin.github.io/tinymist/feature/preview.html#label-sys.inputs).
|
||||
For details, please check [Preview’s sys.inputs](https://myriad-dreamin.github.io/tinymist/feature/preview.html#label-sys.inputs).
|
||||
|
||||
### Configuring path to search fonts
|
||||
|
||||
To configure path to search fonts:
|
||||
1. Open settings.
|
||||
- File -> Preferences -> Settings (Linux, Windows).
|
||||
- Code -> Preferences -> Settings (Mac).
|
||||
2. Search for "Tinymist Font Paths" for providing paths to search fonts order-by-order.
|
||||
3. Search for "Tinymist No System Fonts" for disabling system fonts to be searched, which is useful for reproducible rendering your PDF documents.
|
||||
4. Reload the window or restart the vscode editor to make the settings take effect.
|
||||
- File -\> Preferences -\> Settings (Linux, Windows).
|
||||
- Code -\> Preferences -\> Settings (Mac).
|
||||
1. Search for "Tinymist Font Paths" for providing paths to search fonts order-by-order.
|
||||
1. Search for "Tinymist No System Fonts" for disabling system fonts to be searched, which is useful for reproducible rendering your PDF documents.
|
||||
1. Reload the window or restart the vscode editor to make the settings take effect.
|
||||
|
||||
|
||||
**Note:** you must provide absolute paths.
|
||||
**Note':** you can use vscode variables in the settings, see [vscode-variables](https://www.npmjs.com/package/vscode-variables) for more information.
|
||||
**Note:** you can use vscode variables in the settings, see [vscode-variables](https://www.npmjs.com/package/vscode-variables) for more information.
|
||||
|
||||
### Configuring path to root directory
|
||||
|
||||
To configure the root path resolved for Typst compiler:
|
||||
1. Open settings.
|
||||
2. Search for "Tinymist Root Path" and modify the value.
|
||||
3. Reload the window or restart the vscode editor to make the settings take effect.
|
||||
**Note:** you must provide absolute paths.
|
||||
1. Search for "Tinymist Root Path" and modify the value.
|
||||
1. Reload the window or restart the vscode editor to make the settings take effect. **Note:** you must provide absolute paths.
|
||||
|
||||
### Compiling PDF
|
||||
|
||||
This extension compiles to PDF, but it doesn't have a PDF viewer yet. To view the output as you work, install a PDF viewer extension, such as `vscode-pdf`.
|
||||
This extension compiles to PDF, but it doesn’t have a PDF viewer yet. To view the output as you work, install a PDF viewer extension, such as `vscode-pdf`.
|
||||
|
||||
To find a way to compile PDF:
|
||||
- Click the code len `Export PDF` at the top of document, or use command `Typst Show PDF ...`, to show the current document to PDF.
|
||||
|
@ -99,8 +102,8 @@ To find a way to compile PDF:
|
|||
|
||||
To configure when PDFs are compiled:
|
||||
1. Open settings.
|
||||
2. Search for "Tinymist Export PDF".
|
||||
3. Change the "Export PDF" setting.
|
||||
1. Search for "Tinymist Export PDF".
|
||||
1. Change the "Export PDF" setting.
|
||||
- `onSave` makes a PDF after saving the Typst file.
|
||||
- `onType` makes PDF files live, as you type.
|
||||
- `never` disables PDF compilation.
|
||||
|
@ -109,21 +112,28 @@ To configure when PDFs are compiled:
|
|||
To configure where PDFs are saved:
|
||||
|
||||
1. Open settings.
|
||||
2. Search for "Tinymist Output Path".
|
||||
3. Change the "Output Path" setting. This is the path pattern to store artifacts, you can use `$root` or `$dir` or `$name` to do magic configuration
|
||||
1. Search for "Tinymist Output Path".
|
||||
1. Change the "Output Path" setting. This is the path pattern to store
|
||||
artifacts, you can use `$root` or `$dir` or `$name` to do magic
|
||||
configuration
|
||||
- e.g. `$root/$dir/$name` (default) for `$root/path/to/main.pdf`.
|
||||
- e.g. `$root/target/$dir/$name` for `$root/target/path/to/main.pdf`.
|
||||
- e.g. `$root/target/foo` for `$root/target/foo.pdf`. This will ensure that the output is always output to `target/foo.pdf`.
|
||||
4. Note: the output path should be substituted as an absolute path.
|
||||
- e.g. `$root/target/foo` for `$root/target/foo.pdf`. This will ensure
|
||||
that the output is always output to `target/foo.pdf`.
|
||||
|
||||
**Note:** the output path should be substituted as an absolute path.
|
||||
|
||||
### Exporting to Other Formats
|
||||
|
||||
You can export your documents to various other formats by lsp as well. Currently, the following formats are supported:
|
||||
You can export your documents to various other formats by lsp as well.
|
||||
Currently, the following formats are supported:
|
||||
- Official svg, png, and pdf.
|
||||
- Unofficial html, md (typlite, @ntjess), and txt
|
||||
- Unofficial html, md (typlite), and txt
|
||||
- Query Results (into json, yaml, or txt), and pdfpc (by `typst query --selector <pdfpc-file>`, for [Touying](https://touying-typ.github.io/touying/))
|
||||
|
||||
See [Docs: Exporting Documents](https://myriad-dreamin.github.io/tinymist/feature/export.html) for more information.
|
||||
See
|
||||
[Docs: Exporting Documents](https://myriad-dreamin.github.io/tinymist/feature/export.html)
|
||||
for more information.
|
||||
|
||||
### Working with Multiple-File Projects
|
||||
|
||||
|
@ -144,12 +154,14 @@ Supported arguments:
|
|||
- This is used to specify the **default** entry file for the compiler, which may be overridden by other settings.
|
||||
- `--input`: Add a string key-value pair visible through `sys.inputs`.
|
||||
- `--font-path` (environment variable: `TYPST_FONT_PATHS`), Font paths, maybe overriden by `tinymist.fontPaths`.
|
||||
- `--ignore-system-fonts`: Ensures system fonts won't be searched, maybe overriden by `tinymist.systemFonts`.
|
||||
- `--creation-timestamp` (environment variable: `SOURCE_DATE_EPOCH`): The document's creation date formatted as a [UNIX timestamp](https://reproducible-builds.org/specs/source-date-epoch/).
|
||||
- `--ignore-system-fonts`: Ensures system fonts won’t be searched, maybe overriden by `tinymist.systemFonts`.
|
||||
- `--creation-timestamp` (environment variable: `SOURCE_DATE_EPOCH`): The document’s creation date formatted as a [UNIX timestamp](https://reproducible-builds.org/specs/source-date-epoch/).
|
||||
|
||||
**Note:** Fix entry to `main.typ` may help multiple-file projects but you may loss diagnostics and autocompletions in unrelated files.
|
||||
**Note:** Fix entry to `main.typ` may help multiple-file projects
|
||||
but you may loss diagnostics and autocompletions in unrelated files.
|
||||
|
||||
Note: the arguments has quite low priority, and that may be overridden by other settings.
|
||||
**Note:** the arguments has quite low priority, and that may be overridden
|
||||
by other settings.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
<!-- This file is generated by scripts/link-docs.mjs from docs/tinymist/frontend/zed.typ. Do not edit manually. -->
|
||||
# Tinymist Zed Support for Typst
|
||||
|
||||
See [typst.zed](https://github.com/WeetHet/typst.zed).
|
||||
|
|
|
@ -42,6 +42,10 @@ const convert = async (inp, out, opts) => {
|
|||
const main = async () => {
|
||||
await Promise.all([
|
||||
convert('docs/tinymist/introduction.typ', 'README.md', { before: "# Tinymist\n\n" }),
|
||||
convert('docs/tinymist/frontend/neovim.typ', 'editors/neovim/README.md', { before: "# Tinymist Neovim Support for Typst\n\n" }),
|
||||
convert('docs/tinymist/frontend/helix.typ', 'editors/helix/README.md', { before: "# Tinymist Helix Support for Typst\n\n" }),
|
||||
convert('docs/tinymist/frontend/vscode.typ', 'editors/vscode/README.md', { before: "# Tinymist Typst VS Code Extension\n\n" }),
|
||||
convert('docs/tinymist/frontend/zed.typ', 'editors/zed/README.md', { before: "# Tinymist Zed Support for Typst\n\n" }),
|
||||
])
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue