Skip to content

Commit

Permalink
Restructure readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Jun 1, 2024
1 parent bf74f90 commit 13b8c3b
Showing 1 changed file with 58 additions and 67 deletions.
125 changes: 58 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,105 +51,96 @@ See:

## Installation

### Using luarocks

[![][luarocks-shield]][luarocks-pkg-url]

This package is available on [luarocks].

```
luarocks install --local nlua
```

### Manually

For [luarocks] support, copy or symlink `nlua` to `/usr/bin/`
If you don't need [luarocks] support, copy it into any folder in your `$PATH`.


## Luarocks setup

### Neovim Plugin setup

You can use the [plugin
template](https://github.com/nvim-lua/nvim-lua-plugin-template) to create a new
repository that contains nlua/busted based test setup.

### Manual configuration

- Install luarocks using a package manager. For example `pacman -S luarocks`
- Install `nlua` via `luarocks`:

```bash
luarocks --local install nlua
```

At this point you should be able to use `nlua`. Confirm it with:
- Add `./luarocks/bin/nlua` to your `$PATH`:

```bash
export PATH=$PATH:$HOME/.luarocks/bin:
```

- Confirm it is working:

```bash
echo "print(1 + 2)" | ~/.luarocks/bin/nlua
echo "print(1 + 2)" | nlua
```

## Usage

### Use cases
### Busted

- Use it with busted:
```bash
luarocks --local install busted
busted --lua nlua spec/mytest_spec.lua
```

```bash
luarocks --local install busted
busted --lua nlua spec/mytest_spec.lua
```
If you see a `module 'busted.runner'` not found error you need to update your `LUA_PATH`:

If you see a `module 'busted.runner'` not found error you need to update your `LUA_PATH`:
```bash
eval $(luarocks path --no-bin)
busted --lua nlua spec/mytest_spec.lua
```

```bash
eval $(luarocks path --no-bin)
busted --lua nlua spec/mytest_spec.lua
```
### CI for Neovim Plugins

You can use the [plugin
template](https://github.com/nvim-lua/nvim-lua-plugin-template) to create a new
repository that contains nlua/busted based test setup.

- Use `nlua` with `luarocks`

This allows package installation directly via `nlua` instead of a system `lua`
### As Lua interpreter for luarocks

Create a `~./luarocks/config-nlua.lua` with the following contents.

For `luarocks 3.10.0` and above:
This allows package installation directly via `nlua` instead of a system `lua`

```lua
lua_version = "5.1"
variables = {
LUA = "$HOME/.luarocks/bin/nlua" -- path to where nlua is installed
LUA_INCDIR = "/usr/include/luajit-2.1",
}
```
Create a `~./luarocks/config-nlua.lua` with the following contents.

For `luarocks 3.9.2` and below:
For `luarocks 3.10.0` and above:

```lua
lua_version = "5.1"
variables = {
lua_interpreter = "nlua"
LUA_INCDIR = "/usr/include/luajit-2.1",
LUA_BINDIR = "$HOME/.luarocks/bin", -- path to where nlua is installed
}
```
```lua
lua_version = "5.1"
variables = {
LUA = "$HOME/.luarocks/bin/nlua" -- path to where nlua is installed
LUA_INCDIR = "/usr/include/luajit-2.1",
}
```

To make using this custom configuration a bit easier, you can create a small wrapper.
Create a file called `nluarocks` somewhere in `$PATH` - e.g. in
`~/.local/bin/nluarocks` - with the following content:
For `luarocks 3.9.2` and below:

```bash
#!/usr/bin/env bash
```lua
lua_version = "5.1"
variables = {
lua_interpreter = "nlua"
LUA_INCDIR = "/usr/include/luajit-2.1",
LUA_BINDIR = "$HOME/.luarocks/bin", -- path to where nlua is installed
}
```

LUAROCKS_CONFIG=$HOME/.luarocks/config-nlua.lua luarocks --local "$@"
```
To make using this custom configuration a bit easier, you can create a small wrapper.
Create a file called `nluarocks` somewhere in `$PATH` - e.g. in
`~/.local/bin/nluarocks` - with the following content:

Now you should be able to install packages from `luarocks` using the `nvim`
Lua-interpreter. For example:
```bash
#!/usr/bin/env bash
```bash
nluarocks install busted
```
LUAROCKS_CONFIG=$HOME/.luarocks/config-nlua.lua luarocks --local "$@"
```

Now you should be able to install packages from `luarocks` using the `nvim`
Lua-interpreter. For example:

```bash
nluarocks install busted
```


[luarocks]: https://luarocks.org/
Expand Down

0 comments on commit 13b8c3b

Please sign in to comment.