Skip to content

Commit 2e09bcb

Browse files
authored
fix(config): invalid key checking in config handles lists and doesn't… (#35)
* fix(config): invalid key checking in config handles lists and doesn't throw errors instead of crashing python.nvim, show a notification as a warning. Be able to handle list-type tables by not having it be an error if the key is a number (indicating its a list) * chore: lint on config * ci(nvim): remove testing for neovim 10, 11 is only supported for lspconfig
1 parent ef512f3 commit 2e09bcb

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
fail-fast: false
3030
matrix:
3131
os: [ubuntu-latest]
32-
neovim_version: ["v0.10.4", "v0.11.3", "nightly"]
32+
neovim_version: ["v0.11.3", "nightly"]
3333
include:
3434
- os: macos-latest
3535
neovim_version: v0.11.3

lua/python/config.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,18 @@ local function tbl_deep_extend_existing(target, source, prev_key)
130130
-- Overwrite existing key
131131
target[key] = value
132132
end
133+
elseif type(key) == "number" then
134+
-- If the key is a number then we can assume
135+
-- that this is a table that is supposed to be a list
136+
goto continue
133137
else
134-
error(("python.nvim: user inputted config key: %s is not found in config table: %s"):format(key, prev_key))
138+
vim.notify(
139+
("python.nvim: user inputted config key: %s is not found in config table: %s"):format(key, prev_key),
140+
vim.log.levels.WARN
141+
)
142+
goto continue
135143
end
144+
::continue::
136145
end
137146
return target
138147
end

tests/test_config.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ T["setup"]["override"] = function()
3434
end
3535

3636
T["setup"]["not_found"] = function()
37-
expect.error(function()
38-
child.lua("config.setup({ ui = { popup = {foobar = true}} })")
39-
end, ".*user inputted config key: foobar is not found.*")
37+
child.lua("config.setup({ ui = { popup = {foobar = true}} })")
38+
eq(
39+
child.lua([[return vim.split(vim.fn.execute("messages", "silent"), "\n")]]),
40+
{ "", "python.nvim: user inputted config key: foobar is not found in config table: config.ui.popup" }
41+
)
4042
end
4143

4244
-- Return test set which will be collected and execute inside `MiniTest.run()`

0 commit comments

Comments
 (0)