martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.27k stars 261 forks source link

Feature request: Make the current Lua runtime path available in Lua API #815

Closed erf closed 4 years ago

erf commented 4 years ago

I'd like to have the current Lua runtime path, used to source the visrc.lua, available via the Lua API.

I require a Lua plugin, which would like to do some disk operations on the current path.

martanne commented 4 years ago

You can use the standard Lua package.path, it is also used to produce the :help Lua listing.

As was explained in #813, the first path which contains the requested file is used.

More concretely, you can use package.searchpath:

local path, err = package.searchpath("visrc", package.path)
if err then
    -- not found
else
    -- do something with path
end
erf commented 4 years ago

Thanks!

Ok, this might be weird, but would it be possible to make a command line script ( bash or lua ) somehow get the default visrc.lua path; perhaps by running a command / pipe via vis ?