Skip to content

Commit 3d1d188

Browse files
authored
Merge pull request #79 from Cynosphere/better-neovim-instructions_luarc-example
README: Better Neovim instructions, `.luarc.json` example
2 parents 404b595 + b36736b commit 3d1d188

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

README.md

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Test Coverage Status](https://coveralls.io/repos/github/luttje/glua-api-snippets/badge.svg?branch=main)](https://coveralls.io/github/luttje/glua-api-snippets?branch=main)
77
[![All Contributors](https://img.shields.io/github/all-contributors/luttje/glua-api-snippets?color=ee8449&style=flat-square)](#contributors)
88

9-
This repository scrapes the Garry's Mod Lua API and generates annotated code snippets that will help provide autocompletion for Lua in editors like VSCode, NeoVim and more.
9+
This repository scrapes the Garry's Mod Lua API and generates annotated code snippets that will help provide autocompletion for Lua in editors like VSCode, Neovim and more.
1010

1111
<div align="center">
1212

@@ -22,14 +22,10 @@ To get autocompletion for the Garry's Mod Lua API in your Garry's Mod projects,
2222

2323
* [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=sumneko.lua)
2424

25-
* [NeoVim Configuration](https://github.com/LuaLS/lua-language-server#neovim)
25+
* [Neovim Configuration](https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#lua_ls)
2626

2727
**Then** download/install our GLua API Definitions for the Lua Language Server. This process varies depending on your editor:
2828

29-
* [Visual Studio Code](#visual-studio-code)
30-
31-
* [NeoVim](#neovim)
32-
3329
### Visual Studio Code
3430

3531
Installing our GLua API Definitions for the Lua Language Server in Visual Studio Code is easy thanks to the Lua Language Server Addon Manager built into the VSCode extension.
@@ -43,7 +39,7 @@ Installing our GLua API Definitions for the Lua Language Server in Visual Studio
4339
![VSCode editor command suggestion showing: Lua: Open Addon Manager ...](docs/lls-addon-manager-command.jpg)
4440

4541
</div>
46-
42+
4743
3. Search for the **Garry's Mod** addon and **`Enable`** it:
4844

4945
<div align="center">
@@ -52,11 +48,44 @@ Installing our GLua API Definitions for the Lua Language Server in Visual Studio
5248

5349
</div>
5450

55-
### NeoVim
51+
### Neovim
5652

57-
1. Clone (or download and unzip) [our `lua-language-server-addon` branch](https://github.com/luttje/glua-api-snippets/tree/lua-language-server-addon)
53+
1. Setup a folder for storing Lua Language Server addons (e.g. `~/.cache/luals/`) and create `addonManager/addons/garrysmod/module` folders inside it
5854

59-
2. Follow [the instructions in the Lua Language Server documentation](https://luals.github.io/wiki/addons/#installing-addons) and point `workspace.userThirdParty` to where you placed the `lua-language-server-addon` branch
55+
> [!NOTE]
56+
>
57+
> If you switch between Neovim and VSCode regularly, you probably want to use VSCode's directory, which is `~/AppData/Roaming/Code/User/globalStorage/sumneko.lua` on Windows and `~/.config/Code/User/globalStorage/sumneko.lua` on Linux
58+
59+
2. Clone (or download and unzip) [our `lua-language-server-addon` branch](https://github.com/luttje/glua-api-snippets/tree/lua-language-server-addon) into the `garrysmod/module` folder
60+
61+
3. In your Neovim config where you call `lspconfig.lua_ls.setup`, add the following to the table
62+
63+
```lua
64+
before_init = function(init_params, config)
65+
init_params.initializationOptions = init_params.initializationOptions or {}
66+
init_params.initializationOptions.storagePath = "~/.cache/luals"
67+
end
68+
```
69+
70+
### Example `.luarc.json` for projects
71+
72+
```json
73+
{
74+
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
75+
"runtime.version": "LuaJIT",
76+
"runtime.special": {
77+
"IncludeCS": "dofile",
78+
"include": "dofile"
79+
},
80+
"runtime.nonstandardSymbol": ["!", "!=", "&&", "||", "//", "/**/", "continue"],
81+
"workspace.library": ["${addons}/garrysmod/module/library"],
82+
"workspace.checkThirdParty": false
83+
}
84+
```
85+
86+
> [!WARNING]
87+
>
88+
> The VSCode extension [currently does not automatically install addons](https://github.com/LuaLS/vscode-lua/issues/159). If a user that does not have this addon installed already opens a project that has this `.luarc.json` present, they will have to open the Addon Manager and click Disable and Enable on this addon for it to install the addon properly.
6089
6190
## 📅 Automatically up-to-date
6291

0 commit comments

Comments
 (0)