Howto:Syntax highlighting for Nasal: Difference between revisions

Jump to navigation Jump to search
Rearranging some sections alphabetically; copyediting first section; etc
m (→‎Notepad++: Updated URL)
(Rearranging some sections alphabetically; copyediting first section; etc)
Line 1: Line 1:
There's '''[[Nasal]] syntax-highlighting''' support available for some editors, which is a big advantage, as it makes Nasal coding much easier. It can often point to syntax errors and so reduce the number of tedious time-consuming and unproductive [[FlightGear]] runs, and it can be a sort of "guide" to the language, highlighting functions or keywords that are builtin, so you can quickly check if it is "type" or "typeof" by typing each. It also makes understanding other people's code easier, since you have all of the parts visually separated out, like loops, strings, constants, and builtin functions.
There's '''[[Nasal]] syntax-highlighting''' support available for some editors, which is a big advantage, as it makes Nasal coding much easier.


== Notepad++ ==
Syntax highlighting can often point to syntax errors and so reduce the number of tedious time-consuming and unproductive [[FlightGear]] runs. It can also be a sort of "guide" to the language, highlighting functions or keywords that are builtin, so you can quickly check if it is "type" or "typeof" by typing each. In addition makes understanding other people's code easier, since you have all of the parts visually separated out, like loops, strings, constants, and builtin functions.
[[File:Highlight parse.png|400px|thumb|Screenshot of Nasal support for Notepad++]]
Provides comprehensive syntax highlighting and a function list parser with support for hierarchical display of both inline and out-of-body class member functions.
* [http://gitorious.org/nasal-support/nasal-npp Gitorious repository for download and instructions]
{{-}}
'''Alternative (syntax highlighting only):'''
* [http://dl.dropbox.com/u/1463693/nasal.xml Download here]
** [http://superuser.com/questions/62474/notepad-custom-syntax-highlighting-setting-where-to-look-for-it Instructions are here]
{{-}}


== jEdit ==
== Atom ==
There's a syntax highlighting mode for jEdit, programmer's text editor
Script are here: https://github.com/www2000/atom-language-nasal and can also find in the in the atom's ( https://atom.io/ ) packages repository.


Included are some of Nasal's internal functions and those functions currently implemented in NasalSys.cxx
Manual installation:
To use, add the content of the catalog inside your own catalog (do NOT overwrite the file) and nasal.xml in /home/USER/.jedit/modes


Restart jEdit and you can use it. Current extension is .nas, you can add your own extension and functions.
1. Download the latest release from https://github.com/www2000/atom-language-nasal<br/>
This mode is heavily based on the Javascript mode.
2. Unpackt the tar.bz2<br/>
3. Copy/move the language-nasal package to ~/.atom/packages


Get it here: https://sourceforge.net/projects/fgscheduleview/files/jedit/catalog.zip/download
For installation from atom's packages repository:<br/>
1. open atom<br/>
2. Go to Pregerences Edit->Pregerences or Ctrl+,<br/>
3. Click on packages and search for nasal<br/>
4. Click install for Language Nasal


== gedit ==
== gedit ==
[[File:Philosopher's nasal highlighting in gEdit.jpeg|400px|thumb|Screen shot illustrating syntax highlighting in gedit]]
[[File:Philosopher's nasal highlighting in gEdit.jpeg|400px|thumb|Screen shot illustrating syntax highlighting in gedit]]


Line 36: Line 31:
In the same post given above, there are instructions for how to edit ''xml.lang'' (in the same directory) to add the embedded XML content support (with this minor edit, Nasal highlighting will be used inside of certain tags, instead of plain text).
In the same post given above, there are instructions for how to edit ''xml.lang'' (in the same directory) to add the embedded XML content support (with this minor edit, Nasal highlighting will be used inside of certain tags, instead of plain text).


For "snippets" support, nasal.xml from the above post has to be moved into ''/usr/share/gedit/plugins/snippets/'' folder or installed using the "import" feature. See this image for more details: [[:File:Install nasal snippets in gedit.png|how to import Nasal snippets]].
For "snippets" support, nasal.xml from the above post has to be moved into ''/usr/share/gedit/plugins/snippets/'' folder or installed using the "import" feature. See this image for more details:  


== Vim ==
[[:File:Install nasal snippets in gedit.png|how to import Nasal snippets]].
One such editor is the free vim or its gui variant gvim.
{{-}}


It's not for everyone but it's free, and testing it doesn't hurt: http://www.vim.org/.
== jEdit ==
There's a syntax highlighting mode for jEdit, programmer's text editor


The syntax definition file comes with the FlightGear code (http://gitorious.org/fg/flightgear/blobs/next/scripts/syntax/nasal.vim). Highlighting works even for Nasal embedded in XML files (type ":set ft=nasal", where ft stands for file-type)
Included are some of Nasal's internal functions and those functions currently implemented in NasalSys.cxx
To use, add the content of the catalog inside your own catalog (do NOT overwrite the file) and nasal.xml in /home/USER/.jedit/modes


Here's an example, which demonstrates a short code segment with three syntax errors as well as the highlighting of a matching pair of parentheses (yellow) and trailing spaces (blue x). (The leading blue dots aren't on by default. They help to spot tab crimes.)
Restart jEdit and you can use it. Current extension is .nas, you can add your own extension and functions.
This mode is heavily based on the Javascript mode.


[[File:Vim-nasal-syntax-highlighting.png|400px|thumb|Screen shot illustrating syntax highlighting in Vim]]
Get it here: https://sourceforge.net/projects/fgscheduleview/files/jedit/catalog.zip/download


==KDE Editors==
== KDE Editors ==
There's a highlighting definition for nasal available at '''kde-files.org''' (http://kde-files.org/content/show.php/Nasal+highlighting?content=154555)
There's a highlighting definition for nasal available at '''kde-files.org''' (http://kde-files.org/content/show.php/Nasal+highlighting?content=154555)


Line 57: Line 55:


The highlighting file should work with all editors based on the katepart: KWrite, Kate, and the editor component of KDevelop.
The highlighting file should work with all editors based on the katepart: KWrite, Kate, and the editor component of KDevelop.
== Notepad++ ==
[[File:Highlight parse.png|400px|thumb|Screenshot of Nasal support for Notepad++]]
Provides comprehensive syntax highlighting and a function list parser with support for hierarchical display of both inline and out-of-body class member functions.
* [http://gitorious.org/nasal-support/nasal-npp Gitorious repository for download and instructions]
'''Alternative (syntax highlighting only):'''
* [http://dl.dropbox.com/u/1463693/nasal.xml Download here]
** [http://superuser.com/questions/62474/notepad-custom-syntax-highlighting-setting-where-to-look-for-it Instructions are here]
{{-}}


== Sublime Text 2 ==
== Sublime Text 2 ==
[[File:Sublime Text 2 syntax highlighting.png|400px|thumb|Sublime Text 2 syntax highlighting]]
Scripts and installation instructions are here: https://github.com/freevryheid/nasal
Scripts and installation instructions are here: https://github.com/freevryheid/nasal
[[File:Sublime Text 2 syntax highlighting.png|400px|thumb|Sublime Text 2 syntax highlighting]]
{{-}}
 
== Vim ==
[[File:Vim-nasal-syntax-highlighting.png|400px|thumb|Screen shot illustrating syntax highlighting in Vim]]


== Atom ==
One such editor is the free vim or its gui variant gvim.  
Script are here: https://github.com/www2000/atom-language-nasal and can also find in the in the atom's ( https://atom.io/ ) packages repository.


Manual installation:
It's not for everyone but it's free, and testing it doesn't hurt: http://www.vim.org/.


1. Download the latest release from https://github.com/www2000/atom-language-nasal<br/>
The syntax definition file comes with the FlightGear code (http://gitorious.org/fg/flightgear/blobs/next/scripts/syntax/nasal.vim). Highlighting works even for Nasal embedded in XML files (type ":set ft=nasal", where ft stands for file-type)
2. Unpackt the tar.bz2<br/>
3. Copy/move the language-nasal package to ~/.atom/packages


For installation from atom's packages repository:<br/>
Here's an example, which demonstrates a short code segment with three syntax errors as well as the highlighting of a matching pair of parentheses (yellow) and trailing spaces (blue x). (The leading blue dots aren't on by default. They help to spot tab crimes.)
1. open atom<br/>
{{-}}
2. Go to Pregerences Edit->Pregerences or Ctrl+,<br/>
3. Click on packages and search for nasal<br/>
4. Click install for Language Nasal


== Other editors ==
== Other editors ==
Line 100: Line 107:


== Syntax highlighting test ==
== Syntax highlighting test ==
Just a collection of keywords, etc. to test whether highlighting works (you can copy this to test your own highlighting):
Just a collection of keywords, etc. to test whether highlighting works (you can copy this to test your own highlighting):
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
Line 134: Line 140:
</syntaxhighlight>
</syntaxhighlight>


[[Category:Nasal howto]]
== Related content ==
 
== Related ==
* http://www.flightgear.org/forums/viewtopic.php?f=30&t=17265&p=164155#p164155
* http://www.flightgear.org/forums/viewtopic.php?f=30&t=17265&p=164155#p164155
* http://www.flightgear.org/forums/viewtopic.php?f=30&t=12495
* http://www.flightgear.org/forums/viewtopic.php?f=30&t=12495
* http://www.flightgear.org/forums/viewtopic.php?f=30&t=15972
* http://www.flightgear.org/forums/viewtopic.php?f=30&t=15972
* http://www.flightgear.org/forums/viewtopic.php?f=30&t=9812
* http://www.flightgear.org/forums/viewtopic.php?f=30&t=9812
[[Category:Nasal howto]]

Navigation menu