[gnome-builder] plugins/lua-language-server: add lua-language-server support
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/lua-language-server: add lua-language-server support
- Date: Wed, 5 Oct 2022 21:24:10 +0000 (UTC)
commit bef5a5a4e0906a601a14670cb7d1754e7a38105c
Author: Christian Hergert <chergert redhat com>
Date: Wed Oct 5 14:13:39 2022 -0700
plugins/lua-language-server: add lua-language-server support
You still have to install the language server manually, but this gets
things in place to discover/run the language server.
The most annoying part is that you have to use a wrapper script for it
because the language server requires locating lua files bundled with the
project to be run.
Fixes #49
meson_options.txt | 1 +
.../gbp-lua-code-action-provider.c | 65 ++++++++++++++++
.../gbp-lua-code-action-provider.h | 31 ++++++++
.../gbp-lua-completion-provider.c | 61 +++++++++++++++
.../gbp-lua-completion-provider.h | 31 ++++++++
.../gbp-lua-diagnostic-provider.c | 65 ++++++++++++++++
.../gbp-lua-diagnostic-provider.h | 31 ++++++++
.../lua-language-server/gbp-lua-formatter.c | 65 ++++++++++++++++
.../lua-language-server/gbp-lua-formatter.h | 31 ++++++++
.../lua-language-server/gbp-lua-highlighter.c | 65 ++++++++++++++++
.../lua-language-server/gbp-lua-highlighter.h | 31 ++++++++
.../lua-language-server/gbp-lua-hover-provider.c | 66 ++++++++++++++++
.../lua-language-server/gbp-lua-hover-provider.h | 31 ++++++++
.../lua-language-server/gbp-lua-rename-provider.c | 65 ++++++++++++++++
.../lua-language-server/gbp-lua-rename-provider.h | 31 ++++++++
src/plugins/lua-language-server/gbp-lua-service.c | 89 ++++++++++++++++++++++
src/plugins/lua-language-server/gbp-lua-service.h | 31 ++++++++
.../lua-language-server/gbp-lua-symbol-resolver.c | 65 ++++++++++++++++
.../lua-language-server/gbp-lua-symbol-resolver.h | 31 ++++++++
.../lua-language-server-plugin.c | 68 +++++++++++++++++
.../lua-language-server.gresource.xml | 6 ++
.../lua-language-server/lua-language-server.plugin | 16 ++++
src/plugins/lua-language-server/meson.build | 24 ++++++
src/plugins/meson.build | 2 +
24 files changed, 1002 insertions(+)
---
diff --git a/meson_options.txt b/meson_options.txt
index 34904150e..572c67d68 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -50,6 +50,7 @@ option('plugin_intelephense', type: 'boolean')
option('plugin_jdtls', type: 'boolean')
option('plugin_jedi_language_server', type: 'boolean', value: false)
option('plugin_jhbuild', type: 'boolean')
+option('plugin_lua_language_server', type: 'boolean')
option('plugin_make', type: 'boolean')
option('plugin_make_templates', type: 'boolean')
option('plugin_markdown_preview', type: 'boolean')
diff --git a/src/plugins/lua-language-server/gbp-lua-code-action-provider.c
b/src/plugins/lua-language-server/gbp-lua-code-action-provider.c
new file mode 100644
index 000000000..0d67a6d33
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-code-action-provider.c
@@ -0,0 +1,65 @@
+/* gbp-lua-code-action-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-code-action-provider"
+
+#include "config.h"
+
+#include "gbp-lua-code-action-provider.h"
+#include "gbp-lua-service.h"
+
+struct _GbpLuaCodeActionProvider
+{
+ IdeLspCodeActionProvider parent_instance;
+};
+
+static void
+gbp_lua_code_action_provider_load (IdeCodeActionProvider *provider)
+{
+ g_autoptr(IdeLspServiceClass) klass = NULL;
+
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_CODE_ACTION_PROVIDER (provider));
+
+ klass = g_type_class_ref (GBP_TYPE_LUA_SERVICE);
+ ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+ IDE_EXIT;
+}
+
+static void
+code_action_provider_iface_init (IdeCodeActionProviderInterface *iface)
+{
+ iface->load = gbp_lua_code_action_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpLuaCodeActionProvider, gbp_lua_code_action_provider,
IDE_TYPE_LSP_CODE_ACTION_PROVIDER,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_CODE_ACTION_PROVIDER,
code_action_provider_iface_init))
+
+static void
+gbp_lua_code_action_provider_class_init (GbpLuaCodeActionProviderClass *klass)
+{
+}
+
+static void
+gbp_lua_code_action_provider_init (GbpLuaCodeActionProvider *self)
+{
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-code-action-provider.h
b/src/plugins/lua-language-server/gbp-lua-code-action-provider.h
new file mode 100644
index 000000000..05b4e7516
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-code-action-provider.h
@@ -0,0 +1,31 @@
+/* gbp-lua-code-action-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_CODE_ACTION_PROVIDER (gbp_lua_code_action_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaCodeActionProvider, gbp_lua_code_action_provider, GBP, LUA_CODE_ACTION_PROVIDER,
IdeLspCodeActionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/gbp-lua-completion-provider.c
b/src/plugins/lua-language-server/gbp-lua-completion-provider.c
new file mode 100644
index 000000000..61489389b
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-completion-provider.c
@@ -0,0 +1,61 @@
+/* gbp-lua-completion-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-completion-provider"
+
+#include "config.h"
+
+#include "gbp-lua-completion-provider.h"
+#include "gbp-lua-service.h"
+
+struct _GbpLuaCompletionProvider
+{
+ IdeLspCompletionProvider parent_instance;
+};
+
+static void
+gbp_lua_completion_provider_load (IdeLspCompletionProvider *provider)
+{
+ g_autoptr(IdeLspServiceClass) klass = NULL;
+
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_COMPLETION_PROVIDER (provider));
+
+ klass = g_type_class_ref (GBP_TYPE_LUA_SERVICE);
+ ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+ IDE_EXIT;
+}
+
+G_DEFINE_FINAL_TYPE (GbpLuaCompletionProvider, gbp_lua_completion_provider, IDE_TYPE_LSP_COMPLETION_PROVIDER)
+
+static void
+gbp_lua_completion_provider_class_init (GbpLuaCompletionProviderClass *klass)
+{
+ IdeLspCompletionProviderClass *lsp_completion_provider_class = IDE_LSP_COMPLETION_PROVIDER_CLASS (klass);
+
+ lsp_completion_provider_class->load = gbp_lua_completion_provider_load;
+}
+
+static void
+gbp_lua_completion_provider_init (GbpLuaCompletionProvider *self)
+{
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-completion-provider.h
b/src/plugins/lua-language-server/gbp-lua-completion-provider.h
new file mode 100644
index 000000000..41380302d
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-completion-provider.h
@@ -0,0 +1,31 @@
+/* gbp-lua-completion-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_COMPLETION_PROVIDER (gbp_lua_completion_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaCompletionProvider, gbp_lua_completion_provider, GBP, LUA_COMPLETION_PROVIDER,
IdeLspCompletionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/gbp-lua-diagnostic-provider.c
b/src/plugins/lua-language-server/gbp-lua-diagnostic-provider.c
new file mode 100644
index 000000000..77886d3e9
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-diagnostic-provider.c
@@ -0,0 +1,65 @@
+/* gbp-lua-diagnostic-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-diagnostic-provider"
+
+#include "config.h"
+
+#include "gbp-lua-diagnostic-provider.h"
+#include "gbp-lua-service.h"
+
+struct _GbpLuaDiagnosticProvider
+{
+ IdeLspDiagnosticProvider parent_instance;
+};
+
+static void
+gbp_lua_diagnostic_provider_load (IdeDiagnosticProvider *provider)
+{
+ g_autoptr(IdeLspServiceClass) klass = NULL;
+
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_DIAGNOSTIC_PROVIDER (provider));
+
+ klass = g_type_class_ref (GBP_TYPE_LUA_SERVICE);
+ ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+ IDE_EXIT;
+}
+
+static void
+diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface)
+{
+ iface->load = gbp_lua_diagnostic_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpLuaDiagnosticProvider, gbp_lua_diagnostic_provider,
IDE_TYPE_LSP_DIAGNOSTIC_PROVIDER,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER,
diagnostic_provider_iface_init))
+
+static void
+gbp_lua_diagnostic_provider_class_init (GbpLuaDiagnosticProviderClass *klass)
+{
+}
+
+static void
+gbp_lua_diagnostic_provider_init (GbpLuaDiagnosticProvider *self)
+{
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-diagnostic-provider.h
b/src/plugins/lua-language-server/gbp-lua-diagnostic-provider.h
new file mode 100644
index 000000000..961ef7b14
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-diagnostic-provider.h
@@ -0,0 +1,31 @@
+/* gbp-lua-diagnostic-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_DIAGNOSTIC_PROVIDER (gbp_lua_diagnostic_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaDiagnosticProvider, gbp_lua_diagnostic_provider, GBP, LUA_DIAGNOSTIC_PROVIDER,
IdeLspDiagnosticProvider)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/gbp-lua-formatter.c
b/src/plugins/lua-language-server/gbp-lua-formatter.c
new file mode 100644
index 000000000..6bb523cb9
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-formatter.c
@@ -0,0 +1,65 @@
+/* gbp-lua-formatter.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-formatter"
+
+#include "config.h"
+
+#include "gbp-lua-formatter.h"
+#include "gbp-lua-service.h"
+
+struct _GbpLuaFormatter
+{
+ IdeLspFormatter parent_instance;
+};
+
+static void
+gbp_lua_formatter_load (IdeFormatter *provider)
+{
+ g_autoptr(IdeLspServiceClass) klass = NULL;
+
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_FORMATTER (provider));
+
+ klass = g_type_class_ref (GBP_TYPE_LUA_SERVICE);
+ ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+ IDE_EXIT;
+}
+
+static void
+formatter_iface_init (IdeFormatterInterface *iface)
+{
+ iface->load = gbp_lua_formatter_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpLuaFormatter, gbp_lua_formatter, IDE_TYPE_LSP_FORMATTER,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_FORMATTER, formatter_iface_init))
+
+static void
+gbp_lua_formatter_class_init (GbpLuaFormatterClass *klass)
+{
+}
+
+static void
+gbp_lua_formatter_init (GbpLuaFormatter *self)
+{
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-formatter.h
b/src/plugins/lua-language-server/gbp-lua-formatter.h
new file mode 100644
index 000000000..98ade5792
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-formatter.h
@@ -0,0 +1,31 @@
+/* gbp-lua-formatter.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_FORMATTER (gbp_lua_formatter_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaFormatter, gbp_lua_formatter, GBP, LUA_FORMATTER, IdeLspFormatter)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/gbp-lua-highlighter.c
b/src/plugins/lua-language-server/gbp-lua-highlighter.c
new file mode 100644
index 000000000..95de0cd49
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-highlighter.c
@@ -0,0 +1,65 @@
+/* gbp-lua-highlighter.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-highlighter"
+
+#include "config.h"
+
+#include "gbp-lua-highlighter.h"
+#include "gbp-lua-service.h"
+
+struct _GbpLuaHighlighter
+{
+ IdeLspHighlighter parent_instance;
+};
+
+static void
+gbp_lua_highlighter_load (IdeHighlighter *provider)
+{
+ g_autoptr(IdeLspServiceClass) klass = NULL;
+
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_HIGHLIGHTER (provider));
+
+ klass = g_type_class_ref (GBP_TYPE_LUA_SERVICE);
+ ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+ IDE_EXIT;
+}
+
+static void
+highlighter_iface_init (IdeHighlighterInterface *iface)
+{
+ iface->load = gbp_lua_highlighter_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpLuaHighlighter, gbp_lua_highlighter, IDE_TYPE_LSP_HIGHLIGHTER,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_HIGHLIGHTER, highlighter_iface_init))
+
+static void
+gbp_lua_highlighter_class_init (GbpLuaHighlighterClass *klass)
+{
+}
+
+static void
+gbp_lua_highlighter_init (GbpLuaHighlighter *self)
+{
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-highlighter.h
b/src/plugins/lua-language-server/gbp-lua-highlighter.h
new file mode 100644
index 000000000..1f6ef641e
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-highlighter.h
@@ -0,0 +1,31 @@
+/* gbp-lua-highlighter.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_HIGHLIGHTER (gbp_lua_highlighter_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaHighlighter, gbp_lua_highlighter, GBP, LUA_HIGHLIGHTER, IdeLspHighlighter)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/gbp-lua-hover-provider.c
b/src/plugins/lua-language-server/gbp-lua-hover-provider.c
new file mode 100644
index 000000000..4f27430bb
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-hover-provider.c
@@ -0,0 +1,66 @@
+/* gbp-lua-hover-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-hover-provider"
+
+#include "config.h"
+
+#include "gbp-lua-hover-provider.h"
+#include "gbp-lua-service.h"
+
+struct _GbpLuaHoverProvider
+{
+ IdeLspHoverProvider parent_instance;
+};
+
+static void
+gbp_lua_hover_provider_prepare (IdeLspHoverProvider *provider)
+{
+ g_autoptr(IdeLspServiceClass) klass = NULL;
+
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_HOVER_PROVIDER (provider));
+
+ g_object_set (provider,
+ "category", "Lua",
+ "priority", 200,
+ NULL);
+
+ klass = g_type_class_ref (GBP_TYPE_LUA_SERVICE);
+ ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+ IDE_EXIT;
+}
+
+G_DEFINE_FINAL_TYPE (GbpLuaHoverProvider, gbp_lua_hover_provider, IDE_TYPE_LSP_HOVER_PROVIDER)
+
+static void
+gbp_lua_hover_provider_class_init (GbpLuaHoverProviderClass *klass)
+{
+ IdeLspHoverProviderClass *lsp_hover_provider_class = IDE_LSP_HOVER_PROVIDER_CLASS (klass);
+
+ lsp_hover_provider_class->prepare = gbp_lua_hover_provider_prepare;
+}
+
+static void
+gbp_lua_hover_provider_init (GbpLuaHoverProvider *self)
+{
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-hover-provider.h
b/src/plugins/lua-language-server/gbp-lua-hover-provider.h
new file mode 100644
index 000000000..fff39e269
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-hover-provider.h
@@ -0,0 +1,31 @@
+/* gbp-lua-hover-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_HOVER_PROVIDER (gbp_lua_hover_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaHoverProvider, gbp_lua_hover_provider, GBP, LUA_HOVER_PROVIDER,
IdeLspHoverProvider)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/gbp-lua-rename-provider.c
b/src/plugins/lua-language-server/gbp-lua-rename-provider.c
new file mode 100644
index 000000000..0b5c93bd1
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-rename-provider.c
@@ -0,0 +1,65 @@
+/* gbp-lua-rename-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-rename-provider"
+
+#include "config.h"
+
+#include "gbp-lua-rename-provider.h"
+#include "gbp-lua-service.h"
+
+struct _GbpLuaRenameProvider
+{
+ IdeLspRenameProvider parent_instance;
+};
+
+static void
+gbp_lua_rename_provider_load (IdeRenameProvider *provider)
+{
+ g_autoptr(IdeLspServiceClass) klass = NULL;
+
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_RENAME_PROVIDER (provider));
+
+ klass = g_type_class_ref (GBP_TYPE_LUA_SERVICE);
+ ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+ IDE_EXIT;
+}
+
+static void
+rename_provider_iface_init (IdeRenameProviderInterface *iface)
+{
+ iface->load = gbp_lua_rename_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpLuaRenameProvider, gbp_lua_rename_provider, IDE_TYPE_LSP_RENAME_PROVIDER,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_RENAME_PROVIDER, rename_provider_iface_init))
+
+static void
+gbp_lua_rename_provider_class_init (GbpLuaRenameProviderClass *klass)
+{
+}
+
+static void
+gbp_lua_rename_provider_init (GbpLuaRenameProvider *self)
+{
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-rename-provider.h
b/src/plugins/lua-language-server/gbp-lua-rename-provider.h
new file mode 100644
index 000000000..5a719020e
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-rename-provider.h
@@ -0,0 +1,31 @@
+/* gbp-lua-rename-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_RENAME_PROVIDER (gbp_lua_rename_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaRenameProvider, gbp_lua_rename_provider, GBP, LUA_RENAME_PROVIDER,
IdeLspRenameProvider)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/gbp-lua-service.c
b/src/plugins/lua-language-server/gbp-lua-service.c
new file mode 100644
index 000000000..cc919ea9d
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-service.c
@@ -0,0 +1,89 @@
+/* gbp-lua-service.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-service"
+
+#include "config.h"
+
+#include <jsonrpc-glib.h>
+
+#include "gbp-lua-service.h"
+
+struct _GbpLuaService
+{
+ IdeLspService parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpLuaService, gbp_lua_service, IDE_TYPE_LSP_SERVICE)
+
+static void
+gbp_lua_service_configure_client (IdeLspService *service,
+ IdeLspClient *client)
+{
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_SERVICE (service));
+ g_assert (IDE_IS_LSP_CLIENT (client));
+
+ ide_lsp_client_add_language (client, "lua");
+
+ IDE_EXIT;
+}
+
+static void
+gbp_lua_service_configure_launcher (IdeLspService *service,
+ IdePipeline *pipeline,
+ IdeSubprocessLauncher *launcher)
+{
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_SERVICE (service));
+ g_assert (IDE_IS_PIPELINE (pipeline));
+ g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+
+ /* Options:
+ *
+ * --logpath=
+ * --loglevel=trace
+ * --metapath=
+ * --locale=
+ * --configpath=
+ * --version
+ * --check
+ * --checklevel=(Error|Warning|Information)
+ */
+
+ IDE_EXIT;
+}
+
+static void
+gbp_lua_service_class_init (GbpLuaServiceClass *klass)
+{
+ IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
+
+ lsp_service_class->configure_client = gbp_lua_service_configure_client;
+ lsp_service_class->configure_launcher = gbp_lua_service_configure_launcher;
+}
+
+static void
+gbp_lua_service_init (GbpLuaService *self)
+{
+ ide_lsp_service_set_program (IDE_LSP_SERVICE (self), "lua-language-server");
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-service.h
b/src/plugins/lua-language-server/gbp-lua-service.h
new file mode 100644
index 000000000..0b6ba6edf
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-service.h
@@ -0,0 +1,31 @@
+/* gbp-lua-service.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_SERVICE (gbp_lua_service_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaService, gbp_lua_service, GBP, LUA_SERVICE, IdeLspService)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/gbp-lua-symbol-resolver.c
b/src/plugins/lua-language-server/gbp-lua-symbol-resolver.c
new file mode 100644
index 000000000..f7cf9a7ac
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-symbol-resolver.c
@@ -0,0 +1,65 @@
+/* gbp-lua-symbol-resolver.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-lua-symbol-resolver"
+
+#include "config.h"
+
+#include "gbp-lua-symbol-resolver.h"
+#include "gbp-lua-service.h"
+
+struct _GbpLuaSymbolResolver
+{
+ IdeLspSymbolResolver parent_instance;
+};
+
+static void
+gbp_lua_symbol_provider_load (IdeSymbolResolver *provider)
+{
+ g_autoptr(IdeLspServiceClass) klass = NULL;
+
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_LUA_SYMBOL_RESOLVER (provider));
+
+ klass = g_type_class_ref (GBP_TYPE_LUA_SERVICE);
+ ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+ IDE_EXIT;
+}
+
+static void
+symbol_provider_iface_init (IdeSymbolResolverInterface *iface)
+{
+ iface->load = gbp_lua_symbol_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpLuaSymbolResolver, gbp_lua_symbol_provider, IDE_TYPE_LSP_SYMBOL_RESOLVER,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_SYMBOL_RESOLVER, symbol_provider_iface_init))
+
+static void
+gbp_lua_symbol_provider_class_init (GbpLuaSymbolResolverClass *klass)
+{
+}
+
+static void
+gbp_lua_symbol_provider_init (GbpLuaSymbolResolver *self)
+{
+}
diff --git a/src/plugins/lua-language-server/gbp-lua-symbol-resolver.h
b/src/plugins/lua-language-server/gbp-lua-symbol-resolver.h
new file mode 100644
index 000000000..3ebbf73e2
--- /dev/null
+++ b/src/plugins/lua-language-server/gbp-lua-symbol-resolver.h
@@ -0,0 +1,31 @@
+/* gbp-lua-symbol-resolver.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LUA_SYMBOL_RESOLVER (gbp_lua_symbol_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLuaSymbolResolver, gbp_lua_symbol_provider, GBP, LUA_SYMBOL_RESOLVER,
IdeLspSymbolResolver)
+
+G_END_DECLS
diff --git a/src/plugins/lua-language-server/lua-language-server-plugin.c
b/src/plugins/lua-language-server/lua-language-server-plugin.c
new file mode 100644
index 000000000..c9788bbb1
--- /dev/null
+++ b/src/plugins/lua-language-server/lua-language-server-plugin.c
@@ -0,0 +1,68 @@
+/* lua-language-server-plugin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "lua-language-server-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-lsp.h>
+
+#include "gbp-lua-service.h"
+#include "gbp-lua-completion-provider.h"
+#include "gbp-lua-diagnostic-provider.h"
+#include "gbp-lua-symbol-resolver.h"
+#include "gbp-lua-highlighter.h"
+#include "gbp-lua-formatter.h"
+#include "gbp-lua-rename-provider.h"
+#include "gbp-lua-hover-provider.h"
+#include "gbp-lua-code-action-provider.h"
+
+_IDE_EXTERN void
+_gbp_lua_register_types (PeasObjectModule *module)
+{
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_DIAGNOSTIC_PROVIDER,
+ GBP_TYPE_LUA_DIAGNOSTIC_PROVIDER);
+ peas_object_module_register_extension_type (module,
+ GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
+ GBP_TYPE_LUA_COMPLETION_PROVIDER);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_SYMBOL_RESOLVER,
+ GBP_TYPE_LUA_SYMBOL_RESOLVER);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_HIGHLIGHTER,
+ GBP_TYPE_LUA_HIGHLIGHTER);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_FORMATTER,
+ GBP_TYPE_LUA_FORMATTER);
+ peas_object_module_register_extension_type (module,
+ GTK_SOURCE_TYPE_HOVER_PROVIDER,
+ GBP_TYPE_LUA_HOVER_PROVIDER);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_RENAME_PROVIDER,
+ GBP_TYPE_LUA_RENAME_PROVIDER);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_CODE_ACTION_PROVIDER,
+ GBP_TYPE_LUA_CODE_ACTION_PROVIDER);
+}
diff --git a/src/plugins/lua-language-server/lua-language-server.gresource.xml
b/src/plugins/lua-language-server/lua-language-server.gresource.xml
new file mode 100644
index 000000000..864a66d4b
--- /dev/null
+++ b/src/plugins/lua-language-server/lua-language-server.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/plugins/lua-language-server">
+ <file>lua-language-server.plugin</file>
+ </gresource>
+</gresources>
diff --git a/src/plugins/lua-language-server/lua-language-server.plugin
b/src/plugins/lua-language-server/lua-language-server.plugin
new file mode 100644
index 000000000..ed83b5bb3
--- /dev/null
+++ b/src/plugins/lua-language-server/lua-language-server.plugin
@@ -0,0 +1,16 @@
+[Plugin]
+Builtin=true
+Copyright=Copyright © 2022 Christian Hergert
+Description=Provides integration with lua-language-server
+Embedded=_gbp_lua_register_types
+Module=lua-language-server
+Name=Lua Language Server
+X-Category=lsps
+X-Completion-Provider-Languages=lua
+X-Symbol-Resolver-Languages=lua
+X-Diagnostic-Provider-Languages=lua
+X-Highlighter-Languages=lua
+X-Hover-Provider-Languages=lua
+X-Rename-Provider-Languages=lua
+X-Formatter-Languages=lua
+X-Code-Action-Languages=lua
diff --git a/src/plugins/lua-language-server/meson.build b/src/plugins/lua-language-server/meson.build
new file mode 100644
index 000000000..82d3dc62d
--- /dev/null
+++ b/src/plugins/lua-language-server/meson.build
@@ -0,0 +1,24 @@
+if get_option('plugin_lua_language_server')
+
+plugins_sources += files([
+ 'lua-language-server-plugin.c',
+ 'gbp-lua-code-action-provider.c',
+ 'gbp-lua-completion-provider.c',
+ 'gbp-lua-diagnostic-provider.c',
+ 'gbp-lua-formatter.c',
+ 'gbp-lua-highlighter.c',
+ 'gbp-lua-hover-provider.c',
+ 'gbp-lua-rename-provider.c',
+ 'gbp-lua-symbol-resolver.c',
+ 'gbp-lua-service.c',
+])
+
+plugin_lua_resources = gnome.compile_resources(
+ 'lua-language-server-resources',
+ 'lua-language-server.gresource.xml',
+ c_name: 'gbp_lua',
+)
+
+plugins_sources += plugin_lua_resources
+
+endif
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index deb2d81fe..048cf31d8 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -84,6 +84,7 @@ subdir('jdtls')
subdir('jedi-language-server')
subdir('jhbuild')
subdir('ls')
+subdir('lua-language-server')
subdir('make')
subdir('make-templates')
subdir('markdown-preview')
@@ -221,6 +222,7 @@ status += [
'intelephense ................... (PHP) : @0@'.format(get_option('plugin_intelephense')),
'jdtls ......................... (Java) : @0@'.format(get_option('plugin_jdtls')),
'jedi-language-server ........ (Python) : @0@ **'.format(get_option('plugin_jedi_language_server')),
+ 'lua-language-server ............ (Lua) : @0@'.format(get_option('plugin_lua_language_server')),
'python-lsp-server ........... (Python) : @0@'.format(get_option('plugin_python_lsp_server')),
'rust-analyzer ................. (Rust) : @0@'.format(get_option('plugin_rust_analyzer')),
'ts-language-server ... (JS/TypeScript) : @0@'.format(get_option('plugin_ts_language_server')),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]