Skip to content

feat: expose public API for custom syntax parsers #2050

@cxxxr

Description

@cxxxr

Summary

Currently, implementing a custom syntax parser (like tree-sitter integration) requires using internal symbols:

  • lem/buffer/internal::syntax-parser - base class for custom parsers
  • lem/buffer/internal::%syntax-scan-region - method to implement syntax scanning

Background

In PR #2046 (tree-sitter integration), we needed to create a custom syntax parser that integrates with Lem's syntax highlighting system. While we refactored to use public APIs for text property manipulation (put-text-property, remove-text-property, text-property-at), the parser class itself still requires internal symbol access.

Current Implementation

;; extensions/tree-sitter/integration.lisp
(defclass treesitter-parser (lem/buffer/internal::syntax-parser)
  ...)

(defmethod lem/buffer/internal::%syntax-scan-region ((parser treesitter-parser) start end)
  ...)

Proposal

Export a public API for custom syntax parsers:

  1. Export syntax-parser class from lem or lem-core package
  2. Export %syntax-scan-region generic function (possibly renamed to syntax-scan-region)
  3. Document the protocol for implementing custom syntax parsers

Benefits

  • Enables extensions to implement custom syntax highlighting without internal symbol access
  • Follows Lem's convention of using exported symbols
  • Makes the syntax parser extension point official and stable

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions