Lapce Docs
Home
  • Introduction
  • Get started
    • Setup
    • Command palette
    • Settings
    • Keybindings
    • Modal editing
    • Remote development
    • Themes
    • Terminal
  • Features
    • Multiple cursor
    • Syntax highlighting
  • Development
    • Architecture
    • Plugin development
    • Theme
Powered by GitBook
On this page
  • Grammars
  • Queries
  • Language
  • Language Server Protocol
  1. Features

Syntax highlighting

PreviousMultiple cursorNextArchitecture

Last updated 10 months ago

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.

Grammars

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:

  1. User provided grammar

  2. System provider grammar

  3. Built-in grammar

Queries

To learn more about queries, see .

Queries are stored in $SETTINGS_DIR/queries/$LANGUAGE. Currently only highlights.scm are supported.

Language

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.

Language Server Protocol

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 .

Tree-sitter
Creating Parsers
DLL_PREFIX
DLL_EXTENSION
Syntax Highlighting#Queries
lapce-core/src/language.rs
lapce-proxy/src/buffer.rs