Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call luafile with a variable

Tags:

vim

This seems like a trivial thing to accomplish, but I'd like to run a lua script alongside a vimscript (in the same directory).

First I tried

luafile ./somefile.lua

which doesn't work. I looked up how to get the current vimscript's directory and tried

let s:path = fnamemodify(resolve(expand('<sfile>:p')), ':h')
let s:vglua = s:path . "/somefile.lua"
luafile s:vglua

which, unsurprisingly, results in

cannot open s:vglua: No such file or directory

I know I'm doing something stupid, but Vim's helpfiles are huge and I'm not seeing anything really helpful from my initial search queries.

How would I go about running a Lua script that's in the same directory as my vimscript?

like image 741
Qix - MONICA WAS MISTREATED Avatar asked Oct 18 '25 23:10

Qix - MONICA WAS MISTREATED


1 Answers

Supposing s:vglua is correctly defined, you must:

execute "luafile " . s:vglua
like image 69
romainl Avatar answered Oct 22 '25 06:10

romainl