Giter VIP home page Giter VIP logo

atom-file-types's Introduction

file-types package

Installs! Version! License

Specify additional file types for languages.

Note: A subset of this functionality is now available directly in Atom--see Customizing Language Recognition in the Flight Manual.

Matchers

To map a filetype to a different language, use the file-types option in your config.json (via the Atom -> Config... menu). Specify a pattern to match for the key (in bash-like glob format) and the new scope name for the value.

For example, the .hbs extension defaults to the handlebars grammar. To override this to the text.html.htmlbars grammar (provided by the separately installable html-htmlbars), add the following rule to your config.cson:

"*":  # Be sure to put "file-types" under the "*" key
  "file-types":
    "*.hbs": "text.html.htmlbars"

Use the double-star-and-slash notation (** and /) to match against the whole path.

"*":
  "file-types":
    "**/app/tmpl/*.hbs": "text.html.htmlbars"
    "**/text_files/*": "text.plain"

Precedence

The longest glob is given precedence.

For example, with the following settings, all three globs end in .liquid.

"*":
  "file-types":
    "*.css.liquid": "source.css"
    "*.liquid": "text.html.basic"
    "*.scss.liquid": "source.css.scss"

Both *.liquid and *.css.liquid would match a file named super_awesome_file.css.liquid; however, since *.css.liquid is longest, it wins and the source.css scope name would be used.

This is usually not a problem unless multiple globs of equal length match the filename. When that happens, a warning is displayed and the scope name associated with the "alphabetically last" glob is used.

Consider the following settings:

"*":
  "file-types":
    "*_spec.rb": "source.ruby.rspec"
    "*_sp?c.rb": "text.plain"

Both of these would match a file named super_controller_spec.rb; however, *_spec.rb would win because when sorted alphabetically, it comes last (i.e., "*_sp?c.rb" < "*_spec.rb").

Scope Names

The scope name for a grammar can be found in the settings for the corresponding language package. For example, the scope name for CoffeeScript's grammar (as provided by the language-coffee-script package) is source.coffee.

To get a list of all scope names registered in your Atom instance, open the Developer Tools Console and execute the following:

Object.keys(atom.grammars.grammarsByScopeName).sort().join('\n')

Here is a list of the scope names available by default in Atom v1.8.0:

  • source.c
  • source.cake
  • source.clojure
  • source.coffee
  • source.coffee.jsx
  • source.cpp
  • source.cs
  • source.css
  • source.css.less
  • source.css.scss
  • source.csx
  • source.gfm
  • source.git-config
  • source.go
  • source.gotemplate
  • source.java
  • source.java-properties
  • source.js
  • source.js.jsx
  • source.js.rails source.js.jquery
  • source.js.regexp
  • source.js.regexp.replacement
  • source.json
  • source.litcoffee
  • source.makefile
  • source.nant-build
  • source.objc
  • source.objcpp
  • source.perl
  • source.perl6
  • source.plist
  • source.python
  • source.regexp.python
  • source.ruby
  • source.ruby.rails
  • source.ruby.rails.rjs
  • source.sass
  • source.shell
  • source.sql
  • source.sql.mustache
  • source.sql.ruby
  • source.strings
  • source.toml
  • source.yaml
  • text.git-commit
  • text.git-rebase
  • text.html.basic
  • text.html.erb
  • text.html.gohtml
  • text.html.jsp
  • text.html.mustache
  • text.html.php
  • text.html.ruby
  • text.hyperlink
  • text.junit-test-report
  • text.plain
  • text.plain.null-grammar
  • text.python.console
  • text.python.traceback
  • text.shell-session
  • text.todo
  • text.xml
  • text.xml.plist
  • text.xml.xsl

Caveats

You probably don't want to assign the same file type to multiple languages...

atom-file-types's People

Contributors

atibatim avatar execjosh avatar holyjak avatar in-in avatar knuthelland avatar samselikoff avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.