FoamScience / tree-sitter-foam

OpenFOAM grammar for Tree-Sitter
MIT License
15 stars 5 forks source link

Basic tree-sitter question #9

Closed fbraennstroem closed 5 months ago

fbraennstroem commented 5 months ago

Hi, I have a very basic tree-sitter question...

I am using tree-sitter generate within the cloned directory on a macos. The output is

tree-sitter generate
Replacing nan dependency with node-addon-api in package.json
Adding node-gyp-build dependency to package.json
Adding prebuildify devDependency to package.json
Adding an install script to package.json
Adding a prebuildify script to package.json
Adding peerDependencies to package.json
Adding types to package.json
Adding files to package.json
Updated build.rs with the /utf-8 flag for Windows compilation
Replacing index.js with new binding API
Replacing binding.cc with new binding API
Replacing binding.gyp with new binding API

May I ask, how to procede here? Maybe you have a hint!? Actually I am using emacs and not nvim, but I assume that I can somehow load these package.json files.

FoamScience commented 5 months ago

Hi, all the replacing happens because I haven't updated to the new bindings API yet; kinda no time on hand and I'd like to support the old way a little bit more.

It's not clear what you want to do with the parser, but if all you want to do is to use the highlighting in Emacs, it's probably good to add it to https://github.com/emacs-tree-sitter/tree-sitter-langs as you install it with https://emacs-tree-sitter.github.io/installation/; I'm just wing it here, have no actual experience with Emacs.

If you wanna do other stuff with it

the generate command compiles the parser into a WASM file; so you can really use it almost everywhere. I kept switching between the native and wasm (web assembly) implementations for the LSP server for performance considerations at the time (and the hope of supporting vscode)

you can look at the relevant diffs here: https://sourcegraph.com/search?q=context:global+type:diff+repo:%5Egithub%5C.com/FoamScience/foam-language-server%24+foam.wasm&patternType=keyword&sm=0 those files will provide an example JavaScript usage.

I also can point you to a Rust project https://github.com/foamscience/foam-highlighter using the parser.

There are also golang bindings; but I'm not sure if it's feasible to provide parser bindings for CommonLisp

fbraennstroem commented 5 months ago

Hi, thank you for your quick reply! Yes, for now I would just use it for syntax highlighting. I will look into the tree-sitter-emacs more. ... and I need to look more into it to understand the other things I could do with it. Thank you very much!

FoamScience commented 5 months ago

I'd be interested to see it used with Emacs; closing as it's not issue with the code. If you have any further Qs feel free to reopen.

fbraennstroem commented 5 months ago

yes, I will do it, though I need some time to understand tree-sitter better, thank you