aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/07_Modules.md
blob: 297a0ba586555f16141d61160c894dca4942d934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Modules

Most of Textadept's functionality comes from Lua modules. Essentially there are
two classes of module: generic and language-specific. A generic module provides
features for all programming languages while a language-specific module provides
features for a specific programming language.

## Generic

Generic modules have a broad scope and are usually available for programming in
all languages or writing plain-text. An example is the [textadept module][]
which implements most of Textadept's functionality (find & replace, key
bindings, menus, snippets, etc.). In general, Textadept should load these kinds
of modules on startup. See the [preferences][] page for instructions on how to
do this.

[textadept module]: api/_M.textadept.html
[preferences]: 08_Preferences.html#Loading.Modules

## Language-Specific

Language-specific modules have a scope limited to a single programming language.
The module's name matches the language's lexer in the *lexers/* directory.
Textadept automatically loads the module when editing source code in that
particular language. In addition to the source code editing features discussed
previously, these kinds of modules typically also define shell commands for
running and compiling code, indentation settings, custom key bindings, and
perhaps a custom context menu. The manual discusses these features below.

### Compile and Run

Most language-specific modules specify commands that compile and/or run the code
in the current file. Pressing `Ctrl+Shift+R` (`⌘⇧R` on Mac OSX | `M-^R` in
curses) executes the command for compiling code and `Ctrl+R` (`⌘R` | `^R`)
executes the command for running code. A new buffer shows the output from the
command and marks any recognized errors. Pressing `Ctrl+Alt+E` (`^⌘E` | `M-X`)
attempts to jump to the source of the next recognized error and
`Ctrl+Alt+Shift+E` (`^⌘⇧E` | `M-S-X`) attempts to jump to the previous one.
Double-clicking on errors also jumps to their sources. Note: In order for these
features to work, the language you are working with must have its compile and
run commands and error format defined. If the language-specific module does not
exist or does not [define][] commands or an error format, you can do so
[manually][] in your [user-init file][].

![Runtime Error](images/runerror.png)

[define]: api/_M.html#Compile.and.Run
[manually]: http://foicica.com/wiki/run-supplemental
[user-init file]: 08_Preferences.html#User.Init

### Buffer Properties

Some programming languages have style guidelines for indentation and/or line
endings which differ from Textadept's defaults. In this case, language-specific
modules [set][] these preferences. You can do so manually with your
[language module preferences][].

[set]: api/_M.html#Buffer.Properties
[language module preferences]: 08_Preferences.html#Language-Specific

### Key Bindings

Most language-specific modules assign a set of key bindings to
[custom commands][]. The module's [LuaDoc][] or code lists which key bindings
map to which commands. The `Ctrl+L` (`⌘L` on Mac OSX | `M-L` in curses) key
chain prefix typically houses them.

[custom commands]: api/_M.html#Commands
[LuaDoc]: api/index.html

### Context Menu

Some language-specific modules add extra actions to the context menu.
Right-click inside the view to bring up this menu.

## Getting Modules

Textadept has a set of officially supported language modules available as a
separate download from the Textadept downloads page with their sources hosted
[here][]. To upgrade to the most recent version of a module, either use
[Mercurial][] (run `hg pull` and then `hg update` on or from within the module)
or download a zipped version from the module's repository homepage and overwrite
the existing one.

For now, the [wiki][] hosts third-party, user-created modules.

[here]: http://foicica.com/hg
[Mercurial]: http://mercurial.selenic.com
[wiki]: http://foicica.com/wiki/textadept

## Installing Modules

If you do not have write permissions in Textadept's installed location, place
the module in your *~/.textadept/modules/* folder and replace all instances of
`_HOME` with `_USERHOME` in the module's *init.lua*. Putting all custom or
user-created modules in your *~/.textadept/modules/* directory prevents the
possibility of overwriting them when you update Textadept. Also, modules in that
directory override any modules in Textadept's *modules/* directory. This means
that if you have your own *lua* module, Textadept loads that one instead of its
own.

## Developing Modules

See the [module LuaDoc][].

[module LuaDoc]: api/_M.html