GitHub Atom: How to apply a particular syntax highlighting to some files based on name

前端 未结 4 2038
广开言路
广开言路 2021-02-19 04:48

How can I configure GitHub\'s Atom to make it automatically set a particular syntax highlighting to filenames based on name and/or extensions?

Specific

相关标签:
4条回答
  • 2021-02-19 05:15

    As of this writing, there is no way to do this short of submitting a PR to the language-ruby package or creating your own fork of the language-ruby package.

    There is a bug tracking this issue here: https://github.com/atom/atom/issues/1718

    0 讨论(0)
  • 2021-02-19 05:15

    Anyone arriving here looking to add support for template files in php e.g. .tpl, the folloing works in atom 1.10.2. I do not have previous versions so I can't say about earlier versions.

    Add this in your config (config.cson) after core:. I added it after audioBeep: false line.

    customFileTypes:
       "text.html.php": [
        "tpl"
       ]
    

    Documentation made me go around in circles. Several articles wrongly mention source.php where as it should be text.html.php

    Just getting started with atom coming from npp++ basically as I have struggled with snippet support there and hope atom can do a good job.

    0 讨论(0)
  • 2021-02-19 05:22

    As of Atom 1.0.8 this is now possible without the file-types package, using a core feature. To achieve this, open the config.cson file, and add a section like the following:

    "*": # Other config core: customFileTypes: "source.ruby": [ "Podfile" ]

    There is guidance on finding the language scope name here: https://flight-manual.atom.io/using-atom/sections/basic-customization/#finding-a-languages-scope-name


    This is now possible with the file-types third-party package. I used the following syntax:

    "*": # Other config "file-types": "^Podfile$": "source.ruby"

    This should be placed in the config.cson file.

    Here's an excerpt from the readme:

    file-types package

    Specify additional file types for languages.

    Extension Matchers

    Drop the dot before the extension to use extension matchers.

    For example, you can associate .ex_em_el with text.xml in your config.cson as follows:

    'file-types': 'ex_em_el': 'text.xml'

    RegExp Matchers

    You can match with regular expressions, too. Most JavaScript regular expressions should work; but, the system looks for a dot (.), a caret (^) at the start, or a dollar ($) to identify RegExp matchers.

    For example, you can associate /.*_steps\.rb$/ with source.cucumber.steps in your config.cson as follows:

    'file-types': '_steps\\.rb$': 'source.cucumber.steps'

    NOTE: Extension Matchers take priority over RegExp Matchers.

    0 讨论(0)
  • 2021-02-19 05:29

    To add to Maurice Kelly's answer (my reputation is too low to comment) This is now documented at:

    https://github.com/atom/flight-manual.atom.io/blob/681c7fe6e69f1f64396ecadfde1323a01e7f5b96/book/02-using-atom/sections/06-customizing.asc

    0 讨论(0)
提交回复
热议问题