echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.54k stars 175 forks source link

run make to build plugin dependecies #866

Closed bluebrown closed 2 months ago

bluebrown commented 2 months ago

Contributing guidelines

Module(s)

mini.deps

Description

I want to install luasnip https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#install.

This requires to run make after pulling the plugin make install_jsregexp.

Neovim version

NVIM v0.10.0-dev-3050+gcb24a3907

Steps to reproduce

I am trying something like this:

later(function()
  local build = function(path) vim.system({ "make", "-C", path, "install_jsregexp" }) end
  add({
    source = "L3MON4D3/LuaSnip",
    hooks = {
      post_install = function(path)
        later(function() build(path) end)
      end,
      post_checkout = build,
    },
  })
  local luasnip = require("luasnip")
  require("luasnip").config.setup({})
end)

Expected behavior

jsregexp is available to luasnip after starting vim

Actual behavior

But :checkhealth is reporting

luasnip ~
- WARNING             For Variable/Placeholder-transformations, luasnip requires
              the jsregexp library. See `:help |luasnip-lsp-snippets-transformations`| for advice

There are no other messages while starting vim or reinstalling plugins. And nothing in :DepsShowLog.

bluebrown commented 2 months ago

I managed to get more info:

  local build = function(path)
    local obj = vim.system({ "make", "-C", path, "install_jsregexp" }, { text = true }):wait()
    vim.print(vim.inspect(obj))
  end

It says: stderr = "make: option requires an argument -- 'C', meaning the path is not passed.

Reading this again: https://github.com/echasnovski/mini.nvim/blob/5df3155218807fb6049779bb488f48f77fdd9dcb/lua/mini/deps.lua#L282

It says its a table.

So doing it like this works:

later(function()
  local build = function(args)
    local obj = vim.system({ "make", "-C", args.path, "install_jsregexp" }, { text = true }):wait()
    vim.print(vim.inspect(obj))
  end
  add({
    source = "L3MON4D3/LuaSnip",
    hooks = {
      post_install = function(args)
        later(function() build(args) end)
      end,
      post_checkout = build,
    },
  })
  local luasnip = require("luasnip")
  require("luasnip").config.setup({})
end)