aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile3
-rw-r--r--README.md3
-rw-r--r--lexers/README.md1
-rw-r--r--vis-lua.c17
-rw-r--r--vis.14
5 files changed, 23 insertions, 5 deletions
diff --git a/GNUmakefile b/GNUmakefile
index f6e57d7..4773324 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -147,7 +147,7 @@ local: clean dependencies
CFLAGS_TERMKEY= LDFLAGS_TERMKEY=-ltermkey \
CFLAGS_LUA="-DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_ALL" \
LDFLAGS_LUA="-llua -lm -ldl"
- @echo Run with: LD_LIBRARY_PATH=$(DEPS_LIB) VIS_PATH=. ./vis
+ @echo Run with: LD_LIBRARY_PATH=$(DEPS_LIB) ./vis
standalone: clean dependency/sources/install-libmusl
PATH=$(DEPS_BIN):$$PATH PKG_CONFIG_PATH= PKG_CONFIG_LIBDIR= $(MAKE) \
@@ -160,6 +160,5 @@ standalone: clean dependency/sources/install-libmusl
LDFLAGS_LUA="-llua -lm -ldl" \
CONFIG_ACL=0 CFLAGS_ACL= LDFLAGS_ACL= \
CONFIG_SELINUX=0 CFLAGS_SELINUX= LDFLAGS_SELINUX=
- @echo Run with: VIS_PATH=. ./vis
.PHONY: standalone dependencies dependencies-full local \ No newline at end of file
diff --git a/README.md b/README.md
index 367d020..9fb3e00 100644
--- a/README.md
+++ b/README.md
@@ -47,8 +47,7 @@ In order to build vis you will need a C99 compiler as well as:
Assuming these dependencies are met, execute:
- $ ./configure && make
- $ VIS_PATH=. ./vis config.h
+ $ ./configure && make && sudo make install
By default the `configure` script will try to auto detect support for
Lua. See `configure --help` for a list of supported options. You can
diff --git a/lexers/README.md b/lexers/README.md
index a7d25c2..34ca587 100644
--- a/lexers/README.md
+++ b/lexers/README.md
@@ -9,6 +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`)
* `$XDG_CONFIG_HOME/vis/lexers`
* `/usr/local/share/vis/lexers`
* `/usr/share/vis/lexers`
diff --git a/vis-lua.c b/vis-lua.c
index 35dbe95..c25f64d 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -1,6 +1,9 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include <limits.h>
+#include <unistd.h>
+#include <libgen.h>
#include <sys/types.h>
#include <pwd.h>
@@ -823,6 +826,7 @@ void vis_lua_start(Vis *vis) {
/* extends lua's package.path with:
* - $VIS_PATH/{,lexers}
+ * - {,lexers} relative to the binary location
* - $XDG_CONFIG_HOME/vis/{,lexers} (defaulting to $HOME/.config/vis/{,lexers})
* - /usr/local/share/vis/{,lexers}
* - /usr/share/vis/{,lexers}
@@ -841,6 +845,19 @@ void vis_lua_start(Vis *vis) {
paths++;
}
+ char exe[PATH_MAX];
+ ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe)-1);
+ if (len > 0) {
+ exe[len] = '\0';
+ char *exe_path = dirname(exe);
+ lua_pushstring(L, exe_path);
+ lua_pushstring(L, "/?.lua;");
+ lua_pushstring(L, exe_path);
+ lua_pushstring(L, "/lexers/?.lua;");
+ lua_concat(L, 4);
+ paths++;
+ }
+
/* try to get users home directory */
const char *home = getenv("HOME");
if (!home || !*home) {
diff --git a/vis.1 b/vis.1
index 4aafd4e..b655921 100644
--- a/vis.1
+++ b/vis.1
@@ -24,7 +24,9 @@ Defaults (in this order) to:
.RS
.RS
.TP
-.B $XDG_CONFIG_HOME/vis
+The location of the vis binary
+.TP
+.B $XDG_CONFIG_HOME/vis
where
.B $XDG_CONFIG_HOME
refers to