Add library structure to template

This commit is contained in:
Erica Marigold 2024-07-08 16:30:53 +05:30
parent b89b424608
commit 1397b6c289
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1
6 changed files with 20 additions and 6 deletions

View file

@ -7,5 +7,9 @@
"lintErrors": true, "lintErrors": true,
"globals": [ "globals": [
"warn" "warn"
] ],
"aliases": {
"lib": "./lib",
"src": "./src"
}
} }

View file

@ -6,6 +6,8 @@ require("luau-lsp").config({
mode = "relativeToFile", mode = "relativeToFile",
directoryAliases = { directoryAliases = {
["@lune"] = "~/.lune/.typedefs/0.8.6/", ["@lune"] = "~/.lune/.typedefs/0.8.6/",
["@lib"] = "./lib",
["@src"] = "./src",
}, },
}, },
completion = { completion = {

View file

@ -1,6 +1,8 @@
{ {
"luau-lsp.require.mode": "relativeToFile", "luau-lsp.require.mode": "relativeToFile",
"luau-lsp.require.directoryAliases": { "luau-lsp.require.directoryAliases": {
"@lune/": "~/.lune/.typedefs/0.8.6/" "@lune/": "~/.lune/.typedefs/0.8.6/",
"@lib": "./lib",
"@src": "./src"
} }
} }

View file

@ -5,7 +5,7 @@ This is a template for initializing [Luau](https://luau-lang.org) projects with
## What is included in this template? ## What is included in this template?
- A barebones structure for an executable hello world Lune script (src/) - 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: - Configuration files for various tooling:
- aftman for toolchain management (aftman.toml) - aftman for toolchain management (aftman.toml)
- stylua for code formatting (stylua.toml, lune.yml) - stylua for code formatting (stylua.toml, lune.yml)

5
lib/init.luau Normal file
View file

@ -0,0 +1,5 @@
local function makeHello(name: string): string
return "Hello, " .. name .. "!"
end
return makeHello

View file

@ -1,7 +1,8 @@
local makeHello = require("@lib/")
local process = require("@lune/process") local process = require("@lune/process")
function main(_args: { string }): number? function main(args: { string }): number?
print("Hello, world!") print(makeHello(args[1] or "world"))
return 0 return 0
end end