diff --git a/.luaurc b/.luaurc index 3e8f1bc..50a5ce7 100644 --- a/.luaurc +++ b/.luaurc @@ -7,5 +7,9 @@ "lintErrors": true, "globals": [ "warn" - ] + ], + "aliases": { + "lib": "./lib", + "src": "./src" + } } diff --git a/.nvim.lua b/.nvim.lua index 91939df..4fdc181 100644 --- a/.nvim.lua +++ b/.nvim.lua @@ -6,6 +6,8 @@ require("luau-lsp").config({ mode = "relativeToFile", directoryAliases = { ["@lune"] = "~/.lune/.typedefs/0.8.6/", + ["@lib"] = "./lib", + ["@src"] = "./src", }, }, completion = { diff --git a/.vscode/settings.json b/.vscode/settings.json index 1e34534..6acbd92 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,8 @@ { "luau-lsp.require.mode": "relativeToFile", "luau-lsp.require.directoryAliases": { - "@lune/": "~/.lune/.typedefs/0.8.6/" + "@lune/": "~/.lune/.typedefs/0.8.6/", + "@lib": "./lib", + "@src": "./src" } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 52bbd97..91a9d32 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is a template for initializing [Luau](https://luau-lang.org) projects with ## What is included in this template? - A barebones structure for an executable hello world Lune script (src/) -- A barebones structure for a library (lib/) -- TODO +- A barebones structure for a library (lib/) - Configuration files for various tooling: - aftman for toolchain management (aftman.toml) - stylua for code formatting (stylua.toml, lune.yml) diff --git a/lib/init.luau b/lib/init.luau new file mode 100644 index 0000000..715b472 --- /dev/null +++ b/lib/init.luau @@ -0,0 +1,5 @@ +local function makeHello(name: string): string + return "Hello, " .. name .. "!" +end + +return makeHello diff --git a/src/init.luau b/src/init.luau index 56f6a5c..d786748 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1,7 +1,8 @@ +local makeHello = require("@lib/") local process = require("@lune/process") -function main(_args: { string }): number? - print("Hello, world!") +function main(args: { string }): number? + print(makeHello(args[1] or "world")) return 0 end