Skip to content

Commit

Permalink
builtins/nix_flake_fmt: defer loading plenary
Browse files Browse the repository at this point in the history
  • Loading branch information
mochaaP committed Jan 12, 2025
1 parent 0143bb5 commit 326afeb
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions lua/null-ls/builtins/formatting/nix_flake_fmt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,9 @@ local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local log = require("null-ls.logger")
local client = require("null-ls.client")
local async = require("plenary.async")
local Job = require("plenary.job")

local FORMATTING = methods.internal.FORMATTING

local run_job = async.wrap(function(opts, done)
opts.on_exit = function(j, status)
done(status, j:result(), j:stderr_result())
end

Job:new(opts):start()
end, 2)

local tmpname = async.wrap(function(done)
vim.defer_fn(function()
done(vim.fn.tempname())
end, 0)
end, 1)

--- Asynchronously computes the command that `nix fmt` would run, or nil if
--- we're not in a flake with a formatter, or if we fail to discover the
--- formatter somehow. When finished, it invokes the `done` callback with a
Expand All @@ -38,6 +22,23 @@ end, 1)
local find_nix_fmt = function(opts, done)
done = vim.schedule_wrap(done)

local async = require("plenary.async")
local Job = require("plenary.job")

local run_job = async.wrap(function(_opts, _done)
_opts.on_exit = function(j, status)
_done(status, j:result(), j:stderr_result())
end

Job:new(_opts):start()
end, 2)

local tmpname = async.wrap(function(_done)
vim.defer_fn(function()
_done(vim.fn.tempname())
end, 0)
end, 1)

async.run(function()
local title = "discovering `nix fmt` entrypoint"
local progress_token = "nix-flake-fmt-discovery"
Expand Down

0 comments on commit 326afeb

Please sign in to comment.