generated from mrcjkb/nvim-lua-nix-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extend lz.n with custom handlers (#17)
added require('lz.n').register_handler(lz.n.HandlerSpec) added lz.n.Plugin.extras for extra spec items from custom handlers. feat: extend lz.n with custom handlers feat: extend lz.n with custom handlers added tests Update spec/register_handler_spec.lua Update spec/register_handler_spec.lua feat: extend lz.n with custom handlers Update README.md Update lua/lz/n/handler/init.lua Co-authored-by: Marc Jakobi <[email protected]>
- Loading branch information
Showing
11 changed files
with
126 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
---@diagnostic disable: invisible | ||
vim.g.lz_n = { | ||
load = function() end, | ||
} | ||
local lz_n = require("lz.n") | ||
local spy = require("luassert.spy") | ||
|
||
describe("handlers.custom", function() | ||
---@class TestHandler: lz.n.Handler | ||
---@type TestHandler | ||
local hndl = { | ||
spec_field = "testfield", | ||
add = function(_) end, | ||
del = function(_) end, | ||
} | ||
local addspy = spy.on(hndl, "add") | ||
local delspy = spy.on(hndl, "del") | ||
it("Duplicate handlers fail to register", function() | ||
local notispy = spy.new(function() end) | ||
-- NOTE: teardown fails if you don't temporarily replace vim.notify | ||
local og_notify = vim.notify | ||
vim.notify = notispy | ||
assert.False(lz_n.register_handler(require("lz.n.handler.ft"))) | ||
assert.spy(notispy).called(1) | ||
vim.notify = og_notify | ||
end) | ||
it("can add plugins to the handler", function() | ||
assert.True(lz_n.register_handler(hndl)) | ||
lz_n.load({ | ||
"testplugin", | ||
testfield = { "a", "b" }, | ||
}) | ||
assert.spy(addspy).called_with({ | ||
name = "testplugin", | ||
testfield = { "a", "b" }, | ||
lazy = true, | ||
}) | ||
end) | ||
it("loading a plugin removes it from the handler", function() | ||
lz_n.trigger_load("testplugin") | ||
assert.spy(delspy).called_with({ | ||
name = "testplugin", | ||
testfield = { "a", "b" }, | ||
lazy = true, | ||
}) | ||
end) | ||
end) |