enc: config default javascript

This commit is contained in:
asep.komarudin 2024-06-22 10:29:08 +07:00
parent 66d401335e
commit 2165fb1c63
6 changed files with 106 additions and 105 deletions

View file

@ -13,7 +13,6 @@
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"code_runner.nvim": { "branch": "main", "commit": "6c5bfe44a6c7523350cd706e6b3b8101166eed99" },
"codeium.nvim": { "branch": "main", "commit": "d3b88eb3aa1de6da33d325c196b8a41da2bcc825" },
"crates.nvim": { "branch": "main", "commit": "8437522d12a8c523da2aee9db2979d070b2ecc33" },
"dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" },
"dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" },
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" },
@ -24,11 +23,11 @@
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" },
"mason-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "f5425eb1d0d794f0305d5eeebddabb74614683ff" },
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
"mini.indentscope": { "branch": "main", "commit": "f0d7faa064c892b96997810afcddfadc3f2a15b3" },
"neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" },
"neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" },
"neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" },
"noice.nvim": { "branch": "main", "commit": "8f1d9966762e62fa8788e5fb1a5f6a86784221d9" },
"none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" },
"none-ls.nvim": { "branch": "main", "commit": "f1b438ab1709cf9d8875843559d20265013ac755" },
@ -38,7 +37,7 @@
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
"nvim-dap": { "branch": "master", "commit": "5ba8ceace596360321cf33fa4b56d9d46e057ce9" },
"nvim-dap-ui": { "branch": "master", "commit": "f7d75cca202b52a60c520ec7b1ec3414d6e77b0f" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "d7c695ea39542f6da94ee4d66176f5d660ab0a77" },
"nvim-dap-vscode-js": { "branch": "main", "commit": "e7c05495934a658c8aa10afd995dacd796f76091" },
"nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" },
"nvim-material-icon": { "branch": "main", "commit": "2f1d6333bbec2e787774193c9fc7b447b878069a" },
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
@ -55,8 +54,6 @@
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" },
"rest.nvim": { "branch": "main", "commit": "91badd46c60df6bd9800c809056af2d80d33da4c" },
"rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" },
"rustaceanvim": { "branch": "master", "commit": "d6d7620b66d74b3b16defcf85cbef7b3582795b3" },
"smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" },
"telescope.nvim": { "branch": "master", "commit": "f2bfde705ac752c52544d5cfa8b0aee0a766c1ed" },
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "9be4af5b1bc1f26a11206ed7ce8bf44312e7941a" },
@ -65,6 +62,7 @@
"vim-startuptime": { "branch": "master", "commit": "97a88e688482a09c3c4b777d07b509b328a5ec29" },
"vim-visual-multi": { "branch": "master", "commit": "b84a6d42c1c10678928b0bf8327f378c8bc8af5a" },
"virt-column.nvim": { "branch": "master", "commit": "b62b4ef0774d19452d4ed18e473e824c7a756f2f" },
"vscode-js-debug": { "branch": "main", "commit": "9fd0efd39d534304cffd970263148923b627be20" },
"which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" },
"yanky.nvim": { "branch": "main", "commit": "9268018e92d02650a94e39dd5f5903c542f7ea11" }
}

View file

@ -158,11 +158,12 @@ pcode.phpunit = false
-- https://github.com/nvim-neotest/neotest-python
-- https://docs.pytest.org/en/7.1.x/getting-started.html
pcode.pytest = false
-- https://github.com/nvim-neotest/neotest-jest
pcode.jest = false
pcode.jest_command = "npm test -- "
pcode.jest_config = "jest.config.mjs"
-- https://github.com/fredrikaverpil/neotest-golang
pcode.gotest = false
pcode.acive_rust_config = true
pcode.active_rust_config = false
pcode.active_javascript_config = {
status = true,
jest_command = "npm test -- ",
jest_config = "jest.config.mjs",
}

View file

@ -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,

View file

@ -1,5 +1,5 @@
local M = {}
if pcode.acive_rust_config then
if pcode.active_rust_config then
M = {
{
"rust-lang/rust.vim",

View file

@ -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

View file

@ -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 {}