Is it possible to customize Atom language recognition based on filename not extension?
I searched a lot, but all are talking about extension-based language recognition. I'm asking this because we are using a certain filename for some purposes, and the content of this file is written in some language, however this file has no extension.
Yes, this is completely possible. In your language package you will very likely have a grammars/language.cson. Inside this cson you will have a fileTypes key with an array value. The values in this array can be extensions or filenames. Check an example here for ruby: https://github.com/atom/language-ruby/blob/master/grammars/ruby.cson#L3 Inside that array we see extensions like rb (ruby script) and gemspec (ruby gemspec). However, we also see full filenames like Gemfile (bundler), Puppetfile (r10k), Rakefile (rake), and Vagrantfile (vagrant). Without looking at the source code, a good guess is that Atom is executing a matcher of whatever is in that array versus the ending of the filename, including but not necessarily with, the extension.
There is a plugin file-types to map a filetype to a new language. You can do this based not only on file extension but also based on filename. Look at "RegExp Matchers" section.
Matt and Dmitry's answers are instructive, here's what I did: First I read Atom's doc about customizing-language-recognition. Originally I thought this only applies to file extension, but actually it also applies to filename. '*' core: customFileTypes: 'source.python': [ 'my file's name' ] Done.
How to disable code highlighting for google code prettify?
TFS2013 web access syntax highlighting
jinja2 syntax highlighting definitions for Panic's Coda 2?
How do I stop my own highlighting while inside another highlighting group?
Vim: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Contained
can't override syntax highlighting in sublime text 3
textpad syntax highlighting confused by apostrophe
Vim: Looking for Help to Create Custom Syntax Highlighting
How to specify syntax highlighting in VI editor
Vim: how to automatically highlight each line containing a keyword?
Parsing Expression Grammar for syntax highlighting
Does a syntax highlighter in an IDE scan the whole file every time a letter is typed?
Nano syntax highlighting rules for D
Sublime Text 3 ABAP Syntax Highlighting / Color scheme
How do I edit the Solarized (Light) theme in Sublime Text 3
Richer Coloring and Typesetting in DDoc Output