From 3570869c9ae2c4df14b15423789919e514322916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 7 Dec 2016 16:49:29 +0100 Subject: [PATCH] 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. --- Makefile | 6 ++--- lexers/template.txt | 20 ----------------- {luadoc => lua/doc}/README.md | 0 {luadoc => lua/doc}/config.ld | 2 +- lua/lexer.lua | 1 + {lexers => lua/lexers}/LICENSE | 0 {lexers => lua/lexers}/README.md | 29 +++++++++++++++++++++++-- {lexers => lua/lexers}/actionscript.lua | 0 {lexers => lua/lexers}/ada.lua | 0 {lexers => lua/lexers}/ansi_c.lua | 0 {lexers => lua/lexers}/antlr.lua | 0 {lexers => lua/lexers}/apdl.lua | 0 {lexers => lua/lexers}/apl.lua | 0 {lexers => lua/lexers}/applescript.lua | 0 {lexers => lua/lexers}/asm.lua | 0 {lexers => lua/lexers}/asp.lua | 0 {lexers => lua/lexers}/autoit.lua | 0 {lexers => lua/lexers}/awk.lua | 0 {lexers => lua/lexers}/bash.lua | 0 {lexers => lua/lexers}/batch.lua | 0 {lexers => lua/lexers}/bibtex.lua | 0 {lexers => lua/lexers}/boo.lua | 0 {lexers => lua/lexers}/caml.lua | 0 {lexers => lua/lexers}/chuck.lua | 0 {lexers => lua/lexers}/cmake.lua | 0 {lexers => lua/lexers}/coffeescript.lua | 0 {lexers => lua/lexers}/container.lua | 0 {lexers => lua/lexers}/context.lua | 0 {lexers => lua/lexers}/cpp.lua | 0 {lexers => lua/lexers}/crystal.lua | 0 {lexers => lua/lexers}/csharp.lua | 0 {lexers => lua/lexers}/css.lua | 0 {lexers => lua/lexers}/cuda.lua | 0 {lexers => lua/lexers}/dart.lua | 0 {lexers => lua/lexers}/desktop.lua | 0 {lexers => lua/lexers}/diff.lua | 0 {lexers => lua/lexers}/django.lua | 0 {lexers => lua/lexers}/dmd.lua | 0 {lexers => lua/lexers}/dockerfile.lua | 0 {lexers => lua/lexers}/dot.lua | 0 {lexers => lua/lexers}/dsv.lua | 0 {lexers => lua/lexers}/eiffel.lua | 0 {lexers => lua/lexers}/elixir.lua | 0 {lexers => lua/lexers}/erlang.lua | 0 {lexers => lua/lexers}/faust.lua | 0 {lexers => lua/lexers}/fish.lua | 0 {lexers => lua/lexers}/forth.lua | 0 {lexers => lua/lexers}/fortran.lua | 0 {lexers => lua/lexers}/fsharp.lua | 0 {lexers => lua/lexers}/fstab.lua | 0 {lexers => lua/lexers}/gap.lua | 0 {lexers => lua/lexers}/gettext.lua | 0 {lexers => lua/lexers}/gherkin.lua | 0 {lexers => lua/lexers}/glsl.lua | 0 {lexers => lua/lexers}/gnuplot.lua | 0 {lexers => lua/lexers}/go.lua | 0 {lexers => lua/lexers}/groovy.lua | 0 {lexers => lua/lexers}/gtkrc.lua | 0 {lexers => lua/lexers}/haskell.lua | 0 {lexers => lua/lexers}/html.lua | 0 {lexers => lua/lexers}/icon.lua | 0 {lexers => lua/lexers}/idl.lua | 0 {lexers => lua/lexers}/inform.lua | 0 {lexers => lua/lexers}/ini.lua | 0 {lexers => lua/lexers}/io_lang.lua | 0 {lexers => lua/lexers}/java.lua | 0 {lexers => lua/lexers}/javascript.lua | 0 {lexers => lua/lexers}/json.lua | 0 {lexers => lua/lexers}/jsp.lua | 0 {lexers => lua/lexers}/latex.lua | 0 {lexers => lua/lexers}/ledger.lua | 0 {lexers => lua/lexers}/less.lua | 0 {lexers => lua/lexers}/lexer.lua | 2 +- {lexers => lua/lexers}/lilypond.lua | 0 {lexers => lua/lexers}/lisp.lua | 0 {lexers => lua/lexers}/litcoffee.lua | 0 {lexers => lua/lexers}/lua.lua | 0 {lexers => lua/lexers}/makefile.lua | 0 {lexers => lua/lexers}/man.lua | 0 {lexers => lua/lexers}/markdown.lua | 0 {lexers => lua/lexers}/matlab.lua | 0 {lexers => lua/lexers}/moonscript.lua | 0 {lexers => lua/lexers}/nemerle.lua | 0 {lexers => lua/lexers}/networkd.lua | 0 {lexers => lua/lexers}/nim.lua | 0 {lexers => lua/lexers}/nsis.lua | 0 {lexers => lua/lexers}/null.lua | 0 {lexers => lua/lexers}/objective_c.lua | 0 {lexers => lua/lexers}/pascal.lua | 0 {lexers => lua/lexers}/perl.lua | 0 {lexers => lua/lexers}/php.lua | 0 {lexers => lua/lexers}/pico8.lua | 0 {lexers => lua/lexers}/pike.lua | 0 {lexers => lua/lexers}/pkgbuild.lua | 0 {lexers => lua/lexers}/powershell.lua | 0 {lexers => lua/lexers}/prolog.lua | 0 {lexers => lua/lexers}/props.lua | 0 {lexers => lua/lexers}/protobuf.lua | 0 {lexers => lua/lexers}/ps.lua | 0 {lexers => lua/lexers}/pure.lua | 0 {lexers => lua/lexers}/python.lua | 0 {lexers => lua/lexers}/rails.lua | 0 {lexers => lua/lexers}/rebol.lua | 0 {lexers => lua/lexers}/rest.lua | 0 {lexers => lua/lexers}/rexx.lua | 0 {lexers => lua/lexers}/rhtml.lua | 0 {lexers => lua/lexers}/rstats.lua | 0 {lexers => lua/lexers}/ruby.lua | 0 {lexers => lua/lexers}/rust.lua | 0 {lexers => lua/lexers}/sass.lua | 0 {lexers => lua/lexers}/scala.lua | 0 {lexers => lua/lexers}/scheme.lua | 0 {lexers => lua/lexers}/smalltalk.lua | 0 {lexers => lua/lexers}/sml.lua | 0 {lexers => lua/lexers}/snobol4.lua | 0 {lexers => lua/lexers}/sql.lua | 0 {lexers => lua/lexers}/systemd.lua | 0 {lexers => lua/lexers}/taskpaper.lua | 0 {lexers => lua/lexers}/tcl.lua | 0 {lexers => lua/lexers}/tex.lua | 0 {lexers => lua/lexers}/texinfo.lua | 0 {lexers => lua/lexers}/text.lua | 0 {lexers => lua/lexers}/toml.lua | 0 {lexers => lua/lexers}/vala.lua | 0 {lexers => lua/lexers}/vb.lua | 0 {lexers => lua/lexers}/vbscript.lua | 0 {lexers => lua/lexers}/vcard.lua | 0 {lexers => lua/lexers}/verilog.lua | 0 {lexers => lua/lexers}/vhdl.lua | 0 {lexers => lua/lexers}/wsf.lua | 0 {lexers => lua/lexers}/xml.lua | 0 {lexers => lua/lexers}/xtend.lua | 0 {lexers => lua/lexers}/yaml.lua | 0 {lexers => lua}/themes/dark-16.lua | 0 {lexers => lua}/themes/default-16.lua | 0 {lexers => lua}/themes/default-256.lua | 0 {lexers => lua}/themes/light-16.lua | 0 {lexers => lua}/themes/solarized.lua | 0 vis.lua => lua/vis.lua | 0 visrc.lua => lua/visrc.lua | 0 vis-lua.c | 18 ++++++++++----- 141 files changed, 46 insertions(+), 32 deletions(-) delete mode 100644 lexers/template.txt rename {luadoc => lua/doc}/README.md (100%) rename {luadoc => lua/doc}/config.ld (91%) create mode 120000 lua/lexer.lua rename {lexers => lua/lexers}/LICENSE (100%) rename {lexers => lua/lexers}/README.md (78%) rename {lexers => lua/lexers}/actionscript.lua (100%) rename {lexers => lua/lexers}/ada.lua (100%) rename {lexers => lua/lexers}/ansi_c.lua (100%) rename {lexers => lua/lexers}/antlr.lua (100%) rename {lexers => lua/lexers}/apdl.lua (100%) rename {lexers => lua/lexers}/apl.lua (100%) rename {lexers => lua/lexers}/applescript.lua (100%) rename {lexers => lua/lexers}/asm.lua (100%) rename {lexers => lua/lexers}/asp.lua (100%) rename {lexers => lua/lexers}/autoit.lua (100%) rename {lexers => lua/lexers}/awk.lua (100%) rename {lexers => lua/lexers}/bash.lua (100%) rename {lexers => lua/lexers}/batch.lua (100%) rename {lexers => lua/lexers}/bibtex.lua (100%) rename {lexers => lua/lexers}/boo.lua (100%) rename {lexers => lua/lexers}/caml.lua (100%) rename {lexers => lua/lexers}/chuck.lua (100%) rename {lexers => lua/lexers}/cmake.lua (100%) rename {lexers => lua/lexers}/coffeescript.lua (100%) rename {lexers => lua/lexers}/container.lua (100%) rename {lexers => lua/lexers}/context.lua (100%) rename {lexers => lua/lexers}/cpp.lua (100%) rename {lexers => lua/lexers}/crystal.lua (100%) rename {lexers => lua/lexers}/csharp.lua (100%) rename {lexers => lua/lexers}/css.lua (100%) rename {lexers => lua/lexers}/cuda.lua (100%) rename {lexers => lua/lexers}/dart.lua (100%) rename {lexers => lua/lexers}/desktop.lua (100%) rename {lexers => lua/lexers}/diff.lua (100%) rename {lexers => lua/lexers}/django.lua (100%) rename {lexers => lua/lexers}/dmd.lua (100%) rename {lexers => lua/lexers}/dockerfile.lua (100%) rename {lexers => lua/lexers}/dot.lua (100%) rename {lexers => lua/lexers}/dsv.lua (100%) rename {lexers => lua/lexers}/eiffel.lua (100%) rename {lexers => lua/lexers}/elixir.lua (100%) rename {lexers => lua/lexers}/erlang.lua (100%) rename {lexers => lua/lexers}/faust.lua (100%) rename {lexers => lua/lexers}/fish.lua (100%) rename {lexers => lua/lexers}/forth.lua (100%) rename {lexers => lua/lexers}/fortran.lua (100%) rename {lexers => lua/lexers}/fsharp.lua (100%) rename {lexers => lua/lexers}/fstab.lua (100%) rename {lexers => lua/lexers}/gap.lua (100%) rename {lexers => lua/lexers}/gettext.lua (100%) rename {lexers => lua/lexers}/gherkin.lua (100%) rename {lexers => lua/lexers}/glsl.lua (100%) rename {lexers => lua/lexers}/gnuplot.lua (100%) rename {lexers => lua/lexers}/go.lua (100%) rename {lexers => lua/lexers}/groovy.lua (100%) rename {lexers => lua/lexers}/gtkrc.lua (100%) rename {lexers => lua/lexers}/haskell.lua (100%) rename {lexers => lua/lexers}/html.lua (100%) rename {lexers => lua/lexers}/icon.lua (100%) rename {lexers => lua/lexers}/idl.lua (100%) rename {lexers => lua/lexers}/inform.lua (100%) rename {lexers => lua/lexers}/ini.lua (100%) rename {lexers => lua/lexers}/io_lang.lua (100%) rename {lexers => lua/lexers}/java.lua (100%) rename {lexers => lua/lexers}/javascript.lua (100%) rename {lexers => lua/lexers}/json.lua (100%) rename {lexers => lua/lexers}/jsp.lua (100%) rename {lexers => lua/lexers}/latex.lua (100%) rename {lexers => lua/lexers}/ledger.lua (100%) rename {lexers => lua/lexers}/less.lua (100%) rename {lexers => lua/lexers}/lexer.lua (99%) rename {lexers => lua/lexers}/lilypond.lua (100%) rename {lexers => lua/lexers}/lisp.lua (100%) rename {lexers => lua/lexers}/litcoffee.lua (100%) rename {lexers => lua/lexers}/lua.lua (100%) rename {lexers => lua/lexers}/makefile.lua (100%) rename {lexers => lua/lexers}/man.lua (100%) rename {lexers => lua/lexers}/markdown.lua (100%) rename {lexers => lua/lexers}/matlab.lua (100%) rename {lexers => lua/lexers}/moonscript.lua (100%) rename {lexers => lua/lexers}/nemerle.lua (100%) rename {lexers => lua/lexers}/networkd.lua (100%) rename {lexers => lua/lexers}/nim.lua (100%) rename {lexers => lua/lexers}/nsis.lua (100%) rename {lexers => lua/lexers}/null.lua (100%) rename {lexers => lua/lexers}/objective_c.lua (100%) rename {lexers => lua/lexers}/pascal.lua (100%) rename {lexers => lua/lexers}/perl.lua (100%) rename {lexers => lua/lexers}/php.lua (100%) rename {lexers => lua/lexers}/pico8.lua (100%) rename {lexers => lua/lexers}/pike.lua (100%) rename {lexers => lua/lexers}/pkgbuild.lua (100%) rename {lexers => lua/lexers}/powershell.lua (100%) rename {lexers => lua/lexers}/prolog.lua (100%) rename {lexers => lua/lexers}/props.lua (100%) rename {lexers => lua/lexers}/protobuf.lua (100%) rename {lexers => lua/lexers}/ps.lua (100%) rename {lexers => lua/lexers}/pure.lua (100%) rename {lexers => lua/lexers}/python.lua (100%) rename {lexers => lua/lexers}/rails.lua (100%) rename {lexers => lua/lexers}/rebol.lua (100%) rename {lexers => lua/lexers}/rest.lua (100%) rename {lexers => lua/lexers}/rexx.lua (100%) rename {lexers => lua/lexers}/rhtml.lua (100%) rename {lexers => lua/lexers}/rstats.lua (100%) rename {lexers => lua/lexers}/ruby.lua (100%) rename {lexers => lua/lexers}/rust.lua (100%) rename {lexers => lua/lexers}/sass.lua (100%) rename {lexers => lua/lexers}/scala.lua (100%) rename {lexers => lua/lexers}/scheme.lua (100%) rename {lexers => lua/lexers}/smalltalk.lua (100%) rename {lexers => lua/lexers}/sml.lua (100%) rename {lexers => lua/lexers}/snobol4.lua (100%) rename {lexers => lua/lexers}/sql.lua (100%) rename {lexers => lua/lexers}/systemd.lua (100%) rename {lexers => lua/lexers}/taskpaper.lua (100%) rename {lexers => lua/lexers}/tcl.lua (100%) rename {lexers => lua/lexers}/tex.lua (100%) rename {lexers => lua/lexers}/texinfo.lua (100%) rename {lexers => lua/lexers}/text.lua (100%) rename {lexers => lua/lexers}/toml.lua (100%) rename {lexers => lua/lexers}/vala.lua (100%) rename {lexers => lua/lexers}/vb.lua (100%) rename {lexers => lua/lexers}/vbscript.lua (100%) rename {lexers => lua/lexers}/vcard.lua (100%) rename {lexers => lua/lexers}/verilog.lua (100%) rename {lexers => lua/lexers}/vhdl.lua (100%) rename {lexers => lua/lexers}/wsf.lua (100%) rename {lexers => lua/lexers}/xml.lua (100%) rename {lexers => lua/lexers}/xtend.lua (100%) rename {lexers => lua/lexers}/yaml.lua (100%) rename {lexers => lua}/themes/dark-16.lua (100%) rename {lexers => lua}/themes/default-16.lua (100%) rename {lexers => lua}/themes/default-256.lua (100%) rename {lexers => lua}/themes/light-16.lua (100%) rename {lexers => lua}/themes/solarized.lua (100%) rename vis.lua => lua/vis.lua (100%) rename visrc.lua => lua/visrc.lua (100%) diff --git a/Makefile b/Makefile index 42260b9f3..b7ebd0a91 100644 --- a/Makefile +++ b/Makefile @@ -86,10 +86,10 @@ man: done luadoc: - @cd luadoc && ldoc . && sed -e "s/RELEASE/${VERSION}/" -i index.html + @cd lua/doc && ldoc . && sed -e "s/RELEASE/${VERSION}/" -i index.html luadoc-all: - @cd luadoc && ldoc -a . && sed -e "s/RELEASE/${VERSION}/" -i index.html + @cd lua/doc && ldoc -a . && sed -e "s/RELEASE/${VERSION}/" -i index.html install: vis vis-menu @echo stripping executable @@ -109,7 +109,7 @@ install: vis vis-menu @test ${CONFIG_LUA} -eq 0 || { \ echo installing support files to ${DESTDIR}${SHAREPREFIX}/vis; \ mkdir -p ${DESTDIR}${SHAREPREFIX}/vis; \ - cp -r visrc.lua vis.lua lexers ${DESTDIR}${SHAREPREFIX}/vis; \ + cp -r lua/* ${DESTDIR}${SHAREPREFIX}/vis; \ } @echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1 @mkdir -p ${DESTDIR}${MANPREFIX}/man1 diff --git a/lexers/template.txt b/lexers/template.txt deleted file mode 100644 index 4f8c560d9..000000000 --- a/lexers/template.txt +++ /dev/null @@ -1,20 +0,0 @@ --- ? 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 diff --git a/luadoc/README.md b/lua/doc/README.md similarity index 100% rename from luadoc/README.md rename to lua/doc/README.md diff --git a/luadoc/config.ld b/lua/doc/config.ld similarity index 91% rename from luadoc/config.ld rename to lua/doc/config.ld index 8567a895f..a955b38b4 100644 --- a/luadoc/config.ld +++ b/lua/doc/config.ld @@ -8,7 +8,7 @@ sort=true merge=true no_space_before_args=true file={ - "../vis-lua.c", + "../../vis-lua.c", "../vis.lua", } \ No newline at end of file diff --git a/lua/lexer.lua b/lua/lexer.lua new file mode 120000 index 000000000..9d757ac84 --- /dev/null +++ b/lua/lexer.lua @@ -0,0 +1 @@ +lexers/lexer.lua \ No newline at end of file diff --git a/lexers/LICENSE b/lua/lexers/LICENSE similarity index 100% rename from lexers/LICENSE rename to lua/lexers/LICENSE diff --git a/lexers/README.md b/lua/lexers/README.md similarity index 78% rename from lexers/README.md rename to lua/lexers/README.md index 6e43e9481..69c136d5b 100644 --- a/lexers/README.md +++ b/lua/lexers/README.md @@ -9,7 +9,7 @@ based lexers from the [Scintillua](http://foicica.com/scintillua/) project. Vis searches the lexers in the following locations: * `$VIS_PATH/lexers` - * `./lexers` relative to the binary location (using `/proc/self/exe`) + * `./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` @@ -36,9 +36,34 @@ 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` sub directory contains the color schemes. At startup the +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 ` command where `` does not include the `.lua` file extension. diff --git a/lexers/actionscript.lua b/lua/lexers/actionscript.lua similarity index 100% rename from lexers/actionscript.lua rename to lua/lexers/actionscript.lua diff --git a/lexers/ada.lua b/lua/lexers/ada.lua similarity index 100% rename from lexers/ada.lua rename to lua/lexers/ada.lua diff --git a/lexers/ansi_c.lua b/lua/lexers/ansi_c.lua similarity index 100% rename from lexers/ansi_c.lua rename to lua/lexers/ansi_c.lua diff --git a/lexers/antlr.lua b/lua/lexers/antlr.lua similarity index 100% rename from lexers/antlr.lua rename to lua/lexers/antlr.lua diff --git a/lexers/apdl.lua b/lua/lexers/apdl.lua similarity index 100% rename from lexers/apdl.lua rename to lua/lexers/apdl.lua diff --git a/lexers/apl.lua b/lua/lexers/apl.lua similarity index 100% rename from lexers/apl.lua rename to lua/lexers/apl.lua diff --git a/lexers/applescript.lua b/lua/lexers/applescript.lua similarity index 100% rename from lexers/applescript.lua rename to lua/lexers/applescript.lua diff --git a/lexers/asm.lua b/lua/lexers/asm.lua similarity index 100% rename from lexers/asm.lua rename to lua/lexers/asm.lua diff --git a/lexers/asp.lua b/lua/lexers/asp.lua similarity index 100% rename from lexers/asp.lua rename to lua/lexers/asp.lua diff --git a/lexers/autoit.lua b/lua/lexers/autoit.lua similarity index 100% rename from lexers/autoit.lua rename to lua/lexers/autoit.lua diff --git a/lexers/awk.lua b/lua/lexers/awk.lua similarity index 100% rename from lexers/awk.lua rename to lua/lexers/awk.lua diff --git a/lexers/bash.lua b/lua/lexers/bash.lua similarity index 100% rename from lexers/bash.lua rename to lua/lexers/bash.lua diff --git a/lexers/batch.lua b/lua/lexers/batch.lua similarity index 100% rename from lexers/batch.lua rename to lua/lexers/batch.lua diff --git a/lexers/bibtex.lua b/lua/lexers/bibtex.lua similarity index 100% rename from lexers/bibtex.lua rename to lua/lexers/bibtex.lua diff --git a/lexers/boo.lua b/lua/lexers/boo.lua similarity index 100% rename from lexers/boo.lua rename to lua/lexers/boo.lua diff --git a/lexers/caml.lua b/lua/lexers/caml.lua similarity index 100% rename from lexers/caml.lua rename to lua/lexers/caml.lua diff --git a/lexers/chuck.lua b/lua/lexers/chuck.lua similarity index 100% rename from lexers/chuck.lua rename to lua/lexers/chuck.lua diff --git a/lexers/cmake.lua b/lua/lexers/cmake.lua similarity index 100% rename from lexers/cmake.lua rename to lua/lexers/cmake.lua diff --git a/lexers/coffeescript.lua b/lua/lexers/coffeescript.lua similarity index 100% rename from lexers/coffeescript.lua rename to lua/lexers/coffeescript.lua diff --git a/lexers/container.lua b/lua/lexers/container.lua similarity index 100% rename from lexers/container.lua rename to lua/lexers/container.lua diff --git a/lexers/context.lua b/lua/lexers/context.lua similarity index 100% rename from lexers/context.lua rename to lua/lexers/context.lua diff --git a/lexers/cpp.lua b/lua/lexers/cpp.lua similarity index 100% rename from lexers/cpp.lua rename to lua/lexers/cpp.lua diff --git a/lexers/crystal.lua b/lua/lexers/crystal.lua similarity index 100% rename from lexers/crystal.lua rename to lua/lexers/crystal.lua diff --git a/lexers/csharp.lua b/lua/lexers/csharp.lua similarity index 100% rename from lexers/csharp.lua rename to lua/lexers/csharp.lua diff --git a/lexers/css.lua b/lua/lexers/css.lua similarity index 100% rename from lexers/css.lua rename to lua/lexers/css.lua diff --git a/lexers/cuda.lua b/lua/lexers/cuda.lua similarity index 100% rename from lexers/cuda.lua rename to lua/lexers/cuda.lua diff --git a/lexers/dart.lua b/lua/lexers/dart.lua similarity index 100% rename from lexers/dart.lua rename to lua/lexers/dart.lua diff --git a/lexers/desktop.lua b/lua/lexers/desktop.lua similarity index 100% rename from lexers/desktop.lua rename to lua/lexers/desktop.lua diff --git a/lexers/diff.lua b/lua/lexers/diff.lua similarity index 100% rename from lexers/diff.lua rename to lua/lexers/diff.lua diff --git a/lexers/django.lua b/lua/lexers/django.lua similarity index 100% rename from lexers/django.lua rename to lua/lexers/django.lua diff --git a/lexers/dmd.lua b/lua/lexers/dmd.lua similarity index 100% rename from lexers/dmd.lua rename to lua/lexers/dmd.lua diff --git a/lexers/dockerfile.lua b/lua/lexers/dockerfile.lua similarity index 100% rename from lexers/dockerfile.lua rename to lua/lexers/dockerfile.lua diff --git a/lexers/dot.lua b/lua/lexers/dot.lua similarity index 100% rename from lexers/dot.lua rename to lua/lexers/dot.lua diff --git a/lexers/dsv.lua b/lua/lexers/dsv.lua similarity index 100% rename from lexers/dsv.lua rename to lua/lexers/dsv.lua diff --git a/lexers/eiffel.lua b/lua/lexers/eiffel.lua similarity index 100% rename from lexers/eiffel.lua rename to lua/lexers/eiffel.lua diff --git a/lexers/elixir.lua b/lua/lexers/elixir.lua similarity index 100% rename from lexers/elixir.lua rename to lua/lexers/elixir.lua diff --git a/lexers/erlang.lua b/lua/lexers/erlang.lua similarity index 100% rename from lexers/erlang.lua rename to lua/lexers/erlang.lua diff --git a/lexers/faust.lua b/lua/lexers/faust.lua similarity index 100% rename from lexers/faust.lua rename to lua/lexers/faust.lua diff --git a/lexers/fish.lua b/lua/lexers/fish.lua similarity index 100% rename from lexers/fish.lua rename to lua/lexers/fish.lua diff --git a/lexers/forth.lua b/lua/lexers/forth.lua similarity index 100% rename from lexers/forth.lua rename to lua/lexers/forth.lua diff --git a/lexers/fortran.lua b/lua/lexers/fortran.lua similarity index 100% rename from lexers/fortran.lua rename to lua/lexers/fortran.lua diff --git a/lexers/fsharp.lua b/lua/lexers/fsharp.lua similarity index 100% rename from lexers/fsharp.lua rename to lua/lexers/fsharp.lua diff --git a/lexers/fstab.lua b/lua/lexers/fstab.lua similarity index 100% rename from lexers/fstab.lua rename to lua/lexers/fstab.lua diff --git a/lexers/gap.lua b/lua/lexers/gap.lua similarity index 100% rename from lexers/gap.lua rename to lua/lexers/gap.lua diff --git a/lexers/gettext.lua b/lua/lexers/gettext.lua similarity index 100% rename from lexers/gettext.lua rename to lua/lexers/gettext.lua diff --git a/lexers/gherkin.lua b/lua/lexers/gherkin.lua similarity index 100% rename from lexers/gherkin.lua rename to lua/lexers/gherkin.lua diff --git a/lexers/glsl.lua b/lua/lexers/glsl.lua similarity index 100% rename from lexers/glsl.lua rename to lua/lexers/glsl.lua diff --git a/lexers/gnuplot.lua b/lua/lexers/gnuplot.lua similarity index 100% rename from lexers/gnuplot.lua rename to lua/lexers/gnuplot.lua diff --git a/lexers/go.lua b/lua/lexers/go.lua similarity index 100% rename from lexers/go.lua rename to lua/lexers/go.lua diff --git a/lexers/groovy.lua b/lua/lexers/groovy.lua similarity index 100% rename from lexers/groovy.lua rename to lua/lexers/groovy.lua diff --git a/lexers/gtkrc.lua b/lua/lexers/gtkrc.lua similarity index 100% rename from lexers/gtkrc.lua rename to lua/lexers/gtkrc.lua diff --git a/lexers/haskell.lua b/lua/lexers/haskell.lua similarity index 100% rename from lexers/haskell.lua rename to lua/lexers/haskell.lua diff --git a/lexers/html.lua b/lua/lexers/html.lua similarity index 100% rename from lexers/html.lua rename to lua/lexers/html.lua diff --git a/lexers/icon.lua b/lua/lexers/icon.lua similarity index 100% rename from lexers/icon.lua rename to lua/lexers/icon.lua diff --git a/lexers/idl.lua b/lua/lexers/idl.lua similarity index 100% rename from lexers/idl.lua rename to lua/lexers/idl.lua diff --git a/lexers/inform.lua b/lua/lexers/inform.lua similarity index 100% rename from lexers/inform.lua rename to lua/lexers/inform.lua diff --git a/lexers/ini.lua b/lua/lexers/ini.lua similarity index 100% rename from lexers/ini.lua rename to lua/lexers/ini.lua diff --git a/lexers/io_lang.lua b/lua/lexers/io_lang.lua similarity index 100% rename from lexers/io_lang.lua rename to lua/lexers/io_lang.lua diff --git a/lexers/java.lua b/lua/lexers/java.lua similarity index 100% rename from lexers/java.lua rename to lua/lexers/java.lua diff --git a/lexers/javascript.lua b/lua/lexers/javascript.lua similarity index 100% rename from lexers/javascript.lua rename to lua/lexers/javascript.lua diff --git a/lexers/json.lua b/lua/lexers/json.lua similarity index 100% rename from lexers/json.lua rename to lua/lexers/json.lua diff --git a/lexers/jsp.lua b/lua/lexers/jsp.lua similarity index 100% rename from lexers/jsp.lua rename to lua/lexers/jsp.lua diff --git a/lexers/latex.lua b/lua/lexers/latex.lua similarity index 100% rename from lexers/latex.lua rename to lua/lexers/latex.lua diff --git a/lexers/ledger.lua b/lua/lexers/ledger.lua similarity index 100% rename from lexers/ledger.lua rename to lua/lexers/ledger.lua diff --git a/lexers/less.lua b/lua/lexers/less.lua similarity index 100% rename from lexers/less.lua rename to lua/lexers/less.lua diff --git a/lexers/lexer.lua b/lua/lexers/lexer.lua similarity index 99% rename from lexers/lexer.lua rename to lua/lexers/lexer.lua index 5653bb285..b896344e1 100644 --- a/lexers/lexer.lua +++ b/lua/lexers/lexer.lua @@ -1039,7 +1039,7 @@ function M.load(name, alt_name) -- Load the language lexer with its rules, styles, etc. M.WHITESPACE = (alt_name or name)..'_whitespace' - local lexer_file, error = package.searchpath(name, M.LEXERPATH) + local lexer_file, error = package.searchpath('lexers/'..name, M.LEXERPATH) local ok, lexer = pcall(dofile, lexer_file or '') if not ok then return nil diff --git a/lexers/lilypond.lua b/lua/lexers/lilypond.lua similarity index 100% rename from lexers/lilypond.lua rename to lua/lexers/lilypond.lua diff --git a/lexers/lisp.lua b/lua/lexers/lisp.lua similarity index 100% rename from lexers/lisp.lua rename to lua/lexers/lisp.lua diff --git a/lexers/litcoffee.lua b/lua/lexers/litcoffee.lua similarity index 100% rename from lexers/litcoffee.lua rename to lua/lexers/litcoffee.lua diff --git a/lexers/lua.lua b/lua/lexers/lua.lua similarity index 100% rename from lexers/lua.lua rename to lua/lexers/lua.lua diff --git a/lexers/makefile.lua b/lua/lexers/makefile.lua similarity index 100% rename from lexers/makefile.lua rename to lua/lexers/makefile.lua diff --git a/lexers/man.lua b/lua/lexers/man.lua similarity index 100% rename from lexers/man.lua rename to lua/lexers/man.lua diff --git a/lexers/markdown.lua b/lua/lexers/markdown.lua similarity index 100% rename from lexers/markdown.lua rename to lua/lexers/markdown.lua diff --git a/lexers/matlab.lua b/lua/lexers/matlab.lua similarity index 100% rename from lexers/matlab.lua rename to lua/lexers/matlab.lua diff --git a/lexers/moonscript.lua b/lua/lexers/moonscript.lua similarity index 100% rename from lexers/moonscript.lua rename to lua/lexers/moonscript.lua diff --git a/lexers/nemerle.lua b/lua/lexers/nemerle.lua similarity index 100% rename from lexers/nemerle.lua rename to lua/lexers/nemerle.lua diff --git a/lexers/networkd.lua b/lua/lexers/networkd.lua similarity index 100% rename from lexers/networkd.lua rename to lua/lexers/networkd.lua diff --git a/lexers/nim.lua b/lua/lexers/nim.lua similarity index 100% rename from lexers/nim.lua rename to lua/lexers/nim.lua diff --git a/lexers/nsis.lua b/lua/lexers/nsis.lua similarity index 100% rename from lexers/nsis.lua rename to lua/lexers/nsis.lua diff --git a/lexers/null.lua b/lua/lexers/null.lua similarity index 100% rename from lexers/null.lua rename to lua/lexers/null.lua diff --git a/lexers/objective_c.lua b/lua/lexers/objective_c.lua similarity index 100% rename from lexers/objective_c.lua rename to lua/lexers/objective_c.lua diff --git a/lexers/pascal.lua b/lua/lexers/pascal.lua similarity index 100% rename from lexers/pascal.lua rename to lua/lexers/pascal.lua diff --git a/lexers/perl.lua b/lua/lexers/perl.lua similarity index 100% rename from lexers/perl.lua rename to lua/lexers/perl.lua diff --git a/lexers/php.lua b/lua/lexers/php.lua similarity index 100% rename from lexers/php.lua rename to lua/lexers/php.lua diff --git a/lexers/pico8.lua b/lua/lexers/pico8.lua similarity index 100% rename from lexers/pico8.lua rename to lua/lexers/pico8.lua diff --git a/lexers/pike.lua b/lua/lexers/pike.lua similarity index 100% rename from lexers/pike.lua rename to lua/lexers/pike.lua diff --git a/lexers/pkgbuild.lua b/lua/lexers/pkgbuild.lua similarity index 100% rename from lexers/pkgbuild.lua rename to lua/lexers/pkgbuild.lua diff --git a/lexers/powershell.lua b/lua/lexers/powershell.lua similarity index 100% rename from lexers/powershell.lua rename to lua/lexers/powershell.lua diff --git a/lexers/prolog.lua b/lua/lexers/prolog.lua similarity index 100% rename from lexers/prolog.lua rename to lua/lexers/prolog.lua diff --git a/lexers/props.lua b/lua/lexers/props.lua similarity index 100% rename from lexers/props.lua rename to lua/lexers/props.lua diff --git a/lexers/protobuf.lua b/lua/lexers/protobuf.lua similarity index 100% rename from lexers/protobuf.lua rename to lua/lexers/protobuf.lua diff --git a/lexers/ps.lua b/lua/lexers/ps.lua similarity index 100% rename from lexers/ps.lua rename to lua/lexers/ps.lua diff --git a/lexers/pure.lua b/lua/lexers/pure.lua similarity index 100% rename from lexers/pure.lua rename to lua/lexers/pure.lua diff --git a/lexers/python.lua b/lua/lexers/python.lua similarity index 100% rename from lexers/python.lua rename to lua/lexers/python.lua diff --git a/lexers/rails.lua b/lua/lexers/rails.lua similarity index 100% rename from lexers/rails.lua rename to lua/lexers/rails.lua diff --git a/lexers/rebol.lua b/lua/lexers/rebol.lua similarity index 100% rename from lexers/rebol.lua rename to lua/lexers/rebol.lua diff --git a/lexers/rest.lua b/lua/lexers/rest.lua similarity index 100% rename from lexers/rest.lua rename to lua/lexers/rest.lua diff --git a/lexers/rexx.lua b/lua/lexers/rexx.lua similarity index 100% rename from lexers/rexx.lua rename to lua/lexers/rexx.lua diff --git a/lexers/rhtml.lua b/lua/lexers/rhtml.lua similarity index 100% rename from lexers/rhtml.lua rename to lua/lexers/rhtml.lua diff --git a/lexers/rstats.lua b/lua/lexers/rstats.lua similarity index 100% rename from lexers/rstats.lua rename to lua/lexers/rstats.lua diff --git a/lexers/ruby.lua b/lua/lexers/ruby.lua similarity index 100% rename from lexers/ruby.lua rename to lua/lexers/ruby.lua diff --git a/lexers/rust.lua b/lua/lexers/rust.lua similarity index 100% rename from lexers/rust.lua rename to lua/lexers/rust.lua diff --git a/lexers/sass.lua b/lua/lexers/sass.lua similarity index 100% rename from lexers/sass.lua rename to lua/lexers/sass.lua diff --git a/lexers/scala.lua b/lua/lexers/scala.lua similarity index 100% rename from lexers/scala.lua rename to lua/lexers/scala.lua diff --git a/lexers/scheme.lua b/lua/lexers/scheme.lua similarity index 100% rename from lexers/scheme.lua rename to lua/lexers/scheme.lua diff --git a/lexers/smalltalk.lua b/lua/lexers/smalltalk.lua similarity index 100% rename from lexers/smalltalk.lua rename to lua/lexers/smalltalk.lua diff --git a/lexers/sml.lua b/lua/lexers/sml.lua similarity index 100% rename from lexers/sml.lua rename to lua/lexers/sml.lua diff --git a/lexers/snobol4.lua b/lua/lexers/snobol4.lua similarity index 100% rename from lexers/snobol4.lua rename to lua/lexers/snobol4.lua diff --git a/lexers/sql.lua b/lua/lexers/sql.lua similarity index 100% rename from lexers/sql.lua rename to lua/lexers/sql.lua diff --git a/lexers/systemd.lua b/lua/lexers/systemd.lua similarity index 100% rename from lexers/systemd.lua rename to lua/lexers/systemd.lua diff --git a/lexers/taskpaper.lua b/lua/lexers/taskpaper.lua similarity index 100% rename from lexers/taskpaper.lua rename to lua/lexers/taskpaper.lua diff --git a/lexers/tcl.lua b/lua/lexers/tcl.lua similarity index 100% rename from lexers/tcl.lua rename to lua/lexers/tcl.lua diff --git a/lexers/tex.lua b/lua/lexers/tex.lua similarity index 100% rename from lexers/tex.lua rename to lua/lexers/tex.lua diff --git a/lexers/texinfo.lua b/lua/lexers/texinfo.lua similarity index 100% rename from lexers/texinfo.lua rename to lua/lexers/texinfo.lua diff --git a/lexers/text.lua b/lua/lexers/text.lua similarity index 100% rename from lexers/text.lua rename to lua/lexers/text.lua diff --git a/lexers/toml.lua b/lua/lexers/toml.lua similarity index 100% rename from lexers/toml.lua rename to lua/lexers/toml.lua diff --git a/lexers/vala.lua b/lua/lexers/vala.lua similarity index 100% rename from lexers/vala.lua rename to lua/lexers/vala.lua diff --git a/lexers/vb.lua b/lua/lexers/vb.lua similarity index 100% rename from lexers/vb.lua rename to lua/lexers/vb.lua diff --git a/lexers/vbscript.lua b/lua/lexers/vbscript.lua similarity index 100% rename from lexers/vbscript.lua rename to lua/lexers/vbscript.lua diff --git a/lexers/vcard.lua b/lua/lexers/vcard.lua similarity index 100% rename from lexers/vcard.lua rename to lua/lexers/vcard.lua diff --git a/lexers/verilog.lua b/lua/lexers/verilog.lua similarity index 100% rename from lexers/verilog.lua rename to lua/lexers/verilog.lua diff --git a/lexers/vhdl.lua b/lua/lexers/vhdl.lua similarity index 100% rename from lexers/vhdl.lua rename to lua/lexers/vhdl.lua diff --git a/lexers/wsf.lua b/lua/lexers/wsf.lua similarity index 100% rename from lexers/wsf.lua rename to lua/lexers/wsf.lua diff --git a/lexers/xml.lua b/lua/lexers/xml.lua similarity index 100% rename from lexers/xml.lua rename to lua/lexers/xml.lua diff --git a/lexers/xtend.lua b/lua/lexers/xtend.lua similarity index 100% rename from lexers/xtend.lua rename to lua/lexers/xtend.lua diff --git a/lexers/yaml.lua b/lua/lexers/yaml.lua similarity index 100% rename from lexers/yaml.lua rename to lua/lexers/yaml.lua diff --git a/lexers/themes/dark-16.lua b/lua/themes/dark-16.lua similarity index 100% rename from lexers/themes/dark-16.lua rename to lua/themes/dark-16.lua diff --git a/lexers/themes/default-16.lua b/lua/themes/default-16.lua similarity index 100% rename from lexers/themes/default-16.lua rename to lua/themes/default-16.lua diff --git a/lexers/themes/default-256.lua b/lua/themes/default-256.lua similarity index 100% rename from lexers/themes/default-256.lua rename to lua/themes/default-256.lua diff --git a/lexers/themes/light-16.lua b/lua/themes/light-16.lua similarity index 100% rename from lexers/themes/light-16.lua rename to lua/themes/light-16.lua diff --git a/lexers/themes/solarized.lua b/lua/themes/solarized.lua similarity index 100% rename from lexers/themes/solarized.lua rename to lua/themes/solarized.lua diff --git a/vis.lua b/lua/vis.lua similarity index 100% rename from vis.lua rename to lua/vis.lua diff --git a/visrc.lua b/lua/visrc.lua similarity index 100% rename from visrc.lua rename to lua/visrc.lua diff --git a/vis-lua.c b/vis-lua.c index b88a1d17d..f3b011498 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -1804,10 +1804,8 @@ bool vis_lua_path_add(Vis *vis, const char *path) { lua_getglobal(L, "package"); lua_pushstring(L, path); lua_pushstring(L, "/?.lua;"); - lua_pushstring(L, path); - lua_pushstring(L, "/lexers/?.lua;"); - lua_getfield(L, -5, "path"); - lua_concat(L, 5); + lua_getfield(L, -3, "path"); + lua_concat(L, 3); lua_setfield(L, -2, "path"); lua_pop(L, 1); /* package */ return true; @@ -1888,7 +1886,17 @@ void vis_lua_init(Vis *vis) { ssize_t len = readlink("/proc/self/exe", path, sizeof(path)-1); if (len > 0) { path[len] = '\0'; - vis_lua_path_add(vis, dirname(path)); + /* some idotic dirname(3) implementations return pointers to statically + * allocated memory, hence we use memmove to copy it back */ + char *dir = dirname(path); + if (dir) { + size_t len = strlen(dir)+1; + if (len < sizeof(path) - sizeof("/lua")) { + memmove(path, dir, len); + strcat(path, "/lua"); + vis_lua_path_add(vis, path); + } + } } vis_lua_path_add(vis, getenv("VIS_PATH"));