diff --git a/.config/nvim/lua/custom/plugins/barbar.lua b/.config/nvim/lua/custom/plugins/barbar.lua index 5033033c..0e6791ee 100644 --- a/.config/nvim/lua/custom/plugins/barbar.lua +++ b/.config/nvim/lua/custom/plugins/barbar.lua @@ -46,7 +46,7 @@ return { -- Magic buffer-picking mode vim.keymap.set('n', '', 'BufferPick') -- Sort automatically by... - vim.keymap.set('n', 'bb', 'BufferOrderByBufferNumber') + vim.keymap.set('n', 'bn', 'BufferOrderByBufferNumber') vim.keymap.set('n', 'bd', 'BufferOrderByDirectory') vim.keymap.set('n', 'bl', 'BufferOrderByLanguage') vim.keymap.set('n', 'bw', 'BufferOrderByWindowNumber') diff --git a/.config/nvim/lua/custom/plugins/debug.lua b/.config/nvim/lua/custom/plugins/debug.lua index 533d03f9..6c5790b7 100644 --- a/.config/nvim/lua/custom/plugins/debug.lua +++ b/.config/nvim/lua/custom/plugins/debug.lua @@ -18,6 +18,7 @@ return { -- Add your own debuggers here 'leoluz/nvim-dap-go', + 'mfussenegger/nvim-dap-python', 'nvim-neotest/nvim-nio' }, config = function() @@ -47,6 +48,25 @@ return { dap.configurations.typescript = dap.configurations.javascript dap.configurations.typescriptreact = dap.configurations.javascript dap.configurations.javascriptreact = dap.configurations.javascript + local function get_python_path() + if vim.env.VIRTUAL_ENV then + return vim.env.VIRTUAL_ENV .. "/bin/python" + end + return vim.fn.exepath("python3") or vim.fn.exepath("python") or "python" + end + + local python_path = get_python_path() + dap.test_runner = "pytest" + dap.configurations.python = { + { + type = "python", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = vim.fn.getcwd(), + pythonPath = python_path, + }, + } require('mason-nvim-dap').setup { -- Makes a best effort to setup the various debuggers with @@ -70,10 +90,10 @@ return { vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) - vim.keymap.set('n', 'bb', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) - vim.keymap.set('n', 'BB', function() + vim.keymap.set('n', 'bb', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint', }) + vim.keymap.set('n', 'bc', function() dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, { desc = 'Debug: Set Breakpoint' }) + end, { desc = 'Debug: Set Conditional Breakpoint' }) -- Dap UI setup -- For more information, see |:help nvim-dap-ui| @@ -101,10 +121,13 @@ return { vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close + -- dap.listeners.before.event_terminated['dapui_config'] = dapui.close + -- dap.listeners.before.event_exited['dapui_config'] = dapui.close - -- Install golang specific config + -- golang require('dap-go').setup() + + -- python + require("dap-python").setup(python_path) end, }