diff options
| author | William Boman <william@redwill.se> | 2021-09-17 16:05:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-17 16:05:20 +0200 |
| commit | 9551bbc1e207ea9a9d436f1bf02a22afc33f6aa6 (patch) | |
| tree | 58da4fff57cc3aff4380f501b1845310dff4f2e8 /lua/nvim-lsp-installer/process.lua | |
| parent | texlab: fix ensure_executables (diff) | |
| download | mason-9551bbc1e207ea9a9d436f1bf02a22afc33f6aa6.tar mason-9551bbc1e207ea9a9d436f1bf02a22afc33f6aa6.tar.gz mason-9551bbc1e207ea9a9d436f1bf02a22afc33f6aa6.tar.bz2 mason-9551bbc1e207ea9a9d436f1bf02a22afc33f6aa6.tar.lz mason-9551bbc1e207ea9a9d436f1bf02a22afc33f6aa6.tar.xz mason-9551bbc1e207ea9a9d436f1bf02a22afc33f6aa6.tar.zst mason-9551bbc1e207ea9a9d436f1bf02a22afc33f6aa6.zip | |
optimize io (70%+ startup speedups) (#93)
Diffstat (limited to 'lua/nvim-lsp-installer/process.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/process.lua | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/lua/nvim-lsp-installer/process.lua b/lua/nvim-lsp-installer/process.lua index d98a2ed5..8669f7b6 100644 --- a/lua/nvim-lsp-installer/process.lua +++ b/lua/nvim-lsp-installer/process.lua @@ -1,4 +1,5 @@ local log = require "nvim-lsp-installer.log" +local platform = require "nvim-lsp-installer.platform" local uv = vim.loop local M = {} @@ -22,11 +23,19 @@ end -- We gather the root env immediately, primarily because of E5560. -- Also, there's no particular reason we need to refresh the environment (yet). -local environ = vim.fn.environ() +local initial_environ = vim.fn.environ() + +function M.extend_path(new_paths) + local new_path_str = table.concat(new_paths, platform.path_sep) + if initial_environ["PATH"] then + return new_path_str .. platform.path_sep .. initial_environ["PATH"] + end + return new_path_str +end function M.graft_env(env) local root_env = {} - for key, val in pairs(environ) do + for key, val in pairs(initial_environ) do root_env[#root_env + 1] = key .. "=" .. val end for key, val in pairs(env) do @@ -81,7 +90,6 @@ function M.spawn(cmd, opts, callback) return nil, nil end - handle:unref() log.debug { "Spawned with pid", pid } stdout:read_start(connect_sink(stdout, opts.stdio_sink.stdout)) @@ -136,4 +144,21 @@ function M.simple_sink() } end +-- this prob belongs elsewhere ¯\_(ツ)_/¯ +function M.debounced(debounced_fn) + local queued = false + local last_arg = nil + return function(a) + last_arg = a + if queued then + return + end + queued = true + vim.schedule(function() + debounced_fn(last_arg) + queued = false + end) + end +end + return M |
