Skip to content

Commit

Permalink
feat(lua): add Lua default batch log template
Browse files Browse the repository at this point in the history
  • Loading branch information
Goose97 committed Nov 21, 2024
1 parent 9d20a86 commit 5c9eaeb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/neolog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ local default_config = {
typescript = [[console.log({ %repeat<"%identifier": %identifier><, > })]],
jsx = [[console.log({ %repeat<"%identifier": %identifier><, > })]],
tsx = [[console.log({ %repeat<"%identifier": %identifier><, > })]],
lua = [[print(string.format("%repeat<%identifier=%s><, >", %repeat<%identifier><, >))]],
},
},
highlight = {
Expand Down
30 changes: 29 additions & 1 deletion tests/neolog/actions/lang/lua_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local neolog = require("neolog")
local helper = require("tests.neolog.helper")
local actions = require("neolog.actions")

describe("lua", function()
describe("lua single log", function()
before_each(function()
neolog.setup({
log_templates = {
Expand Down Expand Up @@ -579,3 +579,31 @@ describe("lua", function()
end)
end)
end)

describe("lua batch log", function()
it("supports batch log", function()
neolog.setup({
batch_log_templates = {
default = {
lua = [[print(string.format("%repeat<%identifier=%s><, >", %repeat<%identifier><, >))]],
},
},
})

helper.assert_scenario({
input = [[
local fo|o = bar + baz
]],
filetype = "lua",
action = function()
vim.cmd("normal! V")
actions.add_log_targets_to_batch()
actions.insert_batch_log()
end,
expected = [[
local foo = bar + baz
print(string.format("foo=%s, bar=%s, baz=%s", foo, bar, baz))
]],
})
end)
end)

0 comments on commit 5c9eaeb

Please sign in to comment.