@singapore-editor/tree-sitter-languages
v0.2.18
Published
Tree-sitter grammars and syntax queries for Singapore language plugins.
Maintainers
Readme
@singapore-editor/tree-sitter-languages
Tree-sitter grammars and syntax queries for Singapore language plugins.
Part of Singapore. A code editor for the browser that keeps every version.
Install
npm install @singapore-editor/core @singapore-editor/tree-sitter-languagesUsage
import { Editor } from '@singapore-editor/core/editor'
import { css } from '@singapore-editor/tree-sitter-languages/css'
import { html } from '@singapore-editor/tree-sitter-languages/html'
import { typeScript } from '@singapore-editor/tree-sitter-languages/typescript'
const host = document.createElement('div')
host.style.height = '400px'
document.body.append(host)
const editor = new Editor(host, {
plugins: [typeScript(), html(), css()],
})
editor.setText('const value = 1\n', { languageId: 'typescript' })Requirements
Tree-sitter and native Markdown parsing need Chromium 144, Firefox 145, Safari 26.2, or newer, and Node.js 26.0.0 or Bun 1.2.22 or newer for parser calls outside a browser. The parser uses WebAssembly.Memory.prototype.toResizableBuffer(), and those are the first versions that support it.
API highlights
- Each language has its own entry point (
/typescript,/tsx,/javascript,/html,/css,/json,/markdown), so an app's build holds only the grammars it uses. TREE_SITTER_LANGUAGE_CONTRIBUTIONS, from@singapore-editor/tree-sitter-languages/catalog, contains the bundled language set.- The
/metadataentry lists language IDs and file extensions.
In the Singapore family
@singapore-editor/core owns the editor view. This optional package adds language grammars. Choose the other plugins your app needs.
Use a bundler that serves the package worker and data assets. See the hosting guide.
Singapore README · Documentation
