Skip to content

Commit 326afeb

Browse files
committed
builtins/nix_flake_fmt: defer loading plenary
1 parent 0143bb5 commit 326afeb

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lua/null-ls/builtins/formatting/nix_flake_fmt.lua

+17-16
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,9 @@ local h = require("null-ls.helpers")
22
local methods = require("null-ls.methods")
33
local log = require("null-ls.logger")
44
local client = require("null-ls.client")
5-
local async = require("plenary.async")
6-
local Job = require("plenary.job")
75

86
local FORMATTING = methods.internal.FORMATTING
97

10-
local run_job = async.wrap(function(opts, done)
11-
opts.on_exit = function(j, status)
12-
done(status, j:result(), j:stderr_result())
13-
end
14-
15-
Job:new(opts):start()
16-
end, 2)
17-
18-
local tmpname = async.wrap(function(done)
19-
vim.defer_fn(function()
20-
done(vim.fn.tempname())
21-
end, 0)
22-
end, 1)
23-
248
--- Asynchronously computes the command that `nix fmt` would run, or nil if
259
--- we're not in a flake with a formatter, or if we fail to discover the
2610
--- formatter somehow. When finished, it invokes the `done` callback with a
@@ -38,6 +22,23 @@ end, 1)
3822
local find_nix_fmt = function(opts, done)
3923
done = vim.schedule_wrap(done)
4024

25+
local async = require("plenary.async")
26+
local Job = require("plenary.job")
27+
28+
local run_job = async.wrap(function(_opts, _done)
29+
_opts.on_exit = function(j, status)
30+
_done(status, j:result(), j:stderr_result())
31+
end
32+
33+
Job:new(_opts):start()
34+
end, 2)
35+
36+
local tmpname = async.wrap(function(_done)
37+
vim.defer_fn(function()
38+
_done(vim.fn.tempname())
39+
end, 0)
40+
end, 1)
41+
4142
async.run(function()
4243
local title = "discovering `nix fmt` entrypoint"
4344
local progress_token = "nix-flake-fmt-discovery"

0 commit comments

Comments
 (0)