forked from AckslD/nvim-pytrize.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.lua
More file actions
43 lines (37 loc) · 1.21 KB
/
settings.lua
File metadata and controls
43 lines (37 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local M = {}
local warn = require("pytrize.warn").warn
---@class PytrizeSettings
---@field no_commands boolean Whether to skip creating user commands (default: false)
---@field highlight string Highlight group for virtual text (default: "LineNr")
---@field metrics boolean Show performance metrics for operations (default: false)
---@type PytrizeSettings
-- All valid setting keys (including those whose default is nil)
local valid_keys = {
no_commands = true,
highlight = "LineNr",
metrics = true,
preferred_input = true, -- 'telescope', 'fzf-lua', or nil (quickfix fallback)
}
-- defaults
M.settings = {
no_commands = false,
highlight = "LineNr",
metrics = false,
preferred_input = nil,
}
---@param opts table
M.update = function(opts)
for k, v in pairs(opts) do
if not valid_keys[k] then
warn(string.format("unknown setting '%s'", k))
else
local current = M.settings[k]
if current ~= nil and type(current) ~= type(v) then
warn(string.format("invalid type for setting '%s': expected %s, got %s", k, type(current), type(v)))
else
M.settings[k] = v
end
end
end
end
return M