Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
/ dart-snippets Public archive

YASnippets for Dart and Flutter (a part of DOOM-SNIPPETS now)

License

Notifications You must be signed in to change notification settings

Davoodeh/dart-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YASnippets for Dart and Flutter

License GPL 3

This is the complete collection of YASnippets for Dart and its popular framework Flutter. It also features snippets from the VSCode plugin (Dart-Code) and YASnippet-snippets!

Installation

Vanilla Emacs

To use these snippets you need to install the YASnippet package. Once you have YASnippet installed, place contents of this repository on your load path, so Emacs can see it and add the following to your configuration file:

(require 'dart-snippets)

Doom Emacs

As of March 26, these snippets are a part of Doom-snippets package. If you are using it, just update your Doom with doom upgrade and you are good to go.

To install the package on Doom Emacs, all you have to do is to append the lines below to your $DOOMDIR/packages.el (Default is: ~/.doom.d/packages.el).

(package! dart-snippets
    :recipe (:host github
                   :repo "MYDavoodeh/dart-snippets"
                   :files ("*.el" ("snippets" "snippets/*"))))

Usage

To insert a snippet, type its name and press ↹ Tab or C-i.

Also, you can move through the fields pressing ↹ Tab and edit or delete them -- in case snippet has a default value.

Contributions

There are some stylistic conventions:

  • Name files without extensions.

  • Start every file with this preamble:

    # -*- mode: snippet -*-
    # contributor: your name
    # name: readable name of the snippet
    # key: what user needs to enter
    # --
    

    The first line is needed to activate mode for snippet editing in Emacs, Yasnippet ships with it.

  • If the snippet works only in Dart or Flutter, declare its group in your preamble by appending such line as below:

    # group: dart | flutter
    
  • Make sure your files don't have an empty line at the end. This is important, because it will be inserted when your snippet is expanded. snippet-mode takes care of this, setting require-final-newline to nil, just make sure you haven't put it there manually.

Notes

MELPA?

The package is intended to be used with Doom Emacs. Therefore, I don't plan to merge it with YASnippet-snippets nor to add it to MELPA.

Honestly, even if I wanted I cannot add it to MELPA, since the idea of Dart-Snippets is not so original. Also, I didn't want to add them to YASnippet-snippets, because Doom uses Doom-snippets.

Other useful packages

You may also find Dart-Mode and Flutter.el/-Mode packages useful.

You can install the packages above just by uncommenting/adding :lang (dart +flutter) in your $DOOMDIR/init.el (Default is: ~/.doom.d/init.el).

License

Copyright © 2020 Mohammad Yasin Davoodeh

Distributed under GNU GPL, version 3.