Commit 1fd1e81c authored by Nikita Rudenko's avatar Nikita Rudenko
Browse files

vimPlugins: remove redundant patches and replaceVars

Some vimPlugins patches contain replacement of bare binary names to
full nix store paths, i.e. replacing `"node"` with `"${pkgs.nodejs}/bin/node"`

This is brittle and tedious in support, since any code motion in
plugin may break such patch.
Let's replace this with a `runtimeDeps` attribute, which lives outside
of plugin code.
parent 7730a67f
Loading
Loading
Loading
Loading
+22 −33
Original line number Diff line number Diff line
@@ -193,10 +193,8 @@ assertNoAdditions {
  };

  aider-nvim = super.aider-nvim.overrideAttrs {
    patches = [
      (replaceVars ./patches/aider-nvim/bin.patch {
        aider = lib.getExe aider-chat;
      })
    runtimeDeps = [
      aider-chat
    ];
  };

@@ -243,10 +241,8 @@ assertNoAdditions {
  };

  aw-watcher-vim = super.aw-watcher-vim.overrideAttrs {
    patches = [
      (replaceVars ./patches/aw-watcher-vim/program_paths.patch {
        curl = lib.getExe curl;
      })
    runtimeDeps = [
      curl
    ];
  };

@@ -1392,10 +1388,8 @@ assertNoAdditions {
  };

  gx-nvim = super.gx-nvim.overrideAttrs {
    patches = lib.optionals stdenv.hostPlatform.isLinux [
      (replaceVars ./patches/gx-nvim/fix-paths.patch {
        inherit xdg-utils;
      })
    runtimeDeps = [
      xdg-utils
    ];

    nvimRequireCheck = "gx";
@@ -1932,10 +1926,8 @@ assertNoAdditions {
      };
    in
    super.markdown-preview-nvim.overrideAttrs {
      patches = [
        (replaceVars ./patches/markdown-preview-nvim/fix-node-paths.patch {
          node = "${nodejs}/bin/node";
        })
      runtimeDeps = [
        nodejs
      ];
      postInstall = ''
        cp -r ${nodeDep} $out/app/node_modules
@@ -2975,6 +2967,10 @@ assertNoAdditions {
  # The plugin depends on either skim-vim or fzf-vim, but we don't want to force the user so we
  # avoid choosing one of them and leave it to the user
  openscad-nvim = super.openscad-nvim.overrideAttrs {
    runtimeDeps = [
      openscad
    ];

    buildInputs = [
      zathura
      openscad
@@ -2986,11 +2982,6 @@ assertNoAdditions {
      "openscad.snippets.openscad"
      "openscad.utilities"
    ];
    patches = [
      (replaceVars ./patches/openscad.nvim/program_paths.patch {
        openscad = lib.getExe openscad;
      })
    ];
  };

  org-notebook-nvim = super.org-notebook-nvim.overrideAttrs {
@@ -3075,12 +3066,14 @@ assertNoAdditions {
  };

  peek-nvim = super.peek-nvim.overrideAttrs (old: {
    runtimeDeps = [
      deno
    ];

    patches = [
      # Patch peek-nvim to run using nixpkgs deno
      # This means end-users have to build peek-nvim the first time they use it...
      (replaceVars ./patches/peek-nvim/cmd.patch {
        deno = lib.getExe deno;
      })
      ./patches/peek-nvim/cmd.patch
    ];
  });

@@ -3125,10 +3118,8 @@ assertNoAdditions {
  };

  Preview-nvim = super.Preview-nvim.overrideAttrs {
    patches = [
      (replaceVars ./patches/preview-nvim/hardcode-mdt-binary-path.patch {
        mdt = lib.getExe md-tui;
      })
    runtimeDeps = [
      md-tui
    ];
  };

@@ -3195,11 +3186,9 @@ assertNoAdditions {
  };

  ranger-nvim = super.ranger-nvim.overrideAttrs {
    patches = [ ./patches/ranger.nvim/fix-paths.patch ];

    postPatch = ''
      substituteInPlace lua/ranger-nvim.lua --replace-fail '@ranger@' ${ranger}/bin/ranger
    '';
    runtimeDeps = [
      ranger
    ];
  };

  refactoring-nvim = super.refactoring-nvim.overrideAttrs {
+0 −15
Original line number Diff line number Diff line
diff --git a/lua/aider.lua b/lua/aider.lua
index 98b5071..589b06d 100644
--- a/lua/aider.lua
+++ b/lua/aider.lua
@@ -61,9 +61,9 @@ function M.AiderOpen(args, window_type)
     log("Existing aider buffer found, opening in new window")
     helpers.open_buffer_in_new_window(window_type, M.aider_buf)
   else
     log("No existing aider buffer, creating new one")
-    local command = "aider " .. (args or "")
+    local command = "@aider@ " .. (args or "")
     log("Opening window with type: " .. window_type)
     helpers.open_window(window_type)
     log("Adding buffers to command")
     command = helpers.add_buffers_to_command(command, is_valid_buffer)
+0 −13
Original line number Diff line number Diff line
diff --git a/plugin/activitywatch.vim b/plugin/activitywatch.vim
index 6986553..7462b02 100644
--- a/plugin/activitywatch.vim
+++ b/plugin/activitywatch.vim
@@ -29,7 +29,7 @@ let s:heartbeat_apiurl = printf('%s/heartbeat?pulsetime=30', s:bucket_apiurl)
 let s:http_response_code = {}
 
 function! HTTPPostJson(url, data)
-    let l:req = ['curl', '-s', a:url,
+    let l:req = ['@curl@', '-s', a:url,
         \ '-H', 'Content-Type: application/json',
         \ '-X', 'POST',
         \ '-d', json_encode(a:data),
+0 −13
Original line number Diff line number Diff line
diff --git a/lua/gx/init.lua b/lua/gx/init.lua
index 12272d4..c51771a 100644
--- a/lua/gx/init.lua
+++ b/lua/gx/init.lua
@@ -73,7 +73,7 @@ local function get_open_browser_app()
   if sysname == "Darwin" then
     app = "open"
   elseif sysname == "Linux" then
-    app = "xdg-open"
+    app = "@xdg-utils@/bin/xdg-open"
   elseif sysname == "Windows_NT" then
     app = "powershell.exe"
   end
+0 −31
Original line number Diff line number Diff line
diff --git a/autoload/health/mkdp.vim b/autoload/health/mkdp.vim
index 323b57b..8053ea8 100644
--- a/autoload/health/mkdp.vim
+++ b/autoload/health/mkdp.vim
@@ -8,8 +8,8 @@ function! health#mkdp#check() abort
     lua vim.health.info('Pre build: ' .. vim.api.nvim_eval('l:mkdp_server_script'))
     lua vim.health.info('Pre build version: ' .. vim.fn['mkdp#util#pre_build_version']())
     lua vim.health.ok('Using pre build')
-  elseif executable('node')
-    lua vim.health.info('Node version: ' .. string.gsub(vim.fn.system('node --version'), '^%s*(.-)%s*$', '%1'))
+  else
+    lua vim.health.info('Node version: ' .. string.gsub(vim.fn.system('@node@ --version'), '^%s*(.-)%s*$', '%1'))
     let l:mkdp_server_script = s:mkdp_root_dir .. '/app/server.js'
     lua vim.health.info('Script: ' .. vim.api.nvim_eval('l:mkdp_server_script'))
     lua vim.health.info('Script exists: ' .. vim.fn.filereadable(vim.api.nvim_eval('l:mkdp_server_script')))
diff --git a/autoload/mkdp/rpc.vim b/autoload/mkdp/rpc.vim
index b257571..57f04e7 100644
--- a/autoload/mkdp/rpc.vim
+++ b/autoload/mkdp/rpc.vim
@@ -41,9 +41,9 @@ function! mkdp#rpc#start_server() abort
   let l:mkdp_server_script = s:mkdp_root_dir . '/app/bin/markdown-preview-' . mkdp#util#get_platform()
   if executable(l:mkdp_server_script)
     let l:cmd = [l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js']
-  elseif executable('node')
+  else
     let l:mkdp_server_script = s:mkdp_root_dir . '/app/index.js'
-    let l:cmd = ['node', l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js']
+    let l:cmd = ['@node@', l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js']
   endif
   if exists('l:cmd')
     if s:is_vim
Loading