diff --git a/README.md b/README.md index 9674305..49549a3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ INTRODUCTION ============ - Screencast - https://vimeo.com/95775461 Vebugger is yet another debugger frontend plugin for Vim, created because I @@ -22,6 +21,7 @@ interactive shell debugger, and comes with implementations for: * Mdbg - a .NET debugger(Windows only) * PDB - a Python module for debugging Python 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 that add such implementations as long as they use Vim's |license|. diff --git a/autoload/vebugger/ninspect.vim b/autoload/vebugger/ninspect.vim new file mode 100644 index 0000000..1a748c2 --- /dev/null +++ b/autoload/vebugger/ninspect.vim @@ -0,0 +1,202 @@ +function! vebugger#ninspect#attach(connection, args) + let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('node',get(a:args,'version'),'node')) + \.' inspect '.a:connection) + 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') + + let s:programOutputMode=0 + let s:programEvalMode=0 + return l:debugger +endfunction + +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') + let s:programOutputMode=0 + let s:programEvalMode=0 + return l:debugger +endfunction + +function! vebugger#ninspect#_readProgramOutput(pipeName,line,readResult,debugger) + " echom a:line + if 'err'==a:pipeName + let a:readResult.std.programOutput={'line':a:line} + else + let l:donematch=matchlist(a:line,'\vdebug\>.............\<\sWaiting\sfor\sthe\sdebugger\sto\sdisconnect...') + if 1.............|^........|^)\<\s(.*)$') + if 3.............\<\sWaiting\sfor\sthe\sdebugger\sto\sdisconnect...|Error:\sThis\ssocket\shas\sbeen\sended\sby\sthe\sother\sparty') + if 13 + let s:programEvalMode=0 + let l:expression=s:programEvalModeExpression + let l:value=a:line + let a:readResult.std.evaluatedExpression={ + \'expression':(l:expression), + \'value':(l:value)} + endif + endif +endfunction + +function! s:unescapeString(str) + let l:result=a:str + let l:result=substitute(l:result,'\\n','\r','g') + let l:result=substitute(l:result, '\e\[[0-9;]\+[mK]', '', 'g') + return l:result +endfunction diff --git a/doc/vebugger.txt b/doc/vebugger.txt index d119363..cee6412 100644 --- a/doc/vebugger.txt +++ b/doc/vebugger.txt @@ -25,6 +25,7 @@ interactive shell debugger, and comes with implementations for: * Mdbg - a .NET debugger(Windows only) * PDB - a Python module for debugging Python scripts * RDebug - a Ruby command line option for debugging Ruby scripts +* NInspect - Node inspect is a node js 8+ command line debugger 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|. @@ -83,6 +84,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_python* defaults to "python" *g:vebugger_path_ruby* defaults to "ruby" +*g:vebugger_path_node* defaults to "node inspect" Notice that for LLDB, PDB and RDebug you use "python_lldb", "python" and "ruby", since the debugger is actually a module bundled in the interpreter @@ -300,6 +302,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 source file paths. +LAUNCHING NINSPECT *vebugger-ninspect* + +NInspect 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* diff --git a/plugin/vebugger.vim b/plugin/vebugger.vim index 23d7dd5..089968e 100644 --- a/plugin/vebugger.vim +++ b/plugin/vebugger.vim @@ -60,6 +60,7 @@ function! s:attachLLDB(...) endfunction command! -nargs=+ -complete=file VBGattachLLDB call s:attachLLDB() command! -nargs=+ -complete=file VBGstartRDebug call vebugger#rdebug#start([][0],{'args':[][1:]}) +command! -nargs=+ -complete=file VBGstartNInspect call vebugger#ninspect#start([][0],{'args':[][1:]}) command! -nargs=+ -complete=file VBGstartPDB call vebugger#pdb#start([][0],{'args':[][1:]}) command! -nargs=+ -complete=file VBGstartPDB2 call vebugger#pdb#start([][0],{'args':[][1:],'version':'2'}) command! -nargs=+ -complete=file VBGstartPDB3 call vebugger#pdb#start([][0],{'args':[][1:],'version':'3'})