Weissle/persistent-breakpoints.nvim

github github
debugging
star 38
stars
alert-circle 0
open issues
users 1
subscribers
git-branch 1
forks
CREATED

2022-07-10

UPDATED

5 days ago


Persistent checkpoints

persistent-breakpoints is a lua plugin for Neovim to save the nvim-dap's checkpoints to file and automatically load them when you open neovim. It is based on the code in here, but has better performance and some bugs are fixed.

:star: Your stars are my biggest motivation.

Install

with packer.nvim

use {'Weissle/persistent-breakpoints.nvim'}

or with vim-plug

Plug 'Weissle/persistent-breakpoints.nvim'

Setup

require('persistent-breakpoints').setup{} -- use default config

Below is the default config, you can change it according to your need.

require('persistent-breakpoints').setup{
    save_dir = vim.fn.stdpath('data') .. '/nvim_checkpoints',
    -- record the performance of different function. run :lua require('persistent-breakpoints.api').print_perf_data() to see the result.
    perf_record = false,
} 

Usage

-- automatically load breakpoints when a file is loaded into the buffer.
vim.api.nvim_create_autocmd({"BufReadPost"},{ callback = require('persistent-breakpoints.api').load_breakpoints })

local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_set_keymap
-- Save breakpoints to file automatically.
keymap("n", "<YourKey1>", "<cmd>lua require('persistent-breakpoints.api').toggle_breakpoint()<cr>", opts)
keymap("n", "<YourKey2>", "<cmd>lua require('persistent-breakpoints.api').set_conditional_breakpoint()<cr>", opts)
keymap("n", "<YourKey3>", "<cmd>lua require('persistent-breakpoints.api').clear_all_breakpoints()<cr>", opts)

:PBToggleBreakpoint

Like :lua require('dap').toggle_breakpoint()

:PBSetConditionalBreakpoint

Like :lua require('dap').set_breakpoint(vim.fn.input('[Condition] > '))

:PBClearAllBreakpoints

Like :lua require('dap').clear_breakpoints()

Issue

  • Unlike Vscode, persistent breakpoints will only be set when the corresponding file is loaded info buffer. But it can save the breakpoints properly even if a buffer with breakpoints have been closed.
  • Like Vscode, if your pwd is /a/b/ and you add breakpoints to file /a/b/c.xx, file /a/b/c.xx's breakpoints are not loaded when your pwd is not /a/b/.
    Therefore, a session manager plugin is recommended.

Other

PR and ISSUE are welcome:

  • Performance improvements.
  • Bug fix
  • Useful and necessary features.