Based on CC-Tweaked v1.100.4 for Minecraft 1.18.2. Manually scraped from the docs: https://tweaked.cc/.
When installed correctly, this will add intellisense/autocompletions and basic documentation right into your editor by showing:
- Help text
- Parameter types
- API method names
It does this by declaring EmmyLua annotations (docs: https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Annotations) that the lua-language-server made by Sumneko reads to provide intellisense. Sumneko's language server is available in:
- VS Code: https://marketplace.visualstudio.com/items?itemName=sumneko.lua
- VS Codium: https://open-vsx.org/extension/sumneko/lua
- (Neo)vim: https://github.com/xiyaowong/coc-sumneko-lua (via coc.nvim)
Just install the VS Code/coc.nvim extension and everything should work fine:
-
VS Code: https://marketplace.visualstudio.com/items?itemName=sumneko.lua
-
VS Codium: https://open-vsx.org/extension/sumneko/lua
-
coc.nvim:
:CocInstall coc-sumneko-lua
Clone this repo to somewhere nice, such as your documents folder:
cd ~/Documents
git clone https://github.com/jilleJr/CC-Tweaked-EmmyLua.git
Get the full path of the cloned repository on your disk, as we will use it in the config in the section below:
Open your editors config file. For coc.nvim, you would run:
:CocConfig
Add the following fields, but ensure the Lua.workspace.library
is the
correct path to the cloned CC-Tweaked-EmmyLua repo:
{
"Lua.workspace.library": [
"/home/yourname/Documents/CC-Tweaked-EmmyLua"
],
"Lua.workspace.maxPreload": 2000,
"Lua.workspace.preloadFileSize": 1000,
"Lua.runtime.version": "Lua 5.1",
"Lua.runtime.builtin": {
"os": "disable",
"io": "disable"
},
"Lua.diagnostics.enable": true,
"Lua.diagnostics.globals": [],
"Lua.diagnostics.disable": [
"lowercase-global"
],
"Lua.completion.keywordSnippet": "Disable",
"Lua.telemetry.enable": false
}
-
Globals:
- _G
- colors
- colours
- commands
- disk
- fs
- gps
- help
- http
- io
- keys
- multishell
- os
- paintutils
- parallel
- peripheral
- rednet
- redstone
- settings
- shell
- term
- textutils
- turtle
- vector
- window
-
Modules:
- cc.audio.dfpwm
- cc.completion
- cc.expect
- cc.image.nft
- cc.pretty
- cc.require
- cc.shell.completion
- cc.strings
-
Peripherals:
- command
- computer
- drive
- modem
- monitor
- printer
- speaker
-
Generic peripherals:
- energy_storage
- fluid_storage
- inventory
In case you get the following symptom:
$ ls
lua-language-server
main.lua
$ ./lua-language-server
bash: no such file or directory: ./lua-language-server
It might be something wrong with the VS Code provided binary together with how NixOS stores its library files.
Can be resolved by installing it from nixpkgs instead:
nix-env -i sumneko-lua-language-server
Then override the one in the extension with the NixOS variant:
# For VS Code:
cp $(which lua-language-server) ~/.vscode/extensions/sumneko.lua-*/server/bin/Linux/lua-language-server
# For VS Codium:
cp $(which lua-language-server) ~/.vscode-oss/extensions/sumneko.lua-*/server/bin/Linux/lua-language-server
# For coc.nvim:
# 1. First open a .lua file and tell it to download the language server
# 2. Run the following command:
cp $(which lua-language-server) ~/.config/coc/extensions/coc-sumneko-lua-data/sumneko-lua-ls/extension/server/bin/lua-language-server
And then restart your editor.