Browse Source

nextest update

Thomas 1 week ago
parent
commit
d21286b06b
4 changed files with 102 additions and 3 deletions
  1. 36 0
      AGENTS.md
  2. 39 2
      lua/config/mappings.lua
  3. 1 1
      lua/plugins/nonels.lua
  4. 26 0
      lua/plugins/test.lua

+ 36 - 0
AGENTS.md

@@ -0,0 +1,36 @@
+# Repository Guidelines
+
+## Project Structure & Module Organization
+- `init.lua` sets core options (tab width 2, tabs preserved) and wires `config.lazy`, `config.mappings`, and `config.autocmd`.
+- `lua/config/` holds shared behavior: `lazy.lua` bootstraps lazy.nvim and leaders, `mappings.lua` defines keys, `autocmd.lua` holds events and filetype tweaks.
+- `lua/plugins/` contains one-file-per-topic plugin specs for lazy.nvim; add new plugins here using a returned table.
+- `lazy-lock.json` pins plugin revisions; update only when deliberately bumping dependencies.
+- `spell/` contains custom spelling wordlists loaded by the config.
+
+## Build, Test, and Development Commands
+- Install/sync plugins: `nvim --headless "+Lazy sync" +qa` (also respects `lazy-lock.json`).
+- Check runtime health: `nvim --headless "+checkhealth" +qa`.
+- Minimal repro session: `nvim --clean -u init.lua` from the repo root.
+- Format Lua locally when available: `stylua lua` (uses conform.nvim/stylua in-editor).
+
+## Coding Style & Naming Conventions
+- Lua uses tabs with a visual width of 2 (`noexpandtab`, `tabstop=2`, `shiftwidth=2`).
+- Prefer readable tables with trailing commas and module-level `return { ... }` style for plugin specs.
+- Name plugin files by feature (`lua/plugins/telescope.lua`, `lua/plugins/git.lua`); keep config helpers in `lua/config/`.
+- Keep user-facing strings concise; avoid hardcoding machine-specific paths beyond `$HOME`.
+
+## Testing Guidelines
+- After changes, run `nvim --headless "+Lazy sync" +qa` to ensure specs load and dependencies resolve.
+- Run `nvim --headless "+checkhealth" +qa` to catch missing tools (e.g., `stylua`, `rustfmt`, `typstyle`, `styler` for R).
+- For keymap or autocmd changes, open a clean session (`nvim --clean -u init.lua`) and exercise the affected commands or filetypes.
+
+## Commit & Pull Request Guidelines
+- Recent history favors brief, present-tense summaries (e.g., `update LSP`, `buffer`); keep subjects under ~50 characters.
+- When adding plugins or mappings, mention the feature in the subject and note key bindings or defaults in the body.
+- For pull requests, include: what changed, why it helps editing workflows, any new dependencies, and screenshots/gifs if UI-facing (statusline, dashboard).
+- If you update `lazy-lock.json`, call that out explicitly and describe any notable plugin upgrades or breaking changes.
+
+## Security & Configuration Tips
+- Do not commit API keys or machine-specific credentials; prefer environment variables consumed by plugins when needed.
+- Keep external tooling installs (Mason, system packages) documented so others can reproduce formatter/linter availability.
+- Avoid introducing autocmds or keymaps that shadow common defaults without noting the rationale in `lua/config/mappings.lua`.

+ 39 - 2
lua/config/mappings.lua

@@ -56,8 +56,8 @@ function FormatBuffer()
 	-- 	on_exit = function(_, exit_code)
 	-- 		if exit_code == 0 then
 	-- 			print("TypestStyle completed successfully")
-	--        -- vim.cmd('edit!') -- Reload the buffer
-	--        vim.fn.setpos(".", cursor_position)
+	--       -- vim.cmd('edit!') -- Reload the buffer
+	--       vim.fn.setpos(".", cursor_position)
 	-- 		else
 	-- 			print("TypestStyle failed with exit code: " .. exit_code)
 	-- 		end
@@ -127,6 +127,43 @@ wk.add({
 			desc = "Rename symbol",
 		},
 
+		-- Tests
+		{
+			"<leader>tt",
+			function()
+				require("neotest").run.run({ extra_args = { "--", "--nocapture" } })
+			end,
+			desc = "Test nearest",
+		},
+		{
+			"<leader>tF",
+			function()
+				require("neotest").run.run(vim.fn.expand("%"), { extra_args = { "--", "--nocapture" } })
+			end,
+			desc = "Test file",
+		},
+		{
+			"<leader>ts",
+			function()
+				require("neotest").summary.toggle()
+			end,
+			desc = "Test summary",
+		},
+		{
+			"<leader>tO",
+			function()
+				require("neotest").output.open({ enter = true })
+			end,
+			desc = "Test output",
+		},
+		{
+			"<leader>tq",
+			function()
+				require("neotest").run.stop()
+			end,
+			desc = "Test stop",
+		},
+
 		{
 			"<leader>ft",
 			function()

+ 1 - 1
lua/plugins/nonels.lua

@@ -9,7 +9,7 @@ return {
 		config = function()
 			local null_ls = require("null-ls")
 
-      null_ls.setup()
+			null_ls.setup()
 			-- null_ls.setup({
 			-- 	sources = {
 			-- 		null_ls.builtins.formatting.stylua,

+ 26 - 0
lua/plugins/test.lua

@@ -0,0 +1,26 @@
+return {
+	{
+		"nvim-neotest/neotest",
+		dependencies = {
+			"nvim-lua/plenary.nvim",
+			"nvim-treesitter/nvim-treesitter",
+			"nvim-neotest/nvim-nio",
+		},
+		config = function()
+			local neotest = require("neotest")
+			neotest.setup({
+				adapters = {
+					require("rustaceanvim.neotest"),
+				},
+			})
+
+			-- Allow closing output window with q
+			vim.api.nvim_create_autocmd("FileType", {
+				pattern = "neotest-output",
+				callback = function(event)
+					vim.keymap.set("n", "q", "<cmd>close<CR>", { buffer = event.buf, silent = true })
+				end,
+			})
+		end,
+	},
+}