From 08201add5c1b75ac9002bc83d37d6d0bacd46af3 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 21 Feb 2021 21:05:21 +0100 Subject: [PATCH] auto create .combo folder if missing --- plugin/vim-combo.vim | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/plugin/vim-combo.vim b/plugin/vim-combo.vim index c6e0556..9b9b275 100644 --- a/plugin/vim-combo.vim +++ b/plugin/vim-combo.vim @@ -1,27 +1,16 @@ " COMBO Counter " Choose combo file depending on extension -if strlen(expand("%:e")) > 0 - let g:combo_file = $HOME . '/.vim/.combo/' . expand("%:e") . ".cmb" -else - let g:combo_file = $HOME . '/.vim/.combo/none.cmb' + +" Check for a .combo folder, make one if missing +if !isdirectory($HOME . '/.vim/.combo') + silent !mkdir $HOME/.vim/.combo +endif +" Get extension, choose combo file +if strlen(expand("%:e")) > 0 + let g:combo_file = $HOME . '/.vim/.combo/' . expand("%:e") . ".cmb" +else + let g:combo_file = $HOME . '/.vim/.combo/none.cmb' endif - -" Find best score across all filetypes -let scores = [] -for f in split(globpath($HOME . '/.vim/.combo/', '*'), '\n') - let buf = readfile(f) - call insert(scores, buf[0]) -endfor -let g:best_combo_all = max(scores) - -" Checking for ignored extensions -let ignored = ['cmb'] -let g:disable_combo = 0 -for f in ignored - if expand("%:e") == f - let g:disable_combo = 1 - endif -endfor " If file should be ignored, just set text, else continue with script if g:disable_combo