about summary refs log tree commit diff
path: root/pkgs/misc/vim-plugins
diff options
context:
space:
mode:
author*Kim Zick (rummik) <k@9k1.us>2019-11-16 18:56:46 -0500
committer*Kim Zick (rummik) <k@9k1.us>2020-03-19 17:22:52 -0400
commit6de54148ef4c3bb2c32039083a12e2faa42b53c0 (patch)
treef532a51d55582b1957869c0fcddf48befda2217b /pkgs/misc/vim-plugins
parenta402fa81b1e48e587a20e4dc9d7c95a287912e5d (diff)
downloadnixlib-6de54148ef4c3bb2c32039083a12e2faa42b53c0.tar
nixlib-6de54148ef4c3bb2c32039083a12e2faa42b53c0.tar.gz
nixlib-6de54148ef4c3bb2c32039083a12e2faa42b53c0.tar.bz2
nixlib-6de54148ef4c3bb2c32039083a12e2faa42b53c0.tar.lz
nixlib-6de54148ef4c3bb2c32039083a12e2faa42b53c0.tar.xz
nixlib-6de54148ef4c3bb2c32039083a12e2faa42b53c0.tar.zst
nixlib-6de54148ef4c3bb2c32039083a12e2faa42b53c0.zip
vim-utils: Fix converting vam.pluginDictionaries to VimL
Diffstat (limited to 'pkgs/misc/vim-plugins')
-rw-r--r--pkgs/misc/vim-plugins/vim-utils.nix19
1 files changed, 10 insertions, 9 deletions
diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix
index d1b1bc846ebd..a19a09d23e0d 100644
--- a/pkgs/misc/vim-plugins/vim-utils.nix
+++ b/pkgs/misc/vim-plugins/vim-utils.nix
@@ -249,13 +249,14 @@ let
         # plugins with dependencies
         plugins = findDependenciesRecursively specifiedPlugins;
 
-        # Vim almost reads JSON, so eventually JSON support should be added to Nix
-        # TODO: proper quoting
-        toNix = x:
-          if (builtins.isString x) then "'${x}'"
-          else if builtins.isAttrs x && builtins ? out then toNix x # a derivation
-          else if builtins.isAttrs x then "{${lib.concatStringsSep ", " (lib.mapAttrsToList (n: v: "${toNix n}: ${toNix v}") x)}}"
-          else if builtins.isList x then "[${lib.concatMapStringsSep ", " toNix x}]"
+        # Convert scalars, lists, and attrs, to VimL equivalents
+        toVimL = x:
+          if builtins.isString x then "'${lib.replaceStrings [ "\n" "'" ] [ "\n\\ " "''" ] x}'"
+          else if builtins.isAttrs x && builtins ? out then toVimL x # a derivation
+          else if builtins.isAttrs x then "{${lib.concatStringsSep ", " (lib.mapAttrsToList (n: v: "${toVimL n}: ${toVimL v}") x)}}"
+          else if builtins.isList x then "[${lib.concatMapStringsSep ", " toVimL x}]"
+          else if builtins.isInt x || builtins.isFloat x then builtins.toString x
+          else if builtins.isBool x then (if x then "1" else "0")
           else throw "turning ${lib.generators.toPretty {} x} into a VimL thing not implemented yet";
 
       in assert builtins.hasAttr "vim-addon-manager" knownPlugins;
@@ -290,9 +291,9 @@ let
           endif
         endif
 
-        " tell vam about which plugins to load when:
+        " tell vam which plugins to load, and when:
         let l = []
-        ${lib.concatMapStrings (p: "call add(l, {'name': '${p.pname}'})\n") plugins}
+        ${lib.concatMapStrings (p: "call add(l, ${toVimL p})\n") vam.pluginDictionaries}
         call vam#Scripts(l, {})
       '');