From 48f4d9ed213c91e300f4b176a64842ffb9d796f2 Mon Sep 17 00:00:00 2001 From: Klein Florian Date: Tue, 15 Nov 2011 18:05:06 +0100 Subject: [PATCH] initial commit --- README | 3 ++ plugin/stacktrace.vim | 11 ++++++++ plugin/symfonycomplete.vim | 57 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 README create mode 100644 plugin/stacktrace.vim create mode 100644 plugin/symfonycomplete.vim diff --git a/README b/README new file mode 100644 index 0000000..3aa3b8b --- /dev/null +++ b/README @@ -0,0 +1,3 @@ +Symfony2 plugin for ViM + +This plugin handles symfony routing and DIC autocompletion and php stack trace navigation using quickfix list. diff --git a/plugin/stacktrace.vim b/plugin/stacktrace.vim new file mode 100644 index 0000000..7ef824e --- /dev/null +++ b/plugin/stacktrace.vim @@ -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 diff --git a/plugin/symfonycomplete.vim b/plugin/symfonycomplete.vim new file mode 100644 index 0000000..099e24b --- /dev/null +++ b/plugin/symfonycomplete.vim @@ -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