gnu: vim: Automatically find vim plugins.
authorEfraim Flashner <efraim@flashner.co.il>
Fri, 18 Sep 2020 15:25:06 +0000 (18:25 +0300)
committerEfraim Flashner <efraim@flashner.co.il>
Sun, 20 Dec 2020 10:52:51 +0000 (12:52 +0200)
* gnu/packages/vim.scm (vim)[arguments]: Add new 'install-guix.vim phase
to install vendor specific vimrc.
* gnu/packages/aux-files/guix.vim: New file.
* Makefile.am (AUX_FILES): Register it.

Makefile.am
gnu/packages/aux-files/guix.vim [new file with mode: 0644]
gnu/packages/vim.scm

index 1b1360f..e0ee65f 100644 (file)
@@ -356,6 +356,7 @@ dist_noinst_DATA =                          \
 AUX_FILES =                                            \
   gnu/packages/aux-files/chromium/master-preferences.json              \
   gnu/packages/aux-files/emacs/guix-emacs.el           \
+  gnu/packages/aux-files/guix.vim                      \
   gnu/packages/aux-files/linux-libre/5.10-arm.conf     \
   gnu/packages/aux-files/linux-libre/5.10-arm64.conf   \
   gnu/packages/aux-files/linux-libre/5.10-i686.conf    \
diff --git a/gnu/packages/aux-files/guix.vim b/gnu/packages/aux-files/guix.vim
new file mode 100644 (file)
index 0000000..7dc359e
--- /dev/null
@@ -0,0 +1,7 @@
+" This appends all of the vim plugins to the end of Vim's runtimepath.
+for directory in ["/run/current-system/profile", $HOME . "/.guix-profile", $GUIX_PROFILE, $GUIX_ENVIRONMENT]
+    let vimplugins = directory . "/share/vim/vimfiles"
+    if isdirectory(vimplugins)
+        let &rtp = join([&rtp,vimplugins], ',')
+    endif
+endfor
index 81d5ab0..32a668a 100644 (file)
                  ;; Blindly fix some other differences based on error output.
                  (("^\\|!") "|<")
                  (("@37") "")))
-             #t)))))
+             #t))
+         (add-after 'install 'install-guix.vim
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((vimdir (string-append (assoc-ref outputs "out") "/share/vim")))
+               (mkdir-p vimdir)
+               (copy-file (assoc-ref inputs "guix.vim")
+                          (string-append vimdir "/vimrc"))
+               #t))))))
     (inputs
      `(("gawk" ,gawk)
        ("ncurses" ,ncurses)
        ("tcsh" ,tcsh)))                 ; For runtime/tools/vim32
     (native-inputs
      `(("libtool" ,libtool)
+       ("guix.vim" ,(search-auxiliary-file "guix.vim"))
 
        ;; For tests.
        ("tzdata" ,tzdata-for-tests)))