Trying to use lsp - "embedded plugins must be a resourse"

so i wanted to use an language server in gnome-builder, and i looked at the definition for the go lsp, and more or less copied it into a plugin file:

[Plugin]
Copyright=2024
Description=Language server integration for the OCaml programming language
Embedded=ide_lsp_plugin_register_types
Module=ocaml-lsp
Name=OCaml Language Server
X-Category=lsps
X-Code-Action-Languages=ocaml
X-Completion-Provider-Languages=ocaml
X-Diagnostic-Provider-Languages=ocaml
X-Formatter-Languages=ocaml
X-Highlighter-Languages=ocaml
X-Hover-Provider-Languages=ocaml
X-LSP-Command=ocaml-lsp-server
X-LSP-Languages=ocaml
X-LSP-Settings=ocaml-settings.json
X-Rename-Provider-Languages=ocaml
X-Symbol-Resolver-Languages=ocaml
X-Builder-ABI=46

but i am getting this error:

libpeas[    2]:  WARNING: Bad plugin file '/home/user/.var/app/org.gnome.Builder/data/gnome-builder/plugins/ocaml-lsp/ocaml-lsp.plugin': embedded plugins must be a resource

why is this? how do i tell it to load this plugin as an lsp?

IIRC “embedded” is effectively “statically linked”, which I guess is why it’s required to be a resource (GResource’s are typically statically linked). Removing that should help.

doesn’t that specify what function should be called to load the plugin?

with it removed i get:
libpeas[ 2]: WARNING: Failed to load module 'ocaml-lsp': /home/user/.var/app/org.gnome.Builder/data/gnome-builder/plugins/libocaml-lsp.so: cannot open shared object file: No such file or directory

I believe usually you would export a symbol named peas_register_types(), as can be seen in the test suite:

G_MODULE_EXPORT void
peas_register_types (PeasObjectModule *module)
{
  testing_loadable_plugin_register_type (G_TYPE_MODULE (module));
  peas_object_module_register_extension_type (module,
                                              INTROSPECTION_TYPE_ACTIVATABLE,
                                              TESTING_TYPE_LOADABLE_PLUGIN);
}

but this is an LSP, which runs in a separate process, not really a plugin

i used this as a reference: src/plugins/gopls · main · GNOME / gnome-builder · GitLab

Ah, I see the LSP plugin is built-in and expects ide_lsp_plugin_register_types() to be called to register it. You may have to call ide_lsp_plugin_register_types() from peas_register_types()?

I’ve never worked with a plugin like this, sorry :confused:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.