haberdashPI / vscode-neurobehave-presentation

VSCode Language support for Neurobehavioral systems' Presentation
0 stars 0 forks source link

Handle SDL-header data types #2

Open haberdashPI opened 5 years ago

haberdashPI commented 5 years ago

There are a lot of types in the PCL reference, that are not highlighted by this extension, which @MrMho pointed me to in #1.

One workaround for fixing this problem would be to highlight anything before {; kind of ugly, but it might be useful. I don't personally feel the need for these types to be highlighted, as I think the extension is quite usable without this behavior implemented. I am open to changing the behavior if there are other opinions.

A real fix for this would require parsing the ~SDL~PCL header section of a file separately from the rest of a program. That is something I started to try and realized it would be a lot of work: the time and energy it appears to require doesn't seem worth it, as the extension remains pretty usable without this feature. If anyone feels like it is worth their time to get this working, go wild!

MrMho commented 5 years ago

Hey, thanks for fixing the highlighting for the bool type.

I am not sure if I understand your concerns regarding the highlighting of PCL-header data types correctly. Do you mean SDL-headers?

haberdashPI commented 5 years ago

A yes, I do mean SDL-header. I mixed up the terminology. Sorry about that.

The issue is that the syntax within the header differs from the syntax following the begin_pcl portion of a program. The way textMate grammars (which is how I implemented this extension) work, it's not easy to change the syntax on the basis of the begin_pcl marker. It might be possible, but I just haven't figured out how to do it correctly.

So, I can either have keywords like wavefile highlighted everywhere, or nowhere, but not only in the section before begin_pcl. The workaround I was proposing would involve highlighting all words before {, which is where these types typically appear. But this means that even if you typed wavfile instead of wavefile it would still highlight.

MrMho commented 5 years ago

OK, thanks for clarifying. I see. The fact that Presentation mixes two languages (or syntaxes) makes this very difficult.

As for the workaround that involves highlighting words before {, In my opinion that misses one point of syntax highlighting a little bit. One advantage of syntax highlighting is, when I type in a keyword and the editor highlights it, I know it exists and I spelled it correctly. This would not be the case with your suggested workaround.

In my issue [#1], I was only thinking about the PCL syntax. Note that wavefile is a SDL as well as a PCL type. I usually avoid mixing PCL and SDL in one file, meaning I keep the entire SDL header in a separate file. So, I personally do not think it is worth the effort to change the extension, so that it can automatically distinguish between the two syntaxes. The official Presentation editor allows you to switch manually between the two syntax highlighting modes. Maybe this would be an idea for your extension.

To conclude, it would be nice to have highlighting for some more PCL types. But the extension is already quite usable and helpful in its current state.

haberdashPI commented 5 years ago

Thanks for your feedback @MrMho. Sounds like we agree on not highlighting anything before {. Glad to hear the extension works for your purposes.

haberdashPI commented 5 years ago

I think the right solution to this, if it ever becomes worth implementing, would be to use Tree Sitter to define the syntax highlighting grammar, rather than via a TextMate grammar. Tree-sitter grammars more easily allow for contextual highlighting.