Subject: [bug#60286] [PATCHES] Add guile's implementation for scheme-lsp-server

From: "Ricardo G. Herdt" <[email-masked]>
Date: Wed, 21 Jun 2023 19:27:32 +0000

* gnu/packages/guile-xyz.scm: add guile-lsp-server;
   (guile-scheme-json-rpc): update to 0.4.0, change dependencies

Original package author Giacomo Leidi. Adapted to use 
guile-scheme-json-rpc.
---
  gnu/packages/guile-xyz.scm | 97 +++++++++++++++++++++++++++++++++++---
  1 file changed, 91 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index db7be432cc..1195e0e328 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -1054,9 +1054,9 @@ (define-public guile2.2-sjson
      (inputs (list guile-2.2))))

  (define-public guile-scheme-json-rpc
-  (let ((commit "45ae6890f6619286f5679f88c094c88127b54c4a")
+  (let ((commit "50acef7b824e2d23140e48242020f5fdc85cc67d")
          (revision "0")
-        (version "0.2.11"))
+        (version "0.4.0"))
      (package
        (name "guile-scheme-json-rpc")
        (version (git-version version revision commit))
@@ -1068,16 +1068,20 @@ (define-public guile-scheme-json-rpc
                  (file-name (git-file-name name version))
                  (sha256
                   (base32
-                  
"0w4m8xx8yyj0rv0q57mjr8ja87l7yikscj33i3ck26wg7230ppa5"))))
+                  
"0jsampz2ahs18z6yh9b5l3lkj8ycnavs0vg9sjngdj3w3zvrdcvm"))))
        (build-system gnu-build-system)
        (arguments
         `(#:phases (modify-phases %standard-phases
                      (add-after 'unpack 'change-to-guile-dir
                        (lambda _
                          (chdir "guile"))))))
-      (inputs (list guile-3.0 guile-json-3))
-      (native-inputs (list pkg-config))
-      (synopsis "Library providing JSON-RPC capability in Scheme")
+      (inputs (list guile-3.0 guile-srfi-145 guile-srfi-180))
+      (native-inputs (list autoconf
+                           automake
+                           pkg-config
+                           texinfo
+                           guile-3.0))
+      (synopsis "Library providing JSON-RPC capability for Guile 
Scheme")
        (description
         "This library implements parts of the
  @uref{https://www.jsonrpc.org/specification,JSON-RPC specification}, 
allowing
@@ -1085,6 +1089,87 @@ (define-public guile-scheme-json-rpc
        (home-page "https://codeberg.org/rgherdt/scheme-json-rpc/")
        (license license:expat))))

+(define-public guile-lsp-server
+  (package
+    (name "guile-lsp-server")
+    (version "0.4.0")
+    (source
+     (origin
+      (method git-fetch)
+      (uri (git-reference
+            (url "https://codeberg.org/rgherdt/scheme-lsp-server.git")
+            (commit version)))
+      (file-name (git-file-name name version))
+      (sha256
+       (base32
+        "04fc76pnl8mrwrjw49xhzs4r0dx2vh4gy2y151p33hahylf5z1xs"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:modules `((ice-9 match)
+                       (ice-9 ftw)
+                       ,@%gnu-build-system-modules)
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'move-to-guile-directory
+                 (lambda _
+                   (chdir "./guile")))
+               (add-after 'install 'wrap-entrypoint
+                 (lambda _
+                   (let* ((bin (string-append #$output "/bin"))
+                          (site (string-append #$output
+                                               "/share/guile/site"))
+                          (deps (list #$guile-scheme-json-rpc)))
+                     (match (scandir site)
+                       (("." ".." version)
+                        (let ((modules (string-append site "/"
+                                                      version))
+                              (compiled-modules (string-append #$output
+                                                 "/lib/guile/"
+                                                 version
+                                                 "/site-ccache")))
+                          (wrap-program (string-append bin
+                                         "/guile-lsp-server")
+                                        `("GUILE_LOAD_PATH" ":"
+                                          prefix
+                                          (,modules
+                                           ,@(map (lambda (dep)
+                                                    (string-append
+                                                     dep
+                                                     
"/share/guile/site/"
+                                                     version))
+                                                  deps)))
+                                        `("GUILE_LOAD_COMPILED_PATH"
+                                          ":" prefix
+                                          (,compiled-modules
+                                           ,@(map (lambda (dep)
+                                                    (string-append
+                                                     dep
+                                                     "/lib/guile/"
+                                                     version
+                                                     "/site-ccache"))
+                                              deps))))
+                          #t)))))))))
+    (native-inputs (list pkg-config))
+    (inputs
+     ;; Depend on the latest Guile to avoid bytecode compatibility 
issues when
+     ;; using modules built against the latest version.
+     (list bash-minimal
+           guile-3.0-latest))
+    (propagated-inputs (list guile-irregex
+                             guile-scheme-json-rpc
+                             guile-srfi-145
+                             guile-srfi-180))
+    (synopsis "LSP (Language Server Protocol) server for Scheme")
+    (description
+     "@code{guile-lsp-server} is an implementation for Guile of the LSP
+specification.  This software aims to support several Scheme 
implementations.
+To achieve this, the code is designed to contain as much logic as 
possible in
+R7RS Scheme, separating implementation-specific code in different 
modules.
+
+This package delivers Guile's implementation for 
@code{scheme-lsp-server}.")
+    (home-page "https://codeberg.org/rgherdt/scheme-lsp-server")
+    (license license:expat)))
+
  (define-public guile-squee
    (let ((commit "fab9d9590792f3ededd4abd8cfa6be5e56659678")
          (revision "4"))

base-commit: 392f9db97687bfb6195e65a28e1710f22b6cb972
-- 
2.40.1