Sublime Forum

Default syntax mode for files without dot extensions

#1

I’d like to set the default syntax to Ruby for files that do not have dot extensions (e.g. Gemfile, Guardfile). It seems the extensions key in Ruby.sublime-settings files only applies to dot extensions. Rakefile defaults to Ruby syntax, and this seems to be defined in Ruby.tmLanguage. Is there a way to add these other filenames in a user-specific settings file so I don’t have to modify the core tmLanguage file?

Related question: How would I extend this to other types of path/filename pattern matching? Like, if I wanted foo.rb to default to Ruby but foo_spec.rb to default to RSpec.

Thanks!

1 Like

#2

i would also love to see a solution for this!

0 Likes

#3

I am also interested in this. Anyone add this to the uservoice site?

I like the idea of a regex on filename or path. I have used similar functionality with vim.

0 Likes

#4

Currently the only way to add an association for extensionless files is directly in the .tmLanguage file

0 Likes

#5

This would be a huge feature for rails devs :smile:

0 Likes

#6

the SetSyntax plugin will do this. I am patching a fork that will add directory matching. Not sure if I want to do regex, or just list of literal strings.

I am leaning towards literal strings, for simplicity.

0 Likes

#7

Submit the patch as a pull request, I’ll be happy to integrate it.

0 Likes

#8

I think for the time being I am going to have to put St2 up and get back to vim. It is way too dynamic right now and I am spending too much non-project time fiddling with it. I’ll check back in a few releases.

0 Likes