diff options
author | Matthew Lemon <y@yulqen.org> | 2023-04-07 20:56:19 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2023-04-07 20:56:19 +0100 |
commit | 7798ccbe30c3b82ca4ae164eace30f1e82997bc7 (patch) | |
tree | 08c867ed77d96ad119ae83c03bd5f2029ed9baa7 | |
parent | 3fde8747b178ab76788e245419653f3c173a2abc (diff) |
DAP debugging set up - but not as impressive as pdb
This has UI for debugging but it is nothing compared to vim-test and
pdbpp.
Diffstat (limited to '')
-rw-r--r-- | nvim/after/plugin/dap.lua | 30 | ||||
-rw-r--r-- | nvim/after/plugin/neotest-python.lua | 121 | ||||
-rw-r--r-- | nvim/lua/lemon/packer.lua | 2 | ||||
-rw-r--r-- | nvim/plugin/packer_compiled.lua | 10 |
4 files changed, 141 insertions, 22 deletions
diff --git a/nvim/after/plugin/dap.lua b/nvim/after/plugin/dap.lua new file mode 100644 index 0000000..495445f --- /dev/null +++ b/nvim/after/plugin/dap.lua @@ -0,0 +1,30 @@ +local dap = require('dap') +dap.adapters.python = { + type = 'executable'; + command = '.venv/bin/python'; + args = { '-m', 'debugpy.adapter' }; +} + +vim.keymap.set('n', '<F5>', function() require('dap').continue() end) +vim.keymap.set('n', '<F10>', function() require('dap').step_over() end) +vim.keymap.set('n', '<F11>', function() require('dap').step_into() end) +vim.keymap.set('n', '<F12>', function() require('dap').step_out() end) +vim.keymap.set('n', '<F9>', function() require('dap').toggle_breakpoint() end) +vim.keymap.set('n', '<Leader>B', function() require('dap').set_breakpoint() end) +vim.keymap.set('n', '<Leader>lp', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end) +vim.keymap.set('n', '<Leader>dr', function() require('dap').repl.open() end) +vim.keymap.set('n', '<Leader>dl', function() require('dap').run_last() end) +vim.keymap.set({'n', 'v'}, '<Leader>dh', function() + require('dap.ui.widgets').hover() +end) +vim.keymap.set({'n', 'v'}, '<Leader>dp', function() + require('dap.ui.widgets').preview() +end) +vim.keymap.set('n', '<Leader>df', function() + local widgets = require('dap.ui.widgets') + widgets.centered_float(widgets.frames) +end) +vim.keymap.set('n', '<Leader>ds', function() + local widgets = require('dap.ui.widgets') + widgets.centered_float(widgets.scopes) +end) diff --git a/nvim/after/plugin/neotest-python.lua b/nvim/after/plugin/neotest-python.lua index 9df429d..404695b 100644 --- a/nvim/after/plugin/neotest-python.lua +++ b/nvim/after/plugin/neotest-python.lua @@ -1,28 +1,107 @@ require("neotest").setup({ - adapters = { - require("neotest-python")({ - -- Extra arguments for nvim-dap configuration - -- See https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for values - dap = { justMyCode = false }, - -- Command line arguments for runner - -- Can also be a function to return dynamic values - args = {"--log-level", "DEBUG"}, - -- Runner to use. Will use pytest if available by default. - -- Can be a function to return dynamic value. - runner = "pytest", - -- Custom python path for the runner. - -- Can be a string or a list of strings. - -- Can also be a function to return dynamic value. - -- If not provided, the path will be inferred by checking for - -- virtual envs in the local directory and for Pipenev/Poetry configs - python = ".venv/bin/python", - -- Returns if a given file path is a test file. - -- NB: This function is called a lot so don't perform any heavy tasks within it. - }) - } + quickfix = { + open = false, + enabled = false, + }, + status = { + enabled = true, + signs = true, -- Sign after function signature + virtual_text = false + }, + icons = { + child_indent = "│", + child_prefix = "├", + collapsed = "─", + expanded = "╮", + failed = "✘", + final_child_indent = " ", + final_child_prefix = "╰", + non_collapsible = "─", + passed = "✓", + running = "", + running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" }, + skipped = "↓", + unknown = "" + }, + floating = { + border = "rounded", + max_height = 0.9, + max_width = 0.9, + options = {} + }, + summary = { + open = "botright vsplit | vertical resize 60" + }, + highlights = { + adapter_name = "NeotestAdapterName", + border = "NeotestBorder", + dir = "NeotestDir", + expand_marker = "NeotestExpandMarker", + failed = "NeotestFailed", + file = "NeotestFile", + focused = "NeotestFocused", + indent = "NeotestIndent", + marked = "NeotestMarked", + namespace = "NeotestNamespace", + passed = "NeotestPassed", + running = "NeotestRunning", + select_win = "NeotestWinSelect", + skipped = "NeotestSkipped", + target = "NeotestTarget", + test = "NeotestTest", + unknown = "NeotestUnknown" + }, + adapters = { + require("neotest-python")({ + -- Extra arguments for nvim-dap configuration + -- See https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for values + dap = { justMyCode = false }, + -- Command line arguments for runner + -- Can also be a function to return dynamic values + args = {"--log-level", "DEBUG"}, + -- Runner to use. Will use pytest if available by default. + -- Can be a function to return dynamic value. + runner = "pytest", + -- Custom python path for the runner. + -- Can be a string or a list of strings. + -- Can also be a function to return dynamic value. + -- If not provided, the path will be inferred by checking for + -- virtual envs in the local directory and for Pipenev/Poetry configs + python = ".venv/bin/python", + -- Returns if a given file path is a test file. + -- NB: This function is called a lot so don't perform any heavy tasks within it. + }) + }, }) require("neodev").setup({ library = { plugins = { "neotest" }, types = true }, ... }) + +vim.keymap.set("n", "tn", function() + require("neotest").run.run() +end) + +vim.keymap.set("n", "tf", function() + require("neotest").run.run(vim.fn.expand("%")) +end) + +vim.keymap.set("n", "tr", function() + local neotest = require("neotest") + neotest.run.run() + neotest.summary.open() +end, +{ noremap = true, silent = true, nowait = true }) + +vim.keymap.set("n", "to", function() + local neotest = require("neotest") + neotest.output.open({ last_run = true, enter = true }) +end, +{ noremap = true, silent = true, nowait = true }) + +vim.keymap.set("n", "tt", function() + local neotest = require("neotest") + neotest.summary.toggle() +end, +{ noremap = true, silent = true, nowait = true }) diff --git a/nvim/lua/lemon/packer.lua b/nvim/lua/lemon/packer.lua index 4a66fc2..7ef669c 100644 --- a/nvim/lua/lemon/packer.lua +++ b/nvim/lua/lemon/packer.lua @@ -35,11 +35,11 @@ return require('packer').startup(function(use) use({"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}) --- use("theprimeagen/refactoring.nvim") use("mbbill/undotree") use("tpope/vim-fugitive") use("tpope/vim-commentary") use("nvim-treesitter/nvim-treesitter-context"); + use('mfussenegger/nvim-dap') use { 'VonHeikemen/lsp-zero.nvim', diff --git a/nvim/plugin/packer_compiled.lua b/nvim/plugin/packer_compiled.lua index 8ddac8b..430c1c4 100644 --- a/nvim/plugin/packer_compiled.lua +++ b/nvim/plugin/packer_compiled.lua @@ -169,6 +169,16 @@ _G.packer_plugins = { path = "/home/lemon/.local/share/nvim/site/pack/packer/start/nvim-cmp", url = "https://github.com/hrsh7th/nvim-cmp" }, + ["nvim-dap"] = { + loaded = true, + path = "/home/lemon/.local/share/nvim/site/pack/packer/start/nvim-dap", + url = "https://github.com/mfussenegger/nvim-dap" + }, + ["nvim-dap-python"] = { + loaded = true, + path = "/home/lemon/.local/share/nvim/site/pack/packer/start/nvim-dap-python", + url = "https://github.com/mfussenegger/nvim-dap-python" + }, ["nvim-lspconfig"] = { loaded = true, path = "/home/lemon/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", |