Subject: [bug#54221] [PATCH v2 2/2] gnu: neovim: Search and use installed plugins, like vim.

From: SeerLite <[email-masked]>
Date: Thu, 12 May 2022 22:17:27 -0400

* gnu/packages/vim.scm (neovim)[phases]{install-guix.vim}: New phase.
[native-search-paths]: Add search path specification for 'GUIX_VIMRUNTIME'.
---
 gnu/packages/vim.scm | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/vim.scm b/gnu/packages/vim.scm
index 0c8e689b5a..530303a318 100644
--- a/gnu/packages/vim.scm
+++ b/gnu/packages/vim.scm
@@ -717,7 +717,18 @@ (define-public neovim
              ;; doubles its size.  We remove the refirence here.
              (substitute* "cmake/GetCompileFlags.cmake"
                (("\\$\\{CMAKE_C_COMPILER\\}") "/gnu/store/.../bin/gcc"))
-             #t)))))
+             #t))
+         (add-after 'install 'install-guix.vim
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((nvimdir (string-append (assoc-ref outputs "out") "/share/nvim")))
+               (mkdir-p nvimdir)
+               (copy-file (assoc-ref inputs "guix.vim")
+                          (string-append nvimdir "/sysinit.vim"))))))))
+    (native-search-paths
+      (list (search-path-specification
+             (variable "GUIX_VIMRUNTIME")
+             (separator ",")
+             (files (list "share/vim/vimfiles")))))
     (inputs
      `(("libuv" ,libuv)
        ("msgpack" ,msgpack)
@@ -739,7 +750,8 @@ (define-public neovim
     (native-inputs
      `(("pkg-config" ,pkg-config)
        ("gettext" ,gettext-minimal)
-       ("gperf" ,gperf)))
+       ("gperf" ,gperf)
+       ("guix.vim" ,(search-auxiliary-file "guix.vim"))))
     (home-page "https://neovim.io")
     (synopsis "Fork of vim focused on extensibility and agility")
     (description "Neovim is a project that seeks to aggressively
-- 
2.36.0