Skip to content

Commit

Permalink
Make snippets available when outside of Ruby
Browse files Browse the repository at this point in the history
Closes #26

These snippets are really like "start me out with a template", they
aren't intended to be used in the middle of an existing document. As
such, it's very common to try expanding them in a new window, before
setting the language to Ruby. There is no visual information that it's
wrong in this case (ie missing syntax highlighting), so it just looks
like SiB is broken.

I could blame the user, but this is bad UX on my part, I should treat
them like templates rather than snippets and just make them always
available.

The risk of collision is mitigated since the names are all likely to be
unique.

It would be really nice if, after expanding, we could set the language
to Ruby, just in case the user did do this, we now know that the lang
should be Ruby, so take care of that for them instead of requiring them
to realize the highlighting is off, figure out why and figure out how to
change it (eg a lot of users save the file because it has this same
filetype inference behaviour and they don't realize they can just set it
in the editor). This is the second time today I've wanted some behaviour
like this, I opened an issue requesting the ability to do it at
atom/snippets#221
  • Loading branch information
JoshCheek committed Oct 28, 2016
1 parent ec695a1 commit 6dc6feb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion snippets/seeing-is-believing.cson
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'.source.ruby':
'*':
'In memory ActiveRecord bootstrap':
'prefix': 's_arb'
'body': 'require \'active_record\'\nrequire \'logger\'\n\nActiveRecord::Base.establish_connection adapter: \'sqlite3\', database: \':memory:\'\nActiveRecord::Base.logger = Logger.new \$stdout\nActiveSupport::LogSubscriber.colorize_logging = false\n\nActiveRecord::Schema.define do\n self.verbose = false\n \n create_table :users do |t|\n t.string :name\n end\n \n create_table :posts do |t|\n t.string :name\n t.integer :user_id\n end\nend\n\nclass User < ActiveRecord::Base\n has_many :posts\nend\n\nclass Post < ActiveRecord::Base\n belongs_to :user\nend\n\nuser = User.create! name: \'Josh\'\nuser.posts = [Post.new(name: \'yo ho ho\'), Post.new(name: \'and a bottle of rum\')]\n'
Expand Down

0 comments on commit 6dc6feb

Please sign in to comment.