Comments (7)
I'm so glad you reached out - I would be very happy to help!
I hope the read me was clear, but Neon isn't a drop-in view. It is a collection of components you can use for efficient text style application and invalidation. So, how you integrate it it very dependent on your text system and what you are trying to do.
(I'm actually working right now on further generalizing the system and adopting Swift concurrency!)
Are you wrapping up an NSTextView for use in SwiftUI? And are you interested in using tree-sitter for token information, or some other source? You may want to have a look at TextViewHighlighter
. It is easiest (but least-flexible) option for directly connecting tree-sitter to an NSTextView.
from neon.
(I also just put a link to a Discord in case you are looking for some more live help and that's your kind of thing)
I do, also, want to confirm that a SwiftUI example is a great idea and something that should definitely be added.
from neon.
Thanks, I've seen and corrected a mistake of mine.
I had added neon
to my project via the add package... Only did it add 0.5.1
by default and that was missing some classes, as it's 7 months old. So that got me confused for a while.
I understand Swift well, but as a polyglot, I'm not really across XCode. Changing that to "branch" "main" fixed the missing class issues.
The other problem I'm having is with the bundle business
let url = Bundle.main
.resourceURL?
.appendingPathComponent("TreeSitterSwift_TreeSitterSwift.bundle")
.appendingPathComponent("queries/highlights.scm")
let query = try! language.query(contentsOf: url!)
Would it be possible to see a full example with tree_sitter_c
or other language that has a clear cut away from Swift without this bundle business?
For the sake of not tip toeing around and this thread carrying on, which is due to my lack of understanding, I've included the code I'm haplessly trying to adapt for a code editor: https://gist.github.com/keyle/228ffd4a5622c1c328299f3ff9dd7c25
I've highlighted the issue at problem here
.
Thanks for your time! 🙏🏻
from neon.
What wasn't working with 0.5.1? That's definitely supposed to be functional.
The bundle handling is completely independent of parser language. The issue is you must provide the tree-sitter integration with a minimum of two things: the parser and the highlighting query patterns. Many tree-sitter parsers have been packaged up with SPM to ease integration into Swift code.
Your code isn't working because you have added "TreeSitterC", but you are telling the system to look for a bundle called "TreeSitterSwift". Try this:
let url = Bundle.main
.resourceURL?
.appendingPathComponent("TreeSitterC_TreeSitterC.bundle")
.appendingPathComponent("Contents/Resources/queries/highlights.scm")
let query = try! language.query(contentsOf: url!)
Another alternative is to make use of the bundle searching facilities in SwiftTreeSitter (this is the runtime system, not to be confused with the Swift language parser called TreeSitterSwift).
(writing this off the top of my head, could be wrong)
let language = Language(language: tree_sitter_c(), name: "C")
let query = try! language.query(contentsOf: language.highlightsFileURL!)
from neon.
Any progress?
from neon.
Sorry for the lack of updates, life got in the way... What you've written makes sense and clearly I wasn't groking the relationship with the bundle and tree sitter.
from neon.
Absolutely no need to apologize. If anything else comes up, please don't be shy to ask again!
from neon.
Related Issues (17)
- Screenshot link for "painting it black" in README broken
- Variable 'version' needs fix HOT 2
- async version of currentTree HOT 1
- Cannot invalidate highlight at startup and/or with manual text settings HOT 4
- Proposal : TextViewSystemInterface to class HOT 9
- Crash on async access HOT 2
- 'staleContent' error in highlighter HOT 2
- Coalesce attribute changes into one block HOT 2
- Direct text storage attribute modifications HOT 13
- Rendering HTML HOT 3
- Repo example code returns nil for highlight method HOT 6
- Demo crashes when editing text HOT 9
- Validation/Invalidation coordination problem with TreeSitterClient and TextSystemStyler HOT 2
- Text highlighting after edit does not work HOT 1
- TextStorageSystemInterface does not style textedits that are not at end of string HOT 2
- Crash on Updating Text from updateNSView(_ view: NSTextView, context: Context) HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neon.