Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions autoload/nodeinspect.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
" vim: noet
let s:status = 0 " 0 - not started. 1 - started 2 - session ended (bridge exists, node exited) 3 - restarting
let s:plugin_path = expand('<sfile>:h:h')
let s:sign_id = 2
Expand All @@ -6,7 +7,7 @@ let s:sign_group = 'visgroup'
let s:sign_cur_exec = 'vis'
let s:sign_brkpt = 'visbkpt'
let s:breakpoints = {}
let s:session = {}
let s:session = {"watches": {}}
let s:breakpointsUnhandledBuffers = {}
let s:sessionFile = s:plugin_path . '/vim-node-session.json'
let s:msgDelimiter = '&&'
Expand Down Expand Up @@ -128,7 +129,7 @@ function! s:getRemoteFilePath(file)
return a:file
endif
" strip file of its path, add it to the remote
let remoteFile = substitute(a:file, s:session["localRoot"], s:session["remoteRoot"], "")
let remoteFile = substitute(a:file, s:session["localRoot"], s:session["remoteRoot"], "")
return remoteFile
endfunction

Expand Down Expand Up @@ -333,7 +334,7 @@ endfunction
" called when the debug session ended from external job (exec via npm for
" example)
function! nodeinspect#onDebuggerEnded()
call s:onDebuggerHalted()
call s:onDebuggerHalted()
endfunction


Expand Down Expand Up @@ -527,7 +528,7 @@ endfunction

" starts node-inspect. connects to the node bridge.
function! s:NodeInspectStart()
" set configuration defaults
" set configuration defaults
call nodeinspect#config#SetConfigurationDefaults(s:session)
" load configuration. if execution is specified there it shall be used.
" clear configuration in here as it can't be done when passing a variable
Expand Down Expand Up @@ -584,7 +585,7 @@ function! s:NodeInspectStart()
endif
" set the status to running, might be at ended(2)
let s:status = 3
" restarting might need to restart external jobs, if any
" restarting might need to restart external jobs, if any
let repl_result = nodeinspect#repl#StartExternalJobs(s:session)
if repl_result != 0
call nodeinspect#backtrace#ClearBacktraceWindow('node-inspect restart error')
Expand Down Expand Up @@ -613,10 +614,7 @@ function! s:NodeInspectStart()
endif
endif
" redraw the watch window; draws any watches added from the session
for watch in keys(s:session["watches"])
call nodeinspect#watches#AddBulk(s:session["watches"])
endfor

call nodeinspect#watches#AddBulk(s:session["watches"])
endfunction


Expand Down Expand Up @@ -698,7 +696,7 @@ function! nodeinspect#NodeInspectRun(...)
let s:session["script"] = expand('%:p')
let s:session["initialLaunchBreak"] = 1
let s:session["args"] = a:000[:]
call s:NodeInspectStart()
call s:NodeInspectStart()
else
call s:NodeInspectRun()
endif
Expand Down
5 changes: 3 additions & 2 deletions autoload/nodeinspect/backtrace.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
" vim: noet
let s:backtrace_win = -1
let s:backtrace_buf = -1

Expand Down Expand Up @@ -65,14 +66,14 @@ function! nodeinspect#backtrace#ShowBacktraceWindow(startWin)
else
execute "rightb ".winwidth(a:startWin)/3."vnew | setlocal nobuflisted buftype=nofile statusline=Callstack"
endif

let s:backtrace_buf = bufnr('%')
set nonu
else
if g:nodeinspect_window_pos == 'right' || g:nodeinspect_window_pos == 'left'
execute winheight(a:startWin)/3."new | buffer ". s:backtrace_buf
else
execute "rightb ".winwidth(a:startWin)/3."vnew | buffer ". s:backtrace_buf
execute "rightb ".winwidth(a:startWin)/3."vnew | buffer ". s:backtrace_buf
endif
endif
let s:backtrace_win = win_getid()
Expand Down
37 changes: 19 additions & 18 deletions autoload/nodeinspect/config.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
let s:configFileName = 'vim-node-config.json'
" vim: noet
let s:configFileName = 'vim-node-config.json'

function! s:removeSessionKeys(session,...)
for uvar in a:000
Expand All @@ -17,9 +18,9 @@ function! nodeinspect#config#SetConfigurationDefaults(session)
let a:session["cwd"] = getcwd()
let a:session["envFile"] = ""
let a:session["env"] = ""
let a:session["runtimeExecutable"] = ""
let a:session["runtimeArgs"] = []
let a:session["exJob"] = -1
let a:session["runtimeExecutable"] = ""
let a:session["runtimeArgs"] = []
let a:session["exJob"] = -1
endfunction


Expand All @@ -42,7 +43,7 @@ function s:GetConfigFilePath()
if filereadable(configFilePath)
return configFilePath
endif
" if the file is not found in pwd and the script is a decedant, try going up
" if the file is not found in pwd and the script is a decedant, try going up
let expandString = '%:p:h'
let traverseDir = expand(expandString)
while stridx(traverseDir, getcwd()) != -1
Expand Down Expand Up @@ -79,7 +80,7 @@ function! nodeinspect#config#LoadConfigFile(session)
" configPtr holds the used configuration
let configObj = json_decode(fullFile)
let configPtr = v:null
if type(configObj) == v:t_dict
if type(configObj) == v:t_dict
" test wherever its a multi configuration
if has_key(a:session, "configName") == 1 || has_key(configObj,"configurations") == 1
" validation, the first arg must be present and be the config name
Expand All @@ -99,7 +100,7 @@ function! nodeinspect#config#LoadConfigFile(session)
endif
endfor
endif
if type(configPtr) != v:t_dict
if type(configPtr) != v:t_dict
echom "vim-node-inspect - can't find configuration error"
return 1
endif
Expand All @@ -111,10 +112,10 @@ function! nodeinspect#config#LoadConfigFile(session)
let configuration["remoteRoot"] = configPtr["remoteRoot"]
" add trailing backslash if not present. it will normalize both inputs
" in case the user add one with and one without
if configuration["localRoot"][-1:-1] != '/'
if configuration["localRoot"][-1:-1] != '/'
let configuration["localRoot"] = configuration["localRoot"] . '/'
endif
if configuration["remoteRoot"][-1:-1] != '/'
if configuration["remoteRoot"][-1:-1] != '/'
let configuration["remoteRoot"] = configuration["remoteRoot"] . '/'
endif
endif
Expand Down Expand Up @@ -198,17 +199,17 @@ function! nodeinspect#config#LoadConfigFile(session)
endif

if has_key(configPtr,"runtimeArgs") == 1
if type(configPtr["runtimeArgs"]) == 3
let a:session["runtimeArgs"] = configPtr["runtimeArgs"]
else
echom "error reading runtimeArgs in vim-node-inspect"
return 1
endif
if type(configPtr["runtimeArgs"]) == 3
let a:session["runtimeArgs"] = configPtr["runtimeArgs"]
else
echom "error reading runtimeArgs in vim-node-inspect"
return 1
endif
endif

" validate config and setup session
if has_key(configuration, "request") == 1
if configuration["request"] == 'attach'
if has_key(configuration, "request") == 1
if configuration["request"] == 'attach'
if has_key(configuration, "port") == 0
echom "vim-node-inspect config error, attach without a port"
return 1
Expand All @@ -223,7 +224,7 @@ function! nodeinspect#config#LoadConfigFile(session)
endif
endif
endif
if configuration["request"] == 'launch'
if configuration["request"] == 'launch'
if has_key(configuration, "restart") == 1
echom "vim-node-inspect config error, restart in invalid in launch mode"
return 1
Expand Down
Loading