In a previous blog post I looked at Atom and PlatformIO, how to install and how to create and run a project for one of the 200+ supported MCU boards. But the true power of this development platform comes from its extensibility, including syntax highlighting, Git integration, custom board and platform definitions and simple project management.

Let's have a quick look at some of the extensions I've added to improve my 'productivity and workflow'... ;o)

Atom extension packages

Atom is all about extensibility. It comes with dozens of extensions included out-of-the-box and there is a huge collection of extensions available in the Atom packages repository, 4,327 as I write this article. There are two ways to install them: through the menu (File -> Settings -> + Install) or through the command line (apm install ). With both methods you can search for packages (apm search when using the command line) When using apm you have the option to choose a specific version of the package, in this way:

apm install <package_name>@<package_version>

I have noticed that some packages fail to install through the settings pane (or at least give an error), but install just fine when using the command line. So if you get an error installing a package that way, try the command line approach.

Version control in Atom

Version control is a must for any kind of programming that goes beyond a "Hello, World." program. Atom has built-in support for Git and reads the configuration from the .git directory. On the right side of the status bar you can see the currently checked out branch, the commits delta, and an icon showing if the file is modified or untracked (light orange or green).

Although Atom comes with basic Git commands built-in, I recommend to install the git-plus package as it has very simple and powerful features. There are keyboard shortcuts for most commands, but as long as I don't memorize them, I will also use the command window (ctrl-shift-P). Some basic Git commands are:

git status  - get  list of untracked/modified files in current project
git add - add the current file to the local repository
git add all - add all untracked/modified files to the local repository
git commit - commit our changes
git push - sync committed changes with the current branch

The git commit command brings up a window where we can type our commit comments and save the file (ctrl-S) to perform the actual commit. In the tree view of the project the modified and untracked files are shows using light orange for modified files and green for untracked files. If you type git plus in the command windows you get a list of all the commands available.

Basic Git workflow

For those not very familiar with Git, I will summarize a basic workflow for using GitHub as repository:

  • Download and install Git (Windows users could use Git for Windows) and make sure it is included in the PATH.
  • Create a repository on GitHub (you need an account).
  • Do git clone to get the initial repository in your local (empty) project directory.
  • Add or change files as needed with Atom in the local repository.
  • Watch the files changing color in the tree view of Atom and notice the Git status icon at the bottom right.
  • Perform a git add or git add all to add them to the list of files to commit.
  • Once satisfied do a git commit to commit the changes to the local Git repository.
  • To sync the committed changes with the GitHub repository do a git push.

More complex workflows include creating branches to develop separately from the master branch that allows you to work together on the project or to test some changes you can later merge with the main branch, or discard. And you can work in parallel on both branches. But that's all way beyond the scope of this simple introduction.

Syntax coloring and autocomplete

One of the basic functions of an IDE editor is to help you write syntactically correct code. This is usually accomplished through syntax highlighting: recognizing statements, variables, parameters and structures that have a meaning for a certain language and give them distinguishing colors. It is often amended with code completion, recognizing what you want to type from the first few characters. Obviously, this is language specific and requires definitions for different languages. Atom comes with a lot of languages supported and there is even support for Markdown syntax highlighting in Atom. Note that there is no syntax coloring or autocomplete for assembler languages available.

The autocomplete-plus package included with Atom brings suggestions, syntax coloring and snippets for many languages. And since it can work with extension, there is virtually no limit to what it can support. See this wiki for a list of autocomplete providers. The ones that are most interesting (at least to me) are:

  • autocomplete-bibtex: a markdown autocomplete provider. See the package description for details on configuration.
  • autocomplete-clang: a C/C++ autocomplete provider.
  • autocomplete-paths: for completion of file paths (language independent).
  • autocomplete-ctags: automatically rebuilds ctags (need investigation as it failed to install).

After using Atom and PlatformIO for a while, I noticed that from time to time I get an error after saving a file ("unable to read file after file change event" and "EBUSY: resource busy or locked"). Just now it occurred to me that it could be related to the fact that these directories are stored in a OneDrive synched directory. I will move the project home to outside the OneDrive directory and see if it makes a difference.

Make life easier: Atom packages

Some other useful Atom packages are:

  • git-time-machine - Shows the commit history of a file in a very visual way, including comments. Note: installing it from the GUI (Settings -> + Install) gave an error but installing it from the shell apm install git-time-machine worked fine for me).
  • minimap - Shows a miniature view of the entire source file on the right to quickly navigate through it. here are soma add-ons to this that show selections in the minimap (minimap-selection) and bookmarks (minimap-bookmarks).
  • exposé - Gives a thumbnail view of all open files, where the tabs at the top may quickly become overloaded.
  • file-icons - Gives nice file type specific icons in the tree view and fuzzy finder.
  • atom-beautify - Beatify many languages, including C/C++, Java, HTML, C# and PHP.

Obviously, the most interesting extension is missing in this list: PlatformIO. I briefly discussed it in my previous blog post, but since I am going to do some low level assembler programming for the Atmel ATTiny MCU's, it's time to setup a build environment that can deal with shared libraries and include files. But that's for next time...

Add a comment

Next Post Previous Post

Add a comment