mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-28 03:30:12 +02:00
refactor: refactored mason/typescript/vue support
This commit is contained in:
parent
135150307b
commit
9d999fa210
6 changed files with 70 additions and 37 deletions
|
@ -72,7 +72,12 @@ function M.on_very_lazy(fn)
|
|||
})
|
||||
end
|
||||
|
||||
function M.extend(t, key, value)
|
||||
---@generic T
|
||||
---@param t T[]
|
||||
---@param key string
|
||||
---@param values T[]
|
||||
---@return T[]?
|
||||
function M.extend(t, key, values)
|
||||
local keys = vim.split(key, ".", { plain = true })
|
||||
for i = 1, #keys do
|
||||
local k = keys[i]
|
||||
|
@ -82,7 +87,7 @@ function M.extend(t, key, value)
|
|||
end
|
||||
t = t[k]
|
||||
end
|
||||
t[#t + 1] = value
|
||||
return vim.list_extend(t, values)
|
||||
end
|
||||
|
||||
---@param name string
|
||||
|
@ -211,4 +216,27 @@ function M.create_undo()
|
|||
end
|
||||
end
|
||||
|
||||
--- Gets a path to a package in the Mason registry.
|
||||
--- Prefer this to `get_package`, since the package might not always be
|
||||
--- available yet and trigger errors.
|
||||
---@param pkg string
|
||||
---@param path? string
|
||||
function M.get_pkg_path(pkg, path)
|
||||
path = path or ""
|
||||
local ret = vim.env.MASON .. "/packages/" .. pkg .. "/" .. path
|
||||
if not vim.loop.fs_stat(ret) then
|
||||
M.warn(("Mason package path not found for **%s**:\n- `%s`"):format(pkg, path))
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
--- Override the default title for notifications.
|
||||
for _, level in ipairs({ "info", "warn", "error" }) do
|
||||
M[level] = function(msg, opts)
|
||||
opts = opts or {}
|
||||
opts.title = opts.title or "LazyVim"
|
||||
return LazyUtil[level](msg, opts)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue