|
|
@ -60,6 +60,7 @@ module.use_null_ls = function(package_name, null_ls_path, configure_function) |
|
|
|
local path = vim.split(null_ls_path, "%.", nil) |
|
|
|
if #path ~= 3 then |
|
|
|
log.error(("Error setting up null-ls provider `%s`.\n\n null_ls_path should have 3 segments i.e. `builtins.formatting.stylua"):format(null_ls_path)) |
|
|
|
return |
|
|
|
end |
|
|
|
local provider = null_ls[path[1]][path[2]][path[3]] |
|
|
|
|
|
|
@ -70,9 +71,13 @@ module.use_null_ls = function(package_name, null_ls_path, configure_function) |
|
|
|
module.use_null_ls_source({ provider }) |
|
|
|
end |
|
|
|
|
|
|
|
local on_error = function(package_name, message) |
|
|
|
log.error(("There was an error setting up null_ls provider `%s`. Reason: \n%s"):format(null_ls_path, message)) |
|
|
|
end |
|
|
|
|
|
|
|
-- If auto_install module is enabled, try to install package before starting |
|
|
|
if doom.features.auto_install and package_name ~= nil then |
|
|
|
module.use_mason_package(package_name, start_null_ls) |
|
|
|
module.use_mason_package(package_name, start_null_ls, on_error) |
|
|
|
else |
|
|
|
vim.defer_fn(function() |
|
|
|
start_null_ls() |
|
|
@ -85,7 +90,7 @@ end |
|
|
|
---@param package_name string Name of the package that's being installed |
|
|
|
---@param err_message string Reason for erroring out of installing mason package |
|
|
|
local default_error_handler = function(package_name, err_message) |
|
|
|
error(("Error installing mason package `%s`. Reason: %s "):format(package_name, err_message)) |
|
|
|
error(("Error installing mason package `%s`. Reason: \n%s "):format(package_name, err_message)) |
|
|
|
end |
|
|
|
|
|
|
|
--- Installs a mason package and provides an on-ready handler |
|
|
@ -124,10 +129,10 @@ module.use_mason_package = function(package_name, success_handler, error_handler |
|
|
|
if statusline then |
|
|
|
statusline.state.finish_mason_package(package_name) |
|
|
|
end |
|
|
|
local err = "Mason.nvim failed safely. You might be missing the dependencies to install this package." |
|
|
|
local err = "Mason.nvim install failed. Reason:\n" |
|
|
|
if (pkg and pkg.stdio and pkg.stdio.buffers and pkg.stdio.buffers.stderr) then |
|
|
|
err = err .. "\n \n" |
|
|
|
for _, line in ipairs(pkg.stdio.buffers.stderr) do |
|
|
|
print(line) |
|
|
|
err = err .. line |
|
|
|
end |
|
|
|
end |
|
|
@ -141,7 +146,7 @@ module.use_mason_package = function(package_name, success_handler, error_handler |
|
|
|
end |
|
|
|
end, debug.traceback) |
|
|
|
if not ok then |
|
|
|
on_err(package_name, "There was an unknown error when trying to install. \n\n" .. err) |
|
|
|
on_err(package_name, "There was an unknown error when installing. Reason: \n" .. err) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|