aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-11-05 16:28:59 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-11-05 16:28:59 +0100
commit47e82949164c23973dbad72d3982d9aef557d118 (patch)
tree27b0ff988cbdd896a27f52882a8da77a27ecb7be /vis-lua.c
parentfb414a7a85c6b8843d18030f07db0b8c80cc0251 (diff)
downloadvis-47e82949164c23973dbad72d3982d9aef557d118.tar.gz
vis-47e82949164c23973dbad72d3982d9aef557d118.tar.xz
vis: display Lua package.cpath in :help output
These paths are used to load the Lua LPeg module (lpeg.so) and are thus helpful when diagnosing setup problems in case syntax highlighting does not work.
Diffstat (limited to 'vis-lua.c')
-rw-r--r--vis-lua.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/vis-lua.c b/vis-lua.c
index 7f045fa..8431111 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -123,7 +123,7 @@ static void window_status_update(Vis *vis, Win *win) {
#if !CONFIG_LUA
bool vis_lua_path_add(Vis *vis, const char *path) { return true; }
-const char *vis_lua_paths_get(Vis *vis) { return NULL; }
+bool vis_lua_paths_get(Vis *vis, const char **lpath, const char **cpath) { return false; }
void vis_lua_init(Vis *vis) { }
void vis_lua_start(Vis *vis) { }
void vis_lua_quit(Vis *vis) { }
@@ -1343,13 +1343,19 @@ bool vis_lua_path_add(Vis *vis, const char *path) {
return true;
}
-const char *vis_lua_paths_get(Vis *vis) {
+bool vis_lua_paths_get(Vis *vis, char **lpath, char **cpath) {
lua_State *L = vis->lua;
if (!L)
- return NULL;
+ return false;
+ const char *s;
lua_getglobal(L, "package");
lua_getfield(L, -1, "path");
- return lua_tostring(L, -1);
+ s = lua_tostring(L, -1);
+ *lpath = s ? strdup(s) : NULL;
+ lua_getfield(L, -2, "cpath");
+ s = lua_tostring(L, -1);
+ *cpath = s ? strdup(s) : NULL;
+ return true;
}
static bool package_exist(Vis *vis, lua_State *L, const char *name) {