-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(typst): add typst
completion spec
#2144
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,376 @@ | ||
import { filepaths } from "@fig/autocomplete-generators"; | ||
|
||
const completionSpec: Fig.Spec = { | ||
name: "typst", | ||
description: "The Typst compiler", | ||
icon: "📄", | ||
subcommands: [ | ||
{ | ||
name: ["compile", "c"], | ||
description: "Compiles an input file into a supported output format", | ||
icon: "📄", | ||
options: [ | ||
{ | ||
name: "--root", | ||
description: "Configures the project root (for absolute paths)", | ||
args: { | ||
name: "root", | ||
template: "folders", | ||
}, | ||
}, | ||
{ | ||
name: "--font-path", | ||
description: "Adds additional directories to search for fonts", | ||
isRepeatable: true, | ||
args: { | ||
name: "font_paths", | ||
template: "filepaths", | ||
}, | ||
}, | ||
{ | ||
name: "--diagnostic-format", | ||
description: "The format to emit diagnostics in", | ||
args: { | ||
name: "diagnostic_format", | ||
suggestions: ["human", "short"], | ||
default: "human", | ||
}, | ||
}, | ||
{ | ||
name: ["-f", "--format"], | ||
description: | ||
"The format of the output file, inferred from the extension by default", | ||
args: { | ||
name: "format", | ||
suggestions: ["pdf", "png", "svg"], | ||
}, | ||
}, | ||
{ | ||
name: "--open", | ||
description: | ||
"Opens the output file using the default viewer after compilation", | ||
args: { | ||
name: "open", | ||
isVariadic: true, | ||
isOptional: true, | ||
}, | ||
}, | ||
{ | ||
name: "--ppi", | ||
description: "The PPI (pixels per inch) to use for PNG export", | ||
args: { | ||
name: "ppi", | ||
default: "144.0", | ||
}, | ||
}, | ||
{ | ||
name: "--flamegraph", | ||
description: "Produces a flamegraph of the compilation process", | ||
args: { | ||
name: "flamegraph", | ||
isVariadic: true, | ||
isOptional: true, | ||
template: "filepaths", | ||
}, | ||
}, | ||
{ | ||
name: ["-h", "--help"], | ||
description: "Print help", | ||
}, | ||
], | ||
args: [ | ||
{ | ||
name: "input", | ||
description: "Path to input Typst file", | ||
generators: filepaths({ | ||
extensions: ["typ"], | ||
}), | ||
}, | ||
{ | ||
name: "output", | ||
description: "Path to output file (PDF, PNG, or SVG)", | ||
isOptional: true, | ||
template: "filepaths", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: ["watch", "w"], | ||
description: "Watches an input file and recompiles on changes", | ||
icon: "🔄", | ||
options: [ | ||
{ | ||
name: "--root", | ||
description: "Configures the project root (for absolute paths)", | ||
args: { | ||
name: "root", | ||
template: "folders", | ||
}, | ||
}, | ||
{ | ||
name: "--font-path", | ||
description: "Adds additional directories to search for fonts", | ||
isRepeatable: true, | ||
args: { | ||
name: "font_paths", | ||
template: "filepaths", | ||
}, | ||
}, | ||
{ | ||
name: "--diagnostic-format", | ||
description: "The format to emit diagnostics in", | ||
args: { | ||
name: "diagnostic_format", | ||
suggestions: ["human", "short"], | ||
default: "human", | ||
}, | ||
}, | ||
{ | ||
name: ["-f", "--format"], | ||
description: | ||
"The format of the output file, inferred from the extension by default", | ||
args: { | ||
name: "format", | ||
suggestions: ["pdf", "png", "svg"], | ||
}, | ||
}, | ||
{ | ||
name: "--open", | ||
description: | ||
"Opens the output file using the default viewer after compilation", | ||
args: { | ||
name: "open", | ||
isVariadic: true, | ||
isOptional: true, | ||
}, | ||
}, | ||
{ | ||
name: "--ppi", | ||
description: "The PPI (pixels per inch) to use for PNG export", | ||
args: { | ||
name: "ppi", | ||
default: "144.0", | ||
}, | ||
}, | ||
{ | ||
name: "--flamegraph", | ||
description: "Produces a flamegraph of the compilation process", | ||
args: { | ||
name: "flamegraph", | ||
isVariadic: true, | ||
isOptional: true, | ||
template: "filepaths", | ||
}, | ||
}, | ||
{ | ||
name: ["-h", "--help"], | ||
description: "Print help", | ||
}, | ||
], | ||
args: [ | ||
{ | ||
name: "input", | ||
description: "Path to input Typst file", | ||
generators: filepaths({ | ||
extensions: ["typ"], | ||
}), | ||
}, | ||
{ | ||
name: "output", | ||
description: "Path to output file (PDF, PNG, or SVG)", | ||
isOptional: true, | ||
template: "filepaths", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "query", | ||
description: "Processes an input file to extract provided metadata", | ||
icon: "🔍", | ||
options: [ | ||
{ | ||
name: "--root", | ||
description: "Configures the project root (for absolute paths)", | ||
args: { | ||
name: "root", | ||
template: "folders", | ||
}, | ||
}, | ||
{ | ||
name: "--font-path", | ||
description: "Adds additional directories to search for fonts", | ||
isRepeatable: true, | ||
args: { | ||
name: "font_paths", | ||
template: "filepaths", | ||
}, | ||
}, | ||
{ | ||
name: "--diagnostic-format", | ||
description: "The format to emit diagnostics in", | ||
args: { | ||
name: "diagnostic_format", | ||
suggestions: ["human", "short"], | ||
default: "human", | ||
}, | ||
}, | ||
{ | ||
name: "--field", | ||
description: "Extracts just one field from all retrieved elements", | ||
args: { | ||
name: "field", | ||
}, | ||
}, | ||
{ | ||
name: "--format", | ||
description: "The format to serialize in", | ||
args: { | ||
name: "format", | ||
suggestions: ["json", "yaml"], | ||
default: "json", | ||
}, | ||
}, | ||
{ | ||
name: "--one", | ||
description: "Expects and retrieves exactly one element", | ||
}, | ||
{ | ||
name: ["-h", "--help"], | ||
description: "Print help", | ||
}, | ||
], | ||
args: [ | ||
{ | ||
name: "input", | ||
description: "Path to input Typst file", | ||
generators: filepaths({ | ||
extensions: ["typ"], | ||
}), | ||
}, | ||
{ | ||
name: "selector", | ||
description: "Defines which elements to retrieve", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "fonts", | ||
description: "Lists all discovered fonts in system and custom font paths", | ||
icon: "🔤", | ||
options: [ | ||
{ | ||
name: "--font-path", | ||
description: "Adds additional directories to search for fonts", | ||
isRepeatable: true, | ||
args: { | ||
name: "font_paths", | ||
template: "filepaths", | ||
}, | ||
}, | ||
{ | ||
name: "--variants", | ||
description: "Also lists style variants of each font family", | ||
}, | ||
{ | ||
name: ["-h", "--help"], | ||
description: "Print help", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "update", | ||
description: "Self update the Typst CLI (disabled)", | ||
icon: "🆙", | ||
options: [ | ||
{ | ||
name: "--force", | ||
description: | ||
"Forces a downgrade to an older version (required for downgrading)", | ||
exclusiveOn: ["--revert"], | ||
}, | ||
{ | ||
// TODO: Make it impossible to use with one or more of the other specified arguments (e.g version) | ||
name: "--revert", | ||
description: | ||
"Reverts to the version from before the last update (only possible if `typst update` has previously ran)", | ||
exclusiveOn: ["--force"], | ||
}, | ||
{ | ||
name: ["-h", "--help"], | ||
description: "Print help", | ||
}, | ||
], | ||
args: { | ||
name: "version", | ||
description: "Which version to update to (defaults to latest)", | ||
isOptional: true, | ||
}, | ||
}, | ||
{ | ||
name: "help", | ||
description: "Print this message or the help of the given subcommand(s)", | ||
icon: "ℹ️", | ||
subcommands: [ | ||
{ | ||
name: "compile", | ||
description: "Compiles an input file into a supported output format", | ||
icon: "📄", | ||
}, | ||
{ | ||
name: "watch", | ||
description: "Watches an input file and recompiles on changes", | ||
icon: "🔄", | ||
}, | ||
{ | ||
name: "query", | ||
description: "Processes an input file to extract provided metadata", | ||
icon: "🔍", | ||
}, | ||
{ | ||
name: "fonts", | ||
description: | ||
"Lists all discovered fonts in system and custom font paths", | ||
icon: "🔤", | ||
}, | ||
{ | ||
name: "update", | ||
description: "Self update the Typst CLI (disabled)", | ||
icon: "🆙", | ||
}, | ||
{ | ||
name: "help", | ||
description: | ||
"Print this message or the help of the given subcommand(s)", | ||
icon: "ℹ️", | ||
}, | ||
], | ||
}, | ||
], | ||
options: [ | ||
{ | ||
name: "--cert", | ||
description: | ||
"Path to a custom CA certificate to use when making network requests", | ||
args: { | ||
name: "cert", | ||
template: "filepaths", | ||
}, | ||
}, | ||
{ | ||
name: ["-v", "--verbosity"], | ||
description: | ||
"Sets the level of logging verbosity: -v = warning & error, -vv = info, -vvv = debug, -vvvv = trace", | ||
isRepeatable: 4, | ||
}, | ||
{ | ||
name: ["-h", "--help"], | ||
description: "Print help", | ||
}, | ||
{ | ||
name: ["-V", "--version"], | ||
description: "Print version", | ||
}, | ||
], | ||
}; | ||
|
||
export default completionSpec; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of an edge case, but I think it makes sense to split these into two options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. An option like that
--verbosity
might be easier to use. Since I am not an typst maintainer, it might be good if you could suggest it for typst.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is verbatim how the command works right now, you can literally repeat
--verbosity
up to 4 times.