Spellcheck typst files with LanguageTool.
// use styling for spellcheck only in the spellchecker
// keep the correct styling in pdf or preview
// should be called after the template
#show: lt()
// use styling for spellcheck in pdf or preview
// should be called after the template
#show: lt(overwrite: true)
#let lt(overwrite: false) = {
if not sys.inputs.at("spellcheck", default: overwrite) {
return (doc) => doc
}
return (doc) => {
show math.equation.where(block: false): it => [0]
show math.equation.where(block: true): it => []
show bibliography: it => []
show par: set par(justify: false, leading: 0.65em)
set page(height: auto)
show block: it => it.body
show page: set page(numbering: none)
show heading: it => if it.level <= 3 {
pagebreak() + it
} else {
it
}
doc
}
}
The compiled document contains the text language, but not the region.
#set text(
lang: "de", // included
region: "DE", // lost
)
The text language is used to determine the region code ("de-DE", ...). If another region is desired, it can be specified in the language parameter.
cargo install ...
with --features=<backend>
typst-languagetool ...
with the required flagsbundle-jar
--bundled
external-jar
jar_location=<path>
remote-server
host=<host>
and port=<port>
cargo install --git=https://github.com/antonWetzel/typst-languagetool cli --features=...
typst-languagetool check ...
typst-languagetool watch ...
typst-languagetool watch --path=<directory or file>
typst-languagetool check --path=<file>
--main=<file>
--root=<path>
cargo install --git=https://github.com/antonWetzel/typst-languagetool lsp --features=...
editors/vscodium/generic-lsp/generic-lsp-0.0.1.vsix
)cargo install --git=https://github.com/antonWetzel/typst-languagetool lsp --features=...
editors/nvim/typst.lua
file in the ftplugin/
folder (should be in the nvim config path)init_option
(see below)main.typst
file and include your typst files inside if neededset filetype=typst
to force the type)
/// Additional allowed words for language codes
dictionary: HashMap<String, Vec<String>>,
/// Languagetool rules to ignore (WHITESPACE_RULE, ...) for language codes
disabled_checks: HashMap<String, Vec<String>>,
/// preferred language codes
languages: Vec<String>,
/// use bundled languagetool
bundled: bool,
/// use external JAR for languagetool
jar_location: Option<String>,
/// host for remote languagetool
host: Option<String>,
/// port for remote languagetool
port: Option<String>,
/// Size for chunk send to LanguageTool
chunk_size: usize,
/// Duration to wait for additional changes before checking the file
/// Leave empty to only check on open and save
on_change: Option<std::time::Duration>,
/// Project Root
root: Option<PathBuf>,
/// Project Main File
main: Option<PathBuf>,