From 3c97c3757822355ca6c895f32ca8038b5c8fdf00 Mon Sep 17 00:00:00 2001 From: Nick Reynolds Date: Thu, 14 Jul 2011 00:16:44 -0400 Subject: [PATCH] Fixes errors when opening vim without a file arg I threw in a try-catch statement, it was a list index error that goes off when there's a no-name buffer. Also cleans up the Darwin detection now that I've discovered =~ --- plugin/cakephp.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin/cakephp.vim b/plugin/cakephp.vim index 3a78386..89ea129 100644 --- a/plugin/cakephp.vim +++ b/plugin/cakephp.vim @@ -16,7 +16,7 @@ set cpo&vim let s:statusline_modified = 0 let s:DS = '/' -if has('unix') && strpart(system('uname'),0,6) == 'Darwin' +if has('unix') && system('uname') =~ 'Darwin' let s:OS = 'mac' elseif has('unix') let s:OS = 'unix' @@ -155,7 +155,11 @@ endfunction function! s:build_associations(...) let path = expand('%:p') - let name = remove(split(expand('%:r'),s:DS),-1) " Get filename from rel or abs path + try + let name = split(expand('%:r'), s:DS)[-1] " Get filename from rel or abs path + catch + return {} + endtry let ext = expand('%:e') let parent = expand('%:p:h:t') let parent_path = expand('%:p:h')