国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Basic Information
Grammar Rules
Match syntax elements
Match multiple elements
Match begin with end and
Home Technology peripherals It Industry How To Develop a Package for GitHub's Atom Code Editor

How To Develop a Package for GitHub's Atom Code Editor

Feb 19, 2025 am 10:20 AM

Atom Editor Extension Guide: Create and publish your own syntax highlighter package

Atom editor is powerful, but sometimes you may need some features that are not provided by default, such as syntax highlighting for a specific language. At this time, it is particularly important to create custom packages. This article will guide you to create a syntax highlighting package and publish it to the Atom community.

How To Develop a Package for GitHub's Atom Code Editor

Core points:

  • Extend the functionality of the Atom editor by creating custom packages, especially for features that are missing by default.
  • Create a folder in the .atom/packages directory and add a valid package.json file to initialize the new package.
  • For syntax highlighting, create a grammars subfolder, define language rules in a CSON file, and specify how Atom recognizes and highlights the language syntax.
  • Test your package in Atom using the View/Reload function to view changes immediately and make sure that the functionality is working.
  • Set up a public repository on GitHub and use the apm publish command to publish your package to the Atom community to benefit other developers.

What will we build?

This article will guide you to create a syntax highlighter similar to language-scilab that you can apply to any language you need. We will learn how to initialize a new package, write syntax highlighting rules, and how to publish your package to the Atom community.

Initialize the new Atom package

Atom uses a configuration file folder called .atom to store personal options and installed packages. Packages are located in the packages subfolder of this folder, and each package has its own folder.

How To Develop a Package for GitHub's Atom Code Editor

The first step is to create your package folder, such as language-mylanguage (this is a naming convention to add language support). Then, create the package.json file in that folder, and Atom can recognize and load it.

How To Develop a Package for GitHub's Atom Code Editor

The following is an example of the language-mylanguage file of a package.json package:

{
  "name": "language-mylanguage",
  "version": "0.0.0",
  "description": "Mylanguage language support in Atom",
  "engines": {
    "atom": "*"
  },
  "dependencies": {},
  "repository": {
    "type": "git",
    "url": "https://github.com/JeremyHeleine/language-mylanguage.git"
  },
  "bugs": {
    "url": "https://github.com/JeremyHeleine/language-mylanguage/issues"
  },
  "license": "MIT"
}

Keyfield explanation:

  • "name": Package name.
  • "version": Version number, following the convention for major, minor, and revised versions. It is recommended to use 0.0.0 in the initial version.
  • "description": Package description.
  • "engines": Atom minimum version requirements.
  • "dependencies": Package dependencies.
  • "repository": The GitHub repository address of the package (can be empty before release).
  • "bugs": Address to report the problem.
  • "license": License.

After creating the package.json file, Atom can recognize your package. You can use the View/Reload command to force Atom to reload the package so that changes are immediately visible.

Create a syntax highlighter package

Create a grammars subfolder in the package folder and create a CSON file named after the language name (for example mylanguage.cson). This file contains syntax highlighting rules.

Basic Information

Before defining grammar rules, you need to tell Atom how to recognize your language:

{
  "name": "language-mylanguage",
  "version": "0.0.0",
  "description": "Mylanguage language support in Atom",
  "engines": {
    "atom": "*"
  },
  "dependencies": {},
  "repository": {
    "type": "git",
    "url": "https://github.com/JeremyHeleine/language-mylanguage.git"
  },
  "bugs": {
    "url": "https://github.com/JeremyHeleine/language-mylanguage/issues"
  },
  "license": "MIT"
}
  • scopeName: Language identifier, used for topics, other packages, or configuration files.
  • name: The language name displayed at the bottom of the Atom editor.
  • fileTypes: The file extension array used by the language.

Grammar Rules

All rules must be declared in the patterns array, each rule is enclosed in {}:

'scopeName': 'source.mylanguage'
'name': 'Mylanguage'
'fileTypes': ['ext1', 'ext2']

Match syntax elements

Match syntax elements using the match attribute, such as matching numbers:

'scopeName': 'source.mylanguage'
'name': 'Mylanguage'
'fileTypes': ['ext1', 'ext2']

'patterns': [
    {
        # 規(guī)則1
    },
    {
        # 規(guī)則2
    }
]

matchUse regular expressions, nameSpecify the style class name, and follow certain naming conventions so that the theme can apply the style correctly.

Match multiple elements

Match multiple elements using the captures attribute, such as matching function declaration:

{
    'match': '\b(([0-9]+\.?[0-9]*)|(\.[0-9]+))\b'
    'name': 'constant.numeric.mylanguage'
}

Match begin with end and

beginMatch the start and end tags using the end and

properties, such as matching single quote strings:
{
    'match': '\b(function)\s+(\w+)\s*\(.*\)'
    'captures': {
        '1': { 'name': 'keyword.control.mylanguage' },
        '2': { 'name': 'entity.name.function.mylanguage' }
    },
    'name': 'meta.function.mylanguage'
}

beginCaptures You can also use endCaptures and patterns to capture the start and end tags, and the

attributes match sub-elements inside the matching element.

Release Atom package

package.json Please check if the package with the same name already exists before publishing it. You need a public GitHub repository. Update the repository address in the

file.

apm publish minorUse the minor command to publish the package (major, patch, and

respectively update the minor version, major version and patch version respectively). This command will register your package name, add version number, create Git tags and push changes.

How To Develop a Package for GitHub's Atom Code Editor

Use the apm unpublish name-of-the-package command to cancel the release package.

Conclusion

This article describes how to create and publish Atom syntax highlighting packages. Atom's flexibility allows the creation of various types of packages, but this article is limited to the creation of syntax highlighted packages. Hope this article helps you expand the functionality of the Atom Editor and share your results with the community.

FAQs (FAQs)

(The FAQs part in the original text is omitted here, because the content of this part is highly repetitive from the above, which is a summary and explanation of the above content. In order to avoid redundancy, repeated output is not performed here.)

The above is the detailed content of How To Develop a Package for GitHub's Atom Code Editor. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The Developer's Shortcut To Your Udemy-like Platform The Developer's Shortcut To Your Udemy-like Platform Jun 17, 2025 pm 04:43 PM

When developing learning platforms similar to Udemy, the focus isn't only on content quality. Just as important is how that content is delivered. This is because modern educational platforms rely on media that is accessible, fast, and easy to digest.

Cost Effective Reseller Platforms for Buying SSL Certificates Cost Effective Reseller Platforms for Buying SSL Certificates Jun 25, 2025 am 08:28 AM

In a world where online trust is non-negotiable, SSL certificates have become essential for every website. The market size of SSL certification was valued at USD 5.6 Billion in 2024 and is still growing strongly, fueled by surging e-commerce business

5 Best Payment Gateways for SaaS: Your Ultimate Guide 5 Best Payment Gateways for SaaS: Your Ultimate Guide Jun 29, 2025 am 08:28 AM

A payment gateway is a crucial component of the payment process, enabling businesses to accept payments online. It acts as a bridge between the customer and the merchant, securely transferring payment information and facilitating transactions. For

New study claims AI 'understands' emotion better than us — especially in emotionally charged situations New study claims AI 'understands' emotion better than us — especially in emotionally charged situations Jul 03, 2025 pm 05:48 PM

In what seems like yet another setback for a domain where we believed humans would always surpass machines, researchers now propose that AI comprehends emotions better than we do.Researchers have discovered that artificial intelligence demonstrates a

Hurricanes and sandstorms can be forecast 5,000 times faster thanks to new Microsoft AI model Hurricanes and sandstorms can be forecast 5,000 times faster thanks to new Microsoft AI model Jul 05, 2025 am 12:44 AM

A new artificial intelligence (AI) model has demonstrated the ability to predict major weather events more quickly and with greater precision than several of the most widely used global forecasting systems.This model, named Aurora, has been trained u

Your devices feed AI assistants and harvest personal data even if they’re asleep. Here's how to know what you're sharing. Your devices feed AI assistants and harvest personal data even if they’re asleep. Here's how to know what you're sharing. Jul 05, 2025 am 01:12 AM

Like it or not, artificial intelligence has become part of daily life. Many devices — including electric razors and toothbrushes — have become AI-powered," using machine learning algorithms to track how a person uses the device, how the devi

Would outsourcing everything to AI cost us our ability to think for ourselves? Would outsourcing everything to AI cost us our ability to think for ourselves? Jul 03, 2025 pm 05:47 PM

Artificial intelligence (AI) began as a quest to simulate the human brain.Is it now in the process of transforming the human brain's role in daily life?The Industrial Revolution reduced reliance on manual labor. As someone who researches the applicat

Advanced AI models generate up to 50 times more CO₂ emissions than more common LLMs when answering the same questions Advanced AI models generate up to 50 times more CO₂ emissions than more common LLMs when answering the same questions Jul 06, 2025 am 12:37 AM

The more precisely we attempt to make AI models function, the greater their carbon emissions become — with certain prompts generating up to 50 times more carbon dioxide than others, according to a recent study.Reasoning models like Anthropic's Claude

See all articles