diff --git a/.stylua.toml b/.stylua.toml index df96b7b..9639dd4 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -3,4 +3,4 @@ line_endings = "Unix" indent_type = "Spaces" indent_width = 2 quote_style = "AutoPreferDouble" -no_call_parentheses = true +# no_call_parentheses = true diff --git a/init.lua b/init.lua index 34e84ab..db8746c 100644 --- a/init.lua +++ b/init.lua @@ -6,9 +6,9 @@ if vim.g.vscode then VSCodeNotify = vim.fn.VSCodeNotify VSCodeCall = vim.fn.VSCodeCall - require "_vscode.functions" - require "_vscode.mappings" + require("_vscode.functions") + require("_vscode.mappings") else -- config neovim - require "core" + require("core") end diff --git a/lazy-lock.json b/lazy-lock.json index 7281a3f..47efed4 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,6 @@ { "Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" }, + "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, "bufferline.nvim": { "branch": "main", "commit": "99337f63f0a3c3ab9519f3d1da7618ca4f91cffe" }, @@ -14,7 +15,7 @@ "darcula-dark.nvim": { "branch": "main", "commit": "cce636860dc5151b6980a35dd378f54a238e0f0e" }, "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, "friendly-snippets": { "branch": "main", "commit": "700c4a25caacbb4648c9a27972c2fe203948e0c2" }, - "gitsigns.nvim": { "branch": "main", "commit": "76927d14d3fbd4ba06ccb5246e79d93b5442c188" }, + "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, "lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" }, "lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" }, @@ -24,7 +25,9 @@ "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mini.indentscope": { "branch": "main", "commit": "f0d7faa064c892b96997810afcddfadc3f2a15b3" }, "neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" }, - "noice.nvim": { "branch": "main", "commit": "b828b575805f1b303c2f4b768744609835140739" }, + "neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" }, + "neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" }, + "noice.nvim": { "branch": "main", "commit": "f65b6b7ab87796f93ea8f8a92d5a64dc53d912d1" }, "none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" }, "none-ls.nvim": { "branch": "main", "commit": "8691504118b252d64fc5023a104aedd100ab754a" }, "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, @@ -34,10 +37,11 @@ "nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" }, "nvim-material-icon": { "branch": "main", "commit": "7a8893417c6947925d00946d16b81b56574796a9" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, + "nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-scrollview": { "branch": "main", "commit": "c29c5f69d37040a1fac88cbea7f5e6f06f0aff4d" }, "nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" }, - "nvim-treesitter": { "branch": "master", "commit": "9636d5a3f4f531256fba147a30b882c44f28fae1" }, + "nvim-treesitter": { "branch": "master", "commit": "cdc613c630598779dc9f975bae12a4dc7c001950" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-ts-autotag": { "branch": "main", "commit": "06fe07d7523ba8c755fac7c913fceba43b1720ee" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, diff --git a/lua/custom/default.lua b/lua/custom/default.lua index 30cde59..3351d4b 100644 --- a/lua/custom/default.lua +++ b/lua/custom/default.lua @@ -135,3 +135,8 @@ vim.g.pcode_telescope_theme_find_file = "center" vim.g.pcode_telescope_theme_live_grep = "dropdown" -- https://github.com/kristijanhusak/vim-dadbod-ui vim.g.pcode_database = false + +-- https://github.com/nvim-neotest/neotest-jest +vim.g.pcode_jest = true +vim.g.pcode_jest_command = "npm test -- " +vim.g.pcode_jest_config = "jest.config.mjs" diff --git a/lua/plugins/test_jest.lua b/lua/plugins/test_jest.lua new file mode 100644 index 0000000..49aecea --- /dev/null +++ b/lua/plugins/test_jest.lua @@ -0,0 +1,92 @@ +local M = {} +local config_file = vim.g.pcode_jest_config or "jest.config.ts" +if vim.g.pcode_jest then + M = { + { + "nvim-neotest/neotest", + dependencies = { + "antoinemadec/FixCursorHold.nvim", + "nvim-neotest/neotest-jest", + "nvim-neotest/nvim-nio", + }, + opts = { + adapters = { + ["neotest-jest"] = { + jestCommand = vim.g.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 = { + { "T","",desc=" Test"}, + { "Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, + { "Tr", function() require("neotest").run.run() end, desc = "Run Nearest" }, + { "TT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" }, + { "Tl", function() require("neotest").run.run_last() end, desc = "Run Last" }, + { "Ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" }, + { "To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" }, + { "TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" }, + { "TS", function() require("neotest").run.stop() end, desc = "Stop" }, + }, + }, + } +end + +return M diff --git a/lua/user/autocommands.lua b/lua/user/autocommands.lua index f89c2aa..886da81 100644 --- a/lua/user/autocommands.lua +++ b/lua/user/autocommands.lua @@ -1,5 +1,5 @@ -- autocmd BufWinEnter * :set formatoptions-=cro -vim.cmd [[ +vim.cmd([[ augroup _general_settings autocmd! autocmd FileType qf,help,man,lspinfo nnoremap q :close @@ -56,12 +56,12 @@ vim.cmd [[ autocmd! autocmd BufWritePre * :call s:MkNonExDir(expand(''), +expand('')) augroup END -]] +]]) -- for fix error last close buffer vim.api.nvim_create_autocmd({ "QuitPre" }, { callback = function() - vim.cmd "NvimTreeClose" + vim.cmd("NvimTreeClose") end, }) @@ -74,7 +74,7 @@ autocmd("VimEnter", { }) vim.api.nvim_create_autocmd("FileType", { - pattern = { "help", "alpha", "dashboard", "NvimTree", "Trouble", "lazy", "mason" }, + pattern = { "help", "alpha", "dashboard", "NvimTree", "Trouble", "lazy", "mason", "neotest-summary" }, callback = function() vim.b.miniindentscope_disable = true end,