From d4af3a551d479e8289789f4dc0df9181c25fada7 Mon Sep 17 00:00:00 2001 From: Zackarias Montell Date: Thu, 22 May 2025 07:59:56 +0200 Subject: [PATCH] Python debugging --- AppData/Local/nvim/init.lua | 12 ++++++++- AppData/Local/nvim/lazy-lock.json | 1 + .../nvim/lua/kickstart/plugins/debug.lua | 27 ++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/AppData/Local/nvim/init.lua b/AppData/Local/nvim/init.lua index 1f01467..a548127 100644 --- a/AppData/Local/nvim/init.lua +++ b/AppData/Local/nvim/init.lua @@ -576,7 +576,17 @@ require('lazy').setup({ }, -- C# Csharp roslyn = {}, - pylsp = {}, + pylsp = { + settings = { + pylsp = { + plugins = { + pycodestyle = { + ignore = { 'E501' }, -- ignore line length, let black formatter manage this, sometimes lines must be long. + }, + }, + }, + }, + }, } -- Ensure the servers and tools above are installed diff --git a/AppData/Local/nvim/lazy-lock.json b/AppData/Local/nvim/lazy-lock.json index 162d340..c94f0e8 100644 --- a/AppData/Local/nvim/lazy-lock.json +++ b/AppData/Local/nvim/lazy-lock.json @@ -23,6 +23,7 @@ "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-python": { "branch": "master", "commit": "261ce649d05bc455a29f9636dc03f8cdaa7e0e2c" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, "nvim-lint": { "branch": "master", "commit": "fdb04e9285edefbe25a02a31a35e8fbb10fe054d" }, "nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, diff --git a/AppData/Local/nvim/lua/kickstart/plugins/debug.lua b/AppData/Local/nvim/lua/kickstart/plugins/debug.lua index c205b66..5785ee1 100644 --- a/AppData/Local/nvim/lua/kickstart/plugins/debug.lua +++ b/AppData/Local/nvim/lua/kickstart/plugins/debug.lua @@ -22,8 +22,11 @@ return { 'jay-babu/mason-nvim-dap.nvim', -- Add your own debuggers here - 'leoluz/nvim-dap-go', + 'leoluz/nvim-dap-go', -- came pre-packaged with this + -- Python debugging 'mfussenegger/nvim-dap-python', + -- adds inline variables + 'theHamsta/nvim-dap-virtual-text', }, keys = { -- Basic debugging keymaps, feel free to change to your liking! @@ -69,6 +72,13 @@ return { end, desc = 'Debug: Set Breakpoint', }, + { + '', + function() + require('dap').disconnect { terminate = true } + end, + desc = 'Debug: See last session result.', + }, -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. { '', @@ -77,6 +87,13 @@ return { end, desc = 'Debug: See last session result.', }, + { + 'de', + function() + require('dapui').eval(vim.fn.expand '') + end, + desc = 'Evaluate expression under cursor', + }, }, config = function() local dap = require 'dap' @@ -146,6 +163,14 @@ return { detached = vim.fn.has 'win32' == 0, }, } + -- Setup python debugging require('dap-python').setup 'python' + -- Setup inline variables + require('nvim-dap-virtual-text').setup { + virt_text_pos = 'inline', + virt_lines = true, + highlight_changed_variables = true, + all_frames = false, + } end, }