SQL Syntax / Custom Syntaxes

72 views
Skip to first unread message

k-hen

unread,
Sep 22, 2020, 1:20:24 PM9/22/20
to leo-editor
OK, I've looked around, but can't seem to find anything on the docs on defining custom syntaxes. i.e. I can't seem to find and @language sql

Can I do this myself (realistically)?

gar

unread,
Sep 23, 2020, 1:14:02 PM9/23/20
to leo-e...@googlegroups.com
For my private usage I made javascript-es6 syntax fork and use it in my project until now.
Actually it is pretty hard - need to make some python coding.
The coloring code itself can be found in leo source code.
Also there's an option to use pygments as a highlighter, but at the moment I tried it - it worked only with python :-(
Edward promised to fix it - but I didnt know the status of this work since my own version of js-es6 is pretty good for me.
https://github.com/iggu/leo-editor here you can see what actually was done

вт, 22 сент. 2020 г. в 20:20, k-hen <percepti...@gmail.com>:
OK, I've looked around, but can't seem to find anything on the docs on defining custom syntaxes. i.e. I can't seem to find and @language sql

Can I do this myself (realistically)?

--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/47b02c2d-e030-45b1-9457-57ababea9e21n%40googlegroups.com.

tbp1...@gmail.com

unread,
Sep 23, 2020, 3:01:43 PM9/23/20
to leo-editor
Leo can colorize javascript (perhaps not es-6 specifically).

@language javascript works fine on my tiny test node.

gar

unread,
Sep 24, 2020, 3:07:44 AM9/24/20
to leo-e...@googlegroups.com
I think that if you are quite familiar with sql and python - it'll take a 3-4 of days for you
first two you'll spend trying to understand what's going on around

вт, 22 сент. 2020 г. в 20:20, k-hen <percepti...@gmail.com>:
OK, I've looked around, but can't seem to find anything on the docs on defining custom syntaxes. i.e. I can't seem to find and @language sql

Can I do this myself (realistically)?

--

percepti...@gmail.com

unread,
Sep 24, 2020, 7:31:09 AM9/24/20
to leo-e...@googlegroups.com
Ok, well, I really appreciate the reply gar, thank you. 
Should be an interesting project once I've got the time to look into it :-)

Edward K. Ream

unread,
Sep 24, 2020, 7:43:41 AM9/24/20
to leo-editor
On Tue, Sep 22, 2020 at 12:20 PM k-hen <percepti...@gmail.com> wrote:

OK, I've looked around, but can't seem to find anything on the docs on defining custom syntaxes.

Controlling Syntax Coloring tells everything you need to know. Feel free to ask questions.
i.e. I can't seem to find and @language sql

There is no such language because there is no leo/modes/sql.py file.

Can I do this myself (realistically)?

Yes you can.  If jEdit has a sql colorer, you can use the @button jEdit2Py button in scripts.leo to convert the jEdit language description file to a modes/sql.py.

Edward

percepti...@gmail.com

unread,
Sep 24, 2020, 9:32:04 AM9/24/20
to leo-e...@googlegroups.com
Ah, ok, I found those modes, thanks! 

I've attached an example of how I'm wrapping the (t)sql nodes. 

I can deal with this, but it would definitely  be a lot cleaner if I could assign the language directive either in just a sql comment (i.e. -- @language sql )
or using a uA/attribute or maybe something in the headline.  As it is the hierarchy is quite clunky to navigate with this double nesting and
I'd prefer for the body to be pure valid sql so I can copy/paste and users linters and things because I have to switch between editors quite frequently.

There are *thousands* of these statements I'd need to convert, 
so I thought I'd throw it out there to see if there might be a cleaner way to do this before I start digging in.


Much appreciated.

Kevin
--
You received this message because you are subscribed to a topic in the Google Groups "leo-editor" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/leo-editor/pU1HOGQ6jXU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS2C2ZX-LjSzUDyGDE-tSbt60_ctPMDuRCnYHGqr11E-%2Bg%40mail.gmail.com.

sql_wrapper_example.leo

Edward K. Ream

unread,
Sep 24, 2020, 9:47:55 AM9/24/20
to leo-editor
On Thu, Sep 24, 2020 at 8:32 AM <percepti...@gmail.com> wrote:

I've attached an example of how I'm wrapping the (t)sql nodes. 

Interesting!
I can deal with this, but it would be a lot cleaner if I could assign the language directive either in just a sql comment (i.e. -- @language sql )
or using a uA/attribute or maybe something in the headline.

Would marking nodes with @sql help?

Edward

percepti...@gmail.com

unread,
Sep 24, 2020, 10:03:52 AM9/24/20
to leo-e...@googlegroups.com
Yes, I believe it would :-) 

There still might be an issue with name collisions since @sql isn't directly a mode (i.e. tsql) 
and creating a directive for every mode obviously wouldn't be ideal either - 
but maybe a shorthand/mapping could be defined in the document Startup section?
i.e. to map a local directive @sql (arbitrary) to a specific mode assignment, like tsql.

I could also deal with buttons to assign/remove attributes but I'd need to be able to view them.
The attributes plugin has still been on my list to try but haven't had time to dive into it yet.

I understand these could also impact things like VR3 so I'm not quite sure how that would factor in.
As it is, I already have to define in a comment, `-- language=sql`, for pycharm to nest syntaxes, 
so aligning with this could work too.
--
You received this message because you are subscribed to a topic in the Google Groups "leo-editor" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/leo-editor/pU1HOGQ6jXU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to leo-editor+...@googlegroups.com.

Edward K. Ream

unread,
Sep 24, 2020, 12:49:31 PM9/24/20
to leo-editor
On Thu, Sep 24, 2020 at 9:03 AM <percepti...@gmail.com> wrote:
Yes, I believe it would :-) 

There still might be an issue with name collisions since @sql isn't directly a mode (i.e. tsql) 
and creating a directive for every mode obviously wouldn't be ideal either - 
but maybe a shorthand/mapping could be defined in the document Startup section?
i.e. to map a local directive @sql (arbitrary) to a specific mode assignment, like tsql.

I could also deal with buttons to assign/remove attributes but I'd need to be able to view them.
The attributes plugin has still been on my list to try but haven't had time to dive into it yet.

I understand these could also impact things like VR3 so I'm not quite sure how that would factor in.
As it is, I already have to define in a comment, `-- language=sql`, for pycharm to nest syntaxes, 
so aligning with this could work too.

These are all reasonable approaches. You can define @button script any way you like.

Let me know if you would benefit from Leo's core. BTW, you can probably use @language sql even though Leo doesn't support it.

Edward
Reply all
Reply to author
Forward
0 new messages