kevinhermawan / Ollamac

Mac app for Ollama
Other
991 stars 52 forks source link

[Feature Request] Syntax Highlighting #16

Closed mattbisme closed 3 days ago

mattbisme commented 7 months ago

Just tried out Ollamac for the first time. Wow, is it smooth! I'll never use a browser UI again! Having said that, it would be great to see some syntax highlighting for code blocks, if that's possible.

kevinhermawan commented 7 months ago

Hi @mattbisme, thanks! Super glad to hear you're finding it smooth.


About the syntax highlighting, I've been wanting to add that feature since day one. Right now, there isn't a native solution that fits perfectly. There's a workaround using JS, but I'm a bit cautious about how it might affect performance. But, I'm up for experimenting to see how it goes 😃

mattbisme commented 7 months ago

Right now, there isn't a native solution that fits perfectly.

Is this a Swift issue, or an Ollama issue? I'm surprised that there isn't a Swift native solution. I did notice that Ollama doesn't specify named code blocks when generating in the CLI. That is, instead of starting a code block with something like

```python

it just has the lone tick marks without python. I found that to be a bit strange.

For what it's worth, Safari has hardware accelerated JS. Does that apply to JS used in a Swift app as well? I can't imagine that it's as performant as native Swift, but, if there is really no other option… I assume it be possible to only activate the syntax highlighting when a code block is generated?

kevinhermawan commented 7 months ago

I'm surprised that there isn't a Swift native solution

Most Swift code highlighters I've found are JavaScript-based, like Highlight.js. And yes, Ollama also doesn't specify the language in code blocks, likely due to a model limitation.

Does that apply to JS used in a Swift app as well?

Yes, the performance benefits of Apple's JavaScriptCore do apply to JavaScript used within a Swift app.

I assume it be possible to only activate the syntax highlighting when a code block is generated?

Yes, it is indeed possible to activate syntax highlighting only when a code block is generated.


I'm still experimenting with this and also keeping an eye on the performance metrics. It's an ongoing process, but I'm making progress! 😃

mattbisme commented 6 months ago

And yes, Ollama also doesn't specify the language in code blocks, likely due to a model limitation.

I noticed that when using phind-codellama with Ollama that it does properly specify the language. I'm not sure if that's helpful at this point, since I see that you are already planning for syntax highlighting in v2… but just thought I'd point that out anyway!

Akeuuh commented 4 months ago

I did tryto add the syntax highlighting, it worked fine but only for swift code since I was using a swift method to do it..