Skip to content

Commit

Permalink
select dsscript; only enable commands in dsscript; bug fix gui launch
Browse files Browse the repository at this point in the history
  • Loading branch information
clavery committed Jul 3, 2017
1 parent 2a3e8b4 commit 373ad10
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 5 deletions.
16 changes: 14 additions & 2 deletions ftdetect/dwre.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
au BufRead *.isml set ft=isml
au BufRead *.ds set ft=javascript
fun! s:SelectDSSCRIPT()
let n = 1
while n < 100 && n <= line("$")
" check for jinja
if getline(n) =~ '\(dw\/\w\{-\}\/\w*\)\|\(guard\.ensure\)\|\(cartridge\/scripts\)'
set ft=dsscript
return
endif
let n = n + 1
endwhile
endfun
autocmd BufNewFile,BufRead *.js call s:SelectDSSCRIPT()
autocmd BufNewFile,BufRead *.isml set ft=isml
autocmd BufNewFile,BufRead *.ds set ft=dsscript
65 changes: 65 additions & 0 deletions ftplugin/dsscript.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
if ( exists('g:loaded_dwre') && g:loaded_dwre ) || v:version < 700 || &cp
fini
en
let g:loaded_dwre = 1

function! AddDwreBreakpoint()
if !exists("g:DWREBreakpoints")
let g:DWREBreakpoints = []
end
let key = expand("%").":".line(".")
if index(g:DWREBreakpoints, key) == -1
call add(g:DWREBreakpoints, key)
end
execute ":sign define dwre text=●"
execute ":sign place 1 line=" . line(".") . " name=dwre file=" . expand("%")
endfunction
function! DelDwreBreakpoint()
if !exists("g:DWREBreakpoints")
let g:DWREBreakpoints = []
end
let key = expand("%").":".line(".")
if index(g:DWREBreakpoints, key) != -1
call remove(g:DWREBreakpoints, key)
end
execute ":sign define dwre text=>"
execute ":sign unplace"
endfunction
function! DwreReset()
let g:DWREBreakpoints = []
execute ":sign define dwre text=>"
execute ":sign unplace *"
endfunction
function! DwreDebug(...)
if !exists("g:DWREBreakpoints")
let g:DWREBreakpoints = []
end
if a:0 == 1
if has("gui_running")
execute ":silent !osascript -e 'tell app \"Terminal\"\do script \"cd " . getcwd() . "; dwre --env " . a:1 . " debug ". join(g:DWREBreakpoints) ."\"\activate\end tell'"
else
execute ":silent !dwre --env " . a:1 . " debug " . join(g:DWREBreakpoints)
execute ":redraw!"
end
elseif a:0 == 2
if has("gui_running")
execute ":silent !osascript -e 'tell app \"Terminal\"\do script \"cd " . getcwd() . "; dwre --project " . a:1 . " --env " . a:2 . " debug ". join(g:DWREBreakpoints) ."\"\activate\end tell'"
else
execute ":silent !dwre --project " . a:1 . " --env " . a:2 . " debug " . join(g:DWREBreakpoints)
execute ":redraw!"
end
else
if has("gui_running")
execute ":silent !osascript -e 'tell app \"Terminal\"\do script \"cd " . getcwd() . "; dwre debug ". join(g:DWREBreakpoints) ."\"\activate\end tell'"
else
execute ":silent !dwre debug " . join(g:DWREBreakpoints)
execute ":redraw!"
end
end
endfunction

command! DWREAdd :call AddDwreBreakpoint()
command! DWREDel :call DelDwreBreakpoint()
command! DWREReset :call DwreReset()
command! -nargs=* DWREDebug :call DwreDebug(<f-args>)

Expand Down
6 changes: 3 additions & 3 deletions plugin/dwre.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ function! DwreDebug(...)
let g:DWREBreakpoints = []
end
if a:0 == 1
if has("gui_macvim")
if has("gui_macvim") && has("gui_running")
execute ":silent !osascript -e 'tell app \"Terminal\"\do script \"cd " . getcwd() . "; dwre --env " . a:1 . " debug ". join(g:DWREBreakpoints) ."\"\activate\end tell'"
else
execute ":silent !dwre --env " . a:1 . " debug " . join(g:DWREBreakpoints)
execute ":redraw!"
end
elseif a:0 == 2
if has("gui_macvim")
if has("gui_macvim") && has("gui_running")
execute ":silent !osascript -e 'tell app \"Terminal\"\do script \"cd " . getcwd() . "; dwre --project " . a:1 . " --env " . a:2 . " debug ". join(g:DWREBreakpoints) ."\"\activate\end tell'"
else
execute ":silent !dwre --project " . a:1 . " --env " . a:2 . " debug " . join(g:DWREBreakpoints)
execute ":redraw!"
end
else
if has("gui_macvim")
if has("gui_macvim") && has("gui_running")
execute ":silent !osascript -e 'tell app \"Terminal\"\do script \"cd " . getcwd() . "; dwre debug ". join(g:DWREBreakpoints) ."\"\activate\end tell'"
else
execute ":silent !dwre debug " . join(g:DWREBreakpoints)
Expand Down
17 changes: 17 additions & 0 deletions syntax/dsscript.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = 'dsscript'
endif

" pull in javascript syntax
runtime! syntax/javascript.vim
runtime! indent/javascript.vim

" if ultisnips is present ensure javascript snippets are loaded
if exists(":UltiSnipsAddFiletypes")
execute "silent UltiSnipsAddFiletypes javascript.dsscript"
end

0 comments on commit 373ad10

Please sign in to comment.