Search code examples
code-snippetsgeanycode-foldinggenie

How to have code folding for Genie (.gs files) in Geany IDE


It seems that Geany does not handle code in Genie programming language very well. It does not offer code folding nor specific snippets.

  • How to have code folding in Geany for the Genie programming language?

  • Does anyone has snippets to share?


Solution

  • In order to get code folding open up (or create) the file:

    ~/.config/geany/filedefs/filetypes.Genie.config
    

    and add or edit the section [lexer_properties] to:

    [settings]
    # Vala uses the C lexer
    lexer_filetype=Python
    tag_parser=Python
    

    For the snippets, here are snippets based on Genie's tutorial. Just add them by navigating the menu to Tools>Configuration files>snippets.conf and add the following:

    [Genie]
    if=if %cursor%a > 0\n\t%cursor%
    ifdo=if %cursor%a > 0 do %cursor%
    else=else if %cursor% is %cursor%\n\t%cursor%
    for=for var %cursor%i = 1 to 10\n\t
    fordo=for %cursor%s in %cursor%args do %cursor%print s
    whiledo=while %cursor% do %cursor%
    while=while %cursor%\n\t%cursor%
    do=%cursor%count:int = 1\ndo\n\t%cursor%print "%i", count\n\tcount++\nwhile %cursor%count <= 10
    case=case %cursor%a\n\twhen %cursor%0,1,2\n\t\t%cursor%print "a is less than 3"\n\twhen %cursor%3 \n\t\t%cursor%print "a is 3"\n\tdefault\n\t\t%cursor%print "a is greater then 3"
    try=try%block%\ncatch (%cursor%)%block_cursor%
    def=def %cursor%(%cursor%a:%cursor%string):%cursor%Type\n\t%cursor%
    class=class %cursor%Foo:%cursor%Object\n\t%cursor%i:int\n\t%cursor%init\n\t\t%cursor%print "something"\n\tfinal\n\t\t%cursor%print "finalizing"\n\tconstruct( %cursor%:%cursor% )\n\t\t%cursor%a=b
    array=%cursor%tokens : array of string = {%cursor%"This", "Is", "Genie"}
    list=var %cursor%l = new list of string\n%cursor%l.add()
    dictstrg=var %cursor%d = new dict of string,string
    dictint=var %cursor%d = new dict of string,int
    try=try\n\t%cursor%fn("home/jamie/test")\nexcept %cursor%ex : %cursor%IOError\n\t%cursor%print "Error: %s", ex.message
    

    I am just a learner, so be free to change it to your will.