Improving Addon Installation #2408
Replies: 6 comments 22 replies
-
Without any expertise in this area, the feature that seems most critical to me is the ability to install an addon from a url. The json registry features you mention would be a nice convenience on top of that, but they're not something I'm personally attached to. The registry could be as simple as a web page with a list of links to addon repos for popular frameworks and I wouldn't complain. It also seems like if the json registry were to be set up, it would be built on the "download from url" tool, so I would think any immediate efforts should start there. I don't know the details of how lls hooks into editors, so I don't know how enabling/disabling certain addons for certain contexts could work in a way that does not involve settings files specific to the current editor, but I'd imagine that's a feature people would need? Given that addons have unique names it could be something that happens within the script, e.g. at the top of a script you could have something along the lines of "---@require busted". With a registry setup that could be pushed as far as automatically scanning the registry for the requested addon and installing it, although that's probably overkill. Alright that's all the thoughts I have, cool project =) |
Beta Was this translation helpful? Give feedback.
-
What you are trying to achieve is a command-line-based plugin management tool. In that case, there's no need to use LuaLS itself. You can use any programming language you prefer to implement such a tool and then configure LuaLS to recognize the location of the plugins based on a configuration file like ".luarc". |
Beta Was this translation helpful? Give feedback.
-
Actually, I just thought of an alternative to the "official" JSON registry idea. I can instead use the GitHub/GitLab API to search for repositories that have a certain topic. This could allow us to simply ask GitHub/GitLab for a list of all projects that have the Using this instead means there is no quality control and reviewing of addons, but it does mean there is no need to maintain an "official" list. We could of course just have this as a fallback should the addon name provided not exist in the official list. |
Beta Was this translation helpful? Give feedback.
-
What about using LuaRocks for installing/uninstalling addons? Devs can create a Creating an AddonDefinitions can live in a -- example-types-1.2.1-1.rockspec
name = "example-types"
version = "1.2.1-1"
description = {
summary = "types for Example 1.2.1",
detailed = [[
This is an example of how types would be specified and published via LuaRocks.
]],
homepage = "https://github.com/goldenstein64/example-types",
license = "MIT",
labels = { "types" },
maintainer = "goldenstein64 <email>"
}
source = {
url = "https://github.com/goldenstein64/example-types"
}
dependencies = {
"lua >= 5.1",
-- other type definitions this module depends on
"other-types ~> 0.8.6",
}
build = {
type = "none",
-- this creates a folder at lua_modules/lib/luarocks/rocks-5.1/example-types/1.2.1/types
copy_directories = { "types" }
} The language server can also create extra tooling for help with writing this file, maybe by executing Publishing an AddonDevelopers can publish their addon as a module using the LuaRocks workflow, either through the website or via CLI, i.e. Manifests are described on the LuaRocks site as just a collection of modules. They are simple to create, and manifest maintainers have the choice of either manually reviewing included modules or marking the manifest as open, letting anyone contribute. Installing an AddonUsers can install an addon using the LuaRocks workflow using their CLI, i.e. Users can also browse addons on the LuaRocks website through the public manifest, i.e. https://luarocks.org/m/lls-addons. For lesser-used addons, they don't have to be part of the |
Beta Was this translation helpful? Give feedback.
-
there is build_dependencies which works |
Beta Was this translation helpful? Give feedback.
-
I created a simple GitHub-based lua package management tool, which might initially address this need. https://github.com/CppCXY/luap |
Beta Was this translation helpful? Give feedback.
-
I have for a long time wanted to get this done, so let's get the ball rolling. Please feel free to provide feedback!
Current Implementation
Currently, if you use VS Code, you can use the addon manager, a webview UI that uses Vue.js to display the available addons from LLS-Addons.
More technically, the UI communicates with the VS Code extension through message ports, as the UI is in an
<iframe>
context. The UI does not handle the installing/enabling of addons, it simply sends a message to the extension to install/enable a specified addon.The way that the addons are installed by the VS Code extension, is by using Git to clone LLS-Addons and then the specific addon submodule is initialized. This has a few positives and negatives:
Positives
Negatives
New Implementation Idea
Let me step through how I think we can improve this.
Creating an addon
This step is very similar. You can have definition files in a
library/
folder, and you can have a plugin. Every addon can optionally contain asettings.json
file, that defines settings that the language server should apply (this is the same info as thesettings
field in the currentconfig.json
. Every addon is required to have anaddon.json
file that contains info about that addon, like the below:Publishing an addon
LLS-Addons should be replaced with a new "addon registry" repo that contains an easy to parse JSON file of "officially" published addons. The JSON could look like this:
Firstly, you use GitHub actions or GitLab CI to create a release that contains your addon as a zip file. Then, once you have a public release available for download, you open a pull request that adds the above info about your addon to the JSON file. Any addon-installing client can then fetch the raw JSON file and have all the officially published addons.
Installing an addon
This is where the bulk of the work is.
While using Git is very convenient, we are not using it as intended and it can behave unexpectedly. Therefor, I think we should switch to simply using the GitHub and GitLab APIs. In the future, we could also add any other platforms that have an API.
The logic for installing addons should move to the language server, that way, wherever it goes, whichever editor someone is using, they are able to install and enable addons. It could instead become its own CLI tool, which should be pretty easy, but then users have to install a completely separate tool, and we will be duplicating the logic that enables addon settings 🙁. To integrate it into the language server, I will need help @sumneko with getting comfortable with the runtime and tooling. I have many questions, here are just a few:
$ lua-language-server addon enable busted --plugin
)zip
Install Flow
So let's say you want to enable the
busted
addon, which has been published to the official registry:busted
. Assuming there is a match, we can look at therepository
field to know where it lives.workspace.library
setting and any additional settings (according to itssettings.json
)addon.json
file, and after it is installed, any dependencies can be resolved and enabled.But what if you have an addon for a small project that isn't published to the official registry? Well, we can also support simply providing the URL to it to install it:
$ lua-language-server addon enable https://github.com/example/addon
We can then use the GitHub API to get the latest release and then follow the same steps as above.
Addon Manager UI
Of course, these changes will completely break the addon manager UI that is being used by the VS Code extension. The UI itself may be easy to fix, as it is just passing messages, but the code that handles those messages and runs git commands will have to all be torn out and refactored. We could maybe add a command like
$ lua-language-server addon list --json
to get the addon registry JSON file. The UI could then continue displaying the official addon list and interact with the language server binary to enable addons.Please let me know what you think of these ideas, and feel free to offer your own suggestions!
Beta Was this translation helpful? Give feedback.
All reactions