Add editorconfig, fix some formatting

This commit is contained in:
Filip Tibell 2023-02-24 10:17:52 +01:00
parent c2dc8e2eb9
commit e340321604
No known key found for this signature in database
8 changed files with 285 additions and 284 deletions

17
.editorconfig Normal file
View file

@ -0,0 +1,17 @@
root = true
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 4
[*.{json,jsonc,json5]
indent_style = space
indent_size = 4
[*.{yml,yaml]
indent_style = space
indent_size = 2

View file

@ -1,4 +1,4 @@
Header1,Header2,Header3 Header1,Header2,Header3
Hello,World,! Hello,World,!
1,2,3 1,2,3
Foo,Bar,Baz Foo,Bar,Baz

1 Header1 Header2 Header3
2 Hello World !
3 1 2 3
4 Foo Bar Baz

View file

@ -12,404 +12,404 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Added auto-generated API reference pages and documentation using GitHub wiki pages - Added auto-generated API reference pages and documentation using GitHub wiki pages
- Added support for `query` in `net.request` parameters, which enables usage of query parameters in URLs without having to manually URL encode values. - Added support for `query` in `net.request` parameters, which enables usage of query parameters in URLs without having to manually URL encode values.
- Added a new function `fs.move` to move / rename a file or directory from one path to another. - Added a new function `fs.move` to move / rename a file or directory from one path to another.
- Implemented a new task scheduler which resolves several long-standing issues: - Implemented a new task scheduler which resolves several long-standing issues:
- Issues with yielding across the C-call/metamethod boundary no longer occur when calling certain async APIs that Lune provides. - Issues with yielding across the C-call/metamethod boundary no longer occur when calling certain async APIs that Lune provides.
- Ordering of interleaved calls to `task.spawn/task.defer` is now completely deterministic, deferring is now guaranteed to run last even in these cases. - Ordering of interleaved calls to `task.spawn/task.defer` is now completely deterministic, deferring is now guaranteed to run last even in these cases.
- The minimum wait time possible when using `task.wait` and minimum delay time using `task.delay` are now much smaller, and only limited by the underlying OS implementation. For most systems this means `task.wait` and `task.delay` are now accurate down to about 5 milliseconds or less. - The minimum wait time possible when using `task.wait` and minimum delay time using `task.delay` are now much smaller, and only limited by the underlying OS implementation. For most systems this means `task.wait` and `task.delay` are now accurate down to about 5 milliseconds or less.
### Changed ### Changed
- Type definitions are now bundled as part of the Lune executable, meaning they no longer need to be downloaded. - Type definitions are now bundled as part of the Lune executable, meaning they no longer need to be downloaded.
- `lune --generate-selene-types` will generate the Selene type definitions file, replacing `lune --download-selene-types` - `lune --generate-selene-types` will generate the Selene type definitions file, replacing `lune --download-selene-types`
- `lune --generate-luau-types` will generate the Luau type definitions file, replacing `lune --download-luau-types` - `lune --generate-luau-types` will generate the Luau type definitions file, replacing `lune --download-luau-types`
- Improved accuracy of Selene type definitions, strongly typed arrays are now used where possible - Improved accuracy of Selene type definitions, strongly typed arrays are now used where possible
- Improved error handling and messages for `net.serve` - Improved error handling and messages for `net.serve`
- Improved error handling and messages for `stdio.prompt` - Improved error handling and messages for `stdio.prompt`
- File path representations on Windows now use legacy paths instead of UNC paths wherever possible, preventing some confusing cases where file paths don't work as expected - File path representations on Windows now use legacy paths instead of UNC paths wherever possible, preventing some confusing cases where file paths don't work as expected
### Fixed ### Fixed
- Fixed `process.cwd` not having the correct ending path separator on Windows - Fixed `process.cwd` not having the correct ending path separator on Windows
- Fixed remaining edge cases where the `task` and `coroutine` libraries weren't interoperable - Fixed remaining edge cases where the `task` and `coroutine` libraries weren't interoperable
- Fixed `task.delay` keeping the script running even if it was cancelled using `task.cancel` - Fixed `task.delay` keeping the script running even if it was cancelled using `task.cancel`
- Fixed `stdio.prompt` blocking all other lua threads while prompting for input - Fixed `stdio.prompt` blocking all other lua threads while prompting for input
## `0.4.0` - February 11th, 2023 ## `0.4.0` - February 11th, 2023
### Added ### Added
- ### Web Sockets - ### Web Sockets
`net` now supports web sockets for both clients and servers! <br /> `net` now supports web sockets for both clients and servers! <br />
Note that the web socket object is identical on both client and Note that the web socket object is identical on both client and
server, but how you retrieve a web socket object is different. server, but how you retrieve a web socket object is different.
#### Server API #### Server API
The server web socket API is an extension of the existing `net.serve` function. <br /> The server web socket API is an extension of the existing `net.serve` function. <br />
This allows for serving both normal HTTP requests and web socket requests on the same port. This allows for serving both normal HTTP requests and web socket requests on the same port.
Example usage: Example usage:
```lua ```lua
net.serve(8080, { net.serve(8080, {
handleRequest = function(request) handleRequest = function(request)
return "Hello, world!" return "Hello, world!"
end, end,
handleWebSocket = function(socket) handleWebSocket = function(socket)
task.delay(10, function() task.delay(10, function()
socket.send("Timed out!") socket.send("Timed out!")
socket.close() socket.close()
end) end)
-- The message will be nil when the socket has closed -- The message will be nil when the socket has closed
repeat repeat
local messageFromClient = socket.next() local messageFromClient = socket.next()
if messageFromClient == "Ping" then if messageFromClient == "Ping" then
socket.send("Pong") socket.send("Pong")
end end
until messageFromClient == nil until messageFromClient == nil
end, end,
}) })
``` ```
#### Client API #### Client API
Example usage: Example usage:
```lua ```lua
local socket = net.socket("ws://localhost:8080") local socket = net.socket("ws://localhost:8080")
socket.send("Ping") socket.send("Ping")
task.delay(5, function() task.delay(5, function()
socket.close() socket.close()
end) end)
-- The message will be nil when the socket has closed -- The message will be nil when the socket has closed
repeat repeat
local messageFromServer = socket.next() local messageFromServer = socket.next()
if messageFromServer == "Ping" then if messageFromServer == "Ping" then
socket.send("Pong") socket.send("Pong")
end end
until messageFromServer == nil until messageFromServer == nil
``` ```
### Changed ### Changed
- `net.serve` now returns a `NetServeHandle` which can be used to stop serving requests safely. - `net.serve` now returns a `NetServeHandle` which can be used to stop serving requests safely.
Example usage: Example usage:
```lua ```lua
local handle = net.serve(8080, function() local handle = net.serve(8080, function()
return "Hello, world!" return "Hello, world!"
end) end)
print("Shutting down after 1 second...") print("Shutting down after 1 second...")
task.wait(1) task.wait(1)
handle.stop() handle.stop()
print("Shut down succesfully") print("Shut down succesfully")
``` ```
- The third and optional argument of `process.spawn` is now a global type `ProcessSpawnOptions`. - The third and optional argument of `process.spawn` is now a global type `ProcessSpawnOptions`.
- Setting `cwd` in the options for `process.spawn` to a path starting with a tilde (`~`) will now use a path relative to the platform-specific home / user directory. - Setting `cwd` in the options for `process.spawn` to a path starting with a tilde (`~`) will now use a path relative to the platform-specific home / user directory.
- `NetRequest` query parameters value has been changed to be a table of key-value pairs similar to `process.env`. - `NetRequest` query parameters value has been changed to be a table of key-value pairs similar to `process.env`.
If any query parameter is specified more than once in the request url, the value chosen will be the last one that was specified. If any query parameter is specified more than once in the request url, the value chosen will be the last one that was specified.
- The internal http client for `net.request` now reuses headers and connections for more efficient requests. - The internal http client for `net.request` now reuses headers and connections for more efficient requests.
- Refactored the Lune rust crate to be much more user-friendly and documented all of the public functions. - Refactored the Lune rust crate to be much more user-friendly and documented all of the public functions.
### Fixed ### Fixed
- Fixed `process.spawn` blocking all lua threads if the spawned child process yields. - Fixed `process.spawn` blocking all lua threads if the spawned child process yields.
## `0.3.0` - February 6th, 2023 ## `0.3.0` - February 6th, 2023
### Added ### Added
- Added a new global `stdio` which replaces `console` - Added a new global `stdio` which replaces `console`
- Added `stdio.write` which writes a string directly to stdout, without any newlines - Added `stdio.write` which writes a string directly to stdout, without any newlines
- Added `stdio.ewrite` which writes a string directly to stderr, without any newlines - Added `stdio.ewrite` which writes a string directly to stderr, without any newlines
- Added `stdio.prompt` which will prompt the user for different kinds of input - Added `stdio.prompt` which will prompt the user for different kinds of input
Example usage: Example usage:
```lua ```lua
local text = stdio.prompt() local text = stdio.prompt()
local text2 = stdio.prompt("text", "Please write some text") local text2 = stdio.prompt("text", "Please write some text")
local didConfirm = stdio.prompt("confirm", "Please confirm this action") local didConfirm = stdio.prompt("confirm", "Please confirm this action")
local optionIndex = stdio.prompt("select", "Please select an option", { "one", "two", "three" }) local optionIndex = stdio.prompt("select", "Please select an option", { "one", "two", "three" })
local optionIndices = stdio.prompt( local optionIndices = stdio.prompt(
"multiselect", "multiselect",
"Please select one or more options", "Please select one or more options",
{ "one", "two", "three", "four", "five" } { "one", "two", "three", "four", "five" }
) )
``` ```
### Changed ### Changed
- Migrated `console.setColor/resetColor` and `console.setStyle/resetStyle` to `stdio.color` and `stdio.style` to allow for more flexibility in custom printing using ANSI color codes. Check the documentation for new usage and behavior. - Migrated `console.setColor/resetColor` and `console.setStyle/resetStyle` to `stdio.color` and `stdio.style` to allow for more flexibility in custom printing using ANSI color codes. Check the documentation for new usage and behavior.
- Migrated the pretty-printing and formatting behavior of `console.log/info/warn/error` to the standard Luau printing functions. - Migrated the pretty-printing and formatting behavior of `console.log/info/warn/error` to the standard Luau printing functions.
### Removed ### Removed
- Removed printing functions `console.log/info/warn/error` in favor of regular global functions for printing. - Removed printing functions `console.log/info/warn/error` in favor of regular global functions for printing.
### Fixed ### Fixed
- Fixed scripts hanging indefinitely on error - Fixed scripts hanging indefinitely on error
## `0.2.2` - February 5th, 2023 ## `0.2.2` - February 5th, 2023
### Added ### Added
- Added global types for networking & child process APIs - Added global types for networking & child process APIs
- `net.request` gets `NetFetchParams` and `NetFetchResponse` for its argument and return value - `net.request` gets `NetFetchParams` and `NetFetchResponse` for its argument and return value
- `net.serve` gets `NetRequest` and `NetResponse` for the handler function argument and return value - `net.serve` gets `NetRequest` and `NetResponse` for the handler function argument and return value
- `process.spawn` gets `ProcessSpawnOptions` for its third and optional parameter - `process.spawn` gets `ProcessSpawnOptions` for its third and optional parameter
### Changed ### Changed
- Reorganize repository structure to take advantage of cargo workspaces, improves compile times - Reorganize repository structure to take advantage of cargo workspaces, improves compile times
## `0.2.1` - February 3rd, 2023 ## `0.2.1` - February 3rd, 2023
### Added ### Added
- Added support for string interpolation syntax (update to Luau 0.561) - Added support for string interpolation syntax (update to Luau 0.561)
- Added network server functionality using `net.serve` - Added network server functionality using `net.serve`
Example usage: Example usage:
```lua ```lua
net.serve(8080, function(request) net.serve(8080, function(request)
print(`Got a {request.method} request at {request.path}!`) print(`Got a {request.method} request at {request.path}!`)
local data = net.jsonDecode(request.body) local data = net.jsonDecode(request.body)
-- For simple text responses with a 200 status -- For simple text responses with a 200 status
return "OK" return "OK"
-- For anything else -- For anything else
return { return {
status = 203, status = 203,
headers = { ["Content-Type"] = "application/json" }, headers = { ["Content-Type"] = "application/json" },
body = net.jsonEncode({ body = net.jsonEncode({
message = "echo", message = "echo",
data = data, data = data,
}) })
} }
end) end)
``` ```
### Changed ### Changed
- Improved type definitions file for Selene, now including constants like `process.env` + tags such as `readonly` and `mustuse` wherever applicable - Improved type definitions file for Selene, now including constants like `process.env` + tags such as `readonly` and `mustuse` wherever applicable
### Fixed ### Fixed
- Fixed type definitions file for Selene not including all API members and parameters - Fixed type definitions file for Selene not including all API members and parameters
- Fixed `process.exit` exiting at the first yield instead of exiting instantly as it should - Fixed `process.exit` exiting at the first yield instead of exiting instantly as it should
## `0.2.0` - January 28th, 2023 ## `0.2.0` - January 28th, 2023
### Added ### Added
- Added full documentation for all global APIs provided by Lune! This includes over 200 lines of pure documentation about behavior & error cases for all of the current 35 constants & functions. Check the [README](/README.md) to find out how to enable documentation in your editor. - Added full documentation for all global APIs provided by Lune! This includes over 200 lines of pure documentation about behavior & error cases for all of the current 35 constants & functions. Check the [README](/README.md) to find out how to enable documentation in your editor.
- Added a third argument `options` for `process.spawn`: - Added a third argument `options` for `process.spawn`:
- `cwd` - The current working directory for the process - `cwd` - The current working directory for the process
- `env` - Extra environment variables to give to the process - `env` - Extra environment variables to give to the process
- `shell` - Whether to run in a shell or not - set to `true` to run using the default shell, or a string to run using a specific shell - `shell` - Whether to run in a shell or not - set to `true` to run using the default shell, or a string to run using a specific shell
- `stdio` - How to treat output and error streams from the child process - set to `"inherit"` to pass output and error streams to the current process - `stdio` - How to treat output and error streams from the child process - set to `"inherit"` to pass output and error streams to the current process
- Added `process.cwd`, the path to the current working directory in which the Lune script is running - Added `process.cwd`, the path to the current working directory in which the Lune script is running
## `0.1.3` - January 25th, 2023 ## `0.1.3` - January 25th, 2023
### Added ### Added
- Added a `--list` subcommand to list scripts found in the `lune` or `.lune` directory. - Added a `--list` subcommand to list scripts found in the `lune` or `.lune` directory.
## `0.1.2` - January 24th, 2023 ## `0.1.2` - January 24th, 2023
### Added ### Added
- Added automatic publishing of the Lune library to [crates.io](https://crates.io/crates/lune) - Added automatic publishing of the Lune library to [crates.io](https://crates.io/crates/lune)
### Fixed ### Fixed
- Fixed scripts that terminate instantly sometimes hanging - Fixed scripts that terminate instantly sometimes hanging
## `0.1.1` - January 24th, 2023 ## `0.1.1` - January 24th, 2023
### Fixed ### Fixed
- Fixed errors containing `./` and / or `../` in the middle of file paths - Fixed errors containing `./` and / or `../` in the middle of file paths
- Potential fix for spawned processes that yield erroring with "attempt to yield across metamethod/c-call boundary" - Potential fix for spawned processes that yield erroring with "attempt to yield across metamethod/c-call boundary"
## `0.1.0` - January 24th, 2023 ## `0.1.0` - January 24th, 2023
### Added ### Added
- `task` now supports passing arguments in `task.spawn` / `task.delay` / `task.defer` - `task` now supports passing arguments in `task.spawn` / `task.delay` / `task.defer`
- `require` now uses paths relative to the file instead of being relative to the current directory, which is consistent with almost all other languages but not original Lua / Luau - this is a breaking change but will allow for proper packaging of third-party modules and more in the future. - `require` now uses paths relative to the file instead of being relative to the current directory, which is consistent with almost all other languages but not original Lua / Luau - this is a breaking change but will allow for proper packaging of third-party modules and more in the future.
- **_NOTE:_** _If you still want to use the default Lua behavior instead of relative paths, set the environment variable `LUAU_PWD_REQUIRE` to `true`_ - **_NOTE:_** _If you still want to use the default Lua behavior instead of relative paths, set the environment variable `LUAU_PWD_REQUIRE` to `true`_
### Changed ### Changed
- Improved error message when an invalid file path is passed to `require` - Improved error message when an invalid file path is passed to `require`
- Much improved error formatting and stack traces - Much improved error formatting and stack traces
### Fixed ### Fixed
- Fixed downloading of type definitions making json files instead of the proper format - Fixed downloading of type definitions making json files instead of the proper format
- Process termination will now always make sure all lua state is cleaned up before exiting, in all cases - Process termination will now always make sure all lua state is cleaned up before exiting, in all cases
## `0.0.6` - January 23rd, 2023 ## `0.0.6` - January 23rd, 2023
### Added ### Added
- Initial implementation of [Roblox's task library](https://create.roblox.com/docs/reference/engine/libraries/task), with some caveats: - Initial implementation of [Roblox's task library](https://create.roblox.com/docs/reference/engine/libraries/task), with some caveats:
- Minimum wait / delay time is currently set to 10ms, subject to change - Minimum wait / delay time is currently set to 10ms, subject to change
- It is not yet possible to pass arguments to tasks created using `task.spawn` / `task.delay` / `task.defer` - It is not yet possible to pass arguments to tasks created using `task.spawn` / `task.delay` / `task.defer`
- Timings for `task.defer` are flaky and deferred tasks are not (yet) guaranteed to run after spawned tasks - Timings for `task.defer` are flaky and deferred tasks are not (yet) guaranteed to run after spawned tasks
With all that said, everything else should be stable! With all that said, everything else should be stable!
- Mixing and matching the `coroutine` library with `task` works in all cases - Mixing and matching the `coroutine` library with `task` works in all cases
- `process.exit()` will stop all spawned / delayed / deferred threads and exit the process - `process.exit()` will stop all spawned / delayed / deferred threads and exit the process
- Lune is guaranteed to keep running until there are no longer any waiting threads - Lune is guaranteed to keep running until there are no longer any waiting threads
If any of the abovementioned things do not work as expected, it is a bug, please file an issue! If any of the abovementioned things do not work as expected, it is a bug, please file an issue!
### Fixed ### Fixed
- Potential fix for spawned processes that yield erroring with "attempt to yield across metamethod/c-call boundary" - Potential fix for spawned processes that yield erroring with "attempt to yield across metamethod/c-call boundary"
## `0.0.5` - January 22nd, 2023 ## `0.0.5` - January 22nd, 2023
### Added ### Added
- Added full test suites for all Lune globals to ensure correct behavior - Added full test suites for all Lune globals to ensure correct behavior
- Added library version of Lune that can be used from other Rust projects - Added library version of Lune that can be used from other Rust projects
### Changed ### Changed
- Large internal changes to allow for implementing the `task` library. - Large internal changes to allow for implementing the `task` library.
- Improved general formatting of errors to make them more readable & glanceable - Improved general formatting of errors to make them more readable & glanceable
- Improved output formatting of non-primitive types - Improved output formatting of non-primitive types
- Improved output formatting of empty tables - Improved output formatting of empty tables
### Fixed ### Fixed
- Fixed double stack trace for certain kinds of errors - Fixed double stack trace for certain kinds of errors
## `0.0.4` - January 21st, 2023 ## `0.0.4` - January 21st, 2023
### Added ### Added
- Added `process.args` for inspecting values given to Lune when running (read only) - Added `process.args` for inspecting values given to Lune when running (read only)
- Added `process.env` which is a plain table where you can get & set environment variables - Added `process.env` which is a plain table where you can get & set environment variables
### Changed ### Changed
- Improved error formatting & added proper file name to stack traces - Improved error formatting & added proper file name to stack traces
### Removed ### Removed
- Removed `...` for process arguments, use `process.args` instead - Removed `...` for process arguments, use `process.args` instead
- Removed individual functions for getting & setting environment variables, use `process.env` instead - Removed individual functions for getting & setting environment variables, use `process.env` instead
## `0.0.3` - January 20th, 2023 ## `0.0.3` - January 20th, 2023
### Added ### Added
- Added networking functions under `net` - Added networking functions under `net`
Example usage: Example usage:
```lua ```lua
local apiResult = net.request({ local apiResult = net.request({
url = "https://jsonplaceholder.typicode.com/posts/1", url = "https://jsonplaceholder.typicode.com/posts/1",
method = "PATCH", method = "PATCH",
headers = { headers = {
["Content-Type"] = "application/json", ["Content-Type"] = "application/json",
}, },
body = net.jsonEncode({ body = net.jsonEncode({
title = "foo", title = "foo",
body = "bar", body = "bar",
}), }),
}) })
local apiResponse = net.jsonDecode(apiResult.body) local apiResponse = net.jsonDecode(apiResult.body)
assert(apiResponse.title == "foo", "Invalid json response") assert(apiResponse.title == "foo", "Invalid json response")
assert(apiResponse.body == "bar", "Invalid json response") assert(apiResponse.body == "bar", "Invalid json response")
``` ```
- Added console logging & coloring functions under `console` - Added console logging & coloring functions under `console`
This piece of code: This piece of code:
```lua ```lua
local tab = { Integer = 1234, Hello = { "World" } } local tab = { Integer = 1234, Hello = { "World" } }
console.log(tab) console.log(tab)
``` ```
Will print the following formatted text to the console, **_with syntax highlighting_**: Will print the following formatted text to the console, **_with syntax highlighting_**:
```lua ```lua
{ {
Integer = 1234, Integer = 1234,
Hello = { Hello = {
"World", "World",
} }
} }
``` ```
Additional utility functions exist with the same behavior but that also print out a colored Additional utility functions exist with the same behavior but that also print out a colored
tag together with any data given to them: `console.info`, `console.warn`, `console.error` - tag together with any data given to them: `console.info`, `console.warn`, `console.error` -
These print out prefix tags `[INFO]`, `[WARN]`, `[ERROR]` in blue, orange, and red, respectively. These print out prefix tags `[INFO]`, `[WARN]`, `[ERROR]` in blue, orange, and red, respectively.
### Changed ### Changed
- The `json` api is now part of `net` - The `json` api is now part of `net`
- `json.encode` becomes `net.jsonEncode` - `json.encode` becomes `net.jsonEncode`
- `json.decode` become `net.jsonDecode` - `json.decode` become `net.jsonDecode`
### Fixed ### Fixed
- Fixed JSON decode not working properly - Fixed JSON decode not working properly
## `0.0.2` - January 19th, 2023 ## `0.0.2` - January 19th, 2023
### Added ### Added
- Added support for command-line parameters to scripts - Added support for command-line parameters to scripts
These can be accessed as a vararg in the root of a script: These can be accessed as a vararg in the root of a script:
```lua ```lua
local firstArg: string, secondArg: string = ... local firstArg: string, secondArg: string = ...
print(firstArg, secondArg) print(firstArg, secondArg)
``` ```
- Added CLI parameters for downloading type definitions: - Added CLI parameters for downloading type definitions:
- `lune --download-selene-types` to download Selene types to the current directory - `lune --download-selene-types` to download Selene types to the current directory
- `lune --download-luau-types` to download Luau types to the current directory - `lune --download-luau-types` to download Luau types to the current directory
These files will be downloaded as `lune.yml` and `luneTypes.d.luau` These files will be downloaded as `lune.yml` and `luneTypes.d.luau`
respectively and are also available in each release on GitHub. respectively and are also available in each release on GitHub.
## `0.0.1` - January 18th, 2023 ## `0.0.1` - January 18th, 2023

View file

@ -370,4 +370,4 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
--------------------------------------------------------- ---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0. defined by the Mozilla Public License, v. 2.0.

View file

@ -23,7 +23,7 @@ if #process.args > 0 then
error("Too many arguments!") error("Too many arguments!")
end end
else else
print("Got no arguments ☹️") print("Got no arguments ☹️")
end end
@ -75,14 +75,14 @@ end
Writing a module Writing a module
Modularizing and splitting up your code is Lune is very straight-forward, Modularizing and splitting up your code is Lune is very straight-forward,
in contrast to other scripting languages and shells such as bash in contrast to other scripting languages and shells such as bash
]] ]]
local module = {} local module = {}
function module.sayHello() function module.sayHello()
print("Hello, Lune! 🌙") print("Hello, Lune! 🌙")
end end
return module return module
@ -94,7 +94,7 @@ return module
Using a function from another module / script Using a function from another module / script
Lune has path-relative imports, similar to other popular languages such as JavaScript Lune has path-relative imports, similar to other popular languages such as JavaScript
]] ]]
local module = require("../modules/module") local module = require("../modules/module")
@ -107,7 +107,7 @@ module.sayHello()
Spawning concurrent tasks Spawning concurrent tasks
These tasks will run at the same time as other Lua code which lets you do primitive multitasking These tasks will run at the same time as other Lua code which lets you do primitive multitasking
]] ]]
task.spawn(function() task.spawn(function()
@ -173,7 +173,7 @@ end
Call out to another program / executable Call out to another program / executable
You can also get creative and combine this with example #6 to spawn several programs at the same time! You can also get creative and combine this with example #6 to spawn several programs at the same time!
]] ]]
print("Sending 4 pings to google 🌏") print("Sending 4 pings to google 🌏")
@ -190,7 +190,7 @@ local result = process.spawn("ping", {
Using the result of a spawned process, exiting the process Using the result of a spawned process, exiting the process
This looks scary with lots of weird symbols, but, it's just some Lua-style pattern matching This looks scary with lots of weird symbols, but, it's just some Lua-style pattern matching
to parse the lines of "min/avg/max/stddev = W/X/Y/Z ms" that the ping program outputs to us to parse the lines of "min/avg/max/stddev = W/X/Y/Z ms" that the ping program outputs to us
]] ]]
if result.ok then if result.ok then
@ -302,12 +302,12 @@ VALID=true
COUNT=1 COUNT=1
while [ $VALID ] while [ $VALID ]
do do
echo $COUNT echo $COUNT
if [ $COUNT -eq 5 ]; if [ $COUNT -eq 5 ];
then then
break break
fi fi
((COUNT++)) ((COUNT++))
done done
``` ```
@ -317,10 +317,10 @@ done
local valid = true local valid = true
local count = 1 local count = 1
while valid do while valid do
print(count) print(count)
if count == 5 then if count == 5 then
break break
end end
count += 1 count += 1
end end
``` ```

View file

@ -10,24 +10,24 @@ These steps assume you have already installed Lune and that it is available to r
2. Run `lune --generate-docs-file` to generate a Luau LSP documentation file (`luneDocs.json`) in the current directory 2. Run `lune --generate-docs-file` to generate a Luau LSP documentation file (`luneDocs.json`) in the current directory
3. Modify your VSCode settings, either by using the settings menu or in `settings.json`: 3. Modify your VSCode settings, either by using the settings menu or in `settings.json`:
```json ```json
{ {
"luau-lsp.require.mode": "relativeToFile", // Set the require mode to work with Lune "luau-lsp.require.mode": "relativeToFile", // Set the require mode to work with Lune
"luau-lsp.types.definitionFiles": ["luneTypes.d.luau"], // Add type definitions for Lune globals "luau-lsp.types.definitionFiles": ["luneTypes.d.luau"], // Add type definitions for Lune globals
"luau-lsp.types.documentationFiles": ["luneDocs.json"] // Add documentation for Lune globals "luau-lsp.types.documentationFiles": ["luneDocs.json"] // Add documentation for Lune globals
} }
``` ```
## Selene ## Selene
1. Run `lune --generate-selene-types` to generate a Selene type definitions file (`lune.yml`) in the current directory 1. Run `lune --generate-selene-types` to generate a Selene type definitions file (`lune.yml`) in the current directory
2. Modify your Selene settings in `selene.toml`: 2. Modify your Selene settings in `selene.toml`:
```yaml ```yaml
# Use this if Lune is the only thing you use Luau files with: # Use this if Lune is the only thing you use Luau files with:
std = "luau+lune" std = "luau+lune"
# OR use this if your project also contains Roblox-specific Luau code: # OR use this if your project also contains Roblox-specific Luau code:
std = "roblox+lune" std = "roblox+lune"
# If you are also using the Luau type definitions file, it may cause issues, and can be safely ignored: # If you are also using the Luau type definitions file, it may cause issues, and can be safely ignored:
exclude = ["luneTypes.d.luau"] exclude = ["luneTypes.d.luau"]
``` ```

View file

@ -6,20 +6,4 @@ Here you can find tutorials as well as a full API reference for all of Lune's bu
If you are just getting started, head over to the [installation](https://github.com/filiptibell/lune/wiki/Getting-Started---1-Installation) page! If you are just getting started, head over to the [installation](https://github.com/filiptibell/lune/wiki/Getting-Started---1-Installation) page!
## Page Reference Anything else can be found in the navigation sidebar.
- Getting Started
- [1. Installation](https://github.com/filiptibell/lune/wiki/Getting-Started---1-Installation)
- [2. Writing Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---2-Writing-Scripts)
- [3. Running Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---3-Running-Scripts)
- [4. Editor Setup](https://github.com/filiptibell/lune/wiki/Getting-Started---4-Editor-Setup)
- API Reference
- [FS](https://github.com/filiptibell/lune/wiki/API-Reference---FS)
- [Net](https://github.com/filiptibell/lune/wiki/API-Reference---Net)
- [Process](https://github.com/filiptibell/lune/wiki/API-Reference---Process)
- [Stdio](https://github.com/filiptibell/lune/wiki/API-Reference---Stdio)
- [Task](https://github.com/filiptibell/lune/wiki/API-Reference---Task)
- [Uncategorized](https://github.com/filiptibell/lune/wiki/API-Reference---Uncategorized)

View file

@ -2,17 +2,17 @@
# Home # Home
- [Getting Started](https://github.com/filiptibell/lune/wiki) - [Getting Started](https://github.com/filiptibell/lune/wiki)
- [1. Installation](https://github.com/filiptibell/lune/wiki/Getting-Started---1-Installation) - [1. Installation](https://github.com/filiptibell/lune/wiki/Getting-Started---1-Installation)
- [2. Writing Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---2-Writing-Scripts) - [2. Writing Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---2-Writing-Scripts)
- [3. Running Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---3-Running-Scripts) - [3. Running Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---3-Running-Scripts)
- [4. Editor Setup](https://github.com/filiptibell/lune/wiki/Getting-Started---4-Editor-Setup) - [4. Editor Setup](https://github.com/filiptibell/lune/wiki/Getting-Started---4-Editor-Setup)
# API Reference # API Reference
- [FS](https://github.com/filiptibell/lune/wiki/API-Reference---FS) - [FS](https://github.com/filiptibell/lune/wiki/API-Reference---FS)
- [Net](https://github.com/filiptibell/lune/wiki/API-Reference---Net) - [Net](https://github.com/filiptibell/lune/wiki/API-Reference---Net)
- [Process](https://github.com/filiptibell/lune/wiki/API-Reference---Process) - [Process](https://github.com/filiptibell/lune/wiki/API-Reference---Process)
- [Stdio](https://github.com/filiptibell/lune/wiki/API-Reference---Stdio) - [Stdio](https://github.com/filiptibell/lune/wiki/API-Reference---Stdio)
- [Task](https://github.com/filiptibell/lune/wiki/API-Reference---Task) - [Task](https://github.com/filiptibell/lune/wiki/API-Reference---Task)
- [Uncategorized](https://github.com/filiptibell/lune/wiki/API-Reference---Uncategorized) - [Uncategorized](https://github.com/filiptibell/lune/wiki/API-Reference---Uncategorized)