Skip to content

Instantly share code, notes, and snippets.

@gorbiz
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save gorbiz/da398b5038d7b58d06ae to your computer and use it in GitHub Desktop.

Select an option

Save gorbiz/da398b5038d7b58d06ae to your computer and use it in GitHub Desktop.
Hydro­gen - Multi purpose editor

Hydro­gen - Multi purpose editor

code-mirror & node-webkit based.

Open a project

hydro some/folder

Project config

Put a .hydro.coffee in project root. It may look ~like:

fs     = require 'fs'
coffee = require 'coffee-script'
{exec} = require 'child_process'

module.exports = (editor) ->

  # compile CoffeeScript to lib folder
  editor.on 'change', (instance, changeObj) ->
    return unless instance.file.ext is 'coffee'
    coffee.compile instance.getValue(), (js) ->
      fs.writeFile "lib/#{instance.file.base}.js", js, (err) ->

  # refresh chrome on file change
  url = "file://" + fs.currentPath() + "/index.html"
  editor.on 'change', (instance, changeObj) ->
    fs.writeFile instance.file, instance.getValue(), (err) ->
      exec "chromix load #{url}", (err, stdout, stderr) ->

User config

~/.config/hydrogen/user.coffee - works like the one above, ex:

exports.options =
  theme: 'solarized dark'
  lineNumbers: true
  # ...

exports.init = (editor) ->

  config =
    coffee:
      mode: 'coffee'
      # use coffee-lint
    md:
      mode: 'markdown'
      theme: 'solarized light'
      extraKeys: null # TODO Ctrl+B bolds and so on...
      # TODO live preview in the browser...

  editor.on 'swapDoc', (instance, oldDoc) ->
    if instance.file.ext in config
      instance.setOptions config[instance.file.ext]

No tabs

Instead: easy to [re]open recent & any file.

Doesn't exist yet

...or does it?

Dr. Manhattan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment