syntax-highlighting


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.

Related Links

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

Categories

HOME
asp.net-web-api
scikit-learn
fpga
knitr
cakephp-3.4
visual-studio-emulator
nuget-package
android-json
angularfire2
lanczos
project
augeas
openstreetmap
heap
xcodebuild
selectize.js
esoteric-languages
dynamic-sql
mvc-mini-profiler
git-extensions
symbols
undertow
jquery-ias
string-concatenation
strongname
perlbrew
opentk
pylons
jackson-modules
tpm
boost-asio
custom-controls
autodesk-designautomation
mockjax
kodi
dynamic-jasper
fossil
baidu-map
video-capture
engine.io
hivemq
docfx
xdocreport
verifiable-c
apriori
logback-groovy
drupal-theming
gitlist
fclose
subnet
java-websocket
cmp
py2neo
shinobi
bootstrap-tags-input
grails-plugin
segment-io
async.js
uicolor
beamer
model-associations
mapinfo
sklearn-pandas
html-to-pdf
libav
user-management
opl
morton-number
zen-cart
rubaxa-sortable
opserver
sapscript
dulwich
wso2greg
matlab-deployment
rapidsvn
webmatrix-3
punycode
encryption-asymmetric
accesscontrolexception
visual-studio-express
inappsettingskit
scringo
swfobject
curb
frameworkelementfactory
xcode3.2
pinch
svk
qglwidget
facebook-iframe
ajax-polling
eclipse-marketplace
skype4java
entitykey
movieplayer
appliance

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App