Skip to content

iXORTech/STTextView-Plugin-Neon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STTextView Source Code Syntax Highlighting with TreeSitter and Neon.

Notepad.exe.mp4

Installation

Add the plugin package as a dependency of your application, then register/add it to the STTextView instance:

import NeonPlugin

textView.addPlugin(
    NeonPlugin(
        theme: .default,
        language: .swift
    )
)

SwiftUI:

import SwiftUI
import STTextViewUI
import NeonPlugin

struct ContentView: View {
    @State private var text: AttributedString = ""
    @State private var selection: NSRange?
    var body: some View {
        STTextViewUI.TextView(
            text: $text,
            selection: $selection,
            options: [.wrapLines, .highlightSelectedLine],
            plugins: [NeonPlugin(theme: .default, language: .swift)]
        )
        .textViewFont(.monospacedDigitSystemFont(ofSize: NSFont.systemFontSize, weight: .regular))
        .onAppear {
            loadContent()
        }
    }

    private func loadContent() {
        // (....)
        self.text = AttributedString(string)
    }
}

About

Source Code Syntax Highlighting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 99.9%
  • Other 0.1%