aboutsummaryrefslogtreecommitdiff
path: root/lua/lexers/README.md
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-12-07 16:49:29 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-12-07 20:11:32 +0100
commit3570869c9ae2c4df14b15423789919e514322916 (patch)
tree6b990c9ec59fbdc7abce89c1307d22e66d0fd88a /lua/lexers/README.md
parent098504f67aea8a862840d58c69e8f6360eef3073 (diff)
downloadvis-3570869c9ae2c4df14b15423789919e514322916.tar.gz
vis-3570869c9ae2c4df14b15423789919e514322916.tar.xz
Move all lua related files to lua/ subfolder
Also remove the lexers sub directory from the Lua search path. As a result we attempt to open fewer files during startup: $ strace -e open -o log ./vis +q config.h && wc -l log In order to avoid having to modifiy all lexers which `require('lexer')` we instead place a symlink in the top level directory. $ ./configure --disable-lua $ rm -rf lua Should result in a source tree with most lua specifc functionality removed.
Diffstat (limited to 'lua/lexers/README.md')
-rw-r--r--lua/lexers/README.md74
1 files changed, 74 insertions, 0 deletions
diff --git a/lua/lexers/README.md b/lua/lexers/README.md
new file mode 100644
index 0000000..69c136d
--- /dev/null
+++ b/lua/lexers/README.md
@@ -0,0 +1,74 @@
+Lua LPeg lexers for vis
+=======================
+
+Vis reuses the [Lua](http://www.lua.org/) [LPeg](http://www.inf.puc-rio.br/~roberto/lpeg/)
+based lexers from the [Scintillua](http://foicica.com/scintillua/) project.
+
+# Vis integration
+
+Vis searches the lexers in the following locations:
+
+ * `$VIS_PATH/lexers`
+ * `./lua/lexers` relative to the binary location (using `/proc/self/exe`)
+ * `$XDG_CONFIG_HOME/vis/lexers`
+ * `/usr/local/share/vis/lexers`
+ * `/usr/share/vis/lexers`
+ * `package.path` (standard lua search path)
+
+at runtime a specific lexer can be loded by means of `:set syntax <name>`
+where `<name>` corresponds to the filename without the `.lua` extension.
+
+# Adding new lexers
+
+To add a new lexer, start with the `template.txt` found in this directory
+or a lexer of a similiar language. Read the
+[lexer module documentation](http://foicica.com/scintillua/api.html#lexer).
+The [LPeg](http://www.inf.puc-rio.br/~roberto/lpeg/) introduction might also
+be useful.
+
+For development purposes it is recommended to test the lexers from a lua
+script as described in the
+[Scintillua manual](http://foicica.com/scintillua/manual.html#Using.Scintillua.as.a.Lua.Library).
+
+To enable auto syntax highlighting when opening a file you can associate your
+new lexer with a set of file extensions by adding a corresponding entry into
+the table found at the end of the [vis.lua](/vis.lua) file.
+
+Changes to existing lexers should also be sent upstream for consideration.
+
+A template for new lexers:
+
+```
+-- ? LPeg lexer.
+
+local l = require('lexer')
+local token, word_match = l.token, l.word_match
+local P, R, S = lpeg.P, lpeg.R, lpeg.S
+
+local M = {_NAME = '?'}
+
+-- Whitespace.
+local ws = token(l.WHITESPACE, l.space^1)
+
+M._rules = {
+ {'whitespace', ws},
+}
+
+M._tokenstyles = {
+
+}
+
+return M
+```
+
+# Color Themes
+
+The `../themes` directory contains the color schemes. At startup the
+`default.lua` theme which should be a symlink to your prefered style is
+used. Themes can be changed at runtime via the `:set theme <name>`
+command where `<name>` does not include the `.lua` file extension.
+
+# Dependencies
+
+ * [Lua](http://www.lua.org/) 5.1 or greater
+ * [LPeg](http://www.inf.puc-rio.br/~roberto/lpeg/) 0.12 or greater