Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: Syntax highlighting in code snippets in help files in nvim #129

Open
madskjeldgaard opened this issue Nov 8, 2020 · 5 comments
Open

Comments

@madskjeldgaard
Copy link
Contributor

Is your feature request related to a problem? Please describe.
It would be nice with proper syntax highlighting in the neovim help files for scnvim.

Describe the solution you'd like
I imagine that the supercollider.vim syntax highlighter is triggered within each code snippet in the help files, but not outside of it, leaving the rest of the help file as is.

Vim has some solutions for this, see :h syn-include.

There's an example described here:
https://vim.fandom.com/wiki/Different_syntax_highlighting_within_regions_of_a_file

It would probably have to end up in a sort of tag around each code snippet for the syntax highlighter to clearly understand the start and end of each code snippet in the help file so that we can setup highlight regions / groups for those.

@madskjeldgaard
Copy link
Contributor Author

(I promise I will shut up about syntax highlighting soon, haha!)

@madskjeldgaard
Copy link
Contributor Author

madskjeldgaard commented Nov 8, 2020

The idea can be tested out by opening a new buffer called whatever:
:e whateveritdoesntmatter.txt

And then pasting some SuperCollider code inside of start/end brackets of sorts, and then outside of it normal text.

This is just normal text. Nothing to see here.

@begin=supercollider@
var file = "hello";
f = {};
Pbind(\dur, 0.125, \degree).play
@end=supercollider@

Not even the word var will trigger the syntax highlighter.

Then run these commands

:syntax on
:syntax include @SC syntax/supercollider.vim
:syntax region scSnip matchgroup=Snip start="@begin=supercollider@" end="@end=supercollider@" contains=@SC
:hi link Snip SpecialComment

Which will result in something like this:
2020-11-08-221346_1920x1080_scrot

@madskjeldgaard
Copy link
Contributor Author

I have some ideas for this which I could turn into a PR if you think it's a good idea @davidgranstrom

@madskjeldgaard
Copy link
Contributor Author

But I think it would be good to have the start/end tags concealed and encapsulated in SC comments to avoid execution by the user and then change the schelp file converter class to wrap the code examples with these.

@madskjeldgaard
Copy link
Contributor Author

PR here
#130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant