Sha256: 1ab1fbeafc2c7eff5d9b11fc6fa13d697db94faad588ca0c50cbee70ae003742

Contents?: true

Size: 1.65 KB

Versions: 30

Compression:

Stored size: 1.65 KB

Contents

let g:rdb_bps = {}

function SET_BP()
  let signed = sign_getplaced(bufname(), {'lnum': line('.')})
  if empty(signed[0]['signs'])
    call sign_place(0, '', 'signBP', bufname(), {'lnum': line('.')})
  else
    "echo signed[0]['signs']
    call sign_unplace('', {'buffer': bufname(), 'id': signed[0]['signs'][0]['id']})
  endif
endfunction

function UPDATE_BPS()
  let signs = sign_getplaced(bufname())
  let key = expand('%:p')

  if empty(signs[0]['signs'])
    let removed = remove(g:rdb_bps, key)
  else
    let g:rdb_bps[key] = signs[0]['signs']
  endif
endfunction

function APPLY_BPS()
  let key = expand('%:p')
  if has_key(g:rdb_bps, key)
    for b in g:rdb_bps[key]
      call sign_place(0, '', 'signBP', bufname(), {'lnum': b['lnum']})
    endfor
  endif
endfunction

function WRITE_BPS()
  call writefile([json_encode(g:rdb_bps)], '.rdb_breakpoints.json')
endfunction

" load
try
  let json = readfile('.rdb_breakpoints.json')
  let g:rdb_bps = json_decode(json[0])
  " {"/full/path/to/file1": [{"lnum": 10}, ...], ...}
catch /Can't open/
  let g:rdb_bps = {}
catch /Invalid arguments for function json_decode/
  let g:rdb_bps = {}
endtry

sign define signBP text=BR

call APPLY_BPS()

autocmd BufReadPost * call APPLY_BPS()
autocmd BufUnload   * call UPDATE_BPS()
autocmd VimLeave    * call WRITE_BPS()

function! s:ruby_bp_settings() abort
  echomsg "Type <Space> to toggle break points and <q> to quit"

  if &readonly
    nnoremap <silent> <buffer> <Space> :call SET_BP()<CR>
    nnoremap <silent> <buffer> q :<C-u>quit<CR>
  endif
endfunction

" autocmd FileType ruby call s:ruby_bp_settings()
autocmd BufEnter *.rb call s:ruby_bp_settings()

call s:ruby_bp_settings()

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/debug-1.4.0/lib/debug/bp.vim
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/debug-1.4.0/lib/debug/bp.vim
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/debug-1.5.0/lib/debug/bp.vim
debug-1.5.0 lib/debug/bp.vim
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/debug-1.4.0/lib/debug/bp.vim
debug-1.4.0 lib/debug/bp.vim
debug-1.3.4 lib/debug/bp.vim
debug-1.3.3 lib/debug/bp.vim
debug-1.3.2 lib/debug/bp.vim
debug-1.3.1 lib/debug/bp.vim
debug-1.3.0 lib/debug/bp.vim
debug-1.2.4 lib/debug/bp.vim
debug-1.2.3 lib/debug/bp.vim
debug-1.2.2 lib/debug/bp.vim
debug-1.2.1 lib/debug/bp.vim
debug-1.2.0 lib/debug/bp.vim
debug-1.1.0 lib/debug/bp.vim
debug-1.0.0 lib/debug/bp.vim
debug-1.0.0.rc2 lib/debug/bp.vim
debug-1.0.0.rc1 lib/debug/bp.vim