Skip to content

OraOpenSource/oracle-and-atom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

Atom packages for Oracle Developers

Atom is a free open source powerful text editor. One of its greatest features is the ability to add packages to enhance its functionality. This document covers recommended packages for Oracle developers that use Atom.

Editor enhancements

Project management

To quickly navigate around your projects, you can install the extension project-manager.

It allows you to set up a configuration of your active projects so that you can quickly switch between them. The configuration for this is a cson file located in your atom user directory - $HOME/.atom/projects.cson most typically. You can quickly access it by opening the command palette (ctrl+shift+p) and searching for Edit projects.

Then, for each project you define properties such as title, paths, icon and settings - there are others, which you can read about on the packages README.

To get your project added without manually filling out the properties, you can search for Save Project in the command palette and it will prompt you for the name of the project, which adds the entries for title and paths in the project configuration file.

So for example, I have one project set up for my Atom user directory, as:

atomConfig:
  title: "Atom user directory"
  paths: [
    "/home/trent/.atom"
  ]
  icon: "icon-tools"
  settings:
    "*":
      "editor.tabLength": 2

This means I can quickly open this project by hitting alt+shift+P and searching for atom user directory.

Settings

Any settings you can apply system wide, you can also apply in the project configuration, with * being the wild card for all file types. You could alternatively have specific settings for specific language scopes. For instance, in the documentation, it has the example:

'.source.coffee':
  'editor.tabLength': 2
  'editor.preferredLineLength': 80

If you look at the grammar specification for CoffeeScript, you will see it's defined the scopeName as source.coffee which is why the above setting is mapped to .source.coffee.

Icon

The icons you can use against your projects are based on GitHub Octicons. For example, on the Atom user directory project I set up earlier, I specified the icon as icon-tools. If you look at the grid of icons, you will find that particular icon towards the bottom.

Clicking onto will give you the class name as octicon-tools. So in our project settings, we use that same class name, only replacing octicon with icon - thus becoming icon-tools.

Minimap

The extension minimap gives a zoomed out view of the code, on either the left or right hand side of the file that you can drag to scroll to a specific portion of the code.

File icons

The extensions file-icons adds icons specific to a files extension - just to add a bit of eye candy, and one more visual recognition of the file type. The icons are based on FontAwesome (and derivative(s)) fonts.

As a little example, before using this package:

and after:

note: The icon on foo.pks in the screenshot above hasn't yet made it into the package - but gives an idea of what is possible

Git

If you would like to be able to perform git operations directly from your editor, you want the extension git-plus. This extension adds commands into the command palette and through context menu's so that you can quickly perform git-operations straight out of your editor.

For example, From the command pallette, you can run:

  • Git Plus: Add to add the active file
  • Git Plus: Add and Commit to add the active file and trigger a commit
  • Git Plus: Commit to commit all staged files

And many more.

image

If you are more of a point-and-click type of person, you can access these commands by right clicking a file in the tree. There will be a menu entry for Git Plus where you can access a sub-set of available commands.

image

Editing remote files

The extension remote-edit allows editing of files from ftp/sftp.

To set up a new host, open the command palette and search for remote edit: new host Sftp

image

image

This configuration gets serialised into the default config: ~/.atom/remoteEdit.json (can be changed through settings)

Once that is set up, you can open those files by opening the remote-edit browse dialog - accessed by the command Remote edit: Browse. This will bring up a list of saved hosts that you can then browse.

image

image

One minor issue that I noticed, is that it doesn't show hidden files - and typing them in manually also doesn't load the file.

Terminal emulator

A common requirement for developers is to be able to access a terminal from within the editor. Whilst there are a number of packages that come with one implementation or another, in my testing I found platformio-ide-terminal to work best (another popular one being terminal-plus, but unfortunately didn't seem to be working on my Linux based system).

Once installed, you will see a + and x symbol in the bottom left hand side of your status bar. Clicking on the + will open up a new console (you can have more than one).

image

image

One "feature" that I found was that when running git status, then changes would come in with a drop shadow which made it difficult to read.

image

To get around this, I added the following to my user stylesheet:

//adapted from: https://github.com/jeremyramin/terminal-plus/issues/124
.platformio-ide-terminal.terminal-view .xterm > .terminal {
    text-shadow: none;
}

After this change, it comes through more readable as:

image

Development enhancements

Oracle syntax highlighting

Syntax highlighting for Oracle (PL/SQL) based code files is made available through the extension language-oracle.

Once installed, the language will automatically pickup the grammar when opening files with all the common PL/SQL file extensions. If you have not yet saved your file, or are using a currently un-recognised file extension, you can manually apply the language with the keyboard shortcut ctrl+shft+L and searching for PL/SQL

Symbols navigation

The extension to add a tree of your source code for quick navigation is provided through the extension symbols-tree-view.

This package provides a symbols/class view on the right hand side of your text editor. Clicking on any symbol will take you to that position in the code.

The pane get easily be toggled on and off with the keyboard shortcut ctrl+alt+o.

Source code alignment

Some developers prefer assignment operators in a given block to be aligned over multiple lines so that all assignment values begin at the same point. If you are one of those people, the extension atom-alignment solves that by allowing you to highlight a section of code, and applying the alignment.

The key bindings are ctrl+alt+A or ctrl+cmd+A. Best demonstrated with an example. So first you need to highlight any text where assignment operators occur, then run the aforementioned key bindings (or by selecting from the menu option, Packages->atom-alignment).

Example 1: Just the package call

Before:

declare
    l_short_field NUMBER;
    l_really_really_long_field NUMBER;
begin

    l_short_field := 1;
    l_really_really_long_field := 999;

    field_updater.get_ready_for_update;

    field_updater.update_details(
        l_short_field => l_short_field
      , l_really_really_long_field => l_really_really_long_field
    );

end;
/

After:

declare
    l_short_field NUMBER;
    l_really_really_long_field NUMBER;
begin

    l_short_field := 1;
    l_really_really_long_field := 999;

    field_updater.get_ready_for_update;

    field_updater.update_details(
        l_short_field              => l_short_field
      , l_really_really_long_field => l_really_really_long_field
    );

end;
/

Example 2: The whole package

declare
    l_short_field NUMBER;
    l_really_really_long_field NUMBER;
begin

    l_short_field := 1;
    l_really_really_long_field := 999;

    field_updater.get_ready_for_update;

    field_updater.update_details(
        l_short_field => l_short_field
      , l_really_really_long_field => l_really_really_long_field
    );

end;
/

After:

declare
    l_short_field NUMBER;
    l_really_really_long_field NUMBER;
begin

    l_short_field              := 1;
    l_really_really_long_field := 999;

    field_updater.get_ready_for_update;

    field_updater.update_details(
        l_short_field              => l_short_field
      , l_really_really_long_field => l_really_really_long_field
    );

end;
/

One change I did make, was to clear one of the settings Add Space Postfix.

If that is left enabled, the previous block would have come out as:

declare
    l_short_field NUMBER;
    l_really_really_long_field NUMBER;
begin

    l_short_field              := 1;
    l_really_really_long_field := 999;

    field_updater.get_ready_for_update;

    field_updater.update_details(
        l_short_field              = > l_short_field
      , l_really_really_long_field = > l_really_really_long_field
    );

end;
/

Oracle compilation

The extension build-oracle allows you to compile your Oracle scripts against the database. It does this be expanding on the build package, which is a generic extension for building on a variety of languages/platforms.

After you install, to start building against your database you need to set up a configuration (json) file, named .atom-build-oracle.json. The first time you add the configuration, you will need to reload Atom for the build targets to be recognised. This configuration expects an array of objects with two fields: targetName and connectString.

For example, if I want two build targets against the hr schema, my configuration file will look like:

[
    {
        "targetName" : "HR_DEV",
        "connectString" : "hr/hr@ORCLDEV"
    },
    {
        "targetName" : "HR_PRD",
        "connectString" : "hr/hr@ORCLPRD"
    }
]

With this applied, in the bottom left corner of your screen (in the status bar), you will see the build target of the first one defined in the config. Clicking on that will then bring up a list of targets at the top of the screen that you can click on to compile the active file against that connection.

image

image

Alternatively, you can hit the (default) key binding ctrl+alt+b to compile against the active build target.

This project depends on SQL*Plus (or SQLcl), so for further set up instructions, it is worth reviewing the README of the project - for SQLcl, it is just a matter of going in the plugin settings and setting it to use sqlcl instead of the default sqlplus.

Script runner

Unlike build-oracle, or more succintly, build, which typically depends on a build file, the extension script allows you to run the file based on the extension and has support for large number of languages. The keyboard shortcut to run a script defaults to ctrl+shift+b.

Suppose you have a JavaScript file you want to quickly run to test out, hit the keyboard shortcut and a little panel at the bottom of the page will show the output/results.

image

Pigments

The extension pigments will highlight colours in your source code. This can be helpful when using for example hex colour codes, or rgb values, to know what colour is actually being applied.

When dealing with CSS pre-processor's such as less, and colour variables that have been declared will come through in the palette. To show the colours, run the command show palette.

image

If I have defined a colour as: @my-var: #123456; in my less file, the palette will show the following:

image

Pigments also comes with a command to list all colours defind in the project. Run the command Find colors.

image

Colour picker

The extensions color-picker allows you to use a UI to choose a colour you want. There is a default trigger binding of ctrl+alt+c. So if you mouse over a colour code in your source file and hit the trigger key, the colour picker will present itself.

image

Clicking the big button at the top that displays the colour and also the HEX (or other desired format) code, will either insert or replace the colour value in your source file.

One issue, it won't work with colour names, such as red, green, blue, etc.

About

Recommended Atom packages for Oracle developers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published