jilleJr / CC-Tweaked-EmmyLua

EmmyLua annotations for CC-Tweaked

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CC-Tweaked EmmyLua Annotations

Based on CC-Tweaked v1.100.4 for Minecraft 1.18.2. Manually scraped from the docs: https://tweaked.cc/.

What this repo does

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:

Preview

VS Code

(Neo)vim

Install Lua-language-server

Just install the VS Code/coc.nvim extension and everything should work fine:

Install files

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:

Configure language server

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
}

Existing documentation

  • Globals:

    • _G
    • colors
    • colours
    • commands
    • disk
    • fs
    • gps
    • help
    • http
    • io
    • keys
    • multishell
    • os
    • paintutils
    • parallel
    • peripheral
    • pocket
    • 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

Install on NixOS

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.

About

EmmyLua annotations for CC-Tweaked


Languages

Language:Lua 100.0%