Making Atom first class Python IDE with help of Nuclide

@mlesyk   2018-11-02 21:04   Development  
ide python

First of all, you need Python 3 installed in your system, otherwise, install it.
Before we actually start set up Atom, we need install few dependencies of our environment.
I recommend install them in dedicated Python virtual environment, so it will be easy to port or back it up.
I’ll use Python 3 built-in module venv, but you can pick any other alternative.

python3 -m venv ~/.devenv
source ~/.devenv/bin/activate
python3 -m pip install wheel

Then we need to install following packages:

  • black - used for auto formatting of code
  • flake8 - used for static analysis of source code and checking for symantec discrepancies
  • flake8-mypy - flake8’s plugin for integrating of mypy - used for type checking
  • isort - used for automatic sorting of imports
  • jedi - used for autocompletion
source ~/.devenv/bin/activate
python3 -m pip install black flake8 flake8-mypy isort jedi

Then, at last, install Atom for your operating system and let’s start hacking it!

After installation of Atom, let’s install following packages:

  • atom-beautify - auto formatting, cleaning, beautify of code
  • atom-jinja2 - jinja2 templating language syntax support
  • file-icons - unnique icons for every file type
  • file-watcher - notify if file changed on disk and optinally reloads it
  • git-plus - adds all possibilities of git to Atom
  • hidpi - useful if you have big monitor and decide interface too small
  • highlight-selected - highlight occurrences of a selection within the open editor
  • nuclide - primary part of turning Atom into IDE
  • python-isort - sorting items in Atom, soon will be replaced with isort support in atom-beautify + black
  • set-syntax - easy selection of syntax for file
  • sort-lines - sort selected lines in one action
  • tool-bar - adds empty toolbar. To fill, needs additional plugins.
  • tool-bar-main - adds basic buttons to tool bar
apm install atom-beautify atom-jinja2 file-icons file-watcher git-plus hidpi highlight-selected nuclide python-isort set-syntax sort-lines tool-bar tool-bar-main

Configuration of Atom is stored in ~/atom/config.cson. By default it is empty.
I’ll post my config here with comments - you could just paste it as-is or remove/delete some sections.
All config options are available through UI, but copying of file will save some time.

"*":
  "atom-beautify":
    # allow formatting files on save for particular languages - disabled by default
    css:
      beautify_on_save: true
    general:
      showLoadingView: false
    go:
      beautify_on_save: true
    html:
      beautify_on_save: true
    js:
      beautify_on_save: true
    json:
      beautify_on_save: true
    nginx:
      beautify_on_save: true
    python:
      beautify_on_save: true
      # select black formatter
      default_beautifier: "black"
      # Not working yet, waiting for https://github.com/Glavin001/atom-beautify/pull/2244
      sort_imports: true
    yaml:
      beautify_on_save: true
  core:
    # do not update Atom autmatically - I prefer doing it manually
    automaticallyUpdate: false
    # if file is deleted outside Atom - close appropriate tab
    closeDeletedFileTabs: true
    # do not close Atom if last tab is closed and "close tab" signal is sent to Atom
    closeEmptyWindows: false
    # changed by nuclide
    customFileTypes:
      "source.ini": [
        ".hgrc"
        ".buckconfig"
        ".flowconfig"
      ]
      "source.json": [
        "BUCK.autodeps"
      ]
      "source.python": [
        "BUCK"
      ]
    # tree-view, image-view, language-gfm are disabled by nuclide
    # welcome - disable welcome screen, metrics - do not send metrics
    disabledPackages: [
      "tree-view"
      "image-view"
      "welcome"
      "metrics"
      "language-gfm"
    ]
    # do not send telemetry
    telemetryConsent: "no"
  editor:
    fontSize: 12
  "exception-reporting":
    userId: "0a55fa38-92d9-44bd-83a7-6f763c9f73e1"
  "file-icons":
    # I prefer monochrome icons
    coloured: false
  nuclide:
    # do not format code on type - it is formatted by save in atom-beautify
    "atom-ide-code-format":
      formatOnType: false
    # by default datatips are too annoying - if I need some info about it, I'll wait 3 seconds
    "atom-ide-datatip":
      datatipDebounceDelay: 3000
      datatipInteractedWithDebounceDelay: 100
    "nuclide-health":
      analyticsTimeout: 60
      viewTimeout: 60
    "nuclide-home":
      # disable home screen
      showHome: false
    "nuclide-python":
      # I do not like filling arguments for me
      autocompleteArguments: false
  "python-isort":
    checkOnSave: false
    # sort python imports on file save
    sortOnSave: true
  "tool-bar":
    # reduce toolbar icons size
    iconSize: "16px"
    # put toolbar from the left side
    position: "Left"
    # I have no mac book, so not using touch bar
    useTouchBar: false

So, now we have Atom and all packages installed and it looks like screenshot in the beginning of article. In next post I’ll review Nuclide and will show couple of tips and tricks.

 Back to main