Syntax highlighting
Last updated
Last updated
Language support such as tokenizing and highlighting is provided by . Each language requires a Tree-sitter grammar to have tokenization and queries to provide additional features such as syntax highlighting.
To learn more about queries, see .
Lapce has select few (Rust, JSON, TOML) grammars built-in for convenience. All other languages need to provide an externally loadable grammar in a form of shared library. Lapce will update all supported grammars by default on start-up.
Grammars are stored in $LOCAL_DATA_DIR/grammars
directory. Each grammar should be named ${DLL_PREFIX}tree-sitter-${NAME}.${DLL_SUFFIX}
where ${NAME}
refers to language name and ${DLL_PREFIX}
/${DLL_SUFFIX}
refer to OS defined constants for shared libraries (see and ).
Grammars are loaded in order:
User provided grammar
System provider grammar
Built-in grammar
To learn more about queries, see .
Queries are stored in $SETTINGS_DIR/queries/$LANGUAGE
. Currently only highlights.scm
are supported.
For Lapce to know how to deal with files, it's required to include a language definition which contains which filenames or extensions to match to language, what indent or comment type it uses and additional configuration (that depends on tree-sitter) such as code lens (unrelated to LSP code lens) or sticky headers tokens.
Languages are defined in .
LSP providers should define DocumentSelector
via the extension API and/or through volt.toml
extension manifest. It can be otherwise defined through language_id_from_path
in .