[gnome-builder/wip/gtk4-port] plugins/clangd: port clangd plugin to C



commit 13d1d29e52782cc9f3d91d0ff4ab021299d21c3c
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 24 02:04:46 2022 -0700

    plugins/clangd: port clangd plugin to C

 src/plugins/clangd/clangd-plugin.c                 | 70 ++++++++++++++++++++
 src/plugins/clangd/clangd.gresource.xml            |  6 ++
 src/plugins/clangd/clangd.plugin                   |  5 +-
 src/plugins/clangd/clangd_plugin.py                | 75 ----------------------
 .../clangd/gbp-clangd-code-action-provider.c       | 65 +++++++++++++++++++
 .../clangd/gbp-clangd-code-action-provider.h       | 31 +++++++++
 .../clangd/gbp-clangd-completion-provider.c        | 75 ++++++++++++++++++++++
 .../clangd/gbp-clangd-completion-provider.h        | 31 +++++++++
 .../clangd/gbp-clangd-diagnostic-provider.c        | 65 +++++++++++++++++++
 .../clangd/gbp-clangd-diagnostic-provider.h        | 31 +++++++++
 src/plugins/clangd/gbp-clangd-formatter.c          | 65 +++++++++++++++++++
 src/plugins/clangd/gbp-clangd-formatter.h          | 31 +++++++++
 src/plugins/clangd/gbp-clangd-highlighter.c        | 65 +++++++++++++++++++
 src/plugins/clangd/gbp-clangd-highlighter.h        | 31 +++++++++
 src/plugins/clangd/gbp-clangd-hover-provider.c     | 66 +++++++++++++++++++
 src/plugins/clangd/gbp-clangd-hover-provider.h     | 31 +++++++++
 src/plugins/clangd/gbp-clangd-rename-provider.c    | 65 +++++++++++++++++++
 src/plugins/clangd/gbp-clangd-rename-provider.h    | 31 +++++++++
 src/plugins/clangd/gbp-clangd-service.c            | 59 +++++++++++++++++
 src/plugins/clangd/gbp-clangd-service.h            | 31 +++++++++
 src/plugins/clangd/gbp-clangd-symbol-resolver.c    | 65 +++++++++++++++++++
 src/plugins/clangd/gbp-clangd-symbol-resolver.h    | 31 +++++++++
 src/plugins/clangd/meson.build                     | 27 +++++---
 src/plugins/meson.build                            |  2 +-
 24 files changed, 967 insertions(+), 87 deletions(-)
---
diff --git a/src/plugins/clangd/clangd-plugin.c b/src/plugins/clangd/clangd-plugin.c
new file mode 100644
index 000000000..c799d8d1e
--- /dev/null
+++ b/src/plugins/clangd/clangd-plugin.c
@@ -0,0 +1,70 @@
+/* clangd-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 "clangd-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-lsp.h>
+
+#include "gbp-clangd-service.h"
+#include "gbp-clangd-completion-provider.h"
+#include "gbp-clangd-diagnostic-provider.h"
+#include "gbp-clangd-symbol-resolver.h"
+#include "gbp-clangd-highlighter.h"
+#include "gbp-clangd-formatter.h"
+#include "gbp-clangd-rename-provider.h"
+#include "gbp-clangd-hover-provider.h"
+#include "gbp-clangd-code-action-provider.h"
+
+_IDE_EXTERN void
+_gbp_clangd_register_types (PeasObjectModule *module)
+{
+  ide_g_file_add_ignored_pattern (".cache");
+
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_DIAGNOSTIC_PROVIDER,
+                                              GBP_TYPE_CLANGD_DIAGNOSTIC_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
+                                              GBP_TYPE_CLANGD_COMPLETION_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_SYMBOL_RESOLVER,
+                                              GBP_TYPE_CLANGD_SYMBOL_RESOLVER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_HIGHLIGHTER,
+                                              GBP_TYPE_CLANGD_HIGHLIGHTER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_FORMATTER,
+                                              GBP_TYPE_CLANGD_FORMATTER);
+  peas_object_module_register_extension_type (module,
+                                              GTK_SOURCE_TYPE_HOVER_PROVIDER,
+                                              GBP_TYPE_CLANGD_HOVER_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_RENAME_PROVIDER,
+                                              GBP_TYPE_CLANGD_RENAME_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_CODE_ACTION_PROVIDER,
+                                              GBP_TYPE_CLANGD_CODE_ACTION_PROVIDER);
+}
diff --git a/src/plugins/clangd/clangd.gresource.xml b/src/plugins/clangd/clangd.gresource.xml
new file mode 100644
index 000000000..f968fa838
--- /dev/null
+++ b/src/plugins/clangd/clangd.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/clangd">
+    <file>clangd.plugin</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/clangd/clangd.plugin b/src/plugins/clangd/clangd.plugin
index ea35876f4..bb2569806 100644
--- a/src/plugins/clangd/clangd.plugin
+++ b/src/plugins/clangd/clangd.plugin
@@ -2,10 +2,9 @@
 Builtin=true
 Copyright=Copyright © 2022 Christian Hergert
 Description=Integration with clangd
-Loader=python3
-Module=clangd_plugin
+Embedded=_gbp_clangd_register_types
+Module=clangd
 Name=Clangd Language Server
-X-Builder-ABI=@PACKAGE_ABI@
 X-Category=lsps
 X-Code-Action-Languages=c,chdr,cpp,cpphdr,objc
 X-Completion-Provider-Languages=c,chdr,cpp,cpphdr,objc
diff --git a/src/plugins/clangd/gbp-clangd-code-action-provider.c 
b/src/plugins/clangd/gbp-clangd-code-action-provider.c
new file mode 100644
index 000000000..61b8c5f88
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-code-action-provider.c
@@ -0,0 +1,65 @@
+/* gbp-clangd-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-clangd-code-action-provider"
+
+#include "config.h"
+
+#include "gbp-clangd-code-action-provider.h"
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdCodeActionProvider
+{
+  IdeLspCodeActionProvider parent_instance;
+};
+
+static void
+gbp_clangd_code_action_provider_load (IdeCodeActionProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_CLANGD_CODE_ACTION_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_CLANGD_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_clangd_code_action_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpClangdCodeActionProvider, gbp_clangd_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_clangd_code_action_provider_class_init (GbpClangdCodeActionProviderClass *klass)
+{
+}
+
+static void
+gbp_clangd_code_action_provider_init (GbpClangdCodeActionProvider *self)
+{
+}
diff --git a/src/plugins/clangd/gbp-clangd-code-action-provider.h 
b/src/plugins/clangd/gbp-clangd-code-action-provider.h
new file mode 100644
index 000000000..20f20e511
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-code-action-provider.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_CODE_ACTION_PROVIDER (gbp_clangd_code_action_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdCodeActionProvider, gbp_clangd_code_action_provider, GBP, 
CLANGD_CODE_ACTION_PROVIDER, IdeLspCodeActionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/gbp-clangd-completion-provider.c 
b/src/plugins/clangd/gbp-clangd-completion-provider.c
new file mode 100644
index 000000000..ff5e7bbd9
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-completion-provider.c
@@ -0,0 +1,75 @@
+/* gbp-clangd-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-clangd-completion-provider"
+
+#include "config.h"
+
+#include "gbp-clangd-completion-provider.h"
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdCompletionProvider
+{
+  IdeLspCompletionProvider parent_instance;
+};
+
+static void
+gbp_clangd_completion_provider_load (IdeLspCompletionProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_CLANGD_COMPLETION_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_CLANGD_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static int
+gbp_clangd_completion_provider_get_priority (GtkSourceCompletionProvider *provider,
+                                             GtkSourceCompletionContext  *context)
+{
+  return -1000;
+}
+
+static void
+completion_provider_iface_init (GtkSourceCompletionProviderInterface *iface)
+{
+  iface->get_priority = gbp_clangd_completion_provider_get_priority;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpClangdCompletionProvider, gbp_clangd_completion_provider, 
IDE_TYPE_LSP_COMPLETION_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER, 
completion_provider_iface_init))
+
+static void
+gbp_clangd_completion_provider_class_init (GbpClangdCompletionProviderClass *klass)
+{
+  IdeLspCompletionProviderClass *lsp_completion_provider_class = IDE_LSP_COMPLETION_PROVIDER_CLASS (klass);
+
+  lsp_completion_provider_class->load = gbp_clangd_completion_provider_load;
+}
+
+static void
+gbp_clangd_completion_provider_init (GbpClangdCompletionProvider *self)
+{
+}
diff --git a/src/plugins/clangd/gbp-clangd-completion-provider.h 
b/src/plugins/clangd/gbp-clangd-completion-provider.h
new file mode 100644
index 000000000..8ce54bf04
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-completion-provider.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_COMPLETION_PROVIDER (gbp_clangd_completion_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdCompletionProvider, gbp_clangd_completion_provider, GBP, 
CLANGD_COMPLETION_PROVIDER, IdeLspCompletionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/gbp-clangd-diagnostic-provider.c 
b/src/plugins/clangd/gbp-clangd-diagnostic-provider.c
new file mode 100644
index 000000000..37232ed36
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-diagnostic-provider.c
@@ -0,0 +1,65 @@
+/* gbp-clangd-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-clangd-diagnostic-provider"
+
+#include "config.h"
+
+#include "gbp-clangd-diagnostic-provider.h"
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdDiagnosticProvider
+{
+  IdeLspDiagnosticProvider parent_instance;
+};
+
+static void
+gbp_clangd_diagnostic_provider_load (IdeDiagnosticProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_CLANGD_DIAGNOSTIC_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_CLANGD_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface)
+{
+  iface->load = gbp_clangd_diagnostic_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpClangdDiagnosticProvider, gbp_clangd_diagnostic_provider, 
IDE_TYPE_LSP_DIAGNOSTIC_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER, 
diagnostic_provider_iface_init))
+
+static void
+gbp_clangd_diagnostic_provider_class_init (GbpClangdDiagnosticProviderClass *klass)
+{
+}
+
+static void
+gbp_clangd_diagnostic_provider_init (GbpClangdDiagnosticProvider *self)
+{
+}
diff --git a/src/plugins/clangd/gbp-clangd-diagnostic-provider.h 
b/src/plugins/clangd/gbp-clangd-diagnostic-provider.h
new file mode 100644
index 000000000..0af4b04f1
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-diagnostic-provider.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_DIAGNOSTIC_PROVIDER (gbp_clangd_diagnostic_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdDiagnosticProvider, gbp_clangd_diagnostic_provider, GBP, 
CLANGD_DIAGNOSTIC_PROVIDER, IdeLspDiagnosticProvider)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/gbp-clangd-formatter.c b/src/plugins/clangd/gbp-clangd-formatter.c
new file mode 100644
index 000000000..ba7b6fec3
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-formatter.c
@@ -0,0 +1,65 @@
+/* gbp-clangd-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-clangd-formatter"
+
+#include "config.h"
+
+#include "gbp-clangd-formatter.h"
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdFormatter
+{
+  IdeLspFormatter parent_instance;
+};
+
+static void
+gbp_clangd_formatter_load (IdeFormatter *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_CLANGD_FORMATTER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_CLANGD_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+formatter_iface_init (IdeFormatterInterface *iface)
+{
+  iface->load = gbp_clangd_formatter_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpClangdFormatter, gbp_clangd_formatter, IDE_TYPE_LSP_FORMATTER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_FORMATTER, formatter_iface_init))
+
+static void
+gbp_clangd_formatter_class_init (GbpClangdFormatterClass *klass)
+{
+}
+
+static void
+gbp_clangd_formatter_init (GbpClangdFormatter *self)
+{
+}
diff --git a/src/plugins/clangd/gbp-clangd-formatter.h b/src/plugins/clangd/gbp-clangd-formatter.h
new file mode 100644
index 000000000..78cd49ef3
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-formatter.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_FORMATTER (gbp_clangd_formatter_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdFormatter, gbp_clangd_formatter, GBP, CLANGD_FORMATTER, IdeLspFormatter)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/gbp-clangd-highlighter.c b/src/plugins/clangd/gbp-clangd-highlighter.c
new file mode 100644
index 000000000..2a267d59c
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-highlighter.c
@@ -0,0 +1,65 @@
+/* gbp-clangd-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-clangd-highlighter"
+
+#include "config.h"
+
+#include "gbp-clangd-highlighter.h"
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdHighlighter
+{
+  IdeLspHighlighter parent_instance;
+};
+
+static void
+gbp_clangd_highlighter_load (IdeHighlighter *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_CLANGD_HIGHLIGHTER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_CLANGD_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+highlighter_iface_init (IdeHighlighterInterface *iface)
+{
+  iface->load = gbp_clangd_highlighter_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpClangdHighlighter, gbp_clangd_highlighter, IDE_TYPE_LSP_HIGHLIGHTER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_HIGHLIGHTER, highlighter_iface_init))
+
+static void
+gbp_clangd_highlighter_class_init (GbpClangdHighlighterClass *klass)
+{
+}
+
+static void
+gbp_clangd_highlighter_init (GbpClangdHighlighter *self)
+{
+}
diff --git a/src/plugins/clangd/gbp-clangd-highlighter.h b/src/plugins/clangd/gbp-clangd-highlighter.h
new file mode 100644
index 000000000..c055a0856
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-highlighter.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_HIGHLIGHTER (gbp_clangd_highlighter_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdHighlighter, gbp_clangd_highlighter, GBP, CLANGD_HIGHLIGHTER, 
IdeLspHighlighter)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/gbp-clangd-hover-provider.c b/src/plugins/clangd/gbp-clangd-hover-provider.c
new file mode 100644
index 000000000..aa8fb87cb
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-hover-provider.c
@@ -0,0 +1,66 @@
+/* gbp-clangd-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-clangd-hover-provider"
+
+#include "config.h"
+
+#include "gbp-clangd-hover-provider.h"
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdHoverProvider
+{
+  IdeLspHoverProvider parent_instance;
+};
+
+static void
+gbp_clangd_hover_provider_prepare (IdeLspHoverProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_CLANGD_HOVER_PROVIDER (provider));
+
+  g_object_set (provider,
+                "category", "Clangd",
+                "priority", 200,
+                NULL);
+
+  klass = g_type_class_ref (GBP_TYPE_CLANGD_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+G_DEFINE_FINAL_TYPE (GbpClangdHoverProvider, gbp_clangd_hover_provider, IDE_TYPE_LSP_HOVER_PROVIDER)
+
+static void
+gbp_clangd_hover_provider_class_init (GbpClangdHoverProviderClass *klass)
+{
+  IdeLspHoverProviderClass *lsp_hover_provider_class = IDE_LSP_HOVER_PROVIDER_CLASS (klass);
+
+  lsp_hover_provider_class->prepare = gbp_clangd_hover_provider_prepare;
+}
+
+static void
+gbp_clangd_hover_provider_init (GbpClangdHoverProvider *self)
+{
+}
diff --git a/src/plugins/clangd/gbp-clangd-hover-provider.h b/src/plugins/clangd/gbp-clangd-hover-provider.h
new file mode 100644
index 000000000..d8acc6388
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-hover-provider.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_HOVER_PROVIDER (gbp_clangd_hover_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdHoverProvider, gbp_clangd_hover_provider, GBP, CLANGD_HOVER_PROVIDER, 
IdeLspHoverProvider)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/gbp-clangd-rename-provider.c b/src/plugins/clangd/gbp-clangd-rename-provider.c
new file mode 100644
index 000000000..8ac708566
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-rename-provider.c
@@ -0,0 +1,65 @@
+/* gbp-clangd-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-clangd-rename-provider"
+
+#include "config.h"
+
+#include "gbp-clangd-rename-provider.h"
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdRenameProvider
+{
+  IdeLspRenameProvider parent_instance;
+};
+
+static void
+gbp_clangd_rename_provider_load (IdeRenameProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_CLANGD_RENAME_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_CLANGD_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+rename_provider_iface_init (IdeRenameProviderInterface *iface)
+{
+  iface->load = gbp_clangd_rename_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpClangdRenameProvider, gbp_clangd_rename_provider, 
IDE_TYPE_LSP_RENAME_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_RENAME_PROVIDER, rename_provider_iface_init))
+
+static void
+gbp_clangd_rename_provider_class_init (GbpClangdRenameProviderClass *klass)
+{
+}
+
+static void
+gbp_clangd_rename_provider_init (GbpClangdRenameProvider *self)
+{
+}
diff --git a/src/plugins/clangd/gbp-clangd-rename-provider.h b/src/plugins/clangd/gbp-clangd-rename-provider.h
new file mode 100644
index 000000000..da8436f5b
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-rename-provider.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_RENAME_PROVIDER (gbp_clangd_rename_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdRenameProvider, gbp_clangd_rename_provider, GBP, CLANGD_RENAME_PROVIDER, 
IdeLspRenameProvider)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/gbp-clangd-service.c b/src/plugins/clangd/gbp-clangd-service.c
new file mode 100644
index 000000000..fcf8a78e5
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-service.c
@@ -0,0 +1,59 @@
+/* gbp-clangd-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-clangd-service"
+
+#include "config.h"
+
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdService
+{
+  IdeLspService parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpClangdService, gbp_clangd_service, IDE_TYPE_LSP_SERVICE)
+
+static void
+gbp_clangd_service_configure_client (IdeLspService *service,
+                                     IdeLspClient  *client)
+{
+  g_assert (GBP_IS_CLANGD_SERVICE (service));
+  g_assert (IDE_IS_LSP_CLIENT (client));
+
+  ide_lsp_client_add_language (client, "c");
+  ide_lsp_client_add_language (client, "cpp");
+  ide_lsp_client_add_language (client, "objective-c");
+  ide_lsp_client_add_language (client, "objective-cpp");
+}
+
+static void
+gbp_clangd_service_class_init (GbpClangdServiceClass *klass)
+{
+  IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
+
+  lsp_service_class->configure_client = gbp_clangd_service_configure_client;
+}
+
+static void
+gbp_clangd_service_init (GbpClangdService *self)
+{
+  ide_lsp_service_set_program (IDE_LSP_SERVICE (self), "clangd");
+}
diff --git a/src/plugins/clangd/gbp-clangd-service.h b/src/plugins/clangd/gbp-clangd-service.h
new file mode 100644
index 000000000..94bd17739
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-service.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_SERVICE (gbp_clangd_service_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdService, gbp_clangd_service, GBP, CLANGD_SERVICE, IdeLspService)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/gbp-clangd-symbol-resolver.c b/src/plugins/clangd/gbp-clangd-symbol-resolver.c
new file mode 100644
index 000000000..510364653
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-symbol-resolver.c
@@ -0,0 +1,65 @@
+/* gbp-clangd-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-clangd-symbol-resolver"
+
+#include "config.h"
+
+#include "gbp-clangd-symbol-resolver.h"
+#include "gbp-clangd-service.h"
+
+struct _GbpClangdSymbolResolver
+{
+  IdeLspSymbolResolver parent_instance;
+};
+
+static void
+gbp_clangd_symbol_provider_load (IdeSymbolResolver *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_CLANGD_SYMBOL_RESOLVER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_CLANGD_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+symbol_provider_iface_init (IdeSymbolResolverInterface *iface)
+{
+  iface->load = gbp_clangd_symbol_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpClangdSymbolResolver, gbp_clangd_symbol_provider, 
IDE_TYPE_LSP_SYMBOL_RESOLVER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_SYMBOL_RESOLVER, symbol_provider_iface_init))
+
+static void
+gbp_clangd_symbol_provider_class_init (GbpClangdSymbolResolverClass *klass)
+{
+}
+
+static void
+gbp_clangd_symbol_provider_init (GbpClangdSymbolResolver *self)
+{
+}
diff --git a/src/plugins/clangd/gbp-clangd-symbol-resolver.h b/src/plugins/clangd/gbp-clangd-symbol-resolver.h
new file mode 100644
index 000000000..17c4927a8
--- /dev/null
+++ b/src/plugins/clangd/gbp-clangd-symbol-resolver.h
@@ -0,0 +1,31 @@
+/* gbp-clangd-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_CLANGD_SYMBOL_RESOLVER (gbp_clangd_symbol_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpClangdSymbolResolver, gbp_clangd_symbol_provider, GBP, CLANGD_SYMBOL_RESOLVER, 
IdeLspSymbolResolver)
+
+G_END_DECLS
diff --git a/src/plugins/clangd/meson.build b/src/plugins/clangd/meson.build
index 37fa0441d..d60f5b1fa 100644
--- a/src/plugins/clangd/meson.build
+++ b/src/plugins/clangd/meson.build
@@ -1,13 +1,24 @@
 if get_option('plugin_clangd')
 
-install_data('clangd_plugin.py', install_dir: plugindir)
-
-configure_file(
-          input: 'clangd.plugin',
-         output: 'clangd.plugin',
-  configuration: config_h,
-        install: true,
-    install_dir: plugindir,
+plugins_sources += files([
+  'clangd-plugin.c',
+  'gbp-clangd-code-action-provider.c',
+  'gbp-clangd-completion-provider.c',
+  'gbp-clangd-diagnostic-provider.c',
+  'gbp-clangd-formatter.c',
+  'gbp-clangd-highlighter.c',
+  'gbp-clangd-hover-provider.c',
+  'gbp-clangd-rename-provider.c',
+  'gbp-clangd-symbol-resolver.c',
+  'gbp-clangd-service.c',
+])
+
+plugin_clangd_resources = gnome.compile_resources(
+  'clangd-resources',
+  'clangd.gresource.xml',
+  c_name: 'gbp_clangd',
 )
 
+plugins_sources += plugin_clangd_resources
+
 endif
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index ec712421a..2b5937265 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -209,7 +209,7 @@ status += [
   '',
   'blueprint ................ (Blueprint) : @0@'.format(get_option('plugin_blueprint')),
   'gnome-builder-clang .. (C, C++, Obj-C) : @0@'.format(get_option('plugin_clang')),
-  'clangd ............... (C, C++, Obj-C) : @0@ (Not Suggested)'.format(get_option('plugin_clangd')),
+  'clangd ............... (C, C++, Obj-C) : @0@ (Testing Only)'.format(get_option('plugin_clangd')),
   'gpls ............................ (Go) : @0@'.format(get_option('plugin_go_langserv')),
   'intelephense ................... (PHP) : @0@'.format(get_option('plugin_intelephense')),
   'jedi-language-server ........ (Python) : @0@'.format(get_option('plugin_jedi_language_server')),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]