aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/ui/state.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-09-07 02:44:09 +0200
committerGitHub <noreply@github.com>2021-09-07 02:44:09 +0200
commit00294b84031711013a385f18c0fb0e8db84ebaf9 (patch)
treee45de668229c6b41643c5d1fa0fdb5beb0ff60fa /lua/nvim-lsp-installer/ui/state.lua
parentlazily require servers for faster startup times (#77) (diff)
downloadmason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.gz
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.bz2
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.lz
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.xz
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.zst
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.zip
add direct integration with libuv instead of going through termopen, also implement a UI (#79)
* add direct integration with libuv instead of going through termopen, also implement a UI * alleged free perf boosts yo that's free cycles
Diffstat (limited to 'lua/nvim-lsp-installer/ui/state.lua')
-rw-r--r--lua/nvim-lsp-installer/ui/state.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/ui/state.lua b/lua/nvim-lsp-installer/ui/state.lua
new file mode 100644
index 00000000..ff54c657
--- /dev/null
+++ b/lua/nvim-lsp-installer/ui/state.lua
@@ -0,0 +1,22 @@
+local M = {}
+
+function M.create_state_container(initial_state, subscriber)
+ -- we do deepcopy to make sure instances of state containers doesn't mutate the initial state
+ local state = vim.deepcopy(initial_state)
+ local has_unsubscribed = false
+
+ return function(mutate_fn)
+ mutate_fn(state)
+ if not has_unsubscribed then
+ subscriber(state)
+ end
+ end,
+ function()
+ return state
+ end,
+ function(val)
+ has_unsubscribed = val
+ end
+end
+
+return M