Skip to content

Commit 4852117

Browse files
committed
rewrite to accept user defined extensions/debuggers
1 parent 8331300 commit 4852117

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

plugin/debugger.vim

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1+
if !exists("g:debugger_array")
2+
let g:debugger_array = [["\.rb", "require 'pry'; binding.pry"],
3+
\["\.ex", "require IEx; IEx.pry"],
4+
\["\.erb", "<% require 'pry'; binding.pry %>"],
5+
\["\.eex", "<%= require IEx; IEx.pry %>"],
6+
\["\.json\.jbuilder", "require 'pry'; binding.pry"],
7+
\["\.js$", "debugger;"]]
8+
endif
9+
110
function! Debugging(direction)
2-
let file_path = expand('%')
3-
let file = split(file_path, "/")[-1]
4-
let rb = file =~ "\.rb"
5-
let ex = file =~ "\.ex"
6-
let erb = file =~ "\.erb"
7-
let eex = file =~ "\.eex"
8-
let json = file =~ "\.json\.jbuilder"
9-
let js = file =~ "\.js"
11+
let file = split(expand("%"), "/")[-1]
1012

11-
let @g = a:direction
13+
for array in g:debugger_array
14+
if file =~ array[0]
15+
execute "normal!" a:direction array[1]
16+
let called = 1
17+
else
18+
endif
19+
endfor
1220

13-
if rb
14-
normal! @grequire "pry"; binding.pry
15-
elseif ex
16-
normal! @grequire IEx; IEx.pry
17-
elseif erb
18-
normal! @g<% require "pry"; binding.pry %>
19-
elseif eex
20-
normal! @g<%= require IEx; IEx.pry %>
21-
elseif json
22-
normal! @grequire "pry"; binding.pry
23-
elseif js
24-
normal! @gdebugger;
21+
if called
2522
else
26-
normal! @gCouldn't figure out the debugger type, add support for this file extension
23+
normal! o Couldn't figure out the debugger type, please add an entry for this file extension
2724
endif
2825
endfunction
2926

0 commit comments

Comments
 (0)