summaryrefslogtreecommitdiff
path: root/lua/telescope/state.lua
blob: 6a06eb183dd03e231932c6f57d539d3befb0ff8f (plain)
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
local state = {}

TelescopeGlobalState = TelescopeGlobalState or {}
TelescopeGlobalState.global = TelescopeGlobalState.global or {}

--- Set the status for a particular prompt bufnr
function state.set_status(prompt_bufnr, status)
  TelescopeGlobalState[prompt_bufnr] = status
end

function state.set_global_key(key, value)
  TelescopeGlobalState.global[key] = value
end

function state.get_global_key(key)
  return TelescopeGlobalState.global[key]
end

function state.get_status(prompt_bufnr)
  return TelescopeGlobalState[prompt_bufnr] or {}
end

function state.clear_status(prompt_bufnr)
  state.set_status(prompt_bufnr, nil)
end

function state.get_existing_prompts()
  return vim.tbl_keys(TelescopeGlobalState)
end

return state