[gnome-builder/wip/gtk4-port] plugins/bash-language-server: add bash language server plugin



commit 9e22368370d9b5ccc022c84b5bac365070db880d
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 24 16:20:49 2022 -0700

    plugins/bash-language-server: add bash language server plugin
    
    This adds support for `bash-language-server` which is available, at least
    on Fedora, using dnf install nodejs-bash-language-server.

 meson_options.txt                                  |  1 +
 .../bash-language-server-plugin.c                  | 68 +++++++++++++++++++
 .../bash-language-server.gresource.xml             |  6 ++
 .../bash-language-server.plugin                    | 16 +++++
 .../gbp-bash-code-action-provider.c                | 65 ++++++++++++++++++
 .../gbp-bash-code-action-provider.h                | 31 +++++++++
 .../gbp-bash-completion-provider.c                 | 75 ++++++++++++++++++++
 .../gbp-bash-completion-provider.h                 | 31 +++++++++
 .../gbp-bash-diagnostic-provider.c                 | 65 ++++++++++++++++++
 .../gbp-bash-diagnostic-provider.h                 | 31 +++++++++
 .../bash-language-server/gbp-bash-formatter.c      | 65 ++++++++++++++++++
 .../bash-language-server/gbp-bash-formatter.h      | 31 +++++++++
 .../bash-language-server/gbp-bash-highlighter.c    | 65 ++++++++++++++++++
 .../bash-language-server/gbp-bash-highlighter.h    | 31 +++++++++
 .../bash-language-server/gbp-bash-hover-provider.c | 66 ++++++++++++++++++
 .../bash-language-server/gbp-bash-hover-provider.h | 31 +++++++++
 .../gbp-bash-rename-provider.c                     | 65 ++++++++++++++++++
 .../gbp-bash-rename-provider.h                     | 31 +++++++++
 .../bash-language-server/gbp-bash-service.c        | 79 ++++++++++++++++++++++
 .../bash-language-server/gbp-bash-service.h        | 31 +++++++++
 .../gbp-bash-symbol-resolver.c                     | 65 ++++++++++++++++++
 .../gbp-bash-symbol-resolver.h                     | 31 +++++++++
 src/plugins/bash-language-server/meson.build       | 24 +++++++
 src/plugins/meson.build                            |  2 +
 24 files changed, 1006 insertions(+)
---
diff --git a/meson_options.txt b/meson_options.txt
index 1b6a03f0e..ca55c6d6a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -22,6 +22,7 @@ option('ctags_path', type: 'string', value: '')
 option('webkit', type: 'feature', value: 'enabled', description: 'Enable features which require WebKit')
 
 option('plugin_autotools', type: 'boolean')
+option('plugin_bash_language_server', type: 'boolean')
 option('plugin_beautifier', type: 'boolean')
 option('plugin_blueprint', type: 'boolean')
 option('plugin_c_pack', type: 'boolean')
diff --git a/src/plugins/bash-language-server/bash-language-server-plugin.c 
b/src/plugins/bash-language-server/bash-language-server-plugin.c
new file mode 100644
index 000000000..284366753
--- /dev/null
+++ b/src/plugins/bash-language-server/bash-language-server-plugin.c
@@ -0,0 +1,68 @@
+/* bash-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 "bash-language-server-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-lsp.h>
+
+#include "gbp-bash-service.h"
+#include "gbp-bash-completion-provider.h"
+#include "gbp-bash-diagnostic-provider.h"
+#include "gbp-bash-symbol-resolver.h"
+#include "gbp-bash-highlighter.h"
+#include "gbp-bash-formatter.h"
+#include "gbp-bash-rename-provider.h"
+#include "gbp-bash-hover-provider.h"
+#include "gbp-bash-code-action-provider.h"
+
+_IDE_EXTERN void
+_gbp_bash_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_DIAGNOSTIC_PROVIDER,
+                                              GBP_TYPE_BASH_DIAGNOSTIC_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
+                                              GBP_TYPE_BASH_COMPLETION_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_SYMBOL_RESOLVER,
+                                              GBP_TYPE_BASH_SYMBOL_RESOLVER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_HIGHLIGHTER,
+                                              GBP_TYPE_BASH_HIGHLIGHTER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_FORMATTER,
+                                              GBP_TYPE_BASH_FORMATTER);
+  peas_object_module_register_extension_type (module,
+                                              GTK_SOURCE_TYPE_HOVER_PROVIDER,
+                                              GBP_TYPE_BASH_HOVER_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_RENAME_PROVIDER,
+                                              GBP_TYPE_BASH_RENAME_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_CODE_ACTION_PROVIDER,
+                                              GBP_TYPE_BASH_CODE_ACTION_PROVIDER);
+}
diff --git a/src/plugins/bash-language-server/bash-language-server.gresource.xml 
b/src/plugins/bash-language-server/bash-language-server.gresource.xml
new file mode 100644
index 000000000..3f77de6c9
--- /dev/null
+++ b/src/plugins/bash-language-server/bash-language-server.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/bash-language-server">
+    <file>bash-language-server.plugin</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/bash-language-server/bash-language-server.plugin 
b/src/plugins/bash-language-server/bash-language-server.plugin
new file mode 100644
index 000000000..0ee5bcea1
--- /dev/null
+++ b/src/plugins/bash-language-server/bash-language-server.plugin
@@ -0,0 +1,16 @@
+[Plugin]
+Builtin=true
+Copyright=Copyright © 2021 Günther Wagner, Copyright © 2022 Christian Hergert
+Description=Provides integration with bash-language-server for Bash
+Embedded=_gbp_bash_register_types
+Module=bash-language-server
+Name=Bash Language Server
+X-Category=lsps
+X-Completion-Provider-Languages=sh
+X-Symbol-Resolver-Languages=sh
+X-Diagnostic-Provider-Languages=sh
+X-Highlighter-Languages=sh
+X-Hover-Provider-Languages=sh
+X-Rename-Provider-Languages=sh
+X-Formatter-Languages=sh
+X-Code-Action-Languages=sh
diff --git a/src/plugins/bash-language-server/gbp-bash-code-action-provider.c 
b/src/plugins/bash-language-server/gbp-bash-code-action-provider.c
new file mode 100644
index 000000000..2520ab767
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-code-action-provider.c
@@ -0,0 +1,65 @@
+/* gbp-bash-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-bash-code-action-provider"
+
+#include "config.h"
+
+#include "gbp-bash-code-action-provider.h"
+#include "gbp-bash-service.h"
+
+struct _GbpBashCodeActionProvider
+{
+  IdeLspCodeActionProvider parent_instance;
+};
+
+static void
+gbp_bash_code_action_provider_load (IdeCodeActionProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_CODE_ACTION_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BASH_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_bash_code_action_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBashCodeActionProvider, gbp_bash_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_bash_code_action_provider_class_init (GbpBashCodeActionProviderClass *klass)
+{
+}
+
+static void
+gbp_bash_code_action_provider_init (GbpBashCodeActionProvider *self)
+{
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-code-action-provider.h 
b/src/plugins/bash-language-server/gbp-bash-code-action-provider.h
new file mode 100644
index 000000000..d843097ab
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-code-action-provider.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_CODE_ACTION_PROVIDER (gbp_bash_code_action_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashCodeActionProvider, gbp_bash_code_action_provider, GBP, 
BASH_CODE_ACTION_PROVIDER, IdeLspCodeActionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/gbp-bash-completion-provider.c 
b/src/plugins/bash-language-server/gbp-bash-completion-provider.c
new file mode 100644
index 000000000..5c6a8fa13
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-completion-provider.c
@@ -0,0 +1,75 @@
+/* gbp-bash-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-bash-completion-provider"
+
+#include "config.h"
+
+#include "gbp-bash-completion-provider.h"
+#include "gbp-bash-service.h"
+
+struct _GbpBashCompletionProvider
+{
+  IdeLspCompletionProvider parent_instance;
+};
+
+static void
+gbp_bash_completion_provider_load (IdeLspCompletionProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_COMPLETION_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BASH_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static int
+gbp_bash_completion_provider_get_priority (GtkSourceCompletionProvider *provider,
+                                           GtkSourceCompletionContext  *context)
+{
+  return -1000;
+}
+
+static void
+completion_provider_iface_init (GtkSourceCompletionProviderInterface *iface)
+{
+  iface->get_priority = gbp_bash_completion_provider_get_priority;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBashCompletionProvider, gbp_bash_completion_provider, 
IDE_TYPE_LSP_COMPLETION_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER, 
completion_provider_iface_init))
+
+static void
+gbp_bash_completion_provider_class_init (GbpBashCompletionProviderClass *klass)
+{
+  IdeLspCompletionProviderClass *lsp_completion_provider_class = IDE_LSP_COMPLETION_PROVIDER_CLASS (klass);
+
+  lsp_completion_provider_class->load = gbp_bash_completion_provider_load;
+}
+
+static void
+gbp_bash_completion_provider_init (GbpBashCompletionProvider *self)
+{
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-completion-provider.h 
b/src/plugins/bash-language-server/gbp-bash-completion-provider.h
new file mode 100644
index 000000000..a4d0c6072
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-completion-provider.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_COMPLETION_PROVIDER (gbp_bash_completion_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashCompletionProvider, gbp_bash_completion_provider, GBP, 
BASH_COMPLETION_PROVIDER, IdeLspCompletionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/gbp-bash-diagnostic-provider.c 
b/src/plugins/bash-language-server/gbp-bash-diagnostic-provider.c
new file mode 100644
index 000000000..299ba274c
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-diagnostic-provider.c
@@ -0,0 +1,65 @@
+/* gbp-bash-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-bash-diagnostic-provider"
+
+#include "config.h"
+
+#include "gbp-bash-diagnostic-provider.h"
+#include "gbp-bash-service.h"
+
+struct _GbpBashDiagnosticProvider
+{
+  IdeLspDiagnosticProvider parent_instance;
+};
+
+static void
+gbp_bash_diagnostic_provider_load (IdeDiagnosticProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_DIAGNOSTIC_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BASH_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface)
+{
+  iface->load = gbp_bash_diagnostic_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBashDiagnosticProvider, gbp_bash_diagnostic_provider, 
IDE_TYPE_LSP_DIAGNOSTIC_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER, 
diagnostic_provider_iface_init))
+
+static void
+gbp_bash_diagnostic_provider_class_init (GbpBashDiagnosticProviderClass *klass)
+{
+}
+
+static void
+gbp_bash_diagnostic_provider_init (GbpBashDiagnosticProvider *self)
+{
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-diagnostic-provider.h 
b/src/plugins/bash-language-server/gbp-bash-diagnostic-provider.h
new file mode 100644
index 000000000..a627568bf
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-diagnostic-provider.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_DIAGNOSTIC_PROVIDER (gbp_bash_diagnostic_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashDiagnosticProvider, gbp_bash_diagnostic_provider, GBP, 
BASH_DIAGNOSTIC_PROVIDER, IdeLspDiagnosticProvider)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/gbp-bash-formatter.c 
b/src/plugins/bash-language-server/gbp-bash-formatter.c
new file mode 100644
index 000000000..d63d116f9
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-formatter.c
@@ -0,0 +1,65 @@
+/* gbp-bash-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-bash-formatter"
+
+#include "config.h"
+
+#include "gbp-bash-formatter.h"
+#include "gbp-bash-service.h"
+
+struct _GbpBashFormatter
+{
+  IdeLspFormatter parent_instance;
+};
+
+static void
+gbp_bash_formatter_load (IdeFormatter *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_FORMATTER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BASH_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+formatter_iface_init (IdeFormatterInterface *iface)
+{
+  iface->load = gbp_bash_formatter_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBashFormatter, gbp_bash_formatter, IDE_TYPE_LSP_FORMATTER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_FORMATTER, formatter_iface_init))
+
+static void
+gbp_bash_formatter_class_init (GbpBashFormatterClass *klass)
+{
+}
+
+static void
+gbp_bash_formatter_init (GbpBashFormatter *self)
+{
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-formatter.h 
b/src/plugins/bash-language-server/gbp-bash-formatter.h
new file mode 100644
index 000000000..44e2f9bd5
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-formatter.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_FORMATTER (gbp_bash_formatter_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashFormatter, gbp_bash_formatter, GBP, BASH_FORMATTER, IdeLspFormatter)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/gbp-bash-highlighter.c 
b/src/plugins/bash-language-server/gbp-bash-highlighter.c
new file mode 100644
index 000000000..95d436b6e
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-highlighter.c
@@ -0,0 +1,65 @@
+/* gbp-bash-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-bash-highlighter"
+
+#include "config.h"
+
+#include "gbp-bash-highlighter.h"
+#include "gbp-bash-service.h"
+
+struct _GbpBashHighlighter
+{
+  IdeLspHighlighter parent_instance;
+};
+
+static void
+gbp_bash_highlighter_load (IdeHighlighter *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_HIGHLIGHTER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BASH_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+highlighter_iface_init (IdeHighlighterInterface *iface)
+{
+  iface->load = gbp_bash_highlighter_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBashHighlighter, gbp_bash_highlighter, IDE_TYPE_LSP_HIGHLIGHTER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_HIGHLIGHTER, highlighter_iface_init))
+
+static void
+gbp_bash_highlighter_class_init (GbpBashHighlighterClass *klass)
+{
+}
+
+static void
+gbp_bash_highlighter_init (GbpBashHighlighter *self)
+{
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-highlighter.h 
b/src/plugins/bash-language-server/gbp-bash-highlighter.h
new file mode 100644
index 000000000..1e0086da5
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-highlighter.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_HIGHLIGHTER (gbp_bash_highlighter_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashHighlighter, gbp_bash_highlighter, GBP, BASH_HIGHLIGHTER, IdeLspHighlighter)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/gbp-bash-hover-provider.c 
b/src/plugins/bash-language-server/gbp-bash-hover-provider.c
new file mode 100644
index 000000000..9b9ac5da7
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-hover-provider.c
@@ -0,0 +1,66 @@
+/* gbp-bash-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-bash-hover-provider"
+
+#include "config.h"
+
+#include "gbp-bash-hover-provider.h"
+#include "gbp-bash-service.h"
+
+struct _GbpBashHoverProvider
+{
+  IdeLspHoverProvider parent_instance;
+};
+
+static void
+gbp_bash_hover_provider_prepare (IdeLspHoverProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_HOVER_PROVIDER (provider));
+
+  g_object_set (provider,
+                "category", "Python",
+                "priority", 200,
+                NULL);
+
+  klass = g_type_class_ref (GBP_TYPE_BASH_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+G_DEFINE_FINAL_TYPE (GbpBashHoverProvider, gbp_bash_hover_provider, IDE_TYPE_LSP_HOVER_PROVIDER)
+
+static void
+gbp_bash_hover_provider_class_init (GbpBashHoverProviderClass *klass)
+{
+  IdeLspHoverProviderClass *lsp_hover_provider_class = IDE_LSP_HOVER_PROVIDER_CLASS (klass);
+
+  lsp_hover_provider_class->prepare = gbp_bash_hover_provider_prepare;
+}
+
+static void
+gbp_bash_hover_provider_init (GbpBashHoverProvider *self)
+{
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-hover-provider.h 
b/src/plugins/bash-language-server/gbp-bash-hover-provider.h
new file mode 100644
index 000000000..a9dbdfaa1
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-hover-provider.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_HOVER_PROVIDER (gbp_bash_hover_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashHoverProvider, gbp_bash_hover_provider, GBP, BASH_HOVER_PROVIDER, 
IdeLspHoverProvider)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/gbp-bash-rename-provider.c 
b/src/plugins/bash-language-server/gbp-bash-rename-provider.c
new file mode 100644
index 000000000..b700d16e4
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-rename-provider.c
@@ -0,0 +1,65 @@
+/* gbp-bash-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-bash-rename-provider"
+
+#include "config.h"
+
+#include "gbp-bash-rename-provider.h"
+#include "gbp-bash-service.h"
+
+struct _GbpBashRenameProvider
+{
+  IdeLspRenameProvider parent_instance;
+};
+
+static void
+gbp_bash_rename_provider_load (IdeRenameProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_RENAME_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BASH_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+rename_provider_iface_init (IdeRenameProviderInterface *iface)
+{
+  iface->load = gbp_bash_rename_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBashRenameProvider, gbp_bash_rename_provider, IDE_TYPE_LSP_RENAME_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_RENAME_PROVIDER, rename_provider_iface_init))
+
+static void
+gbp_bash_rename_provider_class_init (GbpBashRenameProviderClass *klass)
+{
+}
+
+static void
+gbp_bash_rename_provider_init (GbpBashRenameProvider *self)
+{
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-rename-provider.h 
b/src/plugins/bash-language-server/gbp-bash-rename-provider.h
new file mode 100644
index 000000000..4a3027e53
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-rename-provider.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_RENAME_PROVIDER (gbp_bash_rename_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashRenameProvider, gbp_bash_rename_provider, GBP, BASH_RENAME_PROVIDER, 
IdeLspRenameProvider)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/gbp-bash-service.c 
b/src/plugins/bash-language-server/gbp-bash-service.c
new file mode 100644
index 000000000..04ed0803c
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-service.c
@@ -0,0 +1,79 @@
+/* gbp-bash-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-bash-service"
+
+#include "config.h"
+
+#include <jsonrpc-glib.h>
+
+#include "gbp-bash-service.h"
+
+struct _GbpBashService
+{
+  IdeLspService parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpBashService, gbp_bash_service, IDE_TYPE_LSP_SERVICE)
+
+static void
+gbp_bash_service_configure_client (IdeLspService *service,
+                                   IdeLspClient  *client)
+{
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_SERVICE (service));
+  g_assert (IDE_IS_LSP_CLIENT (client));
+
+  ide_lsp_client_add_language (client, "shellscript");
+
+  IDE_EXIT;
+}
+
+static void
+gbp_bash_service_configure_launcher (IdeLspService         *service,
+                                     IdePipeline           *pipeline,
+                                     IdeSubprocessLauncher *launcher)
+{
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_SERVICE (service));
+  g_assert (IDE_IS_PIPELINE (pipeline));
+  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+
+  ide_subprocess_launcher_push_argv (launcher, "start");
+
+  IDE_EXIT;
+}
+
+static void
+gbp_bash_service_class_init (GbpBashServiceClass *klass)
+{
+  IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
+
+  lsp_service_class->configure_client = gbp_bash_service_configure_client;
+  lsp_service_class->configure_launcher = gbp_bash_service_configure_launcher;
+}
+
+static void
+gbp_bash_service_init (GbpBashService *self)
+{
+  ide_lsp_service_set_program (IDE_LSP_SERVICE (self), "bash-language-server");
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-service.h 
b/src/plugins/bash-language-server/gbp-bash-service.h
new file mode 100644
index 000000000..4cdc6fa68
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-service.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_SERVICE (gbp_bash_service_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashService, gbp_bash_service, GBP, BASH_SERVICE, IdeLspService)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/gbp-bash-symbol-resolver.c 
b/src/plugins/bash-language-server/gbp-bash-symbol-resolver.c
new file mode 100644
index 000000000..9dc68f21c
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-symbol-resolver.c
@@ -0,0 +1,65 @@
+/* gbp-bash-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-bash-symbol-resolver"
+
+#include "config.h"
+
+#include "gbp-bash-symbol-resolver.h"
+#include "gbp-bash-service.h"
+
+struct _GbpBashSymbolResolver
+{
+  IdeLspSymbolResolver parent_instance;
+};
+
+static void
+gbp_bash_symbol_provider_load (IdeSymbolResolver *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BASH_SYMBOL_RESOLVER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BASH_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+symbol_provider_iface_init (IdeSymbolResolverInterface *iface)
+{
+  iface->load = gbp_bash_symbol_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBashSymbolResolver, gbp_bash_symbol_provider, IDE_TYPE_LSP_SYMBOL_RESOLVER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_SYMBOL_RESOLVER, symbol_provider_iface_init))
+
+static void
+gbp_bash_symbol_provider_class_init (GbpBashSymbolResolverClass *klass)
+{
+}
+
+static void
+gbp_bash_symbol_provider_init (GbpBashSymbolResolver *self)
+{
+}
diff --git a/src/plugins/bash-language-server/gbp-bash-symbol-resolver.h 
b/src/plugins/bash-language-server/gbp-bash-symbol-resolver.h
new file mode 100644
index 000000000..6016d4bbf
--- /dev/null
+++ b/src/plugins/bash-language-server/gbp-bash-symbol-resolver.h
@@ -0,0 +1,31 @@
+/* gbp-bash-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_BASH_SYMBOL_RESOLVER (gbp_bash_symbol_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBashSymbolResolver, gbp_bash_symbol_provider, GBP, BASH_SYMBOL_RESOLVER, 
IdeLspSymbolResolver)
+
+G_END_DECLS
diff --git a/src/plugins/bash-language-server/meson.build b/src/plugins/bash-language-server/meson.build
new file mode 100644
index 000000000..a044dc504
--- /dev/null
+++ b/src/plugins/bash-language-server/meson.build
@@ -0,0 +1,24 @@
+if get_option('plugin_bash_language_server')
+
+plugins_sources += files([
+  'bash-language-server-plugin.c',
+  'gbp-bash-code-action-provider.c',
+  'gbp-bash-completion-provider.c',
+  'gbp-bash-diagnostic-provider.c',
+  'gbp-bash-formatter.c',
+  'gbp-bash-highlighter.c',
+  'gbp-bash-hover-provider.c',
+  'gbp-bash-rename-provider.c',
+  'gbp-bash-symbol-resolver.c',
+  'gbp-bash-service.c',
+])
+
+plugin_bash_resources = gnome.compile_resources(
+  'bash-language-server-resources',
+  'bash-language-server.gresource.xml',
+  c_name: 'gbp_bash',
+)
+
+plugins_sources += plugin_bash_resources
+
+endif
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index 7382ffbb2..36cf73803 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -36,6 +36,7 @@ endif
 
 subdir('auto-save')
 subdir('autotools')
+subdir('bash-language-server')
 #subdir('beautifier')
 subdir('blueprint')
 subdir('buildconfig')
@@ -206,6 +207,7 @@ status += [
   '',
   'Language Servers:',
   '',
+  'bash-language-server .......... (Bash) : @0@'.format(get_option('plugin_bash_language_server')),
   'blueprint ................ (Blueprint) : @0@'.format(get_option('plugin_blueprint')),
   'clangd ............... (C, C++, Obj-C) : @0@ **'.format(get_option('plugin_clangd')),
   'gnome-builder-clang .. (C, C++, Obj-C) : @0@'.format(get_option('plugin_clang')),


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