summaryrefslogtreecommitdiff
path: root/lua/lvim/lsp/null-ls
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2022-01-08 14:24:05 +0100
committerGitHub <[email protected]>2022-01-08 14:24:05 +0100
commit4a66d4752d06cfe0452c55ee5f2b20f84d19c3bb (patch)
treee5b55cda6903fa1712d0b3c63f701498150a9082 /lua/lvim/lsp/null-ls
parent6740afd743a05028cc48e8f1e203e7f81345aced (diff)
fix(null-ls): avoid sending invalid opts.args (#2154)
Diffstat (limited to 'lua/lvim/lsp/null-ls')
-rw-r--r--lua/lvim/lsp/null-ls/services.lua26
1 files changed, 15 insertions, 11 deletions
diff --git a/lua/lvim/lsp/null-ls/services.lua b/lua/lvim/lsp/null-ls/services.lua
index b8a8edc8..7dc0bb62 100644
--- a/lua/lvim/lsp/null-ls/services.lua
+++ b/lua/lvim/lsp/null-ls/services.lua
@@ -72,22 +72,26 @@ function M.register_sources(configs, method)
local name = config.name or cmd:gsub("-", "_")
local type = method == null_ls.methods.CODE_ACTION and "code_actions" or null_ls.methods[method]:lower()
local source = type and null_ls.builtins[type][name]
- Log:debug(string.format("Received request to register [%s] as a %s source", cmd, type))
+ Log:debug(string.format("Received request to register [%s] as a %s source", name, type))
if not source then
Log:error("Not a valid source: " .. name)
- elseif is_registered { command = cmd or name, method = method } then
- Log:trace "Skipping registering the source more than once"
+ elseif is_registered { name = source.name or name, method = method } then
+ Log:trace(string.format("Skipping registering [%s] more than once", name))
else
local command = M.find_command(source._opts.command) or source._opts.command
- local compat_opts = {
- command = command,
- -- treat `args` as `extra_args` for backwards compatibility. Can otherwise use `generator_opts.args`
- extra_args = config.args or config.extra_args,
- }
- local opts = vim.tbl_deep_extend("keep", compat_opts, config)
- Log:debug("Registering source: " .. source.name)
+
+ -- treat `args` as `extra_args` for backwards compatibility. Can otherwise use `generator_opts.args`
+ local compat_opts = vim.deepcopy(config)
+ if config.args then
+ compat_opts.extra_args = config.args or config.extra_args
+ compat_opts.args = nil
+ end
+
+ local opts = vim.tbl_deep_extend("keep", { command = command }, compat_opts)
+ Log:debug("Registering source " .. name)
+ Log:trace(vim.inspect(opts))
table.insert(sources, source.with(opts))
- vim.list_extend(registered_names, { name })
+ vim.list_extend(registered_names, { source.name })
end
end