|
| 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 | + |
1 | 10 | 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] |
10 | 12 |
|
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 |
12 | 20 |
|
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 |
25 | 22 | 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 |
27 | 24 | endif
|
28 | 25 | endfunction
|
29 | 26 |
|
|
0 commit comments