diff --git a/doc/crates.txt b/doc/crates.txt index b2fb720..d97510f 100644 --- a/doc/crates.txt +++ b/doc/crates.txt @@ -88,7 +88,6 @@ For more information about individual config options see |crates-config|. notification_title = "crates.nvim", curl_args = { "-sL", "--retry", "1" }, max_parallel_requests = 80, - open_programs = { "xdg-open", "open" }, expand_crate_moves_cursor = true, enable_update_available_warning = true, on_attach = function(bufnr) end, @@ -624,12 +623,6 @@ max_parallel_requests *crates-config-max_parallel_requests* Maximum number of parallel requests. -open_programs *crates-config-open_programs* - Type: `string[]`, Default: `{ "xdg-open", "open" }` - - A list of programs that used to open urls. - - expand_crate_moves_cursor *crates-config-expand_crate_moves_cursor* Type: `boolean`, Default: `true` @@ -705,6 +698,9 @@ text.error *crates-config-text-error* Format string used when there was an error loading crate information. +open_programs *crates-config-open_programs* + DEPRECATED + highlight *crates-config-highlight* Section type: `HighlightConfig` diff --git a/docgen/wiki/Documentation-unstable.md b/docgen/wiki/Documentation-unstable.md index 6755fc5..f966895 100644 --- a/docgen/wiki/Documentation-unstable.md +++ b/docgen/wiki/Documentation-unstable.md @@ -168,7 +168,6 @@ require("crates").setup { notification_title = "crates.nvim", curl_args = { "-sL", "--retry", "1" }, max_parallel_requests = 80, - open_programs = { "xdg-open", "open" }, expand_crate_moves_cursor = true, enable_update_available_warning = true, on_attach = function(bufnr) end, diff --git a/lua/crates/config/init.lua b/lua/crates/config/init.lua index 50e5fce..4f5f56a 100644 --- a/lua/crates/config/init.lua +++ b/lua/crates/config/init.lua @@ -54,6 +54,7 @@ local M = {} ---@class Deprecated ---@field new_field string[]? ---@field hard boolean? +---@field msg string? ---@param schema table|SchemaElement[] ---@param elem SchemaElement @@ -210,14 +211,6 @@ entry(M.schema, { Maximum number of parallel requests. ]], }) -entry(M.schema, { - name = "open_programs", - type = STRING_ARRAY_TYPE, - default = { "xdg-open", "open" }, - description = [[ - A list of programs that used to open urls. - ]], -}) entry(M.schema, { name = "expand_crate_moves_cursor", type = BOOLEAN_TYPE, @@ -324,6 +317,15 @@ entry(schema_text, { Format string used when there was an error loading crate information. ]], }) +-- DEPRECATED +entry(M.schema, { + name = "open_programs", + type = STRING_ARRAY_TYPE, + deprecated = { + msg = ", `vim.ui.open()` is used instead", + hard = true, + }, +}) local schema_hl = section_entry(M.schema, { @@ -1746,25 +1748,28 @@ local function validate_schema(path, schema, user_config) local dep = elem.deprecated if dep then - if dep.new_field then - ---@type string - local dep_text - if dep.hard then - dep_text = "deprecated and won't work anymore" - else - dep_text = "deprecated and will stop working soon" - end + ---@type string + local msg + if dep.msg then + msg = dep.msg + elseif dep.hard or not dep.new_field then + msg = " and won't work anymore" + else + msg = " and will stop working soon" + end + if dep.new_field then warn( - "'%s' is now %s, please use '%s'", + "`%s` is now deprecated%s\nPlease use `%s`", table.concat(p, "."), - dep_text, + msg, table.concat(dep.new_field, ".") ) else warn( - "'%s' is now deprecated, ignoring", - table.concat(p, ".") + "`%s` is now deprecated%s", + table.concat(p, "."), + msg ) end elseif elem.type.config_type == "section" then @@ -1772,7 +1777,7 @@ local function validate_schema(path, schema, user_config) validate_schema(p, elem.fields, v) else warn( - "Config field '%s' was expected to be of type 'table' but was '%s', using default value.", + "Config field `%s` was expected to be of type `table` but was `%s`, using default value.", table.concat(p, "."), value_type ) @@ -1780,7 +1785,7 @@ local function validate_schema(path, schema, user_config) else if not matches_type(value_type, elem.type) then warn( - "Config field '%s' was expected to be of type '%s' but was '%s', using default value.", + "Config field `%s` was expected to be of type `%s` but was `%s`, using default value.", table.concat(p, "."), to_user_config_type_string(elem.type), value_type @@ -1789,7 +1794,7 @@ local function validate_schema(path, schema, user_config) end else warn( - "Ignoring invalid config key '%s'", + "Ignoring invalid config key `%s`", table.concat(p, ".") ) end @@ -1800,7 +1805,7 @@ end ---@return Config local function setup_neoconf(config) ---@type boolean, table - local ok, neoconf = pcall(require, 'neoconf') + local ok, neoconf = pcall(require, "neoconf") if not ok then return config end @@ -1808,7 +1813,7 @@ local function setup_neoconf(config) -- enables neodev to autocomplete settings in .neoconf.json pcall(function() ---@type table - local neoconf_plugins = require('neoconf.plugins') + local neoconf_plugins = require("neoconf.plugins") neoconf_plugins.register { on_schema = function(schema) schema:import("crates", config) @@ -1871,7 +1876,7 @@ function M.build(user_config) user_config = user_config or {} local user_config_type = type(user_config) if user_config_type ~= "table" then - warn("Expected config of type 'table' found '%s'", user_config_type) + warn("Expected config of type `table` found `%s`", user_config_type) user_config = {} end diff --git a/lua/crates/config/types.lua b/lua/crates/config/types.lua index 6f9fed0..1e21dea 100644 --- a/lua/crates/config/types.lua +++ b/lua/crates/config/types.lua @@ -16,7 +16,6 @@ ---@field notification_title string ---@field curl_args string[] ---@field max_parallel_requests integer ----@field open_programs string[] ---@field expand_crate_moves_cursor boolean ---@field enable_update_available_warning boolean ---@field on_attach fun(bufnr: integer) @@ -231,7 +230,6 @@ ---@field public notification_title? string ---@field public curl_args? string[] ---@field public max_parallel_requests? integer ----@field public open_programs? string[] ---@field public expand_crate_moves_cursor? boolean ---@field public enable_update_available_warning? boolean ---@field public on_attach? fun(bufnr: integer) diff --git a/lua/crates/health.lua b/lua/crates/health.lua index debc337..2c31ec6 100644 --- a/lua/crates/health.lua +++ b/lua/crates/health.lua @@ -17,20 +17,6 @@ function M.check() else vim.health.error("curl not found") end - - local num = 0 - for _, prg in ipairs(state.cfg.open_programs) do - if util.binary_installed(prg) then - vim.health.ok(string.format("%s installed", prg)) - ---@type integer - num = num + 1 - end - end - - if num == 0 then - local programs = table.concat(state.cfg.open_programs, " ") - vim.health.warn("none of the following are installed " .. programs) - end end return M diff --git a/lua/crates/util.lua b/lua/crates/util.lua index 0a2f2fe..5d2f805 100644 --- a/lua/crates/util.lua +++ b/lua/crates/util.lua @@ -233,14 +233,10 @@ end ---@param url string function M.open_url(url) - for _, prg in ipairs(state.cfg.open_programs) do - local ok, result = pcall(vim.cmd, string.format("silent !%s %s", prg, url)) - if ok == true then - return - end + local _cmd, err = vim.ui.open(url) + if err then + M.notify(vim.log.levels.ERROR, "Couldn't open url: %s", err) end - - M.notify(vim.log.levels.WARN, "Couldn't open url") end return M