-
-
Notifications
You must be signed in to change notification settings - Fork 329
Getting Started
This page goes over getting set up in the various environments that the Lua language server can be used in.
You'll probably want to get familiar with the annotations.
Using the language server through the VS Code extension is a super easy and convenient way to get set up and start coding.
The Visual Studio Code extension can be installed from the marketplace or found in VS Code under sumneko.lua
.
Configuration of the extension can be done from your VS Code settings (Ctrl + ,). Enter @ext:sumneko.lua
in the search bar at the top and you will be presented with all of the settings for the extension.
The Lua language server can be run straight from the command line.
You may be able to get it from your package manager:
- Windows
- Scoop:
scoop install lua-language-server
- Scoop:
- MacOS
- Homebrew:
brew install lua-language-server
- Macports:
sudo port install lua-language-server
- Homebrew:
You can also find precompiled binaries attached to each release and prerelease from the GitHub actions for Windows, Linux, and MacOS.
Note that you can't simply create a symbolic link to the binary in one of the directories on your $PATH
, since lua-language-server
expects to find the scripts in a fixed location relative to the directory it is run from. Instead, create a wrapper script with the contents:
#!/bin/bash
exec "<path-to-directory>/bin/lua-language-server" "$@"
You can also build it yourself.
If you don't have a precompiled binary, you can build the server yourself.
- Install Ninja
- Ensure you have C++17
- Clone the project and its submodules
git clone --depth=1 https://github.com/sumneko/lua-language-server
cd lua-language-server
git submodule update --depth 1 --init --recursive
Continue below with your OS of choice.
cd 3rd\luamake
compile\install.bat
cd ..\..
3rd\luamake\luamake.exe rebuild
cd 3rd/luamake
./compile/install.sh
cd ../..
./3rd/luamake/luamake rebuild
.\bin\lua-language-server.exe
./bin/lua-language-server
There are a few arguments that can be provided when running the language server from the command line.
optional
Type: string
The main Lua script file from the root of this repository. If omitted, the application will attempt to load bin/../main.lua
.
There are a few optional flags that can alter how the server operates.
Type: string
Where the log should be written to. Defaults to ./log
Example: --logpath=D:/luaServer/logs
Type: string
The minimum level of logging that should appear in the logfile. Can be used to log more detailed info for debugging and error reporting.
Options:
trace
Example: --loglevel=trace
Type: string
Where the standard Lua library definition files should be generated to. Defaults to ./meta
Example: --metapath=D:/sumnekoLua/metaDefintions
Type: string
The language to use. Defaults to en-us
. Options can be found in locale/
Example: --locale=zh-cn
Type: string
The location of the configuration file that will be loaded. Can be relative to the workspace. When provided, config files from elsewhere (such as from VS Code) will no longer be loaded.
Example: --configpath=sumnekoLuaConfig.lua
Type: boolean
Get the version of the Lua language server. This will print it to the command line and immediately exit.
Type: boolean
Perform a "diagnosis report" where the results of the diagnosis are written to a file.
Type: string
Default: Warning
To be used with --check
. The minimum level of diagnostic that should be logged. Items with lower priority than the one listed here will not be written to the file. Options include, in order of priority:
Error
Warning
Information
Example: --checklevel=Information
The server loads its settings from one of the following sources, in order:
- The file specified by
--configpath
- A
.luarc.json
file in the workspace - The configuration file sent from the LSP client (like from VS Code)
For more details, go to the configuration file page.
A list of common issues when executing/building from the command line.
- Compile error
/usr/bin/ld: cannot find -lstdc++
(or similar) when runninginstall.sh
- You may need to install
libstdc++
. On Fedora linux or similar run:dnf install libstdc++-static
- You may need to install