GithubHelp home page GithubHelp logo

anasanzari / atom-modular-snippets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielbayley/atom-modular-snippets

0.0 1.0 0.0 16 KB

A modular solution to snippets in @Atom.

Home Page: https://atom.io/packages/modular-snippets

License: MIT License

CoffeeScript 98.31% JavaScript 1.69%

atom-modular-snippets's Introduction

badge badge

Modular Snippets

A modular solution to snippets in Atom, including support for project-specific collections.

Any valid snippets [CSON or JSON] file inside ATOM_HOME/snippets/** will be loaded automatically, or reloaded if modified.

This package does not interfere with the existing snippets.cson, so you can slowly transition to this more modular approach.

The Atom Snippets… menu item will be overridden to open your snippets folder in a new window, along with the default snippets.cson if it still exists.

The Atom Snippets… menu item will be overridden to open your snippets folder in a new window, along with the default snippets.cson if it still exists.

Project Snippets

Some snippets might only be relevant to a particular project, so it makes sense to store them with that project; these could then be committed to version control and shared between a team. These local snippets are loaded from the first item found in the root of your project based on the following order:

  • [.]snippets.cson
  • [.]snippets/**/*.cson
  • snippets: {object} in package.json
  • snippets: {object} in your project-config

API

This package also provides a service to load any snippets {object}, file or folder…

// package.json
"consumedServices": {
  "modular-snippets": {
    "versions": {
      "^1.0.0": "consume"
    }
  }
},
# index.coffee
{Disposable} = require 'atom'

snippet = # {object}, file or folder.
  '.source.coffee':
    Snippet:
      prefix: 'prefix'
      body: 'snippet'

consumeSnippets: ({load}) ->
  load snippet
  new Disposable -> stopUsingService load

or using ES6 if you’re into that…

// index.js
'use babel';

import { Disposable } from 'atom';

let snippet = { // object }, file or folder.
  '.source.js': {
    Snippet: {
      prefix: 'prefix',
      body: 'snippet'
    }
  }
};

function consumeSnippets({load} => {
  load(snippet);
  return new Disposable(() => stopUsingService(load));
}

Install

apm install modular-snippets or search “snippets” under packages within Atom.

License

MIT © Daniel Bayley

Thanks to @thibmaek for the base repository.

atom-modular-snippets's People

Contributors

anasanzari avatar danielbayley avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.