mchakravarty / CodeEditorView

SwiftUI code editor view for iOS, visionOS, and macOS
Apache License 2.0
695 stars 61 forks source link

How to customize syntax highlighting? #41

Open ZhangYiQiu opened 2 years ago

ZhangYiQiu commented 2 years ago

I want to support javascript, shell, python , but only swift and haskell

mchakravarty commented 2 years ago

You can absolutely also support other languages. It is just that the syntax definitions for Swift and Haskell are pre-defined. Definitions for other languages, you need to specify yourself — and I will, of course, glad incorporate PRs that add definitions for other languages.

All the definitions you need are in https://github.com/mchakravarty/CodeEditorView/blob/main/Sources/CodeEditorView/LanguageConfiguration.swift and you can use the syntax spec fro Swift and Haskell as a template of how to use that library.

Please let me know if you run into any problems.

naquin commented 2 years ago

I'm also curious about yaml support, but am unsure if I want to take the full regex plunge to figure it out. Any examples with JSON files to get started?

mchakravarty commented 2 years ago

I don't have any regexs for YAML or JSON lying around, but I'd be more than happy to merge any contributions in this direction.