ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Hansl-Gretl-Language

by atecon ST3

Sublime support for hansl scripting language: syntax-highlighting, auto-complete, snippets

Details

Installs

  • Total 121
  • Win 86
  • Mac 15
  • Linux 20
Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Hansl-gretl-Language

Sublime support for gretl's scripting language called Hansl. The package's features are:

  1. Syntax-highlighting
  2. Completions (plus annotations) of commands, accessors, keywords and data types
  3. Snippets for various purposes
  4. Auto-indentation
  5. gretl build-systems (Batch mode, CLI, REPL)

gretl is an open-source statistics and econometrics software: http://gretl.sourceforge.net/

Hansl is a recursive acronym: it stands for “Hansl’s A Neat Scripting Language”. For a primer on Hansl: https://sourceforge.net/projects/gretl/files/manual/hansl-primer-a4.pdf/download

I - Installation

This plug-in is available on package control. It's recommended to get it from there.

Steps for installation:

1) Call “Package Control” via the key-bind - Win/Linux: ctrl+shift+p - Mac: cmd+shift+p

2) Type “Package Control: Install Package” and search for “Hansl-gretl-Language”. 3) Also install the package named Terminus (repeat steps 1 and 2) which is needed for the REPL mode.

Note: If you don't see this plug-in in package control is likely because you have a too old version of Sublime installed. The plug-in will only be visible with a build >= 3084.

Syntax-highlighting

Build 3084 of Sublime introduced a new format for syntax definition files. The documentation can be found here. This package makes use of this new syntax.

Once the package is installed, every file with an *.inp file type will automatically be recognized as a gretl file using the Hansl syntax. You should experience syntax-highlighting immediately. Otherwise, go through the menu: View > Syntax > Hansl.

The new syntax will improve the way your gretl/Hansl code is coloured: ![alt text][sample]

Auto-indentation

Note: There are still some edgy cases left for improvement.

Completions

This feature is automatically activated for every *.inp file. Start typing a gretl command, function name or name of an accessors and you will see suggestions which can be accepted via the Tab key or Enter.

Completion of accessors

The package treats gretl's built-in accessors as 'variables' (scope). Since Sublime 4, one can add annotations to variables.

Here an example:

Completion of an accessor

Completion of commands

The package treats gretl's built-in commands as 'namespace' (scope). Since Sublime 4, one can add annotations to commands, too.

Here an example:

Completion of an accessor

This is how it works for command blocks:

Completion of an accessor

Completion of data types

Gretl data types are treated as 'type' (scope). Since Sublime 4, one can add annotations here, too.

Here an example:

Completion of an accessor

Completion of keywords

Gretl data types are treated as 'keyword' (scope). Since Sublime 4, one can add annotations here, too.

Here an example:

Completion of an accessor

Indentation

Since version 0.3.0 auto-indentation is supported for gretl scripts.

Here an example of an if-else block.

Auto-indentation

However, indentation of nested blocks are not fully supported, yet.

Snippets

Snippets make you really productive! These are little templates which save typing. Simply open a gretl *.inp file, and start typing if. You will see some suggestions which can be selected via the Tab key again. Explore and start writing your own snippets.

This is how snippets work:

Snippet for creating a function block

For an overview of available snippets you can do the either: 1. Ctrl+Shift+P -> Snippet will list the available snippets. 2. See here for all defined snippets (which you can use for your own templates).

Watch for a tutorial on snippets here: https://youtu.be/MeOaWR2T6TU

gretl build-systems

Support for build-systems is a great feature of the Sublime editor. They allow you to execute a program. I've added different build-system for gretl such that you can run your gretl script via the “gretlcli” program — gretl's command line program instead of the GUI.

Three build-systems are configured (see ./build-systems/gretl.sublime-build): 1. “CLI”: Execute a gretl script in a terminal – non-interactive. 2. “Batch mode”: Execute a gretl script and quit. 3. “REPL”: Interactive mode opening a command line interface.

The REPL requires the additional installation of the Terminus package for sublime. For a video tutorial on Terminus see here: https://youtu.be/mV0ghkMwTQc

For a great video tutorial on how to make a build-system interactive with Terminus I also recommend: https://youtu.be/etIJMVIvVgg

Changelog:

v0.3.0 (June 2021): - Finish completions for all gretl commands - Add support for auto-indentation - Update README

v0.2.5 (June 2021): - Add further completions for commands

v0.2.4 (June 2021): - Add further completions for commands

v0.2.3 (June 2021): - Add much better support for completions for commands including type annotations, annotations and pre-configured options

v0.2.2 (June 2021): - Add new snippets defining a bundle - Minor improvements

v0.2.1 (May 2021): - Added new snippets for loops - Improve existing snippets (all backward compatible)

v0.2.0 (November 2020): - Added new additional snippets

v0.1.0 (May 2020): - Initial release