Difference between revisions of "Textadept"

From Wiki
Jump to navigation Jump to search
m
(Added ConTeXt quick installation guide for Windows users)
Line 5: Line 5:
 
[https://foicica.com/textadept/ Textadept] is a programmable text editor for Linux, Mac OSX and Windows. It is fully extensible using [https://www.lua.org/ Lua].
 
[https://foicica.com/textadept/ Textadept] is a programmable text editor for Linux, Mac OSX and Windows. It is fully extensible using [https://www.lua.org/ Lua].
  
=3rd party projects=
 
  
A ConTeXt module for textadept is being developed at [https://github.com/stephengaito/ta-context-latex ta-context-latex].
+
= How to ConTeXt with Textadept (MS Windows) =
 +
(updated 2017/03)
 +
 
 +
== Step 1: Install '''ConTeXt''' ==
 +
 
 +
1. [http://standalone.contextgarden.net/setup/ Download] ConTeXt.
 +
* Windows x86 / 32 bit users: [http://standalone.contextgarden.net/setup/context-setup-mswin.zip context-setup-mswin.zip]
 +
* Windows x64 / 64 bit users: [http://standalone.contextgarden.net/setup/context-setup-win64.zip context-setup-win64.zip]
 +
** Download the x64 / 64 bit version only when you are really sure, that you '''need''' it.
 +
 
 +
2. Extract the archive to a location of your choice.
 +
* You might want to change the name of the extracted directory to a shorter one as it will be the final location for ConTeXt.
  
Note though, that if you plan to use Textadept without LaTeX with ConTeXt mkiv only (recommended), then you might not need the package mentioned above as it comes with literally only a hand full of ConTeXt snippets. It's almost more comfortable to create own ConTeXt snippets with the ease of Textadept (see below).
+
3. Start your Windows command prompt.
 +
* Use can start it by using the key shortcut <code>Windows-Key + R</code>, entering <code>cmd</code> and pressing <code>ENTER</code>-key.
 +
* Alternatively you can use <code>Start</code> -> <code>Programs</code> -> <code>Accessories</code> -> <code>Command Pompt</code>
  
= How to ConTeXt with Textadept =
+
4. Navigate to where you extracted the ConTeXt archive.
MS Windows machines; updated 2017/03.
+
* The easiest way to do so is to:
 +
** use Windows Explorer to navigate to your ConTeXt directory,
 +
** click in the upper white field with the location
 +
** enter <code>cmd</code> and press <code>Enter</code>-key.
 +
** Now Windows command prompt should pop up with the correct location.
 +
* Otherwise do it the old fashioned way. Some DOS commands you might need:
 +
** <code>X:</code> change to drive X:
 +
** <code>dir</code> list the content of the current directory
 +
** <code>cd DIRECTORY</code> change to directory with name DIRECTORY
 +
** <code>cd..</code> change to superior directory
 +
** <code>cd\</code> change to root drive
 +
* Now your command prompt should look like this:
 +
  X:\ConTeXt>_
  
== Step 1: Install '''ConTeXt''' ==
+
5. Enter the following line:
 +
* If you only want ConTeXt mkiv (highly '''recommended'''):
 +
  first-setup -engine=luatex -modules=all
  
work in progress
+
6. Wait until the download is complete.
  
 
== Step 2: Add ConTeXt's executables folder to Windows search PATH ==
 
== Step 2: Add ConTeXt's executables folder to Windows search PATH ==
Line 33: Line 59:
 
* After extraction of the downloaded Textadept archive there is a file called <code>init.lua</code> in the main program folder. It is '''not recommended''' to edit this file as your changes will be lost when you update Textadept. Instead:
 
* After extraction of the downloaded Textadept archive there is a file called <code>init.lua</code> in the main program folder. It is '''not recommended''' to edit this file as your changes will be lost when you update Textadept. Instead:
 
* When you start Textadept for the first time a new folder  <code>SYSDRIVE:\users\USERNAME\.textadept</code> gets created. It also contains the file called <code>init.lua</code>. It's the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty.
 
* When you start Textadept for the first time a new folder  <code>SYSDRIVE:\users\USERNAME\.textadept</code> gets created. It also contains the file called <code>init.lua</code>. It's the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty.
 +
 
2. Add an execute command for ConTeXt to Textadept's menu:
 
2. Add an execute command for ConTeXt to Textadept's menu:
 
* If your ConTeXt executables folder is already in the Windows search PATH:
 
* If your ConTeXt executables folder is already in the Windows search PATH:
Line 39: Line 66:
 
   textadept.run.compile_commands.tex = 'C:/ctx/tex/texmf-mswin/bin/mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
 
   textadept.run.compile_commands.tex = 'C:/ctx/tex/texmf-mswin/bin/mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
 
* '''Note''' that you have to use slash <code>/</code> instead of backslash <code>\</code> in the file path, since Lua (same as ConTeXt) interprets a <code>\</code> as the beginning of a command, while for Windows it doesn't make any difference.
 
* '''Note''' that you have to use slash <code>/</code> instead of backslash <code>\</code> in the file path, since Lua (same as ConTeXt) interprets a <code>\</code> as the beginning of a command, while for Windows it doesn't make any difference.
 +
 
3. Restart Textadept to reload the modified <code>init.lua</code>.
 
3. Restart Textadept to reload the modified <code>init.lua</code>.
  
Line 60: Line 88:
 
* If you plan to use LaTeX and ConTeXt, you should use different file extensions. For example <code>*.tex</code> for LaTeX and <code>*.cxd</code> for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since <code>.tex</code> files are automatically recognized as LaTeX documents:
 
* If you plan to use LaTeX and ConTeXt, you should use different file extensions. For example <code>*.tex</code> for LaTeX and <code>*.cxd</code> for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since <code>.tex</code> files are automatically recognized as LaTeX documents:
 
   textadept.file_types.extensions.cxd = 'context'
 
   textadept.file_types.extensions.cxd = 'context'
 +
 
2. Restart Textadept to reload <code>init.lua</code>.
 
2. Restart Textadept to reload <code>init.lua</code>.
  
Line 101: Line 130:
  
 
* Then you can use <code>Alt + K</code> (by default on Windows machines) to choose from the list of snippets, when a ConTeXt document is opened in the active tab.
 
* Then you can use <code>Alt + K</code> (by default on Windows machines) to choose from the list of snippets, when a ConTeXt document is opened in the active tab.
 +
 +
 +
=3rd party projects=
 +
 +
A ConTeXt module for textadept is being developed at [https://github.com/stephengaito/ta-context-latex ta-context-latex].
 +
 +
Note though, that if you plan to use Textadept without LaTeX with ConTeXt mkiv only (recommended), then you might not need the package mentioned above as it comes with literally only a hand full of ConTeXt snippets. It's almost more comfortable to create own ConTeXt snippets with the ease of Textadept (see above).

Revision as of 12:09, 3 March 2017

< Text Editors

Introduction

Textadept is a programmable text editor for Linux, Mac OSX and Windows. It is fully extensible using Lua.


How to ConTeXt with Textadept (MS Windows)

(updated 2017/03)

Step 1: Install ConTeXt

1. Download ConTeXt.

2. Extract the archive to a location of your choice.

  • You might want to change the name of the extracted directory to a shorter one as it will be the final location for ConTeXt.

3. Start your Windows command prompt.

  • Use can start it by using the key shortcut Windows-Key + R, entering cmd and pressing ENTER-key.
  • Alternatively you can use Start -> Programs -> Accessories -> Command Pompt

4. Navigate to where you extracted the ConTeXt archive.

  • The easiest way to do so is to:
    • use Windows Explorer to navigate to your ConTeXt directory,
    • click in the upper white field with the location
    • enter cmd and press Enter-key.
    • Now Windows command prompt should pop up with the correct location.
  • Otherwise do it the old fashioned way. Some DOS commands you might need:
    • X: change to drive X:
    • dir list the content of the current directory
    • cd DIRECTORY change to directory with name DIRECTORY
    • cd.. change to superior directory
    • cd\ change to root drive
  • Now your command prompt should look like this:
 X:\ConTeXt>_

5. Enter the following line:

  • If you only want ConTeXt mkiv (highly recommended):
 first-setup -engine=luatex -modules=all

6. Wait until the download is complete.

Step 2: Add ConTeXt's executables folder to Windows search PATH

work in progress

Step 3: Install Textadept

1. Download and extract Textadept to a folder of your choice.

2. Use textadept.exe from the extracted folder to start Textadept.

Step 4: Tweak Textadept's settings

1. Use your freshly installed Textadept to open Textadept's main configuration file called init.lua.

  • After extraction of the downloaded Textadept archive there is a file called init.lua in the main program folder. It is not recommended to edit this file as your changes will be lost when you update Textadept. Instead:
  • When you start Textadept for the first time a new folder SYSDRIVE:\users\USERNAME\.textadept gets created. It also contains the file called init.lua. It's the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty.

2. Add an execute command for ConTeXt to Textadept's menu:

  • If your ConTeXt executables folder is already in the Windows search PATH:
 textadept.run.compile_commands.tex = 'mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
  • If for some reason you can't add the folder to PATH you have to add the full path to your ConTeXt executables. For example:
 textadept.run.compile_commands.tex = 'C:/ctx/tex/texmf-mswin/bin/mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
  • Note that you have to use slash / instead of backslash \ in the file path, since Lua (same as ConTeXt) interprets a \ as the beginning of a command, while for Windows it doesn't make any difference.

3. Restart Textadept to reload the modified init.lua.

4. Open or create a ConTeXt test document:

 \starttext
   hello world!
 \stoptext

5. Use Textadept's Tools -> Compile to build a PDF with the options added to init.lua. A message buffer with compilation status will open in a seperate tab.

6. When you have a popular PDF reader installed already, it should pop up at the end of the process and show the created PDF output. Sumatra PDF is highly recommended for this.

Optional: Additional Textadept tweaks

Lexing

A lexer is a file that defines command highlighting. Since Textadept comes with an own ConTeXt lexer, it is a good idea to bind *.tex files to Textadept's ConTeXt lexer. To do so:

1. Add the following lines to your USER/.textadept/init.lua:

 textadept.file_types.extensions.tex = 'context'
  • If you plan to use LaTeX and ConTeXt, you should use different file extensions. For example *.tex for LaTeX and *.cxd for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since .tex files are automatically recognized as LaTeX documents:
 textadept.file_types.extensions.cxd = 'context'

2. Restart Textadept to reload init.lua.

3. Open a ConTeXt document and check Textadept's status bar in the lower right corner. It should say context. If it says latex make sure it really is a ConTeXt file or repeat the procedure.

Themes & editor font changes

You can change the theme, font and font size of Textadept with the following line

 ui.set_theme('dark', {font = 'Monospace', fontsize = 10})

in which the expression dark is the filename of the theme located either in Textadept\themes or you can download and add new themes to USER\.textadept\themes (create the folder if it's not there yet). There are more settings which you can look up in Textadept's online manual.

Snippets

Snippets are predefined code blocks. You add them to your USER/.textadept/init.lua. Snippets in Textadept look like this:

 -- The first line is mandatory:
 snippets['context'] = snippets['context'] or {}
 -- Snippets start here:
 snippets.context['emph']        = '{\\em %0}'
 snippets.context['bold']        = '{\\bf %0}'
 snippets.context['start']       = '\\start%1\n%0\n\\stop%1'
 snippets.context['itemize']     = '\\startitemize\n\t%0\n\\stopitemize'
 snippets.context['item'] 	 = '\\startitem\n\t%0\n\\stopitem'
 snippets.context['enumerate']   = '\\startenumerate\n\t%0\n\\stopenumerate'
 snippets.context['chapter']     = '\\startchapter[title={%1},marking{%1}]\n%0\n\\stopchapter'
 snippets.context['section']     = '\\startsection[title={%1},marking{%1}]\n%0\n\\stopsection'
 snippets.context['ssection']    = '\\startsubsection[title={%1},marking{%1}]\n%0\n\\stopsubsection'
 snippets.context['title']       = '\\starttitle[title={%1},marking{%1}]\n%0\n\\stoptitle'
 snippets.context['subject']     = '\\startsubject[title={%1},marking{%1}]\n%0\n\\stopsubject'
 snippets.context['ssubject']    = '\\startsubsubject[title={%1},marking{%1}]\n%0\n\\stopsubsubject'
  • Note that a backslash \ is created by typing a double backslash \\.
  • The most important formatting commands are the following:
    • %0 creates a primary input caret (the cursor will jump here first)
    • %1 creates one or multiple secondary input carets
    • %n creates a new line
    • %t creates a tab
  • After adding snippets, you have to restart Textadept first.
  • Then you can use Alt + K (by default on Windows machines) to choose from the list of snippets, when a ConTeXt document is opened in the active tab.


3rd party projects

A ConTeXt module for textadept is being developed at ta-context-latex.

Note though, that if you plan to use Textadept without LaTeX with ConTeXt mkiv only (recommended), then you might not need the package mentioned above as it comes with literally only a hand full of ConTeXt snippets. It's almost more comfortable to create own ConTeXt snippets with the ease of Textadept (see above).