Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua Constant autocomplete support #5663

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

sturnclaw
Copy link
Member

This PR improves our scan_enums script to dump the literal string constants into Lua type information files, providing an additional source of truth when trying to use those enums. It uses the LuaLSP ---@enum annotation to provide autocomplete for function parameters declared with an enum type (although it will currently also incorrectly suggest e.g. Constants.BodyType.1 if you don't type a " to filter the autocomplete results).

This also updates the enum_table file with the changes to the SystemBody enums merged as part of the Json system definition work.

- This provides some code-completion support via the @enum decorator for the enum table
@impaktor
Copy link
Member

Remind me, it's the lua-language-server that we're using, right?

@sturnclaw
Copy link
Member Author

Remind me, it's the lua-language-server that we're using, right?

Correct.

@sturnclaw sturnclaw merged commit b42a745 into pioneerspacesim:master Nov 13, 2023
@impaktor
Copy link
Member

And to make use of this new power, one needs only use LSP in your IDE of choice + run the scan enum's python script?

@sturnclaw
Copy link
Member Author

And to make use of this new power, one needs only use LSP in your IDE of choice + run the scan enum's python script?

All you need to do is use an LSP adapter to run lua-language-server and configure it to load meta files from data/meta - I've already run scan_enums.py and we check the meta files into the repository. Details of the configuration vary between IDEs - our "default" VScode workspace is pre-configured.

@sturnclaw sturnclaw deleted the lua-enum-defs branch November 21, 2023 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants