kaarmu / typst.vim

Vim plugin for Typst
MIT License
281 stars 24 forks source link

typst CLI arguments position change #90

Closed etiennecollin closed 5 months ago

etiennecollin commented 5 months ago

Issue

Since https://github.com/kaarmu/typst.vim/issues/13 and https://github.com/kaarmu/typst.vim/issues/23, it seems that the CLI of typst has changed which makes it impossible to specify a root for the typst project.

Solution

Note that a PR was opened with a potential fix: https://github.com/kaarmu/typst.vim/pull/91

As of typst version 0.11.0, the arguments should be placed after the watch argument just like this:

typst watch <args> --open <app_to_use> <typst_file>

Hence, a command should look like this:

typst watch --root ~ --open sioyek main.typ

I am not that familiar with the architecture of this plugin, but I believe simply swapping lines 7 and 8 in the following file should fix this issue.

https://github.com/kaarmu/typst.vim/blob/8dbc6160138b8d12adbdce5d54595de9fbee9e8c/autoload/typst.vim#L6-L10

Additional Info

typst version

> typst --version
typst 0.11.0

typst CLI options

Here are the new CLI options for typst:

> typst -h
The Typst compiler

Usage: typst [OPTIONS] <COMMAND>

Commands:
  compile  Compiles an input file into a supported output format [aliases: c]
  watch    Watches an input file and recompiles on changes [aliases: w]
  init     Initializes a new project from a template
  query    Processes an input file to extract provided metadata
  fonts    Lists all discovered fonts in system and custom font paths
  update   Self update the Typst CLI (disabled)
  help     Print this message or the help of the given subcommand(s)

Options:
      --color[=<WHEN>]  Set when to use color. auto = use color if a capable terminal is detected [default: auto] [possible values: auto, always, never]
      --cert <CERT>     Path to a custom CA certificate to use when making network requests [env: TYPST_CERT=]
  -h, --help            Print help
  -V, --version         Print version

typst watch CLI options

Here are the new CLI options for typst watch:

> typst watch -h
Watches an input file and recompiles on changes

Usage: typst watch [OPTIONS] <INPUT> [OUTPUT]

Arguments:
  <INPUT>   Path to input Typst file, use `-` to read input from stdin
  [OUTPUT]  Path to output file (PDF, PNG, or SVG)

Options:
      --root <DIR>
          Configures the project root (for absolute paths) [env: TYPST_ROOT=]
      --input <key=value>
          Add a string key-value pair visible through `sys.inputs`
      --font-path <DIR>
          Adds additional directories to search for fonts [env: TYPST_FONT_PATHS=]
      --diagnostic-format <DIAGNOSTIC_FORMAT>
          The format to emit diagnostics in [default: human] [possible values: human, short]
  -f, --format <FORMAT>
          The format of the output file, inferred from the extension by default [possible values: pdf, png, svg]
      --open [<OPEN>]
          Opens the output file using the default viewer after compilation
      --ppi <PPI>
          The PPI (pixels per inch) to use for PNG export [default: 144]
      --timings [<OUTPUT_JSON>]
          Produces performance timings of the compilation process (experimental)
  -h, --help
          Print help (see more with '--help')
kaarmu commented 5 months ago

Thanks a lot!