Lua Notes

nelua configuration
Login
  1. NELUA_INIT
  2. global neluacfg.lua
  3. project-local .neluacfg.lua
  4. tooling .neluacfg.*.lua
  5. Configuration keys

NELUA_INIT

The contents of this environment variable are run when nelua starts up. This is actually the very first thing that happens when nelua starts up, barring toplevel code that executes as libraries are loaded.

global neluacfg.lua

This is hardcoded to $HOME/.config/nelua/neluacfg.lua

Example contents from github discussions:

return {
  cc="ccache gcc",
  cflags="-Wall -Wextra",
  add_path={
    '/home/bart/projects/nelua/nelua-decl/libs/?/?.nelua',
  }
}

Note that this is executed Lua code, which is run rather early (so, no pragmas table to check, for example). For example, here is a global configuration that does nothing except give nelua's CLI a useless feature:

for i, a in ipairs(arg) do
  if a == '-hello' then
    print('hello from global configuration!')
    table.remove(arg, i)
  end
end
return {}

As used:

$ nelua -i ''
$ nelua -i '' -hello
hello from global configuration!
$ nelua -hello -i '' -hello
hello from global configuration!
hello from global configuration!
$ nelua -hello -i 'print "???"' -hello
hello from global configuration!
hello from global configuration!
???

project-local .neluacfg.lua

This file is exactly the same as the global configuration file, but is pulled from the current working directory when nelua's run for per-project settings. This makes it a more interesting place to put 'build system' type commands:

if #arg == 1 then
  if arg[1] == 'clean' then
    print 'removing: example'
    os.remove 'example'
    arg = {'-i', ''}
  elseif arg[1] == 'windows' then
    arg = {'--cc', 'zig cc --target=x86_64-windows', '-o', 'example.exe', 'example.nelua'}
  end
end
return {}

As used:

$ nelua -i 'print "no change to normal operation"'
no change to normal operation
$ nelua clean
removing: example
$ nelua windows
... compilation output ...

tooling .neluacfg.*.lua

In addition to .neluacfg.lua, these files are also read. This is apparently to distinguish the human-maintained Lua contents of .neluacfg.lua, from tooling-generated files. An example is .neluacfg.ppm.lua, generated by linkpy/pancake-pm to add package-managed dependencies to a project.

Configuration keys

likely options

less likely options

unlikely options