1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-12-22 11:38:00 +00:00

[neovim] Add commands and keymaps to Neotest

This commit is contained in:
Daniel Carrillo 2024-02-04 17:55:49 +01:00
parent 6bd5f85550
commit b80f54b07c
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
3 changed files with 47 additions and 7 deletions

View File

@ -27,7 +27,7 @@
"lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" }, "lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" },
"lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "2b3d247fce06f53934174f5dfe0362c42d65c00c" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "0954d7730e749d606ddf8d7ae8846848be435d53" },
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
"mini.align": { "branch": "main", "commit": "c5ab28809c630b65ffe069b564ce1d473bbcb332" }, "mini.align": { "branch": "main", "commit": "c5ab28809c630b65ffe069b564ce1d473bbcb332" },
"mini.starter": { "branch": "main", "commit": "0ee58ac8975a929e90c8b104987fabfd13015e25" }, "mini.starter": { "branch": "main", "commit": "0ee58ac8975a929e90c8b104987fabfd13015e25" },
@ -44,7 +44,7 @@
"nvim-dap": { "branch": "master", "commit": "9d81c11fd185a131f81841e64941859305f6c42d" }, "nvim-dap": { "branch": "master", "commit": "9d81c11fd185a131f81841e64941859305f6c42d" },
"nvim-dap-ui": { "branch": "master", "commit": "0b4816e5ad5f3219e8e3ec9cce07f61b770c1974" }, "nvim-dap-ui": { "branch": "master", "commit": "0b4816e5ad5f3219e8e3ec9cce07f61b770c1974" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "d4542ac257d3c7ee4131350db6179ae6340ce40b" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "d4542ac257d3c7ee4131350db6179ae6340ce40b" },
"nvim-lspconfig": { "branch": "master", "commit": "9a6279953c82d01b58825a46ede032ab246a5983" }, "nvim-lspconfig": { "branch": "master", "commit": "d12140c5687a1186b95b3f42dbc6cc769df0cf0d" },
"nvim-treesitter": { "branch": "master", "commit": "4fbf150a1621d52f17b099506e1a32f107079210" }, "nvim-treesitter": { "branch": "master", "commit": "4fbf150a1621d52f17b099506e1a32f107079210" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" },
"nvim-ufo": { "branch": "main", "commit": "b0741a647efd98d9abb6cb653e056d24a07e4581" }, "nvim-ufo": { "branch": "main", "commit": "b0741a647efd98d9abb6cb653e056d24a07e4581" },
@ -59,7 +59,7 @@
"trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" },
"typescript-tools.nvim": { "branch": "master", "commit": "c43d9580c3ff5999a1eabca849f807ab33787ea7" }, "typescript-tools.nvim": { "branch": "master", "commit": "c43d9580c3ff5999a1eabca849f807ab33787ea7" },
"vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" }, "vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" },
"vim-illuminate": { "branch": "master", "commit": "97c1265ff0b67064b6cfdc15bafc50202a537ae2" }, "vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" },
"vim-kitty-navigator": { "branch": "master", "commit": "20abf8613aa228a5def1ae02cd9da0f2d210352a" }, "vim-kitty-navigator": { "branch": "master", "commit": "20abf8613aa228a5def1ae02cd9da0f2d210352a" },
"vim-markdown-toc": { "branch": "master", "commit": "0e2c7cdc3ac1d067eb309a10220d001bb7be39cd" }, "vim-markdown-toc": { "branch": "master", "commit": "0e2c7cdc3ac1d067eb309a10220d001bb7be39cd" },
"vim-visual-multi": { "branch": "master", "commit": "1c9207b28c8898ab01b54e6d6b61b0b820a814bc" }, "vim-visual-multi": { "branch": "master", "commit": "1c9207b28c8898ab01b54e6d6b61b0b820a814bc" },

View File

@ -138,11 +138,25 @@ keymap(
vim.tbl_extend("force", opts, { desc = "Format the current buffer or selection" }) vim.tbl_extend("force", opts, { desc = "Format the current buffer or selection" })
) )
-- Neotest
keymap(
"n",
"<leader>tr",
"<cmd>RunTest<cr>",
vim.tbl_extend("force", opts, { desc = "Run test on the current function" })
)
keymap(
"n",
"<leader>tf",
"<cmd>RunTestFile<cr>",
vim.tbl_extend("force", opts, { desc = "Run tests on the current file" })
)
-- Better paste -- Better paste
keymap("v", "p", "P", vim.tbl_extend("force", opts, { desc = "Paste" })) keymap("v", "p", "P", vim.tbl_extend("force", opts, { desc = "Paste" }))
-- Press jk fast to enter -- Press jk fast to exit insert mode
keymap("i", "jk", "<ESC>", vim.tbl_extend("force", opts, { desc = "Enter in insert mode" })) keymap("i", "jk", "<ESC>", vim.tbl_extend("force", opts, { desc = "Exit insert mode" }))
-- Stay in indent mode -- Stay in indent mode
keymap("v", "<", "<gv", opts) keymap("v", "<", "<gv", opts)

View File

@ -1,4 +1,5 @@
local neotest_ns = vim.api.nvim_create_namespace("neotest") local neotest_ns = vim.api.nvim_create_namespace("neotest")
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = { virtual_text = {
format = function(diagnostic) format = function(diagnostic)
@ -7,8 +8,33 @@ vim.diagnostic.config({
end, end,
}, },
}, neotest_ns) }, neotest_ns)
require("neotest").setup({
vim.api.nvim_create_user_command("CopyDirectoryPath", function()
local path = vim.fn.expand("%:p:h")
vim.fn.setreg("+", path)
vim.notify('Copied "' .. path .. '" to the clipboard!')
end, {})
local neotest = require("neotest")
neotest.setup({
adapters = { adapters = {
require("neotest-go"), require("neotest-go")({
recursive_run = true,
experimental = {
test_table = true,
},
args = { "-count=1" },
}),
}, },
}) })
vim.api.nvim_create_user_command("RunTest", function()
neotest.run.run()
end, {})
vim.api.nvim_create_user_command("RunTestFile", function()
neotest.run.run(vim.fn.expand('%'))
end, {})