feat: expose public API for custom syntax parsers

Open
#2,050 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale

Research direction

Start by reading the syntax parser implementation and package exports referenced by the issue, then inspect extensions/tree-sitter/integration.lisp and PR #2046 to understand how the extension uses the parser protocol. Define and document the public class and scanning API, and update the integration to use exported symbols; done when custom parsers can use the documented public API without internal symbol access.

Written by the indexing model from the issue text.

Description

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

  • PR #2046: tree-sitter syntax highlighting integration
Dominant language
Common Lisp
Stars
3.1k
Forks
261
Avg merge
1d 6h
Merged PRs (30d)
133

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lem-project/lem

All issues in lem-project/lem

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.