mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-22 00:49:01 +02:00
enc: config default javascript
This commit is contained in:
parent
66d401335e
commit
2165fb1c63
6 changed files with 106 additions and 105 deletions
|
@ -1,6 +1,91 @@
|
|||
local M = {}
|
||||
if pcode.nvim_dap_javascript then
|
||||
local config_file = pcode.active_javascript_config.jest_config or "jest.config.ts"
|
||||
if pcode.active_javascript_config.status then
|
||||
M = {
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
dependencies = {
|
||||
"antoinemadec/FixCursorHold.nvim",
|
||||
"nvim-neotest/neotest-jest",
|
||||
"nvim-neotest/nvim-nio",
|
||||
},
|
||||
opts = {
|
||||
adapters = {
|
||||
["neotest-jest"] = {
|
||||
jestCommand = pcode.active_javascript_config.jest_command or "npm test -- ",
|
||||
jestConfigFile = function()
|
||||
local file = vim.fn.expand("%:p")
|
||||
if string.find(file, "/packages/") then
|
||||
return string.match(file, "(.-/[^/]+/)src") .. config_file
|
||||
end
|
||||
return vim.fn.getcwd() .. "/" .. config_file
|
||||
end,
|
||||
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 },
|
||||
},
|
||||
config = function(_, opts)
|
||||
local neotest_ns = vim.api.nvim_create_namespace("neotest")
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
format = function(diagnostic)
|
||||
-- Replace newline and tab characters with space for more compact diagnostics
|
||||
local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
|
||||
return message
|
||||
end,
|
||||
},
|
||||
}, neotest_ns)
|
||||
|
||||
opts.consumers = opts.consumers or {}
|
||||
if opts.adapters then
|
||||
local adapters = {}
|
||||
for name, config in pairs(opts.adapters or {}) do
|
||||
if type(name) == "number" then
|
||||
if type(config) == "string" then
|
||||
config = require(config)
|
||||
end
|
||||
adapters[#adapters + 1] = config
|
||||
elseif config ~= false then
|
||||
local adapter = require(name)
|
||||
if type(config) == "table" and not vim.tbl_isempty(config) then
|
||||
local meta = getmetatable(adapter)
|
||||
if adapter.setup then
|
||||
adapter.setup(config)
|
||||
elseif meta and meta.__call then
|
||||
adapter(config)
|
||||
else
|
||||
error("Adapter " .. name .. " does not support setup")
|
||||
end
|
||||
end
|
||||
adapters[#adapters + 1] = adapter
|
||||
end
|
||||
end
|
||||
opts.adapters = adapters
|
||||
end
|
||||
|
||||
require("neotest").setup(opts)
|
||||
end,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>T","",desc=" Test"},
|
||||
{ "<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" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
lazy = true,
|
|
@ -1,5 +1,5 @@
|
|||
local M = {}
|
||||
if pcode.acive_rust_config then
|
||||
if pcode.active_rust_config then
|
||||
M = {
|
||||
{
|
||||
"rust-lang/rust.vim",
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
local M = {}
|
||||
local config_file = pcode.jest_config or "jest.config.ts"
|
||||
if pcode.jest then
|
||||
M = {
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
dependencies = {
|
||||
"antoinemadec/FixCursorHold.nvim",
|
||||
"nvim-neotest/neotest-jest",
|
||||
"nvim-neotest/nvim-nio",
|
||||
},
|
||||
opts = {
|
||||
adapters = {
|
||||
["neotest-jest"] = {
|
||||
jestCommand = pcode.jest_command or "npm test -- ",
|
||||
jestConfigFile = function()
|
||||
local file = vim.fn.expand("%:p")
|
||||
if string.find(file, "/packages/") then
|
||||
return string.match(file, "(.-/[^/]+/)src") .. config_file
|
||||
end
|
||||
return vim.fn.getcwd() .. "/" .. config_file
|
||||
end,
|
||||
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 },
|
||||
},
|
||||
config = function(_, opts)
|
||||
local neotest_ns = vim.api.nvim_create_namespace("neotest")
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
format = function(diagnostic)
|
||||
-- Replace newline and tab characters with space for more compact diagnostics
|
||||
local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
|
||||
return message
|
||||
end,
|
||||
},
|
||||
}, neotest_ns)
|
||||
|
||||
opts.consumers = opts.consumers or {}
|
||||
if opts.adapters then
|
||||
local adapters = {}
|
||||
for name, config in pairs(opts.adapters or {}) do
|
||||
if type(name) == "number" then
|
||||
if type(config) == "string" then
|
||||
config = require(config)
|
||||
end
|
||||
adapters[#adapters + 1] = config
|
||||
elseif config ~= false then
|
||||
local adapter = require(name)
|
||||
if type(config) == "table" and not vim.tbl_isempty(config) then
|
||||
local meta = getmetatable(adapter)
|
||||
if adapter.setup then
|
||||
adapter.setup(config)
|
||||
elseif meta and meta.__call then
|
||||
adapter(config)
|
||||
else
|
||||
error("Adapter " .. name .. " does not support setup")
|
||||
end
|
||||
end
|
||||
adapters[#adapters + 1] = adapter
|
||||
end
|
||||
end
|
||||
opts.adapters = adapters
|
||||
end
|
||||
|
||||
require("neotest").setup(opts)
|
||||
end,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>T","",desc=" Test"},
|
||||
{ "<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" },
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
|
@ -28,9 +28,18 @@ _G.all_trim = function(s)
|
|||
return s:match("^%s*(.-)%s*$")
|
||||
end
|
||||
|
||||
if pcode.acive_rust_config then
|
||||
-- run if rust config true
|
||||
if pcode.active_rust_config then
|
||||
table.insert(pcode.mason_ensure_installed, "rust_analyzer")
|
||||
table.insert(pcode.unregister_lsp, "rust_analyzer")
|
||||
table.insert(pcode.treesitter_ensure_installed, "rust")
|
||||
end
|
||||
-- run if javascript config true
|
||||
if pcode.active_javascript_config.status then
|
||||
local lst_ts = { "html", "javascript", "typescript", "tsx", "css", "json", "jsonc" }
|
||||
for _, ts in pairs(lst_ts) do
|
||||
table.insert(pcode.treesitter_ensure_installed, ts)
|
||||
end
|
||||
table.insert(pcode.mason_ensure_installed, "tsserver")
|
||||
end
|
||||
return {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue