Add node support
This commit is contained in:
parent
2f52caac25
commit
c05655d79d
@ -1,6 +1,9 @@
|
|||||||
|
NOTE: I forked to add node.js support for node 8 and later
|
||||||
|
currently the debugger stops at the first line. I'll fix this eventually. and then see if I can get this merged back into the original
|
||||||
|
|
||||||
|
|
||||||
INTRODUCTION
|
INTRODUCTION
|
||||||
============
|
============
|
||||||
|
|
||||||
Screencast - https://vimeo.com/95775461
|
Screencast - https://vimeo.com/95775461
|
||||||
|
|
||||||
Vebugger is yet another debugger frontend plugin for Vim, created because I
|
Vebugger is yet another debugger frontend plugin for Vim, created because I
|
||||||
@ -21,6 +24,7 @@ interactive shell debugger, and comes with implementations for:
|
|||||||
* Mdbg - a .NET debugger(Windows only)
|
* Mdbg - a .NET debugger(Windows only)
|
||||||
* PDB - a Python module for debugging Python scripts
|
* PDB - a Python module for debugging Python scripts
|
||||||
* RDebug - a Ruby command line option for debugging Ruby scripts
|
* RDebug - a Ruby command line option for debugging Ruby scripts
|
||||||
|
* NInspect - node inspect for using node.js with the inspect protocal (tested with node.8)
|
||||||
|
|
||||||
Other implementations can be added with ease, and I will accept pull requests
|
Other implementations can be added with ease, and I will accept pull requests
|
||||||
that add such implementations as long as they use Vim's |license|.
|
that add such implementations as long as they use Vim's |license|.
|
||||||
|
134
autoload/vebugger/ninspect.vim
Normal file
134
autoload/vebugger/ninspect.vim
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
function! vebugger#ninspect#start(entryFile,args)
|
||||||
|
let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('node',get(a:args,'version'),'node'))
|
||||||
|
\.' inspect '.a:entryFile.' '.vebugger#util#commandLineArgsForProgram(a:args))
|
||||||
|
let l:debugger.state.ninspect={}
|
||||||
|
let l:debugger.state.std.config.externalFileStop_flowCommand='stepover' "skip external modules
|
||||||
|
|
||||||
|
|
||||||
|
call l:debugger.writeLine("$stdout=$stderr")
|
||||||
|
let l:debugger.pipes.err.annotation = "err&prg\t\t"
|
||||||
|
if !has('win32')
|
||||||
|
call vebugger#std#openShellBuffer(l:debugger)
|
||||||
|
endif
|
||||||
|
|
||||||
|
call l:debugger.addReadHandler(function('vebugger#ninspect#_readProgramOutput'))
|
||||||
|
call l:debugger.addReadHandler(function('vebugger#ninspect#_readWhere'))
|
||||||
|
" call l:debugger.addReadHandler(function('vebugger#ninspect#_readEvaluatedExpressions'))
|
||||||
|
call l:debugger.addReadHandler(function('vebugger#ninspect#_readFinish'))
|
||||||
|
|
||||||
|
call l:debugger.setWriteHandler('std','flow',function('vebugger#ninspect#_writeFlow'))
|
||||||
|
call l:debugger.setWriteHandler('std','breakpoints',function('vebugger#ninspect#_writeBreakpoints'))
|
||||||
|
call l:debugger.setWriteHandler('std','evaluateExpressions',function('vebugger#ninspect#_requestEvaluateExpression'))
|
||||||
|
" call l:debugger.setWriteHandler('std','executeStatements',function('vebugger#ninspect#_executeStatements'))
|
||||||
|
call l:debugger.setWriteHandler('std','removeAfterDisplayed',function('vebugger#ninspect#_removeAfterDisplayed'))
|
||||||
|
|
||||||
|
call l:debugger.setWriteHandler('std','closeDebugger',function('vebugger#ninspect#_closeDebugger'))
|
||||||
|
|
||||||
|
call l:debugger.generateWriteActionsFromTemplate()
|
||||||
|
|
||||||
|
call l:debugger.std_addAllBreakpointActions(g:vebugger_breakpoints)
|
||||||
|
|
||||||
|
" Don't stop at the beginning
|
||||||
|
" call l:debugger.writeLine('cont')
|
||||||
|
|
||||||
|
return l:debugger
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_readProgramOutput(pipeName,line,readResult,debugger)
|
||||||
|
if 'err'==a:pipeName
|
||||||
|
let a:readResult.std.programOutput={'line':a:line}
|
||||||
|
else
|
||||||
|
let l:matches=matchlist(a:line,'\v(^........debug\>.............|^........|^)\<\s(.*)$')
|
||||||
|
if 3<len(l:matches)
|
||||||
|
let a:readResult.std.programOutput={'line':l:matches[2]}
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_readWhere(pipeName,line,readResult,debugger)
|
||||||
|
if 'out'==a:pipeName
|
||||||
|
let l:matches=matchlist(a:line,'\vin\s(.*):(\d+)$')
|
||||||
|
|
||||||
|
if 3<len(l:matches)
|
||||||
|
let l:file=l:matches[1]
|
||||||
|
let l:line=str2nr(l:matches[2])
|
||||||
|
let a:readResult.std.location={
|
||||||
|
\'file':(l:file),
|
||||||
|
\'line':(l:line)}
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_readFinish(pipeName,line,readResult,debugger)
|
||||||
|
let l:matches=matchlist(a:line,'\vdebug\>.............\<\sWaiting\sfor\sthe\sdebugger\sto\sdisconnect...')
|
||||||
|
if 1<len(l:matches)
|
||||||
|
let a:readResult.std.programFinish={'finish':1}
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_closeDebugger(writeAction,debugger)
|
||||||
|
call a:debugger.writeLine('kill')
|
||||||
|
sign unplace 1
|
||||||
|
call vebugger#killDebugger()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_writeFlow(writeAction,debugger)
|
||||||
|
if 'stepin'==a:writeAction
|
||||||
|
call a:debugger.writeLine('step')
|
||||||
|
elseif 'stepover'==a:writeAction
|
||||||
|
call a:debugger.writeLine('next')
|
||||||
|
elseif 'stepout'==a:writeAction
|
||||||
|
call a:debugger.writeLine('out')
|
||||||
|
elseif 'continue'==a:writeAction
|
||||||
|
call a:debugger.writeLine('cont')
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_writeBreakpoints(writeAction,debugger)
|
||||||
|
for l:breakpoint in a:writeAction
|
||||||
|
if 'add'==(l:breakpoint.action)
|
||||||
|
call a:debugger.writeLine('sb('''.fnameescape(l:breakpoint.file).''','.l:breakpoint.line.')')
|
||||||
|
elseif 'remove'==l:breakpoint.action
|
||||||
|
call a:debugger.writeLine('cb('.fnameescape(l:breakpoint.file).','.l:breakpoint.line.')')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_requestEvaluateExpression(writeAction,debugger)
|
||||||
|
for l:evalAction in a:writeAction
|
||||||
|
call a:debugger.std_addLineToShellBuffer('Eval: '.l:evalAction.expression)
|
||||||
|
call a:debugger.writeLine('exec console.log(JSON.stringify('.l:evalAction.expression.', null, 2))')
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_executeStatements(writeAction,debugger)
|
||||||
|
for l:evalAction in a:writeAction
|
||||||
|
if has_key(l:evalAction,'statement')
|
||||||
|
call a:debugger.std_addLineToShellBuffer('Execute: '.l:evalAction.expression)
|
||||||
|
call a:debugger.writeLine(l:evalAction.statement)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_readEvaluatedExpressions(pipeName,line,readResult,debugger)
|
||||||
|
if 'out'==a:pipeName
|
||||||
|
let l:matches=matchlist(a:line,'\v^(\d+)\: (.*) \= (.*)$')
|
||||||
|
if 4<len(l:matches)
|
||||||
|
let l:id=str2nr(l:matches[1])
|
||||||
|
let l:expression=l:matches[2]
|
||||||
|
let l:value=l:matches[3]
|
||||||
|
let a:readResult.std.evaluatedExpression={
|
||||||
|
\'id':(l:id),
|
||||||
|
\'expression':(l:expression),
|
||||||
|
\'value':(l:value)}
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#ninspect#_removeAfterDisplayed(writeAction,debugger)
|
||||||
|
for l:removeAction in a:writeAction
|
||||||
|
if has_key(l:removeAction,'id')
|
||||||
|
call a:debugger.writeLine('undisplay '.l:removeAction.id)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
@ -81,6 +81,7 @@ g:vebugger_path_XXX, where XXX is the executable used for the debugger:
|
|||||||
*g:vebugger_path_mdbg* defaults to "Mdbg.exe"
|
*g:vebugger_path_mdbg* defaults to "Mdbg.exe"
|
||||||
*g:vebugger_path_python* defaults to "python"
|
*g:vebugger_path_python* defaults to "python"
|
||||||
*g:vebugger_path_ruby* defaults to "ruby"
|
*g:vebugger_path_ruby* defaults to "ruby"
|
||||||
|
*g:vebugger_path_node* defaults to "node inspect"
|
||||||
|
|
||||||
Notice that for PDB and RDebug you use "python" and "ruby", since the debugger
|
Notice that for PDB and RDebug you use "python" and "ruby", since the debugger
|
||||||
is actually a module bundled in the interpreter.
|
is actually a module bundled in the interpreter.
|
||||||
@ -223,6 +224,21 @@ directory. This will display a list of available processes to attach to.
|
|||||||
Notice that unlike GDB, you need "src" here since Mdbg doesn't display full
|
Notice that unlike GDB, you need "src" here since Mdbg doesn't display full
|
||||||
source file paths.
|
source file paths.
|
||||||
|
|
||||||
|
LAUNCHING NINSPECT *vebugger-ninspect*
|
||||||
|
|
||||||
|
RDebug is launched with *vebugger#ninspect#start*
|
||||||
|
>
|
||||||
|
call vebugger#ninspect#start('test.js',{'args':['hello','world']})
|
||||||
|
<
|
||||||
|
The supported extra arguments are:
|
||||||
|
* "args": Command line arguments for the debugged script
|
||||||
|
* "version": The version of the debugger to run
|
||||||
|
|
||||||
|
NInspect can also be launched with the *VBGstartRDebug* command:
|
||||||
|
>
|
||||||
|
VBGstartNInspect script.js hello world
|
||||||
|
<
|
||||||
|
|
||||||
|
|
||||||
USING THE DEBUGGERS *vebugger-usage* *vebugger-commands*
|
USING THE DEBUGGERS *vebugger-usage* *vebugger-commands*
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ command! -range -nargs=0 VBGrawWriteSelectedText call vebugger#writeLine(vebugge
|
|||||||
command! -nargs=+ -complete=file VBGstartGDB call vebugger#gdb#start([<f-args>][0],{'args':[<f-args>][1:]})
|
command! -nargs=+ -complete=file VBGstartGDB call vebugger#gdb#start([<f-args>][0],{'args':[<f-args>][1:]})
|
||||||
command! -nargs=1 -complete=file VBGattachGDB call vebugger#gdb#searchAndAttach(<q-args>)
|
command! -nargs=1 -complete=file VBGattachGDB call vebugger#gdb#searchAndAttach(<q-args>)
|
||||||
command! -nargs=+ -complete=file VBGstartRDebug call vebugger#rdebug#start([<f-args>][0],{'args':[<f-args>][1:]})
|
command! -nargs=+ -complete=file VBGstartRDebug call vebugger#rdebug#start([<f-args>][0],{'args':[<f-args>][1:]})
|
||||||
|
command! -nargs=+ -complete=file VBGstartNInspect call vebugger#ninspect#start([<f-args>][0],{'args':[<f-args>][1:]})
|
||||||
command! -nargs=+ -complete=file VBGstartPDB call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:]})
|
command! -nargs=+ -complete=file VBGstartPDB call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:]})
|
||||||
command! -nargs=+ -complete=file VBGstartPDB2 call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:],'version':'2'})
|
command! -nargs=+ -complete=file VBGstartPDB2 call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:],'version':'2'})
|
||||||
command! -nargs=+ -complete=file VBGstartPDB3 call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:],'version':'3'})
|
command! -nargs=+ -complete=file VBGstartPDB3 call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:],'version':'3'})
|
||||||
|
Loading…
Reference in New Issue
Block a user