diff mbox series

[bug#43539] gnu: vim: Automatically find vim plugins.

Message ID 20200920191523.6871-1-efraim@flashner.co.il
State Superseded
Headers show
Series [bug#43539] gnu: vim: Automatically find vim plugins. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Efraim Flashner Sept. 20, 2020, 7:15 p.m. UTC
* 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                     |  1 +
 gnu/packages/aux-files/guix.vim |  7 +++++++
 gnu/packages/vim.scm            | 10 +++++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/aux-files/guix.vim

Comments

Ricardo Wurmus Sept. 20, 2020, 7:29 p.m. UTC | #1
Efraim Flashner <efraim@flashner.co.il> writes:

> diff --git a/gnu/packages/aux-files/guix.vim b/gnu/packages/aux-files/guix.vim
> new file mode 100644
> index 0000000000..ca97f451d8
> --- /dev/null
> +++ b/gnu/packages/aux-files/guix.vim
> @@ -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_ENVIRONMENT]

How about using $GUIX_PROFILE as well or instead of $HOME/.guix-profile?
This would allow users to keep a separate profile for Vim things.
Efraim Flashner Sept. 20, 2020, 7:32 p.m. UTC | #2
On Sun, Sep 20, 2020 at 09:29:27PM +0200, Ricardo Wurmus wrote:
> 
> Efraim Flashner <efraim@flashner.co.il> writes:
> 
> > diff --git a/gnu/packages/aux-files/guix.vim b/gnu/packages/aux-files/guix.vim
> > new file mode 100644
> > index 0000000000..ca97f451d8
> > --- /dev/null
> > +++ b/gnu/packages/aux-files/guix.vim
> > @@ -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_ENVIRONMENT]
> 
> How about using $GUIX_PROFILE as well or instead of $HOME/.guix-profile?
> This would allow users to keep a separate profile for Vim things.

That was the one part I didn't really like about my patch. Unfortunately
I don't seem to have $GUIX_PROFILE set on my machine.

(ins)efraim@E5400 ~$ echo $GUIX_PROFILE

(ins)efraim@E5400 ~$
Ricardo Wurmus Sept. 20, 2020, 7:50 p.m. UTC | #3
Efraim Flashner <efraim@flashner.co.il> writes:

> On Sun, Sep 20, 2020 at 09:29:27PM +0200, Ricardo Wurmus wrote:
>> 
>> Efraim Flashner <efraim@flashner.co.il> writes:
>> 
>> > diff --git a/gnu/packages/aux-files/guix.vim b/gnu/packages/aux-files/guix.vim
>> > new file mode 100644
>> > index 0000000000..ca97f451d8
>> > --- /dev/null
>> > +++ b/gnu/packages/aux-files/guix.vim
>> > @@ -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_ENVIRONMENT]
>> 
>> How about using $GUIX_PROFILE as well or instead of $HOME/.guix-profile?
>> This would allow users to keep a separate profile for Vim things.
>
> That was the one part I didn't really like about my patch. Unfortunately
> I don't seem to have $GUIX_PROFILE set on my machine.
>
> (ins)efraim@E5400 ~$ echo $GUIX_PROFILE
>
> (ins)efraim@E5400 ~$

Me neither!  But when loading profiles we suggest this approach:

   export GUIX_PROFILE=/the/location/of/the/.guix-profile
   source $GUIX_PROFILE/etc/profile

The variable is set in that case, because that affects whether absolute
store file names are used or the symlink
“/the/location/of/the/.guix-profile”.
Efraim Flashner Sept. 20, 2020, 8:57 p.m. UTC | #4
On Sun, Sep 20, 2020 at 09:50:12PM +0200, Ricardo Wurmus wrote:
> 
> Efraim Flashner <efraim@flashner.co.il> writes:
> 
> > On Sun, Sep 20, 2020 at 09:29:27PM +0200, Ricardo Wurmus wrote:
> >> 
> >> Efraim Flashner <efraim@flashner.co.il> writes:
> >> 
> >> > diff --git a/gnu/packages/aux-files/guix.vim b/gnu/packages/aux-files/guix.vim
> >> > new file mode 100644
> >> > index 0000000000..ca97f451d8
> >> > --- /dev/null
> >> > +++ b/gnu/packages/aux-files/guix.vim
> >> > @@ -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_ENVIRONMENT]
> >> 
> >> How about using $GUIX_PROFILE as well or instead of $HOME/.guix-profile?
> >> This would allow users to keep a separate profile for Vim things.
> >
> > That was the one part I didn't really like about my patch. Unfortunately
> > I don't seem to have $GUIX_PROFILE set on my machine.
> >
> > (ins)efraim@E5400 ~$ echo $GUIX_PROFILE
> >
> > (ins)efraim@E5400 ~$
> 
> Me neither!  But when loading profiles we suggest this approach:
> 
>    export GUIX_PROFILE=/the/location/of/the/.guix-profile
>    source $GUIX_PROFILE/etc/profile
> 
> The variable is set in that case, because that affects whether absolute
> store file names are used or the symlink
> “/the/location/of/the/.guix-profile”.

It seems to be the case for the default profile. And in Guix System. I
could also just add $GUIX_PROFILE as another location in the list of
directories to search.
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 8e91e1e558..d0867ecd22 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -332,6 +332,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.8-arm.conf       \
   gnu/packages/aux-files/linux-libre/5.8-arm64.conf     \
   gnu/packages/aux-files/linux-libre/5.8-i686.conf      \
diff --git a/gnu/packages/aux-files/guix.vim b/gnu/packages/aux-files/guix.vim
new file mode 100644
index 0000000000..ca97f451d8
--- /dev/null
+++ b/gnu/packages/aux-files/guix.vim
@@ -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_ENVIRONMENT]
+    let testpath = directory . "/share/vim/vimfiles"
+    if isdirectory(testpath)
+        let &rtp = join([&rtp,testpath], ',')
+    endif
+endfor
diff --git a/gnu/packages/vim.scm b/gnu/packages/vim.scm
index c6b1092e71..dba5b5a38e 100644
--- a/gnu/packages/vim.scm
+++ b/gnu/packages/vim.scm
@@ -136,7 +136,14 @@ 
              (substitute* "src/testdir/test_popupwin.vim"
                ((".*Test_popup_drag_termwin.*" line)
                 (string-append line "return\n")))
-             #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)
@@ -144,6 +151,7 @@ 
        ("tcsh" ,tcsh)))                 ; For runtime/tools/vim32
     (native-inputs
      `(("libtool" ,libtool)
+       ("guix.vim" ,(search-auxiliary-file "guix.vim"))
 
        ;; For tests.
        ("tzdata" ,tzdata-for-tests)))