Open xeron opened 9 years ago
Sometimes it works as expected, sometimes it doesn't. Looks like some sort of race condition here?
Yes, there's a race condition since both the HTML (Rails)
and HTML (Ruby - ERB)
grammars match files ending in .html.erb
. Related: #3 and atom/atom#2734
There has been a package to work around this by allowing you to match file types to grammars (file-types), but it broke some time ago. Working off the workaround at execjosh/atom-file-types#17, I've put the following in my init.coffee
that fixed the issue:
atom.workspace.observeTextEditors (editor) ->
path = editor.getPath()
return unless path?
fileTypes =
'.html.erb': 'text.html.ruby'
for extension of fileTypes when \
path.toLowerCase().endsWith(extension.toLowerCase()) and
(longestExtension ? "").length < extension.length
longestExtension = extension
return unless longestExtension?
g = atom.grammars.grammarForScopeName fileTypes[longestExtension]
return unless g?
editor.setGrammar g
By adding to the fileTypes
object, you can do more workaround for other file types.
In my case this also affect models, controllers, helpers and migrations. Reopening of projects helps sometimes (even w/o restart of Atom). But this is always random. And while project is opened it's always persistent, so all files being opened with Ruby or with Rails syntax, but never mix of both.
Steps to reproduce are like that:
Oh, yes, now I'm noticing that. You can just add '.rb': 'source.ruby.rails'
to the fileTypes
from my workaround to fix that too.
May be related to https://github.com/atom/first-mate/issues/17
a config like this should work on atom 1.0.8+:
"*":
core:
customFileTypes:
"text.html.ruby": [
"erb"
]
I'm experiencing this with Atom 1.12.2: controller files are being recognized as Ruby rather than Rails files.
I encounter the same problem as @jamieorc on MacOS
Same here with Atom MacOS 1.19.2 (I think that it never worked properly since the beta versions, though). I recently discovered that disabling the language-ruby
package and enabling it again, it starts working properly.
Still encountering this issue.
Atom: 1.32 Mac OS: 10.14 only had encountered issue with this particular version recently, and have to work around with what ~@alepore proposed~ @mcelicalderon proposed below 👇 which is editting config.cson
"*":
core:
customFileTypes:
"source.ruby.rails": [
"rb"
]
This is what fixed it for me, slightly different to @alepore 's solution. On your ~/.atom./config.cson
file, add:
"*":
core:
customFileTypes:
"source.ruby.rails": [
"rb"
]
This is what fixed it for me, slightly different to @alepore 's solution. On your
~/.atom./config.cson
file, add:"*": core: customFileTypes: "source.ruby.rails": [ "rb" ]
This solution is a temp fix. For example it will not handle syntax highlight in Gemfile for rails
But works fine for *.rb
files
@zhisme to workaround with Gemfile
as well as rake
file type, just add more file types into the config
"*":
core:
customFileTypes:
"source.ruby.rails": [
"rb"
"rake"
"Gemfile"
]
I disagree that this needs reproduction, seems like people continue to have problems with this, and on my part I have never across a variety of operating systems and Atom version been able to have my Rails projects ruby files highlight with this ruby-on-rails format instead of the default Ruby one. Surely this can be fixed instead of having to add a special config to every rails project?
When I reported this bug it was random between Ruby and ROR syntax. With the current version it's always Ruby I think. I don't use Atom anymore tho and this bug is one of the reasons.
Still not fixed :(
Atom: 0.208.0 OSX: 10.10.3
I've tried controllers, models, helpers and migrations. Always Ruby. Same issue with
atom --safe
.