Updated 7. Example Custom Plugins (markdown)

Asep Komarudin 2024-06-13 21:27:48 +07:00
parent 6f718e517c
commit 9bbe8a6e5d

@ -2876,3 +2876,97 @@ return {
},
}
```
# Neotest-Jest
```lua
return {
"nvim-neotest/neotest",
dependencies = {
"nvim-neotest/neotest-jest",
"nvim-neotest/nvim-nio",
},
config = function()
require("neotest").setup {
adapters = {
require "neotest-jest" {
jestCommand = "npm test -- ",
jestConfigFile = function()
local file = vim.fn.expand "%:p"
if string.find(file, "/packages/") then
return string.match(file, "(.-/[^/]+/)src") .. "jest.config.mjs"
end
return vim.fn.getcwd() .. "/jest.config.mjs"
end,
env = { CI = true },
cwd = function()
local file = vim.fn.expand "%:p"
if string.find(file, "/packages/") then
return string.match(file, "(.-/[^/]+/)src")
end
return vim.fn.getcwd()
end,
status = { virtual_text = true },
output = { open_on_run = true },
},
},
}
end,
keys = {
{
"<leader>Tt",
function()
require("neotest").run.run(vim.fn.expand "%")
end,
desc = "Run File",
},
{
"<leader>Tr",
function()
require("neotest").run.run()
end,
desc = "Run Nearest",
},
{
"<leader>TT",
function()
require("neotest").run.run(vim.loop.cwd())
end,
desc = "Run All Test Files",
},
{
"<leader>Tl",
function()
require("neotest").run.run_last()
end,
desc = "Run Last",
},
{
"<leader>Ts",
function()
require("neotest").summary.toggle()
end,
desc = "Toggle Summary",
},
{
"<leader>To",
function()
require("neotest").output.open { enter = true, auto_close = true }
end,
desc = "Show Output",
},
{
"<leader>TO",
function()
require("neotest").output_panel.toggle()
end,
desc = "Toggle Output Panel",
},
{
"<leader>TS",
function()
require("neotest").run.stop()
end,
desc = "Stop",
},
},
}
```