diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 15070169..c1a75791 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -35,7 +35,7 @@ jobs: uses: rhysd/action-setup-vim@v1 with: neovim: true - version: nightly + version: stable - name: Install rocks.nvim run: | mkdir rocks @@ -54,7 +54,7 @@ jobs: cat rocks/rocks.log echo "vim.cmd.colorscheme('sweetie')" >> .github/resources/init-integration.lua echo "vim.cmd.e('success')" >> .github/resources/init-integration.lua - nvim -u .github/resources/init-integration.lua -c +wq + nvim -u .github/resources/init-integration.lua -c +wq || true if [ ! -f success ]; then echo "Integration test failed!" exit 1 diff --git a/doc/rocks.txt b/doc/rocks.txt index 507097b7..c7e5e352 100644 --- a/doc/rocks.txt +++ b/doc/rocks.txt @@ -98,31 +98,29 @@ RocksOpts *RocksOpts* Fields: ~ {rocks_path?} (string) - Local path in your file system to install rocks - (Default: a `rocks` directory in `vim.fn.stdpath("data")`). + Local path in your file system to install rocks + (Default: a `rocks` directory in `vim.fn.stdpath("data")`). {config_path?} (string) - Rocks declaration file path (Default: `rocks.toml`) in `vim.fn.stdpath("config")`. + Rocks declaration file path (Default: `rocks.toml`) in `vim.fn.stdpath("config")`. {luarocks_binary?} (string) - Luarocks binary path (Default: `{rocks_path}/bin/luarocks`). + Luarocks binary path (Default: `{rocks_path}/bin/luarocks`). {lazy?} (boolean) - Whether to query luarocks.org lazily (Default: `false`). - Setting this to `true` may improve startup time, - but features like auto-completion will lag initially. + Whether to query luarocks.org lazily (Default: `false`). + Setting this to `true` may improve startup time, + but features like auto-completion will lag initially. {dynamic_rtp?} (boolean) - Whether to automatically add freshly installed plugins to the 'runtimepath'. - (Default: `true` for the best default experience). + Whether to automatically add freshly installed plugins to the 'runtimepath'. + (Default: `true` for the best default experience). {generate_help_pages?} (boolean) - Whether to re-generate plugins help pages after installation/upgrade. (Default: `true`). + Whether to re-generate plugins help pages after installation/upgrade. (Default: `true`). {reinstall_dev_rocks_on_update?} (boolean) - Whether to reinstall 'dev' rocks on update - (Default: `true`, as rocks.nvim cannot determine if 'dev' rocks are up to date). + Whether to reinstall 'dev' rocks on update + (Default: `true`, as rocks.nvim cannot determine if 'dev' rocks are up to date). {enable_luarocks_loader?} (boolean) - Whether to use the luarocks loader to support multiple dependencies (Default: `true`). - {luarocks_config?} (string|table) - Path to the luarocks config file or table of extra luarocks config options. - If a table or not set, rocks.nvim will create a default luarocks config in `rocks_path` - and merge it with this table. - Warning: this is a file path, You should include the settings in the default luarocks-config.lua before overriding this. + Whether to use the luarocks loader to support multiple dependencies (Default: `true`). + {luarocks_config?} (table) + Extra luarocks config options. + rocks.nvim will create a default luarocks config in `rocks_path` and merge it with this table (if set). ============================================================================== diff --git a/flake.nix b/flake.nix index 4ac2a8f7..15605c6c 100644 --- a/flake.nix +++ b/flake.nix @@ -72,7 +72,6 @@ inherit nvim; plugins = with pkgs.lua51Packages; [ toml-edit - toml fidget-nvim fzy nvim-nio diff --git a/lua/rocks/config/init.lua b/lua/rocks/config/init.lua index 7d9764b2..15f7ccaa 100644 --- a/lua/rocks/config/init.lua +++ b/lua/rocks/config/init.lua @@ -46,11 +46,9 @@ local config = {} --- Whether to use the luarocks loader to support multiple dependencies (Default: `true`). ---@field enable_luarocks_loader? boolean --- ---- Path to the luarocks config file or table of extra luarocks config options. ---- If a table or not set, rocks.nvim will create a default luarocks config in `rocks_path` ---- and merge it with this table. ---- Warning: this is a file path, You should include the settings in the default luarocks-config.lua before overriding this. ----@field luarocks_config? string | table +--- Extra luarocks config options. +--- rocks.nvim will create a default luarocks config in `rocks_path` and merge it with this table (if set). +---@field luarocks_config? table ---@type RocksOpts | fun():RocksOpts vim.g.rocks_nvim = vim.g.rocks_nvim diff --git a/lua/rocks/config/internal.lua b/lua/rocks/config/internal.lua index aa71ae16..f1bf8180 100644 --- a/lua/rocks/config/internal.lua +++ b/lua/rocks/config/internal.lua @@ -117,7 +117,7 @@ local default_config = { vim.tbl_deep_extend("force", vim.empty_dict(), rocks_toml.rocks or {}, rocks_toml.plugins or {}) return config.apply_rock_spec_modifiers(user_rocks) end, - ---@type fun():string + ---@type async fun():string luarocks_config_path = nil, } @@ -154,6 +154,12 @@ if #config.debug_info.unrecognized_configs > 0 then end if type(opts.luarocks_config) == "string" then + vim.deprecate( + "g:rocks_nvim.luarocks_config (string)", + "g:rocks_nvim.luarocks_config (table)", + "3.0.0", + "rocks.nvim" + ) -- luarocks_config override if vim.uv.fs_stat(opts.luarocks_config) then local luarocks_config_path = ("%s"):format(opts.luarocks_config) @@ -168,11 +174,13 @@ if type(opts.luarocks_config) == "string" then end if not opts.luarocks_config or type(opts.luarocks_config) == "table" then local nio = require("nio") - local semaphore = nio.control.semaphore(1) + local luarocks_config_path ---@diagnostic disable-next-line: inject-field config.luarocks_config_path = nio.create(function() - semaphore.acquire() - local luarocks_config_path = vim.fs.joinpath(config.rocks_path, "luarocks-config.lua") + if luarocks_config_path then + return luarocks_config_path + end + luarocks_config_path = vim.fs.joinpath(config.rocks_path, "luarocks-config.lua") local default_luarocks_config = { lua_version = "5.1", rocks_trees = { @@ -194,8 +202,9 @@ if not opts.luarocks_config or type(opts.luarocks_config) == "table" then fs.write_file_await(luarocks_config_path, "w+", config_str) - semaphore.release() - + vim.schedule(function() + require("rocks.log").debug("Using luarocks config " .. config_str) + end) ---@diagnostic disable-next-line: inject-field return ("%s"):format(luarocks_config_path) end) diff --git a/lua/rocks/loader.lua b/lua/rocks/loader.lua index eaa313d6..0deff1f2 100644 --- a/lua/rocks/loader.lua +++ b/lua/rocks/loader.lua @@ -27,13 +27,13 @@ end ---@type async fun():boolean loader.enable = nio.create(function() - log.trace("Enabling luarocks loader") local luarocks_config_path = config.luarocks_config_path() local luarocks_lua_dir = config.luarocks_binary == config.default_luarocks_binary and vim.fs.joinpath(config.rocks_path, "share", "lua") or get_luarocks_lua_dir_from_luarocks() local future = nio.control.future() vim.schedule(function() + log.trace("Enabling luarocks loader") if luarocks_lua_dir then package.path = package.path .. ";" diff --git a/nix/test-overlay.nix b/nix/test-overlay.nix index 206a00cd..afa7222f 100644 --- a/nix/test-overlay.nix +++ b/nix/test-overlay.nix @@ -13,7 +13,6 @@ with ps; [ final.lua51Packages.luarocks-rock toml-edit - toml fidget-nvim fzy nvim-nio diff --git a/plugin/rocks.lua b/plugin/rocks.lua index a6378505..8d2c4f34 100644 --- a/plugin/rocks.lua +++ b/plugin/rocks.lua @@ -24,11 +24,12 @@ log.trace("loading rocks.adapter") local adapter = require("rocks.adapter") log.trace("loading rocks config") local config = require("rocks.config.internal") -log.debug("Using luarocks config " .. config.luarocks_config) -- Initialize the luarocks loader if config.enable_luarocks_loader then - nio.run(require("rocks.loader").enable) + nio.run(function() + require("rocks.loader").enable() + end) end -- Set up the Rocks user command