sourceview icon indicating copy to clipboard operation
sourceview copied to clipboard

Add language in LanguageManager from &str

Open zer0x64 opened this issue 5 years ago • 5 comments

Right now, the only way to use a custom language for syntax highlighting is to install the .lang file inside specific folders or add a folder that contains it to the search path. It would be very nice to add the ability to load a custom language syntax from a &str, which would allow to embed the file inside the executable using the include_str!() macro.

zer0x64 avatar Jul 19 '19 14:07 zer0x64

You can't in the C code. Doing it in rust would mean putting this string into a file located into the search path of the LanguageManager, which doesn't seem like a good idea from my point of view...

GuillaumeGomez avatar Jul 19 '19 15:07 GuillaumeGomez

So this would be a limitation of the underlying C library? What would be the cleanest way to use a custom syntax file? Right now I'm adding the executable path dynamically to the search path.

zer0x64 avatar Jul 19 '19 15:07 zer0x64

Not sure if this was obvious, but that was a feature request, not really a question. I don't know a lot about the code base, but would it be really difficult to implement? If it's not that hard, I can try to do it and open a PR

zer0x64 avatar Jul 19 '19 15:07 zer0x64

If you're talking about adding it in the Rust code base, I can't assure you we'll accept it. We're not big fans of adding specific features to the binding instead of the C library. If it's the C library you're talking about, then it's not the good place. :)

GuillaumeGomez avatar Jul 19 '19 16:07 GuillaumeGomez

Hi! Just a quick note that, in my specific case, I'll try to get my .lang files accepted directly into the upstream C project, as others could also make use of it.

zer0x64 avatar Jul 22 '19 12:07 zer0x64