[gnome-builder] Add snippets for ES6 and fix some things



commit 6ba32e4ba8511615cd1301b38ccb17a4e06265dd
Author: Ricardo Silva Veloso <ricvelozo gmail com>
Date:   Sat Jul 28 22:20:25 2018 -0300

    Add snippets for ES6 and fix some things

 data/snippets/c.snippets       |  4 +--
 data/snippets/gobject.snippets | 41 ++++++++++++++++++++++++++++-
 data/snippets/java.snippets    | 50 ++++++++++++++++--------------------
 data/snippets/js.snippets      | 58 +++++++++++++++++-------------------------
 data/snippets/main.snippets    |  2 +-
 data/snippets/python.snippets  | 37 ++++++++++-----------------
 data/snippets/rust.snippets    | 24 ++++++++---------
 7 files changed, 115 insertions(+), 101 deletions(-)
---
diff --git a/data/snippets/c.snippets b/data/snippets/c.snippets
index b5030007f..849293312 100644
--- a/data/snippets/c.snippets
+++ b/data/snippets/c.snippets
@@ -100,7 +100,7 @@ snippet eprintf
 snippet scanf
 - scope c, chdr
 - desc scanf(…)
-       scanf("${1:%d}", ${2:variable});$0
+       scanf("${1:%d}", ${2:&variable});$0
 snippet include
 - scope c, chdr
 - desc Include a file relative to the file or configured include paths
@@ -119,4 +119,4 @@ snippet comment
 - scope c, chdr
        /*
         * $0
-        */
+        */
\ No newline at end of file
diff --git a/data/snippets/gobject.snippets b/data/snippets/gobject.snippets
index 853c13bba..7f641ca67 100644
--- a/data/snippets/gobject.snippets
+++ b/data/snippets/gobject.snippets
@@ -103,6 +103,31 @@ snippet gobject
        $1 *${$1|functify}_new (void);
        $0
        G_END_DECLS
+- scope js
+- desc Create GObject
+       var $1 = GObject.registerClass(
+       class ${1:ClassName} extends ${2:GObject.Object} {
+               _init(${3}) {
+                       super._init();
+                       $0
+               }
+       });
+- scope python
+- desc Create GObject
+       class ${1:ClassName}(${2:GObject.Object}):
+
+               def __init__(self${3:,}):
+                       $2.__init__(self)
+
+       $0
+- scope python3
+- desc Create GObject
+       class ${1:ClassName}(${2:GObject.Object}):
+
+               def __init__(self${3:,}):
+                       super().__init__()
+
+       $0
 snippet gobject_final
 - scope c
 - desc Create GObject for a non-derivable class
@@ -406,6 +431,14 @@ snippet gproperty
                             ${$2|space}   G_PARAM_STATIC_STRINGS));
        g_object_class_install_property (object_class, PROP_$1,
                                         properties [PROP_$1]);
+- scope js
+- desc Add GObject property
+       ${1:foo}: GObject.ParamSpec.${2:int}('$1',
+               '${3:$1|capitalize}', '${4:Property description}',
+               $0),
+- scope python, python3
+- desc Add GObject property
+       ${1:foo} = GObject.Property(type=${2:int}, default=${3:0})$0
 snippet gsignal
 - scope c
 - desc Add GObject signal
@@ -419,6 +452,12 @@ snippet gsignal
                              ${6:g_cclosure_marshal_generic},
                              ${7:G_TYPE_NONE},
                              ${8:0});
+- scope js
+- desc Add GObject signal
+       ${1:signal}: {$0},
+- scope python, python3
+- desc Add GObject signal
+       "${1:signal}": (GObject.SignalFlags.${2:RUN_FIRST}, ${3:None}, (${4:int,}))$0
 snippet async
 - scope c
 - desc Create the async function for an async/finish pair
@@ -511,4 +550,4 @@ snippet fail
 snippet vfail
 - desc Snippet for g_return_val_if_fail()
 - scope c, chdr
-       g_return_val_if_fail 
(${1:`$filename|stripsuffix|functify|namespace|upper`_IS_`$filename|stripsuffix|class|functify|upper` 
(self)}, ${2:NULL});$0
+       g_return_val_if_fail 
(${1:`$filename|stripsuffix|functify|namespace|upper`_IS_`$filename|stripsuffix|class|functify|upper` 
(self)}, ${2:NULL});$0
\ No newline at end of file
diff --git a/data/snippets/java.snippets b/data/snippets/java.snippets
index 2ef738b88..14f4c2872 100644
--- a/data/snippets/java.snippets
+++ b/data/snippets/java.snippets
@@ -1,50 +1,44 @@
-snippet clas
-- desc Create class definition
+snippet class
 - scope java, groovy
+- desc Create class definition
        package ${$relative_dirname|descend_path|descend_path|descend_path|slash_to_dots};
-       
-       public class ${$filename|stripsuffix}
-         {
+
+       public class ${$filename|stripsuffix} {
            $0
-         }
+       }
 snippet iface
-- desc Create interface definition
 - scope java, groovy
+- desc Create interface definition
        package ${$relative_dirname|descend_path|descend_path|descend_path|slash_to_dots};
-       
-       public interface ${$filename|stripsuffix}
-         {
+
+       public interface ${$filename|stripsuffix} {
            $0
-         }
+       }
 snippet psvm
-- desc Creates main java method
 - scope java, groovy
-       public static void main(String[] args)
-         {
+- desc Create main java method
+       public static void main(String[] args) {
            $0
-         }
+       }
 snippet itar
-- desc Create a for loop
 - scope java, groovy
-       for (int ${1:i = 0}; ${2:i < }; ${3:i++})
-         {
+- desc Create a for loop
+       for (int ${1:i = 0}; ${2:i < }; ${3:i++}) {
            $0
-         }
+       }
 snippet iter
-- desc Create a for each loop on a collection
 - scope java, groovy
-       for (${2:type} ${3:var}: ${1:collection})
-         {
+- desc Create a for each loop on a collection
+       for (${2:type} ${3:var}: ${1:collection}) {
            $0
-         }
+       }
 snippet itit
-- desc Create a for loop on an iterator
 - scope java, groovy
-       while (${1:it}.hasNext())
-         {
+- desc Create a for loop on an iterator
+       while (${1:it}.hasNext()) {
            Object next = $1.next();
            $0
-         }
+       }
 snippet comment
 - scope java, groovy
        /*
@@ -60,4 +54,4 @@ snippet sout
        System.out.println($0);
 snippet serr
 - scope java
-       System.err.println($0);
+       System.err.println($0);
\ No newline at end of file
diff --git a/data/snippets/js.snippets b/data/snippets/js.snippets
index 734395a27..ffe9ac2ef 100644
--- a/data/snippets/js.snippets
+++ b/data/snippets/js.snippets
@@ -1,50 +1,39 @@
+snippet import
+       import "${1:./module.js}";
+       $0
+snippet from
+       import ${1:Module} from "${2:./}${3:$1|lower}";
+       $0
+snippet require
+       const ${1:Module} = require("${2:./}${3:$1|lower}");
+       $0
 snippet gi
        const ${1:Gtk} = imports.gi.$1;
        $0
 snippet lang
        const ${1:Lang} = imports.${$1|decapitalize};
        $0
-snippet import
-       const ${1:ModuleName} = imports.${2:path}.${$1|decapitalize};
-       $0
-snippet require
-       const ${1:ModuleName} = require("${$1|lower}");
+snippet imports
+       const ${1:Module} = imports.${2:path}.${$1|decapitalize};
        $0
 snippet class
-       const ${1:ClassName} = new Lang.Class({
-               Name: '$1',
-
-               _init: function () {
-                       $0
-               },
-       });
-snippet gobject
-       const ${1:ClassName} = new Lang.Class({
-               Name: '$1',
-               GTypeName: '${2:$1}',
-               Extends: ${3:GObject.Object},
-
-       ${4:    Properties: {},}
-       ${5:    Signals: {},}
-
-               _init: function (props={}) {
-                       this.parent(props);
+       class ${1:ClassName} {
+               constructor(${2}) {
                        $0
-               },
-       });
-snippet gproperty
-       '${1:foo}': GObject.ParamSpec.${2:int}('$1',
-               '${3:$1|capitalize}', '${4:Property description}',
-               $0),
-snippet gsignal
-       '${1:signal}': {$0},
+               }
+       }
+snippet method
+- desc Create class method
+       ${1:name}(${2}) {
+               $0
+       }
 snippet function
        function ${1:name}(${2}) {
                $0
        }
 snippet arrow
 - desc Create arrow function
-       (${1}) => {
+       ${1:()} => {
                $0
        }
 snippet if
@@ -71,6 +60,7 @@ snippet case
                $0
                break;
 snippet default
+- desc default … break
        default:
                $0
                break;
@@ -97,7 +87,7 @@ snippet try
                $0
        }
 snippet catch
-       catch (${1:e}) {
+       catch (${1:err}) {
                $0
        }
 snippet finally
@@ -117,4 +107,4 @@ snippet error
 snippet info
        console.info("${1:message}");$0
 snippet warn
-       console.warn("${1:message}");$0
+       console.warn("${1:message}");$0
\ No newline at end of file
diff --git a/data/snippets/main.snippets b/data/snippets/main.snippets
index 824969a1c..9429cdd81 100644
--- a/data/snippets/main.snippets
+++ b/data/snippets/main.snippets
@@ -22,4 +22,4 @@ snippet main
 - scope rust
        fn main() {
            $0
-       }
+       }
\ No newline at end of file
diff --git a/data/snippets/python.snippets b/data/snippets/python.snippets
index 31630baa7..888a6f6e5 100644
--- a/data/snippets/python.snippets
+++ b/data/snippets/python.snippets
@@ -8,7 +8,7 @@ snippet import
        import $0
 snippet from
 - scope python, python3
-       from ${1} import $0
+       from ${1:__future__} import $0
 snippet def
 - scope python, python3
        def ${1:function}(${2}):
@@ -22,50 +22,41 @@ snippet class
        
        $0
 snippet if
+- scope python, python3
        if ${1:condition}:
                $0
 snippet else
+- scope python, python3
        else:
                $0
 snippet elif
+- scope python, python3
        elif ${1:condition}:
                $0
 snippet while
+- scope python, python3
        while ${1:condition}:
                $0
 snippet for
+- scope python, python3
        for ${1:item} in ${2:collection}:
                $0
 snippet try
+- scope python, python3
        try:
                $0
 snippet except
+- scope python, python3
        except ${1:Exception}:
                $0
 snippet finally
+- scope python, python3
        finally:
                $0
-snippet lambda
-       lambda ${1:name}: $0
-snippet gobject
-- scope python
-       class ${1:ClassName}(${2:GObject.Object}):
-
-               def __init__(self${3:,}):
-                       $2.__init__(self)
-       
-       $0
-- scope python3
-       class ${1:ClassName}(${2:GObject.Object}):
-
-               def __init__(self${3:,}):
-                       super().__init__()
-       
-       $0
-snippet gsignal
-- desc Entry in __gsignals__ dictionary
+snippet with
 - scope python, python3
-       "${1:signal}": (GObject.SignalFlags.${2:RUN_FIRST}, ${3:None}, (${4:int,}))$0
-snippet gproperty
+       with ${1:expression} as ${2:variable}:
+               $0
+snippet lambda
 - scope python, python3
-       ${1:foo} = GObject.Property(type=${2:int}, default=${3:0})$0
+       lambda ${1:name}: $0
\ No newline at end of file
diff --git a/data/snippets/rust.snippets b/data/snippets/rust.snippets
index 96dc80a4e..683d854ea 100644
--- a/data/snippets/rust.snippets
+++ b/data/snippets/rust.snippets
@@ -187,7 +187,7 @@ snippet whilelet
            $0
        }
 snippet for
-       for ${1:item} in ${2:collection}.iter() {
+       for ${1:item} in ${2:collection.iter()} {
            $0
        }
 snippet loop
@@ -212,7 +212,7 @@ snippet type
        type ${1:Alias} = ${2:Type};$0
 snippet vec
 - desc vec![…]
-       vec![${1:expression}; ${2:size}];$0
+       vec![${1:expression}; ${2:size}]$0
 snippet format_args
 - desc format_args!(…)
        format_args!("${1:{}}", ${2:expression})$0
@@ -221,25 +221,25 @@ snippet format
        format!("${1:{}}", ${2:expression})$0
 snippet write
 - desc write!(…)
-       write!(${1:buffer}, "${2:{}}", ${3:expression});$0
+       write!(${1:buffer}, "${2:{}}", ${3:expression})$0
 snippet writeln
 - desc writeln!(…)
-       writeln!(${1:buffer}, "${2:{}}", ${3:expression});$0
+       writeln!(${1:buffer}, "${2:{}}", ${3:expression})$0
 snippet print
 - desc print!(…)
-       print!("${1:{}}", ${2:expression});$0
+       print!("${1:{}}", ${2:expression})$0
 snippet println
 - desc println!(…)
-       println!("${1:{}}", ${2:expression});$0
+       println!("${1:{}}", ${2:expression})$0
 snippet eprint
 - desc eprint!(…)
-       eprint!("${1:{}}", ${2:expression});$0
+       eprint!("${1:{}}", ${2:expression})$0
 snippet eprintln
 - desc eprintln!(…)
-       eprintln!("${1:{}}", ${2:expression});$0
+       eprintln!("${1:{}}", ${2:expression})$0
 snippet panic
 - desc panic!(…)
-       panic!("${1:{}}", ${2:expression});$0
+       panic!("${1:{}}", ${2:expression})$0
 snippet unreachable
 - desc unreachable!(…)
        unreachable!("${1:reason}")$0
@@ -248,13 +248,13 @@ snippet unimplemented
        unimplemented!()$0
 snippet assert
 - desc assert!(…)
-       assert!(${1:expression});$0
+       assert!(${1:expression})$0
 snippet assert_eq
 - desc assert_eq!(…)
-       assert_eq!(${1:expression1}, ${2:expression2});$0
+       assert_eq!(${1:expression1}, ${2:expression2})$0
 snippet assert_ne
 - desc assert_ne!(…)
-       assert_ne!(${1:expression1}, ${2:expression2});$0
+       assert_ne!(${1:expression1}, ${2:expression2})$0
 snippet testsmod
 - desc Create tests module
        #[cfg(test)]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]