Skip to content

user setting lsp list not replaced default config, but merge with default #972

Closed
@HATTER-LONG

Description

Version confirmation

  • Confirm

Following prerequisites

  • Confirm

Neovim version

0.9.1

Branch info

main (Default/Latest)

Minimal (user) folder structure required to reproduce the issue

user/setting.lua

Minimal config with steps on how to reproduce the issue

settings["dap_deps"] = {
	"codelldb", 
	-- "delve", --  remove Go
	"python", 
}

Expected behavior

Will still install delve by default, this phenomenon exists in other settings lists.

I think it's related to the following implementations, vim.list_extend will merge list which default and user config.

But I didn't think of any good ways to deal it.

--- Function to recursively merge src into dst
--- Unlike vim.tbl_deep_extend(), this function extends if the original value is a list
---@paramm dst table @Table which will be modified and appended to
---@paramm src table @Table from which values will be inserted
---@return table @Modified table
local function tbl_recursive_merge(dst, src)
	for key, value in pairs(src) do
		if type(dst[key]) == "table" and type(value) == "function" then
			dst[key] = value()
		elseif type(dst[key]) == "table" and vim.tbl_islist(dst[key]) then
			vim.list_extend(dst[key], value)
		elseif type(dst[key]) == "table" and not vim.tbl_islist(dst[key]) then
			tbl_recursive_merge(dst[key], value)
		else
			dst[key] = value
		end
	end
	return dst
end

Add a block list setting It seems a bit redundant. Perhaps we don't need to specify any lsp by default.

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions