initial commit

This commit is contained in:
Klein Florian 2011-11-15 18:05:06 +01:00
commit 48f4d9ed21
3 changed files with 71 additions and 0 deletions

3
README Normal file
View File

@ -0,0 +1,3 @@
Symfony2 plugin for ViM
This plugin handles symfony routing and DIC autocompletion and php stack trace navigation using quickfix list.

11
plugin/stacktrace.vim Normal file
View File

@ -0,0 +1,11 @@
function! PhpStackTrace()
let errorformat_bak=&errorformat
try
let &errorformat="%f\ |\ %l\ |\ %m"
cexpr join(readfile('/tmp/stack.php'), "\n")
copen
finally
let &errorformat=errorformat_bak
endtry
endfunction

View File

@ -0,0 +1,57 @@
fun! CompleteSymfonyContainer(base, res)
let shellcmd = 'php app/console container:debug'
let output = system(shellcmd)
if v:shell_error
return 0
endif
for m in split(output, "\n")
let row = split(m)
if len(row) == 3
let [service, scope, class] = row
if service =~ '^' . a:base
let menu = 'scope: '. scope .', class: '. class
call add(a:res, { 'word': service, 'menu': menu })
endif
endif
endfor
endfun
fun! CompleteSymfonyRouter(base, res)
let shellcmd = 'php app/console router:debug'
let output = system(shellcmd)
if v:shell_error
return 0
endif
for m in split(output, "\n")
let row = split(m)
if len(row) == 3
let [route, method, url] = row
if route =~ '^' . a:base
let menu = 'method: '. method .', url: '. url
call add(a:res, { 'word': route, 'menu': menu })
endif
endif
endfor
endfun
fun! CompleteSymfony(findstart, base)
if a:findstart
" locate the start of the word
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~ '[a-zA-Z_\-.]'
let start -= 1
endwhile
return start
else
" find symfony services id / routes matching with "a:base"
let res = []
call CompleteSymfonyContainer(a:base, res)
call CompleteSymfonyRouter(a:base, res)
return res
endfun
set completefunc=CompleteSymfony