I was curious about the official LSP API and what the experience of creating a language API using was like, so I spent an afternoon last week throwing together an experimental plugin for Lua using the LSP API.
Using the LSP API, we’re able to get the following from the language server:
- Syntax highlighting
- Code folding
- Go-to reference across files in the project
- Hover documentation (including support for localization)
- Code formatting
The references are kind of weird because there’s no visual indication (highlight/underline/cursor change) that they’re available.
Syntax highlighting doesn’t seem to work all that great either with the default settings or customized. It just doesn’t want to highlight most tokens. I don’t know if that’s an LSP API thing or a LuaLS issue.
Unrelated to LSP, adding support for basic run configurations and “execute the current file” were pretty straightforward to implement.
To support user preferences and environment customization, I added a settings screen for choosing the lua and lua-language-server paths; choosing a supported language for the LSP (defaults to IDE language when possible); and also supporting configuration via .luarc or .luarc.json (including JSON Schema validation).
Given I’m not sure there’s a need in the marketplace for this specific plugin, this probably where I’ll leave things. Setting aside the syntax highlighting issue I didn’t figure out, the whole process was pretty simple. The code has been uploaded to github for future reference (GitHub - DavidSeptimus/luals-intellij-plugin: An experimental LuaLS integration for JetBrains IDEs).




