• Packages
  • Themes
  • Documentation
  • Blog
  • Discuss

Chapter 1: Getting Started

  • Why Atom?
  • Installing Atom
  • Atom Basics
  • Summary

Chapter 2: Using Atom

  • Atom Packages
  • Moving in Atom
  • Atom Selections
  • Editing and Deleting Text
  • Find and Replace
  • Snippets
  • Autocomplete
  • Folding
  • Panes
  • Pending Pane Items
  • Grammar
  • Version Control in Atom
  • GitHub package
  • Writing in Atom
  • Basic Customization
  • Summary

Chapter 3: Hacking Atom

  • Tools of the Trade
  • The Init File
  • Package: Word Count
  • Package: Modifying Text
  • Package: Active Editor Info
  • Creating a Theme
  • Creating a Grammar
  • Creating a Legacy TextMate Grammar
  • Publishing
  • Iconography
  • Debugging
  • Writing specs
  • Handling URIs
  • Cross-Platform Compatibility
  • Converting from TextMate
  • Hacking on Atom Core
  • Contributing to Official Atom Packages
  • Creating a Fork of a Core Package in atom/atom
  • Maintaining a Fork of a Core Package in atom/atom
  • Summary

Chapter 4: Behind Atom

  • Configuration API
  • Keymaps In-Depth
  • Scoped Settings, Scopes and Scope Descriptors
  • Serialization in Atom
  • Developing Node Modules
  • Interacting With Other Packages Via Services
  • Maintaining Your Packages
  • How Atom Uses Chromium Snapshots
  • Summary

Reference: API

  • AtomEnvironment
  • BufferedNodeProcess
  • BufferedProcess
  • Clipboard
  • Color
  • CommandRegistry
  • CompositeDisposable
  • Config
  • ContextMenuManager
  • Cursor
  • Decoration
  • DeserializerManager
  • Directory
  • DisplayMarker
  • DisplayMarkerLayer
  • Disposable
  • Dock
  • Emitter
  • File
  • GitRepository
  • Grammar
  • GrammarRegistry
  • Gutter
  • HistoryManager
  • KeymapManager
  • LayerDecoration
  • MarkerLayer
  • MenuManager
  • Notification
  • NotificationManager
  • Package
  • PackageManager
  • Pane
  • Panel
  • PathWatcher
  • Point
  • Project
  • Range
  • ScopeDescriptor
  • Selection
  • StyleManager
  • Task
  • TextBuffer
  • TextEditor
  • ThemeManager
  • TooltipManager
  • ViewRegistry
  • Workspace
  • WorkspaceCenter

Appendix A: Resources

  • Glossary

Appendix B: FAQ

  • Is Atom open source?
  • What does Atom cost?
  • What platforms does Atom run on?
  • How can I contribute to Atom?
  • Why does Atom collect usage data?
  • Atom in the cloud?
  • What's the difference between an IDE and an editor?
  • How can I tell if subpixel antialiasing is working?
  • Why is Atom deleting trailing whitespace? Why is there a newline at the end of the file?
  • What does Safe Mode do?
  • I have a question about a specific Atom community package. Where is the best place to ask it?
  • I’m using an international keyboard and keys that use AltGr or Ctrl+Alt aren’t working
  • I’m having a problem with Julia! What do I do?
  • I’m getting an error about a “self-signed certificate”. What do I do?
  • I’m having a problem with PlatformIO! What do I do?
  • How do I make Atom recognize a file with extension X as language Y?
  • How do I make the Welcome screen stop showing up?
  • How do I preview web page changes automatically?
  • How do I accept input from my program or script when using the script package?
  • I am unable to update to the latest version of Atom on macOS. How do I fix this?
  • I’m trying to change my syntax colors from styles.less, but it isn’t working!
  • How do I build or execute code I've written in Atom?
  • How do I uninstall Atom on macOS?
  • macOS Mojave font rendering change
  • Why does macOS say that Atom wants to access my calendar, contacts, photos, etc.?
  • How do I turn on line wrap?
  • The menu bar disappeared, how do I get it back?
  • How do I use a newline in the result of find and replace?
  • What is this line on the right in the editor view?

Appendix C: Shadow DOM

  • Removing Shadow DOM styles

Appendix D: Upgrading to 1.0 APIs

  • Upgrading Your Package
  • Upgrading Your UI Theme Or Package Selectors
  • Upgrading Your Syntax Theme

Appendix E: Atom server-side APIs

  • Atom package server API
  • Atom update server API

  • mac
  • windows
  • linux

GitRepository Extended

Represents the underlying git operations performed by Atom.

This class shouldn’t be instantiated directly but instead by accessing the atom.project global and calling getRepositories(). Note that this will only be available when the project is backed by a Git repository.

This class handles submodules automatically by taking a path argument to many of the methods. This path argument will determine which underlying repository is used.

For a repository with submodules this would have the following outcome:

repo = atom.project.getRepositories()[0]
repo.getShortHead() # 'master'
repo.getShortHead('vendor/path/to/a/submodule') # 'dead1234'

Examples

Logging the URL of the origin remote

git = atom.project.getRepositories()[0]
console.log git.getOriginURL()

Requiring in packages

[GitRepository](../GitRepository/) = require 'atom'

Construction and Destruction

.open(path, options)

Creates a new GitRepository instance.

Argument Description

path

The String path to the Git repository to open.

options

An optional Object with the following keys:

refreshOnWindowFocus

A Boolean, true to refresh the index and statuses when the window is focused.

Return values

Returns a GitRepository instance or null if the repository could not be opened.

::destroy()

Destroy this GitRepository object.

This destroys any tasks and subscriptions and releases the underlying libgit2 repository handle. This method is idempotent.

::isDestroyed()

Return values

Returns a Boolean indicating if this repository has been destroyed.

::onDidDestroy(callback)

Invoke the given callback when this GitRepository’s destroy() method is invoked.

Argument Description

callback

Function

Return values

Returns a Disposable on which .dispose() can be called to unsubscribe.

Event Subscription

::onDidChangeStatus(callback)

Invoke the given callback when a specific file’s status has changed. When a file is updated, reloaded, etc, and the status changes, this will be fired.

Argument Description

callback

Function

event

Object

path

String the old parameters the decoration used to have

pathStatus

Number representing the status. This value can be passed to ::isStatusModified or ::isStatusNew to get more information.

Return values

Returns a Disposable on which .dispose() can be called to unsubscribe.

::onDidChangeStatuses(callback)

Invoke the given callback when a multiple files’ statuses have changed. For example, on window focus, the status of all the paths in the repo is checked. If any of them have changed, this will be fired. Call ::getPathStatus to get the status for your path of choice.

Argument Description

callback

Function

Return values

Returns a Disposable on which .dispose() can be called to unsubscribe.

Repository Details

::getType()

A String indicating the type of version control system used by this repository.

Return values

Returns "git".

::getPath()

Return values

Returns the String path of the repository.

::getWorkingDirectory()

Return values

Returns the String working directory path of the repository.

::isProjectAtRoot()

Return values

Returns true if at the root, false if in a subfolder of the repository.

::relativize()

Makes a path relative to the repository’s working directory.

::hasBranch()

Return values

Returns true if the given branch exists.

::getShortHead(path)

Retrieves a shortened version of the HEAD reference value.

This removes the leading segments of refs/heads, refs/tags, or refs/remotes. It also shortens the SHA-1 of a detached HEAD to 7 characters.

Argument Description

path

An optional String path in the repository to get this information for, only needed if the repository contains submodules.

Return values

Returns a String.

::isSubmodule(path)

Is the given path a submodule in the repository?

Argument Description

path

The String path to check.

Return values

Returns a Boolean.

::getAheadBehindCount(reference, path)

Argument Description

reference

The String branch reference name.

path

The String path in the repository to get this information for, only needed if the repository contains submodules.

Return values

Returns the number of commits behind the current branch is from the its upstream remote branch.

::getCachedUpstreamAheadBehindCount(path)

Get the cached ahead/behind commit counts for the current branch’s upstream branch.

Argument Description

path

An optional String path in the repository to get this information for, only needed if the repository has submodules.

Return values

Returns an Object with the following keys:

  • ahead The Number of commits ahead.
  • behind The Number of commits behind.

::getConfigValue(key, path)

Argument Description

key

The String key for the configuration to lookup.

path

An optional String path in the repository to get this information for, only needed if the repository has submodules.

Return values

Returns the git configuration value specified by the key.

::getOriginURL(path)

Argument Description

path

optional

String path in the repository to get this information for, only needed if the repository has submodules.

Return values

Returns the origin url of the repository.

::getUpstreamBranch(path)

Argument Description

path

An optional String path in the repo to get this information for, only needed if the repository contains submodules.

Return values

Returns the upstream branch for the current HEAD, or null if there is no upstream branch for the current HEAD.

Returns a String branch name such as refs/remotes/origin/master.

::getReferences(path)

Gets all the local and remote references.

Argument Description

path

An optional String path in the repository to get this information for, only needed if the repository has submodules.

Return values

Returns an Object with the following keys:

  • heads An Array of head reference names.
  • remotes An Array of remote reference names.
  • tags An Array of tag reference names.

::getReferenceTarget(reference, path)

Argument Description

reference

The String reference to get the target of.

path

An optional String path in the repo to get the reference target for. Only needed if the repository contains submodules.

Return values

Returns the current String SHA for the given reference.

Reading Status

::isPathModified(path)

Argument Description

path

The String path to check.

Return values

Returns true if the given path is modified.

Returns a Boolean that’s true if the path is modified.

::isPathNew(path)

Argument Description

path

The String path to check.

Return values

Returns true if the given path is new.

Returns a Boolean that’s true if the path is new.

::isPathIgnored(path)

Is the given path ignored?

Argument Description

path

The String path to check.

Return values

Returns a Boolean that’s true if the path is ignored.

::getDirectoryStatus(path)

Get the status of a directory in the repository’s working directory.

Argument Description

path

The String path to check.

Return values

Returns a Number representing the status. This value can be passed to ::isStatusModified or ::isStatusNew to get more information.

::getPathStatus(path)

Get the status of a single path in the repository.

Argument Description

path

A String repository-relative path.

Return values

Returns a Number representing the status. This value can be passed to ::isStatusModified or ::isStatusNew to get more information.

::getCachedPathStatus(path)

Get the cached status for the given path.

Argument Description

path

A String path in the repository, relative or absolute.

Return values

Returns a status Number or null if the path is not in the cache.

::isStatusModified(status)

Argument Description

status

A Number representing the status.

Return values

Returns true if the given status indicates modification.

Returns a Boolean that’s true if the status indicates modification.

::isStatusNew(status)

Argument Description

status

A Number representing the status.

Return values

Returns true if the given status indicates a new path.

Returns a Boolean that’s true if the status indicates a new path.

Retrieving Diffs

::getDiffStats(path)

Retrieves the number of lines added and removed to a path.

This compares the working directory contents of the path to the HEAD version.

Argument Description

path

The String path to check.

Return values

Returns an Object with the following keys:

  • added The Number of added lines.
  • deleted The Number of deleted lines.

::getLineDiffs(path, text)

Retrieves the line diffs comparing the HEAD version of the given path and the given text.

Argument Description

path

The String path relative to the repository.

text

The String to compare against the HEAD contents

Return values

Returns an Array of hunk Objects with the following keys:

  • oldStart The line Number of the old hunk.
  • newStart The line Number of the new hunk.
  • oldLines The Number of lines in the old hunk.
  • newLines The Number of lines in the new hunk

Checking Out

::checkoutHead(path)

Restore the contents of a path in the working directory and index to the version at HEAD.

This is essentially the same as running:

  git reset HEAD -- <path>
  git checkout HEAD -- <path>
Argument Description

path

The String path to checkout.

Return values

Returns a Boolean that’s true if the method was successful.

::checkoutReference(reference, create)

Checks out a branch in your repository.

Argument Description

reference

The String reference to checkout.

create

A Boolean value which, if true creates the new reference if it doesn’t exist.

Return values

Returns a Boolean that’s true if the method was successful.

  • Terms of Use
  • Privacy
  • Code of Conduct
  • Releases
  • FAQ
  • Contact
  • Contribute!
with by