More changes
This commit is contained in:
@@ -75,9 +75,10 @@ end, { desc = 'Open terminal' })
|
||||
-- Editing helpers
|
||||
vim.keymap.set('i', '<C-O>', '<Esc>o', { desc = 'Add line below' })
|
||||
vim.keymap.set('i', '<C-S-O>', '<Esc>O', { desc = 'Add line above' })
|
||||
vim.keymap.set('i', 'jj', '<Esc>', { desc = 'Exit insert mode' })
|
||||
vim.keymap.set('i', 'jk', '<Esc>', { desc = 'Exit insert mode' })
|
||||
vim.keymap.set('i', 'kk', '<Esc>', { desc = 'Exit insert mode' })
|
||||
local esc_keys = { 'jj', 'jk', 'kk' }
|
||||
for _, key in ipairs(esc_keys) do
|
||||
vim.keymap.set('i', key, '<Esc>', { desc = 'Exit insert mode' })
|
||||
end
|
||||
vim.keymap.set('i', '<C-D>', '<Esc>ddi', { desc = 'Delete line' })
|
||||
vim.keymap.set('i', '<Leader>;', '<Esc>mzA;<Esc>`za', { desc = 'Append a semicolon' })
|
||||
vim.keymap.set('n', '<Leader>;', 'mzA;<Esc>`za', { desc = 'Append a semicolon' })
|
||||
@@ -119,6 +120,60 @@ vim.keymap.set('n', '<Leader>]', '<CMD>cnext<CR>', { desc = 'Next item in quickf
|
||||
vim.keymap.set('n', '<Leader>[', '<CMD>cprevious<CR>', { desc = 'Previous item in quickfix list' })
|
||||
vim.keymap.set('n', 'gd', '<CMD>Telescope lsp_definitions<CR>', { desc = 'Go to definition' })
|
||||
|
||||
local function open_test()
|
||||
require('neotest').summary.open()
|
||||
require('neotest').output_panel.open()
|
||||
end
|
||||
-- Testing
|
||||
local test_maps = {
|
||||
{
|
||||
keys = { '<F12>', '<Leader>tn' },
|
||||
action = function()
|
||||
require('neotest').run.run()
|
||||
open_test()
|
||||
end,
|
||||
desc = 'Run nearest test',
|
||||
},
|
||||
{
|
||||
keys = { '<F9>', '<Leader>ta' },
|
||||
action = function()
|
||||
require('neotest').run.run { suite = true }
|
||||
open_test()
|
||||
end,
|
||||
desc = 'Run all tests in the project',
|
||||
},
|
||||
{
|
||||
keys = { '<F11>', '<Leader>tp' },
|
||||
action = function()
|
||||
require('neotest').run.run_last()
|
||||
open_test()
|
||||
end,
|
||||
desc = 'Run previous test again',
|
||||
},
|
||||
{
|
||||
keys = { '<F10>', '<Leader>td' },
|
||||
action = function()
|
||||
require('neotest').run.run_last { strategy = 'dap' }
|
||||
require('neotest').summary.open() -- Note: Doesn't call open_test() like the others
|
||||
end,
|
||||
desc = 'Run last test with debugger',
|
||||
},
|
||||
}
|
||||
|
||||
for _, map_info in ipairs(test_maps) do
|
||||
for _, key in ipairs(map_info.keys) do
|
||||
vim.keymap.set('n', key, map_info.action, { desc = map_info.desc })
|
||||
end
|
||||
end
|
||||
vim.keymap.set('n', '<Leader>tf', function()
|
||||
require('neotest').run.run(vim.fn.expand '%')
|
||||
open_test()
|
||||
end, { desc = 'Run all tests in the current file' })
|
||||
vim.keymap.set('n', '<Leader>tc', function()
|
||||
require('neotest').summary.close()
|
||||
require('neotest').output_panel.close()
|
||||
end, { desc = 'Close test panels' })
|
||||
|
||||
-- Leaving this commented out, I will try the format command instead
|
||||
-- "A command to properly indent json code
|
||||
-- command! FormatJSON %!python -m json.tool
|
||||
|
||||
Reference in New Issue
Block a user