-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathmodel.lua
More file actions
61 lines (49 loc) · 1.28 KB
/
model.lua
File metadata and controls
61 lines (49 loc) · 1.28 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
local store = require('opencode.state.store')
---@class OpencodeModelStateMutations
local M = {}
---@param mode string|nil
function M.set_mode(mode)
return store.set('current_mode', mode)
end
function M.clear_mode()
return store.set('current_mode', nil)
end
---@param model string|nil
function M.set_model(model)
return store.set('current_model', model)
end
function M.clear_model()
return store.set('current_model', nil)
end
function M.clear()
return store.batch(function()
store.set('current_model', nil)
store.set('current_mode', nil)
store.set('current_variant', nil)
end)
end
---@param info table|nil
function M.set_model_info(info)
return store.set('current_model_info', info)
end
---@param variant string|nil
function M.set_variant(variant)
return store.set('current_variant', variant)
end
function M.clear_variant()
return store.set('current_variant', nil)
end
---@param mode_map table<string, string>
function M.set_mode_model_map(mode_map)
return store.set('user_mode_model_map', mode_map)
end
---@param mode string
---@param model string
function M.set_mode_model_override(mode, model)
return store.update('user_mode_model_map', function(current)
local updated = vim.deepcopy(current)
updated[mode] = model
return updated
end)
end
return M