Install atom on your workstation

  • Ubuntu:
sudo add-apt-repository ppa:webupd8team/atom && sudo apt update && sudo apt install atom
  • Archlinux: needs to be compiled from source (AUR)
yaourt -S atom-editor-bin ()

Atom recommanded packages for C++/CMake/Git

Here are the package that are really useful when using atom for PID.

  • atom-beautify: Code formatting
  • autocomplete-clang: Code completion (C++)
  • autocomplete-cmake: Code completion (cmake)
  • build: Base package for other build- packages (F7: select target, F8: show output, F9: run target)
  • build-cmake: Build code based cmake
  • build-make: Build code based on makefiles
  • busy: Needed by some packages
  • git-plus: Do git things within Atom
  • git-time-machine: Make a diff between commits
  • highlight-selected: Highlight every occurrence of the current selection
  • language-cmake: Support for cmake (syntax definition)
  • linter: Base package for other linter- packages
  • linter-clang: C++ linter (shows errors/warnings in the code)
  • local-settings: Allow a local setting file to override the global one
  • platformio-ide-terminal: A terminal inside Atom
  • project-manager: To quickly switch between projects
  • split-diff: Diff files
  • todo-show: List all the TODOs mentionned in the comments
  • Install them all:

Simply install them:

apm install atom-beautify autocomplete-clang autocomplete-cmake build build-cmake build-make busy git-plus git-time-machine highlight-selected language-cmake linter linter-clang local-settings platformio-ide-terminal project-manager split-diff todo-show

Start atom for first time

When first started, atom will probably ask you to install dependencies for the packages you installed with previous command. Or it may ask you to update some of these packages.

Simply answer YES to these operations.

Configuration of atom

C++ snippets

Copy the following content into snippets (into Menu bar > Edit > snippets):

'.source.cpp':
  'For Loop - pre inc':
    'prefix': 'for'
    'body': 'for (size_t ${1:i} = 0; ${1:i} < ${2:count}; ${3:++}${1:i}) {\n\t${4:/* code */}\n}'

  'C++ Class':
    'prefix': 'class'
    'body': 'class $1 {\npublic:\n\t$1();\n\t~$1();\n};'

  'C++ Child Class':
    'prefix': 'child-class'
    'body': 'class $1 : public $2 {\npublic:\n\t$1();\n\t~$1();\n};'

  'const string reference':
    'prefix': 'cstring'
    'body': 'const std::string& $1'

  'Knowbotics World::enable()':
    'prefix': 'kb-world-enable'
    'body': """
  	try {
  		World::enable();
  	}
  	catch (kbot::PropertyLogicError& e) {
  		cout << e.what() << endl;
  		$1
  		exit(0);
  	}
    """

  'Deallocate pointer':
    'prefix': 'del_ptr'
    'body': """
  if($1 != nullptr) {
    delete $1;
    $1 = nullptr;
  }
  """

  'static_cast':
    'prefix': 'scast'
    'body': 'static_cast<$1>($2)'

  'dynamic_cast':
    'prefix': 'dcast'
    'body': 'dyanamic_cast<$1>($2)'

  'Header guards':
    'prefix': 'guards'
    'body': """
    #ifndef $1
    #define $1

    #endif /* $1 */
    """

C++ beautifying

This is used for C++ formatting.

  • Save the following content somewhere in to a file (call it uncrustify.cfg) and copy the path to this file.
 # Uncrustify 0.64

 #
 # General options
 #

 # The type of line endings
 newlines                                 = auto     # auto/lf/crlf/cr

 input_tab_size                           = 4        # number
 output_tab_size                          = 4        # number
 indent_columns                           = 4        # number

 indent_class                             = true     # false/true
 indent_class_colon                       = true     # false/true

 sp_angle_shift                           = ignore      # ignore/add/remove/force
 sp_permit_cpp11_shift                    = true
  • Configure the atom beautify package to use this configuration

Go to Edit > Preferences > Packages, search for atom beautify package and then click on settings button.

In the C and C++ sections, select Uncrustify as beautifier then paste the path to uncrustify.cfg you just save in the field Config Path.

Configure CMake based build

Go to Edit > Preferences > Packages, search for build-cmake package and then click on settings button.

In the field build location paste the text: $PROJECT_DIR/build

Unselect the parallel build option

Configure the clang linter

In order for the linter (autocompletion and fast error detection) to work you need to install clang.

sudo apt install clang

Enable PID plugins for atom

Some atom packages sometimes require additional user information to work, this is for instance the case of the clang based linter.

Hopefully PID is shipped with an integrated environment taht does the job. To use this environment to automatically configure your projects:

pid cd
pid profiles cmd=add env=atom_support

This later commands add the use of atom_support to the current user profile. You can do the same for any profile your are using.

This environment is a kind of plugin that configure your projects to obtain a seamless integration of atom and PID.